dfirhub

ScheduledTasks

Author: Eric Zimmerman, Reece394

description

Scheduled tasks (*.job and XML)

paths

13 paths
Persistenceat .job
C:\Windows\Tasks\*.job
Persistenceat .job
C:\Windows.old\Windows\Tasks\*.job
Persistenceat SchedLgU.txt
C:\Windows\SchedLgU.txt
Persistenceat SchedLgU.txt
C:\Windows.old\Windows\SchedLgU.txt
PersistenceXML
C:\Windows\System32\Tasks\
PersistenceXML
C:\Windows\syswow64\Tasks\
PersistenceXML
C:\Windows.old\Windows\System32\Tasks\
PersistencePowerShell Scheduled_Jobs
C:\Users\%user%\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\
PersistencePowerShell Scheduled_Jobs Output
C:\Users\%user%\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\*\Output\*\
PersistencePowerShell Scheduled_Jobs Systemprofile
C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\
PersistencePowerShell Scheduled_Jobs Output Systemprofile
C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\*\Output\*\
PersistencePowerShell Scheduled_Jobs WOW64 Systemprofile
C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\
PersistencePowerShell Scheduled_Jobs Output WOW64 Systemprofile
C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\*\Output\*\
paths use Windows environment syntax

collection commands

# PowerShell Artifact Collection Script
# Target: ScheduledTasks
# Run as Administrator

#Requires -RunAsAdministrator

$ErrorActionPreference = "SilentlyContinue"
$DestBase = "D:\Evidence"

# Function to handle directory creation and copying
function Collect-Artifact {
    param (
        [string]$SourcePath,
        [string]$FolderName
    )
    $FullDest = Join-Path -Path $DestBase -ChildPath $FolderName
    if (-not (Test-Path -Path $FullDest)) {
        New-Item -ItemType Directory -Path $FullDest -Force | Out-Null
    }
    Copy-Item -Path $SourcePath -Destination $FullDest -Recurse -Force
}

# 1. at .job
Collect-Artifact -SourcePath "C:\Windows\Tasks\\*.job" -FolderName "at__job"

# 2. at .job
Collect-Artifact -SourcePath "C:\Windows.old\Windows\Tasks\\*.job" -FolderName "at__job"

# 3. at SchedLgU.txt
Collect-Artifact -SourcePath "C:\Windows\\SchedLgU.txt" -FolderName "at_SchedLgU_txt"

# 4. at SchedLgU.txt
Collect-Artifact -SourcePath "C:\Windows.old\Windows\\SchedLgU.txt" -FolderName "at_SchedLgU_txt"

# 5. XML
Collect-Artifact -SourcePath "C:\Windows\System32\Tasks\\*" -FolderName "XML"

# 6. XML
Collect-Artifact -SourcePath "C:\Windows\syswow64\Tasks\\*" -FolderName "XML"

# 7. XML
Collect-Artifact -SourcePath "C:\Windows.old\Windows\System32\Tasks\\*" -FolderName "XML"

# 8. PowerShell Scheduled_Jobs
$UserPath = Join-Path $env:USERPROFILE "AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\"
Collect-Artifact -SourcePath "$UserPath\*" -FolderName "PowerShell_Scheduled_Jobs"

# 9. PowerShell Scheduled_Jobs Output
$UserPath = Join-Path $env:USERPROFILE "AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\*\Output\*\"
Collect-Artifact -SourcePath "$UserPath\*" -FolderName "PowerShell_Scheduled_Jobs_Output"

# 10. PowerShell Scheduled_Jobs Systemprofile
Collect-Artifact -SourcePath "C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\\*" -FolderName "PowerShell_Scheduled_Jobs_Systemprofile"

# 11. PowerShell Scheduled_Jobs Output Systemprofile
Collect-Artifact -SourcePath "C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\*\Output\*\\*" -FolderName "PowerShell_Scheduled_Jobs_Output_Systemprofile"

# 12. PowerShell Scheduled_Jobs WOW64 Systemprofile
Collect-Artifact -SourcePath "C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\\*" -FolderName "PowerShell_Scheduled_Jobs_WOW64_Systemprofile"

# 13. PowerShell Scheduled_Jobs Output WOW64 Systemprofile
Collect-Artifact -SourcePath "C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs\*\Output\*\\*" -FolderName "PowerShell_Scheduled_Jobs_Output_WOW64_Systemprofile"

Write-Host "Collection complete!" -ForegroundColor Green

Save as .ps1 and run as Administrator. Use: powershell -ExecutionPolicy Bypass -File script.ps1

cyberchef recipes

Open in CyberChef to decode values extracted from this artifact.

references

included in collections