-
Notifications
You must be signed in to change notification settings - Fork 0
/
gadget.h
83 lines (62 loc) · 1.11 KB
/
gadget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef JITROP_GADGET_H
#define JITROP_GADGET_H
#include <cstdint>
#include <cstddef>
#include <cstdio>
#include <climits>
#include <string>
using namespace std;
class Ending {
public:
char rgx [128];
int rlen;
int blen;
Ending(const char *myrgx, int len, int bxlen){
memcpy(rgx, myrgx, len);
rlen = len;
blen = bxlen;
}
};
class Gadget {
private:
int inst_count;
string gadget;
bool has_address;
public:
Gadget(){
inst_count = 0;
gadget = "";
has_address = false;
}
void append(unsigned long addr, char *mnem, char *args) {
if (!has_address) {
gadget.append(to_string(addr));
gadget.append(": ");
has_address = true;
}
gadget.append(mnem);
if (strlen(args) > 0){
gadget.append(" ");
gadget.append(args);
}
gadget.append("; ");
inst_count++;
}
string get_gadget(){
return gadget;
}
int length() {
return inst_count;
}
bool is_empty() {
return gadget.empty();
}
};
vector<string> create_gadgets(
uint8_t *dest_buffer,
size_t size,
unsigned long target_address,
int inst_count,
int gtype
);
#endif //JITROP_GADGET_H