-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
310 lines (289 loc) · 10.7 KB
/
Program.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using static Reecon.General;
namespace Reecon
{
class Program
{
static string target = "";
static readonly List<int> portList = new();
static readonly List<Thread> threadList = new();
static readonly List<string> postScanList = new();
static void Main(string[] args)
{
DateTime startDate = DateTime.Now;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Reecon - Version 0.34f ( https://github.com/Reelix/Reecon )");
Console.ForegroundColor = ConsoleColor.White;
if (args.Length == 0)
{
General.ShowHelp();
Console.ResetColor();
return;
}
// Check if it's anything custom
if (args.Contains("-h") || args.Contains("--help") || args.Contains("--version") || args.Contains("-v") || args.Contains("-V") || args.Contains("--v")) // Any others? :p
{
General.ShowHelp();
Console.ResetColor();
return;
}
else if (args.Contains("-ip") || args.Contains("--ip"))
{
General.PrintIPList();
Console.ResetColor();
return;
}
else if (args.Contains("-ldap") || args.Contains("--ldap"))
{
string reeconFileName = typeof(Program).Assembly.GetName().Name;
if (args.Count() != 5)
{
Console.WriteLine($"LDAP Auth Enum:\t{reeconFileName} -ldap IP port validUsername validPassword");
}
string ip = args[1];
string port = args[2];
if (!int.TryParse(port, out _))
{
Console.WriteLine($"Invalid Port: {port}");
Console.WriteLine($"LDAP Auth Enum:\t{reeconFileName} -ldap IP port validUsername validPassword");
Console.ResetColor();
return;
}
string username = args[3];
string password = args[4];
string accountInfo = LDAP.GetAccountInfo(ip, int.Parse(port), username, password);
Console.WriteLine(accountInfo);
return;
}
else if (args.Contains("-lfi") || args.Contains("--lfi"))
{
LFI.Scan(args);
Console.ResetColor();
return;
}
else if (args.Contains("-osint") || args.Contains("--osint"))
{
OSINT.GetInfo(args);
Console.ResetColor();
return;
}
else if (args.Contains("-pwn") || args.Contains("--pwn"))
{
Pwn.Scan(args);
Console.ResetColor();
return;
}
else if (args.Contains("-search"))
{
Nist.Search(args);
Console.ResetColor();
return;
}
else if (args.Contains("-searchsploit") || args.Contains("--searchsploit"))
{
Searchsploit.Search(args);
Console.ResetColor();
return;
}
else if (args.Contains("-shell") || args.Contains("--shell"))
{
Shell.GetInfo(args);
Console.ResetColor();
return;
}
else if (args.Contains("-smb-brute"))
{
SMB.SMBBrute(args);
Console.ResetColor();
return;
}
else if (args.Contains("-smb-eternalblue"))
{
string ip = args[1];
Console.WriteLine($"Checking {ip}...");
SMB_MS17_010.IsVulnerable(ip, true);
Console.WriteLine("Check Complete");
}
else if (args.Contains("-winrm-brute"))
{
WinRM.WinRMBrute(args);
Console.ResetColor();
return;
}
else if (args.Contains("-web") || args.Contains("--web"))
{
Web.GetInfo(args);
Console.ResetColor();
return;
}
// Check if you should check if the target is up
bool mustPing = true;
if (args.Contains("-noping") || args.Contains("--noping"))
{
mustPing = false;
args = args.Where(x => !x.Contains("-noping")).ToArray();
}
// A common typo
if (args.Contains("-nopign"))
{
Console.WriteLine("You probably typo'd -noping");
Console.ResetColor();
return;
}
// Everything below here has a maximum of 2 args
if (args.Length > 2)
{
Console.WriteLine("You probably typo'd something");
Console.ResetColor();
return;
}
// Target
if (args[0].EndsWith(".nmap"))
{
Console.WriteLine("Parsing file...");
string fileName = args[0];
var (Target, Ports) = Nmap.ParseFile(fileName);
target = Target;
if (!Ports.Any())
{
Console.WriteLine("Error: Empty file - Bug Reelix!");
}
else
{
portList.AddRange(Ports);
}
}
else
{
target = args[0];
}
if (target.StartsWith("http"))
{
Console.WriteLine("Cannot do a standard scan on a URL - Try a -web scan");
Console.ResetColor();
return;
}
// Custom ports
if (args.Length == 2)
{
string portArg = args[1];
try
{
portList.AddRange(portArg.Split(',').ToList().Select(x => int.Parse(x)));
}
catch
{
// Not a list of ports - Probably a name
}
}
// First check if it's actually up
if (mustPing)
{
Console.WriteLine("Checking if target is online...");
bool? isHostOnline = General.IsUp(target);
General.ClearPreviousConsoleLine();
if (isHostOnline == null)
{
Console.WriteLine($"Invalid target: {target}");
return;
}
if (!isHostOnline.Value)
{
Console.WriteLine($"Host {target} is not responding to pings :(");
Console.WriteLine("If you are sure it's up and are specifying ports, you can use -noping");
return;
}
}
if (portList.Count == 0)
{
// Scan the target
string fileName = Nmap.DefaultScan(args, mustPing);
fileName += ".nmap";
// Parse the ports
var (Target, Ports) = Nmap.ParseFile(fileName);
target = Target;
portList.AddRange(Ports);
}
// Ports have been defined (Either nmap or custom)
if (portList.Count != 0)
{
ScanPorts(portList);
}
else
{
// All parsing and scans done - But still no ports
Console.WriteLine("No open ports found to scan :<");
return;
}
// All done - Output stats
DateTime endDate = DateTime.Now;
TimeSpan t = endDate - startDate;
Console.WriteLine("Done in " + string.Format("{0:0.00}s", t.TotalSeconds) + " - Have fun :)");
Console.ResetColor();
}
static void LocalDebug(string ip, int port)
{
Console.WriteLine("-- Debug Start --");
target = ip;
PortInfo.LoadPortInfo();
ScanPort(port);
Console.WriteLine("-- Debug Ended --");
Console.ReadLine();
Environment.Exit(0);
}
static void ScanPorts(List<int> portList)
{
PortInfo.LoadPortInfo();
Console.Write("Scanning: " + target);
Console.Write(" (Port");
if (portList.Count > 1)
{
Console.Write("s");
}
Console.WriteLine(": " + string.Join(",", portList) + ")");
// Multi-threaded scan
foreach (int port in portList)
{
Thread myThread = new(() => ScanPort(port));
threadList.Add(myThread);
myThread.Start();
}
// Wait for the scans to finish
foreach (Thread theThread in threadList)
{
theThread.Join();
}
// And clear the thread list
threadList.Clear();
// Everything done - Now for some helpful info!
Console.WriteLine("Finished - Some things you probably want to do: ");
if (portList.Count == 0)
{
// Something broke, or there are only UDP Ports :|
Console.WriteLine($"- nmap -sC -sV -p- {target} -oN nmap.txt");
Console.WriteLine($"- nmap -sU {target} -oN nmap-UDP.txt");
}
else
{
postScanList.Add($"- Nmap Script+Version Scan: sudo nmap -sC -sV -p{string.Join(",", portList)} {target} -oN nmap.txt" + Environment.NewLine);
postScanList.Add($"- Nmap UDP Scan: sudo nmap -sU {target} (-F for top 100)" + Environment.NewLine);
foreach (string item in postScanList)
{
// They already have newlines in them
Console.Write(item);
}
}
}
static void ScanPort(int port)
{
string toDo = PortInfo.ScanPort(target, port);
if (toDo != "")
{
postScanList.Add(toDo);
}
}
}
}