-
Notifications
You must be signed in to change notification settings - Fork 4
/
DNS.cs
54 lines (53 loc) · 2.24 KB
/
DNS.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
using System;
using System.Collections.Generic;
namespace Reecon
{
class DNS // Port 53
{
public static (string, string) GetInfo(string ip, int port)
{
// https://raymii.org/s/tutorials/Get_DNS_server_version_and_hide_it_in_BIND.html
string dnsInfo = "";
List<string> outputLines = General.GetProcessOutput("nslookup", $"-type=txt -class=chaos version.bind {ip}");
if (outputLines.Count > 0 && outputLines[0].Trim() == "*** Request to UnKnown timed-out")
{
dnsInfo = "- No Info Available";
}
else
{
bool hasServer = false;
foreach (string line in outputLines)
{
if (line.StartsWith("Server:"))
{
dnsInfo += $"- {line}" + Environment.NewLine;
hasServer = true;
}
else if (line.StartsWith("Address:"))
{
dnsInfo += $"- {line}" + Environment.NewLine;
}
else if (
// Terrible formatting, I know
!(line.Trim().Equals("DNS request timed out."))
&& !(line.Trim().Contains("timeout was") && line.Trim().Contains("seconds"))
&& !(line.StartsWith("*** Request to") && line.Trim().EndsWith("timed-out"))
)
{
dnsInfo += $"- {line}" + Environment.NewLine;
}
}
if (hasServer)
{
dnsInfo += $"- Try the following" + Environment.NewLine
+ "-- nslookup" + Environment.NewLine
+ "-- server 1.2.3.4 (Address from above)" + Environment.NewLine
+ "-- set type=any" + Environment.NewLine
+ "-- ls -d bla.com (Domain from above)" + Environment.NewLine;
}
}
dnsInfo = dnsInfo.Trim(Environment.NewLine.ToCharArray());
return ("DNS", dnsInfo);
}
}
}