Updated
This commit is contained in:
parent
b74c937d62
commit
04432a89f6
|
@ -55,6 +55,9 @@
|
||||||
this.txtResolveHost = new System.Windows.Forms.TextBox();
|
this.txtResolveHost = new System.Windows.Forms.TextBox();
|
||||||
this.btnResolveIP = new System.Windows.Forms.Button();
|
this.btnResolveIP = new System.Windows.Forms.Button();
|
||||||
this.btnResolveHost = new System.Windows.Forms.Button();
|
this.btnResolveHost = new System.Windows.Forms.Button();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// ResultView
|
// ResultView
|
||||||
|
@ -308,6 +311,27 @@
|
||||||
this.btnResolveHost.UseVisualStyleBackColor = true;
|
this.btnResolveHost.UseVisualStyleBackColor = true;
|
||||||
this.btnResolveHost.Click += new System.EventHandler(this.btnResolveHost_Click);
|
this.btnResolveHost.Click += new System.EventHandler(this.btnResolveHost_Click);
|
||||||
//
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(675, 223);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(201, 32);
|
||||||
|
this.label3.TabIndex = 32;
|
||||||
|
this.label3.Text = "Total domains:";
|
||||||
|
//
|
||||||
|
// numericUpDown1
|
||||||
|
//
|
||||||
|
this.numericUpDown1.Location = new System.Drawing.Point(913, 223);
|
||||||
|
this.numericUpDown1.Maximum = new decimal(new int[] {
|
||||||
|
10000000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.numericUpDown1.Name = "numericUpDown1";
|
||||||
|
this.numericUpDown1.Size = new System.Drawing.Size(120, 38);
|
||||||
|
this.numericUpDown1.TabIndex = 33;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(240F, 240F);
|
||||||
|
@ -315,6 +339,8 @@
|
||||||
this.AutoSize = true;
|
this.AutoSize = true;
|
||||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||||
this.ClientSize = new System.Drawing.Size(2517, 1693);
|
this.ClientSize = new System.Drawing.Size(2517, 1693);
|
||||||
|
this.Controls.Add(this.numericUpDown1);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.btnResolveHost);
|
this.Controls.Add(this.btnResolveHost);
|
||||||
this.Controls.Add(this.btnResolveIP);
|
this.Controls.Add(this.btnResolveIP);
|
||||||
this.Controls.Add(this.txtResolveHost);
|
this.Controls.Add(this.txtResolveHost);
|
||||||
|
@ -343,6 +369,7 @@
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "EonaCat.DnsTester";
|
this.Text = "EonaCat.DnsTester";
|
||||||
this.Load += new System.EventHandler(this.TesterUI_Load);
|
this.Load += new System.EventHandler(this.TesterUI_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -376,6 +403,8 @@
|
||||||
private System.Windows.Forms.TextBox txtResolveHost;
|
private System.Windows.Forms.TextBox txtResolveHost;
|
||||||
private System.Windows.Forms.Button btnResolveIP;
|
private System.Windows.Forms.Button btnResolveIP;
|
||||||
private System.Windows.Forms.Button btnResolveHost;
|
private System.Windows.Forms.Button btnResolveHost;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.NumericUpDown numericUpDown1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -28,8 +29,7 @@ namespace EonaCat.DnsTester
|
||||||
private void RunTest_Click(object sender, EventArgs e)
|
private void RunTest_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
string[] CleanNames = new string[500];
|
List<string> CleanNames = new List<string>();
|
||||||
int CleanNamesCount = 0;
|
|
||||||
|
|
||||||
if (this.UseCustomDnsServers)
|
if (this.UseCustomDnsServers)
|
||||||
{
|
{
|
||||||
|
@ -61,9 +61,9 @@ namespace EonaCat.DnsTester
|
||||||
ResultView.Update();
|
ResultView.Update();
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
GetWebAddresses(ref CleanNames, ref CleanNamesCount);
|
GetWebAddresses(ref CleanNames, (int)numericUpDown1.Value);
|
||||||
|
|
||||||
for (i = 0; i < CleanNamesCount; i++)
|
for (i = 0; i < CleanNames.Count; i++)
|
||||||
{
|
{
|
||||||
ListViewItem listURL = new ListViewItem(CleanNames[i]);
|
ListViewItem listURL = new ListViewItem(CleanNames[i]);
|
||||||
listURL.SubItems.Add(" ");
|
listURL.SubItems.Add(" ");
|
||||||
|
@ -87,7 +87,7 @@ namespace EonaCat.DnsTester
|
||||||
}
|
}
|
||||||
|
|
||||||
IsRunning = true;
|
IsRunning = true;
|
||||||
CheckDNS(CleanNames, CleanNamesCount, DNS1, DNS2);
|
CheckDNS(CleanNames.ToArray(), CleanNames.Count, DNS1, DNS2);
|
||||||
IsRunning = false;
|
IsRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ namespace EonaCat.DnsTester
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void GetWebAddresses(ref string[] CleanNames, ref int CleanNamesCount)
|
private void GetWebAddresses(ref List<string> CleanNames, int totalUrls)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
byte[] random = new Byte[256];
|
byte[] random = new Byte[256];
|
||||||
|
@ -173,74 +173,116 @@ namespace EonaCat.DnsTester
|
||||||
if (Letters.Length == 3) break;
|
if (Letters.Length == 3) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use Google to get random addresses for DNS testing
|
KeyValuePair<string, string> searchEngine = new KeyValuePair<string, string>();
|
||||||
|
Random rand = new Random();
|
||||||
|
|
||||||
// Initialize the WebRequest.
|
// Create a list of search engine URLs to query
|
||||||
|
Dictionary<string, string> searchEngineUrls = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "DuckDuckGo", "https://duckduckgo.com/html/?q=" },
|
||||||
|
{ "Yahoo", "https://search.yahoo.com/search?p=" },
|
||||||
|
{ "Bing", "https://www.bing.com/search?q=" },
|
||||||
|
{ "Google", "https://www.google.com/search?q=" },
|
||||||
|
{ "Ask", "https://www.ask.com/web?q=" },
|
||||||
|
{ "AOL", "https://www.aol.com/search?q=" },
|
||||||
|
{ "WolframAlpha", "https://www.wolframalpha.com/input/?i=" },
|
||||||
|
{ "StartPage", "https://www.startpage.com/do/dsearch?query=" },
|
||||||
|
{ "Yandex", "https://www.yandex.com/search/?text=" },
|
||||||
|
{ "Qwant", "https://www.qwant.com/?q=" }
|
||||||
|
};
|
||||||
|
|
||||||
StatusBoxPrint("Getting Google request");
|
try
|
||||||
try
|
{
|
||||||
|
while (CleanNames.Count < totalUrls)
|
||||||
|
{
|
||||||
|
int index = rand.Next(searchEngineUrls.Count);
|
||||||
|
searchEngine = searchEngineUrls.ElementAt(index);
|
||||||
|
|
||||||
|
WebRequest Request = WebRequest.Create(searchEngine.Value + Letters); //Letters);
|
||||||
|
WebResponse Response = Request.GetResponse();
|
||||||
|
Application.DoEvents();
|
||||||
|
|
||||||
|
// Get the response stream.
|
||||||
|
Stream Stream = Response.GetResponseStream();
|
||||||
|
StatusBoxPrint(searchEngine.Key + " response received");
|
||||||
|
|
||||||
|
StreamReader StreamReader = new StreamReader(Stream, Encoding.ASCII);
|
||||||
|
string ResponseString = StreamReader.ReadToEnd();
|
||||||
|
|
||||||
|
// Close the response stream and response to free resources.
|
||||||
|
Stream.Close();
|
||||||
|
Response.Close();
|
||||||
|
Application.DoEvents();
|
||||||
|
|
||||||
|
// find all .xxx.com addresses
|
||||||
|
MatchCollection HostNames;
|
||||||
|
string[] Names = new string[totalUrls + 1000];
|
||||||
|
|
||||||
|
// Create a new Regex object and define the regular expression.
|
||||||
|
Regex Dotcom = new Regex("[.]([A-Za-z]*)[.]com");
|
||||||
|
|
||||||
|
|
||||||
|
// Use the Matches method to find all matches in the input string.
|
||||||
|
HostNames = Dotcom.Matches(ResponseString);
|
||||||
|
|
||||||
|
Application.DoEvents();
|
||||||
|
|
||||||
|
// Loop through the match collection to retrieve all
|
||||||
|
// matches and delete the leading "."
|
||||||
|
for (i = 0; i < HostNames.Count; i++)
|
||||||
|
{
|
||||||
|
Names[i] = HostNames[i].Value.Remove(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// eliminate its own search engine names and repeated entries
|
||||||
|
for (i = 0; i < HostNames.Count - 1; i++)
|
||||||
|
{
|
||||||
|
if (Names[i] == searchEngine.Key.ToLower() + ".com") Names[i] = "";
|
||||||
|
for (j = i + 1; j < HostNames.Count; j++)
|
||||||
|
{
|
||||||
|
if (Names[i] == Names[j]) Names[j] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Shuffle(Names);
|
||||||
|
|
||||||
|
// Add the names to the list
|
||||||
|
for (i = 0; i < HostNames.Count; i++)
|
||||||
|
{
|
||||||
|
if (CleanNames.Count >= totalUrls)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Names[i]) && !CleanNames.Contains(Names[i]))
|
||||||
|
{
|
||||||
|
CleanNames.Add(Names[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StatusBoxPrint(CleanNames.Count + " Random URL's found");
|
||||||
|
}
|
||||||
|
catch(Exception exception)
|
||||||
{
|
{
|
||||||
WebRequest GoogleRequest = WebRequest.Create("http://www.google.com/search?num=100&q=" + Letters); //Letters);
|
StatusBoxPrint(searchEngine.Key + ": " ?? string.Empty + exception.Message);
|
||||||
WebResponse GoogleResponse = GoogleRequest.GetResponse();
|
|
||||||
Application.DoEvents();
|
|
||||||
// Get the response stream.
|
|
||||||
Stream GoogleStream = GoogleResponse.GetResponseStream();
|
|
||||||
StatusBoxPrint("Google response received");
|
|
||||||
// Use a StreamReader to read the entire response.
|
|
||||||
|
|
||||||
StreamReader GoogleReader = new StreamReader(GoogleStream, Encoding.ASCII);
|
|
||||||
string GoogleString = GoogleReader.ReadToEnd();
|
|
||||||
// Close the response stream and response to free resources.
|
|
||||||
GoogleStream.Close();
|
|
||||||
GoogleResponse.Close();
|
|
||||||
Application.DoEvents();
|
|
||||||
|
|
||||||
// find all .xxx.com addresses
|
|
||||||
MatchCollection HostNames;
|
|
||||||
string[] Names = new string[1000];
|
|
||||||
// Create a new Regex object and define the regular expression.
|
|
||||||
Regex Dotcom = new Regex("[.]([A-Za-z]*)[.]com");
|
|
||||||
// Use the Matches method to find all matches in the input string.
|
|
||||||
HostNames = Dotcom.Matches(GoogleString);
|
|
||||||
|
|
||||||
Application.DoEvents();
|
|
||||||
// Loop through the match collection to retrieve all
|
|
||||||
// matches and delete the leading "."
|
|
||||||
for (i = 0; i < HostNames.Count; i++)
|
|
||||||
{
|
|
||||||
Names[i] = HostNames[i].Value.Remove(0, 1);
|
|
||||||
}
|
|
||||||
// eliminate google.com and repeated entries
|
|
||||||
for (i = 0; i < HostNames.Count - 1; i++)
|
|
||||||
{
|
|
||||||
if (Names[i] == "google.com") Names[i] = "";
|
|
||||||
for (j = i + 1; j < HostNames.Count; j++)
|
|
||||||
{
|
|
||||||
if (Names[i] == Names[j]) Names[j] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// count list and compact
|
|
||||||
j = 0;
|
|
||||||
for (i = 0; i < HostNames.Count; i++)
|
|
||||||
{
|
|
||||||
if (Names[i] != "")
|
|
||||||
{
|
|
||||||
CleanNames[j] = Names[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CleanNamesCount = j;
|
|
||||||
StatusBoxPrint(CleanNamesCount + " Random URL's found");
|
|
||||||
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
StatusBoxPrint("Host Google.com not found - are you connected ?");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public static void Shuffle<T>(T[] array)
|
||||||
|
{
|
||||||
|
Random rng = new Random();
|
||||||
|
int n = array.Length;
|
||||||
|
while (n > 1)
|
||||||
|
{
|
||||||
|
n--;
|
||||||
|
int k = rng.Next(n + 1);
|
||||||
|
T value = array[k];
|
||||||
|
array[k] = array[n];
|
||||||
|
array[n] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckDNS(string[] URLNames, int URLNamescount, string DNSAddress1, string DNSAddress2)
|
private void CheckDNS(string[] URLNames, int URLNamescount, string DNSAddress1, string DNSAddress2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const int IPPort = 53;
|
const int IPPort = 53;
|
||||||
|
@ -299,11 +341,13 @@ namespace EonaCat.DnsTester
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] Receivebytes = new byte[512];
|
byte[] Receivebytes = new byte[512];
|
||||||
|
int totalReceived = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// wait for a response up to timeout
|
// wait for a response up to timeout
|
||||||
more: DNSsocket.Receive(Receivebytes);
|
more:
|
||||||
|
DNSsocket.Receive(Receivebytes);
|
||||||
// make sure the message returned is ours
|
// make sure the message returned is ours
|
||||||
if (Receivebytes[0] == Sendbytes[0] && (Receivebytes[1] == 0x31) || (Receivebytes[1] == 0x32))
|
if (Receivebytes[0] == Sendbytes[0] && (Receivebytes[1] == 0x31) || (Receivebytes[1] == 0x32))
|
||||||
{
|
{
|
||||||
|
@ -378,11 +422,17 @@ namespace EonaCat.DnsTester
|
||||||
ResultView.Items[i].ForeColor = System.Drawing.Color.Black;
|
ResultView.Items[i].ForeColor = System.Drawing.Color.Black;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
totalReceived++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto more;
|
|
||||||
}
|
if (totalReceived < URLNamescount)
|
||||||
|
{
|
||||||
|
goto more;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (SocketException e)
|
catch (SocketException e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue