强智科技教务处模拟登录
来源:互联网 发布:mac制作手机铃声 编辑:程序博客网 时间:2024/06/03 02:14
通过对教务处登录进行抓包分析,发现登录教务处只需要两个操作
1 将username和password两个的值post到http://202.114.242.21/whkjdx/Logon.do?method=logon
2 通过1的操作以后,页面会跳转到http://202.114.242.21/whkjdx/index.jsp,接着我们post一个空表单到http://202.114.242.21/whkjdx/Logon.do?method=logonBySSO,这样才算完全登录成功,如果没有第二步,会提示权限错误
接下来给出具体的代码,有两种实现方法,一个是用curl来实现,一个是用snoopy.class.php来实现
登录过程是:
访问index.jsp(获得cookie,这是后面操作的基础)->向Logon.do?method=logon提交用户名和密码->自动跳转页面到main.jsp->由main.jsp发起Logon.do?method=logonBySSO的请求->登录过程完成->访问xszqcjglAction.do?method=queryxscj获得成绩
用curl来实现
<?php$login_url = 'http://202.114.242.21/whkjdx/index.jsp';//cookie文件存放在网站根目录的temp文件夹下$cookie_file = tempnam('./temp','cookie');//从首页获取session的密码$ch = curl_init($login_url);curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)');curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_MAXREDIRS, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_AUTOREFERER, 1);curl_setopt($ch, CURLOPT_POST, 0);curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);curl_exec($ch);curl_close($ch);//准备提交数据登录$send_url='http://202.114.242.21/whkjdx/Logon.do?method=logon';$post_fields='USERNAME=你的用户名&PASSWORD=你的密码&useDogCode=&useDogCode=&x=39&y=10';$ch = curl_init($send_url);curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)');curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_MAXREDIRS, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_AUTOREFERER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);curl_setopt($ch, CURLOPT_REFERER, 'http://202.114.242.21/whkjdx/');$contents = curl_exec($ch);curl_close($ch);$send_url='http://202.114.242.21/whkjdx/framework/main.jsp';$ch = curl_init($send_url);curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)');curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_MAXREDIRS, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_AUTOREFERER, 1);curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);curl_setopt($ch, CURLOPT_REFERER, 'http://202.114.242.21/whkjdx/Logon.do?method=logon');curl_exec($ch);curl_close($ch);$send_url='http://202.114.242.21/whkjdx/Logon.do?method=logonBySSO';$post_fields='';$ch = curl_init($send_url);curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)');curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_MAXREDIRS, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_AUTOREFERER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);curl_setopt($ch, CURLOPT_REFERER, 'http://202.114.242.21/whkjdx/framework/main.jsp');curl_exec($ch);curl_close($ch);//查询成绩$send_url='http://202.114.242.21/whkjdx/xszqcjglAction.do?method=queryxscj';$ch = curl_init($send_url);curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)');curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_MAXREDIRS, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_AUTOREFERER, 1);curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);$contents = curl_exec($ch);curl_close($ch);//输出页面的内容print_r($contents);?>
用snoopy.class.php来实现
<?php include "Snoopy.class.php";$snoopy = new Snoopy; $snoopy->expandlinks=true; $formvars["USERNAME"] = "你的用户名"; $formvars["PASSWORD"] = "你的密码"; $action = "http://202.114.242.21/whkjdx/Logon.do?method=logon";//表单提交地址$snoopy->fetch("http://202.114.242.21/whkjdx/index.jsp");$snoopy->setcookies();//留下cookie,这个很重要
$snoopy->submit($action,$formvars);//$formvars为提交的数组 $snoopy->fetch("http://202.114.242.21/whkjdx/framework/main.jsp");
$formvars=NULL;$action="http://202.114.242.21/whkjdx/Logon.do?method=logonBySSO";$snoopy->submit($action,$formvars); $snoopy->fetch('http://202.114.242.21/whkjdx/xszqcjglAction.do?method=queryxscj');echo $snoopy->results;?>
ps:查询成绩,只要登录成功以后,访问http://202.114.242.21/whkjdx/xszqcjglAction.do?method=queryxscj就可以了
0 0
- 强智科技教务处模拟登录
- Python模拟登录东北大学教务处
- python爬虫获取强智科技教务系统学科成绩(模拟登录+成绩获取)
- Android模拟登录教务处(带验证码)
- php curl 实现模拟登录教务处
- python 模拟登录 中国科大 教务处系统
- HttpClient模拟Post实现登录辽大教务处
- 绕过验证码,模拟登录 南理教务处
- 模拟登陆教务处网站C#
- 模拟登入教务处(header)
- Python 模拟登陆华理教务处
- JAVA 模拟登陆华理教务处
- Android登录学校正方教务处--CSDN第一次发帖
- 模拟登陆教务处-格式化输出(代码太凌乱)
- 模拟登陆西电研究生教务处(爬虫1)
- HDU 5402 强模拟
- 模拟登录
- 模拟登录
- 洲思房地产解决方案
- 如何计算每天的平均反复访问人数
- 埃及分解:将2/n分解成为1/x+1/y的格式
- VC、IE、ASP环境下打印、预备的完美解决方案
- Ext Tree 过滤 树 过滤 代码
- 强智科技教务处模拟登录
- IOS sqlite3,数据库的 ,增, 删,改。查
- 查询oracle正在执行的SQL语句
- java中GUI练习——制作“我的电脑界面”并实现其功能
- 测试如何定位问题
- oltp和olap
- JAVA 创建文件和文件夹,删除文件和文件夹的实用工具
- ArcGIS教程:关于创建TIN的基础知识
- 毕业后不知道去哪里