如何使用Python访问受密码保护的Pastebin?

huangapple go评论69阅读模式
英文:

How do you access pass protected pastebin with python?

问题

我正在尝试从一个Pastebin链接运行Python脚本,但我想要Pastebin受到密码保护。这是我得到的全部:

import requests

pastebin_raw_link = 'https://pastebin.com/raw/F4adqxBq'
response = requests.get(pastebin_raw_link)
source_code = response.content

exec(source_code.decode('utf-8'))
英文:

Im trying to run a python script from a pastebin link but I wanna have the pastebin be password protected this is all I got

import requests

pastebin_raw_link = 'https://pastebin.com/raw/F4adqxBq'
response = requests.get(pastebin_raw_link)
source_code = response.content

exec(source_code.decode('utf-8'))

答案1

得分: 1

你可以使用开发者的 API 来访问私人粘贴,如此处所述:链接

curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_key=YOUR API USER KEY' -d 'api_option=show_paste' -d 'api_paste_key=API PASTE KEY' "https://pastebin.com/api/api_post.php"

上面是一个示例的 POST 请求,你需要使用 Python 执行,使用以下参数:

  1. api_dev_key - 这是你的 API 开发者密钥,你可以通过登录到 pastebin来获取它。
  2. api_user_key - 这是已登录用户的会话密钥。
  3. api_paste_key - 这是你想要从中获取数据的粘贴密钥。
  4. api_option - 设置为 'show_paste'(无需更改)。

现在你可以获取上述所有内容,除了 api_user_key 会话密钥。要获取会话密钥,你需要在调用此 API 之前调用另一个 API,如此处所述。以下是你需要转换为 Python 的示例 POST 请求:

curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_name=a_users_username' -d 'api_user_password=a_users_password' "https://pastebin.com/api/api_login.php"

使用以下参数:

  1. api_dev_key - 这是你的 API 开发者密钥。
  2. api_user_name - 这是你想要登录的用户的用户名。
  3. api_user_password - 这是你想要登录的用户的密码。
英文:

You can use developer's api to access private pastes as mentioned here:

curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_key=YOUR API USER KEY' -d 'api_option=show_paste' -d 'api_paste_key=API PASTE KEY' "https://pastebin.com/api/api_post.php"

The above is a sample POST request which you need to perform using python with the following parameters:

  1. api_dev_key - this is your API Developer Key, which you can obtain by logging into the pastebin
  2. api_user_key - this is the session key of the logged in user
  3. api_paste_key - this is paste key you want to fetch the data from.
  4. api_option - set as 'show_paste' (No need to change)

Now you can get all the above except the api_user_key session key. To get session key you need to call another API before this API as mentioned here. The following is the sample POST request which you need to convert into python:

curl -X POST -d 'api_dev_key=YOUR API DEVELOPER KEY' -d 'api_user_name=a_users_username' -d 'api_user_password=a_users_password' "https://pastebin.com/api/api_login.php"

with the parameters:

  1. api_dev_key - this is your API Developer Key
  2. api_user_name - this is the username of the user you want to login.
  3. api_user_password - this is the password of the user you want to login.

huangapple
  • 本文由 发表于 2023年5月18日 00:41:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274372.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定