Last active
April 2, 2021 11:42
-
-
Save deqline/d3db374bdda0477edabf8aa814fddd24 to your computer and use it in GitHub Desktop.
Generates shellcode from a masm compiled file. Instructions in file comments!.
This file contains hidden or 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
# Create a shellcode.ASM file | |
# the shellcode shall reside in the text segment | |
# compile it using ml64 /c shellcode.ASM | |
# run this file | |
f = open("shellcode.obj", "rb") | |
stream = f.read() | |
SizeOfFileHeader = 0x14 | |
SizeOfBuffer = int.from_bytes(stream[SizeOfFileHeader+0x10:SizeOfFileHeader+0x14], "little") #SizeOfRaw Text segment | |
PtrToRaw = int.from_bytes(stream[SizeOfFileHeader+0x14:SizeOfFileHeader+0x18], "little") #File offset of text segment | |
TextBuffer = stream[PtrToRaw:PtrToRaw+SizeOfBuffer] | |
print("Writing:",TextBuffer) | |
f.close() | |
f1 = open("shellcode.bin", "wb") | |
f1.write(TextBuffer) | |
f1.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment