Captcha. Verificare fake players

In jos

descarca Captcha. Verificare fake players

Mesaj Scris de CelRau la data de Sam Noi 26, 2016 10:57 am

Descriere: Metoda de a interzice intrarea completa pe server a botilor trimisi cu ajutorul exploit-ului xfakeplayers. La conectarea pe server, dupa fereastra MOTD, jucatorului i se afiseaza pe ecran un numar din 4 cifre (captcha) pe care trebuie sa il introduca in chat. Daca jucatorul nu introduce numarul intr-un anumit timp (setat prin #define), sau il introduce incorect, acesta va primi kick. Vreau sa atentionez faptul ca procedura are loc doar o singura data, pentru fiecare jucator, deoarece pluginul automat inscrie steamid-ul jucatorului verificat intr-un fisier si il memoreaza. Acest fisier se afla aici "addons/amxmodx/data/[Captcha] RealPlayers.ini". La fel este prezenta optiunea prin care jucatorii cu licenta steam si jucatorii care au un anumit flag (acces) pe server vor trece peste aceasta verificare, intrand direct pe server.

Sursa:
Spoiler:
#include <amxmodx>

#define CHECK_TIME 30 // Timpul in secunde, pentru a tasta captcha in chat. Nu trebuie sa fie mai mic de 15.
#define IMMUNITY_FLAGS ADMIN_IMMUNITY // Jucatorii cu acest flag vor trece peste verificare.
#define DARK_SCREEN // Ecran negru in momentul verificarii. Comentati acest define daca nu aveti nevoie de aceasta optiune.
//#define HLTV_BOT_KICK // Kick HLTV sau Server Bots
//#define BLOCK_VOICE // Blocheaza microfonul, daca nu a trecut verificarea. Atentie nu folositi aceasta optiune daca aveti alte pluginuri care lucreaza cu voicechat
#define CHECK_ALWAYS // Dezactiveaza salvarea datelor intr-un fisier, si verifica clientul la fiecare conectare. Comentati acest define daca nu aveti nevoie de aceasta optiune.

new Captcha[33];

#if defined BLOCK_VOICE
#include <fakemeta>
#define GetBit(%1,%2) (%1 & (1 << (%2 & 31)))
#define SetBit(%1,%2) %1 |= (1 << (%2 & 31))
#define ResetBit(%1,%2) %1 &= ~(1 << (%2 & 31))
new g_bBlockVoice;
#endif

#if !defined CHECK_ALWAYS
new Trie:RealPlayers, f, szName[33][32], szSteamID[33][25], iFile[64];
#endif

#if defined DARK_SCREEN
new mScreenFade;
#endif

public plugin_init()
{
#define VERSION "1.5"
register_plugin("Captcha", VERSION, "Factor");

#if !defined CHECK_ALWAYS
formatex(iFile, charsmax(iFile), "addons/amxmodx/data/[Captcha %s] RealPlayers.ini", VERSION);
RealPlayers = TrieCreate();
new buff[64], g_szName[32], g_szSteamID[25];
f = fopen(iFile, "a+");
if(!f) set_fail_state(iFile);
while(!feof(f))
{
fgets(f, buff, charsmax(buff));
trim(buff);
if(!buff[0] || buff[0] == ';') continue;
parse(buff, g_szName, charsmax(g_szName), g_szSteamID, charsmax(g_szSteamID));
TrieSetString(RealPlayers, g_szName, g_szSteamID);
}
fclose(f);
#endif
register_cvar("Captcha", VERSION, FCVAR_SERVER | FCVAR_SPONLY);
register_clcmd("chooseteam", "ChooseTeam_Hook"), register_clcmd("jointeam", "ChooseTeam_Hook"), register_clcmd("joinclass", "ChooseTeam_Hook"), register_clcmd("menuselect", "ChooseTeam_Hook");
register_clcmd("say", "Say_Hook"), register_clcmd("say_team", "Say_Hook");

#if defined BLOCK_VOICE
register_forward(FM_Voice_SetClientListening, "fwdSetClientListening", false);
#endif

#if defined DARK_SCREEN
mScreenFade = get_user_msgid("ScreenFade");
#endif
}

public Say_Hook(client)
{
if(Captcha[client] != 1)
{
static szMessage[16]; // [7] optimal
read_args(szMessage, 15), remove_quotes(szMessage), trim(szMessage);

if(str_to_num(szMessage) == Captcha[client])
{
Captcha[client] = 1;
remove_task(client);
show_menu(client, 0, "^n", 1);
engclient_cmd(client, "jointeam", "0");

#if !defined CHECK_ALWAYS
TrieSetString(RealPlayers, szName[client], szSteamID[client]);
f = fopen(iFile, "a+");
fprintf(f, "^n^"%s^" ^"%s^"", szName[client], szSteamID[client]);
fclose(f);
#endif

#if defined BLOCK_VOICE
ResetBit(g_bBlockVoice, client);
#endif

#if defined DARK_SCREEN
message_begin(MSG_ONE_UNRELIABLE, mScreenFade, _, client);
write_short(1<<0);
write_short(1<<0);
write_short(1<<1);
write_byte(0);
write_byte(0);
write_byte(0);
write_byte(0);
message_end();
#endif
}
else KickPlayer(client);

return PLUGIN_HANDLED;
}

return PLUGIN_CONTINUE;
}

public client_putinserver(client)
{
#if !defined HLTV_BOT_KICK
if(is_user_bot(client) || is_user_hltv(client)) return;
#endif

#if !defined CHECK_ALWAYS
static Steamid[25];
get_user_name(client, szName[client], charsmax(szName));
get_user_authid(client, szSteamID[client], charsmax(szSteamID));
if(TrieGetString(RealPlayers, szName[client], Steamid, charsmax(Steamid)) && equal(Steamid, szSteamID[client]) || user_with_immunity(client) || is_user_steam(client))
#else
if(user_with_immunity(client) || is_user_steam(client))
#endif
{
Captcha[client] = 1;
return;
}

set_msg_block(114, BLOCK_ONCE), set_msg_block(96, BLOCK_ONCE);
set_task(1.0, "CheckClient", client);

#if defined BLOCK_VOICE
SetBit(g_bBlockVoice, client);
#endif
}

public CheckClient(client)
{
if(float(CHECK_TIME) >= 15.0) set_task(float(CHECK_TIME), "KickPlayer", client);
else set_task(15.0, "KickPlayer", client);
GenerateCaptcha(client);

#if defined DARK_SCREEN
message_begin(MSG_ONE_UNRELIABLE, mScreenFade, _, client);
write_short(1<<0);
write_short(1<<0);
write_short(1<<2);
write_byte(0);
write_byte(0);
write_byte(0);
write_byte(255);
message_end();
#endif
}

public client_disconnect(client)
{
Captcha[client] = 0;
remove_task(client);
}

public ChooseTeam_Hook(client)
{
if(Captcha[client] != 1)
{
GenerateCaptcha(client);
return PLUGIN_HANDLED;
}

return PLUGIN_CONTINUE;
}

public GenerateCaptcha(client)
{
static Text_Menu[156];
Captcha[client] = random_num(1000, 9999);
formatex(Text_Menu, charsmax(Text_Menu), "\r[Captcha]\w Verificare fake players.^nTasteaza \y%d\w in chat pentru a intra pe server.", Captcha[client]);
client_print(client, print_chat, "[Captcha] O noua captcha a fost generata.", VERSION);
show_menu(client, MENU_KEY_0, Text_Menu);
}

public KickPlayer(client) server_cmd("kick ^"#%d^" ^"Nu ai trecut verificarea fake players. Incearca din nou.^"", get_user_userid(client));

#if defined BLOCK_VOICE
public fwdSetClientListening(receiver, sender)
{
if(receiver != sender && GetBit(g_bBlockVoice, sender))
{
engfunc(EngFunc_SetClientListening, receiver, sender, false);
forward_return(FMV_CELL, false);
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
#endif

#if !defined CHECK_ALWAYS
public plugin_end() TrieDestroy(RealPlayers);
#endif

bool:user_with_immunity(client)
{
if(get_user_flags(client) & IMMUNITY_FLAGS) return true;
return false;
}

stock is_user_steam(client)
{
static dp_pointer;
if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider")))
{
server_cmd("dp_clientinfo %d", client);
server_exec();
return (get_pcvar_num(dp_pointer) == 2) ? 1 : 0;
}
return 0;
}

Nume: Captcha
Versiune: 1.5

Instalare:
1. Fisierul Captcha.amxx il puneti in addons/amxmodx/plugins
2. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati la urma:
Cod:
Captcha.amxx
3. Atentie! In lista plugins.ini, acest plugin trebuie sa se afle mai sus de pluginurile care lucreaza cu chat-ul.

Cvar-uri:
    Setarile pluginului se modifica din #defines


Comenzi administrative (se tasteaza in consola si trebuie sa fiti administrator):
---

Comenzi publice (se tasteaza in joc prin apasarea tastei Y):
---

Module necesare (se sterge ; din fata modulului de mai jos; acestea le gasiti in fisierul amxmodx\configs\modules.ini):
- fakemeta

Imagini:

avatar
CelRau
Registered user
Registered user

Mesaje : 184
Data de inscriere : 26/11/2016

Sus In jos

Sus

- Subiecte similare

 
Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum