Click here to Skip to main content
Sign Up to vote bad
good
See more: C#IPHackingAddress
How to write my own firewall to detect the infiltrator ip . It is not a web application .
 
How to make application like Wireshark or Ethereal
 
How to Detect IP address in console/windows application in c# ?
 
Doing it in Web site is easy but i am not getting how to detect the ip of incoming packet / request in the Console/ windows application.
 
How to get the ip of an unknown machine if it is saving some file on my machine in a console / Windows application
Posted 14 Sep '12 - 1:19
Edited 7 Oct '12 - 20:17

Comments
Bernhard Hiller - 17 Sep '12 - 4:44
It is very unclear what you want to do. What's that console/Windows application? Is that something you want to write and use as a monitor for such accesses? Or is the issue something totally different. E.g. someone accesses your machine's hard disk, e.g. by writing to a shared directory, and you want to see that access somehow? Like the Network tab on Windows 7's Resource Monitor?
Member 8476555 - 17 Sep '12 - 5:04
want to find ip address of a machine saving a file on my pc

5 solutions

Try this code:
using System.Net;
IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
foreach(IPAddress address in localIPs)
   MessageBox.Show(address.ToString());
  Permalink  
Comments
@amitgajjar - 14 Sep '12 - 9:08
5+
Member 8476555 - 16 Sep '12 - 23:37
Doing it in Web site is easy but i am not getting how to detect the ip of incoming packet / request in the Console/ windows application.
1.1 Framework:
StringBuilder sb = new StringBuilder();
string strHostName = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
    sb.Append(addr[i].ToString());
}
string myip = sb.ToString();
 
2.0 or later framework
StringBuilder sb = new StringBuilder();
// Get the hostname
string myHost = System.Net.Dns.GetHostName();
System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);
foreach(System.Net.IPAddress myIP in myIPs.AddressList)
sb.Append(myIP.ToString());
 
string myip = sb.ToString();
  Permalink  
Comments
Member 8476555 - 16 Sep '12 - 23:37
Doing it in Web site is easy but i am not getting how to detect the ip of incoming packet / request in the Console/ windows application.
hi dear
 
try below code
 
 
public void getLocalIPAddress()
{
   try
   {
     string sHostName = Dns.GetHostName();
     IPHostEntry ipE = Dns.GetHostByName(sHostName);
     IPAddress[] IpA = ipE.AddressList;
     for (int i = 0; i < IpA.Length; i++)
     {
         Console.WriteLine("IP Address {0}: {1} ", i, IpA[i].ToString());
     }
   }
   catch (Exception ex)
   {
      MessageBox.Show(ex.Message.ToString(), "getLocalIPAddress");
   }
}
  Permalink  
Comments
Member 8476555 - 16 Sep '12 - 23:38
Doing it in Web site is easy but i am not getting how to detect the ip of incoming packet / request in the Console/ windows application.
You would have to write your own firewall to do this. You would also need to write a filter driver to insert into the network stack so you can pick out all the inbound traffic and get the addresses you're interested in.
 
Oh, and you'll probably need to write some heuristics into your "filter" so you can get a better idea of what is and is not "unknown".
 
Good Luck!
  Permalink  
Comments
Member 8476555 - 8 Oct '12 - 0:36
How to write your own firewall ?
Dave Kreskowiak - 8 Oct '12 - 8:06
That would take an entire book to discuss. That's FAR more information than you're going to get in a couple of forum posts.
  Permalink  
Comments
Unareshraju - 14 Sep '12 - 7:25
http://www.aspdotnet-suresh.com/2012/07/how-to-get-find-ip-address-of-client.html
Kuthuparakkal - 14 Sep '12 - 7:35
ASP.Net solution link for Windows Form Application related question!!!
Unareshraju - 14 Sep '12 - 8:32
we don't get built in answer for every question , we need to change and develop the code .........
Member 8476555 - 16 Sep '12 - 23:38
Doing it in Web site is easy but i am not getting how to detect the ip of incoming packet / request in the Console/ windows application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Aarti Meswania 230
1 OriginalGriff 220
2 Mahesh Bailwal 220
3 Ron Beyer 215
4 Rohan Leuva 178
0 Sergey Alexandrovich Kryukov 8,553
1 OriginalGriff 6,899
2 CPallini 3,648
3 Rohan Leuva 2,963
4 Maciej Los 2,308


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid