-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanner.py
More file actions
44 lines (38 loc) · 1.14 KB
/
scanner.py
File metadata and controls
44 lines (38 loc) · 1.14 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
import requests
import ipaddress
from concurrent.futures import ThreadPoolExecutor
def check_ip(ip):
"""
Probes an IP address for the AxeOS API.
Returns miner data if found, None otherwise.
"""
try:
url = f"http://{ip}/api/system/info"
r = requests.get(url, timeout=0.8)
if r.status_code == 200:
data = r.json()
if 'hashRate' in data or 'model' in data:
return {
"ip": str(ip),
"name": data.get('hostname', str(ip)),
"model": data.get('model', 'Unknown Device')
}
except:
pass
return None
def scan_network(subnet_str):
"""
Scans a /24 subnet for Bitaxe devices.
"""
try:
network = ipaddress.ip_network(subnet_str, strict=False)
hosts = list(network.hosts())[:254]
except ValueError:
return []
found_devices = []
with ThreadPoolExecutor(max_workers=50) as executor:
results = executor.map(check_ip, hosts)
for res in results:
if res:
found_devices.append(res)
return found_devices