pth report is now shown also in the website

This commit is contained in:
Oran Nadler 2018-05-22 03:00:06 -07:00
parent c298544f22
commit 6019432a2b
4 changed files with 51 additions and 1 deletions

View File

@ -19,6 +19,7 @@ from cc.resources.monkey_configuration import MonkeyConfiguration
from cc.resources.monkey_download import MonkeyDownload
from cc.resources.netmap import NetMap
from cc.resources.pthmap import PthMap
from cc.resources.pthreporthtml import PthReportHtml
from cc.resources.node import Node
from cc.resources.report import Report
from cc.resources.root import Root
@ -106,5 +107,6 @@ def init_app(mongo_url):
api.add_resource(TelemetryFeed, '/api/telemetry-feed', '/api/telemetry-feed/')
api.add_resource(Log, '/api/log', '/api/log/')
api.add_resource(PthMap, '/api/pthmap', '/api/pthmap/')
api.add_resource(PthReportHtml, '/api/pthreport', '/api/pthreport/')
return app

View File

@ -1228,4 +1228,23 @@ def main():
print """</div>"""
if __name__ == "__main__":
main()
main()
from cStringIO import StringIO
import sys
class Capturing(list):
def __enter__(self):
self._stdout = sys.stdout
sys.stdout = self._stringio = StringIO()
return self
def __exit__(self, *args):
self.extend(self._stringio.getvalue().splitlines())
del self._stringio # free up some memory
sys.stdout = self._stdout
def get_report_html():
with Capturing() as output:
main()
return "\n".join(output)

View File

@ -0,0 +1,21 @@
import hashlib
import binascii
import copy
import flask_restful
from pthreport import PassTheHashReport, Machine, get_report_html
from cc.auth import jwt_required
from cc.services.edge import EdgeService
from cc.services.node import NodeService
from cc.database import mongo
class PthReportHtml(flask_restful.Resource):
@jwt_required()
def get(self, **kw):
pth = PassTheHashReport()
html = get_report_html()
return \
{
"html": html
}

View File

@ -29,6 +29,7 @@ class PassTheHashMapPageComponent extends AuthComponent {
super(props);
this.state = {
graph: {nodes: [], edges: []},
report: "",
selected: null,
selectedType: null,
killPressed: false,
@ -58,6 +59,12 @@ class PassTheHashMapPageComponent extends AuthComponent {
this.setState({graph: res});
this.props.onStatusChange();
});
this.authFetch('/api/pthreport')
.then(res => res.json())
.then(res => {
this.setState({report: res.html});
this.props.onStatusChange();
});
};
render() {
@ -70,6 +77,7 @@ class PassTheHashMapPageComponent extends AuthComponent {
<div>
<Graph graph={this.state.graph} options={options} />
</div>
<div dangerouslySetInnerHTML={{__html: this.state.report}}></div>
</Col>
</div>
);