mirror of
https://github.com/rscmbbng/Border-Check.git
synced 2024-12-25 21:41:28 +01:00
added xml engine + web xml output results + more fancy interface
This commit is contained in:
parent
045e06aa85
commit
80aa7cee7d
4
main.py
4
main.py
@ -20,6 +20,7 @@ except:
|
|||||||
import subprocess, socket, threading
|
import subprocess, socket, threading
|
||||||
from options import BCOptions
|
from options import BCOptions
|
||||||
from webserver import BorderCheckWebserver
|
from webserver import BorderCheckWebserver
|
||||||
|
from xml_exporter import xml_reporting
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
# set to emit debug messages about errors (0 = off).
|
# set to emit debug messages about errors (0 = off).
|
||||||
@ -360,6 +361,9 @@ class bc(object):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
traces = self.try_running(self.traces, "\nInternal error tracerouting.")
|
traces = self.try_running(self.traces, "\nInternal error tracerouting.")
|
||||||
|
# export data to XML
|
||||||
|
xml_results = xml_reporting(self)
|
||||||
|
xml_results.print_xml_results('data.xml')
|
||||||
print '='*45 + "\n"
|
print '='*45 + "\n"
|
||||||
print "Status: Waiting for new urls ...\n"
|
print "Status: Waiting for new urls ...\n"
|
||||||
# stay latent waiting for new urls
|
# stay latent waiting for new urls
|
||||||
|
54
web/index.py
54
web/index.py
@ -1,12 +1,58 @@
|
|||||||
|
#!/usr/local/bin/python
|
||||||
|
# -*- coding: iso-8859-15 -*-
|
||||||
|
"""
|
||||||
|
BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes.
|
||||||
|
GPLv3 - 2013 by psy (epsylon@riseup.net)
|
||||||
|
"""
|
||||||
|
from xml.dom.minidom import parseString
|
||||||
|
# extract data from a xml file
|
||||||
|
file = open('data.xml','r')
|
||||||
|
data = file.read()
|
||||||
|
file.close()
|
||||||
|
dom = parseString(data)
|
||||||
|
xmlTag = dom.getElementsByTagName('travel')[0].toxml()
|
||||||
|
xmlData= xmlTag.replace('<travel>','').replace('</travel>','')
|
||||||
|
xmlHost = dom.getElementsByTagName('host')[0].toxml()
|
||||||
|
xmlIP = dom.getElementsByTagName('ip')[0].toxml()
|
||||||
|
xmlRoutes = dom.getElementsByTagName('routes')[0].toxml()
|
||||||
|
xmlMeta = dom.getElementsByTagName('meta')[0].toxml()
|
||||||
|
|
||||||
output = """
|
output = """
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Border Check</title>
|
<title>Border Check - Web Visualizator</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<center>
|
||||||
<center><img src="images/WM1.svg"><center>
|
<table>
|
||||||
</div>
|
<tr>
|
||||||
|
<td><div><center><img src="images/WM1.svg"></center></div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<center>
|
||||||
|
<table border="1">
|
||||||
|
<tr>
|
||||||
|
<td><b>Host:</b></td>
|
||||||
|
<td>"""+xmlHost+"""</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>IP:</b></td>
|
||||||
|
<td>"""+xmlIP+"""</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Packages Route:</b></td>
|
||||||
|
<td>"""+xmlRoutes+"""</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Metadata:</b></td>
|
||||||
|
<td>"""+xmlMeta+"""</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</center>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</center>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
@ -69,7 +69,8 @@ class HttpHandler(BaseHTTPRequestHandler):
|
|||||||
content = query.get('upfile')
|
content = query.get('upfile')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
print "Request from %s:%d"%self.client_address + " " + uri
|
# only for debug mode
|
||||||
|
#print "Request from %s:%d"%self.client_address + " " + uri
|
||||||
if uri[-1] == '/' or os.path.isdir(file):
|
if uri[-1] == '/' or os.path.isdir(file):
|
||||||
file = file + "/index.py"
|
file = file + "/index.py"
|
||||||
if os.path.isfile(file + ".py"):
|
if os.path.isfile(file + ".py"):
|
||||||
|
31
xml_exporter.py
Normal file
31
xml_exporter.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: iso-8859-15 -*-
|
||||||
|
"""
|
||||||
|
BC (Border-Check) is a tool to retrieve info of traceroute tests over website navigation routes.
|
||||||
|
GPLv3 - 2013 by psy (epsylon@riseup.net)
|
||||||
|
"""
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
class xml_reporting(object):
|
||||||
|
"""
|
||||||
|
Print results from a traceroute in an XML fashion
|
||||||
|
"""
|
||||||
|
def __init__(self, bc):
|
||||||
|
# initialize main BC
|
||||||
|
self.instance = bc
|
||||||
|
|
||||||
|
def print_xml_results(self, filename):
|
||||||
|
root = ET.Element("travel")
|
||||||
|
host = ET.SubElement(root, "host")
|
||||||
|
ip = ET.SubElement(root, "ip")
|
||||||
|
routes = ET.SubElement(root, "routes")
|
||||||
|
meta = ET.SubElement(root, "meta")
|
||||||
|
|
||||||
|
host.text = self.instance.url[0]
|
||||||
|
ip.text = self.instance.ip
|
||||||
|
routes.text = self.instance.routes
|
||||||
|
meta.text = "Connect here XML metadata"
|
||||||
|
|
||||||
|
tree = ET.ElementTree(root)
|
||||||
|
tree.write(filename)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user