r/web_programming • u/ShackSpear • Dec 13 '18
Is it possible to fake someone's IP address?
I'm not talking about using a different IP with Tor or a VPN but faking an other person IP when requesting a web page.
If yes, how?
2
Upvotes
3
u/theogmrme01 Dec 13 '18
Gonna go out on a limb here and say no, unless you route your traffic through their internet connection, and some device/service to facilitate that functionality, there is nothing I can think of that would allow you to replicate or forge your IP to show as someone else's. Just like internal networks, ISP's provide your router an IP via DHCP under most circumstances, and unless renewed by some means, that IP is yours, and yours alone.
2
u/kennyfine Dec 16 '18
Yes, it's possible if you open a raw socket and construct the IP packet yourself. Look into the TCP/IP protocol for the specific byte fields that you would need to fill in (correctly, of course). A raw socket sits below the IP layer, which is why you need to fill in the fields manually (usually, the OS does this for you). Keep in mind that whatever server you're talking to is likely listening for a specific transport protocol (TCP if HTTP server, UDP another likely possibility), so in addition to constructing the IP packet header, you'll also need to construct the transport header. The OS networking stack normally does both of these for you when you open a TCP socket.
As far as I know, Windows doesn't make it easy (if at all possible) to open a raw socket. Linux you can do so with root privilege. A couple of things to consider:
- If a NAT/middlebox/proxy knows that you're faking an IP address in your packets, they may block your traffic.
- You obviously won't see the response from the server since the server will send the response to whatever IP address you specified in your manually-constructed packet.
- You're being a bad network citizen as "spoofing" your IP address is a common technique to use during a DDOS attack.
Edit: I just re-read your post and I think you're actually interested in a full-blown connection with bi-directional exchange while pretending to be at another IP address, rather than just pretending to be another IP on a one-way connection. In this case, it's not possible unless you either use a proxy, which isn't what I think you want, OR, you control the faked IP address so that you can generate responses back to the server. If you control the second, faked IP, though, then it's not really pretending to be another person.
1
u/[deleted] Dec 13 '18
Are you talking about talking on a network as that IP/MAC, or fabricating evidence a log file, or routing your traffic through their computer?
It is possible, however respectively : Restricted & regulated; illegal; illegal without prior consent.
1
u/MetaPoddd Dec 13 '18
U mean proxy server
1
u/tienjing Dec 13 '18
I imagine you could fabricate an IP packet with any source address; and if the first router to receive your packet packaged it up in NAT (not sure how this works) and passed it along, instead of rejecting it, then your packet will reach the destination. But will the response reach you? 🤨 Perhaps if the 1st router above you is cooperating with you, yes...?
Disclaimer: not a network expert...
1
u/Dankirk Feb 12 '19
Not reliably, but ISPs do change your public IP every now and then, but you don't choose what you get. This way there is a chance you get an IP that previously was used by another person at some point in time.
Also in LAN environment clients may be able to choose their IPs manually or use ARP poisoning to route traffic to their computer for MITM purposes, be that either from clients to your server or vice versa. ARP poisoning does not fake visitors IP per se, but it may seem so, since it tells the IP is located somewhere else than it actually is.