-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
179 lines (141 loc) · 5.57 KB
/
main.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import sys
import time
import yaml
from rich import pretty
from rich.console import Console
from core.cp import format_cp
last_result = None
local_plug_namespace = {}
def get_text_after_input(args):
if "input" in args:
index = args.index("input")
text = " ".join(args[index + 1:])
return text
else:
return None
def get_text_after_plugins(args):
if "plugins" in args:
index = args.index("plugins")
text = args[index + 1]
return text.split(",")
else:
return []
if __name__ == '__main__':
startTime = time.time()
console = Console()
if 'noInspectors' not in sys.argv:
import inspectors
inspectors.init()
if 'noPromptExecutor' not in sys.argv:
from core import executor
executor.initPlugins(get_text_after_plugins(sys.argv))
if 'noPrompt' not in sys.argv:
from prompt_toolkit import PromptSession
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.clipboard.pyperclip import PyperclipClipboard
from prompt_toolkit.completion import NestedCompleter
from prompt_toolkit.history import FileHistory
from prompt_toolkit.lexers import PygmentsLexer
from prompt_toolkit.output import ColorDepth
from prompt_toolkit.shortcuts import CompleteStyle
from prompt_toolkit.styles import Style
from pygments.lexers.python import Python3Lexer
our_history = FileHistory("./mount/.history")
# The history needs to be passed to the `PromptSession`. It can't be passed
# to the `prompt` call because only one history can be used during a
# session.
session = PromptSession(history=our_history)
style = Style.from_dict({
# User input (default text).
'': 'white bold',
# Prompt.
'name': 'ansicyan bold',
'pound': '#00aa00 default',
'user_prompt': 'bold',
'path': 'yellow underline',
})
if 'compact' not in sys.argv:
from frosch import hook, print_exception
import pretty_traceback
import pyfiglet
hook()
pretty.install()
pretty_traceback.install()
ascii_banner = pyfiglet.figlet_format("Taser://")
print(ascii_banner)
console.print(
"Taser Prism is an open source program designed to\nanalyze the source code of android applications")
print("")
with open("data/lib_detect.yml", 'r') as document:
console.print(
f"🗃️️ Known libraries for indexing in code: [orange]{len(yaml.safe_load(document).get('libs').keys())}[/]")
with open("./mount/unicorn.txt", 'r') as document:
console.print(f"🦄 Libraries synchronized: [orange bold]{len(document.readlines())}[/]")
console.print(
"🕔 Runtime is a " + str(round(time.time() - startTime, 2)) + " seconds")
console.print(
"Taser also supports the [red bold]Revisoro[/] utilite to analyze code inheritance out of the box ")
print("")
if 'telnet' in sys.argv:
import adapter.telnet
console.print("🌍 Expansion to the world!!! You use telnet mode. ")
adapter.telnet.main()
if 'input' in sys.argv:
text = get_text_after_input(sys.argv)
executor.input_execute(text)
exit(0)
while True:
try:
message = [
('class:name', "taser"),
('', ':'),
('class:path', f"{format_cp()}"),
('class:pound', '/> '),
('class:user_prompt', ''),
]
if 'noPrompt' not in sys.argv:
text = session.prompt(
message,
lexer=PygmentsLexer(Python3Lexer),
completer=NestedCompleter.from_nested_dict(executor.completer_dict),
style=style,
clipboard=PyperclipClipboard(),
complete_style=CompleteStyle.COLUMN,
enable_history_search=True,
refresh_interval=0.5,
auto_suggest=AutoSuggestFromHistory(),
color_depth=ColorDepth.TRUE_COLOR
)
else:
exit(0)
try:
if text and 'noPromptExecutor' not in sys.argv:
exclude = executor.input_execute(text)
if not isinstance(exclude, list):
if 'noPrompt' not in sys.argv:
console.print(
exclude,
highlight=True,
no_wrap=False,
markup=True
)
else:
print(exclude)
else:
for line in exclude:
if 'noPrompt' not in sys.argv:
console.print(
line,
highlight=True,
no_wrap=False,
markup=True
)
else:
print(line)
except Exception as error:
if 'compact' not in sys.argv:
print_exception(error)
else:
print(error)
except KeyboardInterrupt:
exit(0)