Showing
4 changed files
with
100 additions
and
10 deletions
source/batch/InnerDatabase_test.db
0 → 100644
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.txt | 3 | adb devices > C:\Users\%USERNAME%\Desktop\batch_file\device.txt |
4 | -adb shell dumpsys alarm > C:\Users\%USERNAME%\Desktop\batch_file\alarm.txt | 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.txt | 5 | +adb shell ps -Af > C:\Users\%USERNAME%\Desktop\batch_file\process.txt |
6 | adb shell uptime > C:\Users\%USERNAME%\Desktop\batch_file\uptime.txt | 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.txt | 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.txt | 8 | adb shell getprop ro.build.version.release > C:\Users\%USERNAME%\Desktop\batch_file\sdk_version.txt | ... | ... |
1 | import os.path | 1 | import os.path |
2 | +import sys | ||
2 | import requests | 3 | import requests |
4 | +import sqlite3 | ||
5 | +import os | ||
3 | 6 | ||
4 | -def data_check(data_path): | 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): | ||
5 | while(True): | 54 | while(True): |
6 | if(os.path.isfile(data_path)): | 55 | if(os.path.isfile(data_path)): |
7 | print("file") | 56 | print("file") |
... | @@ -9,20 +58,61 @@ def data_check(data_path): | ... | @@ -9,20 +58,61 @@ def data_check(data_path): |
9 | else: | 58 | else: |
10 | print("x") | 59 | print("x") |
11 | continue | 60 | continue |
12 | - data_transfer(data_path) | 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) | ||
13 | 92 | ||
14 | def data_transfer(data_path): | 93 | def data_transfer(data_path): |
15 | with open(data_path, 'rb') as files: | 94 | with open(data_path, 'rb') as files: |
16 | - header = {'Authorization':'Bearer ',} | 95 | + header = {'Authorization':'..',} |
17 | upload = {'file':files} | 96 | upload = {'file':files} |
18 | response = requests.post('http://13.209.3.132/extractions', files=upload, headers=header) | 97 | response = requests.post('http://13.209.3.132/extractions', files=upload, headers=header) |
19 | print(response.text) | 98 | print(response.text) |
20 | 99 | ||
21 | def main(): | 100 | def main(): |
22 | - path = os.path.expanduser('~')+"\\Desktop\\batch_file\\" | 101 | + try: |
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"] | 102 | + info = [] |
24 | - for i in data_tup: | 103 | + path = os.path.expanduser('~')+"\\Desktop\\batch_file\\" |
25 | - print(i) | 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"] |
26 | - data_check(i) | 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) | ||
27 | 117 | ||
28 | main() | 118 | main() | ... | ... |
source/batch/networkDatabase_test.db
0 → 100644
No preview for this file type
-
Please register or login to post a comment