Skip to content

Commit f59c9ff

Browse files
Merge branch '3.3.5-passive_anticheat' into pafmt
2 parents bc8c4c2 + 1d61b64 commit f59c9ff

33 files changed

+1799
-1829
lines changed

sql/character.anticheat.sql

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
-- run if dropping and creating the tables for the first time or wanting to start fresh on anticheat stats
2+
CREATE TABLE IF NOT EXISTS `daily_players_reports` (
3+
`guid` int unsigned NOT NULL DEFAULT 0,
4+
`creation_time` int unsigned NOT NULL DEFAULT 0,
5+
`average` float NOT NULL DEFAULT 0,
6+
`total_reports` bigint unsigned NOT NULL DEFAULT 0,
7+
`speed_reports` bigint unsigned NOT NULL DEFAULT 0,
8+
`fly_reports` bigint unsigned NOT NULL DEFAULT 0,
9+
`jump_reports` bigint unsigned NOT NULL DEFAULT 0,
10+
`waterwalk_reports` bigint unsigned NOT NULL DEFAULT 0,
11+
`teleportplane_reports` bigint unsigned NOT NULL DEFAULT 0,
12+
`climb_reports` bigint unsigned NOT NULL DEFAULT 0,
13+
`teleport_reports` bigint unsigned NOT NULL DEFAULT 0,
14+
`ignorecontrol_reports` bigint unsigned NOT NULL DEFAULT 0,
15+
`zaxis_reports` bigint unsigned NOT NULL DEFAULT 0,
16+
`antiswim_reports` bigint unsigned NOT NULL DEFAULT 0,
17+
`gravity_reports` bigint unsigned NOT NULL DEFAULT 0,
18+
`antiknockback_reports` bigint unsigned NOT NULL DEFAULT 0,
19+
`no_fall_damage_reports` bigint unsigned NOT NULL DEFAULT 0,
20+
`op_ack_hack_reports` bigint unsigned NOT NULL DEFAULT 0,
21+
`counter_measures_reports` bigint unsigned NOT NULL DEFAULT 0,
22+
PRIMARY KEY (`guid`)
23+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
24+
25+
CREATE TABLE IF NOT EXISTS `players_reports_status` (
26+
`guid` int unsigned NOT NULL DEFAULT 0,
27+
`creation_time` int unsigned NOT NULL DEFAULT 0,
28+
`average` float NOT NULL DEFAULT 0,
29+
`total_reports` bigint unsigned NOT NULL DEFAULT 0,
30+
`speed_reports` bigint unsigned NOT NULL DEFAULT 0,
31+
`fly_reports` bigint unsigned NOT NULL DEFAULT 0,
32+
`jump_reports` bigint unsigned NOT NULL DEFAULT 0,
33+
`waterwalk_reports` bigint unsigned NOT NULL DEFAULT 0,
34+
`teleportplane_reports` bigint unsigned NOT NULL DEFAULT 0,
35+
`climb_reports` bigint unsigned NOT NULL DEFAULT 0,
36+
`teleport_reports` bigint unsigned NOT NULL DEFAULT 0,
37+
`ignorecontrol_reports` bigint unsigned NOT NULL DEFAULT 0,
38+
`zaxis_reports` bigint unsigned NOT NULL DEFAULT 0,
39+
`antiswim_reports` bigint unsigned NOT NULL DEFAULT 0,
40+
`gravity_reports` bigint unsigned NOT NULL DEFAULT 0,
41+
`antiknockback_reports` bigint unsigned NOT NULL DEFAULT 0,
42+
`no_fall_damage_reports` bigint unsigned NOT NULL DEFAULT 0,
43+
`op_ack_hack_reports` bigint unsigned NOT NULL DEFAULT 0,
44+
`counter_measures_reports` bigint unsigned NOT NULL DEFAULT 0,
45+
PRIMARY KEY (`guid`)
46+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
47+
48+
CREATE TABLE IF NOT EXISTS `lua_cheaters` (
49+
`guid` int unsigned NOT NULL DEFAULT 0,
50+
`account` int unsigned NOT NULL DEFAULT 0,
51+
`macro` varchar(255) NOT NULL DEFAULT '',
52+
PRIMARY KEY (`guid`,`account`)
53+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
54+
55+
-- run only if updating from previous table versions
56+
ALTER TABLE `daily_players_reports`
57+
ADD COLUMN `teleport_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `climb_reports`,
58+
ADD COLUMN `ignorecontrol_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `teleport_reports`,
59+
ADD COLUMN `zaxis_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `ignorecontrol_reports`,
60+
ADD COLUMN `antiswim_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `zaxis_reports`,
61+
ADD COLUMN `gravity_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `antiswim_reports`;
62+
ADD COLUMN `antiknockback_reports` bigint unsigned NOT NULL DEFAULT 0 AFTER `gravity_reports`;
63+
ADD COLUMN `no_fall_damage_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `antiknockback_reports`;
64+
ADD COLUMN `op_ack_hack_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `no_fall_damage_reports`;
65+
ADD COLUMN `counter_measures_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `op_ack_hack_reports`;
66+
67+
ALTER TABLE `players_reports_status`
68+
ADD COLUMN `teleport_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `climb_reports`,
69+
ADD COLUMN `ignorecontrol_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `teleport_reports`,
70+
ADD COLUMN `zaxis_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `ignorecontrol_reports`,
71+
ADD COLUMN `antiswim_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `zaxis_reports`,
72+
ADD COLUMN `gravity_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `antiswim_reports`;
73+
ADD COLUMN `antiknockback_reports` bigint unsigned NOT NULL DEFAULT 0 AFTER `gravity_reports`;
74+
ADD COLUMN `no_fall_damage_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `antiknockback_reports`;
75+
ADD COLUMN `op_ack_hack_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `no_fall_damage_reports`;
76+
ADD COLUMN `counter_measures_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `op_ack_hack_reports`;

sql/world.anticheat.sql

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
DELETE FROM `trinity_string` WHERE `entry` IN (30087,30088,30089,30090,30091,30092);
2+
INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES
3+
(30087, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r |cFFFF8C00|r |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00] - Latency: %u ms', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
4+
(30088, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r POSSIBLE TELEPORT HACK DETECTED|cFFFF8C00 %s|r - Latency: %u ms', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
5+
(30089, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r POSSIBLE IGNORE CONTROL HACK DETECTED|cFFFF8C00] %s|r - Latency: %u ms', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
6+
(30090, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r TELEPORT HACK USED WHLE DUELING|cFFFF8C00 %s|r - Latency: %u ms vs |cFFFF8C00 %s|r - Latency: %u ms.', NULL, NULL, NULL, NULL, NULL, '', '', NULL),
7+
(30091, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r BG Start Bound Teleport\\Exploit Hack DETECTED|cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00] - Latency: %u ms', NULL, NULL, NULL, NULL, NULL, '', '', NULL),
8+
(30092, '|cffffff00[|cffff0000COUNTER MEASURE ALERT|r|cffffff00]:|r |cFFFF8C00|r %s |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00]', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
9+
10+
DELETE FROM `command` WHERE `name`='anticheat jail';
11+
DELETE FROM `command` WHERE `name`='anticheat delete';
12+
DELETE FROM `command` WHERE `name`='anticheat player';
13+
DELETE FROM `command` WHERE `name`='anticheat';
14+
DELETE FROM `command` WHERE `name`='anticheat global';
15+
DELETE FROM `command` WHERE `name`='anticheat parole';
16+
DELETE FROM `command` WHERE `name`='anticheat purge';
17+
DELETE FROM `command` WHERE `name`='anticheat warn';
18+
DELETE FROM `command` WHERE `name`='anticheat handle';
19+
INSERT INTO `command` (`name`, `help`) VALUES
20+
('anticheat', 'Syntax: .anticheat\r\n\r\nDisplay the access level of anticheat commands if you possess the necessary permissions.'),
21+
('anticheat global', 'Syntax: .anticheat global\r\n\r\nDisplay if anticheat is active with global statistics.'),
22+
('anticheat player', 'Syntax: .anticheat player [$charactername]\r\n\r\nDisplay anticheat statistics of current session of player.'),
23+
('anticheat delete', 'Syntax: .anticheat delete [$charactername]\r\n\r\nDeletes anticheat statistics of current session of player.'),
24+
('anticheat jail', 'Syntax: .anticheat jail [$charactername]\r\n\r\nJails and restricts player and teleports GM cmd user to jail with no restrictions'),
25+
('anticheat parole', 'Syntax: .anticheat parole [$charactername]\r\n\r\nDeletes anticheat statistics, removes jail restrictions, and sends to faction capital of player.'),
26+
('anticheat purge', 'Syntax: .anticheat purge\r\n\r\nDeletes stored statistics of daily_players_reports table.'),
27+
('anticheat warn', 'Syntax: .anticheat warn [$charactername]\r\n\r\nSends individual player they are being monitored for possible cheating.'),
28+
('anticheat handle', 'Syntax: .anticheat handle 0 or 1\r\n\r\n0 Turns off and 1 Turns On Anticheat');
29+
30+
DROP TABLE IF EXISTS `lua_private_functions`;
31+
CREATE TABLE IF NOT EXISTS `lua_private_functions` (
32+
`function_name` varchar(255) NOT NULL DEFAULT '0',
33+
`enabled` tinyint NOT NULL DEFAULT '1',
34+
PRIMARY KEY (`function_name`)
35+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
36+
37+
INSERT INTO `lua_private_functions` VALUES ('CastSpellByName', '1');
38+
INSERT INTO `lua_private_functions` VALUES ('RunMacroText', '1');

src/server/database/Database/Implementation/CharacterDatabase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ void CharacterDatabaseConnection::DoPrepareStatements()
594594

595595
// DeserterTracker
596596
PrepareStatement(CHAR_INS_DESERTER_TRACK, "INSERT INTO battleground_deserters (guid, type, datetime) VALUES (?, ?, NOW())", CONNECTION_ASYNC);
597+
598+
// Anticheat Lua Cheaters
599+
PrepareStatement(CHAR_INS_ANTICHEAT_LUA_CHEATERS, "INSERT IGNORE INTO `lua_cheaters` (guid, account, macro) VALUES (?, ?, ?)", CONNECTION_ASYNC);
600+
PrepareStatement(CHAR_SEL_ANTICHEAT_LUA_CHEATERS, "SELECT guid, account FROM lua_cheaters WHERE account = ?", CONNECTION_SYNCH);
597601
}
598602

599603
CharacterDatabaseConnection::CharacterDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo)

src/server/database/Database/Implementation/CharacterDatabase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ enum CharacterDatabaseStatements : uint32
509509
CHAR_UPD_QUEST_TRACK_ABANDON_TIME,
510510

511511
CHAR_INS_DESERTER_TRACK,
512-
512+
CHAR_INS_ANTICHEAT_LUA_CHEATERS,
513+
CHAR_SEL_ANTICHEAT_LUA_CHEATERS,
513514
MAX_CHARACTERDATABASE_STATEMENTS
514515
};
515516

src/server/database/Database/Implementation/WorldDatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
9494
PrepareStatement(WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA, "UPDATE gameobject SET zoneId = ?, areaId = ? WHERE guid = ?", CONNECTION_ASYNC);
9595
PrepareStatement(WORLD_DEL_SPAWNGROUP_MEMBER, "DELETE FROM spawn_group WHERE spawnType = ? AND spawnId = ?", CONNECTION_ASYNC);
9696
PrepareStatement(WORLD_DEL_GAMEOBJECT_ADDON, "DELETE FROM gameobject_addon WHERE guid = ?", CONNECTION_ASYNC);
97+
PrepareStatement(WORLD_SEL_ANTICHEAT_FUNCTIONS, "SELECT function_name, enabled FROM lua_private_functions", CONNECTION_SYNCH);
9798
}
9899

99100
WorldDatabaseConnection::WorldDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo)

src/server/database/Database/Implementation/WorldDatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ enum WorldDatabaseStatements : uint32
100100
WORLD_UPD_GAMEOBJECT_ZONE_AREA_DATA,
101101
WORLD_DEL_SPAWNGROUP_MEMBER,
102102
WORLD_DEL_GAMEOBJECT_ADDON,
103-
103+
WORLD_SEL_ANTICHEAT_FUNCTIONS,
104104
MAX_WORLDDATABASE_STATEMENTS
105105
};
106106

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms of the GNU General Public License as published by the
6+
* Free Software Foundation; either version 2 of the License, or (at your
7+
* option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+
* more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include "AnticheatData.h"
19+
20+
AnticheatData::AnticheatData()
21+
{
22+
lastOpcode = 0;
23+
totalReports = 0;
24+
for (uint8 i = 0; i < MAX_REPORT_TYPES; i++)
25+
{
26+
typeReports[i] = 0;
27+
tempReports[i] = 0;
28+
tempReportsTimer[i] = 0;
29+
}
30+
average = 0;
31+
creationTime = 0;
32+
hasDailyReport = false;
33+
}
34+
35+
AnticheatData::~AnticheatData()
36+
{
37+
}
38+
39+
void AnticheatData::SetDailyReportState(bool b)
40+
{
41+
hasDailyReport = b;
42+
}
43+
44+
bool AnticheatData::GetDailyReportState()
45+
{
46+
return hasDailyReport;
47+
}
48+
49+
void AnticheatData::SetLastOpcode(uint32 opcode)
50+
{
51+
lastOpcode = opcode;
52+
}
53+
54+
void AnticheatData::SetPosition(float x, float y, float z, float o)
55+
{
56+
lastMovementInfo.pos = { x, y, z, o };
57+
}
58+
59+
uint32 AnticheatData::GetLastOpcode() const
60+
{
61+
return lastOpcode;
62+
}
63+
64+
const MovementInfo& AnticheatData::GetLastMovementInfo() const
65+
{
66+
return lastMovementInfo;
67+
}
68+
69+
void AnticheatData::SetLastMovementInfo(MovementInfo& moveInfo)
70+
{
71+
lastMovementInfo = moveInfo;
72+
}
73+
74+
uint32 AnticheatData::GetTotalReports() const
75+
{
76+
return totalReports;
77+
}
78+
79+
void AnticheatData::SetTotalReports(uint32 _totalReports)
80+
{
81+
totalReports = _totalReports;
82+
}
83+
84+
void AnticheatData::SetTypeReports(uint32 type, uint32 amount)
85+
{
86+
typeReports[type] = amount;
87+
}
88+
89+
uint32 AnticheatData::GetTypeReports(uint32 type) const
90+
{
91+
return typeReports[type];
92+
}
93+
94+
float AnticheatData::GetAverage() const
95+
{
96+
return average;
97+
}
98+
99+
void AnticheatData::SetAverage(float _average)
100+
{
101+
average = _average;
102+
}
103+
104+
uint32 AnticheatData::GetCreationTime() const
105+
{
106+
return creationTime;
107+
}
108+
109+
void AnticheatData::SetCreationTime(uint32 _creationTime)
110+
{
111+
creationTime = _creationTime;
112+
}
113+
114+
void AnticheatData::SetTempReports(uint32 amount, uint8 type)
115+
{
116+
tempReports[type] = amount;
117+
}
118+
119+
uint32 AnticheatData::GetTempReports(uint8 type)
120+
{
121+
return tempReports[type];
122+
}
123+
124+
void AnticheatData::SetTempReportsTimer(uint32 time, uint8 type)
125+
{
126+
tempReportsTimer[type] = time;
127+
}
128+
129+
uint32 AnticheatData::GetTempReportsTimer(uint8 type)
130+
{
131+
return tempReportsTimer[type];
132+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms of the GNU General Public License as published by the
6+
* Free Software Foundation; either version 2 of the License, or (at your
7+
* option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+
* more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along
15+
* with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#ifndef SC_ACDATA_H
19+
#define SC_ACDATA_H
20+
21+
#include "AnticheatMgr.h"
22+
#include "Player.h"
23+
24+
#define MAX_REPORT_TYPES 15
25+
26+
class AnticheatData
27+
{
28+
public:
29+
AnticheatData();
30+
~AnticheatData();
31+
32+
void SetLastOpcode(uint32 opcode);
33+
uint32 GetLastOpcode() const;
34+
35+
const MovementInfo& GetLastMovementInfo() const;
36+
void SetLastMovementInfo(MovementInfo& moveInfo);
37+
38+
void SetPosition(float x, float y, float z, float o);
39+
40+
uint32 GetTotalReports() const;
41+
void SetTotalReports(uint32 _totalReports);
42+
43+
uint32 GetTypeReports(uint32 type) const;
44+
void SetTypeReports(uint32 type, uint32 amount);
45+
46+
float GetAverage() const;
47+
void SetAverage(float _average);
48+
49+
uint32 GetCreationTime() const;
50+
void SetCreationTime(uint32 creationTime);
51+
52+
void SetTempReports(uint32 amount, uint8 type);
53+
uint32 GetTempReports(uint8 type);
54+
55+
void SetTempReportsTimer(uint32 time, uint8 type);
56+
uint32 GetTempReportsTimer(uint8 type);
57+
58+
void SetDailyReportState(bool b);
59+
bool GetDailyReportState();
60+
private:
61+
uint32 lastOpcode;
62+
MovementInfo lastMovementInfo;
63+
uint32 totalReports;
64+
uint32 typeReports[MAX_REPORT_TYPES];
65+
float average;
66+
uint32 creationTime;
67+
uint32 tempReports[MAX_REPORT_TYPES];
68+
uint32 tempReportsTimer[MAX_REPORT_TYPES];
69+
bool hasDailyReport;
70+
};
71+
72+
#endif

0 commit comments

Comments
 (0)