Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (52 loc) · 2.3 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (52 loc) · 2.3 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
using System.Net;
using IllinoisSiteScanner.PlatformCheck;
//TODO Change this to point to your location
var rootPath = "C:\\Users\\jonker\\source\\repos\\IllinoisSiteScanner\\";
var path = rootPath + "sitelist.txt";
var pathOutput = rootPath + "sitelist-output.txt";
var lines = File.ReadAllLines(path);
var heading = "URL\tResolved URL\tHost\tIP\tHost Information\tCMS Information\tServer Hosting\tToolkit2\tToolkit3\tH1\tV3 Site Name\tPrimary Site";
File.WriteAllText(pathOutput, heading + Environment.NewLine);
foreach (var url in lines) {
try {
using var httpClient = new HttpClient();
var response = await httpClient.SendAsync(new HttpRequestMessage {
Version = HttpVersion.Version10,
RequestUri = new Uri(url),
Method = HttpMethod.Get
});
_ = response.EnsureSuccessStatusCode();
var html = await response.Content.ReadAsStringAsync();
var myUri = new Uri(url);
var ip = Dns.GetHostAddresses(response?.RequestMessage?.RequestUri?.Host ?? myUri.Host)[0];
var line = url;
line += "\t";
line += response?.RequestMessage?.RequestUri?.AbsoluteUri ?? myUri.AbsoluteUri;
line += "\t";
line += response?.RequestMessage?.RequestUri?.Host ?? myUri.Host;
line += "\t";
line += ip;
line += "\t";
line += IpInformation.Check(ip.ToString(), response?.RequestMessage?.RequestUri?.Host ?? myUri.Host);
line += "\t";
line += CmsInformation.Check(html, ip.ToString());
line += "\t";
line += ServerInformation.Check(response?.Headers?.Server?.ToString() ?? "");
line += "\t";
var (oldToolkit, newToolkit) = ToolkitInformation.Check(html);
line += oldToolkit;
line += "\t";
line += newToolkit;
line += "\t";
line += HeaderInformation.Check(html);
line += "\t";
line += PrimarySiteInformation.CheckSite(html);
line += "\t";
line += PrimarySiteInformation.Check(html);
File.AppendAllText(pathOutput, line + Environment.NewLine);
Console.WriteLine(url);
} catch (Exception e) {
File.AppendAllText(pathOutput, "error with " + url + ".\t" + e.Message + Environment.NewLine);
Console.WriteLine("error with " + url + ". " + e.Message);
}
}