-
Notifications
You must be signed in to change notification settings - Fork 1
/
deaddrop.git.py
76 lines (69 loc) · 2.24 KB
/
deaddrop.git.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from twisted.web import server, resource
from twisted.internet import reactor, ssl
import datetime
# This string is the base site
P = '\
<html>\
<head>\
<title>Secure Dead Drop</title>\
</head>\
<body>\
<table>\
<form action="display.php" method="post">\
<tr>\
<td>Enter Secured Text:</td>\
</tr>\
<tr>\
<td><form method="post"><textarea name="message" cols="50" rows="10"></textarea></form></td>\
</tr>\
</table>\
<table>\
<tr>\
<td><input type="submit" value="Submit" /></td><br />\
<td><input type="reset" value="Clear" /></td><br />\
</tr>\
</table>\
</body>\
</html>\
'
# Variables used in program
messages = "/path/to/messages/file"
port = 8083
# Writes passed string and IP address to file, along with a timestamp
def saveMessage(string,IP):
f = open(messages,'a')
timeStamp = datetime.datetime.now().isoformat(' ')
f.write(timeStamp+" : "+ IP +" : "+string+"\n")
f.close()
class Simple(resource.Resource):
isLeaf = True
def render(self, request):
IP = request.getClientIP()
html = ""
extra = ""
html += "<html>"
html += "<title>DDD</title></html>"
html += "<h1>DDD</h1>"
html += """<table><tr>For those of you familiar with the books of Orson Scott Card, there
is some interesting technology in his universe. Besides tablets called "desks"<br>
he has anonymous email and digital dead drops for passing information securely
in a one-way fashion. This is my attempt at that.<tr></table> """
field_value = request.args.get('Field', '')
button_val = request.args.get('name_submit','')
form = """
<FORM ACTION="default.cgi" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
<P><TEXTAREA NAME="Field" COLS="50" ROWS="10"></TEXTAREA><BR>
<INPUT TYPE="SUBMIT" NAME="name_submit" VALUE="Submit"></INPUT>
</FORM>
"""
if button_val == ['Submit']:
saveMessage(field_value[0],IP)
extra += "<html><h2>Submitted Encrypted Message:</h2></html>"
extra += field_value[0]+"<br>"
extra += "<h3>From IP address " + IP + "</h3>"
return html + form + extra
sslContext = ssl.DefaultOpenSSLContextFactory('keys/server.pem','keys/ca.pem')
site = server.Site(Simple())
reactor.listenSSL(port, site, contextFactory = sslContext)
#reactor.listenTCP(8083, site)
reactor.run()