Hello everyone,
Hope everyone fine over here. Well, i am having a small problem , actually, i am developing a software to record all visited url's (from any browser). To do that, i am using SharpPCap, I have managed to capture all packets, but the problems is with the IP, i am having all kind of IP addresses and I want to turn these IP's addresses to their respective domain names.
E.g
Google IP is 64.233.189.147 and I want the program to return www.google.com.
I have tried something but i am only getting some weird output, like
"hkg01s01-in-f104.1e100.net" instead of "www.google.com" . Dudes, I am totally confused, can someone help me please.
The code:
This is where i am using sharppcap
.
.
.
DateTime time = packet.PcapHeader.Date;
int len = packet.PcapHeader.PacketLength;
TCPPacket tcp = (TCPPacket)packet;
string srcIP = tcp.SourceAddress;
string destIP = tcp.DestinationAddress;
.
.
.
Here, i am trying to resolve the domain name.
.
.
.
try
{
IPHostEntry IpToDomainName = Dns.GetHostEntry(destIP);
Console.WriteLine("DomainName: {0}", IpToDomainName.HostName);
}
catch
{
Console.WriteLine("err");
}
.
.
.
Thanks in advance friends.
Regards,
Mike.