Welcome to WebmasterWorld Guest from 54.145.117.164

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Changing Referrer with sockets

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

5+ Year Member



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);
?>

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

WebmasterWorld Senior Member 10+ Year Member



>> why this not work?

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

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

WebmasterWorld Senior Member 5+ Year Member



also you might want to change thread's subject
9:49 am on Sep 12, 2007 (gmt 0)

5+ Year Member



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);
}
?>

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month