• 0

proxy help [php]


Question

this works... but not perfectly it will hide your IP but i need help adding to it .. to get more to display.. and to change the ip address rather then it use my websites IP... ideas or lil snippets for improvmnt?

<?php
$weburl = $_GET['weburl'];
$url = "$weburl";
$page = file($url);

foreach($page as $part)
{

$part = ereg_replace('<img src=','<img src='.$url,$part);
$part = ereg_replace('action=','action='.$url,$part);
$part = ereg_replace('<a href=','<a href='.$url,$part);
$part = ereg_replace('<img=','<img='.$url,$part);
$part = ereg_replace('<script src=','script src='.$url,$part);

echo $part;
}

?>

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

There's a pretty major security flaw. If you navigate to;

yourscript.php?weburl=../../etc/passwd (the number of ../ will probably be different for your server)

it'll read and display the server's passwd file - which is never a good thing :p

Also, ereg_replace has been deprecated and is less efficient than it's replacement, preg_replace. Having 5 statements repeated for every line in a webpage's source code will put quite a load on the server. If it's just going to be you using this script, it's not that much of a problem - but if you want to provide some sort of service to other people, it'll put high load on the server with a relatively small number of users. For what you're using it for, you could probably just use str_replace because it's faster than both ereg & preg replace as it doesn't use regular expressions.

As far as changing the IP address goes - short of using your proxy through another proxy, you won't be able to do it. If your server requests a webpage using a different IP, how is the 3rd party server going to know where to send the response for that request?

Something else you may not have thought of, the images and scripts will be fetched by your browser directly from the website you're trying to hide your IP from...so if someone really wanted to see your IP, they still could just by looking at their server's access logs. Also, presumably whenever you click on a link it's going to navigate your browser to that page directly rather than sending you through the proxy? I don't really know exactly what you're aiming for with this script - is it just a bit of an exercise? You might find it interesting to try and make it so that all the images, links, scripts and form actions are linked through your proxy too.

Link to comment
Share on other sites

  • 0

yea this script is just a bit of trainning start of basic proxy and work my way up.... i basicaly just finishing a project which has taken a year (massive website all scripts are our own... forums... videos. everything...) and i basically done all my work :/ and waiting for the designer to finish the last lil bit before we open.... and i was bored and i heard proxies are one of the most difficult things to build so thought ive done everything else.... why not a proxy... but it i going well!!! LOOL .... thanks for the tips il consider them andhave a go :D i might download a proxy script and learn from it... but i can find a non dodgy looking one.. can you link me?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.