PDA

View Full Version : TraceRtGUI



Tatsumi
09-27-2015, 01:16 PM
Hey there!

The windows-utility "tracert" enables you to trace how you connect to a given address. It outputs the IPs you connect to during this connection-attempt.
Added a geolocation-parser that will try to resolve a given IP to a location.

https://i.gyazo.com/c23f93bbbed232317a67c3ddbadb4a3a.png

Notes:
1. This application executes "tracert -d <ip/hostname>" on your machine by creating a new instance of cmd.
2. If "Get geolocation of IPs" is checked, this application will connect to "https://www.iplocation.net/", submit the currently processed ip and parse the html-response

Here's the code of the geolocation-parser:

public const string REGEX_PATTERN = @"<td width='80'>(?<ip>(.*?))<\/td><td>(?<country>(.*?)) <img(.*?)<\/td><td>(?<region>(.*?))<\/td><td>(?<city>(.*?))<\/td>";
public const string GEOLOCATION_PROVIDER = "https://www.iplocation.net/";

private string[] GetGeolocation(string ip)
{
string[] returnVal = new string[3];
if (ip.StartsWith("192.168"))
{
returnVal[0] = returnVal[1] = returnVal[2] = "<lan>";
return returnVal;
}
InvokePostLogLine("geoloc", string.Format("Querying info of {0}", ip));
using (WebClient client = new WebClient())
{
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
try
{
NameValueCollection coll = new NameValueCollection();
coll.Add("query", ip);
coll.Add("submit", "Query");
byte[] data = client.UploadValues(GEOLOCATION_PROVIDER, "POST", coll);
string html = Encoding.ASCII.GetString(data);
string[] info = ExtractData(html, "EurekAPI");
if (info[0] == "-")
info = ExtractData(html, "DB-IP");
returnVal[0] = info[0];
returnVal[1] = info[1];
returnVal[2] = info[2];
}
catch (Exception ex)
{
returnVal[0] = returnVal[1] = returnVal[2] = "<error>";
}
}
return returnVal;
}
private string[] ExtractData(string html, string provider)
{
string[] returnVal = new string[3];
string[] parts = html.Split(new string[] { provider }, StringSplitOptions.None);
parts = parts[1].Split(new string[] { "Continent" }, StringSplitOptions.None);
Match match = Regex.Match(parts[0], REGEX_PATTERN);
if (!match.Success)
{
returnVal[0] = returnVal[1] = returnVal[2] = "<parsing failed>";
}
else
{
returnVal[0] = match.Groups["city"].Value;
returnVal[1] = match.Groups["region"].Value;
returnVal[2] = match.Groups["country"].Value;
}

return returnVal;
}

Download (https://www.dropbox.com/s/t23p56umldo9o1w/TraceRtGUI.exe?dl=0)

Credits (https://www.unknowncheats.me/forum/pc-software/158302-tracertgui.html)

I didn't make any piece of this program!