Remote addr
This commit is contained in:
parent
382755d58f
commit
a6d76791ad
|
@ -1 +1 @@
|
|||
[{"data": "archtosu@172.23.7.203: x\n", "timestamp": "1681449990"}]
|
||||
[{"data": "archtosu@172.23.7.203: echo hi\n", "timestamp": "1681450590"}, {"data": "archtosu@172.23.7.203: ls\n", "timestamp": "1681450591"}, {"data": "archtosu@172.23.7.203: x\n", "timestamp": "1681450591"}, {"data": "archtosu@172.23.7.203: ls\n", "timestamp": "1681450593"}]
|
|
@ -1 +1 @@
|
|||
[{"data": "start of attack", "timestamp": "1681449990"}, {"data": "command 0: ATTACK", "timestamp": "1681449990"}, {"data": "command 1: ATTACK", "timestamp": "1681449990"}, {"data": "command 2: ATTACK", "timestamp": "1681449990"}, {"data": "command 3: ATTACK", "timestamp": "1681449990"}, {"data": "command 4: ATTACK", "timestamp": "1681449990"}, {"data": "command 5: ATTACK", "timestamp": "1681449990"}, {"data": "command 6: ATTACK", "timestamp": "1681449990"}, {"data": "command 7: ATTACK", "timestamp": "1681449991"}, {"data": "command 8: ATTACK", "timestamp": "1681449991"}, {"data": "command 9: ATTACK", "timestamp": "1681449991"}, {"data": "command 10: ATTACK", "timestamp": "1681449991"}]
|
||||
[{"data": "141.89.221.182: start of attack", "timestamp": "1681450591"}, {"data": "141.89.221.182: command 0: ATTACK", "timestamp": "1681450591"}, {"data": "141.89.221.182: command 1: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 2: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 3: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 4: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 5: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 6: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 7: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 8: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 9: ATTACK", "timestamp": "1681450592"}, {"data": "141.89.221.182: command 10: ATTACK", "timestamp": "1681450593"}]
|
|
@ -1 +0,0 @@
|
|||
1681449990
|
|
@ -1 +1 @@
|
|||
1681449989
|
||||
1681450588
|
|
@ -288,8 +288,11 @@ def api_get_logs():
|
|||
def api_red_logs():
|
||||
global STARTED
|
||||
temp_json_n = request.json
|
||||
print('red log received')
|
||||
print(temp_json_n)
|
||||
if request.environ.get('HTTP_X_FORWARDED_FOR') is None:
|
||||
remote_addr = request.environ['REMOTE_ADDR']
|
||||
else:
|
||||
remote_addr = request.environ['HTTP_X_FORWARDED_FOR']
|
||||
temp_json_n['data'] = remote_addr + ': ' + temp_json_n['data']
|
||||
|
||||
if STARTED:
|
||||
if temp_json_n['data'].lower() == 'start of attack':
|
||||
|
@ -302,17 +305,15 @@ def api_red_logs():
|
|||
with open('./database/logs/red.json', 'w') as f:
|
||||
json.dump(logs_list, f, ensure_ascii=False)
|
||||
|
||||
return 'log saved'
|
||||
return 'log saved\n'
|
||||
else:
|
||||
return 'simulation not started'
|
||||
return 'simulation not started\n'
|
||||
|
||||
@app.route('/api/blue', methods=['POST'])
|
||||
def api_blue_logs():
|
||||
global STARTED
|
||||
temp_json_n = request.json
|
||||
temp_json_n['data'] = b64decode(temp_json_n['data']).decode('utf-8')
|
||||
print('blue log received')
|
||||
print(temp_json_n)
|
||||
|
||||
if STARTED:
|
||||
with open('./database/logs/blue.json') as f:
|
||||
|
@ -321,9 +322,9 @@ def api_blue_logs():
|
|||
with open('./database/logs/blue.json', 'w') as f:
|
||||
json.dump(logs_list, f, ensure_ascii=False)
|
||||
|
||||
return 'log saved'
|
||||
return 'log saved\n'
|
||||
else:
|
||||
return 'simulation not started'
|
||||
return 'simulation not started\n'
|
||||
|
||||
# Error handling
|
||||
@app.errorhandler(401)
|
||||
|
|
Loading…
Reference in New Issue