强智科技教务处模拟登录

通过对教务处登录进行抓包分析,发现登录教务处只需要两个操作

  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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值