Last active
August 5, 2019 21:20
-
-
Save zaneGittins/4d87bd62ede0a2f0249506865207a889 to your computer and use it in GitHub Desktop.
StompTime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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