-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathutils.py
85 lines (70 loc) · 3 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#------------------------------------------------------------------------------
# Virtual Deobfuscator Utility Functions
# author: Jason Raber
# company: HexEffect 2013
# Virtual Deobfuscator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Virtual Deobfuscator is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Virtual Deobfusctor. If not, see http://www.gnu.org/licenses/.
# Notes:
#------------------------------------------------------------------------------
import sys
#------------------------------------------------------------------------------
# Configurables
#------------------------------------------------------------------------------
HEXTRACE = 0
OLLY = 1
IMMUNITY = 2
WINDBG = 3
# Output table formats (i.e. window_sz, line_tbl, cluster_tbl)
DEFAULT_DICT = 1
LIST = 2
BT_ALL_FILE = "all_backtrace.txt"
VALIDATE_FILE = "validate.txt"
FORMATTED_FILE = "rt_formatted.txt"
gen_ids = lambda x: "".join(map(chr, (ord('a')+(y%26) for y in range(x))))
id_round = gen_ids(26) + '0123456789'
divider = "------------------------------------------------------------------" \
"--------------\n"
ST_REG = {"ST(0)": "ST0", "ST(1)": "ST1", "ST(2)": "ST2", \
"ST(3)": "ST3", "ST(4)": "ST4", "ST(5)": "ST5", \
"ST(6)": "ST6", "ST(7)": "ST7", \
"ST," : "ST0,", ",ST ": ",ST0"}
#------------------------------------------------------------------------------
# Error
#------------------------------------------------------------------------------
def vd_error(msg):
print ("\n<!> " + msg)
sys.exit(2)
#------------------------------------------------------------------------------
# Duh!
#------------------------------------------------------------------------------
def is_number_hex(s):
try:
int(s, 16)
return True
except ValueError:
return False
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
#------------------------------------------------------------------------------
# Progress bar
#------------------------------------------------------------------------------
def progress_bar(iterations):
progress_bar.timer += 1
if progress_bar.timer > iterations:
sys.stdout.write(".")
sys.stdout.flush
progress_bar.timer = 0
progress_bar.timer = 0