-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
155 lines (129 loc) · 4.36 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
using WhoAreYou.Helpers;
using WhoAreYou.Menu;
using WhoAreYou.Modules;
using File = WhoAreYou.Helpers.File;
namespace WhoAreYou;
internal static class Program
{
private static async Task Main()
{
Console.Title = "WhoAreYou";
var exitProgram = false;
while (!exitProgram)
{
Console.Clear();
Interface.PrintLine("?", "Enter your choice:");
Interface.PrintLine("1", "LFI Menu");
Interface.PrintLine("2", "RFI Menu");
Interface.PrintLine("3", "XSS Menu");
Interface.PrintLine("4", "Scrape Links");
Interface.PrintLine("5", "TCP Listener");
Interface.PrintLine("0", "Exit");
var choice = Interface.ReadLine();
switch (choice)
{
case "1":
await LfiMenu.Menu();
ReturnToMenu();
break;
case "2":
await RfiMenu.Menu();
ReturnToMenu();
break;
case "3":
await XssMenu.Menu();
ReturnToMenu();
break;
case "4":
await ScrapeLinksMenu();
ReturnToMenu();
break;
case "5":
await ListenerMenu();
ReturnToMenu();
break;
case "0":
exitProgram = true;
Console.WriteLine("Exiting...");
break;
default:
Interface.PrintLine("!", "Invalid choice. Please try again.");
Interface.ReadLine();
break;
}
}
}
private static void ReturnToMenu()
{
Interface.PrintLine("!", "Press any key to return to the main menu...", false);
Console.ReadKey();
}
private static async Task ScrapeLinksMenu()
{
try
{
Console.Clear();
Interface.PrintLine("?", "Type URL");
var url = Interface.ReadLine();
if (string.IsNullOrEmpty(url))
{
Interface.PrintLine("~", "URL cannot be empty.");
return;
}
Interface.PrintLine("?", "Max Sites (0 for unlimited)");
var maxSites = Interface.ReadLine();
if (string.IsNullOrEmpty(url))
{
Interface.PrintLine("~", "Max Sites cannot be empty.");
return;
}
Interface.PrintLine("?", "Check Host (true/false)");
var checkHost = Interface.ReadLine();
if (string.IsNullOrEmpty(checkHost))
{
Interface.PrintLine("~", "Check Host cannot be empty.");
return;
}
Interface.PrintLine("?", "Check for Parameters (true/false)");
var checkForParameters = Interface.ReadLine();
if (string.IsNullOrEmpty(checkForParameters))
{
Interface.PrintLine("~", "Check for Parameters cannot be empty.");
return;
}
var filePath = File.GenerateFileName("Scraped Links");
var scraper = new Scraper(url, int.Parse(maxSites), bool.Parse(checkHost), bool.Parse(checkForParameters));
var links = await scraper.ScrapeLinksAsync();
foreach (var link in links)
{
Interface.PrintLine("+", link);
File.AppendToFile(filePath, link);
}
}
catch (Exception ex)
{
throw new Exception($"An error occurred while scraping links: {ex.Message}");
}
}
private static async Task ListenerMenu()
{
try
{
Console.Clear();
Interface.PrintLine("?", "Type Port");
var port = Interface.ReadLine();
if (string.IsNullOrEmpty(port))
{
Interface.PrintLine("~", "Port cannot be empty.");
return;
}
Console.Clear();
Listener listener = new(int.Parse(port));
await listener.Listen();
}
catch (Exception ex)
{
throw new Exception($"An error occurred while listening: {ex.Message}");
}
}
}