Skip to content

Commit

Permalink
Fix some bugs / Catch some exceptions during gadget symbolic execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Boyan-MILANOV committed Mar 3, 2020
1 parent 41085d3 commit e710087
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 8 additions & 2 deletions libropium/arch/archX86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ inline IROperand x86_arg_translate(CPUMode mode, addr_t addr, cs_x86_op* arg, IR
segment = ir_none();
}

// === Build the operand now ===
// === Build the operand now ===
// Add base and index if any
if( !index.is_none() ){
if( !base.is_none() ){
Expand All @@ -536,7 +536,7 @@ inline IROperand x86_arg_translate(CPUMode mode, addr_t addr, cs_x86_op* arg, IR
}else{
res = index;
}
}else if (!base.is_none()){
}else if(!base.is_none()){
res = base;
}else{
res = ir_none();
Expand All @@ -559,6 +559,12 @@ inline IROperand x86_arg_translate(CPUMode mode, addr_t addr, cs_x86_op* arg, IR
res = segment;
}
}

// Check res
if( res.is_none() ){
throw symbolic_exception("Got IR_NONE memory operand");
}

// Do load memory if requested
if( load_mem ){
block->add_instr(bblkid, IRInstruction(IROperation::LDM,
Expand Down
6 changes: 5 additions & 1 deletion libropium/database/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ int GadgetDB::analyse_raw_gadgets(vector<RawGadget>& raw_gadgets, Arch* arch){
throw symbolic_exception("symbolic engine returned null semantics");
}
}catch(symbolic_exception& e){
//std::cout << "DEBUG ERROR WHILE EXECUTING GADGET: " << irblock->name << " --> " << e.what() << std::endl;
//std::cout << "DEBUG SYMBOLIC ERROR WHILE EXECUTING GADGET: " << irblock->name << " --> " << e.what() << std::endl;
delete gadget; continue;
delete irblock; irblock = nullptr;
}catch(expression_exception& e){
//std::cout << "DEBUG EXPRESSION ERROR WHILE EXECUTING GADGET: " << irblock->name << " --> " << e.what() << std::endl;
delete gadget; continue;
delete irblock; irblock = nullptr;
}
Expand Down
3 changes: 3 additions & 0 deletions libropium/symbolic/symbolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ Semantics* SymbolicEngine::execute_block(IRBlock* block){
block->known_max_sp_inc = true;
block->max_sp_inc = 0;

// FOR DEBUG
// std::cout << "DEBUG EXECUTING " << block->name << std::endl;

while( !stop ){
/* ====================== Execute an IR basic block ======================== */
/* Execute the basic block as long as there is no reason to stop */
Expand Down

0 comments on commit e710087

Please sign in to comment.