김가영

data 전송 기능 추가

1 @echo 1 @echo
2 cd C:\Users\%USERNAME%\Desktop\batch_file 2 cd C:\Users\%USERNAME%\Desktop\batch_file
3 -adb devices > C:\Users\%USERNAME%\Desktop\batch_file\device.csv 3 +adb devices > C:\Users\%USERNAME%\Desktop\batch_file\device.txt
4 -adb shell dumpsys alarm > C:\Users\%USERNAME%\Desktop\batch_file\alarm.csv 4 +adb shell dumpsys alarm > C:\Users\%USERNAME%\Desktop\batch_file\alarm.txt
5 -adb shell ps -A > C:\Users\%USERNAME%\Desktop\batch_file\process.csv 5 +adb shell ps -A > C:\Users\%USERNAME%\Desktop\batch_file\process.txt
6 -adb shell uptime > C:\Users\%USERNAME%\Desktop\batch_file\uptime.csv 6 +adb shell uptime > C:\Users\%USERNAME%\Desktop\batch_file\uptime.txt
7 -adb shell getprop ro.product.model > C:\Users\%USERNAME%\Desktop\batch_file\model.csv 7 +adb shell getprop ro.product.model > C:\Users\%USERNAME%\Desktop\batch_file\model.txt
8 -adb shell getprop ro.build.version.release > C:\Users\%USERNAME%\Desktop\batch_file\sdk_version.csv 8 +adb shell getprop ro.build.version.release > C:\Users\%USERNAME%\Desktop\batch_file\sdk_version.txt
9 -adb shell getprop ro.build.version.sdk > C:\Users\%USERNAME%\Desktop\batch_file\android_version.csv 9 +adb shell getprop ro.build.version.sdk > C:\Users\%USERNAME%\Desktop\batch_file\android_version.txt
10 adb install -r app-release.apk 10 adb install -r app-release.apk
11 start cmd.exe /k "node data.js" 11 start cmd.exe /k "node data.js"
12 adb shell am start -n com.example.dataextraction/com.example.dataextraction.LoadingActivity 12 adb shell am start -n com.example.dataextraction/com.example.dataextraction.LoadingActivity
......
...@@ -18,6 +18,15 @@ function extractDB () { ...@@ -18,6 +18,15 @@ function extractDB () {
18 console.log("move innerDB"); 18 console.log("move innerDB");
19 cmd_moveNdb = fs.rename('apps/com.example.dataextraction/db/networkDatabase.db', 'networkDatabase.db',function(){ 19 cmd_moveNdb = fs.rename('apps/com.example.dataextraction/db/networkDatabase.db', 'networkDatabase.db',function(){
20 console.log("move network db"); 20 console.log("move network db");
21 + python_execute = exec('python data_sender.py',
22 + function (error, stdout, stderr) {
23 + console.log("python code execute")
24 + console.log('stdout: ' + stdout);
25 + console.log('stderr: ' + stderr);
26 + if (error !== null) {
27 + console.log('exec error: ' + error);
28 + }
29 + });
21 }) 30 })
22 }) 31 })
23 }) 32 })
......
1 +import os.path
2 +import requests
3 +
4 +def data_check(data_path):
5 + while(True):
6 + if(os.path.isfile(data_path)):
7 + print("file")
8 + break
9 + else:
10 + print("x")
11 + continue
12 + data_transfer(data_path)
13 +
14 +def data_transfer(data_path):
15 + with open(data_path, 'rb') as files:
16 + header = {'Authorization':'Bearer ',}
17 + upload = {'file':files}
18 + response = requests.post('http://13.209.3.132/extractions', files=upload, headers=header)
19 + print(response.text)
20 +
21 +def main():
22 + path = os.path.expanduser('~')+"\\Desktop\\batch_file\\"
23 + data_tup = [path+"android_version.txt", path+"alarm.txt", path+"device.txt", path+"model.txt", path+"process.txt", path+"sdk_version.txt", path+"uptime.txt", path+"InnerDatabase_test.db", path+"networkDatabase_test.db"]
24 + for i in data_tup:
25 + print(i)
26 + data_check(i)
27 +
28 +main()