| Conditions | 1 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | '''network related functions, mostly for discovery''' |
||
| 13 | def networkmap(dns, api_port, ssh_port): |
||
| 14 | '''see if scanning for ssh port is really necessary''' |
||
| 15 | locip = localip(dns) |
||
| 16 | print('Your ip is {0}'.format(locip)) |
||
| 17 | #scan can take a minute |
||
| 18 | #-n/-R: Never do DNS resolution/Always resolve [default: sometimes] |
||
| 19 | #-sL: List Scan - simply list targets to scan |
||
| 20 | #-sP <hosts>: only does discovery |
||
| 21 | #-PS: Port scan during discovery |
||
| 22 | scanarguments = '-v -sV' #faster but lists hosts that are not miners |
||
| 23 | print("mapping network with arguments '{0}'".format(scanarguments)) |
||
| 24 | netmapper = nmap.PortScanner() |
||
| 25 | netmapper.scan(hosts=locip+'/24', ports='{0},{1}'.format(api_port, ssh_port), arguments=scanarguments, sudo=False) |
||
| 26 | hosts_list = [(h, netmapper[h]['status']['state'], netmapper[h]['vendor']) for h in netmapper.all_hosts()] |
||
| 27 | return hosts_list |
||
| 28 |