PyNesca/CoreModel.py

18 lines
541 B
Python
Raw Permalink Normal View History

2019-01-20 16:59:47 +00:00
import socket
class CoreModel:
def __init__(self, timeout):
2019-01-20 16:59:47 +00:00
self.defSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.defSocket.settimeout(int(timeout))
2019-01-20 16:59:47 +00:00
def scanIP(self, host, ports):
2019-01-20 16:59:47 +00:00
openPorts = []
for i in ports[0]:
result = self.defSocket.connect_ex((host, int(i)))
if result == 0:
openPorts.append(i)
self.defSocket.close()
2019-01-23 06:07:23 +00:00
self.defSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2019-01-20 16:59:47 +00:00
return openPorts