forked from Nightbringer21/fridump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
28 lines (24 loc) · 959 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sys
import string
import logging
import os
import re
# Progress bar function
def printProgress (times, total, prefix ='', suffix ='', decimals = 2, bar = 100):
filled = int(round(bar * times / float(total)))
percents = round(100.00 * (times / float(total)), decimals)
bar = '#' * filled + '-' * (bar - filled)
sys.stdout.write('%s [%s] %s%s %s\r' % (prefix, bar, percents, '%', suffix)),
sys.stdout.flush()
if times == total:
print("\n")
# A very basic implementations of Strings
def strings(filename,directory, min=4):
strings_file = os.path.join(directory,"strings.txt")
path = os.path.join(directory,filename)
str_list = re.findall("[A-Za-z0-9/\-:;.,_$%'!()[\]<> \#]+",open(path,"rb").read())
with open(strings_file,"ab") as st:
for string in str_list:
if len(string)>min:
logging.debug(string)
st.write(string+"\n")