### 代码示例 ```python #coding=utf-8 import nmap from queue import Queue from threading import Thread def portscan(ip): portlist = [] nm = nmap.PortScannerYield() for r in nm.scan(ip, ports='1-10000', arguments='-sS --min-hostgroup'): m = r[1]['scan'][ip]['tcp'] for p in m: temp = str(p) + "----" + m[p]['state'] portlist.append(temp) print(portlist)
class Consumer(Thread): def __init__(self, q): Thread.__init__(self) self.q = q def run(self): while not self.q.empty(): ip = self.q.get() try: portscan(ip) except Exception as e: print(e) continue
def producer(ip_list): num = 10 threads = [] q = Queue() for i in ip_list: print(i) q.put(i) threads = [Consumer(q) for _ in range(num)] for t in threads: t.start() for t in threads: t.join()
```python import socket def portscan(ip, port): try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(0.2) result = s.connect_ex((ip, port)) if result == 0: print(f'{ip}:{port} is open') s.close() except Exception as e: print(e) ```
Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ...
[详细]
ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ...
[详细]