def __init__(self): self.choice = None self._vmr = get_vmr() # UI Management self.ui_mgr = UIManager() self.ui_mgr.get_init_menu() self.menu_name = "VMAttack" self.menu_extensions = []
def __init__(self, configs): self.c = configs #init roguebox self.rb = RogueBox(configs) self.ui = UIManager.init(self.c["userinterface"], self.rb) self.l = Logger(log_depth=self.c["verbose"], log_targets=["file", "ui"], ui=self.ui) self.ui.on_key_press(self._act_callback)
def __init__(self, configs): self.rb = RogueBox(configs) self._pending_action_timer = None self.ui = UIManager.init(configs["userinterface"], self.rb) self.l = Logger(log_depth=configs["verbose"], log_targets=["file", "ui"], ui=self.ui) self.ui.on_key_press(self._keypress_callback) self._timer_value = 100 self._pending_action_timer = self.ui.on_timer_end( self._timer_value, self._act_callback)
def __init__(self, configs): import models, history # class instances self.rb = RogueBox(configs) self.model_manager = getattr(models, configs["model_manager"])(self.rb) self.history_manager = getattr(history, configs["history_manager"])(self) # configs self.configs = configs self.configs["iteration"] = 1 self.configs["actions"] = self.rb.get_actions() self.configs["actions_num"] = len(self.configs["actions"]) # gui stuff ui = None log_targets = [] if configs["logsonfile"]: log_targets.append("file") if self.configs["gui"]: self.ui = UIManager.init(configs["userinterface"], self.rb) self._pending_action = None ui = self.ui log_targets.append("ui") self.l = Logger(log_depth=configs["verbose"], log_targets=log_targets, ui=ui) else: log_targets.append("terminal") self.l = Logger(log_depth=configs["verbose"], log_targets=log_targets) # state self.state = self.model_manager.reshape_initial_state( self.rb.compute_state()) self.old_state = self.state # model self.model = self.model_manager.build_model() self.target_model = self.model_manager.build_model() self.target_model.set_weights(self.model.get_weights()) # resume from file # load weights, transitions history and parameters from assets, if any self._load_progress()
def __init__(self, configs): import history, models # class instances self.rogomatic = StalkOMatic(configs) self.model_manager = getattr(models, configs["model_manager"])(self.rogomatic) self.history_manager = getattr(history, configs["history_manager"])(self) # configs self.configs = configs self.configs["iteration"] = 1 self.configs["actions"] = self.rogomatic.get_actions() self.configs["actions_num"] = len(self.configs["actions"]) # gui stuff ui = None log_targets = [] if configs["logsonfile"]: log_targets.append("file") if self.configs["gui"]: self.ui = UIManager.init(configs["userinterface"], self.rogomatic) self._pending_action = None ui = self.ui log_targets.append("ui") self.l = Logger(log_depth=configs["verbose"], log_targets=log_targets, ui=ui) else: log_targets.append("terminal") self.l = Logger(log_depth=configs["verbose"], log_targets=log_targets) # state self.state = self.model_manager.reshape_initial_state( self.rogomatic.compute_state()) self.old_state = self.state self.last_pos = self.rogomatic.player_pos self.same_pos_count = 0 self.starting = False
def __init__(self, configs): import models, history # class instances self.rb = RogueBox(configs) self.model_manager = getattr(models, configs["model_manager"])(self.rb) self.history_manager = getattr(history, configs["history_manager"])(self) # configs self.configs = configs self.configs["iteration"] = 1 self.configs["actions"] = self.rb.get_actions() self.configs["actions_num"] = len(self.configs["actions"]) # let's see if we have config values for how often to save progress self.save_progress_every = 100000 self.set_weights_every = 10000 if 'save_progress_every' in self.configs: self.save_progress_every = int(self.configs['save_progress_every']) if 'set_weights_every' in self.configs: self.set_weights_every = int(self.configs['set_weights_every']) # model file names self.weights_file_name = 'weights.h5' self.parameters_file_name = 'parameters.csv' self.history_file_name = 'history.pkl' if 'weights_file_name' in self.configs: self.weights_file_name = self.configs['weights_file_name'] if 'parameters_file_name' in self.configs: self.parameters_file_name = self.configs['parameters_file_name'] if 'history_file_name' in self.configs: self.history_file_name = self.configs['history_file_name'] # gui stuff ui = None log_targets = [] if configs["logsonfile"]: log_targets.append("file") if self.configs["gui"]: self.ui = UIManager.init(configs["userinterface"], self.rb) self._pending_action = None ui = self.ui log_targets.append("ui") self.l = Logger(log_depth=configs["verbose"], log_targets=log_targets, ui=ui) else: log_targets.append("terminal") self.l = Logger(log_depth=configs["verbose"], log_targets=log_targets) # state self.state = self.model_manager.reshape_initial_state( self.rb.compute_state()) self.old_state = self.state # model self.model = self.model_manager.build_model() self.target_model = self.model_manager.build_model() self.target_model.set_weights(self.model.get_weights()) # resume from file # load weights, transitions history and parameters from assets, if any self._load_progress()
class VMAttack_Manager(object): def __init__(self): self.choice = None self._vmr = get_vmr() # UI Management self.ui_mgr = UIManager() self.ui_mgr.get_init_menu() self.menu_name = "VMAttack" self.menu_extensions = [] ### EVIRONMENT AND INIT ### @property def trace(self): return self.vmr._trace @trace.setter def trace(self, value): self.vmr._trace = value @property def vmr(self): self.update_vmr() return self._vmr @property def dbg_handl(self): return get_dh(self.choice) @dbg_handl.setter def dbg_handl(self, value): self.vmr._dbg_handl = value @property def vm_operands(self): return self.vmr._vm_operands @vm_operands.setter def vm_operands(self, value): self.vmr._vm_operands = value @property def vm_returns(self): return self.vmr._vm_returns @vm_returns.setter def vm_returns(self, value): self.vmr._vm_returns = value @property def vm_ctx(self): return self.vmr._vm_ctx @vm_ctx.setter def vm_ctx(self, value): self.vmr._vm_ctx = value def select_debugger(self): c = Choose([], "Choose your preferred debugger:", 1) c.list = ["Currently selected IDA Debugger", "Bochs Dbg", "Win32 Dbg"] # TODO , "OllyDbg", "Immunity Dbg"] c.width = 33 # choose() starts counting at 1, not 0 self.choice = c.choose() - 1 if self.choice == 1: LoadDebugger('Bochs', 0) elif self.choice == 2: LoadDebugger('Win32', 0) def update_vmr(self): self._vmr = get_vmr() ### UI MANAGEMENT ### @staticmethod def show_about(): AboutWindow().exec_() @staticmethod def show_settings(): SettingsWindow.Show() def show_trace(self): self.update_vmr() if self._vmr.trace is not None: for line in self._vmr.trace: print line.to_str_line() def remove_colors(self): # reset color heads = Heads(SegStart(ScreenEA()), SegEnd(ScreenEA())) for i in heads: SetColor(i, CIC_ITEM, 0xFFFFFF) def extend_menu(self): """ Extends the menu. """ try: self.revert_menu() menu_path = self.menu_name + "/" self.ui_mgr.get_init_menu() self.ui_mgr.add_menu('&' + self.menu_name) # debugger selection - will be added after plugin interaction with ollydbg and immunitydbg will be enabled - as of now no additional value is generated compared to the debugger selection in IDA itself so it is commented out # An alternative to the chooser would be to hook IDAs Debugger selection? #select_debugger_menu_item = add_menu_item(menu_path, "Select VMAttack Debugger", "", 0, self.select_debugger, None) # credits & settings settings_menu_item = add_menu_item(menu_path, "Settings", "", 0, self.show_settings, None) about_menu_item = add_menu_item(menu_path, "About ...", "", 0, self.show_about, None) # instruction trace generation and handling remove_colors_menu_item = add_menu_item( menu_path + "Instruction Trace/", "Remove Colors from Graph", "", 0, self.remove_colors, None) load_trace_menu_item = add_menu_item( menu_path + "Instruction Trace/", "Load Trace", "", 0, load_trace, None) save_trace_menu_item = add_menu_item( menu_path + "Instruction Trace/", "Save Trace", "", 0, save_trace, None) gen_trace_menu_item = add_menu_item( menu_path + "Instruction Trace/", "Generate Trace", "", 0, gen_instruction_trace, (self.choice, )) show_trace_menu_item = add_menu_item( menu_path + "Instruction Trace/", "Show Trace", "", 0, self.show_trace, None) ### automation ### grading_menu_item = add_menu_item( menu_path + 'Automated Analysis/', "Grading System Analysis", "", 0, grading_automaton, None) automaton_menu_item = add_menu_item( menu_path + 'Automated Analysis/', "Run all analysis capabilities", "", 0, self.automaton, None) show_opti_menu_item = add_menu_item( menu_path + "Automated Analysis/Semi Automated (dynamic)/", "Dynamic Trace Optimization", "", 0, optimization_analysis, None) analyze_addr_trace_menu_item = add_menu_item( menu_path + 'Automated Analysis/Semi Automated (dynamic)/', "Clustering Analysis", "", 0, clustering_analysis, None) show_input_output = add_menu_item( menu_path + "Automated Analysis/Semi Automated (dynamic)/", "VM Input<=>Ouput Analysis", "", 0, input_output_analysis, None) deobfuscate_from_menu_item = add_menu_item( menu_path + "Automated Analysis/Semi Automated (static)/", "Static deobfuscate", "", 0, static_deobfuscate, None) show_abstract_graph_menu_item = add_menu_item( menu_path + "Automated Analysis/Semi Automated (static)/", "Create Abstract VM-Graph", "", 0, static_deobfuscate, (2, )) ### manual analysis ### # vm context related static_start_search_menu_item = add_menu_item( menu_path + "Manual Analysis/VM Context/", "Find VM Context (static)", "", 0, static_vmctx, (True, )) find_vm_values_menu_item = add_menu_item( menu_path + "Manual Analysis/VM Context/", "Find VM Context (dynamic)", "", 0, dynamic_vmctx, (True, )) # static analysis menu items manual_static_menu_item = add_menu_item( menu_path + "Manual Analysis/Static/", "Deobfuscate from ...", "", 0, static_deobfuscate, (0, True)) # dynamic analysis menu items follow_virt_register = add_menu_item( menu_path + "Manual Analysis/Dynamic/", "Follow Virtual Register", "", 0, manual_analysis, (3, )) find_reg_mapping = add_menu_item( menu_path + "Manual Analysis/Dynamic/", "Find Virtual Reg to Reg mapping", "", 0, manual_analysis, (2, )) find_vmfunc_input = add_menu_item( menu_path + "Manual Analysis/Dynamic/", "Find VM Function Input Parameter", "", 0, manual_analysis, (1, )) find_vmfunc_output = add_menu_item( menu_path + "Manual Analysis/Dynamic/", "Find VM Function Output Parameter", "", 0, manual_analysis, (0, )) analyze_count_menu_item = add_menu_item( menu_path + "Manual Analysis/Dynamic/", "Address Count", "", 0, address_heuristic, None) #manual_input_output = add_menu_item(menu_path + "Manual Analysis/Dynamic/", " Run Input<=>Ouput Analysis on Function", "", 0, input_output_analysis, (True,)) self.menu_extensions.append(deobfuscate_from_menu_item) self.menu_extensions.append(settings_menu_item) #self.menu_extensions.append(select_debugger_menu_item) self.menu_extensions.append(load_trace_menu_item) self.menu_extensions.append(save_trace_menu_item) self.menu_extensions.append(gen_trace_menu_item) self.menu_extensions.append(analyze_count_menu_item) self.menu_extensions.append(analyze_addr_trace_menu_item) self.menu_extensions.append(static_start_search_menu_item) self.menu_extensions.append(find_vm_values_menu_item) self.menu_extensions.append(automaton_menu_item) self.menu_extensions.append(show_abstract_graph_menu_item) self.menu_extensions.append(find_vmfunc_input) self.menu_extensions.append(find_vmfunc_output) self.menu_extensions.append(manual_static_menu_item) self.menu_extensions.append(find_reg_mapping) self.menu_extensions.append(follow_virt_register) self.menu_extensions.append(show_input_output) self.menu_extensions.append(show_trace_menu_item) self.menu_extensions.append(about_menu_item) self.menu_extensions.append(show_opti_menu_item) self.menu_extensions.append(grading_menu_item) #self.menu_extensions.append(manual_input_output) self.menu_extensions.append(remove_colors_menu_item) except Exception, e: print "[*] Menu could not be added! Following Error occurred:\n %s" % e.message