Skip to content

Commit b02103a

Browse files
committed
new methods
1 parent 0f2ae88 commit b02103a

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

MacAttack.pyw

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,32 @@ from PyQt5.QtWidgets import (QAbstractItemView, QApplication, QCheckBox,
3131
from requests.adapters import HTTPAdapter
3232
from requests.packages.urllib3.util.retry import Retry
3333

34-
logging.basicConfig(level=logging.DEBUG)
34+
#logging.basicConfig(level=logging.DEBUG)
3535

3636
def get_token(session, url, mac_address, proxies=None):
3737
try:
38+
# Set up retry strategy
39+
retry_strategy = Retry(
40+
total=5, # Number of retries
41+
backoff_factor=1, # Time between retries increases exponentially
42+
status_forcelist=[500, 502, 503, 504], # Retry on these HTTP status codes
43+
allowed_methods=["GET", "POST"] # Retry these HTTP methods
44+
)
45+
46+
# Set up adapter with the retry strategy
47+
adapter = HTTPAdapter(max_retries=retry_strategy)
48+
session.mount("http://", adapter)
49+
session.mount("https://", adapter)
50+
3851
serialnumber = hashlib.md5(mac_address.encode()).hexdigest().upper()
3952
sn = serialnumber[0:13]
4053
device_id = hashlib.sha256(sn.encode()).hexdigest().upper()
4154
device_id2 = hashlib.sha256(mac_address.encode()).hexdigest().upper()
4255
hw_version_2 = hashlib.sha1(mac_address.encode()).hexdigest()
4356
signature_string = f'{sn}{mac_address}'
4457
signature = hashlib.sha256(signature_string.encode()).hexdigest().upper()
45-
metrics = {'mac': mac_address, 'sn': sn, 'type': 'STB', 'model': 'MAG250', 'uid': device_id, 'random': '0'}
46-
58+
metrics = {'mac': mac_address, 'sn': sn, 'type': 'STB', 'model': 'MAG250', 'uid': device_id, 'random': '0'}
59+
4760
headers = {
4861
'User-Agent': 'Mozilla/5.0 (QtEmbedded; U; Linux; C) AppleWebKit/533.3 (KHTML, like Gecko) MAG200 stbapp ver: 2 rev: 250 Safari/533.3',
4962
'Accept-Encoding': 'gzip, deflate, zstd',
@@ -65,7 +78,7 @@ def get_token(session, url, mac_address, proxies=None):
6578
}
6679

6780
# Send GET request to fetch the version.js file with optional proxy
68-
response = requests.get(f"{url}/c/version.js", headers=headers, cookies=cookies, proxies=proxies)
81+
response = session.get(f"{url}/c/version.js", headers=headers, cookies=cookies, proxies=proxies)
6982

7083
# Extract the version number from the response body
7184
version = re.search(r"var ver = '(.*)';", response.text)
@@ -77,7 +90,7 @@ def get_token(session, url, mac_address, proxies=None):
7790
portal_version = "5.0"
7891
logging.debug("Portal version not found.")
7992

80-
url = f"{url}/portal.php" #add portal.php for next 2 requests
93+
url = f"{url}/portal.php" # Add portal.php for next 2 requests
8194

8295
# Data for the first request (to get the token)
8396
data = {
@@ -88,7 +101,7 @@ def get_token(session, url, mac_address, proxies=None):
88101
}
89102

90103
# Step 1: Send the first request to get the token with optional proxy
91-
response = requests.post(url, headers=headers, cookies=cookies, data=data, proxies=proxies)
104+
response = session.post(url, headers=headers, cookies=cookies, data=data, proxies=proxies)
92105

93106
# Check if the response is successful
94107
if response.status_code == 200:
@@ -130,15 +143,15 @@ def get_token(session, url, mac_address, proxies=None):
130143
}
131144

132145
# Send the second request with optional proxy
133-
response = requests.post(url, headers=headers, cookies=cookies, data=data, proxies=proxies)
146+
response = session.post(url, headers=headers, cookies=cookies, data=data, proxies=proxies)
134147

135148
# Output the result of the second request
136149
logging.debug("Response Status Code:", response.status_code)
137150
logging.debug("Response Text:")
138151
logging.debug(response.text)
139-
152+
140153
return token
141-
154+
142155
except Exception as e:
143156
logging.error(f"Unexpected error in get_token: {e}")
144157
return None
@@ -1808,8 +1821,9 @@ class MacAttack(QMainWindow):
18081821
Settings_layout.addWidget(self.moreoutput_checkbox)
18091822

18101823
# single output file
1811-
self.singleoutputfile_checkbox = QCheckBox("Only create 1 output file\n(Output logs will be saved in the file MacAttackOutput.txt.)")
1824+
self.singleoutputfile_checkbox = QCheckBox("Create a single output file.\n(Output will be saved in MacAttackOutput.txt.)")
18121825
Settings_layout.addWidget(self.singleoutputfile_checkbox)
1826+
self.singleoutputfile_checkbox.setChecked(True) # Set the checkbox to be checked by default
18131827
Settings_layout.addSpacing(15) # Adds space
18141828

18151829
# Ludicrous speed checkbox
@@ -1898,7 +1912,7 @@ class MacAttack(QMainWindow):
18981912

18991913
# IPTV link input
19001914
self.iptv_link_label = QLabel("IPTV link:")
1901-
self.iptv_link_entry = QLineEdit("")
1915+
self.iptv_link_entry = QLineEdit("http://evilvir.us.streamtv.to:8080/c/")
19021916
combined_layout.addWidget(self.iptv_link_label)
19031917
combined_layout.addWidget(self.iptv_link_entry)
19041918

@@ -2162,9 +2176,7 @@ class MacAttack(QMainWindow):
21622176
self.SaveTheDay()
21632177

21642178
def RandomMacGenerator(self, prefix="00:1A:79:"):
2165-
# Create random MACs. Purely for mischief. Don't tell anyone.
2166-
return "00:1A:79:C7:DC:83"
2167-
#return f"{prefix}{random.randint(0, 255):02X}:{random.randint(0, 255):02X}:{random.randint(0, 255):02X}"
2179+
return f"{prefix}{random.randint(0, 255):02X}:{random.randint(0, 255):02X}:{random.randint(0, 255):02X}"
21682180

21692181
def macattack_update_proxy_textbox(self, new_text):
21702182
# Slot to handle signal
@@ -2246,8 +2258,15 @@ class MacAttack(QMainWindow):
22462258

22472259
if res.text:
22482260
data = json.loads(res.text)
2249-
#tok = data.get('js', {}).get('token') # Safely access token to prevent KeyError
2250-
token = get_token
2261+
token = data.get('js', {}).get('token') # Safely access token to prevent KeyError
2262+
logging.debug(f"TOKEN: {token}")
2263+
2264+
if token:
2265+
base_token = token
2266+
token = get_token(s, url, mac, proxies) #activates token for some providers
2267+
logging.debug(f"Clean TOKEN: {token}")
2268+
if not token:
2269+
token = base_token
22512270
url2 = f"{self.base_url}/portal.php?type=account_info&action=get_main_info&JsHttpRequest=1-xml"
22522271
headers = {
22532272
"User-Agent": "Mozilla/5.0 (QtEmbedded; U; Linux; C) AppleWebKit/533.3 (KHTML, like Gecko) MAG200 stbapp ver: 2 rev: 250 Safari/533.3",

0 commit comments

Comments
 (0)