V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yth492300648
V2EX  ›  Python

求助:模拟登录 DZ 论坛提示非法字符

  •  1
     
  •   yth492300648 · 2019-11-11 15:52:03 +08:00 · 2411 次点击
    这是一个创建于 1627 天前的主题,其中的信息可能已经有所发展或是发生改变。
    a = session.post(url,data=data)
    print(a.text)

    <root><![CDATA[您当前的访问请求当中含有非法字符,已经被系统拒绝<script type="text/javascript" reload="1">if(typeof errorhandle_login=='function') {errorhandle_login('您当前的访问请求当中含有非法字符,已经被系统拒绝', {});}</script>]]></root>

    姑且查了一下没找到问题。。。(都是说 DZ 论坛防范 XSS 攻击需要改什么内容)
    different
        1
    different  
       2019-11-11 16:20:58 +08:00
    你这个够简洁,两行代码。怎么分析?起码描述一下你的 data 吧
    yth492300648
        2
    yth492300648  
    OP
       2019-11-11 16:27:23 +08:00
    @different
    ![图片注释]( https://s2.ax1x.com/2019/11/11/MQ1fDP.png)
    formmash 应该是对的 自己手动登录一边就是这个
    pws22
        3
    pws22  
       2019-11-11 16:43:38 +08:00
    具体没看,估计分析是你获取 formhash 的同时 将得到的 cookie 也一并带到登陆 post 上去
    Vegetable
        4
    Vegetable  
       2019-11-11 16:48:55 +08:00
    骗人的,带上 cookie 就好了

    ```
    from requests import post
    url = 'https://bbs.colg.cn/member.php'
    params = dict(
    mod="logging",
    action="login",
    loginsubmit="yes",
    handlekey="login",
    loginhash="LFIX5",
    inajax="1")

    data = dict(
    formhash="62c5c2ef",
    referer="https://bbs.colg.cn/",
    loginfield="username",
    username="3123123",
    password="32131231",
    questionid="0",
    answer="",
    )

    r = post(url, params=params, data=data,
    cookies={
    "6KaR_be18_saltkey": "z9XWPZF4",
    "6KaR_be18_lastvisit": "1573457424",
    "6KaR_be18_pvi": "22566260",
    "6KaR_be18_si": "s1017261035",
    "pgv_pvi": "345539584",
    "pgv_si": "s2773357568",
    "6KaR_be18_sid": "GUByBi",
    "6KaR_be18_lastact": "1573461043%09member.php%09logging"
    },
    headers={
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36"})
    print(r.text)

    ```
    Lunatic1
        5
    Lunatic1  
       2019-11-11 16:49:51 +08:00
    之前遇到相同的问题解决了,应该跟 header 有关尝试加入 header,添加 'Content-Type': 'application/x-www-form-urlencoded'
    yth492300648
        6
    yth492300648  
    OP
       2019-11-11 17:12:44 +08:00
    不好意思 看来是自己傻逼了
    @Lunatic1
    yth492300648
        7
    yth492300648  
    OP
       2019-11-11 17:12:49 +08:00
    @pws22 不好意思 看来是自己傻逼了
    yth492300648
        8
    yth492300648  
    OP
       2019-11-11 17:12:54 +08:00
    @Vegetable 不好意思 看来是自己傻逼了
    yth492300648
        9
    yth492300648  
    OP
       2019-11-11 17:13:01 +08:00
    @different 不好意思 看来是自己傻逼了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3269 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 14:15 · PVG 22:15 · LAX 07:15 · JFK 10:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.