forked from p34709852/monkey
Fix some bugs and todos
This commit is contained in:
parent
95d35fc8aa
commit
746ff9c26a
|
@ -3,6 +3,7 @@ import bson
|
||||||
from bson.json_util import dumps
|
from bson.json_util import dumps
|
||||||
from flask import Flask, send_from_directory, redirect, make_response
|
from flask import Flask, send_from_directory, redirect, make_response
|
||||||
import flask_restful
|
import flask_restful
|
||||||
|
from werkzeug.exceptions import NotFound
|
||||||
|
|
||||||
from cc.database import mongo
|
from cc.database import mongo
|
||||||
from cc.resources.client_run import ClientRun
|
from cc.resources.client_run import ClientRun
|
||||||
|
@ -20,15 +21,14 @@ from cc.services.config import ConfigService
|
||||||
|
|
||||||
__author__ = 'Barak'
|
__author__ = 'Barak'
|
||||||
|
|
||||||
def serve_static_file(path):
|
|
||||||
print 'requested', path
|
def serve_static_file(static_path):
|
||||||
if path.startswith('api/'):
|
if static_path.startswith('api/'):
|
||||||
return make_response(404)
|
raise NotFound()
|
||||||
return send_from_directory('ui/dist', path)
|
return send_from_directory('ui/dist', static_path)
|
||||||
|
|
||||||
|
|
||||||
def serve_home():
|
def serve_home():
|
||||||
# TODO: remove this or merge with frontend.
|
|
||||||
return serve_static_file('index.html')
|
return serve_static_file('index.html')
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ def init_app(mongo_url):
|
||||||
ConfigService.init_config()
|
ConfigService.init_config()
|
||||||
|
|
||||||
app.add_url_rule('/', 'serve_home', serve_home)
|
app.add_url_rule('/', 'serve_home', serve_home)
|
||||||
app.add_url_rule('/<path:path>', 'serve_static_file', serve_static_file)
|
app.add_url_rule('/<path:static_path>', 'serve_static_file', serve_static_file)
|
||||||
|
|
||||||
api.add_resource(Root, '/api')
|
api.add_resource(Root, '/api')
|
||||||
api.add_resource(Monkey, '/api/monkey', '/api/monkey/', '/api/monkey/<string:guid>')
|
api.add_resource(Monkey, '/api/monkey', '/api/monkey/', '/api/monkey/<string:guid>')
|
||||||
|
|
|
@ -18,11 +18,7 @@ class EdgeService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_displayed_edges_by_to(to):
|
def get_displayed_edges_by_to(to):
|
||||||
edges = mongo.db.edge.find({"to": ObjectId(to)})
|
edges = mongo.db.edge.find({"to": ObjectId(to)})
|
||||||
new_edges = []
|
return [EdgeService.edge_to_displayed_edge(edge) for edge in edges]
|
||||||
# TODO: find better solution for this
|
|
||||||
for i in range(edges.count()):
|
|
||||||
new_edges.append(EdgeService.edge_to_displayed_edge(edges[i]))
|
|
||||||
return new_edges
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def edge_to_displayed_edge(edge):
|
def edge_to_displayed_edge(edge):
|
||||||
|
@ -154,7 +150,6 @@ class EdgeService:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def services_to_displayed_services(services):
|
def services_to_displayed_services(services):
|
||||||
# TODO: Consider returning extended information on services.
|
|
||||||
return [x + ": " + services[x]["name"] for x in services]
|
return [x + ": " + services[x]["name"] for x in services]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -35,12 +35,7 @@ class ConfigurePageComponent extends React.Component {
|
||||||
|
|
||||||
onSubmit = ({formData}) => {
|
onSubmit = ({formData}) => {
|
||||||
this.currentFormData = formData;
|
this.currentFormData = formData;
|
||||||
let newConfig = this.state.configuration;
|
this.updateConfigSection();
|
||||||
if (this.currentFormData != {}) {
|
|
||||||
newConfig[this.currentSection] = this.currentFormData;
|
|
||||||
this.currentFormData = {};
|
|
||||||
}
|
|
||||||
this.setState({configuration: newConfig});
|
|
||||||
fetch('/api/configuration',
|
fetch('/api/configuration',
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -62,17 +57,20 @@ class ConfigurePageComponent extends React.Component {
|
||||||
this.currentFormData = formData;
|
this.currentFormData = formData;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: remove code duplication
|
updateConfigSection = () => {
|
||||||
setSelectedSection = (key) => {
|
|
||||||
let newConfig = this.state.configuration;
|
let newConfig = this.state.configuration;
|
||||||
if (Object.keys(this.currentFormData).length > 0) {
|
if (Object.keys(this.currentFormData).length > 0) {
|
||||||
newConfig[this.currentSection] = this.currentFormData;
|
newConfig[this.currentSection] = this.currentFormData;
|
||||||
this.currentFormData = {};
|
this.currentFormData = {};
|
||||||
}
|
}
|
||||||
|
this.setState({configuration: newConfig});
|
||||||
|
};
|
||||||
|
|
||||||
|
setSelectedSection = (key) => {
|
||||||
|
this.updateConfigSection();
|
||||||
this.currentSection = key;
|
this.currentSection = key;
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedSection: key,
|
selectedSection: key
|
||||||
configuration: newConfig
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ class PreviewPaneComponent extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
infectedAssetInfo(asset) {
|
infectedAssetInfo(asset) {
|
||||||
// TODO: Have exploit info expandable (show detailed attempts)
|
|
||||||
// TODO: consider showing scans with exploits on same timeline
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{this.assetInfo(asset)}
|
{this.assetInfo(asset)}
|
||||||
|
|
|
@ -18,6 +18,7 @@ if sys.platform == "win32":
|
||||||
return socket.gethostbyname_ex(local_hostname)[2]
|
return socket.gethostbyname_ex(local_hostname)[2]
|
||||||
else:
|
else:
|
||||||
import fcntl
|
import fcntl
|
||||||
|
|
||||||
def local_ips():
|
def local_ips():
|
||||||
result = []
|
result = []
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue