forked from p15670423/monkey
Replace base64 with string escaping
This commit is contained in:
parent
70766e7358
commit
aa02d8945d
|
@ -1,4 +1,3 @@
|
||||||
import base64
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import platform
|
import platform
|
||||||
|
@ -117,7 +116,7 @@ class ControlClient(object):
|
||||||
if not WormConfiguration.current_server:
|
if not WormConfiguration.current_server:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
telemetry = {'monkey_guid': GUID, 'log': base64.b64encode(log)}
|
telemetry = {'monkey_guid': GUID, 'log': json.dumps(log)}
|
||||||
reply = requests.post("https://%s/api/log" % (WormConfiguration.current_server,),
|
reply = requests.post("https://%s/api/log" % (WormConfiguration.current_server,),
|
||||||
data=json.dumps(telemetry),
|
data=json.dumps(telemetry),
|
||||||
headers={'content-type': 'application/json'},
|
headers={'content-type': 'application/json'},
|
||||||
|
|
|
@ -82,22 +82,34 @@ class PreviewPaneComponent extends React.Component {
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<Toggle id={asset.id} checked={!asset.config.alive} icons={false} disabled={asset.dead}
|
<Toggle id={asset.id} checked={!asset.config.alive} icons={false} disabled={asset.dead}
|
||||||
onChange={(e) => this.forceKill(e, asset)} />
|
onChange={(e) => this.forceKill(e, asset)}/>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadLog(asset) {
|
unescapeLog(st) {
|
||||||
|
return st.substr(1, st.length - 2) // remove quotation marks on beginning and end of string.
|
||||||
|
.replace(/\\n/g, "\n")
|
||||||
|
.replace(/\\r/g, "\r")
|
||||||
|
.replace(/\\t/g, "\t")
|
||||||
|
.replace(/\\b/g, "\b")
|
||||||
|
.replace(/\\f/g, "\f")
|
||||||
|
.replace(/\\"/g, '\"')
|
||||||
|
.replace(/\\'/g, "\'")
|
||||||
|
.replace(/\\&/g, "\&");
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadLog(asset) {
|
||||||
fetch('/api/log?id=' + asset.id)
|
fetch('/api/log?id=' + asset.id)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let timestamp = res['timestamp'];
|
let timestamp = res['timestamp'];
|
||||||
timestamp = timestamp.substr(0, timestamp.indexOf('.'));
|
timestamp = timestamp.substr(0, timestamp.indexOf('.'));
|
||||||
let filename = res['monkey_label'].split(':').join('-') + ' - ' + timestamp + '.log';
|
let filename = res['monkey_label'].split(':').join('-') + ' - ' + timestamp + '.log';
|
||||||
download(atob(res['log']), filename, 'text/plain');
|
let logContent = this.unescapeLog(res['log']);
|
||||||
|
download(logContent, filename, 'text/plain');
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -119,7 +131,7 @@ class PreviewPaneComponent extends React.Component {
|
||||||
|
|
||||||
exploitsTimeline(asset) {
|
exploitsTimeline(asset) {
|
||||||
if (asset.exploits.length === 0) {
|
if (asset.exploits.length === 0) {
|
||||||
return (<div />);
|
return (<div/>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -129,9 +141,9 @@ class PreviewPaneComponent extends React.Component {
|
||||||
{this.generateToolTip('Timeline of exploit attempts. Red is successful. Gray is unsuccessful')}
|
{this.generateToolTip('Timeline of exploit attempts. Red is successful. Gray is unsuccessful')}
|
||||||
</h4>
|
</h4>
|
||||||
<ul className="timeline">
|
<ul className="timeline">
|
||||||
{ asset.exploits.map(exploit =>
|
{asset.exploits.map(exploit =>
|
||||||
<li key={exploit.timestamp}>
|
<li key={exploit.timestamp}>
|
||||||
<div className={'bullet ' + (exploit.result ? 'bad' : '')} />
|
<div className={'bullet ' + (exploit.result ? 'bad' : '')}/>
|
||||||
<div>{new Date(exploit.timestamp).toLocaleString()}</div>
|
<div>{new Date(exploit.timestamp).toLocaleString()}</div>
|
||||||
<div>{exploit.origin}</div>
|
<div>{exploit.origin}</div>
|
||||||
<div>{exploit.exploiter}</div>
|
<div>{exploit.exploiter}</div>
|
||||||
|
@ -147,10 +159,10 @@ class PreviewPaneComponent extends React.Component {
|
||||||
<div>
|
<div>
|
||||||
<table className="table table-condensed">
|
<table className="table table-condensed">
|
||||||
<tbody>
|
<tbody>
|
||||||
{this.osRow(asset)}
|
{this.osRow(asset)}
|
||||||
{this.ipsRow(asset)}
|
{this.ipsRow(asset)}
|
||||||
{this.servicesRow(asset)}
|
{this.servicesRow(asset)}
|
||||||
{this.accessibleRow(asset)}
|
{this.accessibleRow(asset)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{this.exploitsTimeline(asset)}
|
{this.exploitsTimeline(asset)}
|
||||||
|
@ -163,13 +175,13 @@ class PreviewPaneComponent extends React.Component {
|
||||||
<div>
|
<div>
|
||||||
<table className="table table-condensed">
|
<table className="table table-condensed">
|
||||||
<tbody>
|
<tbody>
|
||||||
{this.osRow(asset)}
|
{this.osRow(asset)}
|
||||||
{this.statusRow(asset)}
|
{this.statusRow(asset)}
|
||||||
{this.ipsRow(asset)}
|
{this.ipsRow(asset)}
|
||||||
{this.servicesRow(asset)}
|
{this.servicesRow(asset)}
|
||||||
{this.accessibleRow(asset)}
|
{this.accessibleRow(asset)}
|
||||||
{this.forceKillRow(asset)}
|
{this.forceKillRow(asset)}
|
||||||
{this.downloadLogRow(asset)}
|
{this.downloadLogRow(asset)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{this.exploitsTimeline(asset)}
|
{this.exploitsTimeline(asset)}
|
||||||
|
@ -202,9 +214,9 @@ class PreviewPaneComponent extends React.Component {
|
||||||
<div>
|
<div>
|
||||||
<h4 style={{'marginTop': '2em'}}>Timeline</h4>
|
<h4 style={{'marginTop': '2em'}}>Timeline</h4>
|
||||||
<ul className="timeline">
|
<ul className="timeline">
|
||||||
{ edge.exploits.map(exploit =>
|
{edge.exploits.map(exploit =>
|
||||||
<li key={exploit.timestamp}>
|
<li key={exploit.timestamp}>
|
||||||
<div className={'bullet ' + (exploit.result ? 'bad' : '')} />
|
<div className={'bullet ' + (exploit.result ? 'bad' : '')}/>
|
||||||
<div>{new Date(exploit.timestamp).toLocaleString()}</div>
|
<div>{new Date(exploit.timestamp).toLocaleString()}</div>
|
||||||
<div>{exploit.origin}</div>
|
<div>{exploit.origin}</div>
|
||||||
<div>{exploit.exploiter}</div>
|
<div>{exploit.exploiter}</div>
|
||||||
|
@ -235,8 +247,8 @@ class PreviewPaneComponent extends React.Component {
|
||||||
this.infectedAssetInfo(this.props.item) : this.assetInfo(this.props.item);
|
this.infectedAssetInfo(this.props.item) : this.assetInfo(this.props.item);
|
||||||
break;
|
break;
|
||||||
case 'island_edge':
|
case 'island_edge':
|
||||||
info = this.islandEdgeInfo();
|
info = this.islandEdgeInfo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let label = '';
|
let label = '';
|
||||||
|
@ -250,12 +262,12 @@ class PreviewPaneComponent extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="preview-pane">
|
<div className="preview-pane">
|
||||||
{ !info ?
|
{!info ?
|
||||||
<span>
|
<span>
|
||||||
<Icon name="hand-o-left" style={{'marginRight': '0.5em'}} />
|
<Icon name="hand-o-left" style={{'marginRight': '0.5em'}}/>
|
||||||
Select an item on the map for a detailed look
|
Select an item on the map for a detailed look
|
||||||
</span>
|
</span>
|
||||||
:
|
:
|
||||||
<div>
|
<div>
|
||||||
<h3>
|
<h3>
|
||||||
{label}
|
{label}
|
||||||
|
|
Loading…
Reference in New Issue