2019-01-20 16:59:47 +00:00
|
|
|
import socket
|
|
|
|
|
|
|
|
|
|
|
|
class CoreModel:
|
2019-01-21 15:22:17 +00:00
|
|
|
def __init__(self, timeout):
|
2019-01-20 16:59:47 +00:00
|
|
|
self.defSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
2019-01-21 15:22:17 +00:00
|
|
|
self.defSocket.settimeout(int(timeout))
|
2019-01-20 16:59:47 +00:00
|
|
|
|
2019-01-21 15:22:17 +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
|