The purpose is to run objdump on selected file, grab output bytes, & format as shellcode.
The program is licensed under GNU Public License v3.0
This program is updated to Python version 3.10.6 on Linux systems with objdump utility. The modules used should already be included in the Python default installation.
- Run the setup.py script to build a virtual environment and install all external packages in the created venv.
Examples:
- Windows:python setup.py venv
- Linux:python3 setup.py venv
- Once virtual env is built traverse to the (Scripts-Windows or bin-Linux) directory in the environment folder just created.
- For Windows, in the venv\Scripts directory, execute
activate
oractivate.bat
script to activate the virtual environment. - For Linux, in the venv/bin directory, execute
source activate
to activate the virtual environment. - If for some reason issues are experienced with the setup script, the alternative is to manually create an environment, activate it, then run pip install -r packages.txt in project root.
- To exit from the virtual environment when finished, execute
deactivate
.
Example:
python3 shellcodeGen.py <executable>
- If arg is not passed, the user is prompted for input
- Selected executable is run in objdump, the output in intel syntax is redirected to a temporary text file
- The text file is then iterated over line by line; grabbing bytes, stripping whitespace, & formatting it as shellcode
- The shellcode formatted for the current line will be appended to a variable
- Once all iterations are complete the temp file is deleted and final shellcode result is provided
-- shellcode_gen.py --
objdump_run - Takes the passed in binary executable, runs objdump utility, and writes the output to file.
print_err - Prints a timed error message via stderr.
prompt_user - Prompt the user for input, handle errors accordingly.
main - Take input file, run in objdump, and parse output into shellcode.
0 - Successful operation
1 - Error occurred during parsing of args in startup
2 - Error occurred writing objdump output to file
3 - Error occurred reading objdump output for parsing shellcode