wind3110991
V2EX  ›  问与答

最近教务系统升级了。。用 python 爬时, URL 被加密了无法操作模拟登陆

  •  
  •   wind3110991 · Apr 18, 2015 · 4783 views
    This topic created in 4070 days ago, the information mentioned may be changed or developed.

    Header里的信息:

    General
    Remote Address:222.201.132.116:80
    Request URL:http://222.201.132.116/(wa4qm345dj1m5i55qectnu22)/default2.aspx
    Request Method:POST
    Status Code:302 Found

    Cache-Control:no-cache, no-store
    Content-Length:173
    Content-Type:text/html; charset=gb2312
    Date:Sat, 18 Apr 2015 13:43:18 GMT
    Expires:-1
    Location:/(wa4qm345dj1m5i55qectnu22)/xs_main.aspx?xh=(这里是我的教务系统ID)
    P3P:CP=CAO PSA OUR
    Pragma:no-cache
    Pragma:no-cache
    Server:Microsoft-IIS/6.0
    X-AspNet-Version:1.1.4322
    X-Powered-By:ASP.NET

    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
    Accept-Encoding:gzip, deflate
    Accept-Language:zh-CN,zh;q=0.8
    Cache-Control:max-age=0
    Connection:keep-alive
    Content-Length:198
    Content-Type:application/x-www-form-urlencoded
    Host:222.201.132.116
    Origin:http://222.201.132.116
    Referer:http://222.201.132.116/(wa4qm345dj1m5i55qectnu22)/default2.aspx
    User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2369.0 Safari/537.36

    __VIEWSTATE:dDwyODE2NTM0OTg7Oz5VGnjXV87Z19Dm3QbgRgvcptEYyA==
    txtUserName:(我的ID)
    TextBox2:(我的密码)
    txtSecretCode:xwcu
    RadioButtonList1:(unable to decode value)
    Button1:
    lbLanguage:
    hidPdrs:
    hidsc:

    主要是URL:http://222.201.132.116/(wa4qm345dj1m5i55qectnu22)/default2.aspx
    这个URL中间是什么加密方法啊? = =

    自己模拟登陆的代码:

    import urllib
    import urllib2
    import cookielib
    import re
    
    class SCUT:
    
        def __init__(self):
            self.loginUrl = '这里是Login的URL'
            self.cookies = cookielib.CookieJar()
            self.postdata = urllib.urlencode({
                'txtUserName:':'我的ID',
                'TextBox2':'我的密码'
             })
            self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookies))
    
        def getPage(self):
            request  = urllib2.Request(
                url = self.loginUrl,
                data = self.postdata)
            result = self.opener.open(request)
            #打印登录内容
            print result.read().decode('gbk')
    
    
    scut = SCUT()
    scut.getPage()
    

    有大神知道如何解决吗?

    21 replies    2015-04-19 21:42:01 +08:00
    binux
        1
    binux  
       Apr 18, 2015 via Android
    你有没有想过,如果“加密”了,浏览器是怎么登录的?
    decken
        2
    decken  
       Apr 18, 2015 via Android
    可以先获取被"加密"的登录URL
    NewYear
        3
    NewYear  
       Apr 18, 2015
    @binux 根本就没加密,先抓取一下/路径,就会跳转,数据都写在包头里了。
    lk09364
        4
    lk09364  
       Apr 18, 2015
    duplicate of /t/184559
    我这边 __VIEWSTATE 内容和你的一样,看来这个直接传回去就可以。
    Ghoul2005
        5
    Ghoul2005  
       Apr 18, 2015
    只要没有验证码,都没有任何障碍,只是多请求一两个页面而已。
    chaucerling
        6
    chaucerling  
       Apr 18, 2015
    请求的是frame的地址<frame src="http://jw2005.scuteo.com/">
    response header返回一个重定向的地址
    Location:/(gx4jp0repbkmkn45u5muqlqu)/Default.aspx
    chaucerling
        7
    chaucerling  
       Apr 18, 2015
    之后又两个重定向,真蛋疼
    Location:http://222.201.132.117/default2.aspx
    Location:/(bpkwxe55m0gnz23beiprl545)/default2.aspx
    RIcter
        8
    RIcter  
       Apr 18, 2015 via iPhone
    這教務系統有漏洞的_(:з」∠)_好像
    cxe2v
        9
    cxe2v  
       Apr 19, 2015
    @RIcter 教务系统基本都是漏洞一堆的
    wind3110991
        10
    wind3110991  
    OP
       Apr 19, 2015
    @NewYear 那应该怎么操作?
    wind3110991
        11
    wind3110991  
    OP
       Apr 19, 2015
    @lk09364 什么意思啊
    sb
        12
    sb  
       Apr 19, 2015
    那串东西是个session, 你提取出来给拼装上就好。
    lgh
        13
    lgh  
       Apr 19, 2015
    母校……
    trepwq
        14
    trepwq  
       Apr 19, 2015 via iPhone
    母校。。。
    oott123
        15
    oott123  
       Apr 19, 2015
    PhantomJS 大法好
    ccbikai
        16
    ccbikai  
    PRO
       Apr 19, 2015 via iPhone
    去年做过一个这样的,没难度,代码搞丢了
    NewYear
        17
    NewYear  
       Apr 19, 2015
    @wind3110991 先用你的组件/插件/类/控件访问http://222.201.132.116/这个地址,但是要禁止跳转,然后获取HTTP头部的跳转信息Location这部分,就是你说的“加密”部分了啊。然后以后访问的网址部分,都带上这个,不就好了。
    welsmann
        18
    welsmann  
       Apr 19, 2015
    看路径就知道是正方.....
    bestie
        19
    bestie  
       Apr 19, 2015
    华南皇家理工大学, 轮子哥一个学校
    Comdex
        20
    Comdex  
       Apr 19, 2015
    @NewYear
    @wind3110991 17楼正解
    endoffight
        21
    endoffight  
       Apr 19, 2015 via Android
    http://202.200.112.200
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   925 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 21:31 · PVG 05:31 · LAX 14:31 · JFK 17:31
    ♥ Do have faith in what you're doing.