Sigma 4.11 FakeHacker module 2 files, 185 lines

Sigma 4.11 FakeHacker: Full Source Analysis

Sigma 4.11's FakeHacker is a troll module that makes a chosen player look like a cheater on the local client.

info/sigmaclient/module/impl/other/FakeHacker.java · GitHub source ↗

Published 2026-08-13 · Updated 2026-08-13

Packets This Module Uses

Analysis

Overview

Sigma 4.11's FakeHacker is a troll module that makes a chosen player look like a cheater on the local client. The target is a public static TARGET string (default 'NONE') set by the chat-prefixed FakeHackerTarget command, whose fire() handler only writes a local chat line via addChatMessage. Every update tick the module scans mc.theWorld.loadedEntityList for an entity whose name matches, and per enabled mode: KILLAURA aims the target's head and camera at the local player and swings the target's arm when it is within the RANGE setting (default 6.0); FLY snaps the target's posY to the local player's y plus 3 plus a randomized offset on a 100-tick counter; SPEED drifts the target's x and z by 0.1 toward its own yaw; SNEAK forces the sneak pose. The REACH and FLY branches that mutate C04/C06 packet fields are gated on EventPacket.isIncoming(), which is false for serverbound packets, so they never execute: the module's entire effect is local rendering and its wire footprint is zero.

Architecture

The module is one EventUpdate handler plus one EventPacket handler. The target comes from the public static TARGET field, which the FakeHackerTarget command sets by uppercasing its argument after validating args.length equals 1 and printing a local confirmation line through addChatMessage, so even the setup traffic is client-local. The settings are KILLAURA (default true), FLY, SPEED, SNEAK and REACH (all default false) plus RANGE, a Number setting with default 6.0, increment 0.1, and bounds 1 to 10. Each update tick the handler iterates the loaded entity list, matches entity names case-insensitively against TARGET, skips dead entities, and casts the match to EntityOtherPlayerMP without an instanceof guard.

Local rendering theater

KILLAURA computes the angles from the target toward the local player: getAnglesForThisEntityToHitYou takes the position difference with the player's eye height divided by 1.4, derives yaw from atan2 and pitch from the distance, and writes rotationYaw, rotationYawHead, rotationPitch and cameraPitch onto the target's entity, then calls swingItem() on it, so the victim's head tracks the player and its arm swings like an aura. FLY keeps a delay counter that resamples randomfly and randomfly2 (the local player's posY) every 100 ticks and sets the target's posY to randomfly2 plus 3 plus a randomized fraction, so the victim bobs roughly three blocks above the player. SPEED drifts the target's position by 0.1 per tick along the direction of its yaw minus 90 degrees, and SNEAK calls setSneaking(true). All four write only client-side state on a remote entity; the server's copy of the target never changes.

Dead packet branches

The EventPacket half is the interesting failure. REACH adds cos of (yaw minus 90) times 0.5 to the x and z of any C04PacketPlayerPosition or C06PacketPlayerPosLook, and FLY adds 1 to the y of any C04, but both branches are guarded by ep.isIncoming(). Sigma's NetworkManager fires EventPacket with the outgoing flag set to true in sendPacket for every packet the client sends, and with false in channelRead0 only for packets received from the server, so isIncoming(), which returns the negation of outgoing, is false for the serverbound C04/C06 family: the guards never pass and both branches are unreachable. The intended effect would have been a 0.5-block position shift toward the facing on the client's own movement stream (a crude reach assist) and a one-block y lift (a crude fly assist); as shipped, the module emits nothing.

source FakeHacker.java

FakeHacker.java137 lines · JavaOriginal ↗
1
package info.sigmaclient.module.impl.other;
2
3
import info.sigmaclient.event.Event;
4
import info.sigmaclient.event.RegisterEvent;
5
import info.sigmaclient.event.impl.EventPacket;
6
import info.sigmaclient.event.impl.EventUpdate;
7
import info.sigmaclient.module.Module;
8
import info.sigmaclient.module.data.ModuleData;
9
import info.sigmaclient.module.data.Setting;
10
import net.minecraft.client.entity.EntityOtherPlayerMP;
11
import net.minecraft.entity.Entity;
12
import net.minecraft.entity.EntityLivingBase;
13
import net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition;
14
import net.minecraft.network.play.client.C03PacketPlayer.C06PacketPlayerPosLook;
15
import net.minecraft.potion.Potion;
16
import net.minecraft.potion.PotionEffect;
17
18
public class FakeHacker extends Module {
19
	
20
    public static final String KILLAURA = "KILLAURA";
21
    public static final String FLY = "FLY";
22
    public static final String SPEED = "SPEED";
23
    public static final String SNEAK = "SNEAK";
24
    public static final String REACH = "REACH";
25
	public static final String RANGE = "RANGE";
26
    public static String TARGET = "NONE";
27
    public int delay = 100;
28
    public double randomfly = Math.random();
29
    public double randomfly2;
30
    public double flyrandomization = 1;
31
32
33
	public FakeHacker(ModuleData data) {
34
		super(data);
35
		settings.put(KILLAURA, new Setting<>(KILLAURA, true, "Make the target fake killaura."));
36
		settings.put(FLY, new Setting<>(FLY, false, "Make the target fake fly."));
37
		settings.put(SPEED, new Setting<>(SPEED, false, "Make the target fake speed."));
38
		settings.put(SNEAK, new Setting<>(SNEAK, false, "Make the target fake sneak."));
39
		settings.put(REACH, new Setting<>(REACH, false, "Make the target fake reach."));
40
		settings.put(RANGE, new Setting<>(RANGE, 6.0, "Range for fake killaura.", 0.1, 1, 10.0));
41
	}
42
43
	@Override
44
	@RegisterEvent(events = { EventUpdate.class, EventPacket.class })
45
	public void onEvent(Event event) {
46
		if (event instanceof EventUpdate){
47
			EventUpdate em = (EventUpdate) event;
48
			for (int entityList = 0; entityList < mc.theWorld.loadedEntityList.size(); ++entityList) {
49
	            final Entity entity = (Entity) mc.theWorld.getLoadedEntityList().get(entityList);
50
	            if (entity.getName().equalsIgnoreCase(TARGET) && !entity.isDead) {
51
	            	EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
52
	                if ((Boolean)settings.get(KILLAURA).getValue()) {
53
	                	float range = ((Number) settings.get(RANGE).getValue()).floatValue();
54
	                    if (mc.thePlayer.getDistanceToEntity(e) < range) {
55
	                        float[] yawAndPitch = getAnglesForThisEntityToHitYou(e);
56
	                        float yaw = yawAndPitch[0];
57
	                        float pitch = yawAndPitch[1];
58
	                        e.rotationYaw = yaw;
59
	                        e.setRotationYawHead(yaw);
60
	                        e.rotationPitch = pitch;
61
	                        e.cameraPitch = pitch;
62
	                        e.swingItem();
63
	                    }
64
	                }
65
	                if ((Boolean)settings.get(FLY).getValue()) {
66
	                    //e.motionY = (Math.random()*2)-(Math.random()*2);
67
	                	delay++;
68
	                    if(delay >= 100){
69
	                        randomfly = Math.random();
70
	                        randomfly2 = mc.thePlayer.posY;
71
	                        delay = 0;
72
	                    }
73
	                    e.posY = randomfly2+3+(flyrandomization*randomfly);
74
	                }
75
	                if ((Boolean)settings.get(SPEED).getValue()) {
76
	                	double angleA = Math.toRadians(normalizeAngle(e.getRotationYawHead() - 90.0F));
77
	                    entity.posX = entity.posX - Math.cos(angleA) * 0.1;
78
	                    entity.posZ = entity.posZ - Math.cos(angleA) * 0.1;
79
	                }
80
	                if ((Boolean)settings.get(SNEAK).getValue()) {
81
	                	e.setSneaking(true);
82
	                }
83
	            }
84
			}
85
		}
86
		if (event instanceof EventPacket) { 
87
			EventPacket ep = (EventPacket) event;
88
			if ((Boolean)settings.get(REACH).getValue()) {
89
				if(ep.isIncoming() && ep.getPacket() instanceof C04PacketPlayerPosition){
90
					C04PacketPlayerPosition e = (C04PacketPlayerPosition)ep.getPacket();
91
					double angleA = Math.toRadians(normalizeAngle(e.getYaw() - 90.0F));
92
	                e.x = e.x + Math.cos(angleA) * 0.5;
93
	                e.z = e.z + Math.cos(angleA) * 0.5;
94
	                
95
				}
96
				if(ep.isIncoming() && ep.getPacket() instanceof C06PacketPlayerPosLook){
97
					C06PacketPlayerPosLook e = (C06PacketPlayerPosLook)ep.getPacket();
98
					double angleA = Math.toRadians(normalizeAngle(e.getYaw() - 90.0F));
99
	                e.x = e.x + Math.cos(angleA) * 0.5;
100
	                e.z = e.z + Math.cos(angleA) * 0.5;
101
				}
102
			}
103
			if ((Boolean)settings.get(FLY).getValue()) {
104
				if(ep.isIncoming() && ep.getPacket() instanceof C04PacketPlayerPosition){
105
					C04PacketPlayerPosition e = (C04PacketPlayerPosition)ep.getPacket();
106
					e.y = e.y+1;
107
				}
108
			}
109
		}
110
	}
111
	
112
	@Override
113
	public void onEnable() {
114
		//randomfly2 = mc.thePlayer.posY;
115
		delay = 100;
116
	}
117
	
118
	public static float normalizeAngle(float angle)
119
    {
120
        return (angle + 360.0F) % 360.0F;
121
    }
122
123
    private float[] getAnglesForThisEntityToHitYou(EntityLivingBase entityLiving) {
124
        double difX = mc.thePlayer.posX - entityLiving.posX;
125
        double difY = mc.thePlayer.posY - entityLiving.posY + (double) (mc.thePlayer.getEyeHeight() / 1.4f);
126
        double difZ = mc.thePlayer.posZ - entityLiving.posZ;
127
        double hypo = entityLiving.getDistanceToEntity((Entity) mc.thePlayer);
128
        float yaw = (float) Math.toDegrees(Math.atan2(difZ, difX)) - 90.0f;
129
        float pitch = (float) (-Math.toDegrees(Math.atan2(difY, hypo)));
130
        return new float[]{yaw, pitch};
131
    }
132
133
    public float getDistanceBetweenAngles(final float angle1, final float angle2) {
134
        return Math.abs(angle1 % 360.0f - angle2 % 360.0f) % 360.0f;
135
    }
136
137
}

What this file does

The six settings, the entity scan with the name match and dead-entity skip, the KILLAURA aim math with the eye-height divisor, the FLY position snapping, the SPEED drift, the SNEAK pose write, and the direction-inverted C04/C06 mutation branches that never fire. The TARGET static and the normalizeAngle helper are here too.

source EventPacket.java (outgoing-flag semantics)

EventPacket.java48 lines · JavaOriginal ↗
1
package info.sigmaclient.event.impl;
2
3
import info.sigmaclient.event.Event;
4
import net.minecraft.network.Packet;
5
6
public class EventPacket extends Event {
7
    private Packet packet;
8
    private boolean outgoing;
9
10
    public boolean isPre() {
11
        return pre;
12
    }
13
14
    public boolean isPost() {
15
        return !pre;
16
    }
17
18
    private boolean pre;
19
20
    public void fire(Packet packet, boolean outgoing) {
21
        this.packet = packet;
22
        this.outgoing = outgoing;
23
        this.pre = true;
24
        super.fire();
25
    }
26
27
    public void fire(Packet packet) {
28
        this.packet = packet;
29
        this.pre = false;
30
        super.fire();
31
    }
32
33
    public Packet getPacket() {
34
        return packet;
35
    }
36
37
    public void setPacket(Packet packet) {
38
        this.packet = packet;
39
    }
40
41
    public boolean isOutgoing() {
42
        return outgoing;
43
    }
44
45
    public boolean isIncoming() {
46
        return !outgoing;
47
    }
48
}

What this file does

This event class carries the proof that the REACH and FLY packet branches are dead: fire(Packet, boolean outgoing) records the direction and isIncoming() returns the negation of outgoing. NetworkManager.sendPacket fires it with true and channelRead0 with false, so the serverbound C04/C06 instances the module checks can never satisfy isIncoming(). The module registers for exactly this event, which makes the inversion a property of the module's own guard rather than of the event system.

anticheat Countering Checks

The anticheat code that detects or counters the techniques this module uses. Full source, with the detection mechanism explained below each box.

anticheat Text (chat content and frequency scoring)

Text.java331 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.chat;
16
17
import java.util.Collections;
18
import java.util.LinkedList;
19
import java.util.List;
20
import java.util.Map;
21
22
import org.bukkit.entity.Player;
23
24
import fr.neatmonster.nocheatplus.NCPAPIProvider;
25
import fr.neatmonster.nocheatplus.checks.Check;
26
import fr.neatmonster.nocheatplus.checks.CheckType;
27
import fr.neatmonster.nocheatplus.checks.chat.analysis.MessageLetterCount;
28
import fr.neatmonster.nocheatplus.checks.chat.analysis.WordLetterCount;
29
import fr.neatmonster.nocheatplus.checks.chat.analysis.engine.LetterEngine;
30
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
31
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
32
import fr.neatmonster.nocheatplus.components.registry.feature.INotifyReload;
33
import fr.neatmonster.nocheatplus.config.ConfigFile;
34
import fr.neatmonster.nocheatplus.config.ConfigManager;
35
import fr.neatmonster.nocheatplus.players.IPlayerData;
36
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
37
import fr.neatmonster.nocheatplus.utilities.StringUtil;
38
39
/**
40
 * Some alternative more or less advanced analysis methods.
41
 * @author asofold
42
 *
43
 */
44
public class Text extends Check implements INotifyReload {
45
46
    private LetterEngine engine = null;
47
48
    /** Not really cancelled but above threshold for actions. */
49
    private String lastCancelledMessage = "";
50
    private long lastCancelledTime = 0;
51
52
    private String lastGlobalMessage = "";
53
    private long lastGlobalTime = 0;
54
55
    public Text() {
56
        super(CheckType.CHAT_TEXT);
57
        init();
58
    }
59
60
    /**
61
     * Start analysis.
62
     * @param player
63
     *          The player who issued the message.
64
     * @param message
65
     *          The message to check.
66
     * @param captcha 
67
     *          Used for starting captcha on failure, if configured so.
68
     * @param alreadyCancelled 
69
     * @return
70
     */
71
    public boolean check(final Player player, final String message, 
72
                         final ChatConfig cc, final IPlayerData pData,
73
                         final ICaptcha captcha, boolean isMainThread, final boolean alreadyCancelled) {
74
        final ChatData data = pData.getGenericInstance(ChatData.class);
75
        synchronized (data) {
76
            return unsafeCheck(player, message, captcha, cc, data, pData, isMainThread, alreadyCancelled);
77
        }
78
    }
79
80
    private void init() {
81
        // Set some things from the global config.
82
        final ConfigFile config = ConfigManager.getConfigFile();
83
        final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
84
        if (engine != null) {
85
            engine.clear();
86
            api.removeComponent(engine);
87
        }
88
        engine = new LetterEngine(config);
89
        api.addComponent(engine);
90
    }
91
92
    @Override
93
    public void onReload() {
94
        synchronized(engine) {
95
            engine.clear();
96
        }
97
        init();
98
    }
99
100
    /**
101
     * Check without further synchronization.
102
     * @param player
103
     * @param message
104
     * @param captcha
105
     * @param cc
106
     * @param data
107
     * @param isMainThread 
108
     * @param alreadyCancelled 
109
     * @return
110
     */
111
    private boolean unsafeCheck(final Player player, final String message, final ICaptcha captcha,
112
                                final ChatConfig cc, final ChatData data, final IPlayerData pData,
113
                                boolean isMainThread, final boolean alreadyCancelled) {
114
115
        // Test captcha.
116
        if (captcha.shouldCheckCaptcha(player, cc, data, pData)) {
117
            captcha.checkCaptcha(player, message, cc, data, isMainThread);
118
            return true;
119
        } 
120
        else if (alreadyCancelled) {
121
            // Skip checking.
122
            return true;
123
        }
124
125
        final long time = System.currentTimeMillis();
126
        final String lcMessage = message.trim().toLowerCase();
127
        boolean cancel = false;
128
        final boolean debug = pData.isDebugActive(type);
129
        final List<String> debugParts;
130
        if (debug) {
131
            debugParts = new LinkedList<String>();
132
            debugParts.add("Message (length=" + message.length()+"): ");
133
        }
134
        else debugParts = null;
135
136
        // Update the frequency interval weights.
137
        data.chatFrequency.update(time);
138
139
        // Score for this message (violation score).
140
        float score = 0;
141
        final MessageLetterCount letterCounts = new MessageLetterCount(message);
142
        final int msgLen = message.length();
143
144
145
146
        // (Following: random/made up criteria.)
147
        // TODO: Create tests for all methods with wordlists, fake chat (refactor for that).
148
        // Full message processing. ------------
149
        // Upper case.
150
        if (letterCounts.fullCount.upperCase > msgLen / 3) {
151
            // TODO: Regard chunks of 48 or so letters of the message for this?
152
            final float wUpperCase = 0.6f * letterCounts.fullCount.getUpperCaseRatio();
153
            score += wUpperCase  * cc.textMessageUpperCase;
154
        }
155
156
        // Letters vs. word length.
157
        if (msgLen > 4) {
158
            final float fullRep = letterCounts.fullCount.getLetterCountRatio();
159
            // Long messages: very small and very big are bad !
160
            // 128 is a quick attempt to make one long message possible on 1.11.
161
            final float wRepetition = (float) Math.min(msgLen, 128) / 15.0f * Math.abs(0.5f - fullRep);
162
            score += wRepetition * cc.textMessageLetterCount;
163
164
            // Number of words vs. length of message
165
            final float fnWords = (float) letterCounts.words.length / (float) msgLen;
166
            if (fnWords > 0.75f) { // TODO: balance or configure or remove ?
167
                score += fnWords  * cc.textMessagePartition;
168
            }
169
        }
170
171
        final CombinedData cData = pData.getGenericInstance(CombinedData.class);
172
        final long timeout = 8000; // TODO: maybe set dynamically in data.
173
        // Repetition of last message.
174
        if (cc.textMsgRepeatSelf != 0f && time - data.chatLastTime < timeout) {
175
            if (StringUtil.isSimilar(lcMessage, data.chatLastMessage, 0.8f)) {
176
                final float timeWeight = (float) (timeout - (time - data.chatLastTime)) / (float) timeout; 
177
                score += cc.textMsgRepeatSelf * timeWeight;
178
            }
179
        }
180
        // Repetition of last global message.
181
        if (cc.textMsgRepeatGlobal != 0f && time - lastGlobalTime < timeout) {
182
            if (StringUtil.isSimilar(lcMessage, lastGlobalMessage, 0.8f)) {
183
                final float timeWeight = (float) (timeout - (time - lastGlobalTime)) / (float) timeout; 
184
                score += cc.textMsgRepeatGlobal * timeWeight;
185
            }
186
        }
187
        // Repetition of last cancelled message.
188
        if (cc.textMsgRepeatCancel != 0f && time - lastCancelledTime < timeout) {
189
            if (StringUtil.isSimilar(lcMessage, lastCancelledMessage, 0.8f)) {
190
                final float timeWeight = (float) (timeout - (time - lastCancelledTime)) / (float) timeout; 
191
                score += cc.textMsgRepeatCancel * timeWeight;
192
            }
193
        }
194
        // Chat quickly after join.
195
        if (cc.textMsgAfterJoin != 0f && time - cData.lastJoinTime < timeout) {
196
            final float timeWeight = (float) (timeout - (time - cData.lastJoinTime)) / (float) timeout;
197
            score += cc.textMsgAfterJoin * timeWeight; 
198
        }
199
        // Chat without moving.
200
        if (cc.textMsgNoMoving != 0f && time - cData.lastMoveTime > timeout) {
201
            score += cc.textMsgNoMoving;
202
        }
203
204
205
206
        // Per word checks. -------------------
207
        float wWords = 0.0f;
208
        final float avwLen = (float) msgLen / (float) letterCounts.words.length; 
209
        for (final WordLetterCount word : letterCounts.words) {
210
            float wWord = 0.0f;
211
            final int wLen = word.word.length();
212
            // TODO: ? used letters vs. word length.
213
214
            // Length of word vs. av. word length.
215
            final float fLenAv = Math.abs(avwLen - (float) wLen) / avwLen;
216
            wWord += fLenAv * cc.textMessageLengthAv;
217
218
            // Length of word vs. message length;
219
            final float fLenMsg = (float) wLen / (float) msgLen;
220
            wWord += fLenMsg * cc.textMessageLengthMsg;
221
222
            // Not letter:
223
            float notLetter = word.getNotLetterRatio();
224
            notLetter *= notLetter;
225
            wWord += notLetter * cc.textMessageNoLetter;
226
227
            wWord *= wWord; // TODO: quadratic ? (configurable)
228
            wWords += wWord;
229
        }
230
        wWords /= (float) letterCounts.words.length;
231
        score += wWords;
232
233
        if (debug && score > 0f) {
234
            debugParts.add("Simple score: " + StringUtil.fdec3.format(score));
235
        }
236
237
        // Engine:
238
        // TODO: more fine grained sync !
239
        float wEngine = 0f;
240
        final Map<String, Float> engMap;
241
        synchronized (engine) {
242
            engMap = engine.process(letterCounts, player.getName(), cc, data);
243
            // TODO: more fine grained sync !s
244
            // TODO: different methods (add or max or add+max or something else).
245
            for (final Float res : engMap.values()) {
246
                if (cc.textEngineMaximum) {
247
                    wEngine = Math.max(wEngine, res.floatValue());
248
                }
249
                else wEngine += res.floatValue();
250
            }
251
        }
252
        score += wEngine;
253
254
255
        // Wrapping it up. --------------------
256
        // Add weight to frequency counts.
257
        final float normalScore = Math.max(cc.textFreqNormMin, score);
258
        data.chatFrequency.add(time, normalScore);
259
        final float accumulated = cc.textFreqNormWeight * data.chatFrequency.score(cc.textFreqNormFactor);
260
        final boolean normalViolation = accumulated > cc.textFreqNormLevel;
261
        final float shortTermScore = Math.max(cc.textFreqShortTermMin, score);
262
        data.chatShortTermFrequency.add(time, shortTermScore);
263
        // TODO: very short term (1st bucket) or do it indirectly.
264
        final float shortTermAccumulated = cc.textFreqShortTermWeight * data.chatShortTermFrequency.score(cc.textFreqShortTermFactor);
265
        final boolean shortTermViolation = shortTermAccumulated > cc.textFreqShortTermLevel;
266
267
        if (normalViolation || shortTermViolation) {
268
            lastCancelledMessage = lcMessage;
269
            lastCancelledTime = time;
270
271
            final double added;
272
            if (shortTermViolation) {
273
                added = (shortTermAccumulated - cc.textFreqShortTermLevel)/ 3.0;
274
            } 
275
            else added = (accumulated - cc.textFreqNormLevel) / 10.0; 
276
            data.textVL += added;
277
278
            if (captcha.shouldStartCaptcha(player, cc, data, pData)) {
279
                captcha.sendNewCaptcha(player, cc, data);
280
                cancel = true;
281
            }
282
            else {
283
                if (shortTermViolation) {
284
                    if (executeActions(player, data.textVL, added, cc.textFreqShortTermActions).willCancel()) {
285
                        cancel = true;
286
                    }
287
                }
288
                else if (normalViolation) {
289
                    if (executeActions(player, data.textVL, added, cc.textFreqNormActions).willCancel()) {
290
                        cancel = true;
291
                    }
292
                }
293
            }
294
        }
295
        else if (cc.chatWarningCheck && time - data.chatWarningTime > cc.chatWarningTimeout && (100f * accumulated / cc.textFreqNormLevel > cc.chatWarningLevel || 100f * shortTermAccumulated / cc.textFreqShortTermLevel > cc.chatWarningLevel)) {
296
            NCPAPIProvider.getNoCheatPlusAPI().sendMessageOnTick(player.getName(), ColorUtil.replaceColors(cc.chatWarningMessage));
297
            data.chatWarningTime = time;
298
        }
299
        else {
300
            data.textVL *= 0.95;
301
            if (cc.textAllowVLReset && normalScore < 2.0f * cc.textFreqNormWeight && shortTermScore < 2.0f * cc.textFreqShortTermWeight) {
302
                // Reset the VL.
303
                // Maybe elaborate on resetting conditions (after some timeout just divide by two or so?).
304
                data.textVL = 0.0;
305
            }
306
        }
307
308
        if (debug) {
309
            final List<String> keys = new LinkedList<String>(engMap.keySet());
310
            Collections.sort(keys);
311
            for (String key : keys) {
312
                Float s = engMap.get(key);
313
                if (s.floatValue() > 0.0f)
314
                    debugParts.add(key + ":" + StringUtil.fdec3.format(s));
315
            }
316
            if (wEngine > 0.0f)
317
                debugParts.add("Engine score (" + (cc.textEngineMaximum?"max":"sum") + "): " + StringUtil.fdec3.format(wEngine));
318
319
            debugParts.add("Final score: " +  StringUtil.fdec3.format(score));
320
            debugParts.add("Normal: min=" +  StringUtil.fdec3.format(cc.textFreqNormMin) +", weight=" +  StringUtil.fdec3.format(cc.textFreqNormWeight) + " => accumulated=" + StringUtil.fdec3.format(accumulated));
321
            debugParts.add("Short-term: min=" +  StringUtil.fdec3.format(cc.textFreqShortTermMin) +", weight=" +  StringUtil.fdec3.format(cc.textFreqShortTermWeight) + " => accumulated=" + StringUtil.fdec3.format(shortTermAccumulated));
322
            debugParts.add("vl: " + StringUtil.fdec3.format(data.textVL));
323
            debug(player, StringUtil.join(debugParts, " | "));
324
            debugParts.clear();
325
        }
326
327
        lastGlobalMessage = data.chatLastMessage = lcMessage;
328
        lastGlobalTime = data.chatLastTime = time;
329
        return cancel;
330
    }
331
}

How it counteracts this module

NCP's Text check scores every C01 chat message: an upper-case ratio beyond a third of the message length, letter-count and partition ratios for longer messages, per-word length and non-letter scores with the non-letter term squared, and a similarity comparison against the previous message within 8000ms, all folded into the chatFrequency and chatShortTermFrequency accumulators with the textFreqNormLevel and textFreqShortTermLevel floors.

The honest boundary: FakeHacker produces no serverbound traffic of its own, so no chat check can observe it. The theater it imitates surfaces in chat only if the user broadcasts accusations, and that broadcast stream is exactly what Text binds with its frequency floors and repetition penalty; the module itself stays under every threshold by emitting nothing. Text runs from ChatListener.onPlayerChat on the AsyncPlayerChatEvent at LOWEST priority, so it sees every message the module's user actually sends.

anticheat Commands ('/' command rate)

Commands.java117 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.chat;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.checks.Check;
20
import fr.neatmonster.nocheatplus.checks.CheckType;
21
import fr.neatmonster.nocheatplus.players.IPlayerData;
22
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
23
import fr.neatmonster.nocheatplus.utilities.TickTask;
24
25
/**
26
 * Check only for commands
27
 * @author asofold
28
 *
29
 */
30
public class Commands extends Check {
31
32
    public Commands() {
33
        super(CheckType.CHAT_COMMANDS);
34
    }
35
    
36
    /**
37
     * Checks a player for command spam
38
     * 
39
     * @param player
40
     * @param message
41
     * @param cc
42
     * @param pData
43
     * @param captcha
44
     * @return true if successful.
45
     */
46
    public boolean check(final Player player, final String message, 
47
                         final ChatConfig cc, final IPlayerData pData, 
48
                         final ICaptcha captcha) {
49
50
        final long now = System.currentTimeMillis();
51
        final int tick = TickTask.getTick();
52
        final ChatData data = pData.getGenericInstance(ChatData.class);
53
        final boolean captchaEnabled = !cc.captchaSkipCommands && pData.isCheckActive(CheckType.CHAT_CAPTCHA, player); 
54
        if (captchaEnabled){
55
            synchronized (data) {
56
                if (captcha.shouldCheckCaptcha(player, cc, data, pData)){
57
                    captcha.checkCaptcha(player, message, cc, data, true);
58
                    return true;
59
                }
60
            }
61
        }
62
63
        // Rest of the check is done without sync, because the data is only used by this check.
64
        // Weight might later be read from some prefix tree (also known / unknown).
65
        final float weight = 1f;
66
        data.commandsWeights.add(now, weight);
67
        if (tick < data.commandsShortTermTick) {
68
            // TickTask got reset.
69
            data.commandsShortTermTick = tick;
70
            data.commandsShortTermWeight = 1.0;
71
        }
72
        else if (tick - data.commandsShortTermTick < cc.commandsShortTermTicks) {
73
            if (!pData.getCurrentWorldData().shouldAdjustToLag(type) 
74
                || TickTask.getLag(50L * (tick - data.commandsShortTermTick), true) < 1.3f) {
75
                // Add up.
76
                data.commandsShortTermWeight += weight;
77
            }
78
            else {
79
                // Reset, too much lag.
80
                data.commandsShortTermTick = tick;
81
                data.commandsShortTermWeight = 1.0;
82
            }
83
        }
84
        else{
85
            // Reset.
86
            data.commandsShortTermTick = tick;
87
            data.commandsShortTermWeight = 1.0;
88
        }
89
90
        final float nw = data.commandsWeights.score(1f);
91
        final double violation = Math.max(nw - cc.commandsLevel, data.commandsShortTermWeight - cc.commandsShortTermLevel);
92
93
        if (violation > 0.0) {
94
            data.commandsVL += violation;
95
            // TODO: Evaluate if sync(data) is necessary or better for executeActions.
96
            if (captchaEnabled) {
97
                synchronized (data) {
98
                    captcha.sendNewCaptcha(player, cc, data);
99
                }
100
                return true;
101
            }
102
            else if (executeActions(player, data.commandsVL, violation, cc.commandsActions).willCancel()) {
103
                return true;
104
            }
105
        }
106
        else if (cc.chatWarningCheck && now - data.chatWarningTime > cc.chatWarningTimeout && (100f * nw / cc.commandsLevel > cc.chatWarningLevel || 100f * data.commandsShortTermWeight / cc.commandsShortTermLevel > cc.chatWarningLevel)){
107
            player.sendMessage(ColorUtil.replaceColors(cc.chatWarningMessage));
108
            data.chatWarningTime = now;
109
        }
110
        else {
111
            // TODO: This might need invalidation with time.
112
            data.commandsVL *= 0.99;
113
        }
114
        return false;
115
    }
116
117
}

How it counteracts this module

NCP Commands weights every '/'-prefixed command at 1.0 into commandsWeights and compares the accumulated weight against commandsLevel plus the short-term window against commandsShortTermLevel, resetting the window when server lag exceeds 1.3. It runs from ChatListener.onPlayerCommandPreprocess, so only commands that reach the server count.

The FakeHackerTarget setup is handled by Sigma's chat-prefixed command system: its fire() writes a local message through addChatMessage and never queues a C01, so the setup produces no PlayerCommandPreprocess traffic either. Commands can therefore only bound the genuine '/'-commands the user types around the fake-hacker theater, and the module's zero-traffic behavior is invisible to it by construction, which is the honest statement of this entry: the check polices the surrounding command stream, not the module.

anticheat Captcha (chat gate)

Captcha.java115 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.chat;
16
17
import java.util.concurrent.ThreadLocalRandom;
18
19
import org.bukkit.entity.Player;
20
21
import fr.neatmonster.nocheatplus.checks.Check;
22
import fr.neatmonster.nocheatplus.checks.CheckType;
23
import fr.neatmonster.nocheatplus.players.DataManager;
24
import fr.neatmonster.nocheatplus.players.IPlayerData;
25
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
26
27
/**
28
 * NOTE: EARLY REFACTORING STATE, MOST METHODS NEED SYNC OVER DATA !
29
 * @author mc_dev
30
 *
31
 */
32
public class Captcha extends Check implements ICaptcha{
33
34
    public Captcha() {
35
        super(CheckType.CHAT_CAPTCHA);
36
    }
37
38
    @Override
39
    public void checkCaptcha(Player player, String message, ChatConfig cc, ChatData data, boolean isMainThread) {
40
        // Correct answer to the captcha?
41
        if (message.equals(data.captchaGenerated)) {
42
            // Yes, clear their data and do not worry anymore about them.
43
            data.reset();
44
            data.captchaStarted = false;
45
            player.sendMessage(ColorUtil.replaceColors(cc.captchaSuccess));
46
        } 
47
        else {
48
            // Increment their tries number counter.
49
            data.captchTries++;
50
            data.captchaVL ++;
51
            // Have they failed too man times?
52
            if (data.captchTries > cc.captchaTries) {
53
                // Find out if we need to kick the player or not.
54
                executeActions(player, data.captchaVL, 1, cc.captchaActions);
55
                // (Resetting captcha tries is done on quit/kick).
56
            }
57
            // Display the question again (if not kicked).
58
            if (player.isOnline()) {
59
                sendCaptcha(player, cc, data);
60
            }
61
        }
62
    }
63
64
    @Override
65
    public void sendNewCaptcha(Player player, ChatConfig cc, ChatData data) {
66
        // Display a captcha to the player.
67
        generateCaptcha(cc, data, true);
68
        sendCaptcha(player, cc, data);
69
        data.captchaStarted = true;
70
    }
71
72
    @Override
73
    public void generateCaptcha(ChatConfig cc, ChatData data, boolean reset) {
74
        if (reset) data.captchTries = 0;
75
        final char[] chars = new char[cc.captchaLength];
76
        for (int i = 0; i < cc.captchaLength; i++) {
77
            chars[i] = cc.captchaCharacters.charAt(ThreadLocalRandom.current().nextInt(cc.captchaCharacters.length()));
78
        }
79
        data.captchaGenerated = new String(chars);
80
    }
81
82
    @Override
83
    public void resetCaptcha(Player player){
84
        final IPlayerData pData = DataManager.getPlayerData(player);
85
        ChatData data = pData.getGenericInstance(ChatData.class);
86
        synchronized (data) {
87
            resetCaptcha(player, pData.getGenericInstance(ChatConfig.class), data, pData);
88
        }
89
    }
90
91
    @Override
92
    public void resetCaptcha(Player player, ChatConfig cc, ChatData data, IPlayerData pData) {
93
        data.captchTries = 0;
94
        if (shouldCheckCaptcha(player, cc, data, pData) || shouldStartCaptcha(player, cc, data, pData)){
95
            generateCaptcha(cc, data, true);
96
        }
97
    }
98
99
    @Override
100
    public void sendCaptcha(Player player, ChatConfig cc, ChatData data) {
101
        player.sendMessage(ColorUtil.replaceColors(cc.captchaQuestion.replace("[captcha]", data.captchaGenerated)));
102
    }
103
104
    @Override
105
    public boolean shouldStartCaptcha(Player player, ChatConfig cc, ChatData data, IPlayerData pData) {
106
        // TODO: Only call if IWorldData.isCheckActive(CHAT_CAPTCHA) has returned true?
107
        return !data.captchaStarted && pData.isCheckActive(CheckType.CHAT_CAPTCHA, player);
108
    }
109
110
    @Override
111
    public boolean shouldCheckCaptcha(Player player, ChatConfig cc, ChatData data, IPlayerData pData) {
112
        // TODO: Only call if IWorldData.isCheckActive(CHAT_CAPTCHA) has returned true?
113
        return data.captchaStarted  && pData.isCheckActive(CheckType.CHAT_CAPTCHA, player);
114
    }
115
}

How it counteracts this module

NCP Captcha is the enforcement end of the chat pipeline: shouldStartCaptcha auto-arms a challenge on chat violations, sendNewCaptcha generates a random captchaLength-character string, and checkCaptcha accepts only an exact equality between the incoming message and the stored captchaGenerated value, with wrong answers raising captchTries and captchaVL until the captchaTries threshold triggers the configured kick or ban actions.

For FakeHacker the gate is doubly unreachable: the module never sends chat, so it can never trip the frequency checks that arm the captcha, and the setup command is intercepted client-side before the wire. The captcha would only ever engage against the user's own spam, not against the module's behavior. The entry is therefore an honest boundary: it is the strongest chat-side enforcement available on the channel this module's category implies, and the module passes through it by emitting nothing, which is also why no server-side check can ever detect the module running.

← Back to Analysis Hub