Ma Suhyeon
No preview for this file type
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 | grep -e "[set]" -e "[trigger]" -e "[remove]" | grep "com.sec.android.app.clockpackage" > 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 -Af > 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 sys
3 +import requests
4 +import sqlite3
5 +import os
6 +
7 +def create_adb_info_db():
8 + path = os.path.expanduser('~')+"\\Desktop\\batch_file\\"
9 + if(os.path.isfile(path+'adb_info.db')):
10 + os.remove(path+'adb_info.db')
11 + conn=sqlite3.connect('adb_info.db')
12 + c = conn.cursor()
13 + c.execute("CREATE TABLE process (UID TEXT, PID TEXT, PPID TEXT, C TEXT, STIME TEXT, TTY TEXT, TIME TEXT, CMD TEXT)")
14 + c.execute("CREATE TABLE info (android_version TEXT, sdk_version TEXT, device TEXT, model TEXT, uptime TEXT)")
15 + c.execute("CREATE TABLE alarm (TIME TEXT, TYPE TEXT, DETAIL TEXT)")
16 + conn.commit()
17 + c.close()
18 +
19 +def insert_alarm_db_file(info):
20 + conn=sqlite3.connect('adb_info.db')
21 + c = conn.cursor()
22 + c.execute(
23 + 'insert into alarm(TIME, TYPE, DETAIL) values (?, ?, ?)'\
24 + , (info[0], info[1], info[2])
25 + )
26 + conn.commit()
27 + c.close()
28 +
29 +def insert_info_db_file(info):
30 + conn=sqlite3.connect('adb_info.db')
31 + c = conn.cursor()
32 + c.execute(
33 + 'insert into info(android_version, sdk_version, device, model, uptime) values (?, ?, ?, ?, ?)'\
34 + , (info[0], info[1], info[2], info[3], info[4])
35 + )
36 + conn.commit()
37 + c.close()
38 +
39 +def insert_process_db_file(data_path):
40 + conn=sqlite3.connect('adb_info.db')
41 + c = conn.cursor()
42 + with open(data_path) as f:
43 + file_data = f.readlines()
44 + for item in file_data:
45 + info = item.strip().split()
46 + c.execute(
47 + 'insert into process(UID, PID, PPID, C, STIME, TTY, TIME, CMD) values (?, ?, ?, ?, ?, ?, ?, ?)'\
48 + , (info[0], info[1], info[2], info[3], info[4], info[5], info[6], info[7])
49 + )
50 + conn.commit()
51 + c.close()
52 +
53 +def data_processing(data_path, info):
54 + while(True):
55 + if(os.path.isfile(data_path)):
56 + print("file")
57 + break
58 + else:
59 + print("x")
60 + continue
61 + if(data_path.endswith('android_version.txt') or data_path.endswith('sdk_version.txt') or data_path.endswith('model.txt') or data_path.endswith('uptime.txt')):
62 + with open(data_path) as f:
63 + file_data = f.readlines()
64 + info.append(file_data[0].strip())
65 + print(info)
66 + if(data_path.endswith('uptime.txt')):
67 + insert_info_db_file(info)
68 + elif(data_path.endswith('device.txt')):
69 + with open(data_path) as f:
70 + f.readline()
71 + file_data = f.readlines()
72 + info.append((file_data[0].strip().split())[0])
73 + print(info)
74 + elif(data_path.endswith('process.txt')):
75 + insert_process_db_file(data_path)
76 + elif(data_path.endswith('alarm.txt')):
77 + with open(data_path) as f:
78 + f.readline()
79 + file_data = f.readlines()
80 + for i in file_data:
81 + if(i.endswith("wakeups:\n")):
82 + continue
83 + else:
84 + if("[set]" in i or "[trigger]" in i or "[remove]" in i):
85 + alarm_list = []
86 + temp = i.strip().split('[') #time
87 + temp2 = temp[1].split(']') #set 정보, detail
88 + alarm_list.append(temp[0])
89 + alarm_list.extend(temp2)
90 + print(alarm_list)
91 + insert_alarm_db_file(alarm_list)
92 +
93 +def data_transfer(data_path):
94 + with open(data_path, 'rb') as files:
95 + header = {'Authorization':'..',}
96 + upload = {'file':files}
97 + response = requests.post('http://13.209.3.132/extractions', files=upload, headers=header)
98 + print(response.text)
99 +
100 +def main():
101 + try:
102 + info = []
103 + path = os.path.expanduser('~')+"\\Desktop\\batch_file\\"
104 + data_tup = [path+"android_version.txt", path+"sdk_version.txt", path+"device.txt", path+"model.txt", path+"uptime.txt", path+"process.txt", path+"alarm.txt", path+"InnerDatabase_test.db", path+"networkDatabase_test.db"]
105 + create_adb_info_db()
106 + for i in data_tup:
107 + print(i)
108 + data_processing(i, info)
109 + trans_data_tup = [path+"adb_info.db", path+"InnerDatabase_test.db", path+"networkDatabase_test.db"]
110 + for i in trans_data_tup:
111 + print(i)
112 + data_transfer(i)
113 + except Exception as e:
114 + exc_type, exc_obj, tb = sys.exc_info()
115 + print('[error line No = {}]'.format(tb.tb_lineno))
116 + print(e)
117 +
118 +main()
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type