-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
51 lines (41 loc) · 1.41 KB
/
app.py
File metadata and controls
51 lines (41 loc) · 1.41 KB
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
"""Flask App"""
from flask import Flask, request, render_template
from options import REGEX_OPTIONS, AVAILABLE_ACTIONS, REGISTERS
app = Flask(__name__)
def format_action(action_name, source, dest, options):
if source == "any":
source = "e[abcds][ipx]"
if dest == "any":
dest = "e[abcds][ipx]"
regexs = [
item.format(source=source, dest=dest) for item in AVAILABLE_ACTIONS[action_name]["regexs"]
]
for option in options:
if option == "no_call":
regexs = [rf"(?!.*call.*){item}" for item in regexs]
if option == "no_large_retn":
regexs = [rf"{item}.*(?:ret[ ]*;|retn 0x00[012][0-9A-F][ ]*;)" for item in regexs]
if option == "no_esp":
regexs = [rf"(?!.*esp.*){item}" for item in regexs]
return {"regexs": regexs, "help": AVAILABLE_ACTIONS[action_name].get("help")}
@app.get("/")
def home_get():
return render_template(
"home.j2",
registers=REGISTERS,
available_actions=AVAILABLE_ACTIONS,
source="eax",
dest="eax",
options=REGEX_OPTIONS,
)
@app.post("/api/get-regexs")
def get_regexs():
data = request.json
selected_action = data["action"]
source = data["source"]
dest = data["dest"]
options = data["options"]
results = format_action(selected_action, source, dest, options)
return {"results": results}
if __name__ == "__main__":
app.run()