-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
146 lines (130 loc) · 3.75 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
using System.CommandLine;
using System.Net;
namespace WellKnowns
{
internal class Program
{
public static async Task<int> Main(string[] args)
{
var cmd = CreateCommand();
await cmd.InvokeAsync(args);
return 0;
}
private static RootCommand CreateCommand()
{
var cmd = new RootCommand("Scans a host for it's .well-known URIs (RFC 8615)");
var hostArgument = new Argument<Uri>("hostUri", "Host URI to be scanned");
cmd.AddArgument(hostArgument);
cmd.SetHandler(ExecuteAsync, hostArgument);
return cmd;
}
private static async Task ExecuteAsync(Uri host)
{
var httpClient = new HttpClient();
var foundEndpoints = new List<string>();
foreach (var wellKnown in _wellKnowns)
{
var response = await httpClient.GetAsync($"{host}/.well-known/{wellKnown}");
if (response.StatusCode != HttpStatusCode.NotFound)
{
foundEndpoints.Add(wellKnown);
}
}
if (!foundEndpoints.Any())
{
Console.WriteLine("[+] No endpoints found...");
return;
}
Console.WriteLine("[+] Found endpoints:");
foreach (var item in foundEndpoints)
{
Console.WriteLine($"\t{item}");
}
}
// https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml
private static readonly List<string> _wellKnowns = new List<string>
{
"acme-challenge",
"amphtml",
"appspecific",
"ashrae",
"assetlinks.json",
"brski",
"caldav",
"carddav",
"change-password",
"cmp",
"coap",
"core",
"csaf",
"csaf-aggregator",
"csvm",
"did.json",
"did-configuration.json",
"dnt",
"dnt-policy.txt",
"dots",
"ecips",
"edhoc",
"enterprise-network-security",
"enterprise-transport-security",
"est",
"genid",
"gpc.json",
"gs1resolver",
"hoba",
"host-meta",
"host-meta.json",
"hosting-provider",
"http-opportunistic",
"idp-proxy",
"jmap",
"keybase.txt",
"knx",
"looking-glass",
"masque",
"matrix",
"mercure",
"mta-sts.txt",
"mud",
"nfv-oauth-server-configuration",
"ni",
"nostr.json",
"oauth-authorization-server",
"ohttp-gateway",
"open-resource-discovery",
"openid-configuration",
"openorg",
"oslc",
"pki-validation",
"posh",
"private-token-issuer-directory",
"probing.txt",
"pvd",
"rd",
"related-website-set.json",
"reload-config",
"repute-template",
"resourcesync",
"sbom",
"security.txt",
"ssf-configuration",
"sshfp",
"stun-key",
"terraform.json",
"thread",
"time",
"timezone",
"tdmrep.json",
"tor-relay",
"tpcd",
"traffic-advice",
"trust.txt",
"uma2-configuration",
"void",
"webfinger",
"webweaver.json",
"wot"
};
}
}