diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1377554
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.swp
diff --git a/blueteam/blueteam1.sh b/blueteam/blueteam1.sh
new file mode 100755
index 0000000..c2493e8
--- /dev/null
+++ b/blueteam/blueteam1.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+domain=hackhpi23.timo.one
+
+curl -L https://${domain}/api/red -X POST -H "Content-Type: application/json" -d "{\"data\": \"Start of post-exploitation\", \"timestamp\": \"$(date +%s)\"}"
+
+curl -L https://${domain}/api/blue -X POST -H "Content-Type: application/json" -d "{\"data\": \"Snort: Intrusion Detected!\", \"timestamp\": \"$(date +%s)\"}"
diff --git a/blueteam_observability/.bashrc b/blueteam_observability/.bashrc
new file mode 100644
index 0000000..1c900be
--- /dev/null
+++ b/blueteam_observability/.bashrc
@@ -0,0 +1,12 @@
+##### INFORMATION FOR BLUE TEAM #####
+# DO NOT REMOVE LINES AFTER THIS COMMENT,
+# OTHERWISE MONITORING WILL BREAK
+export PS0='$(__cmd () { hostname | tr -d "\n"; printf "@"; ip -o route get to 8.8.8.8 | sed -n "s/.*src \([0-9.]\+\).*/\1/p" | tr -d "\n"; printf ": "; fc -lnr | head -1 | xargs; }; curl -sL https://hackhpi.kyudev.xyz/api/blue -X POST -H "Content-Type: application/json" -d "{\"data\": \"$(__cmd | base64 -w0)\", \"timestamp\": \"$(date +%s)\"}" >/dev/null & unset -f __cmd)'
+
+ssh () {
+ if [ -n "${@}" ]; then
+ $(type -P ssh) -t "${@}" "export PS0='${PS0}'; bash"
+ else
+ $(type -P ssh)
+ fi
+}
diff --git a/blueteam_observability/mon.sh b/blueteam_observability/mon.sh
index d10c6a5..0684036 100755
--- a/blueteam_observability/mon.sh
+++ b/blueteam_observability/mon.sh
@@ -1,23 +1,24 @@
#!/usr/bin/env bash
BUFFER=buf.txt
-STDOUT=0
+first=0
# Requires sudo, strace and GNU grep
-get-char () {
- cat /dev/stdin |
- grep \
- --line-buffered \
- -o '".*[^"]"' |
+trimxxd () {
+ cat /dev/stdin |
+ sed -e 's/\(0a\|0d\)*$//g' -e 's/^\(0a\|0d\)*//g' -e 's/2020$/20/g'
+}
- grep \
- --line-buffered \
- -o '[^"]*[^"]' |
+get-between () {
+ cat /dev/stdin |
+ grep \
+ --line-buffered \
+ -o '".*[^"]"' |
-while IFS="" read -r char; do
- printf '%b' "$char"
-done
+ grep \
+ --line-buffered \
+ -o '[^"]*[^"]'
}
write-buffer () {
@@ -33,7 +34,10 @@ clear-buffer () {
send-buffer () {
buffer="${1}"
content="$(cat "${BUFFER}" | xxd -ps -c0 | sed -e 's/\(0d\)\?1b5b3f323030346\(8\|c\)//g' -e 's/0d$//g' -e 's/^24//g' | xxd -ps -c0 -r | base64 -w0)"
- curl -sL https://hackhpi.kyudev.xyz/api/blue -X POST -H "Content-Type: application/json" -d "{\"data\": \"${content}\", \"timestamp\": \"$(date +%s)\"}" 1>/dev/null
+ if [ -n "${content}" ]; then
+ echo "{${content}}"
+ # curl -sL https://hackhpi.kyudev.xyz/api/blue -X POST -H "Content-Type: application/json" -d "{\"data\": \"${content}\", \"timestamp\": \"$(date +%s)\"}" 1>/dev/null
+ fi
clear-buffer "${BUFFER}"
}
@@ -46,6 +50,7 @@ clear-buffer "${BUFFER}"
sudo strace \
-e trace=write \
-s 1000 \
+ -f \
$(ps u |
grep pts |
grep Ss |
@@ -54,11 +59,22 @@ sudo strace \
xargs) \
2>&1 |
while IFS="" read -r line; do
+ between="$(printf '%s' "${line}" | get-between)"
fd="$(printf '%s' "${line}" | grep -o 'write(.' | tail -c 2 | head -c 1)"
- if [ "${fd}" = "1" ] || [ ! "${line}" = "${line//SIGCHLD/}" ]; then
- send-buffer "${BUFFER}"
+ if [ "${fd}" = "1" ] || [ "${fd}" = "4" ]; then
+ first=1
+ elif [ "$(printf '%s' "${between}" | wc -c)" -gt 10 ] || [ "${fd}" = "3" ]; then
+ :
else
- printf '%s\n' "${line}" | get-char | write-buffer "${BUFFER}"
+ if [ "${first}" = "1" ]; then
+ first=0
+ send-buffer "${BUFFER}"
+ fi
+ pre_replace="$(printf '%b' "${between}" | xxd -ps -c0 | trimxxd)"
+ replace="$(printf '%s' "${pre_replace}" | sed -e 's/^1b5b3f323030346c/BEGIN/g' -e 's/1b5b3f3230303468.*/AFTER/g')"
+ if [ "${between}" = " " ] ||[ "${between}" = "\n" ] || [ -n "${replace}" ] && [ "${replace}" = "${pre_replace}" ]; then
+ printf '%b' "${between}" | write-buffer "${BUFFER}"
+ fi
fi
done
delete-buffer "${BUFFER}"
diff --git a/webserver/database/logs/blue.json b/webserver/database/logs/blue.json
new file mode 100644
index 0000000..95836ad
--- /dev/null
+++ b/webserver/database/logs/blue.json
@@ -0,0 +1 @@
+[{"data": "archtosu@172.23.7.203: ./auto.sh", "timestamp": "1681451149"}, {"data": "Snort: Intrusion Detected!", "timestamp": "1681451149"}, {"data": "archtosu@172.23.7.203: mv auto.sh blueteam1.sh", "timestamp": "1681451169"}, {"data": "archtosu@172.23.7.203: git s", "timestamp": "1681451171"}, {"data": "archtosu@172.23.7.203: git status", "timestamp": "1681451173"}]
\ No newline at end of file
diff --git a/webserver/database/logs/red.json b/webserver/database/logs/red.json
new file mode 100644
index 0000000..47f38c1
--- /dev/null
+++ b/webserver/database/logs/red.json
@@ -0,0 +1 @@
+[{"data": "141.89.221.182: Start of post-exploitation", "timestamp": "1681451149"}]
\ No newline at end of file
diff --git a/webserver/database/temp/sim_running.txt b/webserver/database/temp/sim_running.txt
new file mode 100644
index 0000000..4791ed5
--- /dev/null
+++ b/webserver/database/temp/sim_running.txt
@@ -0,0 +1 @@
+True
\ No newline at end of file
diff --git a/webserver/database/temp/sim_start.txt b/webserver/database/temp/sim_start.txt
new file mode 100644
index 0000000..a0f9269
--- /dev/null
+++ b/webserver/database/temp/sim_start.txt
@@ -0,0 +1 @@
+1681451148
\ No newline at end of file
diff --git a/webserver/main.py b/webserver/main.py
old mode 100644
new mode 100755
index 6b3b9ca..51f60ae
--- a/webserver/main.py
+++ b/webserver/main.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
import os, datetime, requests, random, json, time, string
from werkzeug.security import generate_password_hash
from werkzeug.utils import secure_filename
@@ -13,7 +15,8 @@ from shutil import copyfile
from werkzeug.middleware.shared_data import SharedDataMiddleware
from oauthlib.oauth2 import WebApplicationClient
from discord_webhook import DiscordWebhook, DiscordEmbed
-from base64 import b64decode
+
+STARTED = 0
app = Flask(__name__)
@@ -25,15 +28,14 @@ app.config.update(
login_manager = LoginManager()
login_manager.init_app(app)
-
class User(UserMixin):
def __init__(self, id):
self.id = id
- self.name = "user" + str(id)
- self.password = self.name + "_secret"
+ self.name = 'user' + str(id)
+ self.password = self.name + '_secret'
def __repr__(self):
- return "%d/%s/%s" % (self.id, self.name, self.password)
+ return '%d/%s/%s' % (self.id, self.name, self.password)
@login_manager.user_loader
def load_user(userid):
@@ -42,125 +44,111 @@ def load_user(userid):
def get_username(self):
return self.username
-
@app.route('/')
def homepage():
- return redirect("/login")
+ return redirect('/login')
-
-@app.route('/login', methods=['GET',"POST"])
+@app.route('/login', methods=['GET', 'POST'])
def login_general():
- if request.method == "POST":
+ if request.method == 'POST':
commit_proper = True
try:
username = request.form['username']
password_login = request.form['password_login']
- if username == "" and password_login == "":
+ if username == '' and password_login == '':
commit_proper = False
except:
commit_proper = False
if commit_proper:
- all_user_files = os.listdir('database/users')
+ all_user_files = os.listdir('./database/users')
matching_user_json = None
for user_now in all_user_files:
- with open(f'database/users/{user_now}/user.json','r') as user_file:
+ with open(f'./database/users/{user_now}/user.json') as user_file:
user_json = json.load(user_file)
- if user_json["username"] == username or str(user_json["email"]).lower() == username.lower():
+ if user_json['username'] == username or str(user_json['email']).lower() == username.lower():
matching_user_json = user_json
if not matching_user_json == None:
- if matching_user_json["password"] == password_login:
- var_user_to_login = User(matching_user_json["userid"])
+ if matching_user_json['password'] == password_login:
+ var_user_to_login = User(matching_user_json['userid'])
login_user(var_user_to_login)
- return redirect("/d1")
+ return redirect('/d1')
else:
- return render_template("login/invalid_credentials_noti.html")
+ return render_template('login/invalid_credentials_noti.html')
else:
- return render_template("login/invalid_credentials_noti.html")
+ return render_template('login/invalid_credentials_noti.html')
else:
- return render_template("login/invalid_credentials_noti.html")
+ return render_template('login/invalid_credentials_noti.html')
else:
- return render_template("login/main_login.html")
+ return render_template('login/main_login.html')
-
-@app.route("/logout", methods=['GET']) #logout
+@app.route('/logout', methods=['GET'])
def cpdashy_logout_main():
try:
logout_user()
except:
pass #prolly not even logged in
- return redirect("/login")
-
-
+ return redirect('/login')
# Main Dashboard start
def extract_time(json):
try:
- return int(int(json['timestamp'].split("m")[0])*60 + int(json['timestamp'].split("m")[1].replace("m","").replace("s","").replace(" ","").replace("&nbp;","")))
+ return json['timestamp']
except KeyError:
return 0
def cpdash_get_sidebar():
- with open('templates/sidebar.html','r') as f:
+ with open('templates/sidebar.html') as f:
sidebar = f.read()
- return(sidebar)
+ return sidebar
-@app.route("/d1", methods=['GET']) #main manager dash
+@app.route('/d1', methods=['GET']) #main manager dash
def cpdashy_1_main():
+ global STARTED
if current_user.is_authenticated:
- userid = str(current_user.name).replace("user","").replace("User","").replace("USER","")
- with open(f'database/users/{userid}/user.json','r') as f:
+ userid = str(current_user.name).replace('user', '').replace('User', '').replace('USER', '')
+ with open(f'./database/users/{userid}/user.json') as f:
user_data = json.load(f)
- if not os.path.exists("database/temp/sim_running.txt"):
- sim_running = "False"
+ if not os.path.exists('./database/temp/sim_running.txt'):
+ sim_running = 'False'
else:
- with open("database/temp/sim_running.txt","r") as f:
+ with open('./database/temp/sim_running.txt') as f:
sim_running = f.read()
- if not os.path.exists("database/temp/sim_start.txt"):
- sim_start_timestamp = "0"
+ if not os.path.exists('./database/temp/sim_start.txt'):
+ sim_start_timestamp = '-1'
+ STARTED = False
else:
- with open("database/temp/sim_start.txt","r") as f:
- sim_start_timestamp_stamp = int(f.read().split(".")[0])
-
- min, sec = divmod(time.time() - int(sim_start_timestamp_stamp),60)
- sim_start_timestamp = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
+ with open('./database/temp/sim_start.txt') as f:
+ sim_start_timestamp = f.read()
+ STARTED = True
-
- if not os.path.exists("database/temp/attack_start.txt"):
- attack_start_timestamp = "0"
+ if not os.path.exists('./database/temp/attack_start.txt'):
+ attack_start_timestamp = '-1'
else:
- with open("database/temp/attack_start.txt","r") as f:
- attack_start_timestamp = int(f.read().split(".")[0])
-
- min, sec = divmod(time.time() - int(attack_start_timestamp),60)
- attack_start_timestamp = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
+ with open('./database/temp/attack_start.txt') as f:
+ attack_start_timestamp = f.read()
-
-
-
- with open("database/logs/blue.json","r") as f:
+ with open('./database/logs/blue.json') as f:
blue_logs_list_ori = json.load(f)
blue_logs_list = []
for blue_log_now in blue_logs_list_ori:
- min, sec = divmod(time.time() - int(blue_log_now["timestamp"]),60)
- blue_log_now["timestamp"] = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
- blue_log_now["origin"] = "blue"
- blue_log_now["timeline_class"] = "container_time_right"
- blue_log_now["timeline_side"] = "right"
+ blue_log_now['timestamp'] = str(int(time.time()))
+ blue_log_now['origin'] = 'blue'
+ blue_log_now['timeline_class'] = 'container_time_right'
+ blue_log_now['timeline_side'] = 'right'
blue_logs_list.append(blue_log_now)
- with open("database/logs/red.json","r") as f:
+ with open('./database/logs/red.json') as f:
red_logs_list_ori = json.load(f)
red_logs_list = []
for red_log_now in red_logs_list_ori:
- min, sec = divmod(time.time() - int(red_log_now["timestamp"]),60)
- red_log_now["timestamp"] = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
- red_log_now["origin"] = "red"
- red_log_now["timeline_class"] = "container_time"
- red_log_now["timeline_side"] = "left"
+ red_log_now['timestamp'] = str(int(time.time()))
+ red_log_now['origin'] = 'red'
+ red_log_now['timeline_class'] = 'container_time'
+ red_log_now['timeline_side'] = 'left'
red_logs_list.append(red_log_now)
total_logs_list = []
@@ -172,66 +160,61 @@ def cpdashy_1_main():
red_logs_list.reverse()
# total_logs_list.reverse()
- return render_template("main/dashboard_main1.html",total_logs_list=total_logs_list,attack_start_timestamp=attack_start_timestamp,blue_logs_list=blue_logs_list,red_logs_list=red_logs_list,sim_running=sim_running,sim_start_timestamp=sim_start_timestamp,sidebar_html_insert=cpdash_get_sidebar().replace("active_state_class1","is-active"), profile_picture=user_data["picture"],profile_username=user_data["username"],profile_userid=user_data["userid"],profile_email=user_data["email"])
+ return render_template('main/dashboard_main1.html', total_logs_list=total_logs_list, attack_start_timestamp=attack_start_timestamp, blue_logs_list=blue_logs_list, red_logs_list=red_logs_list, sim_running=sim_running, sim_start_timestamp=sim_start_timestamp, sidebar_html_insert=cpdash_get_sidebar().replace('active_state_class1', 'is-active'), profile_picture=user_data['picture'], profile_username=user_data['username'], profile_userid=user_data['userid'], profile_email=user_data['email'])
else:
return redirect('/login')
-
-@app.route("/d2", methods=['GET']) #logs
+@app.route('/d2', methods=['GET']) #logs
def cpdashy_2_main():
if current_user.is_authenticated:
- userid = str(current_user.name).replace("user","").replace("User","").replace("USER","")
- with open(f'database/users/{userid}/user.json','r') as f:
+ userid = str(current_user.name).replace('user', '').replace('User', '').replace('USER', '')
+ with open(f'./database/users/{userid}/user.json') as f:
user_data = json.load(f)
- if not os.path.exists("database/temp/sim_running.txt"):
- sim_running = "False"
+ if not os.path.exists('./database/temp/sim_running.txt'):
+ sim_running = 'False'
else:
- with open("database/temp/sim_running.txt","r") as f:
+ with open('./database/temp/sim_running.txt') as f:
sim_running = f.read()
- if not os.path.exists("database/temp/sim_start.txt"):
- sim_start_timestamp = "0"
+ if not os.path.exists('./database/temp/sim_start.txt'):
+ sim_start_timestamp = '0'
else:
- with open("database/temp/sim_start.txt","r") as f:
- sim_start_timestamp_stamp = int(f.read().split(".")[0])
+ with open('./database/temp/sim_start.txt') as f:
+ sim_start_timestamp = int(f.read().split('.')[0])
- min, sec = divmod(time.time() - int(sim_start_timestamp_stamp),60)
- sim_start_timestamp = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
+ min, sec = divmod(int(time.time()) - int(sim_start_timestamp), 60)
+ sim_start_timestamp = str(int(min)) + 'm ' + str(int(round(sec, 0))) + 's'
-
- if not os.path.exists("database/temp/attack_start.txt"):
- attack_start_timestamp = "0"
+ if not os.path.exists('./database/temp/attack_start.txt'):
+ attack_start_timestamp = '0'
else:
- with open("database/temp/attack_start.txt","r") as f:
- attack_start_timestamp = int(f.read().split(".")[0])
+ with open('./database/temp/attack_start.txt') as f:
+ attack_start_timestamp = int(f.read().split('.')[0])
- min, sec = divmod(time.time() - int(attack_start_timestamp),60)
- attack_start_timestamp = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
+ min, sec = divmod(int(time.time()) - int(attack_start_timestamp), 60)
+ attack_start_timestamp = str(int(min)) + 'm ' + str(int(round(sec, 0))) + 's'
-
-
-
- with open("database/logs/blue.json","r") as f:
+ with open('./database/logs/blue.json') as f:
blue_logs_list_ori = json.load(f)
blue_logs_list = []
for blue_log_now in blue_logs_list_ori:
- min, sec = divmod(time.time() - int(blue_log_now["timestamp"]),60)
- blue_log_now["timestamp"] = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
- blue_log_now["origin"] = "blue"
- blue_log_now["timeline_class"] = "container_time_right"
- blue_log_now["timeline_side"] = "right"
+ min, sec = divmod(int(time.time()) - int(blue_log_now['timestamp']), 60)
+ blue_log_now['timestamp'] = str(int(min)) + 'm ' + str(int(round(sec, 0))) + 's'
+ blue_log_now['origin'] = 'blue'
+ blue_log_now['timeline_class'] = 'container_time_right'
+ blue_log_now['timeline_side'] = 'right'
blue_logs_list.append(blue_log_now)
- with open("database/logs/red.json","r") as f:
+ with open('./database/logs/red.json') as f:
red_logs_list_ori = json.load(f)
red_logs_list = []
for red_log_now in red_logs_list_ori:
- min, sec = divmod(time.time() - int(red_log_now["timestamp"]),60)
- red_log_now["timestamp"] = str(int(min)) + "m " + str(int(round(sec,0))) + "s"
- red_log_now["origin"] = "red"
- red_log_now["timeline_class"] = "container_time"
- red_log_now["timeline_side"] = "left"
+ min, sec = divmod(int(time.time()) - int(red_log_now['timestamp']), 60)
+ red_log_now['timestamp'] = str(int(min)) + 'm ' + str(int(round(sec, 0))) + 's'
+ red_log_now['origin'] = 'red'
+ red_log_now['timeline_class'] = 'container_time'
+ red_log_now['timeline_side'] = 'left'
red_logs_list.append(red_log_now)
total_logs_list = []
@@ -243,7 +226,7 @@ def cpdashy_2_main():
red_logs_list.reverse()
total_logs_list.reverse()
- return render_template("main/dashboard_main2.html",total_logs_list=total_logs_list,attack_start_timestamp=attack_start_timestamp,blue_logs_list=blue_logs_list,red_logs_list=red_logs_list,sim_running=sim_running,sim_start_timestamp=sim_start_timestamp,sidebar_html_insert=cpdash_get_sidebar().replace("active_state_class2","is-active"), profile_picture=user_data["picture"],profile_username=user_data["username"],profile_userid=user_data["userid"],profile_email=user_data["email"])
+ return render_template('main/dashboard_main2.html', total_logs_list=total_logs_list, attack_start_timestamp=attack_start_timestamp, blue_logs_list=blue_logs_list, red_logs_list=red_logs_list, sim_running=sim_running, sim_start_timestamp=sim_start_timestamp, sidebar_html_insert=cpdash_get_sidebar().replace('active_state_class2', 'is-active'), profile_picture=user_data['picture'], profile_username=user_data['username'], profile_userid=user_data['userid'], profile_email=user_data['email'])
else:
return redirect('/login')
@@ -281,93 +264,110 @@ def cpdashy_3_main():
else:
return redirect('/login')
-@app.route("/d1/startsim", methods=['GET']) #start and stop the sim
+@app.route('/d1/startsim', methods=['GET']) #start and stop the sim
def cpdashy_startsim():
if current_user.is_authenticated:
- if os.path.exists("database/temp/sim_running.txt"):
- with open("database/temp/sim_running.txt","r") as f:
+ if os.path.exists('./database/temp/sim_running.txt'):
+ with open('./database/temp/sim_running.txt') as f:
current_state = f.read()
- if not current_state == "False":
- with open("database/temp/sim_running.txt","w") as f:
- f.write("False")
+ if not current_state == 'False':
+ with open('./database/temp/sim_running.txt', 'w') as f:
+ f.write('False')
else:
clear_session_full()
- with open("database/temp/sim_start.txt","w") as f:
- f.write(str(time.time()))
- with open("database/temp/sim_running.txt","w") as f:
- f.write("True")
+ with open('./database/temp/sim_start.txt', 'w') as f:
+ f.write(str(int(time.time())))
+ with open('./database/temp/sim_running.txt', 'w') as f:
+ f.write('True')
else:
clear_session_full()
- with open("database/temp/sim_start.txt","w") as f:
- f.write(str(time.time()))
- with open("database/temp/sim_running.txt","w") as f:
- f.write("True")
- return redirect("/d1")
+ with open('./database/temp/sim_start.txt', 'w') as f:
+ f.write(str(int(time.time())))
+ with open('./database/temp/sim_running.txt', 'w') as f:
+ f.write('True')
+ return redirect('/d1')
else:
return redirect('/login')
-
# API
def clear_session_full():
- for file_now in ["database/temp/sim_start.txt","database/temp/attack_start.txt","database/temp/sim_running.txt","database/temp/attack_running.txt"]:
+ for file_now in ['./database/temp/sim_start.txt', './database/temp/attack_start.txt', './database/temp/sim_running.txt', './database/temp/attack_running.txt']:
try:
os.remove(file_now)
except:
pass
- with open("database/logs/red.json","w") as f:
- f.write("[]")
- with open("database/logs/blue.json","w") as f:
- f.write("[]")
+ with open('./database/logs/red.json', 'w') as f:
+ f.write('[]')
+ with open('./database/logs/blue.json', 'w') as f:
+ f.write('[]')
-@app.route("/api/red", methods=['POST'])
+@app.route('/api/logs', methods=['GET'])
+def api_get_logs():
+ with open('./database/logs/red.json') as f:
+ red_raw = f.read()
+ red = json.loads(red_raw)
+ with open('./database/logs/blue.json') as f:
+ blue_raw = f.read()
+ blue = json.loads(blue_raw)
+
+ result = {
+ 'red': red,
+ 'blue': blue
+ }
+ return json.dumps(result, ensure_ascii=False)
+
+@app.route('/api/red', methods=['POST'])
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 temp_json_n["data"].lower() == "start of attack":
- with open("database/temp/attack_start.txt",'w') as f:
- f.write(str(temp_json_n["timestamp"]))
+ if STARTED:
+ if temp_json_n['data'].lower() == 'start of attack':
+ with open('./database/temp/attack_start.txt', 'w') as f:
+ f.write(str(temp_json_n['timestamp']))
- with open("database/logs/red.json","r") as f:
- logs_list = json.load(f)
- logs_list.append(temp_json_n)
- with open("database/logs/red.json","w") as f:
- json.dump(logs_list,f)
+ with open('./database/logs/red.json') as f:
+ logs_list = json.load(f)
+ logs_list.append(temp_json_n)
+ 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\n'
-
-@app.route("/api/blue", methods=['POST'])
+@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").replace("\n","
")
- print("blue log received")
- print(temp_json_n)
-
-
- with open("database/logs/blue.json","r") as f:
- logs_list = json.load(f)
- logs_list.append(temp_json_n)
- with open("database/logs/blue.json","w") as f:
- json.dump(logs_list,f)
-
- return("log saved")
-
+ if STARTED:
+ with open('./database/logs/blue.json') as f:
+ logs_list = json.load(f)
+ logs_list.append(temp_json_n)
+ with open('./database/logs/blue.json', 'w') as f:
+ json.dump(logs_list, f, ensure_ascii=False)
+ return 'log saved\n'
+ else:
+ return 'simulation not started\n'
# Error handling
@app.errorhandler(401)
def custom_401(error):
- return redirect("/")
+ return redirect('/')
@app.errorhandler(404)
def custom_404(error):
- return redirect("/")
+ return redirect('/')
clear_session_full()
if __name__ == '__main__':
- app.run(host='185.78.255.231', threaded=True,use_reloader=True, port=443, ssl_context=('/etc/letsencrypt/live/network.kyudev.xyz/fullchain.pem', '/etc/letsencrypt/live/network.kyudev.xyz/privkey.pem'))
\ No newline at end of file
+ app.run(host='0.0.0.0', threaded=True, use_reloader=True, port=8088)
diff --git a/webserver/templates/main/dashboard_main1.html b/webserver/templates/main/dashboard_main1.html
index 5b535a3..4dc3578 100644
--- a/webserver/templates/main/dashboard_main1.html
+++ b/webserver/templates/main/dashboard_main1.html
@@ -77,7 +77,7 @@
overflow: hidden;
width: 100%;
border-radius: 20px;
- font-size: 15px;
+ font-size: 12px;
font-weight: 500;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
position: relative;
@@ -1303,30 +1303,30 @@