diff --git a/target/Dockerfile b/target/Dockerfile index 8d6625d..526680f 100644 --- a/target/Dockerfile +++ b/target/Dockerfile @@ -12,9 +12,6 @@ COPY web /var/www/html/ RUN sed -i -e 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf RUN sed -i -e 's/Require all denied/Require all granted/g' /etc/apache2/apache2.conf -#RUN chmod u+x /root/app/starter.sh -#CMD ["/root/app/starter.sh"] - +RUN chmod u+x /root/app/starter.sh RUN chmod u+x /root/app/wydah.py -CMD ["/root/app/wydah.py"] - +CMD ["/root/app/starter.sh"] diff --git a/target/app/starter.sh b/target/app/starter.sh index aefba77..5413ae8 100644 --- a/target/app/starter.sh +++ b/target/app/starter.sh @@ -12,7 +12,7 @@ do echo echo -n "IP: " ifconfig eth0|grep inet[^6]|cut -d " " -f 10 - - sleep 3 + /root/app/wydah.py + sleep 2 clear done diff --git a/target/app/wydah.py b/target/app/wydah.py index 7f55159..f3bbc77 100644 --- a/target/app/wydah.py +++ b/target/app/wydah.py @@ -2,8 +2,9 @@ import socket import random import os +import select portOptions=[37000+x*100+x*2 for x in range(9)] -print(portOptions) + port=random.choice(portOptions) hostname=socket.gethostname() @@ -11,18 +12,19 @@ serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversocket.bind((hostname, port)) os.system("""ifconfig eth0|grep inet[^6]|cut -d " " -f 10""") -print(f"Serving on port {port}") +#print(f"Serving on port {port}") serversocket.listen() response1=b"57 65 6c 63 6f 6d 65 20 74 6f 20 57 79 64 61 68" - class WydSock: def __init__(self, sock): self.sock = sock def send(self, msg): + if isinstance(msg,str): + msg=str.encode(msg) self.sock.sendall(msg) def rcv(self): @@ -38,12 +40,47 @@ class WydSock: def close(self): self.sock.shutdown(socket.SHUT_RDWR) self.sock.close() + + def status(self): + + try: + ready_to_read, ready_to_write, in_error = select.select([self.sock,], [self.sock,], [], 5) + return len(ready_to_read) + except select.error: + return False + +rdata="Q29uZ3JhdHVsYXRpb25zLCB5b3UgZm91bmQgYSBmbGFnLiAiZmxhZzpoZWF2ZWhvIg==" while True: + (clientsocket, address) = serversocket.accept() print(f"Got a connection from {address}") s=WydSock(clientsocket) - s.send(response1) - s.close() + connected=True + s.send(response1) + while connected: + status=s.status() + if status is False: + connected=False + elif status>0: + data=s.rcv().strip().upper() + print(f"Revieved data: {data}") + if(data==b"CLOSE"): + connected=False + elif data==b"SHADOW": + data="Unable to open" + try: + f = open("/etc/shadow",mode='r') + data = f.read() + f.close() + except Exception as e: + print(e) + data=str(e) + s.send(data) + else: + s.send(rdata) + + + s.close() serversocket.shutdown(socket.SHUT_RDWR) serversocket.close() break diff --git a/target/web/index.html b/target/web/index.html index 4920872..6a80782 100644 --- a/target/web/index.html +++ b/target/web/index.html @@ -1,6 +1,101 @@ Wydah - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +