aboutsummaryrefslogtreecommitdiffstats
path: root/propagate/src/cli_fe_http.py
diff options
context:
space:
mode:
Diffstat (limited to 'propagate/src/cli_fe_http.py')
-rw-r--r--propagate/src/cli_fe_http.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/propagate/src/cli_fe_http.py b/propagate/src/cli_fe_http.py
new file mode 100644
index 0000000..40b7373
--- /dev/null
+++ b/propagate/src/cli_fe_http.py
@@ -0,0 +1,34 @@
+import httplib
+import urllib
+import optparse
+import Cookie
+"""
+ Christian
+ Usage: The following program reads strings from the standard input
+ and sends them to the server ([host] [port]) in the POST
+ request on URL [url] in field 'cmd'.
+ The result is read from the COOKIE "result" and displayed.
+"""
+def send_cmd_http_post(host, port=80, base64command="base64command", url="/test.php"):
+ headers = { "Content-type": "application/x-www-form-urlencoded" }
+ params = urllib.urlencode({'cmd': base64command})
+ conn = httplib.HTTPConnection(host, port)
+ conn.request("POST", url, params, headers)
+ response = conn.getresponse()
+
+ response_headers = dict(response.getheaders())
+ if ('set-cookie' in response_headers):
+ cookie = Cookie.BaseCookie(response_headers['set-cookie'])
+ return cookie["result"].value
+ return "result-cookie-not-found"
+
+if __name__ == '__main__':
+ usage = "usage: %prog host port url"
+ parser = optparse.OptionParser(usage=usage)
+ (options, args) = parser.parse_args()
+ if len(args) != 3:
+ parser.error("incorrect number of arguments")
+ host, port, url = args
+ while (True):
+ base64command = raw_input()
+ print send_cmd_http_post(host, int(port), base64command, url)