SHOW:
|
|
- or go back to the newest paste.
1 | #define FILTERSCRIPT | |
2 | ||
3 | #include <a_samp> | |
4 | #include <pawn.RakNet> | |
5 | ||
6 | // - | |
7 | #define VERS "2.4" | |
8 | ||
9 | #define C_GREEN 0x20DD6AFF | |
10 | #define C_ERROR 0xA01616FF | |
11 | ||
12 | #define MOBILE_CLIENT "ED40ED0E8089CC44C08EE9580F4C8C44EE8EE990" | |
13 | ||
14 | // - | |
15 | native SendClientCheck(playerid, type, arg, offsetMem, size); | |
16 | native gpci(playerid, serial[], maxlen); | |
17 | ||
18 | // - | |
19 | enum PR_JoinData | |
20 | { | |
21 | PR_iVersion, | |
22 | PR_byteMod, | |
23 | PR_byteNicknameLen, | |
24 | PR_NickName[24], | |
25 | PR_uiClientChallengeResponse, | |
26 | PR_byteAuthKeyLen, | |
27 | PR_auth_key[50], | |
28 | PR_iClientVerLen, | |
29 | PR_ClientVersion[30] | |
30 | }; | |
31 | ||
32 | enum AC_PlayerData { | |
33 | bool:mobilePlayer, | |
34 | bool:pSuspicious, | |
35 | bool:pResponded, | |
36 | pCheat, | |
37 | pCheckSum | |
38 | }; | |
39 | ||
40 | new AC_Player[MAX_PLAYERS][AC_PlayerData]; | |
41 | ||
42 | // ------------ | |
43 | new rMemAddr[10]; | |
44 | new opcodes[10] = { | |
45 | 0x06865E, | |
46 | 0xA88774, | |
47 | 0xDB6746, | |
48 | 0xFDB957, | |
49 | 0x52D558, | |
50 | 0xE4FC58, | |
51 | 0x1BA246, | |
52 | 0xB0C56F, | |
53 | 0xF9855E, | |
54 | 0xF51D54 | |
55 | }; | |
56 | new expectedValues[10] = {192, 72, 192, 68, 196, 64, 8, 200, 200, 128}; | |
57 | ||
58 | // -- Callbacks -- | |
59 | public OnFilterScriptInit() | |
60 | { | |
61 | print("--------------------------------------------------"); | |
62 | print("\t"); | |
63 | print("\t"); | |
64 | print(" AntyCheat "VERS" by Pevenaider loaded "); | |
65 | print("\t"); | |
66 | print("\t"); | |
67 | print("--------------------------------------------------"); | |
68 | return 1; | |
69 | } | |
70 | ||
71 | public OnPlayerConnect(playerid) | |
72 | { | |
73 | new version[24], pAuth[43]; | |
74 | ||
75 | // -- | |
76 | AC_Player[playerid][pCheat] = -1; | |
77 | AC_Player[playerid][mobilePlayer] = false; | |
78 | AC_Player[playerid][pSuspicious] = false; | |
79 | AC_Player[playerid][pResponded] = false; | |
80 | ||
81 | // -- Client version | GPCI -- | |
82 | GetPlayerVersion(playerid, version, sizeof(version)); | |
83 | gpci(playerid, pAuth, sizeof(pAuth)); | |
84 | ||
85 | if ( !strcmp ( MOBILE_CLIENT, pAuth, true ) ) | |
86 | { | |
87 | if ( AC_Player[playerid][pCheckSum] == 0xBEEF ) | |
88 | { | |
89 | AC_Player[playerid][mobilePlayer] = true; | |
90 | AC_Player[playerid][pResponded] = true; | |
91 | } else { | |
92 | SendClientMessage(playerid, C_ERROR, "[ERROR] There was a problem with the mobile version authentication, Your IP is temporarily blocked!"); | |
93 | SetTimerEx("kickPlayer", 1500, false, "ii", playerid, 1); | |
94 | } | |
95 | } | |
96 | ||
97 | if ( strcmp ( version, "0.3.7" ) == 0 && AC_Player[playerid][mobilePlayer] == false ) | |
98 | { | |
99 | SendClientMessage(playerid, C_ERROR, "[ERROR] The server requires a client version newer than 0.3.7 R1!"); | |
100 | SetTimerEx("kickPlayer", 1500, false, "ii", playerid, 0); | |
101 | } | |
102 | ||
103 | // -- | |
104 | SendClientCheck(playerid, 0x47, 0, 0, 0x4); | |
105 | SendClientCheck(playerid, 0x48, 0, 0, 0x4); | |
106 | // -- | |
107 | ||
108 | for (new i = 0; i < 10; i++) rMemAddr[i] = rrAddress(opcodes[i]), SendClientCheck(playerid, 0x5, rMemAddr[i], 0x0, 0x4); | |
109 | ||
110 | // -- Check RPC -- | |
111 | CallLocalFunction("OnClientCheckResponse", "iiii", playerid, 0x47, 0xCECECE, 256); | |
112 | CallLocalFunction("OnClientCheckResponse", "iiii", playerid, 0x48, 0xDEDEDE, 256); | |
113 | // - | |
114 | ||
115 | AC_Player[playerid][pCheckSum] = -1; | |
116 | SetTimerEx("autoSobCheck", 2900, false, "i", playerid); | |
117 | return 1; | |
118 | } | |
119 | ||
120 | forward OnClientCheckResponse(playerid, actionid, memaddr, retndata); | |
121 | public OnClientCheckResponse(playerid, actionid, memaddr, retndata) | |
122 | { | |
123 | switch(actionid) | |
124 | { | |
125 | case 0x5: | |
126 | { | |
127 | if ( AC_Player[playerid][mobilePlayer] == false ) { AC_Player[playerid][pResponded] = true; } | |
128 | ||
129 | for (new i = 0; i < 10; i++) | |
130 | { | |
131 | if ( memaddr == rMemAddr[i] ) | |
132 | { | |
133 | if ( retndata != expectedValues[i] ) AC_Player[playerid][pCheat] = i + 1; | |
134 | break; | |
135 | } | |
136 | } | |
137 | } | |
138 | ||
139 | case 0x47: | |
140 | { | |
141 | if ( AC_Player[playerid][mobilePlayer] == false && memaddr == 0x0 && retndata != 256 ) | |
142 | { | |
143 | AC_Player[playerid][pSuspicious] = false; | |
144 | } | |
145 | ||
146 | if ( AC_Player[playerid][mobilePlayer] == false && memaddr == 0xCECECE && retndata == 256 ) | |
147 | { | |
148 | AC_Player[playerid][pSuspicious] = true; | |
149 | // - | |
150 | SendClientCheck(playerid, 0x47, 0, 0, 0x4); | |
151 | } | |
152 | } | |
153 | ||
154 | case 0x48: | |
155 | { | |
156 | if ( AC_Player[playerid][mobilePlayer] == false && memaddr != 0xDEDEDE && retndata == 0 ) | |
157 | { | |
158 | AC_Player[playerid][pSuspicious] = false; | |
159 | } | |
160 | ||
161 | if ( AC_Player[playerid][mobilePlayer] == false && memaddr == 0xDEDEDE && retndata == 256 ) | |
162 | { | |
163 | AC_Player[playerid][pSuspicious] = true; | |
164 | // - | |
165 | SendClientCheck(playerid, 0x48, 0, 0, 0x4); | |
166 | } | |
167 | } | |
168 | } | |
169 | return 1; | |
170 | } | |
171 | ||
172 | forward autoSobCheck(playerid); | |
173 | public autoSobCheck(playerid) | |
174 | { | |
175 | if ( AC_Player[playerid][mobilePlayer] == true ) | |
176 | { | |
177 | SendClientMessage(playerid, C_GREEN, "You’re currently playing the mobile version of SA-MP."); | |
178 | } | |
179 | ||
180 | // -- | |
181 | if ( AC_Player[playerid][pSuspicious] == true ) | |
182 | { | |
183 | SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are probably using some mods. If you think this is a mistake, please contact the Admin."); | |
184 | SetTimerEx("kickPlayer", 1500, false, "ii", playerid, 0); | |
185 | } | |
186 | if ( AC_Player[playerid][pResponded] == false ) | |
187 | { | |
188 | SendClientMessage(playerid, C_ERROR, "[ERROR] System has detected that you are probably using some mods. If you think this is a mistake, please contact the Admin."); | |
189 | SetTimerEx("kickPlayer", 1500, false, "ii", playerid, 0); | |
190 | } | |
191 | // -- | |
192 | ||
193 | switch ( AC_Player[playerid][pCheat] ) | |
194 | { | |
195 | case 1:cheatDetected(playerid, "S0beit"); | |
196 | case 2..4:cheatDetected(playerid, "CLEO"); | |
197 | case 5..6:cheatDetected(playerid, "CLEO / MoonLoader"); | |
198 | case 7:cheatDetected(playerid, "CLEO"); | |
199 | case 8:cheatDetected(playerid, "SilentPatch"); | |
200 | case 9:cheatDetected(playerid, "SampFuncs"); | |
201 | case 10:cheatDetected(playerid, "S0beit"); | |
202 | } | |
203 | return 1; | |
204 | } | |
205 | ||
206 | forward OnIncomingRPC(playerid, rpcid, BitStream:bs); | |
207 | public OnIncomingRPC(playerid, rpcid, BitStream:bs) | |
208 | { | |
209 | switch ( rpcid ) | |
210 | { | |
211 | case 25: | |
212 | { | |
213 | new data[PR_JoinData]; | |
214 | ||
215 | BS_ReadValue( bs, PR_INT32, data[PR_iVersion], PR_UINT8, data[PR_byteMod], PR_UINT8, data[PR_byteNicknameLen], PR_STRING, data[PR_NickName], data[PR_byteNicknameLen], | |
216 | PR_UINT32, data[PR_uiClientChallengeResponse], | |
217 | PR_UINT8, data[PR_byteAuthKeyLen], | |
218 | PR_STRING, data[PR_auth_key], data[PR_byteAuthKeyLen], | |
219 | PR_UINT8, data[PR_iClientVerLen] | |
220 | ); | |
221 | ||
222 | BS_ReadValue( bs, PR_STRING, data[PR_ClientVersion], (data[PR_iClientVerLen] >= 30 ? 30:data[PR_iClientVerLen]) ); | |
223 | // - | |
224 | BS_ReadUint16(bs, AC_Player[playerid][pCheckSum]); | |
225 | } | |
226 | } | |
227 | return 1; | |
228 | } | |
229 | ||
230 | forward kickPlayer(playerid, action); | |
231 | public kickPlayer(playerid, action) | |
232 | { | |
233 | switch ( action ) | |
234 | { | |
235 | case 0:Kick(playerid); | |
236 | case 1: | |
237 | { | |
238 | new pIP[16+1]; | |
239 | ||
240 | GetPlayerIp(playerid, pIP, sizeof(pIP)); | |
241 | BlockIpAddress(pIP, 60 * 3000); | |
242 | } | |
243 | } | |
244 | } | |
245 | ||
246 | // -- | |
247 | static cheatDetected(playerid, const cName[]) | |
248 | { | |
249 | new string[128]; | |
250 | ||
251 | for(new i = 0; i < 7; i++) SendClientMessage(playerid, -1, " "); | |
252 | SendClientMessage(playerid, C_GREEN, "--------------------------------------------"); | |
253 | ||
254 | format(string, 128, "[ERROR] System has detected that you are using %s. Remove it and return to the server!", cName); | |
255 | SendClientMessage(playerid, C_ERROR, string); | |
256 | ||
257 | SetTimerEx("kickPlayer", 1500, false, "ii", playerid, 0); | |
258 | return 1; | |
259 | } | |
260 | ||
261 | static rrAddress(input) | |
262 | { | |
263 | new result; | |
264 | ||
265 | #emit LOAD.S.pri input | |
266 | #emit CONST.alt 0xFF | |
267 | #emit AND | |
268 | #emit CONST.alt 16 | |
269 | #emit SHL | |
270 | #emit STOR.S.pri result | |
271 | ||
272 | #emit LOAD.S.pri input | |
273 | #emit CONST.alt 0xFF00 | |
274 | #emit AND | |
275 | #emit LOAD.S.alt result | |
276 | #emit ADD | |
277 | #emit STOR.S.pri result | |
278 | ||
279 | #emit LOAD.S.pri input | |
280 | #emit CONST.alt 0xFF0000 | |
281 | #emit AND | |
282 | #emit CONST.alt 16 | |
283 | #emit SHR | |
284 | #emit LOAD.S.alt result | |
285 | #emit ADD | |
286 | #emit STOR.S.pri result | |
287 | ||
288 | return result; | |
289 | } |