Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import urllib3
- from PIL import Image
- from io import BytesIO
- from unittest.mock import patch
- import argparse
- def connect_to(host, port):
- from urllib3.util.connection import create_connection as orig_create_connection
- def _forced_address_connection(address, *args, **kwargs):
- forced_address = (host, port)
- return orig_create_connection(forced_address, *args, **kwargs)
- return patch('urllib3.util.connection.create_connection', _forced_address_connection)
- urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
- ns = ['193.178.169.19', '94.103.81.80', '94.103.82.74', '94.103.94.73', '195.2.93.193', '185.165.190.88', '23.163.176.229', '195.2.76.245', '95.179.139.27', '178.62.218.115', 'sys.8kun.top']
- parser = argparse.ArgumentParser()
- parser.add_argument('url', help='Link to image')
- parser.add_argument('-s', default=False, dest='s', action='store_true', help='Enable sys workaround, short link only works with jpg')
- parser.add_argument('-p', default=False, dest='p', action='store_true', help='Also rename png to jpg, must use longer dl link')
- parser.add_argument('-g', default=False, dest='g', action='store_true', help='Also rename gif to jpg, must use longer dl link')
- parser.add_argument('-v', default=False, dest='v', action='store_true', help='Verbose output')
- args = parser.parse_args()
- for media in ns:
- try:
- url = args.url
- s = args.s
- p = args.p
- v = args.v
- g = args.g
- if s:
- url = url.replace('https://media', 'https://sys')
- if p:
- n = '.jpg'
- url = n.join(url.rsplit('.png', 1))
- if g:
- n = '.jpg'
- url = n.join(url.rsplit('.gif', 1))
- with connect_to(media, 443):
- try:
- if v:
- print(media)
- print(url)
- r = requests.get(url, verify=False)
- img = Image.open(BytesIO(r.content))
- img.show()
- break
- except Exception as error:
- print(error)
- except Exception as error:
- print(error)
Advertisement
Add Comment
Please, Sign In to add comment