Skip to content

Instantly share code, notes, and snippets.

@AmirSbss
Created June 9, 2018 22:01
Show Gist options
  • Save AmirSbss/caa40ffdbf3fb1d2fc6aa9524ffe803b to your computer and use it in GitHub Desktop.
Save AmirSbss/caa40ffdbf3fb1d2fc6aa9524ffe803b to your computer and use it in GitHub Desktop.
Hotgram free Socks5 proxies, 10 different servers, Python3
import urllib.request
import json
import base64
from Crypto.Cipher import AES as _AES
import random
class AES(object):
def __init__(self, key="KCH@LQj#>6VCqqLg", iv="YC'2bmK=b%#NQ?9j"):
self.bs = 16
self.cipher = _AES.new(key, _AES.MODE_CBC, iv)
def encrypt(self, raw):
raw = self._pad(raw)
encrypted = self.cipher.encrypt(raw)
encoded = base64.b64encode(encrypted)
return str(encoded, 'utf-8')
def decrypt(self, raw):
decoded = base64.b64decode(raw)
decrypted = self.cipher.decrypt(decoded)
return str(self._unpad(decrypted), 'utf-8')
def _pad(self, s):
return s + (self.bs - len(s) % self.bs) * chr(self.bs - len(s) % self.bs)
def _unpad(self, s):
return s[:-ord(s[len(s)-1:])]
def get_proxy(server=None) :
servers = ["lh1.talagram.ir", "lh81.talagram.ir", "lh80.talagram.ir", "lh9.talagram.ir", "lh23.talagram.ir", "lh82.talagram.ir", "lh12.talagram.ir", "lh33.talagram.ir", "lh53.talagram.ir", "lh12.talagram.ir", "lh67.talagram.ir"]
if not server:
server = random.choice(servers)
data = json.loads(urllib.request.urlopen("http://" + server + "/v1/proxy").read())["data"][0]
raw = AES().decrypt(data)
proxy = json.loads(raw)
ip = proxy["ip"].split(".")
proxy["ip"] = ".".join([ip[1], ip[0], ip[2], ip[3]])
return "https://t.me/socks?server={ip}&port={prt}&user={usr}&pass={pwd}".format(**proxy)
print(get_proxy())
@SayedSadat
Copy link

SayedSadat commented Jun 10, 2018

Not work !

Traceback (most recent call last):
  File "sh.py", line 37, in <module>
    print(get_proxy())
  File "sh.py", line 31, in get_proxy
    data = json.loads(urllib.request.urlopen("http://" + server + "/v1/proxy").read())["data"][0]
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.class.name))
TypeError: the JSON object must be str, not 'bytes'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment