| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
ah_mh_request_id = 99 |
| 14 |
|
| 15 |
ah_mh_offset = 0x0047FD12 |
| 16 |
|
| 17 |
ah_mh_value = 139 |
| 18 |
|
| 19 |
|
| 20 |
function ah_init() |
| 21 |
timer_add("ah_timer", config.ah_interval, ah_timer_tick) |
| 22 |
INFO("Starcraft Antihack activated") |
| 23 |
end |
| 24 |
|
| 25 |
|
| 26 |
function ah_timer_tick(options) |
| 27 |
|
| 28 |
for i,game in pairs(api.server_get_games()) do |
| 29 |
|
| 30 |
if game.clienttag and (game.clienttag == CLIENTTAG_BROODWARS) then |
| 31 |
|
| 32 |
if game.players and (substr_count(game.players, ",") > -1) then |
| 33 |
|
| 34 |
|
| 35 |
for username in string.split(game.players,",") do |
| 36 |
api.client_readmemory(username, ah_mh_request_id, ah_mh_offset, 2) |
| 37 |
|
| 38 |
|
| 39 |
end |
| 40 |
end |
| 41 |
end |
| 42 |
end |
| 43 |
end |
| 44 |
|
| 45 |
|
| 46 |
function ah_handle_client(account, request_id, data) |
| 47 |
local is_cheater = false |
| 48 |
|
| 49 |
|
| 50 |
if (request_id == ah_mh_request_id) then |
| 51 |
|
| 52 |
local value = bytes_to_int(data, 0, 2) |
| 53 |
|
| 54 |
|
| 55 |
if not (value == ah_mh_value) then |
| 56 |
is_cheater = true |
| 57 |
end |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
end |
| 63 |
|
| 64 |
|
| 65 |
if (is_cheater) then |
| 66 |
|
| 67 |
account_set_auth_lock(account.name, true) |
| 68 |
account_set_auth_lockreason(account.name, "we do not like cheaters") |
| 69 |
|
| 70 |
|
| 71 |
local game = api.game_get_by_id(account.game_id) |
| 72 |
if game then |
| 73 |
for username in string.split(game.players,",") do |
| 74 |
api.message_send_text(username, message_type_error, nil, account.name .. " was banned by the antihack system.") |
| 75 |
end |
| 76 |
end |
| 77 |
|
| 78 |
|
| 79 |
api.client_kill(account.name) |
| 80 |
|
| 81 |
INFO(account.name .. " was banned by the antihack system.") |
| 82 |
end |
| 83 |
end |