From 40eb187bca6a985ce7d24b19ac54c47ade285858 Mon Sep 17 00:00:00 2001 From: bitform Date: Mon, 21 Jan 2013 08:33:51 -0500 Subject: Consistency improvements in comment-based help --- Exfiltration/Get-TimedScreenshot.ps1 | 142 ++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 70 deletions(-) (limited to 'Exfiltration') diff --git a/Exfiltration/Get-TimedScreenshot.ps1 b/Exfiltration/Get-TimedScreenshot.ps1 index 3a19a7d..e1c44d0 100644 --- a/Exfiltration/Get-TimedScreenshot.ps1 +++ b/Exfiltration/Get-TimedScreenshot.ps1 @@ -1,99 +1,101 @@ -Function Get-TimedScreenshot { +function Get-TimedScreenshot +{ <# .SYNOPSIS - - Get-TimedScreenshot - - Author: Chris Campbell (@obscuresec) - License: BSD 3-Clause + +Takes screenshots at a regular interval and saves them to disk. + +PowerSploit Function: Get-TimedScreenshot +Author: Chris Campbell (@obscuresec) +License: BSD 3-Clause +Required Dependencies: None +Optional Dependencies: None .DESCRIPTION - A function that takes screenshots and saves them to a folder. +A function that takes screenshots and saves them to a folder. -.PARAMETER $Path +.PARAMETER Path - Specifies the folder path. +Specifies the folder path. -.PARAMETER $Interval +.PARAMETER Interval - Specifies the interval in seconds between taking screenshots. +Specifies the interval in seconds between taking screenshots. -.PARAMETER $EndTime +.PARAMETER EndTime - Specifies when the script should stop running in the format HH-MM +Specifies when the script should stop running in the format HH-MM .EXAMPLE - PS C:\> Get-TimedScreenshot -Path c:\temp\ -Interval 30 -EndTime 14:00 +PS C:\> Get-TimedScreenshot -Path c:\temp\ -Interval 30 -EndTime 14:00 .LINK - http://obscuresecurity.blogspot.com/2013/01/Get-TimedScreenshot.html - https://github.com/obscuresec/random/blob/master/Get-TimedScreenshot - +http://obscuresecurity.blogspot.com/2013/01/Get-TimedScreenshot.html +https://github.com/mattifestation/PowerSploit/blob/master/Exfiltration/Get-TimedScreenshot.ps1 #> [CmdletBinding()] Param( - [Parameter(Mandatory=$True)] - [ValidateScript({Test-Path -Path $_ })] - [string] $Path, - - [Parameter(Mandatory=$True)] - [int32] $Interval, - - [Parameter(Mandatory=$True)] - [string] $EndTime - ) - - #Define helper function that generates and saves screenshot - Function GenScreenshot { - $ScreenBounds = [Windows.Forms.SystemInformation]::VirtualScreen - $ScreenshotObject = New-Object Drawing.Bitmap $ScreenBounds.Width, $ScreenBounds.Height - $DrawingGraphics = [Drawing.Graphics]::FromImage($ScreenshotObject) - $DrawingGraphics.CopyFromScreen( $ScreenBounds.Location, [Drawing.Point]::Empty, $ScreenBounds.Size) - $DrawingGraphics.Dispose() - $ScreenshotObject.Save($FilePath) - $ScreenshotObject.Dispose() - } + [Parameter(Mandatory=$True)] + [ValidateScript({Test-Path -Path $_ })] + [String] $Path, + + [Parameter(Mandatory=$True)] + [Int32] $Interval, + + [Parameter(Mandatory=$True)] + [String] $EndTime + ) + + #Define helper function that generates and saves screenshot + Function GenScreenshot { + $ScreenBounds = [Windows.Forms.SystemInformation]::VirtualScreen + $ScreenshotObject = New-Object Drawing.Bitmap $ScreenBounds.Width, $ScreenBounds.Height + $DrawingGraphics = [Drawing.Graphics]::FromImage($ScreenshotObject) + $DrawingGraphics.CopyFromScreen( $ScreenBounds.Location, [Drawing.Point]::Empty, $ScreenBounds.Size) + $DrawingGraphics.Dispose() + $ScreenshotObject.Save($FilePath) + $ScreenshotObject.Dispose() + } + + Try { + + #load required assembly + Add-Type -Assembly System.Windows.Forms - Try { + Do { + #get the current time and build the filename from it + $Time = (Get-Date) - #load required assembly - Add-Type -Assembly System.Windows.Forms - - Do { - #get the current time and build the filename from it - $Time = (Get-Date) - - [string] $FileName = "$($Time.Month)" - $FileName += '-' - $FileName += "$($Time.Day)" - $FileName += '-' - $FileName += "$($Time.Year)" - $FileName += '-' - $FileName += "$($Time.Hour)" - $FileName += '-' - $FileName += "$($Time.Minute)" - $FileName += '-' - $FileName += "$($Time.Second)" - $FileName += '.png' + [String] $FileName = "$($Time.Month)" + $FileName += '-' + $FileName += "$($Time.Day)" + $FileName += '-' + $FileName += "$($Time.Year)" + $FileName += '-' + $FileName += "$($Time.Hour)" + $FileName += '-' + $FileName += "$($Time.Minute)" + $FileName += '-' + $FileName += "$($Time.Second)" + $FileName += '.png' - #use join-path to add path to filename - [string] $FilePath = (Join-Path $Path $FileName) - - #run screenshot function - GenScreenshot - - Write-Verbose "Saved screenshot to $FilePath. Sleeping for $Interval seconds" + #use join-path to add path to filename + [String] $FilePath = (Join-Path $Path $FileName) - Start-Sleep -Seconds $Interval - } + #run screenshot function + GenScreenshot + + Write-Verbose "Saved screenshot to $FilePath. Sleeping for $Interval seconds" - #note that this will run once regardless if the specified time as passed - While ((Get-Date -Format HH:%m) -lt $EndTime) + Start-Sleep -Seconds $Interval } - Catch {Write-Warning "$Error[0].ToString() + $Error[0].InvocationInfo.PositionMessage"} + #note that this will run once regardless if the specified time as passed + While ((Get-Date -Format HH:%m) -lt $EndTime) + } + Catch {Write-Warning "$Error[0].ToString() + $Error[0].InvocationInfo.PositionMessage"} } \ No newline at end of file -- cgit v1.2.3