mirror of
https://github.com/laramies/theHarvester.git
synced 2024-11-11 18:03:10 +08:00
95e32aa343
Added port_scanning and domain Takeover checks
31 lines
No EOL
883 B
Python
31 lines
No EOL
883 B
Python
import threading
|
|
import socket
|
|
|
|
class port_scan():
|
|
def __init__(self, host, ports):
|
|
self.threads = 25
|
|
self.host = host
|
|
self.ports = ports
|
|
|
|
self.lock = threading.BoundedSemaphore(value=self.threads)
|
|
|
|
def port_scanner(self, host, ports):
|
|
openports = []
|
|
self.lock.acquire()
|
|
for port in ports:
|
|
try:
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.settimeout(2)
|
|
result = s.connect_ex((host, int(port)))
|
|
if result == 0:
|
|
openports.append(port)
|
|
s.close()
|
|
except Exception,e:
|
|
print e
|
|
pass
|
|
self.lock.release()
|
|
return openports
|
|
|
|
def process(self):
|
|
ports = self.port_scanner (self.host, self.ports)
|
|
return ports |