Skip to content

Commit 0077f39

Browse files
committed
Bug fix, Windows not supports gizp, changed for the GZIP lib instead of subprocess
1 parent 7f05c8c commit 0077f39

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

acquisitionGUI.spec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ a = Analysis(
1919
cipher=block_cipher,
2020
noarchive=False,
2121
)
22-
a.datas += [('labcif.png','./img/labcif.png','DATA')]
2322
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
2423

2524
exe = EXE(
@@ -36,11 +35,10 @@ exe = EXE(
3635
upx=True,
3736
upx_exclude=[],
3837
runtime_tmpdir=None,
39-
console=False,
38+
console=True,
4039
disable_windowed_traceback=False,
4140
argv_emulation=False,
4241
target_arch=None,
4342
codesign_identity=None,
4443
entitlements_file=None,
45-
icon='./img/labcif.ico'
4644
)

modules/adb_acquistion.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import os
2+
import shutil
23
import subprocess
4+
import gzip
35
import time
46
from datetime import datetime
57
import modules.sha_hashes as sha_hashes
8+
import modules.utils as utils
69

710

811
class Bcolors:
@@ -111,6 +114,8 @@ def get_acquistion(APP, DEVICE, DATA, callback=None, folder=''):
111114
USER) + "--" + datetime.now().strftime("%Y%m%d-%H%M%S") + ".tar"
112115

113116
OUTPUT_FOLDER = FILENAME[:-4]
117+
#remove \r\n from the string
118+
OUTPUT_FOLDER = utils.sanitize_filename(OUTPUT_FOLDER)
114119
if folder != '':
115120
OUTPUT_FOLDER = folder + "/" + OUTPUT_FOLDER
116121
OUTPUT_FILE = OUTPUT_FOLDER + "/" + "sha256_hashes.txt"
@@ -160,13 +165,6 @@ def get_acquistion(APP, DEVICE, DATA, callback=None, folder=''):
160165
ADB + " " + DEVICE + " shell " + CMD + " tar -cvzf /sdcard/Download/" + FILENAME + " /storage/emulated/0/Android/data/" + APP + END,
161166
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=SHELL)
162167

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)
170168
# Retrieve the file from the device and save it to the current directory and remove the file from the device
171169
print_message(callback, "[Info ] Copying to local storage ...")
172170
print_message(callback, "[Info ] Compressing " + FILENAME + " ...")
@@ -185,7 +183,12 @@ def get_acquistion(APP, DEVICE, DATA, callback=None, folder=''):
185183

186184
# unzip the file
187185
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+
189192
print_message(callback, "[Info ] Unzip Terminated.")
190193
# untar the file
191194
print_message(callback, "[Info ] Untaring file...")

modules/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import re
2+
3+
4+
def sanitize_filename(filename):
5+
# Define a regular expression pattern to match invalid characters
6+
invalid_chars_pattern = r'[\/:*?"<>|\\]|[\r\n]'
7+
8+
# Replace invalid characters with underscores
9+
sanitized_filename = re.sub(invalid_chars_pattern, '', filename)
10+
11+
return sanitized_filename

0 commit comments

Comments
 (0)