-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructered the servers and introduced a parent class
started the reimplementation of the web interface as flask webapp
- Loading branch information
Showing
9 changed files
with
233 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Server: | ||
|
||
def start_server(self): | ||
raise NotImplementedError("ABSTRACT METHOD") | ||
|
||
def stop_server(self): | ||
raise NotImplementedError("ABSTRACT METHOD") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
__author__ = 'susperius' | ||
|
||
import logging | ||
import gevent | ||
from gevent import pywsgi | ||
from server import Server | ||
|
||
|
||
class WebServer: | ||
def __init__(self, port, task_queue, web_main_function): | ||
class WebServer(Server): | ||
def __init__(self, port, web_main_function): | ||
self._port = port | ||
self._serving = False | ||
self._serving_greenlet = None | ||
self._web_server = None | ||
self._logger = logging.getLogger(__name__) | ||
self._task_queue = task_queue | ||
self._web_main_function = web_main_function | ||
|
||
def __serve(self): | ||
self._logger.info("[WebServer] initialized on port " + str(self._port) + " ...") | ||
self._web_server = pywsgi.WSGIServer(('', self._port), self._web_main_function) | ||
self._web_server.serve_forever() | ||
|
||
def serve(self): | ||
def start_server(self): | ||
if not self._serving: | ||
self._serving_greenlet = gevent.spawn(self.__serve) | ||
self._serving = True | ||
gevent.sleep(0) | ||
else: | ||
pass | ||
|
||
def stop_server(self): | ||
if self._serving: | ||
gevent.kill(self._serving_greenlet) | ||
self._serving = False | ||
self._web_server.close() | ||
self._logger.info("[WebServer] shut down") | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from flask import Flask, render_template, send_file | ||
from gevent.queue import Queue | ||
|
||
|
||
class WebInterface(): | ||
def __init__(self, web_queue): | ||
self._web_queue = web_queue | ||
self.app = Flask(__name__) | ||
self.app.add_url_rule("/", "index", self.index_site) | ||
|
||
def index_site(self): | ||
return render_template("index.html") | ||
|
||
if __name__ == "__main__": | ||
intf = WebInterface(Queue()) | ||
intf.app.run("127.0.0.1", 5000, debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Created by susperius on 11.07.15. | ||
*/ | ||
|
||
FUZZERS; | ||
|
||
|
||
function changeFuzzer(){ | ||
var x = -1; | ||
var fuzz_table = document.getElementById("fuzz_table"); | ||
var old_inputs = document.getElementById("fuzz_config"); | ||
var new_inputs = document.createElement("div"); | ||
var fuzz_select = document.getElementById("fuzzers"); | ||
new_inputs.id = "fuzz_config"; | ||
for(i=0; i<fuzzers.length; i+=2){ | ||
if(fuzzers[i] == fuzz_select.value){ | ||
x = i + 1; | ||
} | ||
} | ||
|
||
for(i=0; i<fuzzers[x].length; i++){ | ||
var input = document.createElement("input"); | ||
input.type = "text"; | ||
input.name = fuzzers[x][i]; | ||
new_inputs.appendChild(input); | ||
} | ||
old_inputs.parentNode.replaceChild(new_inputs, old_inputs); | ||
} | ||
|
||
function set_select_value(name){ | ||
var fuzz_select = document.getElementById("fuzzers"); | ||
fuzz_select.value = name; | ||
} | ||
|
||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#header { | ||
background-color:darkorange; | ||
color:black; | ||
text-align: left; | ||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
padding:5px; | ||
} | ||
#nav { | ||
background-color: darkorange; | ||
color: black; | ||
line-height:30px; | ||
height:800px; | ||
width:15%; | ||
float:left; | ||
padding:5px; | ||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
font-style: oblique; | ||
text-transform: uppercase; | ||
} | ||
#nav li{ | ||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
} | ||
#nav a:hover{ | ||
background-color: white; | ||
border-bottom: 1px solid black; | ||
color: black; | ||
padding-bottom: 8px; | ||
} | ||
#nav a{ | ||
background: darkorange; | ||
border-bottom: 1px solid white; | ||
color: black; | ||
display: block; | ||
margin: 0; | ||
padding: 8px 12px; | ||
text-decoration: none; | ||
font-weight: normal; | ||
} | ||
#section { | ||
width:80%; | ||
height: 780px; | ||
float:left; | ||
padding:10px; | ||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
overflow: scroll; | ||
} | ||
|
||
#section h2 { | ||
text-align: center; | ||
} | ||
|
||
#footer { | ||
background-color: darkorange; | ||
color:black; | ||
clear:both; | ||
text-align:center; | ||
padding:5px; | ||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
} | ||
|
||
table { | ||
width:100%; | ||
} | ||
table, th, td { | ||
border: 1px solid black; | ||
border-collapse: collapse; | ||
} | ||
th, td { | ||
padding: 5px; | ||
text-align: left; | ||
} | ||
table tr:nth-child(even) { | ||
background-color: #eee; | ||
} | ||
table tr:nth-child(odd) { | ||
background-color:#fff; | ||
} | ||
table th { | ||
background-color: black; | ||
color: white; | ||
} | ||
table a:link { | ||
color:black; | ||
text-decoration: underline; | ||
} | ||
|
||
table a:hover { | ||
color: black; | ||
text-decoration: none; | ||
} | ||
|
||
table a:visited{ | ||
color: black; | ||
text-decoration: underline; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head lang="en"> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="{{ url_for("static", filename="style.css")}}"> | ||
<title>PyFuzz 2</title> | ||
<script src="{{ url_for("static", filename="scripts.js") }}"></script> | ||
</head> | ||
<body> | ||
<div id="header"> | ||
<h1>PyFuzz 2</h1> | ||
</div> | ||
<div id="nav"> | ||
<li class="active"><a href='index.py?func=home'><span>Overview</span></a></li> | ||
<li class="active"><a href='index.py?func=stats'><span>Stats</span></a></li> | ||
<li class="active"><a href='index.py?func=about'><span>About</span></a></li> | ||
</div> | ||
<div id="section"> | ||
<h2>SECTION_TITLE</h2> | ||
|
||
REPLACE_ME<br> | ||
</div> | ||
|
||
<div id="footer"> | ||
[email protected] 2016 | ||
</div> | ||
</body> | ||
</html> |