-
Notifications
You must be signed in to change notification settings - Fork 4
/
HTTP.cs
98 lines (95 loc) · 3.86 KB
/
HTTP.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
using System;
namespace Reecon
{
class HTTP //80 / 8080 / 8000 (Also used for 443, HTTPS)
{
public static (string, string) GetInfo(string target, int port)
{
string result = GetInfoMain(target, port, false);
if (result.Contains("Page Text: Client sent an HTTP request to an HTTPS server."))
{
// Whoops - HTTPS Server!
// TODO: This still returns as HTTP instead of HTTPS though - Need to find a way to change it...
Console.WriteLine("Whoops - HTTPS Server - Not HTTP - Bug Reelix to update this in General.MultiBannerGrab!");
result = GetInfoMain(target, port, true);
}
return ("HTTP", result);
}
public static string GetInfoMain(string target, int port, bool isHTTPS)
{
try
{
string url = "";
if (isHTTPS)
{
if (port == 443)
{
url = $"https://{target}/";
}
else
{
url = $"https://{target}:{port}/";
}
}
else
{
if (port == 80)
{
url = $"http://{target}/";
}
else
{
url = $"http://{target}:{port}/";
}
}
var httpInfo = Web.GetHTTPInfo(url);
if (httpInfo.AdditionalInfo == "Timeout")
{
return "- Timeout";
}
else if (httpInfo.AdditionalInfo == "WeirdSSL")
{
return "- It's SSL, but can't connect with https for some reason :(";
}
else if (httpInfo.AdditionalInfo == "Name or service not known")
{
return $"- The url {url} does not exist - Maybe fix your /etc/hosts file?";
}
else if (httpInfo == (0, null, null, null, null, null, null, null))
{
return "";
}
string portData = Web.ParseHTTPInfo(httpInfo.StatusCode, httpInfo.PageTitle, httpInfo.PageText, httpInfo.DNS, httpInfo.Headers, httpInfo.SSLCert, httpInfo.URL);
// The final Environment.NewLine is stripped from portData, so we need to re-add it
if (httpInfo.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
portData += Environment.NewLine + "- Skipping file enumeration due to unauthorized result" + Environment.NewLine;
portData += $"-- hydra -L users.txt -P passwords.txt -s {port} -f {target} http-get /" + Environment.NewLine;
}
else
{
string commonFiles = Web.FindCommonFiles(url);
if (commonFiles != "")
{
portData += Environment.NewLine + commonFiles;
}
}
string baseLFI = Web.TestBaseLFI(target, port);
if (baseLFI != "")
{
portData += Environment.NewLine + baseLFI + Environment.NewLine;
}
if (portData == "")
{
portData = "- No Info Found";
}
return portData.TrimEnd(Environment.NewLine.ToCharArray());
}
catch (Exception ex)
{
Console.WriteLine("Critical HTTP.GetInfo Error: " + ex.Message);
return "";
}
}
}
}