python post請求偽造登陸 瀏覽器抓包

來源:互聯網
上載者:User

標籤:python   post請求   瀏覽器抓包   

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/8B/48/wKioL1hJACzjbzDDAAHlVRZi_kU399.png-wh_500x0-wm_3-wmp_4-s_2045683009.png" title="21.png" alt="wKioL1hJACzjbzDDAAHlVRZi_kU399.png-wh_50" />

網站是vmware虛擬機器搭建了個go網路商城,Tomcat+Mysql+SSH架構的,這是後台介面,瀏覽器按F12抓包

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/8B/4B/wKiom1hJAO6wDyv5AAIfAHHmRg8676.png-wh_500x0-wm_3-wmp_4-s_3587759057.png" title="22.png" alt="wKiom1hJAO6wDyv5AAIfAHHmRg8676.png-wh_50" />

帳號密碼admin 下面我們py偽造post請求登陸

# coding=utf-8import urllibimport urllib2import re#9ok 類比登陸了admin賬戶def DengLu(username=‘admin‘,password=‘admin‘):    url = ‘http://192.168.171.144:8080/Shop/admin/user/user_logon.html‘    #請求體    postdata=urllib.urlencode(    {  ‘Content-Type‘: ‘application/x-www-form-urlencoded‘,       ‘username‘:username,         ‘password‘:password    })    #要求標頭    headers = {        ‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0‘,        ‘Accept‘: ‘text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8‘,        ‘Accept-Language‘: ‘zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3‘,        ‘Accept-Encoding‘: ‘gzip, deflate‘,        ‘Referer‘: ‘http://192.168.171.144:8080/Shop/admin/user/user_login.html‘,        ‘Connection‘: ‘keep-alive‘,        ‘Upgrade-Insecure-Requests‘: ‘1‘    }    req = urllib2.Request(url, postdata, headers)    response = urllib2.urlopen(req)    the_page = response.read()    print the_page    print response.code    print len(the_page)#函數調用 第一個登陸帳號 第二個登入密碼  返回一個cookieDengLu(‘admin‘,‘admin‘)

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M01/8B/48/wKioL1hJA6HiQIJFAADvdTA-1T4205.png-wh_500x0-wm_3-wmp_4-s_2033514890.png" title="23.png" alt="wKioL1hJA6HiQIJFAADvdTA-1T4205.png-wh_50" />

有些抓包工具也很好用 例如burp 需要調試上傳或者其他請求的時候可以用


關於post中擷取cookie值 調用web其他功能請看下一篇

本文出自 “俠米” 部落格,請務必保留此出處http://xiami.blog.51cto.com/9292349/1880743

python post請求偽造登陸 瀏覽器抓包

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.