Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/usr/env python3
- import argparse
- import json
- import sys
- import time
- import requests
- from os import path
- from mitmproxy.tools import _main as main
- def ensure_file_existence(file_path):
- if not path.isfile(file_path):
- print('Error: the file {} does not exist. Please check the path'.format(file_path))
- sys.exit(-1)
- def run_mitmproxy_live(output):
- main.mitmdump(["--mode", "transparent", "--showhost", "-s", "./cookiefinder.py", "--set",
- "signin=https://13.33.32.47/ap/signin", "--set", "output=" + path.expanduser(output),
- "--set", "ajax=https://13.33.32.47/hz/mycd/ajax"])
- def run_mitmproxy_on_file(flows, output):
- main.mitmdump(
- ["-n", "-r", flows, "--showhost", "-s", "./cookiefinder.py", "--set", "signin=https://13.33.32.47/ap/signin",
- "--set", "output=" + path.expanduser(output), "--set", "ajax=https://13.33.32.47/hz/mycd/ajax"])
- def get_info():
- parser = argparse.ArgumentParser()
- parser.add_argument("--cookies", type=str, nargs='?', default="cookies.json", const="cookies.json",
- help="specify file for finding necessary cookies")
- parser.add_argument("--flows", type=str, nargs='?', help="specify file for incoming flows")
- args = parser.parse_args()
- cookies_path = path.expanduser(args.cookies)
- if path.isfile(cookies_path):
- with open(cookies_path) as f:
- cookies = json.load(f)
- else:
- if args.flows is not None:
- flows_path = path.expanduser(args.flows)
- run_mitmproxy_on_file(flows_path, cookies_path)
- else:
- run_mitmproxy_live(cookies_path)
- while not path.exists(cookies_path):
- time.sleep(1)
- ensure_file_existence(cookies_path)
- with open(cookies_path) as f:
- cookies = json.load(f)
- return cookies
- info = get_info()
- csrfToken = info["csrfToken"]
- cookies = info["cookies"]
- start_date = str(int(round(time.time() * 1000)) - 86400000)
- end_date = str(int(round(time.time() * 1000)))
- batchSize = "100"
- shouldParseStartDate = "false"
- shouldParseEndDate = "false"
- authority = "www.amazon.com"
- accept = "text/html, */*; q=0.01"
- content_type = "application/x-www-form-urlencoded"
- x_requested_with = "XMLHttpRequest"
- accept_language = "en-us"
- accept_encoding = "br, gzip, deflate"
- origin = "https://www.amazon.com"
- referer = "https://www.amazon.com/hz/mycd/alexa/activityHistory"
- user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 PitanguiBridge/2.2.288637.0-[HARDWARE=iPhone11_2][SOFTWARE=12.4]"
- encoded_form = {
- "csrfToken": csrfToken,
- "rangeType": "custom",
- "startDate": start_date,
- "endDate": end_date,
- "batchSize": "100",
- "shouldParseStartDate": "false",
- "shouldParseEndDate": "false"
- }
- json = json.dumps(encoded_form)
- headers = {
- "authority": authority,
- "content-type": content_type,
- "accept": accept,
- "x-requested-with": x_requested_with,
- "accept-language": accept_language,
- "accept-encoding": accept_encoding,
- "origin": origin,
- "referer": referer,
- "content-length": str(len(json)),
- "user-agent": user_agent
- }
- response = requests.post("https://amazon.com/hz/mycd/alexa/activityTranscripts", data=encoded_form, headers=headers)
- with open("test.html", "w") as f:
- f.write(response.json())
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement