Skip to content

Commit

Permalink
Add ObfuscateImport arguments to ConvertToShellcode.py
Browse files Browse the repository at this point in the history
  • Loading branch information
coldfusion39 committed Oct 5, 2019
1 parent eaf2f0b commit a820757
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Python/ConvertToShellcode.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import argparse
from ShellcodeRDI import *

__version__ = '1.1'
__version__ = '1.2'

def main():
parser = argparse.ArgumentParser(description='RDI Shellcode Converter', conflict_handler='resolve')
parser.add_argument('-v', '--version', action='version', version='%(prog)s Version: ' + __version__)
parser.add_argument('input_dll', help='DLL to convert to shellcode')
parser.add_argument('-f', '--function-name', dest='function_name', default='SayHello', help='The function to call after DllMain')
parser.add_argument('-c', '--clear-header', dest='clear_header', action="store_true", help='Clear the PE header on load')
parser.add_argument('-f', '--function-name', dest='function_name', help='The function to call after DllMain', default='SayHello')
parser.add_argument('-u', '--user-data', dest='user_data', help='Data to pass to the target function', default='dave')
parser.add_argument('-c', '--clear-header', dest='clear_header', action='store_true', help='Clear the PE header on load')
parser.add_argument('-i', '--obfuscate-imports', dest='obfuscate_imports', action='store_true', help='Randomize import dependency load order', default=False)
parser.add_argument('-d', '--import-delay', dest='import_delay', help='Number of seconds to pause between loading imports', type=int, default=0)
arguments = parser.parse_args()

input_dll = arguments.input_dll
Expand All @@ -22,7 +25,10 @@ def main():
if arguments.clear_header:
flags |= 0x1

converted_dll = ConvertToShellcode(dll, HashFunctionName(arguments.function_name), b'dave', flags)
if arguments.obfuscate_imports:
flags = flags | 0x4 | arguments.import_delay << 16

converted_dll = ConvertToShellcode(dll, HashFunctionName(arguments.function_name), arguments.user_data.encode(), flags)

with open(output_bin, 'wb') as f:
f.write(converted_dll)
Expand Down

0 comments on commit a820757

Please sign in to comment.