Jump to content

Anti Wait Hack Damage


Recommended Posts

M2 Download Center

Hidden Content

    Give reaction to this post to see the hidden content.
( Internal )

Hi devs,

I created simple wait hack detection and ban system

open "battle.cpp" and add ths include

#include "db.h"

Result;

 

df5e860410.png

 

 

search "bool IS_SPEED_HACK(LPCHARACTER ch, LPCHARACTER victim, DWORD current_time)"

 

and replace with this

#define ENABLE_SYSCHAT_NOTICE
#define ENABLE_SYSLOG_NOTICE
#define ENABLE_BAN_WAITHACK
bool IS_SPEED_HACK(LPCHARACTER ch, LPCHARACTER victim, DWORD current_time)
{
	if (ch->m_kAttackLog.dwVID == victim->GetVID())
	{
		if (current_time - ch->m_kAttackLog.dwTime < GET_ATTACK_SPEED(ch))
		{
			INCREASE_SPEED_HACK_COUNT(ch);

			if (test_server)
			{
				sys_log(0, "%s attack hack! time (delta, limit)=(%u, %u) hack_count %d",
						ch->GetName(),
						current_time - ch->m_kAttackLog.dwTime,
						GET_ATTACK_SPEED(ch),
						ch->m_speed_hack_count);

				ch->ChatPacket(CHAT_TYPE_INFO, "%s attack hack! time (delta, limit)=(%u, %u) hack_count %d",
						ch->GetName(),
						current_time - ch->m_kAttackLog.dwTime,
						GET_ATTACK_SPEED(ch),
						ch->m_speed_hack_count);
			}

			SET_ATTACK_TIME(ch, victim, current_time);
			SET_ATTACKED_TIME(ch, victim, current_time);
			return true;
		}
	}

	SET_ATTACK_TIME(ch, victim, current_time);

	if (victim->m_AttackedLog.dwPID == ch->GetPlayerID())
	{
		if (current_time - victim->m_AttackedLog.dwAttackedTime < GET_ATTACK_SPEED(ch))
		{
			INCREASE_SPEED_HACK_COUNT(ch);
			if (ch->m_speed_hack_count > 50)
			{
#ifdef ENABLE_SYSLOG_NOTICE
				sys_log(0, "%s Attack Speed HACK! time (delta, limit)=(%u, %u), hack_count = %d",
						ch->GetName(),
						current_time - victim->m_AttackedLog.dwAttackedTime,
						GET_ATTACK_SPEED(ch),
						ch->m_speed_hack_count);
#endif
#ifdef ENABLE_SYSCHAT_NOTICE
				ch->ChatPacket(CHAT_TYPE_INFO, "Attack Speed Hack(%s), (delta, limit)=(%u, %u), hack_count = %d",
						ch->GetName(),
						current_time - victim->m_AttackedLog.dwAttackedTime,
						GET_ATTACK_SPEED(ch),
						ch->m_speed_hack_count);
#endif				
#ifdef ENABLE_BAN_WAITHACK				
				std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("UPDATE account.account SET status= 'BLOCK' WHERE id = %d", ch->GetDesc()->GetAccountTable().id));
#endif
				ch->GetDesc()->DelayedDisconnect(3);
			}
			
			SET_ATTACKED_TIME(ch, victim, current_time);
			return true;
		}
	}

	SET_ATTACKED_TIME(ch, victim, current_time);
	return false;
}

Before:

 

Hidden Content

    Give reaction to this post to see the hidden content.

Hidden Content

    Give reaction to this post to see the hidden content.

 

After:

 

Hidden Content

    Give reaction to this post to see the hidden content.

Hidden Content

    Give reaction to this post to see the hidden content.

 

 

Final:

 

 

  • Metin2 Dev 2
  • Love 19
  • Good 1
Link to comment
  • 4 weeks later...

I changed if (ch->m_speed_hack_count > 50) with if (ch->m_speed_hack_count > 5)

And works verry good .

 

 

I work on mainline sg ,pvm hard server ;

This protection can cause fake result and ban a fair player ?

Link to comment
Wasn't a good ideea , but with >50 works fine now ;

I'm pretty sure if you play ninja with daggers you will get banned :)

The ninja character is the most secured , even you use hack you won't get ban so fast .

i dont know why...

Link to comment

Metod log > more secure :

#define ENABLE_SYSCHAT_NOTICE
#define ENABLE_SYSLOG_NOTICE
#define ENABLE_BAN_WAITHACK
bool IS_SPEED_HACK(LPCHARACTER ch, LPCHARACTER victim, DWORD current_time)
{
    if (ch->m_kAttackLog.dwVID == victim->GetVID())
    {
        if (current_time - ch->m_kAttackLog.dwTime < GET_ATTACK_SPEED(ch))
        {
            INCREASE_SPEED_HACK_COUNT(ch);
 
            if (test_server)
            {
                sys_log(0, "%s attack hack! time (delta, limit)=(%u, %u) hack_count %d",
                        ch->GetName(),
                        current_time - ch->m_kAttackLog.dwTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
 
                ch->ChatPacket(CHAT_TYPE_INFO, "%s attack hack! time (delta, limit)=(%u, %u) hack_count %d",
                        ch->GetName(),
                        current_time - ch->m_kAttackLog.dwTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
            }
 
            SET_ATTACK_TIME(ch, victim, current_time);
            SET_ATTACKED_TIME(ch, victim, current_time);
            return true;
        }
    }
 
    SET_ATTACK_TIME(ch, victim, current_time);
 
    if (victim->m_AttackedLog.dwPID == ch->GetPlayerID())
    {
        if (current_time - victim->m_AttackedLog.dwAttackedTime < GET_ATTACK_SPEED(ch))
        {
            INCREASE_SPEED_HACK_COUNT(ch);
            if (ch->m_speed_hack_count > 100)
            {
#ifdef ENABLE_SYSLOG_NOTICE
                sys_log(0, "%s Attack Speed HACK! time (delta, limit)=(%u, %u), hack_count = %d",
                        ch->GetName(),
                        current_time - victim->m_AttackedLog.dwAttackedTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
#endif
#ifdef ENABLE_SYSCHAT_NOTICE
                ch->ChatPacket(CHAT_TYPE_INFO, "A hack was detected , close it!",
                        ch->GetName(),
                        current_time - victim->m_AttackedLog.dwAttackedTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
#endif             
#ifdef ENABLE_BAN_WAITHACK              
                DBManager::instance().Query("INSERT INTO log.wait_hack SET login='%s', nickname='%s', ip='%s', time=NOW(), map_index=%d, server='%s';",
      ch->GetDesc()->GetAccountTable().login, ch->GetName(), ch->GetDesc()->GetHostName(), ch->GetMapIndex(), g_stHostname.c_str());
#endif
                ch->GetDesc()->DelayedDisconnect(3);
            }
             
            SET_ATTACKED_TIME(ch, victim, current_time);
            return true;
        }
    }
 
    SET_ATTACKED_TIME(ch, victim, current_time);
    return false;
}

Create in database log a table with name : wait_hack

/*
Navicat MySQL Data Transfer

Source Server         : test
Source Server Version : 50613
Source Host           : 
Source Database       : log

Target Server Type    : MYSQL
Target Server Version : 50613
File Encoding         : 65001

Date: 2015-01-02 12:54:57
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for wait_hack
-- ----------------------------
DROP TABLE IF EXISTS `wait_hack`;
CREATE TABLE `wait_hack` (
  `login` varchar(50) COLLATE big5_bin DEFAULT NULL,
  `nickname` varchar(50) COLLATE big5_bin DEFAULT NULL,
  `ip` varchar(50) COLLATE big5_bin DEFAULT NULL,
  `time` time DEFAULT NULL,
  `map_index` varchar(30) COLLATE big5_bin DEFAULT NULL,
  `server` varchar(30) COLLATE big5_bin DEFAULT NULL,
  `playtime` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=big5 COLLATE=big5_bin;

It is more secure now .

  • Love 6
Link to comment
  • 6 months later...
  • 3 weeks later...

Metod log > more secure :

#define ENABLE_SYSCHAT_NOTICE
#define ENABLE_SYSLOG_NOTICE
#define ENABLE_BAN_WAITHACK
bool IS_SPEED_HACK(LPCHARACTER ch, LPCHARACTER victim, DWORD current_time)
{
    if (ch->m_kAttackLog.dwVID == victim->GetVID())
    {
        if (current_time - ch->m_kAttackLog.dwTime < GET_ATTACK_SPEED(ch))
        {
            INCREASE_SPEED_HACK_COUNT(ch);
 
            if (test_server)
            {
                sys_log(0, "%s attack hack! time (delta, limit)=(%u, %u) hack_count %d",
                        ch->GetName(),
                        current_time - ch->m_kAttackLog.dwTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
 
                ch->ChatPacket(CHAT_TYPE_INFO, "%s attack hack! time (delta, limit)=(%u, %u) hack_count %d",
                        ch->GetName(),
                        current_time - ch->m_kAttackLog.dwTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
            }
 
            SET_ATTACK_TIME(ch, victim, current_time);
            SET_ATTACKED_TIME(ch, victim, current_time);
            return true;
        }
    }
 
    SET_ATTACK_TIME(ch, victim, current_time);
 
    if (victim->m_AttackedLog.dwPID == ch->GetPlayerID())
    {
        if (current_time - victim->m_AttackedLog.dwAttackedTime < GET_ATTACK_SPEED(ch))
        {
            INCREASE_SPEED_HACK_COUNT(ch);
            if (ch->m_speed_hack_count > 100)
            {
#ifdef ENABLE_SYSLOG_NOTICE
                sys_log(0, "%s Attack Speed HACK! time (delta, limit)=(%u, %u), hack_count = %d",
                        ch->GetName(),
                        current_time - victim->m_AttackedLog.dwAttackedTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
#endif
#ifdef ENABLE_SYSCHAT_NOTICE
                ch->ChatPacket(CHAT_TYPE_INFO, "A hack was detected , close it!",
                        ch->GetName(),
                        current_time - victim->m_AttackedLog.dwAttackedTime,
                        GET_ATTACK_SPEED(ch),
                        ch->m_speed_hack_count);
#endif             
#ifdef ENABLE_BAN_WAITHACK              
                DBManager::instance().Query("INSERT INTO log.wait_hack SET login='%s', nickname='%s', ip='%s', time=NOW(), map_index=%d, server='%s';",
      ch->GetDesc()->GetAccountTable().login, ch->GetName(), ch->GetDesc()->GetHostName(), ch->GetMapIndex(), g_stHostname.c_str());
#endif
                ch->GetDesc()->DelayedDisconnect(3);
            }
             
            SET_ATTACKED_TIME(ch, victim, current_time);
            return true;
        }
    }
 
    SET_ATTACKED_TIME(ch, victim, current_time);
    return false;
}

Create in database log a table with name : wait_hack

/*
Navicat MySQL Data Transfer

Source Server         : test
Source Server Version : 50613
Source Host           : 
Source Database       : log

Target Server Type    : MYSQL
Target Server Version : 50613
File Encoding         : 65001

Date: 2015-01-02 12:54:57
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for wait_hack
-- ----------------------------
DROP TABLE IF EXISTS `wait_hack`;
CREATE TABLE `wait_hack` (
  `login` varchar(50) COLLATE big5_bin DEFAULT NULL,
  `nickname` varchar(50) COLLATE big5_bin DEFAULT NULL,
  `ip` varchar(50) COLLATE big5_bin DEFAULT NULL,
  `time` time DEFAULT NULL,
  `map_index` varchar(30) COLLATE big5_bin DEFAULT NULL,
  `server` varchar(30) COLLATE big5_bin DEFAULT NULL,
  `playtime` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=big5 COLLATE=big5_bin;

It is more secure now .

I used for 10 minutes at a pro damage and did not create any log help me

Link to comment
  • 11 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.