1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change IP in PHP

Discussion in 'PHP & Perl' started by Sniper, Aug 28, 2009.

  1. Sniper

    Sniper Regular Member

    Joined:
    Dec 30, 2008
    Messages:
    471
    Likes Received:
    213
    Location:
    Torrent Assault
    Home Page:
    Anyone know how to or if it is possible to change the IP address of a visitor.

    For example, if I use REMOTE_ADDR to get the IP, it will show my IP. Is there a way I can change this to whatever I want?

    To further expand on this question.. is there a way to either spoof or blank the "X-PHP-Script" when using the php mail command?
     
    Last edited: Aug 28, 2009
  2. Sniper

    Sniper Regular Member

    Joined:
    Dec 30, 2008
    Messages:
    471
    Likes Received:
    213
    Location:
    Torrent Assault
    Home Page:
    No one hey? I was searching and it doesn't look really possible.. unless someone can help...
     
  3. zappak

    zappak Junior Member

    Joined:
    Mar 8, 2007
    Messages:
    101
    Likes Received:
    9
    If you mean, you want to change IP of your PC using PHP and if you have dynamic IP connection then you can do by executing "rasdial" command using php.
     
  4. TheMadBlackHatter

    TheMadBlackHatter Newbie

    Joined:
    Aug 7, 2009
    Messages:
    38
    Likes Received:
    47
    Occupation:
    Self-employed
    Location:
    The web
    I'm not quite sure what the point would be in changing the visitor's IP. Like any variable, you can access $_SERVER['REMOTE_ADDR'] perfectly fine but changing it won't actually effect your visitor's IP address.

    As for mail, try http://sourceforge.net/projects/phpmailer/ or some other mail script. These can allow the usage of SMTP, proxies, etc.
     
  5. justone

    justone Elite Member

    Joined:
    Oct 12, 2008
    Messages:
    1,516
    Likes Received:
    1,037
    Occupation:
    -
    Location:
    Europe
    I think you should read up a bit more about TCP/IP and PHP in general.
    Your question does not make sense in more than one way:
    a) you can not change the ip address of a visitor.
    b) of course you can change the remote address variable, it makes no sense but it's a normal variable that is generated from the http headers.
    c) For mailing you might want to take a look at the PEAR:Mail project. the php internal mail() isn't good for anything serious.
    With PEAR:Mail you can influence more.
     
  6. Sniper

    Sniper Regular Member

    Joined:
    Dec 30, 2008
    Messages:
    471
    Likes Received:
    213
    Location:
    Torrent Assault
    Home Page:
    Justone, actually, that leads me in the correct direction. If you do a mail() in Php, and look at the source of the mail, you will see the x-php-script, and that identifies the IP of the calling web browser. If I can fake this IP, then essentially, I can send anonymous emails.

    I am calling the php via a desktop mailing software that passes teh contents of the mail to be sent via url, and the mail php just blasts it out.

    The only thing showing would be the url to the php file and if you cover tracks on some hosting you don't care about, then you might be able to use it.

    So how would I change the http header to show a fake IP?

    Surely it isn't as simply as $_SERVER['REMOTE_ADDR'] = "1.2.3.4"
     
  7. justone

    justone Elite Member

    Joined:
    Oct 12, 2008
    Messages:
    1,516
    Likes Received:
    1,037
    Occupation:
    -
    Location:
    Europe
    use PEAR:MAIL, you can define any headers in there.
    But don't forget two things:
    a) the sendmail daemon adds your IP too, you can not fake that without hacking it
    b) the receiver will always see which server sent the mail
     
  8. hip_hop_x

    hip_hop_x Regular Member

    Joined:
    Aug 27, 2009
    Messages:
    303
    Likes Received:
    65
    Occupation:
    Developer
    Home Page:
    you could use proxy in php, to change the ip address
     
  9. heiska

    heiska Junior Member

    Joined:
    Dec 5, 2008
    Messages:
    139
    Likes Received:
    170
    Would something like this be accomplished with blind ip spoofing?
     
  10. SharePro

    SharePro BANNED BANNED

    Joined:
    Sep 18, 2008
    Messages:
    156
    Likes Received:
    914
    Part of the negotiation (between remote server and client) in TCP/IP is the IP address - so you cannot forge the IP of a TCP/IP request.

    You can use a proxy, but that isnt spoofing. Its just using a 3rd party to forward requests.

    You can only spoof with UDP.