forked from Foxmole/PwnAdventure3
-
Notifications
You must be signed in to change notification settings - Fork 31
/
hook-linux.cc
148 lines (125 loc) · 3.73 KB
/
hook-linux.cc
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// #define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include <iostream>
class Player {
public:
char padding[736];
float speed;
float jumpspeed;
float jumphold;
void Chat(const char *text);
};
struct Vector3 { float x; float y; float z; };
typedef void (*orig_chat_f_type)(Player *, const char *);
typedef void (*orig_teleport_f_type)(Player *, const std::string);
typedef void (*orig_player_f_type)(Player *, bool isAdmin);
typedef void (*orig_fast_travel_f_type)(Player *, const std::string, const std::string);
typedef void (*orig_respawn_f_type)(Player *);
typedef void (*orig_get_fast_travel_f_type)(Player *, const char *);
typedef void (*orig_pos_f_type)(Player *, const Vector3 *);
void Player::Chat(const char *text)
{
std::string str(text);
if (str.compare(0, 3, "tp ") == 0)
{
bool teleport = true;
Vector3 pos;
str.erase(0, 3);
if (!str.compare("GreatBallsOfFire")) {
pos.x = -43655.0;
pos.y = -56210.0;
pos.z = 471.0;
} else if (!str.compare("MichaelAngelo")) {
pos.x = 260255.0;
pos.y = -249336.0;
pos.z = 1476.0;
} else if (!str.compare("Town")) {
pos.x = -39130.0;
pos.y = -20280.0;
pos.z = 2530.0;
} else if (!str.compare("BearChestTop")) {
pos.x = -7894.0;
pos.y = 64482.0;
pos.z = 5663.0;
} else if (!str.compare("BearChestUnder")) {
pos.x = -7894.0;
pos.y = 64482.0;
pos.z = 2663.0 - 244.0;
} else if (!str.compare("BallmerPeak")) {
pos.x = -6791.0;
pos.y = -11655.0;
pos.z = 10528.0;
} else if (!str.compare("LavaCave")) {
pos.x = 50876.0;
pos.y = -5243.0;
pos.z = 1645.0;
} else if (!str.compare("BlockyCave")) {
pos.x = -18450.0;
pos.y = -4360.0;
pos.z = 2225.0;
} else if (!str.compare("GoldFarm")) {
pos.x = 21162.0;
pos.y = 41232.0;
pos.z = 2256.0;
} else if (!str.compare("PirateChest")) {
pos.x = 45774.0;
pos.y = 58794.0;
pos.z = 671.0;
} else {
teleport = false;
std::cout << "Teleport: Wrong location!\n";
}
if (teleport)
{
std::cout << "Teleport: " << str << "\n";
const Vector3 p = pos;
orig_pos_f_type orig;
orig = (orig_pos_f_type) dlsym(RTLD_NEXT, "_ZN5Actor11SetPositionERK7Vector3");
orig(this, &p);
}
}
else if (str.compare(0, 3, "ft ") == 0)
{
str.erase(0, 3);
int pos = str.find(" ");
const std::string origin = str.substr(0, pos);
str.erase(0, pos+1);
const std::string dest = str;
std::cout << "Fast Travel: " << dest << "\n";
orig_fast_travel_f_type orig;
orig = (orig_fast_travel_f_type) dlsym(RTLD_NEXT, "_ZN6Player17PerformFastTravelERKSsS1_");
orig(this, origin, dest);
}
else if (str.compare(0, 3, "sp ") == 0)
{
str.erase(0, 3);
if (str.compare("up") == 0)
this->speed = this->speed * 4;
else if (str.compare("down") == 0)
this->speed = this->speed / 4;
else
std::cout << "Usage: sp <up|down>\n";
}
else if (str.compare(0, 3, "jp ") == 0)
{
str.erase(0, 3);
if (str.compare("up") == 0)
this->jumpspeed = this->jumpspeed * 1.5;
else if (str.compare("down") == 0)
this->jumpspeed = this->jumpspeed / 1.5;
else
std::cout << "Usage: sp <up|down>\n";
}
else
{
orig_chat_f_type orig;
orig = (orig_chat_f_type) dlsym(RTLD_NEXT, "_ZN6Player4ChatEPKc");
orig(this, "Command not identified.");
orig(this, "Type \"help\" for more information.");
}
// Call orignal Player::Chat() function
orig_chat_f_type orig;
orig = (orig_chat_f_type) dlsym(RTLD_NEXT, "_ZN6Player4ChatEPKc");
orig(this, text);
}