Created
May 30, 2022 11:44
-
-
Save sum-catnip/8d76d922c2eec503d2b19aaea951a46d to your computer and use it in GitHub Desktop.
powershell script that compiles a nasm .asm file (needs BITS32/64 at the start) into a c style array. only dependency is nasm.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
compiles an asm file into a c-style byte array | |
#> | |
param ( | |
# path to asm file | |
[parameter(mandatory=$true)] | |
[string]$path | |
) | |
$nasm = "$env:LOCALAPPDATA\bin\NASM\nasm.exe" | |
if (-not (test-path $nasm)) { | |
write-error "nasm.exe not found in appdata. install nasm for local user to continue." | |
exit 1 | |
} | |
$tempfile = "$env:TEMP\shellcode.bin" | |
& $nasm $path -f bin -o $tempfile | |
'{ ' + ((format-hex $tempfile | select -expand bytes | % { '0x{0:x2}' -f $_ }) -join ', ') + ' }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment