L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java/** AntiBot */public static boolean ANTIBOT_ENABLE;public static int ANTIBOT_TIME_JAIL;public static int ANTIBOT_TIME_VOTE;public static int ANTIBOT_KILL_MOBS;public static int ANTIBOT_MIN_LEVEL;ANTIBOT_ENABLE = customServerConfig.getBoolean("AntiBotEnable", true);ANTIBOT_TIME_JAIL = customServerConfig.getInt("AntiBotTimeJail", 1);ANTIBOT_TIME_VOTE = customServerConfig.getInt("AntiBotTimeVote", 30);ANTIBOT_KILL_MOBS = customServerConfig.getInt("AntiBotKillMobs", 1);ANTIBOT_MIN_LEVEL = customServerConfig.getInt("AntiBotMinLevel", 1);
L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.javaimport org.l2jmobius.gameserver.datatables.AntiBotTable;AntiBotTable.getInstance().loadImage();
L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/AntiBotTable.java/* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */package org.l2jmobius.gameserver.datatables;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.util.HashMap;import java.util.Map;import java.util.Map.Entry;import java.util.logging.Level;import java.util.logging.Logger;import org.l2jmobius.commons.concurrent.ThreadPool;import org.l2jmobius.commons.util.Rnd;import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;import org.l2jmobius.gameserver.network.serverpackets.PledgeImage;/** * @author Fissban */public class AntiBotTable{ public static Logger _log = Logger.getLogger(AntiBotTable.class.getName()); public static Map<Integer, antiBotData> _imageAntiBotOri = new HashMap<>(); public static Map<Integer, antiBotData> _imageAntiBotClient = new HashMap<>(); public final static int[] img_antibot_id = { 7000, 7001, 7002, 7003, 7004, 7005, 7006, 7007, 7008, 7009 }; public void loadImage() { LoadImgAntiBot(); _log.log(Level.INFO, "loading " + _imageAntiBotOri.size() + " images of AntiBot"); } private static void LoadImgAntiBot() { _imageAntiBotOri.clear(); int cont = 0; for (int imgId : img_antibot_id) { File image = new File("data/images/antibot/" + imgId + ".dds"); _imageAntiBotOri.put(cont, new antiBotData(cont, ConverterImgBytes(image))); cont++; } ThreadPool.scheduleAtFixedRate(new startEncriptCaptcha(), 100, 600000); // 10 Minutes } public void sendImage(PlayerInstance player, int imgId) { PledgeImage packet = null; if ((imgId >= 50000) && (imgId <= 800000)) { for (Entry<Integer, antiBotData> entrySet : _imageAntiBotClient.entrySet()) { antiBotData imgCoding = entrySet.getValue(); if (imgId == imgCoding.getCodificacion()) { packet = new PledgeImage(imgId, imgCoding.getImagen()); } } } player.sendPacket(packet); } public static class startEncriptCaptcha implements Runnable { public startEncriptCaptcha() { } @Override public void run() { _imageAntiBotClient.clear(); for (Entry<Integer, antiBotData> entrySet : _imageAntiBotOri.entrySet()) { entrySet.getValue().getImagen(); _imageAntiBotClient.put(entrySet.getKey(), new antiBotData(Rnd.get(50000, 800000), entrySet.getValue().getImagen())); } } } public int getAntiBotClientID(int pos) { int returnCoding = 0; for (Entry<Integer, antiBotData> entrySet : _imageAntiBotClient.entrySet()) { int numeroImage = entrySet.getKey().intValue(); if (pos == numeroImage) { antiBotData imgCoding = entrySet.getValue(); returnCoding = imgCoding.getCodificacion(); } if (pos > 9) { _log.log(Level.SEVERE, "error in getAntiBotClientID...number dont exist"); } } return returnCoding; } public static class antiBotData { int _codificacion; byte[] _data; public antiBotData(int codificacion, byte[] data) { _codificacion = codificacion; _data = data; } public int getCodificacion() { return _codificacion; } public byte[] getImagen() { return _data; } } private static byte[] ConverterImgBytes(File imagen) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; try (FileInputStream fis = new FileInputStream(imagen)) { for (int readNum; (readNum = fis.read(buffer)) != -1;) { bos.write(buffer, 0, readNum); } } catch (IOException e) { _log.log(Level.SEVERE, "Error when converter image to byte[]"); } return bos.toByteArray(); } public static AntiBotTable getInstance() { return SingletonHolder._instance; } private static class SingletonHolder { protected static final AntiBotTable _instance = new AntiBotTable(); }}
L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java private String _code = ""; private int _attempt = 0; private int _mobs_dead = 0; public static ScheduledFuture<?> _antiBotTask; // AntiBoot public void antibot() { increaseMobsDead(); if (getMobsDead() >= Config.ANTIBOT_KILL_MOBS) { resetMobsDead(); _antiBotTask = ThreadPool.schedule(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000); } } private static void stopAntiBotTask() { if (_antiBotTask != null) { _antiBotTask.cancel(false); _antiBotTask = null; } } private class startAntiBotTask implements Runnable { public startAntiBotTask() { setParalyzed(true); setInvul(true); startAbnormalEffect(Creature.ABNORMAL_EFFECT_FLOATING_ROOT); sendPacket(new ExShowScreenMessage("[AntiBot]: You have " + Config.ANTIBOT_TIME_VOTE + " to confirm the Captcha!", 10000)); getActingPlayer().sendPacket(new CreatureSay(0, ChatType.CRITICAL_ANNOUNCE, "[AntiBot]:", "You have " + Config.ANTIBOT_TIME_VOTE + " to confirm the Catpcha.")); showHtml_Start(); } @Override public void run() { if (!isInJail()) { sendPacket(new CreatureSay(0, ChatType.HERO_VOICE, "[AntiBot]:", "Your time limit has elapsed.")); increaseAttempt(); if (getAttempt() >= 3) { setParalyzed(false); setInvul(false); startAbnormalEffect(Creature.ABNORMAL_EFFECT_FLOATING_ROOT); getActingPlayer().setPunishLevel(PlayerInstance.PunishLevel.JAIL, Config.ANTIBOT_TIME_JAIL); getActingPlayer().sendPacket(new CreatureSay(0, ChatType.HERO_VOICE, "[AntiBot]:", "Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes.")); LOGGER.warning("[AntiBot]: Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes."); } else { _antiBotTask = ThreadPool.schedule(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000); } } } } public String num2img(int numero) { String num = Integer.toString(numero); char[] digitos = num.toCharArray(); String tmp = ""; for (int x = 0; x < num.length(); x++) { int dig = Integer.parseInt(Character.toString(digitos[x])); final int it = AntiBotTable.getInstance().getAntiBotClientID(dig); AntiBotTable.getInstance().sendImage(this, it); tmp += "<img src=Crest.crest_" + Config.SERVER_ID + "_" + it + " width=38 height=33 align=left>"; } return tmp; } public void showHtml_Start() { NpcHtmlMessage html = new NpcHtmlMessage(0); html.setFile("data/html/antiBot/start.htm"); html.replace("%playerName%", getName()); html.replace("%attemp%", String.valueOf(3 - getAttempt())); int maxR = 3; String random = new String(); for (int x = 0; x < maxR; x++) { random += Integer.toString(Rnd.get(0, 9)); } html.replace("%code1%", num2img(Integer.parseInt(random))); this.sendPacket(html); setCode(String.valueOf(Integer.parseInt(random))); } public void showHtml_End() { NpcHtmlMessage html = new NpcHtmlMessage(0); html.setFile("data/html/antiBot/end.htm"); html.replace("%playerName%", getName()); this.sendPacket(html); } public void checkCode(String code) { if (code.equals(getCode())) { stopAntiBotTask(); resetAttempt(); sendPacket(new CreatureSay(0, ChatType.HERO_VOICE, "[AntiBot]:", "Congratulations, has passed control.")); setParalyzed(false); setInvul(false); stopAbnormalEffect(Creature.ABNORMAL_EFFECT_FLOATING_ROOT); } else { stopAntiBotTask(); increaseAttempt(); _antiBotTask = ThreadPool.schedule(new startAntiBotTask(), Config.ANTIBOT_TIME_VOTE * 1000); } if (getAttempt() >= 3) { stopAntiBotTask(); resetAttempt(); setParalyzed(false); setInvul(false); startAbnormalEffect(Creature.ABNORMAL_EFFECT_FLOATING_ROOT); setPunishLevel(PunishLevel.JAIL, Config.ANTIBOT_TIME_JAIL); sendPacket(new CreatureSay(0, ChatType.HERO_VOICE, "[AntiBot]:", "Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes.")); LOGGER.warning("[AntiBot]: Character " + getName() + " jailed for " + Config.ANTIBOT_TIME_JAIL + " minutes."); } } private int getMobsDead() { return _mobs_dead; } private void increaseMobsDead() { _mobs_dead++; } private void resetMobsDead() { _mobs_dead = 0; } private void setCode(String code) { _code = code; } private String getCode() { return _code; } public void increaseAttempt() { _attempt += 1; } public int getAttempt() { return _attempt; } public void resetAttempt() { _attempt = 0; }
L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java else if (_command.startsWith("antibot")) { StringTokenizer st = new StringTokenizer(_command); st.nextToken(); if (st.hasMoreTokens()) { player.checkCode(st.nextToken()); return; } player.checkCode("Fail"); }
L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Attackable.java // AntiBot if (Config.ANTIBOT_ENABLE && (killer != null) && (killer instanceof PlayerInstance) && (killer.getLevel() >= Config.ANTIBOT_MIN_LEVEL)) { killer.getActingPlayer().antibot(); }
L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/serverpackets/PledgeImage.java/* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */package org.l2jmobius.gameserver.network.serverpackets;import org.l2jmobius.commons.network.PacketWriter;import org.l2jmobius.gameserver.network.OutgoingPackets;public class PledgeImage implements IClientOutgoingPacket{ private final int _crestId; private final byte[] _data; public PledgeImage(int crestId, byte[] data) { _crestId = crestId; _data = data; } @Override public boolean write(PacketWriter packet) { OutgoingPackets.PLEDGE_IMAGE.writeId(packet); packet.writeD(_crestId); if (_data != null) { packet.writeD(_data.length); packet.writeB(_data); } else { packet.writeD(0); } return true; }}
L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/network/OutgoingPackets.java PLEDGE_IMAGE(0x6C),
L2J_Mobius_C6_Interlude/dist/game/config/custom/Other.ini#=============================================================# AntiBot #=============================================================# AntiBot. True to enable, False to disable.AntiBotEnable = True# Time the user will be in jail in minutes.AntiBotTimeJail = 10# Time that the user will have to control captcha in seconds.AntiBotTimeVote = 40# Dead mobs needed for captcha.AntiBotKillMobs = 100# Level min need for captcha.AntiBotMinLevel = 1
L2jmobius_interlude/datahttps://www.mediafire.com/file/fet4u1w9qyov8oh/antibot.7z/filehttps://www.mediafire.com/file/lnkzvpewjpctokl/images.7z/file
Better add a diff patch.