forked from linuxun1x/dbgwine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbgwine.py
79 lines (69 loc) · 2.37 KB
/
dbgwine.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
import os
import sys
hash_options = {}
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def where_ami():
current = os.getcwd()
with open('channels.txt',"r") as fh:
output = fh.read()
return output
def whats_avaiable(output):
global hash_options
count = 0
str_brkup = output.split("\n")
color = bcolors.OKGREEN
print(f'{bcolors.HEADER}These are the channels avaiable for getting debug logs')
for lines in str_brkup:
hash_options[count]=lines
print(f'{color}{count}){lines} ',end="\t")
count += 1
if count % 10 == 0:
if color == bcolors.OKGREEN:
color = bcolors.OKBLUE
else:
color = bcolors.OKGREEN
if len(lines) > 10:
print("\t\t")
print("")
def get_input(wine_file):
dbgstring = ""
print(f'\n\n{bcolors.OKBLUE}Please enter values you would like to trace seperated by space. i.e. 1 13 22 64')
the_input = input()
the_input_array = the_input.split(" ")
print(f'{bcolors.OKBLUE}{bcolors.UNDERLINE}Ok options ',end="")
for each_space in the_input_array:
print(f' {bcolors.UNDERLINE} {hash_options[int(each_space)]}', end="")
dbgstring += "+" + hash_options[int(each_space)]+", "
print(f' are enabled{bcolors.ENDC}')
try:
wp = "WINEPREFIX="+os.environ["WINEPREFIX"]
except:
wp = ""
print(f'{bcolors.BOLD}I did not find a WINEPREFIX, going with default')
final_str = wp + " WINEDEBUG="+dbgstring+" /usr/bin/wine "+wine_file
print(f'final result{final_str}')
os.system(final_str)
def process_startup():
num_of_args = len(sys.argv)
if num_of_args == 1:
print('I need a windows binary, i.e. dbl.py /home/win/notepad.exe')
try:
wine_file = sys.argv[num_of_args-1]
if os.path.exists(wine_file):
print(f"Hey! We got a winner! using {wine_file}")
return wine_file
except:
print(f'just going to exit, I expected the last argument to be a windows binary, but the path is wrong. Sorry')
sys.exit()
if __name__ == '__main__':
wine_file = process_startup()
whats_avaiable(where_ami())
get_input(wine_file)