-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
70 lines (60 loc) · 2.1 KB
/
Program.cs
File metadata and controls
70 lines (60 loc) · 2.1 KB
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace PasswordCrackingClient
{
class Program
{
private const String Server = "172.28.172.2"; //"localhost";
private const Int32 Port = 13000;
private static string passwords = "Empty";
static void Main(string[] args)
{
Thread t1 = new Thread(SingleRequest);
Thread t2 = new Thread(SingleRequest);
Thread t3 = new Thread(SingleRequest);
Thread t4 = new Thread(SingleRequest);
t1.Start();
t2.Start();
t3.Start();
t4.Start();
}
private static void SingleRequest()
{
Console.WriteLine("PasswordRequest started...");
// https://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx
using (TcpClient client = new TcpClient(Server, Port))
{
Console.WriteLine("Found the connection!!!");
NetworkStream stream = client.GetStream();
StreamWriter writer = new StreamWriter(stream);
string request = "GET";
writer.WriteLine(request);
writer.Flush();
StreamReader reader = new StreamReader(stream);
String response = reader.ReadLine();
Cracking cracker = new Cracking();
passwords = cracker.RunCracking(response);
if (passwords.Length > 20)
{
ReturnResult();
}
}
}
private static void ReturnResult()
{
using (TcpClient client = new TcpClient(Server, Port))
{
NetworkStream stream = client.GetStream();
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine("RES " +passwords);
writer.Flush();
}
}
}
}