Spaces:
Running
Running
Update to bot.py file
Browse filesFiles changed (5)
- accounts.jsonAdded+12
- bot.pyAdded+769
- proxy.txtAdded+3
- requirements.txtAdded+4
- setup.pyAdded+455
123456789101112[ { "email": "abdulabubakar08084@gmail.com", "passcode": "181106", "interlinkId": "89753842", "deviceId": "c1a4d50786c76279", "tokens": { "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dpbklkIjoiODk3NTM4NDIiLCJzaWQiOiI2YTZmZGYzMzMzYmYxM2QzZWE0YTc0N2MiLCJ0eXAiOiJhY2Nlc3MiLCJpYXQiOjE3ODU3MTY1MzEsImV4cCI6MTc4NTcxODMzMSwiYXVkIjoiaW50ZXJsaW5rLXVzZXIiLCJpc3MiOiJpbnRlcmxpbmsifQ.r_75gf28bjovXOOiHGA9Xmj4kbsoOWuAhPE4AgyUJfg", "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dpbklkIjoiODk3NTM4NDIiLCJzaWQiOiI2YTZmZGYzMzMzYmYxM2QzZWE0YTc0N2MiLCJ0eXAiOiJyZWZyZXNoIiwiaWF0IjoxNzg1NzE2NTMxLCJleHAiOjE3ODgzMDg1MzEsImF1ZCI6ImludGVybGluay11c2VyIiwiaXNzIjoiaW50ZXJsaW5rIn0.qa9QSkJA1qFzYg6f6UtGYSl-47KLzQi3EQVRljwMM4w" } }]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769from aiohttp import ( ClientResponseError, ClientSession, ClientTimeout, BasicAuth)from aiohttp_socks import ProxyConnectorfrom base64 import urlsafe_b64decodefrom dotenv import load_dotenvfrom datetime import datetime, timedelta, timezonefrom colorama import *import asyncio, random, time, json, sys, re, os
load_dotenv()
class Interlink: def __init__(self) -> None: self.BASE_API = "https://prod.interlinklabs.ai" self.VERSION = str(os.getenv("APP_VERSION", "5.0.5"))
self.USE_PROXY = False self.ROTATE_PROXY = False
self.proxies = [] self.proxy_index = 0 self.account_proxies = {} self.accounts = {}
def clear_terminal(self): os.system('cls' if os.name == 'nt' else 'clear')
def log(self, message): print( f"{Fore.CYAN + Style.BRIGHT}[ {datetime.now().strftime('%x %X')} ]{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}{message}", flush=True )
def welcome(self): print( f""" {Fore.GREEN + Style.BRIGHT}Interlink Labs {Fore.BLUE + Style.BRIGHT}Auto BOT """ f""" {Fore.GREEN + Style.BRIGHT}Rey? {Fore.YELLOW + Style.BRIGHT}<INI WATERMARK> """ )
def format_seconds(self, seconds): hours, remainder = divmod(seconds, 3600) minutes, seconds = divmod(remainder, 60) return f"{int(hours):02}:{int(minutes):02}:{int(seconds):02}" def load_accounts(self): filename = "accounts.json" try: if not os.path.exists(filename): self.log(f"{Fore.RED}File {filename} Not Found.{Style.RESET_ALL}") return
with open(filename, 'r') as file: data = json.load(file) if isinstance(data, list): return data return [] except json.JSONDecodeError: return [] def save_accounts(self, new_accounts): filename = "accounts.json" try: if os.path.exists(filename) and os.path.getsize(filename) > 0: with open(filename, 'r') as file: existing_accounts = json.load(file) else: existing_accounts = []
account_dict = {acc["email"]: acc for acc in existing_accounts}
for new_acc in new_accounts: email = new_acc["email"]
if email in account_dict: account_dict[email].update(new_acc) else: account_dict[email] = new_acc
updated_accounts = list(account_dict.values())
with open(filename, 'w') as file: json.dump(updated_accounts, file, indent=4)
except Exception as e: return [] def load_proxies(self): filename = "proxy.txt" try: if not os.path.exists(filename): self.log(f"{Fore.RED + Style.BRIGHT}File {filename} Not Found.{Style.RESET_ALL}") return with open(filename, 'r') as f: self.proxies = [line.strip() for line in f.read().splitlines() if line.strip()] if not self.proxies: self.log(f"{Fore.RED + Style.BRIGHT}No Proxies Found.{Style.RESET_ALL}") return
self.log( f"{Fore.GREEN + Style.BRIGHT}Proxies Total : {Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT}{len(self.proxies)}{Style.RESET_ALL}" ) except Exception as e: self.log(f"{Fore.RED + Style.BRIGHT}Failed To Load Proxies: {e}{Style.RESET_ALL}") self.proxies = []
def check_proxy_schemes(self, proxies): schemes = ["http://", "https://", "socks4://", "socks5://"] if any(proxies.startswith(scheme) for scheme in schemes): return proxies return f"http://{proxies}"
def get_next_proxy_for_account(self, account): if account not in self.account_proxies: if not self.proxies: return None proxy = self.check_proxy_schemes(self.proxies[self.proxy_index]) self.account_proxies[account] = proxy self.proxy_index = (self.proxy_index + 1) % len(self.proxies) return self.account_proxies[account]
def rotate_proxy_for_account(self, account): if not self.proxies: return None proxy = self.check_proxy_schemes(self.proxies[self.proxy_index]) self.account_proxies[account] = proxy self.proxy_index = (self.proxy_index + 1) % len(self.proxies) return proxy def build_proxy_config(self, proxy=None): if not proxy: return None, None, None
if proxy.startswith("socks"): connector = ProxyConnector.from_url(proxy) return connector, None, None
elif proxy.startswith("http"): match = re.match(r"http://(.*?):(.*?)@(.*)", proxy) if match: username, password, host_port = match.groups() clean_url = f"http://{host_port}" auth = BasicAuth(username, password) return None, clean_url, auth else: return None, proxy, None
raise Exception("Unsupported Proxy Type.") def display_proxy(self, proxy_url=None): if not proxy_url: return "No Proxy"
proxy_url = re.sub(r"^(http|https|socks4|socks5)://", "", proxy_url)
if "@" in proxy_url: proxy_url = proxy_url.split("@", 1)[1]
return proxy_url def decode_token(self, email: str, type: str = "access"): try: if type == "refresh": token = self.accounts[email]["refreshToken"] else: token = self.accounts[email]["accessToken"]
header, payload, signature = token.split(".") decoded_payload = urlsafe_b64decode(payload + "==").decode("utf-8") parsed_payload = json.loads(decoded_payload) exp_time = parsed_payload["exp"] return exp_time except Exception as e: return None def mask_account(self, account): if "@" in account: local, domain = account.split('@', 1) mask_account = local[:3] + '*' * 3 + local[-3:] return f"{mask_account}@{domain}" def generate_device_id(self): return str(os.urandom(8).hex()) def generate_timestamp(self): return str(int(time.time()) * 1000) def initialize_headers(self, email: str): headers = { "Host": "prod.interlinklabs.ai", "Accept": "*/*", "Version": self.VERSION, "X-Platform": "android", "X-Date": self.generate_timestamp(), "X-Unique-Id": self.accounts[email]["deviceId"], "X-Model": "25053PC47G", "X-Brand": "POCO", "X-System-Name": "Android", "X-Device-Id": self.accounts[email]["deviceId"], "X-Bundle-Id": "org.ai.interlinklabs.interlinkId", "Accept-Encoding": "gzip, deflate", "User-Agent": "okhttp/4.12.0" }
return headers.copy() def get_next_run_time(self, anchor_minute=1, interval_hours=4): now = datetime.now(timezone.utc) today_base = now.replace(hour=0, minute=anchor_minute, second=0, microsecond=0)
slots = [today_base + timedelta(hours=interval_hours * i) for i in range(24 // interval_hours)]
for slot in slots: if slot > now: return slot
return today_base + timedelta(days=1)
def print_question(self): while True: try: print(f"{Fore.WHITE + Style.BRIGHT}1. Run With Proxy{Style.RESET_ALL}") print(f"{Fore.WHITE + Style.BRIGHT}2. Run Without Proxy{Style.RESET_ALL}") proxy_choice = int(input(f"{Fore.BLUE + Style.BRIGHT}Choose [1/2] -> {Style.RESET_ALL}").strip())
if proxy_choice in [1, 2]: proxy_type = ( "With" if proxy_choice == 1 else "Without" ) print(f"{Fore.GREEN + Style.BRIGHT}Run {proxy_type} Proxy Selected.{Style.RESET_ALL}") self.USE_PROXY = True if proxy_choice == 1 else False break else: print(f"{Fore.RED + Style.BRIGHT}Please enter either 1 or 2.{Style.RESET_ALL}") except ValueError: print(f"{Fore.RED + Style.BRIGHT}Invalid input. Enter a number (1 or 2).{Style.RESET_ALL}")
if self.USE_PROXY: while True: rotate_proxy = input(f"{Fore.BLUE + Style.BRIGHT}Rotate Invalid Proxy? [y/n] -> {Style.RESET_ALL}").strip() if rotate_proxy in ["y", "n"]: self.ROTATE_PROXY = True if rotate_proxy == "y" else False break else: print(f"{Fore.RED + Style.BRIGHT}Invalid input. Enter 'y' or 'n'.{Style.RESET_ALL}")
async def ensure_ok(self, response): if response.status >= 400: raise Exception(f"HTTP: {response.status}:{await response.text()}")
async def check_connection(self, proxy_url=None): url = "https://api.ipify.org?format=json" connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: async with ClientSession(connector=connector, timeout=ClientTimeout(total=15)) as session: async with session.get(url=url, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return True except (Exception, ClientResponseError) as e: self.log( f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Connection Not 200 OK {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(e)} {Style.RESET_ALL}" ) return None async def refresh_token(self, email: str, proxy_url=None, retries=5): url = f"{self.BASE_API}/api/v1/auth/token" for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Authorization"] = f"Bearer {self.accounts[email]['accessToken']}" headers["Content-Type"] = "application/json" payload = { "refreshToken": self.accounts[email]["refreshToken"] }
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.post(url=url, headers=headers, json=payload, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: await asyncio.sleep(5) continue self.log( f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Failed to Refreshing Tokens {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(e)} {Style.RESET_ALL}" )
return None async def user_info(self, email: str, proxy_url=None, retries=5): url = f"{self.BASE_API}/api/v1/auth/current-user-full" for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Authorization"] = f"Bearer {self.accounts[email]['accessToken']}"
params = { "include": "userInfo,token,isClaimable" }
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.get(url=url, headers=headers, params=params, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: await asyncio.sleep(5) continue self.log( f"{Fore.CYAN+Style.BRIGHT}User :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Failed to Fetch Info {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(e)} {Style.RESET_ALL}" )
return None async def claim_airdrop(self, email: str, proxy_url=None, retries=1): url = f"{self.BASE_API}/api/v1/token/claim-airdrop"
for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Authorization"] = f"Bearer {self.accounts[email]['accessToken']}" headers["Content-Type"] = "application/json"
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.post(url=url, headers=headers, json={}, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: await asyncio.sleep(5) continue self.log( f"{Fore.CYAN+Style.BRIGHT}Mining :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Not Claimed {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(e)} {Style.RESET_ALL}" )
return None async def group_mining_list(self, email: str, proxy_url=None, retries=1): url = f"{self.BASE_API}/api/v1/group-mining/get-list-group-mining"
for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Authorization"] = f"Bearer {self.accounts[email]['accessToken']}" headers["Content-Type"] = "application/json"
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.post(url=url, headers=headers, json={}, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: await asyncio.sleep(5) continue self.log( f"{Fore.CYAN+Style.BRIGHT}Group :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Failed to Fetch List {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(e)} {Style.RESET_ALL}" )
return None async def claim_group_mining(self, email: str, group_id: str, proxy_url=None, retries=1): url = f"{self.BASE_API}/api/v1/group-mining/claim-group-mining"
for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Authorization"] = f"Bearer {self.accounts[email]['accessToken']}" headers["Content-Type"] = "application/json"
payload = { "groupId": group_id }
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.post(url=url, headers=headers, json=payload, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: await asyncio.sleep(5) continue self.log( f"{Fore.CYAN+Style.BRIGHT}Group :{Style.RESET_ALL}" f"{Fore.BLUE+Style.BRIGHT} {group_id} {Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT}Failed to Claim{Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT} - {Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT}{str(e)}{Style.RESET_ALL}" )
return None async def synchronize_status(self, email: str, proxy_url=None, retries=1): url = f"{self.BASE_API}/api/v1/synchronize-curator"
for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Authorization"] = f"Bearer {self.accounts[email]['accessToken']}"
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.get(url=url, headers=headers, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: await asyncio.sleep(5) continue self.log( f"{Fore.CYAN+Style.BRIGHT}Metric :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Failed to Fetch Status {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(e)} {Style.RESET_ALL}" )
return None async def synchronize_metric(self, email: str, proxy_url=None, retries=1): url = f"{self.BASE_API}/api/v1/synchronize-curator"
for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Authorization"] = f"Bearer {self.accounts[email]['accessToken']}" headers["Content-Type"] = "application/json"
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.post(url=url, headers=headers, json={}, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: await asyncio.sleep(5) continue self.log( f"{Fore.CYAN+Style.BRIGHT}Metric :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Failed to Synchronized {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(e)} {Style.RESET_ALL}" )
return None async def process_check_connection(self, email: str, proxy_url=None): while True: if self.USE_PROXY: proxy_url = self.get_next_proxy_for_account(email)
self.log( f"{Fore.CYAN+Style.BRIGHT}Proxy :{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {self.display_proxy(proxy_url)} {Style.RESET_ALL}" )
is_valid = await self.check_connection(proxy_url) if is_valid: return True if self.ROTATE_PROXY: proxy_url = self.rotate_proxy_for_account(email) await asyncio.sleep(1) continue
return False async def process_check_tokens(self, email: str, proxy_url=None): access_exp_time = self.decode_token(email) if not access_exp_time: self.log( f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Invalid Access Token {Style.RESET_ALL}" ) return False
if int(time.time()) > access_exp_time:
refresh_exp_time = self.decode_token(email, "refresh") if not refresh_exp_time: self.log( f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Invalid Refresh Token {Style.RESET_ALL}" ) return False if int(time.time()) > refresh_exp_time: self.log( f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} Refresh Token Already Expired, Run 'setup.py' Again {Style.RESET_ALL}" ) return False
refresh = await self.refresh_token(email, proxy_url) if not refresh: return False
self.accounts[email]["accessToken"] = refresh.get("data", {}).get("accessToken") self.accounts[email]["refreshToken"] = refresh.get("data", {}).get("refreshToken")
account_data = [{ "email": email, "interlinkId": self.accounts[email]["interlinkId"], "passcode": self.accounts[email]["passcode"], "deviceId": self.accounts[email]["deviceId"], "tokens": { "accessToken": self.accounts[email]["accessToken"], "refreshToken": self.accounts[email]["refreshToken"] } }] self.save_accounts(account_data)
self.log( f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.GREEN+Style.BRIGHT} Tokens Refreshed {Style.RESET_ALL}" )
return True
async def process_accounts(self, email: str, proxy_url=None): is_ok = await self.process_check_connection(email, proxy_url) if not is_ok: return False
if self.USE_PROXY: proxy_url = self.get_next_proxy_for_account(email)
is_valid = await self.process_check_tokens(email, proxy_url) if not is_valid: return False
user = await self.user_info(email, proxy_url) if user: balance = user.get("data", {}).get("token", {}).get("interlinkGoldTokenAmount", 0)
self.log( f"{Fore.CYAN+Style.BRIGHT}Balance:{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {balance} $ITLG {Style.RESET_ALL}" )
is_claimable = user.get("data", {}).get("isClaimable", {}).get("isClaimable", False) if is_claimable: claim = await self.claim_airdrop(email, proxy_url) if claim: reward = claim.get("data") or "N/A"
self.log( f"{Fore.CYAN+Style.BRIGHT}Mining :{Style.RESET_ALL}" f"{Fore.GREEN+Style.BRIGHT} Claimed Successfully {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.CYAN+Style.BRIGHT} Reward: {Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT}{reward}{Style.RESET_ALL}" ) else: next_frame_ts = user.get("data", {}).get("isClaimable", {}).get("nextFrame", 0) formatted_next_frame = datetime.fromtimestamp(next_frame_ts / 1000).strftime('%x %X')
self.log( f"{Fore.CYAN+Style.BRIGHT}Mining :{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} Already Claimed {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.CYAN+Style.BRIGHT} Next Claim at: {Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT}{formatted_next_frame}{Style.RESET_ALL}" )
group_list = await self.group_mining_list(email, proxy_url) if group_list: groups = group_list.get("data", {}).get("groups", [])
if groups != []: claimable_groups = [ group for group in groups if group.get("canClaim") ]
if claimable_groups: selected_group = max( claimable_groups, key=lambda g: g.get("totalReward", 0) )
group_id = selected_group.get("groupId") reward = selected_group.get("totalReward")
claim = await self.claim_group_mining(email, group_id, proxy_url) if claim: self.log( f"{Fore.CYAN+Style.BRIGHT}Group :{Style.RESET_ALL}" f"{Fore.BLUE+Style.BRIGHT} {group_id} {Style.RESET_ALL}" f"{Fore.GREEN+Style.BRIGHT}Claimed{Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT} - {Style.RESET_ALL}" f"{Fore.CYAN+Style.BRIGHT}Reward:{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {reward} $ITLG {Style.RESET_ALL}" )
else: self.log( f"{Fore.CYAN+Style.BRIGHT}Group :{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} No Claimable Mining Found {Style.RESET_ALL}" )
else: self.log( f"{Fore.CYAN+Style.BRIGHT}Group :{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} There're No Groups Yet {Style.RESET_ALL}" )
metric = await self.synchronize_status(email, proxy_url) if metric:
can_click = metric.get("data", {}).get("canClick") if can_click:
click = await self.synchronize_metric(email, proxy_url) if click: self.log( f"{Fore.CYAN+Style.BRIGHT}Metric :{Style.RESET_ALL}" f"{Fore.GREEN+Style.BRIGHT} Synchronized {Style.RESET_ALL}" )
else: self.log( f"{Fore.CYAN+Style.BRIGHT}Metric :{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} Already Synchronized {Style.RESET_ALL}" ) async def main(self): try: accounts = self.load_accounts() if not accounts: self.log(f"{Fore.RED}No Accounts Loaded.{Style.RESET_ALL}") return
self.print_question()
while True: self.clear_terminal() self.welcome() self.log( f"{Fore.GREEN + Style.BRIGHT}Account's Total: {Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT}{len(accounts)}{Style.RESET_ALL}" )
if self.USE_PROXY: self.load_proxies() separator = "=" * 28 for idx, account in enumerate(accounts, start=1): email = account.get("email") interlink_id = account.get("interlinkId") passcode = account.get("passcode") device_id = account.get("deviceId") tokens = account.get("tokens", {}) access_token = tokens.get("accessToken") refresh_token = tokens.get("refreshToken")
if device_id is None: device_id = self.generate_device_id()
account_data = [{ "email": email, "interlinkId": interlink_id, "passcode": passcode, "deviceId": device_id, "tokens": { "accessToken": access_token, "refreshToken": refresh_token } }] self.save_accounts(account_data)
self.log( f"{Fore.CYAN + Style.BRIGHT}{separator}[{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} {idx} {Style.RESET_ALL}" f"{Fore.CYAN + Style.BRIGHT}Of{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} {len(accounts)} {Style.RESET_ALL}" f"{Fore.CYAN + Style.BRIGHT}]{separator}{Style.RESET_ALL}" )
if "@" not in email or not interlink_id or not passcode or not device_id or not access_token or not refresh_token: self.log( f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Invalid Account Data {Style.RESET_ALL}" ) continue
self.log( f"{Fore.CYAN+Style.BRIGHT}Account:{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {self.mask_account(email)} {Style.RESET_ALL}" )
self.accounts[email] = { "interlinkId": interlink_id, "passcode": passcode, "deviceId": device_id, "accessToken": access_token, "refreshToken": refresh_token } await self.process_accounts(email) await asyncio.sleep(random.uniform(2.0, 3.0))
self.log(f"{Fore.CYAN + Style.BRIGHT}={Style.RESET_ALL}"*67)
next_run = self.get_next_run_time(anchor_minute=1, interval_hours=4)
while True: now = datetime.now(timezone.utc) remaining = (next_run - now).total_seconds()
if remaining <= 0: break
formatted_time = self.format_seconds(remaining)
print( f"{Fore.CYAN+Style.BRIGHT}[ Wait for{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {formatted_time} {Style.RESET_ALL}" f"{Fore.CYAN+Style.BRIGHT}]{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} | {Style.RESET_ALL}" f"{Fore.BLUE+Style.BRIGHT}All Accounts Have Been Processed...{Style.RESET_ALL}", end="\r" ) await asyncio.sleep(1)
except Exception as e: self.log(f"{Fore.RED+Style.BRIGHT}Error: {e}{Style.RESET_ALL}") raise e
if __name__ == "__main__": try: bot = Interlink() asyncio.run(bot.main()) except KeyboardInterrupt: print( f"{Fore.CYAN + Style.BRIGHT}[ {datetime.now().strftime('%x %X')} ]{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}" f"{Fore.RED + Style.BRIGHT}[ EXIT ] Interlink - BOT{Style.RESET_ALL} " ) sys.exit(0)123ip:port # Default Protcol HTTP.protocol://ip:portprotocol://user:pass@ip:port1234aiohttp==3.11.10aiohttp-socks==0.9.1python-dotenv==1.0.1colorama==0.4.6123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455from aiohttp import ( ClientResponseError, ClientSession, ClientTimeout, BasicAuth)from aiohttp_socks import ProxyConnectorfrom datetime import datetimefrom colorama import *import asyncio, random, time, json, sys, re, os
class Interlink: def __init__(self) -> None: self.BASE_API = "https://prod.interlinklabs.ai" self.VERSION = str(os.getenv("APP_VERSION", "5.0.5"))
self.USE_PROXY = False self.ROTATE_PROXY = False
self.proxies = [] self.proxy_index = 0 self.account_proxies = {} self.accounts = {}
def clear_terminal(self): os.system('cls' if os.name == 'nt' else 'clear')
def log(self, message): print( f"{Fore.CYAN + Style.BRIGHT}[ {datetime.now().strftime('%x %X')} ]{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}{message}", flush=True )
def log_status(self, action, status, message="", error=None): if status == "success": self.log( f"{Fore.CYAN+Style.BRIGHT}Action :{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {action} {Style.RESET_ALL}" f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.GREEN+Style.BRIGHT} Success {Style.RESET_ALL}" f"{(Fore.MAGENTA+Style.BRIGHT + '- ' + Style.RESET_ALL + Fore.WHITE+Style.BRIGHT + message + Style.RESET_ALL) if message else ''}" ) elif status == "failed": self.log( f"{Fore.CYAN+Style.BRIGHT}Action :{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {action} {Style.RESET_ALL}" f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.RED+Style.BRIGHT} Failed {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} {str(error)} {Style.RESET_ALL}" ) elif status == "retry": self.log( f"{Fore.CYAN+Style.BRIGHT}Action :{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {action} {Style.RESET_ALL}" f"{Fore.CYAN+Style.BRIGHT}Status :{Style.RESET_ALL}" f"{Fore.YELLOW+Style.BRIGHT} Retrying {Style.RESET_ALL}" f"{Fore.MAGENTA+Style.BRIGHT}-{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {message} {Style.RESET_ALL}" )
def welcome(self): print( f""" {Fore.GREEN + Style.BRIGHT}Interlink Labs {Fore.BLUE + Style.BRIGHT}Auto BOT """ f""" {Fore.GREEN + Style.BRIGHT}Rey? {Fore.YELLOW + Style.BRIGHT}<INI WATERMARK> """ )
def format_seconds(self, seconds): hours, remainder = divmod(seconds, 3600) minutes, seconds = divmod(remainder, 60) return f"{int(hours):02}:{int(minutes):02}:{int(seconds):02}" def load_accounts(self): filename = "accounts.json" try: if not os.path.exists(filename): self.log(f"{Fore.RED}File {filename} Not Found.{Style.RESET_ALL}") return
with open(filename, 'r') as file: data = json.load(file) if isinstance(data, list): return data return [] except json.JSONDecodeError: return [] def save_accounts(self, new_accounts): filename = "accounts.json" try: if os.path.exists(filename) and os.path.getsize(filename) > 0: with open(filename, 'r') as file: existing_accounts = json.load(file) else: existing_accounts = []
account_dict = {acc["email"]: acc for acc in existing_accounts}
for new_acc in new_accounts: email = new_acc["email"]
if email in account_dict: account_dict[email].update(new_acc) else: account_dict[email] = new_acc
updated_accounts = list(account_dict.values())
with open(filename, 'w') as file: json.dump(updated_accounts, file, indent=4)
self.log_status("Save Accounts", "success", "Accounts saved to file")
except Exception as e: self.log_status("Save Accounts", "failed", error=e) return [] def load_proxies(self): filename = "proxy.txt" try: if not os.path.exists(filename): self.log(f"{Fore.RED + Style.BRIGHT}File {filename} Not Found.{Style.RESET_ALL}") return with open(filename, 'r') as f: self.proxies = [line.strip() for line in f.read().splitlines() if line.strip()] if not self.proxies: self.log(f"{Fore.RED + Style.BRIGHT}No Proxies Found.{Style.RESET_ALL}") return
self.log( f"{Fore.GREEN + Style.BRIGHT}Proxies Total : {Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT}{len(self.proxies)}{Style.RESET_ALL}" ) except Exception as e: self.log(f"{Fore.RED + Style.BRIGHT}Failed To Load Proxies: {e}{Style.RESET_ALL}") self.proxies = []
def check_proxy_schemes(self, proxies): schemes = ["http://", "https://", "socks4://", "socks5://"] if any(proxies.startswith(scheme) for scheme in schemes): return proxies return f"http://{proxies}"
def get_next_proxy_for_account(self, account): if account not in self.account_proxies: if not self.proxies: return None proxy = self.check_proxy_schemes(self.proxies[self.proxy_index]) self.account_proxies[account] = proxy self.proxy_index = (self.proxy_index + 1) % len(self.proxies) return self.account_proxies[account]
def rotate_proxy_for_account(self, account): if not self.proxies: return None proxy = self.check_proxy_schemes(self.proxies[self.proxy_index]) self.account_proxies[account] = proxy self.proxy_index = (self.proxy_index + 1) % len(self.proxies) return proxy def build_proxy_config(self, proxy=None): if not proxy: return None, None, None
if proxy.startswith("socks"): connector = ProxyConnector.from_url(proxy) return connector, None, None
elif proxy.startswith("http"): match = re.match(r"http://(.*?):(.*?)@(.*)", proxy) if match: username, password, host_port = match.groups() clean_url = f"http://{host_port}" auth = BasicAuth(username, password) return None, clean_url, auth else: return None, proxy, None
raise Exception("Unsupported Proxy Type.") def display_proxy(self, proxy_url=None): if not proxy_url: return "No Proxy"
proxy_url = re.sub(r"^(http|https|socks4|socks5)://", "", proxy_url)
if "@" in proxy_url: proxy_url = proxy_url.split("@", 1)[1]
return proxy_url def mask_account(self, account): if "@" in account: local, domain = account.split('@', 1) mask_account = local[:3] + '*' * 3 + local[-3:] return f"{mask_account}@{domain}" def generate_device_id(self): return str(os.urandom(8).hex()) def generate_timestamp(self): return str(int(time.time()) * 1000) def initialize_headers(self, email: str): headers = { "Host": "prod.interlinklabs.ai", "Accept": "*/*", "Version": self.VERSION, "X-Platform": "android", "X-Date": self.generate_timestamp(), "X-Unique-Id": self.accounts[email]["deviceId"], "X-Model": "25053PC47G", "X-Brand": "POCO", "X-System-Name": "Android", "X-Device-Id": self.accounts[email]["deviceId"], "X-Bundle-Id": "org.ai.interlinklabs.interlinkId", "Accept-Encoding": "gzip, deflate", "User-Agent": "okhttp/4.12.0" }
return headers.copy()
def print_question(self): while True: try: print(f"{Fore.WHITE + Style.BRIGHT}1. Run With Proxy{Style.RESET_ALL}") print(f"{Fore.WHITE + Style.BRIGHT}2. Run Without Proxy{Style.RESET_ALL}") proxy_choice = int(input(f"{Fore.BLUE + Style.BRIGHT}Choose [1/2] -> {Style.RESET_ALL}").strip())
if proxy_choice in [1, 2]: proxy_type = ( "With" if proxy_choice == 1 else "Without" ) print(f"{Fore.GREEN + Style.BRIGHT}Run {proxy_type} Proxy Selected.{Style.RESET_ALL}") self.USE_PROXY = True if proxy_choice == 1 else False break else: print(f"{Fore.RED + Style.BRIGHT}Please enter either 1 or 2.{Style.RESET_ALL}") except ValueError: print(f"{Fore.RED + Style.BRIGHT}Invalid input. Enter a number (1 or 2).{Style.RESET_ALL}")
if self.USE_PROXY: while True: rotate_proxy = input(f"{Fore.BLUE + Style.BRIGHT}Rotate Invalid Proxy? [y/n] -> {Style.RESET_ALL}").strip() if rotate_proxy in ["y", "n"]: self.ROTATE_PROXY = True if rotate_proxy == "y" else False break else: print(f"{Fore.RED + Style.BRIGHT}Invalid input. Enter 'y' or 'n'.{Style.RESET_ALL}")
async def ensure_ok(self, response): if response.status >= 400: raise Exception(f"HTTP: {response.status}:{await response.text()}")
async def check_connection(self, proxy_url=None): url = "https://api.ipify.org?format=json" connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: async with ClientSession(connector=connector, timeout=ClientTimeout(total=15)) as session: async with session.get(url=url, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) self.log_status("Check Connection", "success", "Connection OK") return True except (Exception, ClientResponseError) as e: self.log_status("Check Connection", "failed", error=e) return None async def request_otp(self, email: str, proxy_url=None, retries=5): url = f"{self.BASE_API}/api/v1/auth/send-otp-email-verify-login"
for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Content-Type"] = "application/json" payload = { "loginId": self.accounts[email]["interlinkId"], "passcode": self.accounts[email]["passcode"], "email": email, "deviceId": self.accounts[email]["deviceId"] }
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.post(url=url, headers=headers, json=payload, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) self.log_status("Request OTP", "success", "OTP request sent") return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: self.log_status("Request OTP", "retry", f"Attempt {attempt + 1}/{retries}") await asyncio.sleep(5) continue else: self.log_status("Request OTP", "failed", error=e) return None async def verify_otp(self, email: str, otp_code: str, proxy_url=None, retries=5): url = f"{self.BASE_API}/api/v1/auth/check-otp-email-verify-login?v=2" for attempt in range(retries): connector, proxy, proxy_auth = self.build_proxy_config(proxy_url) try: headers = self.initialize_headers(email) headers["Content-Type"] = "application/json" payload = { "loginId": self.accounts[email]["interlinkId"], "otp": otp_code, "deviceId": self.accounts[email]["deviceId"] }
async with ClientSession(connector=connector, timeout=ClientTimeout(total=60)) as session: async with session.post(url=url, headers=headers, json=payload, proxy=proxy, proxy_auth=proxy_auth) as response: await self.ensure_ok(response) self.log_status("Verify OTP", "success", "OTP verified successfully") return await response.json() except (Exception, ClientResponseError) as e: if attempt < retries - 1: self.log_status("Verify OTP", "retry", f"Attempt {attempt + 1}/{retries}") await asyncio.sleep(5) continue else: self.log_status("Verify OTP", "failed", error=e) return None async def process_check_connection(self, email: str, proxy_url=None): while True: if self.USE_PROXY: proxy_url = self.get_next_proxy_for_account(email)
self.log( f"{Fore.CYAN+Style.BRIGHT}Proxy :{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {self.display_proxy(proxy_url)} {Style.RESET_ALL}" )
is_valid = await self.check_connection(proxy_url) if is_valid: return True if self.ROTATE_PROXY: proxy_url = self.rotate_proxy_for_account(email) await asyncio.sleep(1) continue
return False
async def process_accounts(self, email: str, proxy_url=None): is_valid = await self.process_check_connection(email, proxy_url) if not is_valid: self.log_status("Process Account", "failed", error="Connection check failed") return
if self.USE_PROXY: proxy_url = self.get_next_proxy_for_account(email)
request = await self.request_otp(email, proxy_url) if not request: return
timestamp = ( f"{Fore.CYAN + Style.BRIGHT}[ {datetime.now().strftime('%x %X')} ]{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}" f"{Fore.CYAN + Style.BRIGHT}Action :{Style.RESET_ALL}" ) otp_code = input(f"{timestamp}{Fore.BLUE + Style.BRIGHT} Enter OTP Code -> {Style.RESET_ALL}")
verify = await self.verify_otp(email, otp_code, proxy_url) if not verify: return
access_token = verify.get("data", {}).get("accessToken") refresh_token = verify.get("data", {}).get("refreshToken")
account_data = [{ "email": email, "interlinkId": self.accounts[email]["interlinkId"], "passcode": self.accounts[email]["passcode"], "deviceId": self.accounts[email]["deviceId"], "tokens": { "accessToken": access_token, "refreshToken": refresh_token } }] self.save_accounts(account_data) self.log_status("Process Account", "success", f"Account {self.mask_account(email)} processed successfully") async def main(self): try: accounts = self.load_accounts() if not accounts: print(f"{Fore.YELLOW + Style.BRIGHT}No Accounts Loaded{Style.RESET_ALL}") return self.print_question() self.clear_terminal() self.welcome()
if self.USE_PROXY: self.load_proxies()
separator = "=" * 27 for idx, account in enumerate(accounts, start=1): email = account.get("email") interlink_id = account.get("interlinkId") passcode = account.get("passcode") device_id = account.get("deviceId")
if device_id is None: device_id = self.generate_device_id()
if "@" not in email or not interlink_id or not passcode or not device_id: self.log_status("Account Validation", "failed", error="Invalid account format") continue
self.log( f"{Fore.CYAN + Style.BRIGHT}{separator}[{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} {idx} {Style.RESET_ALL}" f"{Fore.CYAN + Style.BRIGHT}Of{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} {len(accounts)} {Style.RESET_ALL}" f"{Fore.CYAN + Style.BRIGHT}]{separator}{Style.RESET_ALL}" )
self.log( f"{Fore.CYAN+Style.BRIGHT}Email :{Style.RESET_ALL}" f"{Fore.WHITE+Style.BRIGHT} {self.mask_account(email)} {Style.RESET_ALL}" )
if email not in self.accounts: self.accounts[email] = { "interlinkId": interlink_id, "passcode": passcode, "deviceId": device_id }
await self.process_accounts(email) await asyncio.sleep(random.uniform(2.0, 3.0))
except Exception as e: self.log_status("Main Process", "failed", error=e) raise e
if __name__ == "__main__": try: bot = Interlink() asyncio.run(bot.main()) except KeyboardInterrupt: print( f"{Fore.CYAN + Style.BRIGHT}[ {datetime.now().strftime('%x %X')} ]{Style.RESET_ALL}" f"{Fore.WHITE + Style.BRIGHT} | {Style.RESET_ALL}" f"{Fore.RED + Style.BRIGHT}[ EXIT ] Interlink Labs - BOT{Style.RESET_ALL} ", ) sys.exit(0)accounts.jsonAdded+12
bot.pyAdded+769
proxy.txtAdded+3
requirements.txtAdded+4
setup.pyAdded+455