- 1 year ago
Powershell read shellcode from file
Comment
1 / 1
You can use the Get-Content
cmdlet to read the contents of a file as a string and then convert it to a byte array using the Convert
class. Here's an example PowerShell code snippet that shows how to read shellcode from a file:
powershell# Read the contents of the file as a string
$shellcode = Get-Content -Path "C:\path\to\file.bin" -Encoding Byte -Raw
# Convert the string to a byte array
$bytes = [Convert]::FromBase64String($shellcode)
# Display the byte array
Write-Output $bytes
In this example, the Get-Content
cmdlet reads the contents of the file located at C:\path\to\file.bin
as a raw byte stream. The output is then piped to the Convert
class, which converts the string to a byte array using the FromBase64String
method. Finally, the Write-Output
cmdlet displays the resulting byte array.