[C++/Python]Hardware Ban

Discuție în 'C++ /Python' creată de Theo222, 8 Noi 2018.

  1. Theo222

    Theo222 Membru

    Înscris:
    17 Noi 2017
    Mesaje:
    142
    Aprecieri primite:
    17
    Puncte trofeu:
    17
    Sex:
    Masculin
    1) First Server Part:



    1-1) Common



    1-1-1) Tables.h



    Search



    typedef struct SAccountTable


    And replace with this



    typedef struct SAccountTable
    {
    DWORD id;
    char login[LOGIN_MAX_LEN + 1];
    char Hwid[HWID_MAX_LEN + 1];
    char Snn[SNN_MAX_LEN + 1];
    char passwd[PASSWD_MAX_LEN + 1];
    char social_id[SOCIAL_ID_MAX_LEN + 1];
    char status[ACCOUNT_STATUS_MAX_LEN + 1];
    BYTE bEmpire;
    TSimplePlayer players[PLAYER_PER_ACCOUNT];
    } TAccountTable;

    Search

    typedef struct SLoginPacket


    And replace with this



    typedef struct SLoginPacket
    {
    char login[LOGIN_MAX_LEN + 1];
    char passwd[PASSWD_MAX_LEN + 1];
    char Hwid[HWID_MAX_LEN + 1];
    char Snn[SNN_MAX_LEN + 1];
    } TLoginPacket;


    Search



    typedef struct SPacketGDAuthLogin


    And replace with this



    typedef struct SPacketGDAuthLogin
    {
    DWORD dwID;
    DWORD dwLoginKey;
    char szLogin[LOGIN_MAX_LEN + 1];
    char szHwid[HWID_MAX_LEN + 1];
    char szSnn[SNN_MAX_LEN + 1];
    char szSocialID[SOCIAL_ID_MAX_LEN + 1];
    DWORD adwClientKey[4];
    BYTE bBillType;
    DWORD dwBillID;
    int iPremiumTimes[PREMIUM_MAX_NUM];
    } TPacketGDAuthLogin;


    1-1-2) Lenght.h



    Search



    PASSWD_MAX_LEN = 16,


    Add it below



    HWID_MAX_LEN = 50,
    SNN_MAX_LEN = 50,




    1-2) Game



    1-2-1) input_auth.cpp



    Search this function



    void CInputAuth::Login(LPDESC d, const char * c_pData)


    Find this



    char passwd[PASSWD_MAX_LEN + 1];
    strlcpy(passwd, pinfo->passwd, sizeof(passwd));


    and add it below



    char Hwid[HWID_MAX_LEN + 1];
    strlcpy(Hwid, pinfo->Hwid, sizeof(Hwid));

    char Snn[SNN_MAX_LEN + 1];
    strlcpy(Snn, pinfo->Snn, sizeof(Snn));

    std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET hwid = '%s', Snn = '%s' WHERE login = '%s'", pinfo->Hwid, pinfo->Snn, login));


    1-2-2) packet.h



    Search



    typedef struct command_login2


    and replace with this





    typedef struct command_login2
    {
    BYTE header;
    char login[LOGIN_MAX_LEN + 1];
    DWORD dwLoginKey;
    DWORD adwClientKey[4];
    char Hwid[HWID_MAX_LEN + 1];
    char Snn[SNN_MAX_LEN + 1];
    } TPacketCGLogin2;


    Search



    typedef struct command_login3


    and replace with this



    typedef struct command_login3
    {
    BYTE header;
    char login[LOGIN_MAX_LEN + 1];
    char passwd[PASSWD_MAX_LEN + 1];
    char Hwid[HWID_MAX_LEN + 1];
    char Snn[SNN_MAX_LEN + 1];
    DWORD adwClientKey[4];
    } TPacketCGLogin3;


    2) Second Client Part



    2-1)Pack



    2-1-1)Constinfo.py



    Add anywhere



    import os
    try: Hwid = os.popen("wmic csproduct get uuid").read().split("n")[1]
    except: Hwid = os.popen("%WINDIR%/system32/wbem/wmic csproduct get uuid").read().split("n")[1]
    try: Snn = os.popen('wmic path win32_physicalmedia get SerialNumber').read().split("n")[1]
    except: Snn = os.popen("%WINDIR%/system32/wbem/wmic path win32_physicalmedia get SerialNumber").read().split("n")[1]




    2-1-2)Networkmodule.py



    add this import



    import constInfo


    and add it below



    Hwid=constInfo.Hwid
    Snn=constInfo.Snn


    Search



    self.pwd=""


    and add it below



    self.Hwid=constInfo.Hwid
    self.Snn=constInfo.Snn


    Search



    def SetLoginInfo(self, id, pwd)
    self.id = id
    self.pwd = pwd
    net.SetLoginInfo(id, pwd)


    and replace with this



    def SetLoginInfo(self, id, pwd, Hwid, Snn):
    self.id = id
    self.pwd = pwd
    self.Hwid = constInfo.Hwid
    self.Snn = constInfo.Snn
    net.SetLoginInfo(id, pwd, Hwid, Snn)


    2-2-3)introLogin.py



    Search



    RUNUP_MATRIX_AUTH = FALSE


    Add top



    Hwid = constInfo.Hwid
    Snn = constInfo.Snn


    Search this function



    def Connect(self, id):


    and replace with this



    def Connect(self, id, pwd, Hwid, Snn):
    global Hwid, Snn
    if constInfo.SEQUENCE_PACKET_ENABLE:
    net.SetPacketSequenceMode()

    if IsLoginDelay():
    loginDelay = GetLoginDelay()
    self.connectingDialog = ConnectingDialog()
    self.connectingDialog.Open(loginDelay)
    self.connectingDialog.SAFE_SetTimeOverEvent(self.OnEndCountDown)
    self.connectingDialog.SAFE_SetExitEvent(self.OnPressExitKey)
    self.isNowCountDown = TRUE

    else:
    self.stream.popupWindow.Close()
    self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.SetPasswordEditLineFocus, localeInfo.UI_CANCEL)

    self.stream.SetLoginInfo(id, pwd, Hwid, Snn)
    self.stream.Connect()


    Search



    def __LoadLoginInfo(self, loginInfoFileName):


    Add it below



    global Hwid, Snn


    Search



    self.pwd = None


    Add it below



    self.Hwid = Hwid
    self.Snn = Snn


    Search



    self.Connect(id, pwd)


    Replace with this



    self.Connect(id, pwd, Hwid, Snn)


    Search



    self.Connect(id, pwd)


    Replace With This



    self.Connect(id, pwd, Hwid, Snn)


    Search



    def __OnClickLoginButton(self):


    Add it below



    global Hwid, Snn




    2-2)Client



    2-2-1)Packet.h



    Search



    PASS_MAX_NUM = 16,


    and add it below



    HWID_MAX_NUM = 50,
    SNN_MAX_NUM = 50,


    Search



    typedef struct command_login


    And replace with this



    typedef struct command_login
    {
    BYTE header;
    char name[ID_MAX_NUM + 1];
    char pwd[PASS_MAX_NUM + 1];
    char Hwid[HWID_MAX_NUM + 1];
    char Snn[SNN_MAX_NUM + 1];
    } TPacketCGLogin;


    Search



    typedef struct command_login3


    And replace with this

    typedef struct command_login3
    {
    BYTE header;
    char name[ID_MAX_NUM + 1];
    char pwd[PASS_MAX_NUM + 1];
    char Hwid[HWID_MAX_NUM + 1];
    char Snn[SNN_MAX_NUM + 1];
    DWORD adwClientKey[4];
    } TPacketCGLogin3;


    Search



    typedef struct command_direct_enter


    And replace with this



    typedef struct command_direct_enter
    {
    BYTE bHeader;
    char login[ID_MAX_NUM + 1];
    char passwd[PASS_MAX_NUM + 1];
    char Hwid[HWID_MAX_NUM + 1];
    char Snn[SNN_MAX_NUM + 1];
    BYTE index;
    } TPacketCGDirectEnter;




    2-2-2)AccountConnector.h



    Search



    void SetLoginInfo(const char * c_szName, const char * c_szPwd


    Replace with this

    void SetLoginInfo(const char * c_szName, const char * c_szPwd, const char * c_szHwid, const char * c_szSnn);


    Search



    std::string m_strPassword;


    Add it below



    std::string m_strHwid;
    std::string m_strSnn;




    2-2-3)AccountConnector.cpp



    Search this function



    void CAccountConnector::SetLoginInfo(const char * c_szName, const char * c_szPwd)


    Replace with this



    void CAccountConnector::SetLoginInfo(const char * c_szName, const char * c_szPwd, const char * c_szHwid, const char * c_szSnn)
    {
    m_strID = c_szName;
    m_strPassword = c_szPwd;
    m_strHwid = c_szHwid;
    m_strSnn = c_szSnn;
    }


    Search



    strncpy(LoginPacket.pwd, m_strPassword.c_str(), PASS_MAX_NUM);


    add it below



    strncpy(LoginPacket.Hwid, m_strHwid.c_str(), HWID_MAX_NUM);
    strncpy(LoginPacket.Snn, m_strSnn.c_str(), SNN_MAX_NUM);


    Search



    LoginPacket.pwd[PASS_MAX_NUM] = '0';


    Add it below



    LoginPacket.Hwid[HWID_MAX_NUM] = '0';
    LoginPacket.Snn[SNN_MAX_NUM] = '0';


    Search



    SetLoginInfo("", "");


    Replace with this



    SetLoginInfo("", "", "", "");




    2-2-4)PythonNetworkStreamPhaseLogin.cpp



    Search(2x)



    if (0 != m_dwLoginKey)


    and replace with this



    if (0 != m_dwLoginKey)
    SendLoginPacketNew(m_stID.c_str(), m_stPassword.c_str(), m_stHwid.c_str(), m_stSnn.c_str());
    else
    SendLoginPacket(m_stID.c_str(), m_stPassword.c_str(), m_stHwid.c_str(), m_stSnn.c_str());


    Search this function



    bool CPythonNetworkStream::SendDirectEnterPacket(const char* c_szID, const char* c_szPassword)


    replace with this



    bool CPythonNetworkStream::SendDirectEnterPacket(const char* c_szID, const char* c_szPassword, const char* c_szHwid, const char* c_szSnn, UINT uChrSlot)
    {
    TPacketCGDirectEnter kPacketDirectEnter;
    kPacketDirectEnter.bHeader=HEADER_CG_DIRECT_ENTER;
    kPacketDirectEnter.index=uChrSlot;
    strncpy(kPacketDirectEnter.login, c_szID, ID_MAX_NUM);
    strncpy(kPacketDirectEnter.passwd, c_szPassword, PASS_MAX_NUM);
    strncpy(kPacketDirectEnter.Hwid, c_szHwid, HWID_MAX_NUM);
    strncpy(kPacketDirectEnter.Snn, c_szSnn, SNN_MAX_NUM);

    if (!Send(sizeof(kPacketDirectEnter), &kPacketDirectEnter))
    {
    Tracen("SendDirectEnter");
    return false;
    }

    return SendSequence();
    }


    Search this function



    bool CPythonNetworkStream::SendLoginPacket(const char* c_szName, const char* c_szPassword)


    and replace with this



    bool CPythonNetworkStream::SendLoginPacket(const char* c_szName, const char* c_szPassword, const char* c_szHwid, const char* c_szSnn)
    {
    TPacketCGLogin LoginPacket;
    LoginPacket.header = HEADER_CG_LOGIN;

    strncpy(LoginPacket.name, c_szName, sizeof(LoginPacket.name)-1);
    strncpy(LoginPacket.pwd, c_szPassword, sizeof(LoginPacket.pwd)-1);
    strncpy(LoginPacket.Hwid, c_szHwid, sizeof(LoginPacket.Hwid)-1);
    strncpy(LoginPacket.Snn, c_szSnn, sizeof(LoginPacket.Snn)-1);

    LoginPacket.name[ID_MAX_NUM]='0';
    LoginPacket.pwd[PASS_MAX_NUM]='0';
    LoginPacket.Hwid[HWID_MAX_NUM]='0';
    LoginPacket.Snn[SNN_MAX_NUM]='0';

    if (!Send(sizeof(LoginPacket), &LoginPacket))
    {
    Tracen("SendLogin Error");
    return false;
    }

    return SendSequence();
    }


    Search



    bool CPythonNetworkStream::SendLoginPacketNew(const char * c_szName, const char * c_szPassword)


    and replace with this



    bool CPythonNetworkStream::SendLoginPacketNew(const char * c_szName, const char * c_szPassword, const char * c_szHwid, const char * c_szSnn)


    2-2-4)PythonNetworkStreamModule.cpp



    Search this function



    PyObject* netSetLoginInfo(PyObject* poSelf, PyObject* poArgs)


    and replace with this



    PyObject* netSetLoginInfo(PyObject* poSelf, PyObject* poArgs)
    {
    char* szName;
    if (!PyTuple_GetString(poArgs, 0, &szName))
    return Py_BuildException();

    char* szPwd;
    if (!PyTuple_GetString(poArgs, 1, &szPwd))
    return Py_BuildException();

    char* szHwid;
    if (!PyTuple_GetString(poArgs, 2, &szHwid))
    return Py_BuildException();

    char* szSnn;
    if (!PyTuple_GetString(poArgs, 3, &szSnn))
    return Py_BuildException();


    CPythonNetworkStream& rkNetStream=CPythonNetworkStream::Instance();
    CAccountConnector & rkAccountConnector = CAccountConnector::Instance();
    rkNetStream.SetLoginInfo(szName, szPwd, szHwid, szSnn);
    rkAccountConnector.SetLoginInfo(szName, szPwd, szHwid, szSnn);
    return Py_BuildNone();
    }


    Search this function



    PyObject* netSendLoginPacket(PyObject* poSelf, PyObject* poArgs)


    and replace with this



    PyObject* netSendLoginPacket(PyObject* poSelf, PyObject* poArgs)
    {
    char* szName;
    if (!PyTuple_GetString(poArgs, 0, &szName))
    return Py_BuildException();

    char* szPwd;
    if (!PyTuple_GetString(poArgs, 1, &szPwd))
    return Py_BuildException();

    char* szHwid;
    if (!PyTuple_GetString(poArgs, 2, &szHwid))
    return Py_BuildException();

    char* szSnn;
    if (!PyTuple_GetString(poArgs, 3, &szSnn))
    return Py_BuildException();

    CPythonNetworkStream& rkNetStream=CPythonNetworkStream::Instance();
    rkNetStream.SendLoginPacket(szName, szPwd, szHwid, szSnn);
    return Py_BuildNone();
    }


    2-2-5)PythonNetworkStream.h



    Search



    void SetLoginInfo(const char* c_szID, const char* c_szPassword);


    Replace with this



    void SetLoginInfo(const char* c_szID, const char* c_szPassword, const char* c_szHwid, const char* c_szSnn);




    Search



    bool SendLoginPacket(const char * c_szName, const char * c_szPassword);
    bool SendLoginPacketNew(const char * c_szName, const char * c_szPassword);


    Replace with this



    bool SendLoginPacket(const char * c_szName, const char * c_szPassword, const char * c_szHwid, const char * c_szSnn);
    bool SendLoginPacketNew(const char * c_szName, const char * c_szPassword, const char * c_szHwid, const char * c_szSnn);


    Search



    bool SendDirectEnterPacket(const char * c_szName, const char * c_szPassword, UINT uChrSlot);


    And replace with this



    bool SendDirectEnterPacket(const char * c_szName, const char * c_szPassword, const char * c_szHwid, const char * c_szSnn, UINT uChrSlot);


    Search



    std::string m_stPassword;


    Add it below



    std::string m_stHwid;
    std::string m_stSnn;


    2-2-6)PythonNetworkStream.cpp



    Search this function



    void CPythonNetworkStream::SetLoginInfo(const char* c_szID, const char* c_szPassword)


    And replace with this



    void CPythonNetworkStream::SetLoginInfo(const char* c_szID, const char* c_szPassword, const char* c_szHwid, const char* c_szSnn)
    {
    m_stID=c_szID;
    m_stPassword=c_szPassword;
    m_stHwid=c_szHwid;
    m_stSnn=c_szSnn;
    }






    Now run this query commands;



    ALTER TABLE account.account ADD Hwid VARCHAR(50);
    ALTER TABLE account.account ADD Snn VARCHAR(50);


    Create tables



    DROP TABLE IF EXISTS `snnban`;
    CREATE TABLE `snnban` (
    `Snn` varchar(255) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

    DROP TABLE IF EXISTS `hwidban`;
    CREATE TABLE `hwidban` (
    `Hwid` varchar(255) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;




    Basic php ban script

    <?php
    error_reporting(0);

    if($_GET)
    {
    $baglanti = mysqli_connect('localhost', 'root', 'PASSWORD', 'account');
    $hwid = mysqli_real_escape_string($baglanti, $_GET['hwid']);
    $snn = mysqli_real_escape_string($baglanti, $_GET['snn']);

    if(strlen($snn) == 0) {
    $hwid_bul = mysqli_query($baglanti, "SELECT null FROM hwidban WHERE hwid='$hwid'");
    if(mysqli_num_rows($hwid_bul) > 0) echo 'BLOCK';
    mysqli_free_result($hwid_bul);
    }else{
    $snn_bul = mysqli_query($baglanti, "SELECT null FROM snnban WHERE snn='$snn'");
    if(mysqli_num_rows($snn_bul) > 0) echo 'BLOCK';
    mysqli_free_result($snn_bul);
    }

    mysqli_close($baglanti);
    }
    ?>
     

Distribuie pagina asta