Add the CGI File - Ryuretic/SecRev GitHub Wiki
This file must be saved to the directory /var/www/cgi-bin/process_data.py
Modify the permissions for this file:
sudo chmod 705 process_data.py
Create the file and copy the following to the file.
#####################################################################
# Ryuretic: A Modular Framework for RYU #
# !/var/www/cgi-bin/process_data.py #
# Author: #
# Jacob Cox ([email protected]) #
# process_data.py #
# date 12 May 2016 #
#####################################################################
# Copyright (C) 1883 Thomas Edison - All Rights Reserved #
# You may use, distribute and modify this code under the #
# terms of the Ryuretic license, provided this work is cited #
# in the work for which it is used. #
# For latest updates, please visit: #
# https://github.gatech.edu/jcox70/SecRevFrame #
#####################################################################
# This script takes data obtained from /var/www/index.php (mac and #
# passkey) and calls the ClientTable_Handler.py to querry the #
# /var/www/cgi-bin/ClientTable.txt file. If there is a mac and #
# passkey match, then the user is notified that privileges are be- #
# ing restored. #
#####################################################################
#!/usr/bin/env python
import cgi
import cgitb
import sys
sys.path.insert(0,'/home/ubuntu/mininet/examples/SecFrameTest')
from ClientTable_Handler import ClientTable_Handler
cgitb.enable()
def htmlTop():
print("""Content-type:text/html\n\n
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title> Trusted Agent </title>
</head>
<body>
""")
def htmlTail():
print("""</body>
</html>""")
def getData():
formData = cgi.FieldStorage()
mac = formData.getvalue('mac')
passkey = formData.getvalue('passkey')
return mac, passkey
#main program
if __name__ == "__main__":
try:
htmlTop()
mac, passkey = getData()
c_handle = ClientTable_Handler()
found,keyID = c_handle.validate_passkey(mac, passkey)
#need the keyID to be returned
if found == True:
#ICMP_Revocation.revoke_policy(keyID)
c_handle.send_revocation(keyID)
print ("Your passkey is {0}".format(found))
print "<br>"
print("You entered passkey: {0}".format(passkey))
print "<br>"
print("Your MAC is: {0}".format(mac))
htmlTail()
except:
cgi.print_exception()