mirror of
https://github.com/flotwig/spoofident
synced 2025-08-29 13:27:41 +00:00
Fixing possible crash scenario with malformed port sequences
This commit is contained in:
parent
c8257b82c3
commit
23f7d8ff72
@ -5,17 +5,22 @@ def handleIdent(fd):
|
|||||||
data=fd.recv(1024).strip()
|
data=fd.recv(1024).strip()
|
||||||
ports=data.split(',',2)
|
ports=data.split(',',2)
|
||||||
ports=map(validPort,ports)
|
ports=map(validPort,ports)
|
||||||
if not ports[1] or not ports[0]:
|
if not ports[0] or not ports[1]:
|
||||||
fd.sendall('0 , 0 : ERROR : INVALID-PORT')
|
fd.send('0 , 0 : ERROR : INVALID-PORT')
|
||||||
return
|
else:
|
||||||
fd.sendall(data + ' : USERID : '+settings['os']+' : '+settings['user'])
|
fd.send(data + ' : USERID : '+settings['os']+' : '+settings['user'])
|
||||||
|
fd.send('\r\n')
|
||||||
|
fd.close()
|
||||||
def validPort(port):
|
def validPort(port):
|
||||||
port=int(port)
|
try:
|
||||||
|
port=int(port)
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
if port>0 and port<65536:
|
if port>0 and port<65536:
|
||||||
return port
|
return port
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
pwd=path.dirname(path.realpath(__file__))
|
pwd=path.dirname(path.realpath(__file__))
|
||||||
config=open(pwd+'/spoofident.json','r')
|
config=open(pwd+'/spoofident.json','r')
|
||||||
settings=load(config)
|
settings=load(config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user