diff --git a/spoofident.py b/spoofident.py index c1d5cc7..19fb065 100644 --- a/spoofident.py +++ b/spoofident.py @@ -5,17 +5,22 @@ def handleIdent(fd): data=fd.recv(1024).strip() ports=data.split(',',2) ports=map(validPort,ports) - if not ports[1] or not ports[0]: - fd.sendall('0 , 0 : ERROR : INVALID-PORT') - return - fd.sendall(data + ' : USERID : '+settings['os']+' : '+settings['user']) + if not ports[0] or not ports[1]: + fd.send('0 , 0 : ERROR : INVALID-PORT') + else: + fd.send(data + ' : USERID : '+settings['os']+' : '+settings['user']) + fd.send('\r\n') + fd.close() def validPort(port): - port=int(port) + try: + port=int(port) + except ValueError: + return False if port>0 and port<65536: return port else: return False -if __name__ == "__main__": +if __name__ == '__main__': pwd=path.dirname(path.realpath(__file__)) config=open(pwd+'/spoofident.json','r') settings=load(config)