-
Notifications
You must be signed in to change notification settings - Fork 4
/
devicelist.py
53 lines (41 loc) · 1.56 KB
/
devicelist.py
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 socket, subprocess, json, os, time # for connecting
# Discovery Tool for Atlas Devices, writes to two files:
# IP addresses (DeviceIP.txt)
# IP addreses + Names (DeviceNameIP.txt)
host = "192.168.0." # Fill in local IP Here without ending number
port = 5555 # Atlas port
f = open("DeviceIP.txt", "w")
x = open("DeviceNameIP.txt", "w")
def is_port_open(host, port):
"""
determine whether `host` has the `port` open
"""
# creates a new socket
s = socket.socket()
try:
# tries to connect to host using that port
s.settimeout(20.0)
s.connect((host, port))
# make timeout if you want it a little faster ( less accuracy )
except:
# cannot connect, port is closed
# return false
return False
else:
# the connection was established, port is open!
return True
def write_devicename(hostport):
os.system("./adb connect "+str(hostport))
os.system("./adb -s " + str(hostport) + " pull /data/local/tmp/atlas_config.json")
with open("atlas_config.json") as jsonFile:
jsonObject = json.load(jsonFile)
jsonFile.close()
devicename = "="+jsonObject['deviceName']
x.write(hostport+devicename+"\n")
for DeviceIP in range(38, 245):
if is_port_open(host+str(DeviceIP), port):
print(f"[+] {host+str(DeviceIP)}:{port} is open ")
f.write(host + str(DeviceIP) + ":" + str(port) + "\n")
write_devicename(host + str(DeviceIP) + ":" + str(port))
else:
print(f"[!] {host+str(DeviceIP)}:{port} is closed ", end="\r")