您的浏览器试图发送消息,但未在pos中提供窗体边界

2024-10-01 22:37:37 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试向一个非常旧的网站提交发帖请求

我试图发布一个类似的有效负载(这是来自谷歌)

------WebKitFormBoundaryosJxc86zagk885w4
Content-Disposition: form-data; name="hashid"

+13334445555
------WebKitFormBoundaryosJxc86zagk885w4
Content-Disposition: form-data; name="reqUID"

ajpm
------WebKitFormBoundaryosJxc86zagk885w4
Content-Disposition: form-data; name="recipients"


------WebKitFormBoundaryosJxc86zagk885w4
Content-Disposition: form-data; name="file-name"


------WebKitFormBoundaryosJxc86zagk885w4
Content-Disposition: form-data; name="text"

too%20complicated
------WebKitFormBoundaryosJxc86zagk885w4--

对于这些标头(来自inspect元素):

Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9
Connection:keep-alive
Content-Length:547
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryosJxc86zagk885w4
Host:127.0.0.1:333
Origin:http://127.0.0.1:333
Referer:http://127.0.0.1:333/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36
X-Requested-With:XMLHttpRequest

http://127.0.0.1:333/sendMessage.srv

我使用这个简单的python脚本来实现它

#!/usr/bin/env python3
import random
import requests
url = "http://127.0.0.1:333/sendMessage.srv/"
message = "hello"
number = "+13334445555"
# https://stackoverflow.com/questions/2267362/how-to-convert-an-integer-in-any-base-to-a-string
def baseN(num,b,numerals="0123456789abcdefghijklmnopqrstuvwxyz"):
    return ((num == 0) and numerals[0]) or (baseN(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b]) 
reqId = baseN(round(random.random() * 1679616), 36) 
data = { 
        'hashid':number,
        'reqUID':reqId,
        'recipients':"",
        'file-name':"",
        'text':message,
}
r = requests.post(url, data=data)
print(r.status_code, r.reason)
print(r.text)
print("finished")

它给我一个200 OK但它说Your browser tried to send a message without supplying a form boundary in the post.。我做错什么了


Tags: totextnameformhttpmessagedatarandom

热门问题