Spammer module

Spammer: Minecraft 26.3 cheat module, full source for every implementation (2 clients: MelaHack (ThunderHack fork), LiquidBounce (Kotlin)).

2 implementationsMISC

Full module source: 2 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

MelaHack (ThunderHack fork)MISCsrc/main/java/thunder/hack/features/modules/misc/Spammer.javaJava · 181 lines · 6.3 KB

Spamming the name of your best kitshop.

SettingsmodemessagesprefixglobalAntiSpamdelay
Spammer.javaJava · Minecraft 26.2 · 181 lines · 6.3 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.misc;
2
3
import com.google.gson.JsonObject;
4
import com.google.gson.JsonParser;
5
import org.apache.commons.io.IOUtils;
6
import thunder.hack.core.Managers;
7
import thunder.hack.features.hud.impl.StaffBoard;
8
import thunder.hack.features.modules.Module;
9
import thunder.hack.setting.Setting;
10
import thunder.hack.utility.Timer;
11
12
import java.io.*;
13
import java.net.URI;
14
import java.net.URL;
15
import java.nio.charset.StandardCharsets;
16
import java.util.ArrayList;
17
import java.util.List;
18
import java.util.Random;
19
20
import static thunder.hack.features.modules.client.ClientSettings.isRu;
21
22
public class Spammer extends Module {
23
    public static ArrayList<String> SpamList = new ArrayList<>();
24
    public Setting<Mode> mode = new Setting<>("mode", Mode.Chat);
25
    public Setting<Messages> messages = new Setting<>("messages", Messages.File);
26
    public Setting<WhisperPrefix> whisper_prefix = new Setting<>("prefix", WhisperPrefix.W, v -> mode.getValue() == Mode.Whispers);
27
    public Setting<Boolean> global = new Setting<>("global", true, v -> mode.getValue() == Mode.Chat);
28
    public Setting<Boolean> antiSpam = new Setting<>("AntiSpam", false);
29
    public Setting<Float> delay = new Setting<>("delay", 5f, 0f, 30f);
30
    private final Timer timer_delay = new Timer();
31
    private final Random random = new Random();
32
    private String fact;
33
34
    public Spammer() {
35
        super("Spammer", Category.MISC);
36
    }
37
38
    public static void loadSpammer() {
39
        try {
40
            File file = new File("ThunderHackRecode/misc/spammer.txt");
41
42
            if (!file.exists()) file.createNewFile();
43
            new Thread(() -> {
44
                try {
45
                    FileInputStream fis = new FileInputStream(file);
46
                    InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
47
                    BufferedReader reader = new BufferedReader(isr);
48
                    ArrayList<String> lines = new ArrayList<>();
49
                    String line;
50
                    while ((line = reader.readLine()) != null) {
51
                        lines.add(line);
52
                    }
53
54
                    boolean newline = false;
55
56
                    for (String l : lines) {
57
                        if (l.equals("")) {
58
                            newline = true;
59
                            break;
60
                        }
61
                    }
62
63
                    SpamList.clear();
64
                    ArrayList<String> spamList = new ArrayList<>();
65
66
                    if (newline) {
67
                        StringBuilder spamChunk = new StringBuilder();
68
69
                        for (String l : lines) {
70
                            if (l.equals("")) {
71
                                if (!spamChunk.isEmpty()) {
72
                                    spamList.add(spamChunk.toString());
73
                                    spamChunk = new StringBuilder();
74
                                }
75
                            } else {
76
                                spamChunk.append(l).append(" ");
77
                            }
78
                        }
79
                        spamList.add(spamChunk.toString());
80
                    } else spamList.addAll(lines);
81
                    SpamList = spamList;
82
                } catch (Exception ignored) {
83
                }
84
            }).start();
85
        } catch (IOException ignored) {
86
        }
87
    }
88
89
    public String getPlayerName() {
90
        try {
91
            List<String> list = StaffBoard.getOnlinePlayer();
92
            if (list.isEmpty())
93
                return "";
94
            return list.get(random.nextInt(0, list.size() - 1));
95
        } catch (NullPointerException e) {
96
            return null;
97
        }
98
    }
99
100
    private void changeFact() {
101
        Managers.ASYNC.run(() -> {
102
            try {
103
                String jsonResponse = IOUtils.toString(URI.create("https://catfact.ninja/fact?max_length=200").toURL(), StandardCharsets.UTF_8);
104
                JsonObject jsonObject = JsonParser.parseString(jsonResponse).getAsJsonObject();
105
                fact = jsonObject.get("fact").getAsString();
106
            } catch (IOException e) {
107
                disable(isRu() ? "Не удалось загрузить факт, может ты включишь интернет?" : "Failed to load the fact, can you turn on the Internet?");
108
            }
109
        });
110
    }
111
112
    public static String generateRandomSymbol() {
113
        Random random = new Random();
114
        String randomSymbol = "[";
115
        randomSymbol += (char) (random.nextInt(26) + 'a');
116
        randomSymbol += random.nextInt(10);
117
        randomSymbol += (char) (random.nextInt(26) + 'a');
118
        randomSymbol += "]";
119
        return randomSymbol;
120
    }
121
122
    @Override
123
    public void onEnable() {
124
        loadSpammer();
125
        changeFact();
126
    }
127
128
    @Override
129
    public void onUpdate() {
130
        if (timer_delay.passedMs((long) (delay.getValue() * 1000))) {
131
            String c;
132
            if (messages.getValue() == Messages.File) {
133
                if (SpamList.isEmpty()) {
134
                    disable(isRu() ? "Файл spammer пустой!" : "The spammer file is empty!");
135
                    return;
136
                }
137
                c = SpamList.get(new Random().nextInt(SpamList.size()));
138
            } else {
139
                if (fact == null) {
140
                    return;
141
                }
142
                c = fact;
143
                changeFact();
144
            }
145
            if (antiSpam.getValue()) {
146
                c += generateRandomSymbol();
147
            }
148
            if (mode.getValue() == Mode.Chat) {
149
                if (c.charAt(0) == '/') {
150
                    c = c.replace("/", "");
151
                    mc.player.connection.sendCommand(c);
152
                } else mc.player.connection.sendChat(global.getValue() ? "!" + c : c);
153
            } else {
154
                try {
155
                    String prefix = whisper_prefix.getValue().prefix;
156
                    mc.player.connection.sendCommand(prefix + getPlayerName() + " " + c);
157
                } catch (NullPointerException e) {
158
                }
159
            }
160
161
            timer_delay.reset();
162
        }
163
    }
164
165
    private enum Messages {File, CatFacts}
166
167
    private enum Mode {Chat, Whispers}
168
169
    private enum WhisperPrefix {
170
        W("w "),
171
        Msg("msg "),
172
        Tell("tell ");
173
174
        final String prefix;
175
176
        WhisperPrefix(String p) {
177
            prefix = p;
178
        }
179
    }
180
}
181
LiquidBounce (Kotlin)MISCsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/misc/ModuleSpammer.ktKotlin · 248 lines · 8.6 KB

Spams the chat with specified messages.

SettingsDelayMPSMessageSourcePatternMessageConverterCustomFormatter
ModuleSpammer.ktKotlin · Minecraft 26.2 · 248 lines · 8.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.misc
20
21
import it.unimi.dsi.fastutil.longs.LongArrayList
22
import kotlinx.atomicfu.atomic
23
import kotlinx.coroutines.CoroutineName
24
import kotlinx.coroutines.Dispatchers
25
import kotlinx.coroutines.delay
26
import kotlinx.coroutines.launch
27
import kotlinx.coroutines.withContext
28
import net.ccbluex.fastutil.longListOf
29
import net.ccbluex.liquidbounce.api.core.ioScope
30
import net.ccbluex.liquidbounce.config.types.group.Mode
31
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
32
import net.ccbluex.liquidbounce.config.types.list.Tagged
33
import net.ccbluex.liquidbounce.features.module.ClientModule
34
import net.ccbluex.liquidbounce.features.module.ModuleCategories
35
import net.ccbluex.liquidbounce.utils.client.chat
36
import net.ccbluex.liquidbounce.utils.client.markAsError
37
import net.ccbluex.liquidbounce.utils.io.skipLine
38
import net.ccbluex.liquidbounce.utils.kotlin.mapString
39
import net.ccbluex.liquidbounce.utils.kotlin.random
40
import org.apache.commons.lang3.RandomStringUtils
41
import java.io.RandomAccessFile
42
import kotlin.random.Random
43
import kotlin.time.Duration.Companion.seconds
44
45
/**
46
 * Spammer module
47
 *
48
 * Spams the chat with a given message.
49
 */
50
object ModuleSpammer : ClientModule("Spammer", ModuleCategories.MISC, disableOnQuit = true) {
51
52
    init {
53
        doNotIncludeAlways()
54
    }
55
56
    private const val MAX_CHARS = 256
57
58
    private val delay by floatRange("Delay", 2f..4f, 0f..300f, "secs")
59
    private val mps by intRange("MPS", 1..1, 1..500, "messages")
60
    private val message = choices("MessageSource", 0) {
61
        arrayOf(MessageProvider.Setting, MessageProvider.File)
62
    }
63
64
    private sealed class MessageProvider(name: String) : Mode(name) {
65
        override val parent: ModeValueGroup<*>
66
            get() = message
67
68
        abstract fun nextMessage(): String
69
70
        object Setting : MessageProvider("Setting") {
71
            private val linear = atomic(0)
72
73
            private val texts by textList("Message", mutableListOf(
74
                "LiquidBounce Nextgen | CCBlueX on [youtube] | liquidbounce{.net}",
75
                "I'm using LiquidBounce Nextgen and you should too!",
76
                "Check out LiquidBounce Nextgen - the best Minecraft client!",
77
                "Tired of losing? Try LiquidBounce Nextgen!",
78
            ))
79
80
            override fun nextMessage(): String =
81
                when (pattern) {
82
                    SpammerPattern.RANDOM -> texts.random()
83
                    SpammerPattern.LINEAR -> texts[linear.getAndIncrement() % texts.size]
84
                }
85
        }
86
87
        object File : MessageProvider("File") {
88
89
            private val coroutineName = CoroutineName("SpammerFileSourceReader")
90
91
            private val source by file("Source", supportedExtensions = setOf("txt")).onChanged {
92
                if (!it.isFile) return@onChanged
93
94
                ioScope.launch(coroutineName) {
95
                    val newIndices = LongArrayList()
96
                    newIndices.add(0L)
97
                    RandomAccessFile(it, "r").use { raf ->
98
                        while (raf.skipLine() != 0L) {
99
                            newIndices.add(raf.filePointer)
100
                        }
101
                    }
102
                    lineIndex = newIndices
103
                }
104
            }
105
106
            private val linear = atomic(0)
107
            @Volatile
108
            private var lineIndex = longListOf()
109
110
            override fun nextMessage(): String {
111
                val lineIndex = lineIndex
112
                require(lineIndex.isNotEmpty()) { "File is empty or not selected" }
113
114
                val index = when (pattern) {
115
                    SpammerPattern.RANDOM -> lineIndex.getLong(Random.nextInt(lineIndex.size))
116
                    SpammerPattern.LINEAR -> lineIndex.getLong(linear.getAndIncrement() % lineIndex.size)
117
                }
118
                return RandomAccessFile(source, "r").use { raf ->
119
                    raf.seek(index)
120
                    raf.readLine()
121
                }
122
            }
123
        }
124
    }
125
    private val pattern by enumChoice("Pattern", SpammerPattern.RANDOM)
126
    private val messageConverterMode by enumChoice("MessageConverter", MessageConverterMode.LEET_CONVERTER)
127
    private val customFormatter by boolean("CustomFormatter", false)
128
129
    override suspend fun enabledEffect() = withContext(Dispatchers.IO) {
130
        while (true) {
131
            repeat(mps.random()) {
132
                val chosenMessage = try {
133
                    message.activeMode.nextMessage()
134
                } catch (e: Exception) {
135
                    chat(markAsError("Failed to get spammer message: $e"))
136
                    return@repeat
137
                }
138
139
                val text = applyConversion(chosenMessage)
140
141
                sendMessageOrCommand(text)
142
            }
143
144
            delay(delay.random().toDouble().seconds)
145
        }
146
    }
147
148
    private fun applyConversion(text: String): String {
149
        return messageConverterMode.convert(if (customFormatter) {
150
            format(text)
151
        } else {
152
            "[${RandomStringUtils.insecure().nextAlphabetic(1, 5)}] " +
153
                MessageConverterMode.RANDOM_CASE_CONVERTER.convert(text)
154
        })
155
    }
156
157
    private fun sendMessageOrCommand(text: String) {
158
        if (text.length > MAX_CHARS) {
159
            chat("Spammer message is too long! (Max $MAX_CHARS characters)")
160
            return
161
        }
162
163
        if (text.startsWith('/')) {
164
            network.sendCommand(text.substring(1))
165
        } else {
166
            network.sendChat(text)
167
        }
168
    }
169
170
    private fun format(text: String): String {
171
        var formattedText = text.replace("%f") {
172
            Random.nextFloat()
173
        }.replace("%i") {
174
            Random.nextInt(10000)
175
        }.replace("%s") {
176
            RandomStringUtils.insecure().nextAlphabetic(4, 7)
177
        }
178
179
        if (formattedText.contains("@a")) {
180
            mc.connection?.onlinePlayers?.mapNotNull {
181
                it?.profile?.name.takeIf { n -> n != player.gameProfile?.name }
182
            }?.takeIf { it.isNotEmpty() }?.let { playerNameList ->
183
                formattedText = formattedText.replace("@a") { playerNameList.random() }
184
            }
185
        }
186
187
        return formattedText
188
    }
189
190
    private inline fun String.replace(oldValue: String, newValueProvider: () -> Any): String {
191
        var index = 0
192
        val newString = StringBuilder(this)
193
        while (true) {
194
            index = newString.indexOf(oldValue, startIndex = index)
195
            if (index == -1) {
196
                break
197
            }
198
199
            val newValue = newValueProvider().toString()
200
            newString.replace(index, index + oldValue.length, newValue)
201
202
            index += newValue.length
203
        }
204
        return newString.toString()
205
    }
206
207
    enum class MessageConverterMode(override val tag: String, val convert: (String) -> String) : Tagged {
208
        NO_CONVERTER("None", { text ->
209
            text
210
        }),
211
        LEET_CONVERTER("Leet", { text ->
212
            text.mapString { char ->
213
                when (char) {
214
                    'o' -> '0'
215
                    'l' -> '1'
216
                    'e' -> '3'
217
                    'a' -> '4'
218
                    't' -> '7'
219
                    's' -> 'Z'
220
                    else -> char
221
                }
222
            }
223
        }),
224
        RANDOM_CASE_CONVERTER("Random Case", { text ->
225
            // Random case the whole string
226
            text.mapString { char ->
227
                if (Random.nextBoolean()) char.uppercaseChar() else char.lowercaseChar()
228
            }
229
        }),
230
        RANDOM_SPACE_CONVERTER("Random Space", { text ->
231
            buildString(text.length * 2) {
232
                for (char in text) {
233
                    append(char)
234
                    if (Random.nextBoolean()) {
235
                        append(' ')
236
                    }
237
                }
238
            }
239
        }),
240
    }
241
242
    enum class SpammerPattern(override val tag: String) : Tagged {
243
        RANDOM("Random"),
244
        LINEAR("Linear"),
245
    }
246
247
}
248