libTriton version 1.0 build 1592
Loading...
Searching...
No Matches
taintEngine.hpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
8#ifndef TRITON_TAINTENGINE_H
9#define TRITON_TAINTENGINE_H
10
11#include <unordered_set>
12
13#include <triton/dllexport.hpp>
15#include <triton/modes.hpp>
16#include <triton/register.hpp>
19
20
21
23namespace triton {
30 namespace engines {
38 namespace taint {
46 const bool TAINTED = true;
47
49 const bool UNTAINTED = !TAINTED;
50
54 private:
57
60
63
64 protected:
66 std::unordered_set<triton::uint64> taintedMemory;
67
69 std::unordered_set<triton::arch::register_e> taintedRegisters;
70
71 public:
74
76 TRITON_EXPORT TaintEngine(const TaintEngine& other);
77
79 TRITON_EXPORT TaintEngine& operator=(const TaintEngine& other);
80
82 TRITON_EXPORT const std::unordered_set<triton::uint64>& getTaintedMemory(void) const;
83
85 TRITON_EXPORT std::unordered_set<const triton::arch::Register*> getTaintedRegisters(void) const;
86
88 TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const;
89
91 TRITON_EXPORT bool isMemoryTainted(const triton::arch::MemoryAccess& mem, bool mode=true) const;
92
94 TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register& reg) const;
95
97 TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper& op) const;
98
100 TRITON_EXPORT bool setTaint(const triton::arch::OperandWrapper& op, bool flag);
101
103 TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess& mem, bool flag);
104
106 TRITON_EXPORT bool setTaintRegister(const triton::arch::Register& reg, bool flag);
107
109 TRITON_EXPORT bool taintMemory(triton::uint64 addr);
110
112 TRITON_EXPORT bool taintMemory(const triton::arch::MemoryAccess& mem);
113
115 TRITON_EXPORT bool taintRegister(const triton::arch::Register& reg);
116
118 TRITON_EXPORT bool untaintMemory(triton::uint64 addr);
119
121 TRITON_EXPORT bool untaintMemory(const triton::arch::MemoryAccess& mem);
122
124 TRITON_EXPORT bool untaintRegister(const triton::arch::Register& reg);
125
127 TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2);
128
130 TRITON_EXPORT bool taintUnion(const triton::arch::MemoryAccess& memDst, const triton::arch::Immediate& imm);
131
133 TRITON_EXPORT bool taintUnion(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
134
136 TRITON_EXPORT bool taintUnion(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
137
139 TRITON_EXPORT bool taintUnion(const triton::arch::Register& regDst, const triton::arch::Immediate& imm);
140
142 TRITON_EXPORT bool taintUnion(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
143
145 TRITON_EXPORT bool taintUnion(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
146
148 TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper& op1, const triton::arch::OperandWrapper& op2);
149
151 TRITON_EXPORT bool taintAssignment(const triton::arch::MemoryAccess& memDst, const triton::arch::Immediate& imm);
152
154 TRITON_EXPORT bool taintAssignment(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
155
157 TRITON_EXPORT bool taintAssignment(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
158
160 TRITON_EXPORT bool taintAssignment(const triton::arch::Register& regDst, const triton::arch::Immediate& imm);
161
163 TRITON_EXPORT bool taintAssignment(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
164
166 TRITON_EXPORT bool taintAssignment(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
167
168 private:
170 bool unionMemoryImmediate(const triton::arch::MemoryAccess& memDst);
171
173 bool unionMemoryMemory(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
174
176 bool unionMemoryRegister(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
177
179 bool unionRegisterImmediate(const triton::arch::Register& regDst);
180
182 bool unionRegisterMemory(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
183
185 bool unionRegisterRegister(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
186
188 bool assignmentMemoryImmediate(const triton::arch::MemoryAccess& memDst);
189
191 bool assignmentMemoryMemory(const triton::arch::MemoryAccess& memDst, const triton::arch::MemoryAccess& memSrc);
192
194 bool assignmentMemoryRegister(const triton::arch::MemoryAccess& memDst, const triton::arch::Register& regSrc);
195
197 bool assignmentRegisterImmediate(const triton::arch::Register& regDst);
198
200 bool assignmentRegisterMemory(const triton::arch::Register& regDst, const triton::arch::MemoryAccess& memSrc);
201
203 bool assignmentRegisterRegister(const triton::arch::Register& regDst, const triton::arch::Register& regSrc);
204 };
205
207 };
209 };
211};
212
213#endif /* !__TRITON_TAINTENGINE_H__ */
This interface is used as abstract CPU interface. All CPU must use this interface.
This class is used to represent an immediate.
Definition immediate.hpp:37
This class is used to represent a memory access.
This class is used as operand wrapper.
This class is used when an instruction has a register operand.
Definition register.hpp:44
std::unordered_set< triton::arch::register_e > taintedRegisters
The set of tainted registers. Currently it is an over approximation of the taint.
TRITON_EXPORT bool taintRegister(const triton::arch::Register &reg)
Taints a register. Returns TAINTED if the register has been tainted correctly. Otherwise it returns t...
TRITON_EXPORT bool setTaint(const triton::arch::OperandWrapper &op, bool flag)
Sets the flag (taint or untaint) to an abstract operand (Register or Memory).
TRITON_EXPORT bool setTaintMemory(const triton::arch::MemoryAccess &mem, bool flag)
Sets the flag (taint or untaint) to a memory.
TRITON_EXPORT bool untaintMemory(triton::uint64 addr)
Untaints an address. Returns !TAINTED if the address has been untainted correctly....
TRITON_EXPORT bool isTainted(const triton::arch::OperandWrapper &op) const
Abstract taint verification. Returns true if the operand is tainted.
TRITON_EXPORT std::unordered_set< const triton::arch::Register * > getTaintedRegisters(void) const
Returns the tainted registers.
TRITON_EXPORT bool isMemoryTainted(triton::uint64 addr, triton::uint32 size=1) const
Returns true if the addr is tainted.
std::unordered_set< triton::uint64 > taintedMemory
The set of tainted addresses.
TRITON_EXPORT bool taintUnion(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
Abstract union tainting.
TRITON_EXPORT bool setTaintRegister(const triton::arch::Register &reg, bool flag)
Sets the flag (taint or untaint) to a register.
TRITON_EXPORT bool taintAssignment(const triton::arch::OperandWrapper &op1, const triton::arch::OperandWrapper &op2)
Abstract assignment tainting.
TRITON_EXPORT TaintEngine(const triton::modes::SharedModes &modes, triton::engines::symbolic::SymbolicEngine *symbolicEngine, triton::arch::CpuInterface &cpu)
Constructor.
TRITON_EXPORT bool untaintRegister(const triton::arch::Register &reg)
Untaints a register. Returns !TAINTED if the register has been untainted correctly....
TRITON_EXPORT bool taintMemory(triton::uint64 addr)
Taints an address. Returns TAINTED if the address has been tainted correctly. Otherwise it returns th...
TRITON_EXPORT bool isRegisterTainted(const triton::arch::Register &reg) const
Returns true if the register is tainted.
TRITON_EXPORT const std::unordered_set< triton::uint64 > & getTaintedMemory(void) const
Returns the tainted addresses.
TRITON_EXPORT TaintEngine & operator=(const TaintEngine &other)
Copies a TaintEngine.
std::shared_ptr< triton::modes::Modes > SharedModes
Shared Modes.
Definition modes.hpp:66
const bool TAINTED
Defines a tainted item.
const bool UNTAINTED
Defines an untainted item.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
The Triton namespace.