-
Notifications
You must be signed in to change notification settings - Fork 0
/
discovery_test.py
41 lines (31 loc) · 965 Bytes
/
discovery_test.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
import socket
def connect(hostname, port):
print(hostname, port)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.setdefaulttimeout(1)
result = sock.connect_ex((hostname, port))
sock.close()
return result == 0
print("start")
'''for i in range(1,10):
res = connect("192.168.0."+str(i), 80)
if res:
print("Device found at: ", "192.168.0."+str(i) + ":"+str(80))'''
#import nmap
#nm = nmap.PortScanner()
'''nm.scan(hosts='192.168.1.0/29', arguments='-n -sP -PE -PA21,23,80,3389')
hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
for host, status in hosts_list:
print('{0}:{1}'.host)
'''
import os
os.system('net view > conn.tmp')
f = open('conn.tmp', 'r')
f.readline();f.readline();f.readline()
conn = []
host = f.readline()
while host[0] == '\\':
conn.append(host[2:host.find(' ')])
host = f.readline()
print (conn)
f.close()