[Tutorial] Ban for Hardware ID

Yuri-BR - [Tutorial] Ban for Hardware ID - RaGEZONE Forums
 
i don't create the HWID Log and HWID_Ban

Error is

In HWID_Ban
Msg 2714, Level 16, State 4, Line 1
There is already an object named 'PK_MacBan' in the database.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.


and in HWID_Log
Msg 2714, Level 16, State 4, Line 1
There is already an object named 'PK_LoginLog' in the database.
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
 
thank you for code
it is generating a new ID for each new login from the same user

gSlGjVW - [Tutorial] Ban for Hardware ID - RaGEZONE Forums


help-me please

id is the same.. It's simply tracking there hardware id every time they login, what if they changed their hardware at some point? Had a second pc? This is normal.
 
lol
Why bother? These guys that msg like that are not fit to dev a game, or even call themselves developers.
i will update my signature now for the fun of it.

I suffered the same with many things, if not the ragezone.
today I would be out there yet.


I like to help contribute.
I'm not miserable

Sorry my english :(
 
Anyone knows how to fix this? My source is Vusion from 2013... All is working, launcher, fine, but HWID doesn't show in the HWID_Log, why and how to fix? :/
(PICTURE UNDER ME)
paodFhT - [Tutorial] Ban for Hardware ID - RaGEZONE Forums
 
Tutorial for Hardware ID Ban by Yuri-BR

​

Solution RSUpdate >
WOLoginHelper.cpp
Search for:
PHP:
#include "SteamHelper.h"

Add:
PHP:
#include "HWInfo.h"

Search for:
PHP:
SaveUserName();

Add:
PHP:
LoadComputerToken();

Search for:
PHP:
req.AddParam("password", passwd);

Add:
PHP:
req.AddParam("computerid", hardwareid);

Search for:
PHP:
bool CLoginHelper::LoadUserName()
{
    // query for game registry node
    HKEY hKey;
    int hr;
    hr = RegOpenKeyEx(HKEY_CURRENT_USER, 
        "Software\\Arktos Entertainment Group\\WarZ", 
        0, 
        KEY_ALL_ACCESS, 
        &hKey);
    if(hr != ERROR_SUCCESS)
        return true;

    DWORD size = sizeof(username);
    hr = RegQueryValueEx(hKey, "username", NULL, NULL, (BYTE*)username, &size);
    RegCloseKey(hKey);

    return true;
}

Add:
PHP:
bool CLoginHelper::LoadComputerToken(){
    HKEY hKey;
    int hr;
    hr = RegOpenKeyEx(HKEY_CURRENT_USER, 
        "Software\\House of Warrior Interactive\\WarZ", 
        0, 
        KEY_ALL_ACCESS, 
        &hKey);
    if(hr != ERROR_SUCCESS)
    {
        CreateComputerToken();
        return true;
    }

    DWORD size = sizeof(hardwareid);
    hr = RegQueryValueEx(hKey, "hardwareid", NULL, NULL, (BYTE*)hardwareid, &size);
    RegCloseKey(hKey);

    return true;
}

void CLoginHelper::CreateComputerToken()
{
    HKEY hKey;
    int hr;
    hr = RegCreateKeyEx(HKEY_CURRENT_USER, 
        "Software\\House of Warrior Interactive\\WarZ", 
        0, 
        NULL,
        REG_OPTION_NON_VOLATILE, 
        KEY_ALL_ACCESS,
        NULL,
        &hKey,
        NULL);
    if(hr == ERROR_SUCCESS)
    {
        CHWInfo g_HardwareInfo;
        g_HardwareInfo.Grab();
        sprintf(hardwareid, "0x%I64x", g_HardwareInfo.uniqueId); // Hardware ID By Yuri-BR

        DWORD size = strlen(hardwareid) + 1;

        hr = RegSetValueEx(hKey, "hardwareid", NULL, REG_SZ, (BYTE*)hardwareid, size);
        RegCloseKey(hKey);
    }
}

WOLoginHelper.h
Search for:
PHP:
char        passwd[128];

Add:
PHP:
char        hardwareid[50];

Search for:
PHP:
bool        LoadUserName();

Add:
PHP:
bool        LoadComputerToken();
void        CreateComputerToken();

Solution WZBackend-ASP.NET > api_login.aspx.cs
Search for:
PHP:
string password = web.Param("password");

Add:
PHP:
string computerid = web.Param("computerid");

Search for:
PHP:
sqcmd.Parameters.AddWithValue("@in_Password", password);

Add:
PHP:
sqcmd.Parameters.AddWithValue("@in_HardwareID", computerid);

SQL Server 2008 > Run this script in the database

HWID_Log
PHP:
USE [WarZ]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[HWID_Log](
[id] [int] IDENTITY(1,1) NOT NULL,
[CustomerID] [int] NOT NULL,
[ip] [nvarchar](50) NOT NULL,
[HardwareID] [nvarchar](50) NOT NULL,
[time] [datetime] NOT NULL,
CONSTRAINT [PK_LoginLog] PRIMARY KEY CLUSTERED 
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

HWID_Ban
PHP:
USE [WarZ]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[HWID_Ban](
[HardwareID] [nvarchar](50) NOT NULL,
[Reason] [nvarchar](200) NOT NULL,
CONSTRAINT [PK_MacBan] PRIMARY KEY CLUSTERED 
(
[HardwareID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

Navicat > WarZ > dbo > function > WZ_ACCOUNT_LOGIN
Search for:
PHP:
@in_EMail varchar(100),

Add:
PHP:
@in_HardwareID varchar(50),

Search for:
PHP:
exec WZ_ACCOUNT_LOGIN_EXEC @in_IP,

Add:
PHP:
@in_HardwareID,

WZ_ACCOUNT_LOGIN_EXEC
Search for:
PHP:
@in_IP varchar(100),

Add:
PHP:
@in_HardwareID varchar(50),

Search for:
PHP:
-- check if game is still active or 90sec passed from last update (COPYPASTE_GAMECHECK, search for others)
    if(@GameServerId > 0 and DATEDIFF(second,    [USER=1333422059]LASTGAME[/USER]date, GETDATE()) < 90) begin
        select
            0 as LoginResult,
               [USER=25895]Custom[/USER]erID as CustomerID,
            70 as AccountStatus,    -- game still active code
            0 as SessionID,
            0 as IsDeveloper
        return
    end

Add:
PHP:
-- Ban por Hardware ID by Yuri-BR
    IF (EXISTS(SELECT * FROM HWID_Ban WHERE HardwareID = @in_HardwareID)) 
    BEGIN
        select
            3 as LoginResult,
               [USER=25895]Custom[/USER]erID as CustomerID,
            200 as AccountStatus,
            0 as SessionID,
            0 as IsDeveloper
        return
    END

Search for:
PHP:
INSERT INTO Logins 
        (CustomerID, LoginTime, IP, LoginSource) 
    VALUES 
            [USER=25895]Custom[/USER]erID, GETDATE(), @in_IP, 0)

Add:
PHP:
-- Insert to HWID_Log
    --if @in_HardwareID != ''
    --begin
        INSERT INTO HWID_Log (CustomerID, ip, HardwareID, time) VALUES     [USER=25895]Custom[/USER]erID,@in_IP,@in_HardwareID,GETDATE())
    --end

Add message for Ban Hardware ID and Fix

LauncherConfig.cpp
Search for:
PHP:
accountBannedMessage = r3dReadCFG_S(configFile, group, "accountBannedMessage",
        "Your account has been permanently banned");

Add:
PHP:
accountHWBannedMessage = r3dReadCFG_S(configFile, group, "accountHWBannedMessage",
        "Your account has been banned by HardwareID");

LauncherConfig.h
Search for:
PHP:
std::string accountBannedMessage;

Add:
PHP:
std::string accountHWBannedMessage;

In Updater.cpp
Search for:
PHP:
case CLoginHelper::ANS_Banned:
        loginErrMsg_ = "Your account has been permanently banned";
        MessageBox(NULL, gLauncherConfig.accountBannedMessage.c_str(), "Login", MB_OK | MB_ICONSTOP);
        break;

Add:
PHP:
case CLoginHelper::ANS_HWBanned:
        loginErrMsg_ = "Your account has been banned by Hardware ID";
        MessageBox(NULL, gLauncherConfig.accountHWBannedMessage.c_str(), "Login", MB_OK | MB_ICONSTOP);
        break;

WOLoginHelper.cpp
Search for:
PHP:
else if(AccountStatus == 201)
        loginAnswerCode = ANS_Frozen;

Add:
PHP:
else if(AccountStatus == 202)
        loginAnswerCode = ANS_HWBanned;

WOLoginHelper.h // Thanks for reminding me @DNC
Search for:
PHP:
ANS_Banned,

Add:
PHP:
ANS_HWBanned,

Navicat > WarZ > dbo > function > WZ_ACCOUNT_LOGIN_EXEC
Search for:
PHP:
if    [USER=1333383561]Accounts[/USER]tatus >= 200) begin
        select
            3 as LoginResult,
               [USER=25895]Custom[/USER]erID as CustomerID,
              [USER=1333383561]Accounts[/USER]tatus as AccountStatus,
            0 as SessionID,
            0 as IsDeveloper
        return
    end

Add:
PHP:
if    [USER=1333383561]Accounts[/USER]tatus >= 202) begin
        select
            3 as LoginResult,
               [USER=25895]Custom[/USER]erID as CustomerID,
              [USER=1333383561]Accounts[/USER]tatus as AccountStatus,
            0 as SessionID,
            0 as IsDeveloper
        return
    end

Search for:
PHP:
-- Ban por Hardware ID by Yuri-BR
    IF (EXISTS(SELECT * FROM HWID_Ban WHERE HardwareID = @in_HardwareID)) 
    BEGIN
        select
            3 as LoginResult,
               [USER=25895]Custom[/USER]erID as CustomerID,
            200 as AccountStatus,
            0 as SessionID,
            0 as IsDeveloper
        return
    END

Replace for:
PHP:
-- Ban por Hardware ID by Yuri-BR
    IF (EXISTS(SELECT * FROM HWID_Ban WHERE HardwareID = @in_HardwareID)) 
    BEGIN
        update UsersData set AccountStatus=202 WHERE CustomerID    [USER=25895]Custom[/USER]erID
        select
            3 as LoginResult,
               [USER=25895]Custom[/USER]erID as CustomerID,
            202 as AccountStatus,
            0 as SessionID,
            0 as IsDeveloper
        return
    END

To ban a player, you need to add the Hardware id of player in table HWID_Ban



Credits:
@aomsin2526 for base code
@Yuri BR for Tutorial and alterations
​


its work bro, tnx. God bless you ..
 
Back