当前位置:首页 » 编程语言 » snoopyphp登录

snoopyphp登录

发布时间: 2023-06-03 13:27:57

1. 请问php模拟登录后怎么保持session总是不能成功保持session到目标站的其他页面

请问楼主 最后怎么解决的此问题 ,求公布答案, 我也是碰到这个问题了,能模拟登录成功并且获取到cookie保存,然后总是返回登录成功后 第一个看到的页面,再获取其他页面就不行了,目标服务器也是和你的问题一样,通过session 来判断

2. php curl 模拟登录 失败不成功 高手来解救!

请使用SNOOPY,你网络一下就有下载地址了他是对CURL的封装,大网站很多都用这个

3. PHP模拟登陆QQ空间

PHP代码:
<php
$qq = "100000"; //qq号码
$pwd = "123456"; //密码
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://211.139.167.71/waptest/TWF/qqportal/rela/updateuserinfo.jsp");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //这行是设定curl是否跟随header发送的location, 重要
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, "Connection", "Keep-Alive");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "qq=".$qq."&pwd=".$pwd."&FromWhere=register");
$return = curl_exec($ch);
curl_close($ch);
echo strstr($return, "postfield") ? "登录失败" : "登录成功";
?>
注:1、需curl模块支持,2、登陆后,你的好友将会看到你在线 3、不知道如何下线。
其他语言的实现类似,有兴趣的朋友可以自己动手开发一下。

这个你试试

4. php curl 无法实现模拟登陆

<?php
$discuz_url = 'http://127.0.0.1/discuz/';//论坛地址
$login_url = $discuz_url .'logging.php?action=login';//登录页地址

$post_fields = array();
//以下两项不需要修改
$post_fields['loginfield'] = 'username';
$post_fields['loginsubmit'] = 'true';
//用户名和密码,必须填写
$post_fields['username'] = 'tianxin';
$post_fields['password'] = '111111';
//安全提问
$post_fields['questionid'] = 0;
$post_fields['answer'] = '';
//@todo验证码
$post_fields['seccodeverify'] = '';
//获取表单FORMHASH
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$contents = curl_exec($ch);
curl_close($ch);
preg_match('/<input\s*type="hidden"\s*name="formhash"\s*value="(.*?)"\s*\/>/i', $contents, $matches);
if(!empty($matches)) {
$formhash = $matches[1];
} else {
die('Not found the forumhash.');
}

//POST数据,获取COOKIE,cookie文件放在网站的temp目录下
$cookie_file = tempnam('./temp','cookie');
$ch = curl_init($login_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_exec($ch);
curl_close($ch);
//取到了关键的cookie文件就可以带着cookie文件去模拟发帖,fid为论坛的栏目ID
$send_url = $discuz_url."post.php?action=newthread&fid=2";

$ch = curl_init($send_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
$contents = curl_exec($ch);
curl_close($ch);
//这里的hash码和登陆窗口的hash码的正则不太一样,这里的hidden多了一个id属性
preg_match('/<input\s*type="hidden"\s*name="formhash"\s*id="formhash"\s*value="(.*?)"\s*\/>/i', $contents, $matches);
if(!empty($matches)) {
$formhash = $matches[1];
} else {
die('Not found the forumhash.');
}

$post_data = array();
//帖子标题
$post_data['subject'] = 'test2';
//帖子内容
$post_data['message'] = 'test2';
$post_data['topicsubmit'] = "yes";
$post_data['extra'] = '';
//帖子标签
$post_data['tags'] = 'test';
//帖子的hash码,这个非常关键!假如缺少这个hash码,discuz会警告你来路的页面不正确
$post_data['formhash']=$formhash;

$ch = curl_init($send_url);
curl_setopt($ch, CURLOPT_REFERER, $send_url); //伪装REFERER
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$contents = curl_exec($ch);
curl_close($ch);
//清理cookie文件
unlink($cookie_file);
?>

热点内容
qq刷红包脚本 发布:2024-05-03 16:16:54 浏览:769
c服务编译耗时优化原理及实例 发布:2024-05-03 15:35:26 浏览:15
ue编程 发布:2024-05-03 15:34:40 浏览:610
经典的c语言程序 发布:2024-05-03 15:03:24 浏览:859
工程加密网 发布:2024-05-03 14:59:55 浏览:292
吃冰球解压 发布:2024-05-03 14:59:10 浏览:895
编译芯片发烫 发布:2024-05-03 14:59:05 浏览:549
优化算法pdf 发布:2024-05-03 14:18:10 浏览:291
python算法书 发布:2024-05-03 14:14:25 浏览:736
方舟怎么加入服务器闪退 发布:2024-05-03 14:05:27 浏览:491