bool Instruction::isWriteTo(const triton::arch::OperandWrapper& target) const { switch(target.getType()) { case triton::arch::OP_IMM: break; case triton::arch::OP_MEM: for (auto&& pair : this->storeAccess) { const triton::arch::MemoryAccess& m1 = pair.first; const triton::arch::MemoryAccess& m2 = target.getConstMemory(); if (m1.isOverlapWith(m2)) return true; } break; case triton::arch::OP_REG: for (auto&& pair : this->writtenRegisters) { const triton::arch::Register& r1 = pair.first; const triton::arch::Register& r2 = target.getConstRegister(); if (r1.isOverlapWith(r2)) return true; } break; default: throw triton::exceptions::Instruction("Instruction::isWriteTo(): Invalid type operand."); } return false; }
/* Sets the flag (taint or untaint) to an abstract operand (Register or Memory). */ bool TaintEngine::setTaint(const triton::arch::OperandWrapper& op, bool flag) { switch (op.getType()) { case triton::arch::OP_IMM: return triton::engines::taint::UNTAINTED; case triton::arch::OP_MEM: return this->setTaintMemory(op.getConstMemory(), flag); case triton::arch::OP_REG: return this->setTaintRegister(op.getConstRegister(), flag); default: throw triton::exceptions::TaintEngine("TaintEngine::setTaint(): Invalid operand."); } }
/* Abstract taint verification. */ bool TaintEngine::isTainted(const triton::arch::OperandWrapper& op) const { switch (op.getType()) { case triton::arch::OP_IMM: return triton::engines::taint::UNTAINTED; case triton::arch::OP_MEM: return this->isMemoryTainted(op.getConstMemory()); case triton::arch::OP_REG: return this->isRegisterTainted(op.getConstRegister()); default: throw triton::exceptions::TaintEngine("TaintEngine::isTainted(): Invalid operand."); } }
bool API::setTaint(const triton::arch::OperandWrapper& op, bool flag) { this->checkTaint(); switch (op.getType()) { case triton::arch::OP_IMM: return triton::engines::taint::UNTAINTED; case triton::arch::OP_MEM: return this->setTaintMemory(op.getConstMemory(), flag); case triton::arch::OP_REG: return this->setTaintRegister(op.getConstRegister(), flag); default: throw std::runtime_error("API::setTaint(): Invalid operand."); } }
/* Abstract assignment tainting */ bool TaintEngine::taintAssignment(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2) { triton::uint32 t1 = op1.getType(); triton::uint32 t2 = op2.getType(); if (t1 == triton::arch::OP_MEM && t2 == triton::arch::OP_IMM) return this->taintAssignmentMemoryImmediate(op1.getConstMemory()); if (t1 == triton::arch::OP_MEM && t2 == triton::arch::OP_MEM) return this->taintAssignmentMemoryMemory(op1.getConstMemory(), op2.getConstMemory()); if (t1 == triton::arch::OP_MEM && t2 == triton::arch::OP_REG) return this->taintAssignmentMemoryRegister(op1.getConstMemory(), op2.getConstRegister()); if (t1 == triton::arch::OP_REG && t2 == triton::arch::OP_IMM) return this->taintAssignmentRegisterImmediate(op1.getConstRegister()); if (t1 == triton::arch::OP_REG && t2 == triton::arch::OP_MEM) return this->taintAssignmentRegisterMemory(op1.getConstRegister(), op2.getConstMemory()); if (t1 == triton::arch::OP_REG && t2 == triton::arch::OP_REG) return this->taintAssignmentRegisterRegister(op1.getConstRegister(), op2.getConstRegister()); throw triton::exceptions::TaintEngine("TaintEngine::taintAssignment(): Invalid operands."); }
bool API::taintAssignment(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2) { triton::uint32 t1 = op1.getType(); triton::uint32 t2 = op2.getType(); if (t1 == triton::arch::OP_MEM && t2 == triton::arch::OP_IMM) return this->taintAssignmentMemoryImmediate(op1.getConstMemory()); if (t1 == triton::arch::OP_MEM && t2 == triton::arch::OP_MEM) return this->taintAssignmentMemoryMemory(op1.getConstMemory(), op2.getConstMemory()); if (t1 == triton::arch::OP_MEM && t2 == triton::arch::OP_REG) return this->taintAssignmentMemoryRegister(op1.getConstMemory(), op2.getConstRegister()); if (t1 == triton::arch::OP_REG && t2 == triton::arch::OP_IMM) return this->taintAssignmentRegisterImmediate(op1.getConstRegister()); if (t1 == triton::arch::OP_REG && t2 == triton::arch::OP_MEM) return this->taintAssignmentRegisterMemory(op1.getConstRegister(), op2.getConstMemory()); if (t1 == triton::arch::OP_REG && t2 == triton::arch::OP_REG) return this->taintAssignmentRegisterRegister(op1.getConstRegister(), op2.getConstRegister()); throw std::runtime_error("API::taintAssignment(): Invalid operands."); }