IP address spoofing - c#

Is it true that, if I want to make an IP spoofing program, I need only a program that can change my machine IP address?
If true how can I use System.Net - IPAddress Class to set the ip address?

No, it is not true. Changing your machine's IP address is not IP spoofing. IP spoofing is when you create network packets that have a source IP address that does not match the actual IP address of the source machine.
http://en.wikipedia.org/wiki/IP_address_spoofing
This could be achieved using RAW sockets or WinPCap using SharpPCap to interop to WinPCap
http://www.tamirgal.com/blog/page/SharpPcap.aspx

Your machine IP address is simply the IP address given to your machine to be used internally by devices within your home network. This is how routers, switches and other client devices can deliver and exchange packets.
You cannot spoof your external-facing IP in this manner. Using proxies will make the proxy's IP appear to be your external-facing IP.
I do not suggest changing your internal IP unless you know what you are doing and actually have a need for it to be static. For example, I forward ports on my router so I can run services. The router knows to point that traffic directly to my internal IP. Because DHCP can change your IP (due to lease expiration and what not), it's best that I make my internal IP static.
Also, depending on your network configuration, your internal IP has a certain format, like 192.168.1.X.

The best way to http://www.change-ip-proxy.com>change your ip address is through a proxy. In my search for a proxy, I found that having a reliable company behind the proxy is very important. Everything you do is sent through the company’s proxy, so you want to be sure that you can trust them to not read or steal your personal information. Or else there's no point in having a proxy.

Related

need to store IP address, is Request.UserHostAddress ok to use?

In a website I need to store visitor's IP address for security logging. I m not sure about IP address and its details just have an idea there are different types of IP addresses like user, internet provider, LAN IP, WAN IP etc.
I am even not sure which IP address I should store in database for security I have searched and came to know about Request.UserHostAddress that it returns The IP address of the remote client.
Can you please guide and confirm if I am sotring correct IP and using correct code to retrive IP ?
Edit
I am not certain why IP address is stored but know just as a good practice to do it. My guess is IP need to be stored to identify user, just in case if something wrong happens, with stored IP address it can be traced out who did it or from what area this request came.
Is there some other use of IP, please direct me as well.
Cheers
IP stands for Internet Protocol, which is the protocol underlying HTTP, which is what clients use to connect to web servers. Every machine on an IP network has a unique IP address.
UserHostAddress is the correct property for identifying the client's IP address. It does not matter whether the client is coming from the LAN or WAN, nor does it matter who their internet provider is. Internet providers (and I'm simplifying here) help route traffic to your website, but don't actually participate as an endpoint; the ISP's servers will not show up in the UserHostAddress, only the actual client who initiates the connection, which is typically the user.
Note that I say typically. IP addresses can be spoofed, or they can be hidden behind a proxy (like TunnelBear) or other obfuscation system (like Tor). There's no way to guarantee that you have the "real" IP address of the "real" user, but the aforementioned property is the closest you're going to be able to get.

Find and assign a unique IP address to a device

I need to assign a unique IP address (local) for a device we will be connecting into our system via. USB. The actually assigning I will do over RS232 (don't ask!) by telling the device what it's IP is.
I would like to somehow find a usable address relative to the local PC in order to tell the device which to use. Is there a way of enumerating or finding a usable address in C#? I don't want to simply use a fixed one in case of possible clashes with other devices.
I've done a search here and there's lots of people wanting to find the current IP, or the IP of an already existing device, but I can't find much about generating a usable, unique one.
Thanks for any assistance you can give me.
Assigning static IP addresses (even if you ping them) is a bad idea.
What happens if the IP address you've assigned is to a device that happens to be offline right now?
Use DHCP if you can, and consider prompting the user if you can not retrieve an IP address from DHCP as to what it should be assigned to.
I am not ware of a native C# library for DHCP client's, but using pinvoke will get you what you're after. Example code (not tested) here, http://www.ianatkinson.net/computing/dhcpcsharp.htm
From http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
The Dynamic Host Configuration Protocol (DHCP) is a network
configuration protocol for hosts on Internet Protocol (IP) networks.
Computers that are connected to IP networks must be configured before
they can communicate with other hosts. The most essential information
needed is an IP address, and a default route and routing prefix. DHCP
eliminates the manual task by a network administrator. It also
provides a central database of devices that are connected to the
network and eliminates duplicate resource assignments. In addition to
IP addresses, DHCP also provides other configuration information,
particularly the IP addresses of local Domain Name Server (DNS),
network boot servers, or other service hosts. DHCP is used for IPv4 as
well as IPv6. While both versions serve much the same purpose, the
details of the protocol for IPv4 and IPv6 are sufficiently different
that they may be considered separate protocols.[1] Hosts that do not
use DHCP for address configuration may still use it to obtain other
configuration information. Alternatively, IPv6 hosts may use stateless
address autoconfiguration. IPv4 hosts may use link-local addressing to
achieve limited local connectivity.
Ok, not really sophisticated or anything, but why don't you just try to ping the ips, starting by the lowest, and pick the first one which doesn't respond?

Is there a built-in way to check if an IP address is already occupied?

My software changes the IP of a computer, but I am coming into conflicts with other devices. Is there a built-in way to check if an IP address is already occupied/taken before setting it?
Thanks
If your network doesn't use DHCP and IP addresses really do need to be manually assigned, you could try using the System.Net.NetworkInformation.Ping class to see if a host on the network responds.
You could use the System.Net.NetworkInformation.Ping class, as Donut suggested, but not all devices will respond to Pings. However, any device with an IP address will respond to ARP requests if they are communicating with the network properly.
If you can find a way to send out an ARP request that says "Who has IP address xxx.xxx.xxx.xxx?" and you get a response, then you know someone else has that IP address. I personally don't know how to do that off the top of my head, but you could try looking at this question for information on how to access ARP information.
Also, this might be a useful resource.

Socket Communication C#- IP Address

I have a socket application which I can use in local network, at home.
I can make them communicate for example from 192.168.x.x to 192.168.y.y ip addresses.
What should I do if I want to use the application over internet, from a remote machine, not local. For example which ip addresses should I use if my friend who lives another country wants to access my application.
On the server end, the easiest way is to bind to all available addresses by using IPAddress.Any as the address. You'll need to give the client your public Internet address to connect to. If you're being a NAT, it might involve looking at your router for the address (or using http://www.whatismyip.com/) and configuring it to route the traffic to your PC.
You need to set up your router to forward the port that you wish to communicate on. Once you have that in place, give your friend your public IP address.
For instance, you can configure your router rules to point all port 80 requests to your 192.168.x.x machine, so that when ever a request for port 80 comes in, it automatically gets sent to a specific address on your subnet.
Your outgoing IP address. Use this site to see it: http://www.whatismyip.com/
And of cause port forward your router.
You will have to use the IP address provided by you ISP (internet service provider). Usually these IP addresses are non static, so that you need to provide some way to resolve your dynamic IP address to a static name (dyndns providers do this usually).
In addition you need to configure you router to forward the incomming traffic on port xxx to your local machine (this is usually not your router, except when you are using a modem). This is called port forwarding.

TcpListener: Listen on every address, including GPRS IP address

We have a simple piece of legacy software with which we need to
communicate using TCP/IP over port 15001. We need to listen on port 15001
for the legacy software to make a connection and then read whatever it sends us.
We have tested this solution accross the internet and it works just fine.
If however we test the same solution across a GPRS TCP/IP network it does not.
All the basics have been checked, we can ping other devices in the GPRS network
and port 15001 is not blocked by any firewall.
So maybe there is something wrong with my TcpListener?
It is initialized like this:
tcpServer = new TcpListener(IPAddress.Any, TCP_PORT);
I'm assuming it listens on every available IPv4 enabled interface on the system,
because I used IPAddress.Any ?
Does anybody have any idea what the difference might be between the two networks? (Even though there shouldn't be any difference) and if there is something I need to change to my TcpListener?
You need to specify the IP address on which you want to listen, instead of IPAddress.Any. See here. When you use IPAddress.Any, it will automatically choose the network interface for you. To listen on a certain interface (in your case, GPRS) you have to use the correct IP in the constructor.
This post has more information on getting the IP address for each nic.
Also, if you're looking to listen on every IP address at once, you'll need a TcpListener for each nic.

Categories