Skip to content

Commit

Permalink
Added import/export functionality and fixed some minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rfox committed Oct 17, 2020
1 parent c6572cf commit 4e1a828
Show file tree
Hide file tree
Showing 9 changed files with 379 additions and 24 deletions.
101 changes: 101 additions & 0 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_timeline)
break;

case 'export':
export_csv(w2ui.grd_timeline)
break;
}
}

Expand Down Expand Up @@ -222,6 +230,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_investigated_systems)
break;

case 'export':
export_csv(w2ui.grd_investigated_systems)
break;
}
}

Expand Down Expand Up @@ -286,6 +302,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_malware)
break;

case 'export':
export_csv(w2ui.grd_malware)
break;
}
}

Expand Down Expand Up @@ -395,6 +419,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_accounts)
break;

case 'export':
export_csv(w2ui.grd_accounts)
break;
}
}

Expand Down Expand Up @@ -438,6 +470,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_network)
break;

case 'export':
export_csv(w2ui.grd_network)
break;
}
}

Expand Down Expand Up @@ -492,6 +532,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_exfiltration)
break;

case 'export':
export_csv(w2ui.grd_exfiltration)
break;
}
}

Expand Down Expand Up @@ -568,6 +616,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_systems)
break;

case 'export':
export_csv(w2ui.grd_systems)
break;
}
}

Expand All @@ -589,6 +645,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_investigators)
break;

case 'export':
export_csv(w2ui.grd_investigators)
break;
}
}

Expand All @@ -607,7 +671,17 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_evidence)
break;

case 'export':
export_csv(w2ui.grd_evidence)
break;
}


}

w2ui.grd_evidence.onMenuClick = function(event){
Expand Down Expand Up @@ -654,6 +728,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_actions)
break;

case 'export':
export_csv(w2ui.grd_actions)
break;
}
}

Expand All @@ -674,6 +756,14 @@ registerComponents = function(){
case 'remove':
currentgrid.remove(currentgrid.getSelection())
break;

case 'import':
show_import_dialog(w2ui.grd_casenotes)
break;

case 'export':
export_csv(w2ui.grd_casenotes)
break;
}
}

Expand All @@ -693,6 +783,17 @@ registerComponents = function(){
}
}

w2ui.grd_import_mapping.toolbar.onClick = function(event){


switch(event.target) {
case 'import':
import_data()
break;

}
}




Expand Down
18 changes: 10 additions & 8 deletions src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ function updateSOD(){
function updateSODFile() { //TODO: need to write that in a way that it also works when you don0t have the lock. currently all calls to editable will fail when they are not set

var fs = require('fs');

w2utils.lock($( "#main" ),"Loading file...",true)

var filebuffer = fs.readFileSync(currentfile.toString());
case_data = JSON.parse(filebuffer);

w2utils.unlock($( "#main" ))
if(case_data.hasOwnProperty(storage_format_version) && case_data.storage_format_version < storage_format_version){
w2alert("You are opening a file created with a newer version of Aurora IR. Please upgrade to the newest version of Aurora IR and try again")
return false
Expand Down Expand Up @@ -143,7 +144,7 @@ function newSOD() {
w2confirm('Are you sure you want to create a new SOD? All unsaved data will be lost.', function btn(answer) {
if (answer == "Yes") {

case_data = case_template
case_data = data_template
w2ui.grd_timeline.clear()
w2ui.grd_timeline.render()
w2ui.grd_investigated_systems.clear()
Expand Down Expand Up @@ -312,9 +313,10 @@ function saveSODFile(){


var fs = require("fs");
w2utils.lock($( "#main" ),"Saving file...",true)
var buffer = new Buffer.from(JSON.stringify(case_data,null, "\t"));
fs.writeFileSync(currentfile.toString(), buffer);

w2utils.unlock($( "#main" ))
var today = new Date();
var time=('0' + today.getHours()).slice(-2)+':'+('0' + today.getMinutes()).slice(-2)+':'+('0' + today.getSeconds()).slice(-2);

Expand Down Expand Up @@ -558,7 +560,7 @@ function getNextRECID(grid){

var highest = 1;

for(i=0; i< grid.records.length;i++){
for(var i=0; i< grid.records.length;i++){

var recid = grid.records[i].recid
if(recid>highest) highest=recid
Expand Down Expand Up @@ -618,7 +620,7 @@ function updateSystems(event){

//check timeline
records = w2ui.grd_timeline.records
for(i=0;i<records.length;i++){
for(var i=0;i<records.length;i++){
system1 = records[i].event_host
system2 = records[i].event_source_host

Expand All @@ -628,7 +630,7 @@ function updateSystems(event){

//check investigated systems
records = w2ui.grd_investigated_systems.records
for(i=0;i<records.length;i++){
for(var i=0;i<records.length;i++){
system1 = records[i].hostname

if(system1 == old_system) records[i].hostname=new_system
Expand All @@ -637,7 +639,7 @@ function updateSystems(event){

//check malware
records = w2ui.grd_malware.records
for(i=0;i<records.length;i++){
for(var i=0;i<records.length;i++){
system1 = records[i].hostname

if(system1 == old_system) records[i].hostname=new_system
Expand All @@ -646,7 +648,7 @@ function updateSystems(event){

//Check exfil
records = w2ui.grd_exfiltration.records
for(i=0;i<records.length;i++){
for(var i=0;i<records.length;i++){
system1 = records[i].stagingsystem
system2 = records[i].original
system3 = records[i].exfil_to
Expand Down
39 changes: 39 additions & 0 deletions src/export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function export_csv(grid){

const {remote} = require('electron')
const {dialog} = remote
const selectedPath = dialog.showSaveDialog({filters: [{name: "Export File", extensions: ["csv"]}]});
if (selectedPath == undefined) {

w2alert('No file selected. Could not export.');
return false

}
csv =""
//generate header line
headerline = ""
for(var i=0; i<grid.columns.length;i++) {
headerline += grid.columns[i].caption
if(i<grid.columns.length-1) headerline += ","
}

csv += headerline + "\n"

//generate content
for(var i = 0;i < grid.records.length;i++){

line = ""
for(var j=0; j<grid.columns.length;j++) {
data = grid.records[i][grid.columns[j].field]
if(!data) data = " "
line += data
if(j<grid.columns.length-1) line += ","
}
csv += line +"\n"
}

var fs = require("fs");
w2utils.lock($( "#main" ),"Exporting file...",true)
fs.writeFileSync(selectedPath.toString(), csv);
w2utils.unlock($( "#main" ))
}
Loading

0 comments on commit 4e1a828

Please sign in to comment.