強智科技教務處模擬登錄


通過對教務處登錄進行抓包分析,發現登錄教務處只需要兩個操作

  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就可以了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM