【问题标题】:Different return of Burpsuite repeater and python requestsBurpsuite 转发器和 python 请求的不同返回
【发布时间】:2021-01-26 13:09:43
【问题描述】:

出于我公司的安全考虑,我删除了网址。但我认为它们对于理解问题并不重要。

当我使用 Burpsuite 发布帖子时,帖子被正确执行,like this print. 请求如下所示:

POST /upload/1 HTTP/1.1
Host: URL REMOVED
Connection: close
Content-Length: 0
sec-ch-ua: "Google Chrome";v="87", " Not;A Brand";v="99", "Chromium";v="87"
Accept: application/json, text/plain, */*
sec-ch-ua-mobile: ?0
x-access-token: TOKEN REMOVED
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Origin: URL REMOVED
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: URL REMOVED
Accept-Encoding: gzip, deflate
Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7

BurpSuite 中的答案如下所示:

HTTP/1.1 200 OK
Date: Mon, 25 Jan 2021 15:28:46 GMT
Server: Apache
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 86
ETag: W/"56-bL6Iw6mpmbZmkXyESXWzn8xcLXc"
Connection: close

{"status":{"type":"success","message":"success","code":200,"error":false},"data":"Ok"}

但是当我尝试使用 python 请求执行相同的帖子时,我得到了 401 错误。代码如下:

import requests
import json
#DESAFIO 2

url_post = 'URL REMOVED'
parametros_post = {
    "Host": "URL REMOVED",
    "Connection": "close",
    "Content-Length": 0,
    "sec-ch-ua": '"Google Chrome";v="87", " Not;A Brand";v="99", "Chromium";v="87"',
    "Accept": "application/json, text/plain, */*",
    "sec-ch-ua-mobile": "?0",
    "x-access-token": "TOKEN REMOVED",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36",
    "Content-Type": "application/x-www-form-urlencoded",
    "Origin": "URL",
    "Sec-Fetch-Site": "same-site",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Dest": "empty",
    "Referer": "URL REMOVED",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7"
}
headers_post = {}
r = requests.post(url_post, data = json.dumps(parametros_post), headers = headers_post)

print(r.json())

返回的python代码如下:

{'status': {'type': 'AppError', 'message': 'Please log in.', 'error': True, 'code': 401}}

我对两种请求方式都使用相同的用户代理和相同的标头。 我该怎么做才能让它在 python 上运行?

【问题讨论】:

    标签: python-requests request http-post python-requests-html burp


    【解决方案1】:

    您发送的请求如下所示:

    您的脚本在请求正文中以 json 格式发送这些标头,但这些是请求标头。 您应该将它们作为标题发送。

    此更改请求后如下所示:

    您可以使用 Burp Comparer 比较您的请求,您只需要通过 Burp 代理发送您的请求,例如 8040 是 Burp 代理的示例。在“比较器”窗口中,您将看到您的请求是什么样的,并且会更容易发现问题所在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-07
      • 1970-01-01
      • 2023-02-17
      • 1970-01-01
      • 2021-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多