Created
May 27, 2023 20:47
-
-
Save LiEnby/32f3403ed7174c6e28181631fdce143f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import base64 | |
from lxml import etree | |
import json | |
import hashlib | |
from io import StringIO | |
# specify user id | |
USER_ID = "w5YcMrssXv" | |
# create base64 uri | |
data = base64.b64encode(open("img.png", "rb").read()).decode("UTF-8") | |
uri = "data:image/png;base64,"+data | |
sha256 = hashlib.sha256(uri.encode("UTF-8")).hexdigest() | |
uri += "|"+sha256 | |
# create session | |
s = requests.Session() | |
data = s.get("https://drawme.share-on.me/"+USER_ID, | |
headers={"User-Agent":"Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0"}).content | |
# parse csrf token from html | |
parser = etree.HTMLParser() | |
tree = etree.parse(StringIO(data.decode("UTF-8")), parser) | |
csrf = tree.xpath('//*[@id="csrf_token"]')[0].get("value") | |
#print(csrf) | |
# send the drawing | |
print(s.post("https://drawme.share-on.me/drawing/senddrawing", | |
json={ | |
"drawing": uri, | |
"user_id": USER_ID | |
}, headers={ | |
"X-CSRF-TOKEN": csrf, | |
"User-Agent":"Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0", | |
"Content-Type": "application/json", | |
"Origin": "https://drawme.share-on.me", | |
"Referer":"https://drawme.share-on.me/"+USER_ID, | |
}).content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment