From 9d60e4974461e8f6cf21602ec7deb788bcc54b90 Mon Sep 17 00:00:00 2001 From: digehode Date: Thu, 30 Jul 2020 11:41:43 +0100 Subject: [PATCH] Created rough outline of README and started building target container --- README.md | 6 +++++- target/Dockerfile | 20 +++++++++++++++++ target/Makefile | 10 +++++++++ target/app/starter.sh | 18 ++++++++++++++++ target/app/wydah.py | 50 +++++++++++++++++++++++++++++++++++++++++++ target/web/index.html | 6 ++++++ 6 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 target/Dockerfile create mode 100644 target/Makefile create mode 100644 target/app/starter.sh create mode 100644 target/app/wydah.py create mode 100644 target/web/index.html diff --git a/README.md b/README.md index 191c891..a6747fd 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,12 @@ and their binary, decimal or hexadecimal (hex) representation. For example, the capital letter A has the ASCII code 65. 65 in hex is 41. In octal it is 101, and in binary it is 01000001. +# The Target -# Completing Transcoder +TODO + + +# Completing HarbourMaster TODO: diff --git a/target/Dockerfile b/target/Dockerfile new file mode 100644 index 0000000..8d6625d --- /dev/null +++ b/target/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:bionic +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update + +RUN apt-get -y install python3-pip +RUN apt-get -y install apache2 +RUN apt-get -y install libapache2-mod-php +RUN apt-get -y install net-tools +RUN apt-get -y install python3 +COPY app /root/app/ +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/wydah.py +CMD ["/root/app/wydah.py"] + diff --git a/target/Makefile b/target/Makefile new file mode 100644 index 0000000..f4667ad --- /dev/null +++ b/target/Makefile @@ -0,0 +1,10 @@ +NAME=wydah +PROJ=harbourmaster +ALL: Dockerfile + docker build $(OPTS) -t $(PROJ)_$(NAME) . +run: + docker run -t --name $(PROJ)_$(NAME) $(PROJ)_$(NAME) + +clean: + -docker kill $(PROJ)_$(NAME) + -docker rm $(PROJ)_$(NAME) diff --git a/target/app/starter.sh b/target/app/starter.sh new file mode 100644 index 0000000..aefba77 --- /dev/null +++ b/target/app/starter.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +/etc/init.d/apache2 start + +for (( ; ; )) +do + + echo + echo "-------------------------" + echo " Wydah Started" + echo "-------------------------" + echo + echo -n "IP: " + ifconfig eth0|grep inet[^6]|cut -d " " -f 10 + + sleep 3 + clear +done diff --git a/target/app/wydah.py b/target/app/wydah.py new file mode 100644 index 0000000..7f55159 --- /dev/null +++ b/target/app/wydah.py @@ -0,0 +1,50 @@ +#!/usr/bin/python3 +import socket +import random +import os +portOptions=[37000+x*100+x*2 for x in range(9)] +print(portOptions) +port=random.choice(portOptions) +hostname=socket.gethostname() + +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}") + +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): + self.sock.sendall(msg) + + def rcv(self): + chunks = [] + bytes_recd = 0 + chunks=[] + while bytes_recd <=0: + chunk = self.sock.recv(1024) + chunks.append(chunk) + bytes_recd = len(chunk) + return b''.join(chunks) + + def close(self): + self.sock.shutdown(socket.SHUT_RDWR) + self.sock.close() +while True: + (clientsocket, address) = serversocket.accept() + print(f"Got a connection from {address}") + s=WydSock(clientsocket) + s.send(response1) + s.close() + serversocket.shutdown(socket.SHUT_RDWR) + serversocket.close() + break + diff --git a/target/web/index.html b/target/web/index.html new file mode 100644 index 0000000..4920872 --- /dev/null +++ b/target/web/index.html @@ -0,0 +1,6 @@ + + Wydah + + + +