實用的小偷程序

kahn178 2009-05-26 10:24:08

<?php

/**
* $Id$
*
* Filename : referer.php
* Create : 20060831
* LastMod : 2009

*/

//ini_set('display_errors', 1);
//error_reporting(E_ALL ^ E_NOTICE);
//header("Content-type:text/html;charset=utf-8");

set_time_limit(5);

$referer = 'http://php.club.goodoon.com';
$data = 'Hello PHPX!';
$host = "www.phpx.com";
$path = "/happy/index.php";
$port = '80';
$user = 'user;
$pswd = '屁屁';


// {{{ 方法 1 ,用 fsockopen
/*
// 处理好 formhash 的值就可以实现登录,这里还不可以,弄过discuz的可以尝试一下
$path = "/happy/logging.php?action=login";
$data = "formhash=&referer=$referer&loginmode=normal&cookietime=2592000&loginfield=username&username=$user&password=$pswd&questionid=0";
*/

$q = '';
$q .= "GET $path HTTP/1.1rn";
$q .= "Host: $hostrn";
$q .= "Referer: $refererrn"; // 看这里
$q .= "Content-type: application/x-www-form-urlencodedrn";
$q .= "Content-length: ".strlen($data)."rn";
$q .= "Accept: */*rn";
$q .= "Connection: closern";
$q .= "rn";
$q .= $data;

$fp = fsockopen($host, $port);
fputs($fp, $q);
$r = '';
while(!feof($fp)) {
$r .= fgets($fp);
}
fclose($fp);
//echo $r;
// }}}

// {{{ 方法 2 ,用 curl 系列函数(另外 curl 真的非常不错,值得大家尝试。你,值得拥有。 ^_^)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.phpx.com/happy/logging.php?action=login");
curl_setopt($ch, CURLOPT_REFERER, $referer); // 看这里,你也可以说你从google来
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
// 上面这句,当然你可以说你是baidu,改掉这里的值就ok了,可以实现小偷的功能,
//你也可以自己做个 spider 了,那么就伪装这里的 CURLOPT_USERAGENT 吧

curl_setopt($ch, CURLOPT_POST, 1); // post 过去
curl_setopt($ch, CURLOPT_POSTFIELDS, array('username' => $user, 'password' => $pswd)); // post 的字段
// 当然这里也可以用这个方式来实现登录,不过这里对discuz来讲还是有 formhash 问题,
// 也许换个没有这种安全验证机制的登录是可以的。
// 烦琐的我就不再弄了。

$r = curl_exec($ch);
curl_close($ch);
// }}}

// {{{ 方法 3 就是 stream 系列函数了
$opts = array(
"http" => array(
'method' => "GET",
'header' => "Referer: http://php.club.goodoon.comrnAccept: */*rnAccept-language: zh-cnrnCookie: username=userrn"
/*也许“user”这里需要encode什么滴*/
)
);

$context = stream_context_create($opts);
// 当然这里也可以用 stream_context_set_option 函数设置更多 options

$fp = fopen("http://www.phpx.com/happy/index.php", "r", false, $context);
fpassthru($fp);
fclose($fp);
// }}}

/**
总结,虽然这里什么事情也没有去做。

但是,这里告诉大家的东西很显然,

以上就是使用我们都喜欢的 php 伪装 http 的 referer,就这样。

所以,referer 不是完全可以信任的。

*/

?>



...全文
149 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ynkmhp 2009-06-06
  • 打赏
  • 举报
回复
jf~
ACMAIN_CHM 2009-06-06
  • 打赏
  • 举报
回复

dhgdmw 2009-06-06
  • 打赏
  • 举报
回复
mark
lyshanshi 2009-06-06
  • 打赏
  • 举报
回复
看不懂,到底是做什么的,
榕树花园 2009-06-05
  • 打赏
  • 举报
回复
有空研究一下
lxh1 2009-06-03
  • 打赏
  • 举报
回复
谢谢,学习中!
lonelyriver 2009-06-03
  • 打赏
  • 举报
回复
丿
f411csh 2009-06-02
  • 打赏
  • 举报
回复
看不懂,可以说说大概的功能和实现么

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧