Created
March 26, 2018 06:46
-
-
Save jymcheong/5748e81a02dfeaeffc7e9d76c8239ac6 to your computer and use it in GitHub Desktop.
C# to resolve list of domains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace DGAtester | |
{ | |
class Program | |
{ | |
public static void DoGetHostEntry(string hostname) | |
{ | |
IPHostEntry host; | |
ServicePointManager.DnsRefreshTimeout = 0; | |
host = Dns.GetHostEntry(hostname); | |
Console.WriteLine("GetHostEntry({0}) returns:", hostname); | |
foreach (IPAddress ip in host.AddressList) | |
{ | |
Console.WriteLine(" {0}", ip); | |
} | |
} | |
static void Main(string[] args) | |
{ | |
if (args.Length == 0) | |
{ | |
Console.WriteLine("Please enter text file containing DGA domains."); | |
return; | |
} | |
try | |
{ | |
foreach (string line in File.ReadLines(args[0])) | |
{ | |
Console.WriteLine("Rsolving {0}..", line); | |
try | |
{ | |
DoGetHostEntry(line); | |
} | |
catch(Exception) | |
{ | |
} | |
} | |
} | |
catch(Exception e) | |
{ | |
Console.WriteLine("Oops.. " + e.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment