Skip to content

Add "Local Job Scheduling" attack technique (T1168) #683

Closed

Description

@shreyamalviya

T1168

Job scheduling can be used by adversaries to schedule running malicious code at some specified date and time.

Adding it as a PBA:
- LINUX: There are multiple methods supported by Linux for creating pre-scheduled and periodic background jobs.

  • at: not all systems have at so skip this (or check if it exists and then proceed?)
  • cron: attempt to add some file with some command (commented) to /etc/cron.hourly directory then delete it

- WINDOWS: not applicable (T1053)

Mapping the technique to the ATT&CK matrix

Activity

  1. self-assigned this
    on Jun 8, 2020
  2. acepace commented on Jun 8, 2020

    @acepace
    Contributor

    Cron is pretty much always there, we can rely on it. It also has per user abilities so we don't need to run as root to run it.
    But why not applicable in Windows? Ah, that's because in Windows it's T1053

    Last, how will we handle leftovers? Are we leaving a command running in the victim PC till end of time? What command will we leave?

  3. shreyamalviya commented on Jun 9, 2020

    @shreyamalviya
    ContributorAuthor

    It also has per user abilities so we don't need to run as root to run it.

    I can't add files to /etc/cron.* without root permissions. I can edit crontab using crontab -e but how would I do that in a single command? When we're using cronab -e, it creates a temporary copy of the crontab file in /tmp which is edited and then runs some checks before installing it to the actual crontab file (see this).

    About the command to leave, we can just leave in a comment in the file we're editing so nothing will run.

  4. acepace commented on Jun 9, 2020

    @acepace
    Contributor

    Can you explain further? Cron files can exist for per users, I assume there's a command or a file to be created.

  5. shreyamalviya commented on Jun 9, 2020

    @shreyamalviya
    ContributorAuthor

    Cron files exist per user under /var/spool/cron/crontab/. While the file itself is accessible by the user (since the user is the owner), the user doesn't have access to the directory that it is a part of, so the user can't write to the file without root permission.

    But as a user, you can use crontab -e to edit the file. This creates a temporary copy of /var/spool/cron/crontab/myusername in /tmp which the user can edit, and before adding the changes to the actual cron file, some checks are run on it.

    However, given that using crontab -e creates a temporary copy of the cron file to edit, how would we make changes to it using just a command? It creates a file with a random name under /tmp which we can't know beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FeatureIssue that describes a new feature to be implemented.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions