blob: d401d4280d20fbaae69e2ca851c055ff97438030 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import monkey
import subprocess
content = ''
def list_cb(vhost, url, get, get_len, post, post_len, header):
global content
content = "<html><body><h2>Hello friend. You asked for %s.</h2>\n"
content += "<pre>"
content += subprocess.check_output(['ls', '-lh', '/tmp'])
content += "</pre></body></html>"
ret = {}
ret['return'] = 1
ret['content'] = content
ret['content_len'] = len(ret['content'])
return ret
monkey.init(None, 0, 0, None)
monkey.set_callback('data', list_cb)
monkey.start()
raw_input("Press enter to stop the server...")
monkey.stop()
|