1
1
import os
2
+ import shutil
2
3
import subprocess
4
+ import gzip
3
5
import time
4
6
from datetime import datetime
5
7
import modules .sha_hashes as sha_hashes
8
+ import modules .utils as utils
6
9
7
10
8
11
class Bcolors :
@@ -111,6 +114,8 @@ def get_acquistion(APP, DEVICE, DATA, callback=None, folder=''):
111
114
USER ) + "--" + datetime .now ().strftime ("%Y%m%d-%H%M%S" ) + ".tar"
112
115
113
116
OUTPUT_FOLDER = FILENAME [:- 4 ]
117
+ #remove \r\n from the string
118
+ OUTPUT_FOLDER = utils .sanitize_filename (OUTPUT_FOLDER )
114
119
if folder != '' :
115
120
OUTPUT_FOLDER = folder + "/" + OUTPUT_FOLDER
116
121
OUTPUT_FILE = OUTPUT_FOLDER + "/" + "sha256_hashes.txt"
@@ -160,13 +165,6 @@ def get_acquistion(APP, DEVICE, DATA, callback=None, folder=''):
160
165
ADB + " " + DEVICE + " shell " + CMD + " tar -cvzf /sdcard/Download/" + FILENAME + " /storage/emulated/0/Android/data/" + APP + END ,
161
166
stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL , shell = SHELL )
162
167
163
- OUTPUT_FOLDER = FILENAME [:- 4 ]
164
- if folder != '' :
165
- OUTPUT_FOLDER = folder + "/" + OUTPUT_FOLDER
166
- OUTPUT_FILE = OUTPUT_FOLDER + "/" + "sha256_hashes.txt"
167
- # create the folder
168
- if not os .path .exists (OUTPUT_FOLDER ):
169
- os .makedirs (OUTPUT_FOLDER )
170
168
# Retrieve the file from the device and save it to the current directory and remove the file from the device
171
169
print_message (callback , "[Info ] Copying to local storage ..." )
172
170
print_message (callback , "[Info ] Compressing " + FILENAME + " ..." )
@@ -185,7 +183,12 @@ def get_acquistion(APP, DEVICE, DATA, callback=None, folder=''):
185
183
186
184
# unzip the file
187
185
print_message (callback , "[Info ] Unzipping file..." )
188
- subprocess .run ("gzip -d " + OUTPUT_FOLDER + "/" + FILENAME + ".gz" , stdout = subprocess .DEVNULL , shell = True )
186
+ #remove \r\n from the string
187
+ FILENAME = utils .sanitize_filename (FILENAME )
188
+ with gzip .open (OUTPUT_FOLDER + "/" + FILENAME + ".gz" , 'rb' ) as f_in :
189
+ with open (OUTPUT_FOLDER + "/" + FILENAME , 'wb' ) as f_out :
190
+ shutil .copyfileobj (f_in , f_out )
191
+
189
192
print_message (callback , "[Info ] Unzip Terminated." )
190
193
# untar the file
191
194
print_message (callback , "[Info ] Untaring file..." )
0 commit comments