Last active
January 18, 2017 08:46
-
-
Save mfkaptan/b6962f8a4bdfcb07a9deea49a757dca9 to your computer and use it in GitHub Desktop.
This file contains 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 json | |
import hmac | |
import hashlib | |
from urllib import request | |
from urllib.parse import urlencode | |
API_DEV_KEY = '1e1582421ea81b1e7e1fd879626466de' | |
def verify_signature(key, data, signature): | |
mac = hmac.new(key.encode("utf-8"), msg=data.encode("utf8"), digestmod=hashlib.sha1) | |
return mac.hexdigest() == signature | |
signature = Hook['req']['headers']['x-taiga-webhook-signature'] | |
key = Hook['hookAccessKey'] | |
data = json.dumps(Hook['params'], ensure_ascii=False) | |
if not verify_signature(key, data, signature): | |
print("Signature not verified") | |
user_vars = {'api_dev_key':'1e1582421ea81b1e7e1fd879626466de', | |
'api_user_name':'mfkaptan', | |
'api_user_password':'123123paste'} | |
ukencoded = bytes(urlencode(user_vars), encoding='utf-8') | |
user_key = request.urlopen('http://pastebin.com/api/api_login.php', ukencoded).read() | |
params = {'api_dev_key': API_DEV_KEY, | |
'api_option': 'paste', | |
'api_paste_private': '1', | |
'api_user_key': user_key, | |
'api_paste_name': 'Taiga', | |
} | |
params['api_paste_code'] = Hook['params'] | |
params_urlencoded = bytes(urlencode(params), encoding='utf-8') | |
resp = request.urlopen('http://pastebin.com/api/api_post.php', params_urlencoded) | |
print(resp.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment