-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathporterbox
executable file
·35 lines (26 loc) · 957 Bytes
/
porterbox
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
#!/usr/bin/env python
import bs4
import requests
machine_count = 0
machines_url = 'https://db.debian.org/machines.cgi'
response = requests.get(machines_url)
soup = bs4.BeautifulSoup(response.text, 'html.parser')
machine_entries = soup.find_all('tr')
print('%-18s %-24s %s' % ("Architecture", "Hostname", "Access"))
print('-' * 68)
for machine_entry in machine_entries:
machine_data = machine_entry.find_all('td')
try:
purpose = machine_data[4].text.strip()
access = machine_data[6].text.strip()
if 'porterbox' in purpose:
hostname = machine_data[0].text.strip()
architecture = machine_data[2].text.strip()
if access == "":
access = "[unknown]"
machine_count += 1
print('%-18s %-24s %s' % (architecture, hostname, access))
except IndexError:
# malformed entry, skip it
pass
print("\nFound %d machines" % (machine_count))