diff --git a/app/options.py b/app/options.py index ed47b848..5a8cf88b 100644 --- a/app/options.py +++ b/app/options.py @@ -23,7 +23,7 @@ if act == "checkrestart": sys.exit() sys.exit() -if form.getvalue('token') is None: +if not sql.check_token_exists(form.getvalue('token')): print("What the fuck?! U r hacker Oo?!") sys.exit() diff --git a/app/sql.py b/app/sql.py index 09f296a9..bb357631 100644 --- a/app/sql.py +++ b/app/sql.py @@ -1369,18 +1369,54 @@ def select_keep_alive(**kwargs): return cur.fetchall() cur.close() con.close() + + +def check_token_exists(token): + try: + import http.cookies + import os + cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) + user_id = cookie.get('uuid') + if get_token(user_id.value) == token: + return True + else: + try: + funct.logging('localhost', ' tried do action with wrong token', haproxywi=1, login=1) + except: + funct.logging('localhost', ' An action with wrong token', haproxywi=1) + return False + except: + try: + funct.logging('localhost', ' cannot check token', haproxywi=1, login=1) + except: + funct.logging('localhost', ' Cannot check token', haproxywi=1) + return False + form = cgi.FieldStorage() error_mess = 'All fields must be completed X' def check_token(): - if form.getvalue('token') is None: + if not check_token_exists(form.getvalue('token')): print('Content-type: text/html\n') - print("What the fuck?! U r hacker Oo?!") + print("What the fuck?! U r hacker Oo?!") import sys sys.exit() - + + +def check_group(group): + import http.cookies + import os + cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE")) + user_id = cookie.get('uuid') + user_group = get_user_group_by_uuid(user_id.value) + if user_group == group or user_group == '1': + return True + else: + funct.logging(new_user, ' tried to change user group', haproxywi=1, login=1) + return False + if form.getvalue('newuser') is not None: email = form.getvalue('newemail') @@ -1394,13 +1430,16 @@ if form.getvalue('newuser') is not None: if password is None or role is None or group is None: print(error_mess) else: - role_id = get_role_id_by_name(role) - if funct.is_admin(level=role_id): - if add_user(new_user, email, password, role, group, activeuser): - show_update_user(new_user, page) - else: - funct.logging(new_user, ' tried to do privilege escalation', haproxywi=1, login=1) - + if check_group(group): + role_id = get_role_id_by_name(role) + if funct.is_admin(level=role_id): + if add_user(new_user, email, password, role, group, activeuser): + show_update_user(new_user, page) + else: + funct.logging(new_user, ' tried to privilege escalation', haproxywi=1, login=1) + + + if form.getvalue('updateuser') is not None: email = form.getvalue('email') role = form.getvalue('role') @@ -1412,12 +1451,14 @@ if form.getvalue('updateuser') is not None: check_token() if new_user is None or role is None or group is None: print(error_mess) - else: - role_id = get_role_id_by_name(role) - if funct.is_admin(level=role_id): - update_user(new_user, email, role, group, id, activeuser) - else: - funct.logging(new_user, ' tried to do privilege escalation', haproxywi=1, login=1) + else: + if check_group(group): + role_id = get_role_id_by_name(role) + if funct.is_admin(level=role_id): + update_user(new_user, email, role, group, id, activeuser) + else: + funct.logging(new_user, ' tried to privilege escalation', haproxywi=1, login=1) + if form.getvalue('updatepassowrd') is not None: @@ -1437,6 +1478,7 @@ if form.getvalue('userdel') is not None: check_token() if delete_user(form.getvalue('userdel')): print("Ok") + if form.getvalue('newserver') is not None: hostname = form.getvalue('servername') @@ -1460,6 +1502,7 @@ if form.getvalue('newserver') is not None: else: if add_server(hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active): show_update_server(ip, page) + if form.getvalue('serverdel') is not None: print('Content-type: text/html\n') @@ -1467,6 +1510,7 @@ if form.getvalue('serverdel') is not None: if delete_server(form.getvalue('serverdel')): delete_waf_server(form.getvalue('serverdel')) print("Ok") + if form.getvalue('newgroup') is not None: newgroup = form.getvalue('groupname') @@ -1479,11 +1523,13 @@ if form.getvalue('newgroup') is not None: if add_group(newgroup, desc): show_update_group(newgroup) + if form.getvalue('groupdel') is not None: print('Content-type: text/html\n') check_token() if delete_group(form.getvalue('groupdel')): print("Ok") + if form.getvalue('updategroup') is not None: name = form.getvalue('updategroup') @@ -1495,6 +1541,7 @@ if form.getvalue('updategroup') is not None: print(error_mess) else: update_group(name, descript, id) + if form.getvalue('updateserver') is not None: name = form.getvalue('updateserver') @@ -1516,6 +1563,7 @@ if form.getvalue('updateserver') is not None: print(error_mess) else: update_server(name, ip, group, typeip, enable, master, id, cred, alert, metrics, port, desc, active) + if form.getvalue('updatessh'): id = form.getvalue('id') @@ -1544,7 +1592,8 @@ if form.getvalue('updatessh'): except: pass update_ssh(id, name, enable, group, username, password) - + + if form.getvalue('new_ssh'): name = form.getvalue('new_ssh') enable = form.getvalue('ssh_enable') @@ -1560,6 +1609,7 @@ if form.getvalue('new_ssh'): else: if insert_new_ssh(name, enable, group, username, password): show_update_ssh(name, page) + if form.getvalue('sshdel') is not None: import funct @@ -1580,6 +1630,7 @@ if form.getvalue('sshdel') is not None: if delete_ssh(form.getvalue('sshdel')): print("Ok") + if form.getvalue('newtelegram'): token = form.getvalue('newtelegram') chanel = form.getvalue('chanel') @@ -1593,12 +1644,14 @@ if form.getvalue('newtelegram'): else: if insert_new_telegram(token, chanel, group): show_update_telegram(token, page) + if form.getvalue('telegramdel') is not None: print('Content-type: text/html\n') check_token() if delete_telegram(form.getvalue('telegramdel')): print("Ok") + if form.getvalue('getoption'): group = form.getvalue('getoption') @@ -1626,7 +1679,8 @@ if form.getvalue('newtoption'): else: if insert_new_option(option, group): show_update_option(option) - + + if form.getvalue('updateoption') is not None: option = form.getvalue('updateoption') id = form.getvalue('id') @@ -1636,6 +1690,7 @@ if form.getvalue('updateoption') is not None: print(error_mess) else: update_options(option, id) + if form.getvalue('optiondel') is not None: print('Content-type: text/html\n') @@ -1675,7 +1730,8 @@ if form.getvalue('newsavedserver'): else: if insert_new_savedserver(savedserver, description, group): show_update_savedserver(savedserver) - + + if form.getvalue('updatesavedserver') is not None: savedserver = form.getvalue('updatesavedserver') description = form.getvalue('description') @@ -1686,12 +1742,14 @@ if form.getvalue('updatesavedserver') is not None: print(error_mess) else: update_savedserver(savedserver, description, id) - + + if form.getvalue('savedserverdel') is not None: print('Content-type: text/html\n') check_token() if delete_savedserver(form.getvalue('savedserverdel')): print("Ok") + if form.getvalue('updatetoken') is not None: token = form.getvalue('updatetoken') @@ -1703,7 +1761,8 @@ if form.getvalue('updatetoken') is not None: print(error_mess) else: update_telegram(token, chanel, group, id) - + + if form.getvalue('updatesettings') is not None: print('Content-type: text/html\n') check_token() diff --git a/app/templates/add.html b/app/templates/add.html index d5a0790f..541c37aa 100644 --- a/app/templates/add.html +++ b/app/templates/add.html @@ -823,6 +823,12 @@ h3 {
In this section you can create, edit and delete options with given parameters. And after use them as autocomplete in the "Add" sections +
+
+ How to use pre saved option you can see in + + this video +
@@ -872,6 +878,12 @@ h3 {
In this section you can create, edit and delete servers. And after use them as autocomplete in the "Add" sections +
+
+ How to use pre saved servers you can see in + + this video +
diff --git a/app/templates/ajax/new_option.html b/app/templates/ajax/new_option.html index 440240a2..01483ea5 100644 --- a/app/templates/ajax/new_option.html +++ b/app/templates/ajax/new_option.html @@ -4,7 +4,7 @@ {{ option.0 }} - + diff --git a/app/templates/ajax/new_saved_servers.html b/app/templates/ajax/new_saved_servers.html index 7b5a2c31..0be108d0 100644 --- a/app/templates/ajax/new_saved_servers.html +++ b/app/templates/ajax/new_saved_servers.html @@ -1,10 +1,10 @@ {% for s in server %} - + - - + + diff --git a/app/templates/base.html b/app/templates/base.html index 8df51c1b..9bf0cff8 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -1,11 +1,28 @@ - + {{title}} - HAproxy-WI - + + + + + + + + + + + + + + + + + + @@ -14,7 +31,7 @@ - + @@ -243,7 +260,7 @@ diff --git a/inc/add.js b/inc/add.js index e0a3f668..3b53100e 100644 --- a/inc/add.js +++ b/inc/add.js @@ -928,6 +928,7 @@ function resetProxySettings() { $('input:checkbox').checkboxradio("refresh"); $('.advance-show').fadeIn(); $('.advance').fadeOut(); + $('[id^=https-hide]').hide(); $('[name=mode').val('http'); $('select').selectmenu('refresh'); replace_text("#optionsInput", ssl_offloading_var); diff --git a/inc/images/favicon/android-icon-144x144.png b/inc/images/favicon/android-icon-144x144.png new file mode 100644 index 00000000..cca19e0d Binary files /dev/null and b/inc/images/favicon/android-icon-144x144.png differ diff --git a/inc/images/favicon/android-icon-192x192.png b/inc/images/favicon/android-icon-192x192.png new file mode 100644 index 00000000..c11c5df1 Binary files /dev/null and b/inc/images/favicon/android-icon-192x192.png differ diff --git a/inc/images/favicon/android-icon-36x36.png b/inc/images/favicon/android-icon-36x36.png new file mode 100644 index 00000000..5b7e8126 Binary files /dev/null and b/inc/images/favicon/android-icon-36x36.png differ diff --git a/inc/images/favicon/android-icon-48x48.png b/inc/images/favicon/android-icon-48x48.png new file mode 100644 index 00000000..25b0c782 Binary files /dev/null and b/inc/images/favicon/android-icon-48x48.png differ diff --git a/inc/images/favicon/android-icon-72x72.png b/inc/images/favicon/android-icon-72x72.png new file mode 100644 index 00000000..a491b1ca Binary files /dev/null and b/inc/images/favicon/android-icon-72x72.png differ diff --git a/inc/images/favicon/android-icon-96x96.png b/inc/images/favicon/android-icon-96x96.png new file mode 100644 index 00000000..719f0b3e Binary files /dev/null and b/inc/images/favicon/android-icon-96x96.png differ diff --git a/inc/images/favicon/apple-icon-114x114.png b/inc/images/favicon/apple-icon-114x114.png new file mode 100644 index 00000000..1696900f Binary files /dev/null and b/inc/images/favicon/apple-icon-114x114.png differ diff --git a/inc/images/favicon/apple-icon-120x120.png b/inc/images/favicon/apple-icon-120x120.png new file mode 100644 index 00000000..23183498 Binary files /dev/null and b/inc/images/favicon/apple-icon-120x120.png differ diff --git a/inc/images/favicon/apple-icon-144x144.png b/inc/images/favicon/apple-icon-144x144.png new file mode 100644 index 00000000..cca19e0d Binary files /dev/null and b/inc/images/favicon/apple-icon-144x144.png differ diff --git a/inc/images/favicon/apple-icon-152x152.png b/inc/images/favicon/apple-icon-152x152.png new file mode 100644 index 00000000..2a2ff2ca Binary files /dev/null and b/inc/images/favicon/apple-icon-152x152.png differ diff --git a/inc/images/favicon/apple-icon-180x180.png b/inc/images/favicon/apple-icon-180x180.png new file mode 100644 index 00000000..e6c7bf94 Binary files /dev/null and b/inc/images/favicon/apple-icon-180x180.png differ diff --git a/inc/images/favicon/apple-icon-57x57.png b/inc/images/favicon/apple-icon-57x57.png new file mode 100644 index 00000000..9abc0a31 Binary files /dev/null and b/inc/images/favicon/apple-icon-57x57.png differ diff --git a/inc/images/favicon/apple-icon-60x60.png b/inc/images/favicon/apple-icon-60x60.png new file mode 100644 index 00000000..30647234 Binary files /dev/null and b/inc/images/favicon/apple-icon-60x60.png differ diff --git a/inc/images/favicon/apple-icon-72x72.png b/inc/images/favicon/apple-icon-72x72.png new file mode 100644 index 00000000..a491b1ca Binary files /dev/null and b/inc/images/favicon/apple-icon-72x72.png differ diff --git a/inc/images/favicon/apple-icon-76x76.png b/inc/images/favicon/apple-icon-76x76.png new file mode 100644 index 00000000..c49e93c1 Binary files /dev/null and b/inc/images/favicon/apple-icon-76x76.png differ diff --git a/inc/images/favicon/apple-icon-precomposed.png b/inc/images/favicon/apple-icon-precomposed.png new file mode 100644 index 00000000..8d5a0c80 Binary files /dev/null and b/inc/images/favicon/apple-icon-precomposed.png differ diff --git a/inc/images/favicon/apple-icon.png b/inc/images/favicon/apple-icon.png new file mode 100644 index 00000000..8d5a0c80 Binary files /dev/null and b/inc/images/favicon/apple-icon.png differ diff --git a/inc/images/favicon/browserconfig.xml b/inc/images/favicon/browserconfig.xml new file mode 100644 index 00000000..c5541482 --- /dev/null +++ b/inc/images/favicon/browserconfig.xml @@ -0,0 +1,2 @@ + +#ffffff \ No newline at end of file diff --git a/inc/images/favicon/favicon-16x16.png b/inc/images/favicon/favicon-16x16.png new file mode 100644 index 00000000..e23e8f30 Binary files /dev/null and b/inc/images/favicon/favicon-16x16.png differ diff --git a/inc/images/favicon/favicon-32x32.png b/inc/images/favicon/favicon-32x32.png new file mode 100644 index 00000000..b0432ffe Binary files /dev/null and b/inc/images/favicon/favicon-32x32.png differ diff --git a/inc/images/favicon/favicon-96x96.png b/inc/images/favicon/favicon-96x96.png new file mode 100644 index 00000000..719f0b3e Binary files /dev/null and b/inc/images/favicon/favicon-96x96.png differ diff --git a/inc/images/favicon/favicon.ico b/inc/images/favicon/favicon.ico new file mode 100644 index 00000000..27d6b383 Binary files /dev/null and b/inc/images/favicon/favicon.ico differ diff --git a/inc/images/favicon/manifest.json b/inc/images/favicon/manifest.json new file mode 100644 index 00000000..013d4a6a --- /dev/null +++ b/inc/images/favicon/manifest.json @@ -0,0 +1,41 @@ +{ + "name": "App", + "icons": [ + { + "src": "\/android-icon-36x36.png", + "sizes": "36x36", + "type": "image\/png", + "density": "0.75" + }, + { + "src": "\/android-icon-48x48.png", + "sizes": "48x48", + "type": "image\/png", + "density": "1.0" + }, + { + "src": "\/android-icon-72x72.png", + "sizes": "72x72", + "type": "image\/png", + "density": "1.5" + }, + { + "src": "\/android-icon-96x96.png", + "sizes": "96x96", + "type": "image\/png", + "density": "2.0" + }, + { + "src": "\/android-icon-144x144.png", + "sizes": "144x144", + "type": "image\/png", + "density": "3.0" + }, + { + "src": "\/android-icon-192x192.png", + "sizes": "192x192", + "type": "image\/png", + "density": "4.0" + } + ] +} \ No newline at end of file diff --git a/inc/images/favicon/ms-icon-144x144.png b/inc/images/favicon/ms-icon-144x144.png new file mode 100644 index 00000000..cca19e0d Binary files /dev/null and b/inc/images/favicon/ms-icon-144x144.png differ diff --git a/inc/images/favicon/ms-icon-150x150.png b/inc/images/favicon/ms-icon-150x150.png new file mode 100644 index 00000000..ece92c0b Binary files /dev/null and b/inc/images/favicon/ms-icon-150x150.png differ diff --git a/inc/images/favicon/ms-icon-310x310.png b/inc/images/favicon/ms-icon-310x310.png new file mode 100644 index 00000000..cf55f743 Binary files /dev/null and b/inc/images/favicon/ms-icon-310x310.png differ diff --git a/inc/images/favicon/ms-icon-70x70.png b/inc/images/favicon/ms-icon-70x70.png new file mode 100644 index 00000000..a829c94a Binary files /dev/null and b/inc/images/favicon/ms-icon-70x70.png differ diff --git a/inc/images/loading.gif b/inc/images/loading.gif new file mode 100644 index 00000000..cac2113c Binary files /dev/null and b/inc/images/loading.gif differ diff --git a/inc/metrics.js b/inc/metrics.js index 64808c9a..b7624f1b 100644 --- a/inc/metrics.js +++ b/inc/metrics.js @@ -7,10 +7,8 @@ function getChartData(server) { token: $('#token').val() }, type: "GET", - success: function (result) { - + success: function (result) { var data = []; - data.push(result.chartData.curr_con); data.push(result.chartData.curr_ssl_con); data.push(result.chartData.sess_rate); @@ -133,9 +131,20 @@ function renderWafChart(data, labels, server) { $("#secIntervals").css("display", "none"); function loadMetrics() { - $.get( "options.py?table_metrics=1&token="+$('#token').val(), function( data ) { - $( "#table_metrics" ).html( data ); - }); + $.ajax({ + url: "options.py", + data: { + table_metrics: '1', + token: $('#token').val() + }, + beforeSend: function() { + $('#table_metrics').prepend('') + }, + type: "GET", + success: function (data) { + $( "#table_metrics" ).html( data ); + } + }); } diff --git a/inc/script.js b/inc/script.js index 2d10d8af..6c4d8bf6 100644 --- a/inc/script.js +++ b/inc/script.js @@ -198,6 +198,9 @@ function showOverview() { act: "overview", token: $('#token').val() }, + beforeSend: function() { + $('#ajaxstatus').html('') + }, type: "GET", success: function( data ) { $("#ajaxstatus").empty(); @@ -218,6 +221,9 @@ function showOverviewServer(name,ip,id) { page: 'hapservers.py', token: $('#token').val() }, + beforeSend: function() { + $("#ajax-server-"+id).html('') + }, type: "GET", success: function( data ) { $("#ajax-server-"+id).empty(); @@ -255,6 +261,14 @@ function showOverviewWaf() { page: cur_url[0], token: $('#token').val() }, + beforeSend: function() { + if (cur_url[0] == "waf.py") { + var load_class = 'loading_full_page' + } else { + var load_class = 'loading' + } + $('#ajaxwafstatus').html('') + }, type: "GET", success: function( data ) { $("#ajaxwafstatus").empty(); @@ -277,6 +291,9 @@ function showOverviewServers() { act: "overviewServers", token: $('#token').val() }, + beforeSend: function() { + $('#ajaxservers').html('') + }, type: "GET", success: function( data ) { $("#ajaxservers").html(data); @@ -290,6 +307,9 @@ function showOverviewHapWI() { act: "overviewHapwi", token: $('#token').val() }, + beforeSend: function() { + $('#ajaxHapwi').html('') + }, type: "GET", success: function( data ) { $("#ajaxHapwi").html(data); @@ -307,7 +327,7 @@ function showStats() { type: "GET", success: function( data ) { $("#ajax").html(data); - // window.history.pushState("Stats", "Stats", cur_url[0]+"?serv="+$("#serv").val()); + window.history.pushState("Stats", "Stats", cur_url[0]+"?serv="+$("#serv").val()); wait(); } } ); diff --git a/inc/style.css b/inc/style.css index f9daf602..c80b6bfd 100644 --- a/inc/style.css +++ b/inc/style.css @@ -309,7 +309,7 @@ pre { font-size: 13px !important; } .advance-show a{ - color: #9d9d9d !important; + color: #23527c !important; } .addButton { padding-top: 15px; @@ -810,6 +810,10 @@ label { #logo_span { margin-left: 17%; } + .chart-container { + height: 290px; + width: 32.4%; + } } @media (max-width: 1080px) { #logo_span { @@ -869,3 +873,23 @@ label { max-width: 95%; } } +.loading, .loading_full_page, .loading_hapwi_overview { + width: 100px; + height: 100px; + margin-left: 100%; +} +.loading_full_page { + margin-left: 45%; +} +.loading_hapwi_overview{ + margin-left: 40%; +} +.tooltip { + font-size: 12px; + padding-bottom: 10px; +} +.tooltipTop { + margin-bottom: -20px; + padding-top: 10px; + color: #9d9d9d; +} diff --git a/inc/users.js b/inc/users.js index 75ec2ad7..946fae3c 100644 --- a/inc/users.js +++ b/inc/users.js @@ -770,7 +770,8 @@ function cloneServer(id) { $('#slavefor').selectmenu("refresh"); $('#credentials').val($('#credentials-'+id+' option:selected').val()).change() $('#credentials').selectmenu("refresh"); - if (cur_url[0] == 'users.py') { + cur_url = cur_url[0].split('#')[0] + if (cur_url == 'users.py') { $('#new-server-group-add').val($('#servergroup-'+id+' option:selected').val()).change() $('#new-server-group-add').selectmenu("refresh"); } @@ -785,7 +786,8 @@ function cloneUser(id) { $('#activeuser').checkboxradio("refresh"); $('#new-role').val($('#role-'+id+' option:selected').val()).change() $('#new-role').selectmenu("refresh"); - if (cur_url[0] == 'users.py') { + cur_url = cur_url[0].split('#')[0] + if (cur_url == 'users.py') { $('#new-group').val($('#usergroup-'+id+' option:selected').val()).change(); $('#new-group').selectmenu("refresh"); } @@ -1191,7 +1193,6 @@ function changeUserPasswordDialog(id) { effect: "fade", duration: 200 }, - // beforeClose: function( event, ui ) {return changeUserPassword(id);}, buttons: { "Change": function() { changeUserPassword(id, $(this));