Jump to content

Anti Wait Hack Damage


Koray

Recommended Posts

  • Active Member

M2 Download Center

This is the hidden content, please
( 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:

 

https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

 

After:

 

https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

 

 

Final:

 

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 33
  • Dislove 1
  • Good 10
  • muscle 1
  • Love 3
  • Love 46
Link to comment
Share on other sites

  • 4 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 .

  • Love 1
  • Love 6
Link to comment
Share on other sites

  • 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

  • Love 1
Link to comment
Share on other sites

  • 11 months later...
  • 5 years later...

Announcements



  • Similar Content

  • Similar Content

  • Similar Content

  • Tags

  • Activity

    1. 0

      We are looking for a C++ and Python programmer

    2. 0

      [Quest Scheduler Request] Is there a way to make a quest run independet of player events? Lets say start quest automatically at server startup?

    3. 111

      Ulthar SF V2 (TMP4 Base)

    4. 0

      Quest function when 102.kill definition whereabouts help

    5. 5

      [M2 FILTER] Customized Client Filter

    6. 0

      [INGAME] RGB Color on chat broken

    7. 5

      [FREE] 1x1 pvp/event map by Davian

    8. 0

      Beginner / What is the most important?

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.