data.js
4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const { ipcRenderer } = require("electron");
const { BrowserWindow } = require("electron").remote;
const path = require('path')
const fs = require('fs')
var io = require('socket.io').listen(3000);
var exec = require('child_process').exec, child;
//var mysql = require('mysql');
const connect_btn = document.getElementById("connect_btn");
connect_btn.addEventListener("click", () => {
win = new BrowserWindow({
width: 600,
height: 450,
frame: false,
alwaysOnTop: true,
webPreferences: {
nodeIntegration: true
}
});
//win.webContents.openDevTools();
win.on("close", () => {
win = null;
});
win.loadFile("./src/connect.html");
win.show();
});
/*
var connection = mysql.createConnection({
host:'localhost',
user:'root',
password:'1234'
});
connection.connect();
*/
var mysql = {
user : 'root',
password : '1234'
};
function apkInstall(){
cmd_install = exec('adb -s '+device+' install -r app-release.apk',function(error, stdout, stderr){
cc.innerHTML="install apk";
cmd_exec = exec('adb -s '+device+' shell am start -n com.example.dataextraction/com.example.dataextraction.MainActivity',function(error, stdout, stderr){
cc.innerHTML="start app";
})
});
//cmd_install();
}
function convertToMysql(){
cmd_sqlIdb = exec('sqlite3 InnerDatabase.db .dump | python SQLiteToMysql.py > InnerDatabase.sql',function(error, stdout, stderr){
cc.innerHTML="make InnerDB SQL";
cmd_sqlNdb = exec('sqlite3 networkDatabase.db .dump | python SQLiteToMysql_network.py > networkDatabase.sql', function(error, stdout, stderr){
cc.innerHTML="make NetworkDB SQL";
cmd_makeIdb = exec('mysql -u'+mysql.user+' -p'+mysql.password+' -e "DROP DATABASE IF EXISTS DATAEXTRACTION;CREATE DATABASE DATAEXTRACTION CHARACTER SET utf8 COLLATE utf8_unicode_ci;USE DATAEXTRACTION;"',function(error, stdout, stderr){
cc.innerHTML="create InnerDB";
cmd_insertIdb = exec('mysql -u'+mysql.user+' -p'+mysql.password+' DATAEXTRACTION < InnerDatabase.sql',function(error, stdout, stderr){
cc.innerHTML="insert Data ; InnerDB";
cmd_makeNdb = exec('mysql -u'+mysql.user+' -p'+mysql.password+' -e "DROP DATABASE IF EXISTS DATAEXTRACTION_network;CREATE DATABASE DATAEXTRACTION_network;USE DATAEXTRACTION_network;"',function(error, stdout, stderr){
cc.innerHTML="create NetworkDB";
cmd_insertNdb = exec('mysql -u'+mysql.user+' -p'+mysql.password+' DATAEXTRACTION_network < networkDatabase.sql',function(error, stdout, stderr){
cc.innerHTML="insert Data ; NetworkDB";
cc.innerHTML="Data Extraction Complete !";
cc.innerHTML="Click 'NEXT' Button";
})
})
})
})
})
})
}
function extractDB () {
cmd_backup = exec('adb -s '+device+' backup com.example.dataextraction -f backup.dataextraction.ad', function(error, stdout, stderr){
cc.innerHTML="backup app";
setTimeout(function(){
cmd_unpack = exec('java -jar abe.jar unpack backup.dataextraction.ad dataextraction.tar',function(error, stdout, stderr){
cc.innerHTML="unpack backup";
cmd_unzip = exec('tar xvf dataextraction.tar', function(error, stdout, stderr){
cc.innerHTML="unzip tar";
cmd_moveIdb = fs.rename('apps/com.example.dataextraction/db/InnerDatabase.db', 'InnerDatabase.db', function(){
cc.innerHTML="move InnerDB File";
cmd_moveNdb = fs.rename('apps/com.example.dataextraction/db/networkDatabase.db', 'networkDatabase.db',function(){
cc.innerHTML="move NetworkDB File";
convertToMysql();
})
})
})
})
},7000);
});
//cmd_backup();
}
//db insert done
io.on('connection', function(socket){
var instanceId = socket.id;
socket.on('alert', function(data){
cc.innerHTML = data.comment+" db created";
})
socket.on('end', function(data){
cc.innerHTML="all databases created !";
extractDB();
})
})
var device = new String();
ipcRenderer.on("device", (e, arg) => {
device = arg;
connect_btn.innerHTML = "Connected : ".concat(device);
//device.innerHTML = arg.toString();
cc.innerHTML="DATA EXTRACTION START !";
apkInstall();
});