Files
logical_bombs/python/server.py

25 lines
564 B
Python
Executable File

#!/usr/bin/python
import socket
import hashlib
ip = "10.0.0.50"
port = 12345
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
s.bind(( ip, port ))
s.listen( 1 )
try:
while True:
komm, addr = s.accept()
while True:
data = komm.recv( 1024 )
if not data:
komm.close()
break
antwort = ( hashlib.sha256( socket.gethostbyname( socket.gethostname() ) ).hexdigest() if hashlib.sha256( addr[0] ).hexdigest() == data else hashlib.sha256( "ERROR" ).hexdigest() )
komm.send( antwort )
finally:
s.close()