homepage Welcome to WebmasterWorld Guest from 54.235.39.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Changing Referrer with sockets
script33




msg:3447460
 3:36 pm on Sep 11, 2007 (gmt 0)

why this not work?(4 spoof Referer)

<?php
error_reporting(E_ALL);
$service_port = getservbyname('www', 'tcp');
$address = gethostbyname('www.google.com');

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) {
echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
}
$result = socket_connect($socket, $address, $service_port);
if ($result < 0) {
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
}

$in = "GET / HTTP/1.1\r\n";
$in .= "Host: www.google.com\r\n";
$in .= "User-Agent: Ive been forged!\r\n";
$in .= "Referer: [google.com...]
$in .= "Connection: Close\r\n\r\n";
$out = '';

socket_write($socket, $in, strlen($in));
while ($out = socket_read($socket, 2048)) {
echo $out;
}
$socket_close($socket);
?>

 

Habtom




msg:3448178
 4:44 am on Sep 12, 2007 (gmt 0)

>> why this not work?

You might as well mention error messages, any results, it will help you get a quick response.

phparion




msg:3448184
 4:49 am on Sep 12, 2007 (gmt 0)

also you might want to change thread's subject

script33




msg:3448296
 9:49 am on Sep 12, 2007 (gmt 0)

Error?
no
i want spoof Referrer with a PHP or...
how i can do it?
i tested many scripts but they dont work...

4 exam this:

<?php

$host = 'http://www.google.com';
$service_uri = '/ref.php';
$vars ='download_ticket=3234&over18=yes';

$header = "Host: $host\r\n";
$header .= "User-Agent: PHP Script\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Referer: [google.com";...]
$header .= "Content-Length: ".strlen($vars)."\r\n";
$header .= "Connection: close\r\n\r\n";

$fp = fsockopen("".$host,80, $errno, $errstr);

if (!$fp) {
echo "$errstr ($errno)<br/>\n";
echo $fp;
} else {
fputs($fp, "POST $service_uri HTTP/1.1\r\n");
fputs($fp, $header.$vars);
fwrite($fp, $out);

while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>

jatar_k




msg:3448422
 12:36 pm on Sep 12, 2007 (gmt 0)

when using cURL you can set the referer

there are examples in the comments here
[php.net...]

you could do exactly what you want with cURL

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved