data.js
1.34 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
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');
//3. adb backup 명령어를 통해 데이터베이스 추출
function extractDB () {
cmd_backup = exec('adb backup com.example.dataextraction -f backup.dataextraction.ad', function(error, stdout, stderr){
console.log("backup app");
setTimeout(function(){
cmd_unpack = exec('java -jar abe.jar unpack backup.dataextraction.ad dataextraction.tar',function(error, stdout, stderr){
console.log("unpack backup");
cmd_unzip = exec('tar xvf dataextraction.tar', function(error, stdout, stderr){
console.log("unzip tar");
cmd_moveIdb = fs.rename('apps/com.example.dataextraction/db/InnerDatabase.db', 'InnerDatabase.db', function(){
console.log("move innerDB");
cmd_moveNdb = fs.rename('apps/com.example.dataextraction/db/networkDatabase.db', 'networkDatabase.db',function(){
console.log("move network db");
})
})
})
})
},7000);
});
}
//2. 애플리케이션에서 데이터베이스 생성이 끝나면 알림
io.on('connection', function(socket){
var instanceId = socket.id;
socket.on('alert', function(data){
console.log("alert");
})
socket.on('end', function(data){
console.log("extract db end");
extractDB();
})
})