Title: Writing Shellcode to a File used in Penetration TestingAuthor: ajayverma
This really is a trivial code snippet, but as with most scripts it comes in handy because it simplifies even a basic task further. Save this to a simple filename like ‘hex2file’ and place it in your /usr/bin directory. Whenever you need to write out hex characters directly to a file use the following syntax.

hex2file 4142434445 > hexfile.bin

Resulting in…

hexdump -C hexfile.bin
00000000 41 42 43 44 45 |ABCDE|
00000005
Here is the snippet.

#!/usr/bin/python

import sys

sys.stdout.write(sys.argv[1].decode('hex'))
Again, trivial – but useful!


Submitted On: 2019-05-30 12:51:28