-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added emergency method of obtaining a license
- Loading branch information
Showing
2 changed files
with
43 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
from .sec_email_api import * | ||
|
||
import time | ||
import re | ||
|
||
class EsetKeygen: | ||
def __init__(self, registered_email_obj: SecEmail, driver): | ||
|
@@ -20,8 +19,10 @@ def sendRequestForKey(self): | |
console_log('Waiting for permission to request...', INFO) | ||
uCE(self.driver, f"return {CLICK_WITH_BOOL}({GET_EBAV}('ion-card', 'robot', 'license-fork-slide-trial-license-card'))") | ||
console_log('Access to the request was open!', OK) | ||
uCE(self.driver, f"return {CLICK_WITH_BOOL}({GET_EBAV}('ion-button', 'robot', 'license-fork-slide-continue-button'))") | ||
|
||
try: | ||
uCE(self.driver, f"return {CLICK_WITH_BOOL}({GET_EBAV}('ion-button', 'robot', 'license-fork-slide-continue-button'))") | ||
except: | ||
raise RuntimeError('Access to the request is denied, try again later!') | ||
console_log('\nPlatforms loading...', INFO) | ||
uCE(self.driver, f"return {CLICK_WITH_BOOL}({GET_EBAV}('ion-card', 'robot', 'device-protect-os-card-Windows'))") | ||
console_log('Windows platform is selected!', OK) | ||
|
@@ -36,17 +37,42 @@ def sendRequestForKey(self): | |
def getLicenseData(self): | ||
exec_js = self.driver.execute_script | ||
uCE = untilConditionExecute | ||
self.driver.get('https://home.eset.com/subscriptions') | ||
console_log('\nLicense uploads...', INFO) | ||
uCE(self.driver, f"return typeof {GET_EBAV}('ion-button', 'robot', 'license-list-open-detail-page-btn') === 'object'") | ||
license_tag = exec_js(f"return {GET_EBAV}('ion-button', 'robot', 'license-list-open-detail-page-btn').href") | ||
console_log('License is uploaded!', OK) | ||
|
||
console_log('\nGetting information from the license...', INFO) | ||
self.driver.get(f"https://home.eset.com{license_tag}") | ||
uCE(self.driver, f"return typeof {GET_EBAV}('div', 'class', 'LicenseDetailInfo') === 'object'") | ||
license_name = exec_js(f"return {GET_EBAV}('p', 'data-r', 'license-detail-product-name').innerText") | ||
license_out_date = exec_js(f"return {GET_EBAV}('p', 'data-r', 'license-detail-license-model-additional-info').innerText") | ||
license_key = exec_js(f"return {GET_EBAV}('p', 'data-r', 'license-detail-license-key').innerText") | ||
console_log('Information successfully received!', OK) | ||
try: # first method (main) | ||
console_log('\n[V1] License uploads...', INFO) | ||
self.driver.get('https://home.eset.com/subscriptions') | ||
uCE(self.driver, f"return typeof {GET_EBAV}('ion-button', 'robot', 'license-list-open-detail-page-btn') === 'object'") | ||
license_tag = exec_js(f"return {GET_EBAV}('ion-button', 'robot', 'license-list-open-detail-page-btn').href") | ||
console_log('[V1] License is uploaded!', OK) | ||
console_log('\n[V1] Getting information from the license...', INFO) | ||
self.driver.get(f"https://home.eset.com{license_tag}") | ||
uCE(self.driver, f"return typeof {GET_EBAV}('div', 'class', 'LicenseDetailInfo') === 'object'") | ||
license_name = exec_js(f"return {GET_EBAV}('p', 'data-r', 'license-detail-product-name').innerText") | ||
license_out_date = exec_js(f"return {GET_EBAV}('p', 'data-r', 'license-detail-license-model-additional-info').innerText") | ||
license_key = exec_js(f"return {GET_EBAV}('p', 'data-r', 'license-detail-license-key').innerText") | ||
console_log('[V1] Information successfully received!', OK) | ||
except: # second method (emergency) | ||
console_log('[V1] Algorithm error, attempt through a new algorithm...', ERROR) | ||
console_log('\n[V2] License uploads...', INFO) | ||
for _ in range(DEFAULT_MAX_ITER*2): | ||
last_message = self.email_obj.read_email()[0] | ||
last_message_id = last_message['id'] | ||
if last_message['from'] == '[email protected]': | ||
last_message_body = self.email_obj.get_message(last_message_id)['body'] | ||
f = open('license.html', 'wb') | ||
f.write(last_message_body.encode('utf-8')) | ||
f.close() | ||
break | ||
time.sleep(DEFAULT_DELAY*2) | ||
console_log('[V2] License is uploaded!', OK) | ||
console_log('\n[V2] Getting information from the license...', INFO) | ||
self.driver.get(f"file://{os.getcwd()}/license.html") | ||
uCE(self.driver, f"return {GET_EBCN}('contents').length > 20") | ||
license_name = exec_js(f"return {GET_EBCN}('contents')[4].innerText") | ||
license_out_date = exec_js(f"return {GET_EBCN}('contents')[8].innerText") | ||
license_key = exec_js(f"return {GET_EBCN}('contents')[6].innerText") | ||
console_log('[V2] Information successfully received!', OK) | ||
try: | ||
os.remove('license.html') | ||
except: | ||
pass | ||
return license_name, license_out_date, license_key |