Skip to content

Instantly share code, notes, and snippets.

@jhawkwind
Last active May 19, 2020 07:23
Show Gist options
  • Select an option

  • Save jhawkwind/78dae54e0108d3661ac9db721ec86fd5 to your computer and use it in GitHub Desktop.

Select an option

Save jhawkwind/78dae54e0108d3661ac9db721ec86fd5 to your computer and use it in GitHub Desktop.
This is used to loop through a directory of "Meaoware", rename them to be executable, and execute; while keeping score.
$FileNum = 0
$Meaoware = 0
$AVEDR = 0
$AllFiles = Get-ChildItem ".\" -File -Name -Exclude *.ps1,*.exe
$TotalFiles = $AllFiles | Measure-Object
$AllFiles | Foreach-Object {
$FileNum++
try{
Write-Output "Now Renaming: $($_) to $($_).exe [$($FileNum) of $($TotalFiles.count)]"
Rename-Item -Path ".\$($_)" -NewName "$($_).exe"
Write-Output "Now Executing: $($_).exe [$($FileNum) of $($TotalFiles.count)]"
Start-Process -FilePath ".\$($_)"
Write-Output "Executed with $($_).exe, Meaoware wins."
$Meaoware++
Add-Content "~\Desktop\Meaoware.win.log" "$($_) was executed and not blocked."
}
catch
{
Write-Output "Execution or rename failed $($_).exe, AV+EDR wins."
$AVEDR++
}
Write-Output "Done with $($_).exe [$($FileNum) of $($TotalFiles.count)]"
Write-Output "SCORE IS NOW: AV+EDR $($AVEDR) v Meaoware $($Meaoware)"
}
Write-Ouput "Script Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment