def Register_NewImplantFromStagerKey(self, stager_key): # -- We are registering a NEW implant and generating a unique_stager_key (or UIK) # -- Moving forward all reference to ImplantKey/UII should be changed to StagerID implant = self.Session.query(Implants).filter(Implants.stager_key == stager_key).first() if implant is not None: unique_implant_key = random.randint(000000, 999999) new_title = str(implant.title) + "_" + str(unique_implant_key) generated_implant = GeneratedImplants(unique_implant_id=unique_implant_key, last_check_in=0, current_beacon=implant.beacon, iid=implant.iid, generated_title=new_title, time=int(time.time())) self.Session.add(generated_implant) try: self.Session.commit() self.Session.query(GeneratedImplants).first() except Exception as e: print("db.Add_Implant: ", e) return False active_implant_record = self.Session.query(GeneratedImplants, Implants).filter( Implants.iid == GeneratedImplants.iid, GeneratedImplants.unique_implant_id == unique_implant_key).first() active_implant_record = self.db_methods.__splice_implants_and_generated_implants__(active_implant_record) print("Post splicechecl: ", active_implant_record) # -- Return Raw objects, and caller to manage them, return active_implant_record return False
def Register_NewImplantFromStagerKey(self, StagerKey): # -- We are registering a NEW implant and generating a unique_stager_key (or UIK) # -- Moving forward all reference to ImplantKey/UII should be changed to StagerID I = self.Session.query(Implants).filter(Implants.stager_key==StagerKey).first() if I != None: UIK = random.randint(000000,999999) new_title = str(I.title) +"_"+ str(UIK) GI=GeneratedImplants(unique_implant_id = UIK,last_check_in = 0,current_beacon = I.beacon,iid = I.iid, generated_title = new_title, time=int(time.time())) self.Session.add(GI) try: self.Session.commit() q = self.Session.query(GeneratedImplants).first() print("~",q) except Exception as e: print("db.Add_Implant: ", e) return False GetImplant = self.Session.query(GeneratedImplants, Implants).filter(Implants.iid == GeneratedImplants.iid, GeneratedImplants.unique_implant_id == UIK).first() GetImplant = self.__splice_implants_and_generated_implants__(GetImplant) # GetImplant=self.Session.query(Implants,GeneratedImplants).filter(GeneratedImplants.iid == Implants.iid).filter(Implants.stager_key == StagerKey).first() print("Post splicechecl: ",GetImplant) # -- Return Raw objects, and caller to manage them, return GetImplant return False