0
所以,我正在做一个IDS - 我正在检测连接到主机的过程中。当我终于跑了我得到这个:问题TypeError和python 3.5
Exception in thread Thread-3709:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
TypeError: Scan() argument after * must be a sequence, not int
下面的代码:
import threading
import socket
print("[*] Starting HazimIDS\n")
def Scan(port):
while True:
noPrint = ''
stcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sudp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
stcp.bind(('127.0.0.1', port))
sudp.bind(('127.0.0.1', port))
Threads = StartListening(stcp, sudp)
TCPThread = Threads[0]
UDPThread = Threads[1]
ConnectionThread = threading.Thread(target=DealWithConnections, args=(TCPThread, UDPThread))
RawPackThread = threading.Thread(target=PrintConnections, args=(listConnection))
ConnectionThread.start()
RawPackThread.start()
while True:
try:
TCPTrue
portstr = str(port)
for x in range(len(recentports)):
port = recentports[x]
if portstr == port:
noPrint = 'true'
else:
continue
if noPrint == '':
recentports.append(portstr + "-tcp")
print("[*] New Connection Found on port: " + portstr)
else:
continue
except NameError:
continue
def ListenTCP(socketObj):
while True:
socketObj.listen(1)
global TCPConnection
TCPConnection = 'true'
def ListenUDP(socketObj):
while True:
data, addr = socketObj.recvfrom(4096)
global UDPConnection
UDPConnection = ['true', addr]
def StartListening(socketObjTCP, socketObjUDP):
ttcp = threading.Thread(target=ListenTCP, args = (socketObjTCP))
tudp = threading.Thread(target=ListenUDP, args = (socketObjUDP))
return([ttcp, tudp])
def DealWithConnections(TCPThread, UDPThread):
TCPThread.start()
UDPThread.start()
global listConnection
listConnection = []
while True:
if TCPConnection == 'true':
try:
test = listConnection[1]
except IndexError:
listConnection.append('tcp')
elif UDPConnection[0] == 'true':
try:
test = listConnection[1]
except IndexError:
listConnection.append('udp')
def PrintConnections(globalListConnection):
while True:
try:
test = globalListConnection[1]
fListVar = globalListConnection[0]
if test == 'tcp':
global TCPTrue
elif test == 'udp':
global UDPTrue
elif fListVar == 'tcp':
global TCPTrue
elif fListVar == 'udp':
global UDPTrue
except IndexError:
continue
def main():
for x in range(4000):
ScanThread = threading.Thread(target=Scan, args=(x))
ScanThread.start()
if __name__ == "__main__":
main()
它将如果有人可以帮助我和消除所有的错误是极大的赞赏...