absfuyu 3.1.1__py3-none-any.whl → 3.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of absfuyu might be problematic. Click here for more details.
- absfuyu/__init__.py +3 -10
- absfuyu/__main__.py +5 -250
- absfuyu/cli/__init__.py +51 -0
- absfuyu/cli/color.py +24 -0
- absfuyu/cli/config_group.py +56 -0
- absfuyu/cli/do_group.py +76 -0
- absfuyu/cli/game_group.py +109 -0
- absfuyu/config/__init__.py +117 -100
- absfuyu/config/config.json +0 -7
- absfuyu/core.py +5 -66
- absfuyu/everything.py +7 -9
- absfuyu/extensions/beautiful.py +30 -23
- absfuyu/extensions/dev/__init__.py +11 -8
- absfuyu/extensions/dev/password_hash.py +4 -2
- absfuyu/extensions/dev/passwordlib.py +7 -5
- absfuyu/extensions/dev/project_starter.py +4 -2
- absfuyu/extensions/dev/shutdownizer.py +148 -0
- absfuyu/extensions/extra/__init__.py +1 -2
- absfuyu/extensions/extra/data_analysis.py +182 -107
- absfuyu/fun/WGS.py +50 -26
- absfuyu/fun/__init__.py +6 -7
- absfuyu/fun/tarot.py +1 -1
- absfuyu/game/__init__.py +75 -81
- absfuyu/game/game_stat.py +36 -0
- absfuyu/game/sudoku.py +41 -48
- absfuyu/game/tictactoe.py +303 -548
- absfuyu/game/wordle.py +56 -47
- absfuyu/general/__init__.py +17 -7
- absfuyu/general/content.py +16 -15
- absfuyu/general/data_extension.py +282 -90
- absfuyu/general/generator.py +67 -67
- absfuyu/general/human.py +74 -78
- absfuyu/logger.py +94 -68
- absfuyu/pkg_data/__init__.py +29 -25
- absfuyu/py.typed +0 -0
- absfuyu/sort.py +61 -47
- absfuyu/tools/__init__.py +0 -1
- absfuyu/tools/converter.py +80 -62
- absfuyu/tools/keygen.py +62 -67
- absfuyu/tools/obfuscator.py +57 -53
- absfuyu/tools/stats.py +24 -24
- absfuyu/tools/web.py +10 -9
- absfuyu/util/__init__.py +71 -33
- absfuyu/util/api.py +53 -43
- absfuyu/util/json_method.py +25 -27
- absfuyu/util/lunar.py +20 -24
- absfuyu/util/path.py +362 -241
- absfuyu/util/performance.py +217 -135
- absfuyu/util/pkl.py +8 -8
- absfuyu/util/zipped.py +17 -19
- absfuyu/version.py +160 -147
- absfuyu-3.3.3.dist-info/METADATA +124 -0
- absfuyu-3.3.3.dist-info/RECORD +59 -0
- {absfuyu-3.1.1.dist-info → absfuyu-3.3.3.dist-info}/WHEEL +1 -2
- {absfuyu-3.1.1.dist-info → absfuyu-3.3.3.dist-info}/entry_points.txt +1 -0
- {absfuyu-3.1.1.dist-info → absfuyu-3.3.3.dist-info/licenses}/LICENSE +1 -1
- absfuyu/extensions/dev/pkglib.py +0 -98
- absfuyu/game/tictactoe2.py +0 -318
- absfuyu-3.1.1.dist-info/METADATA +0 -215
- absfuyu-3.1.1.dist-info/RECORD +0 -55
- absfuyu-3.1.1.dist-info/top_level.txt +0 -1
absfuyu/tools/keygen.py
CHANGED
|
@@ -5,16 +5,13 @@ Mod7 product key generator (90's)
|
|
|
5
5
|
|
|
6
6
|
This is for educational and informative purposes only.
|
|
7
7
|
|
|
8
|
-
Version: 2.0.
|
|
9
|
-
Date updated:
|
|
8
|
+
Version: 2.0.2
|
|
9
|
+
Date updated: 05/04/2024 (dd/mm/yyyy)
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
# Module level
|
|
14
13
|
###########################################################################
|
|
15
|
-
__all__ = [
|
|
16
|
-
"Keygen"
|
|
17
|
-
]
|
|
14
|
+
__all__ = ["Keygen"]
|
|
18
15
|
|
|
19
16
|
|
|
20
17
|
# Library
|
|
@@ -26,88 +23,84 @@ import random
|
|
|
26
23
|
###########################################################################
|
|
27
24
|
class Keygen:
|
|
28
25
|
"""Key generator"""
|
|
26
|
+
|
|
29
27
|
@staticmethod
|
|
30
28
|
def _is_mod7(text: str) -> bool:
|
|
31
29
|
"""
|
|
32
30
|
Check if sum of elements in a string is divisible by 7
|
|
33
31
|
|
|
34
|
-
text: number in str type to check
|
|
32
|
+
:param text: number in str type to check
|
|
35
33
|
"""
|
|
36
|
-
text = str(text)
|
|
34
|
+
text = str(text) # Safety convert
|
|
37
35
|
try:
|
|
38
36
|
res = sum(map(int, text)) % 7
|
|
39
37
|
# logger.debug(f"Sum value: {res}")
|
|
40
38
|
return res == 0
|
|
41
|
-
except:
|
|
42
|
-
raise ValueError("Invalid string")
|
|
43
|
-
|
|
39
|
+
except Exception:
|
|
40
|
+
raise ValueError("Invalid string") # noqa: B904
|
|
41
|
+
|
|
44
42
|
@staticmethod
|
|
45
|
-
def _mod7_gen(
|
|
46
|
-
num_of_digits: int,
|
|
47
|
-
*,
|
|
48
|
-
fillchar: str = "0"
|
|
49
|
-
) -> str:
|
|
43
|
+
def _mod7_gen(num_of_digits: int, *, fillchar: str = "0") -> str:
|
|
50
44
|
"""
|
|
51
45
|
Generate a number with desired length that is divisible by 7
|
|
52
46
|
|
|
53
|
-
Parameters
|
|
54
|
-
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
55
49
|
num_of_digits : int
|
|
56
50
|
Length of number
|
|
57
51
|
|
|
58
52
|
fillchar : str
|
|
59
53
|
filled character when `len(generated number)` < `num_of_digits`
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
63
57
|
str:
|
|
64
58
|
Mod7 number
|
|
65
59
|
"""
|
|
66
|
-
|
|
60
|
+
|
|
67
61
|
# Init
|
|
68
62
|
mod7_num: int = 0
|
|
69
|
-
|
|
63
|
+
|
|
70
64
|
# Conditions
|
|
71
|
-
max_value = 10**num_of_digits-1
|
|
65
|
+
max_value = 10**num_of_digits - 1
|
|
72
66
|
mod7_valid = False
|
|
73
|
-
invalid_digits = [0,8,9]
|
|
74
|
-
|
|
67
|
+
invalid_digits = [0, 8, 9] # Invalid last digit
|
|
68
|
+
|
|
75
69
|
# Loop
|
|
76
70
|
while not mod7_valid:
|
|
77
71
|
# Gen num
|
|
78
72
|
mod7_num = random.randint(0, max_value)
|
|
79
|
-
|
|
73
|
+
|
|
80
74
|
# Check last digit
|
|
81
75
|
if int(str(mod7_num)[-1]) in invalid_digits:
|
|
82
76
|
continue
|
|
83
|
-
|
|
77
|
+
|
|
84
78
|
# Check divide by 7
|
|
85
|
-
if __class__._is_mod7(mod7_num):
|
|
79
|
+
if __class__._is_mod7(mod7_num): # type: ignore
|
|
86
80
|
mod7_valid = True
|
|
87
|
-
|
|
81
|
+
|
|
88
82
|
# Output
|
|
89
83
|
return str(mod7_num).rjust(num_of_digits, fillchar)
|
|
90
84
|
|
|
91
|
-
|
|
92
85
|
@staticmethod
|
|
93
86
|
def mod7_cd_key(fast: bool = False) -> str:
|
|
94
87
|
"""
|
|
95
88
|
CD Key generator
|
|
96
89
|
|
|
97
|
-
Format: ``XXX-XXXXXXX``
|
|
98
|
-
|
|
90
|
+
Format: ``XXX-XXXXXXX``
|
|
91
|
+
|
|
99
92
|
Rules:
|
|
100
|
-
|
|
93
|
+
|
|
101
94
|
- Last seven digits must add to be divisible by ``7``
|
|
102
95
|
- First 3 digits cannot be ``333``, ``444``,..., ``999``
|
|
103
96
|
- Last digit of last seven digits cannot be ``0``, ``8`` or ``9``
|
|
104
|
-
|
|
97
|
+
|
|
105
98
|
Parameters
|
|
106
99
|
----------
|
|
107
100
|
fast : bool
|
|
108
|
-
Use pre-generated key
|
|
101
|
+
Use pre-generated key
|
|
109
102
|
(Default: ``False``)
|
|
110
|
-
|
|
103
|
+
|
|
111
104
|
Returns
|
|
112
105
|
-------
|
|
113
106
|
str:
|
|
@@ -122,15 +115,15 @@ class Keygen:
|
|
|
122
115
|
part1_valid = False
|
|
123
116
|
part1_not_valid_digits = [333, 444, 555, 666, 777, 888]
|
|
124
117
|
part1: str = ""
|
|
125
|
-
while not part1_valid:
|
|
126
|
-
part1_num = random.randint(0, 998)
|
|
118
|
+
while not part1_valid: # Loop check
|
|
119
|
+
part1_num = random.randint(0, 998) # Gen random int from 0 to 998
|
|
127
120
|
# part1_num = random.randint(100,300) # or just use this
|
|
128
121
|
if part1_num not in part1_not_valid_digits:
|
|
129
|
-
part1 = str(part1_num).rjust(3, "0")
|
|
130
|
-
part1_valid = True
|
|
122
|
+
part1 = str(part1_num).rjust(3, "0") # Convert into string
|
|
123
|
+
part1_valid = True # Break loop
|
|
131
124
|
|
|
132
125
|
# PART 02
|
|
133
|
-
part2 = __class__._mod7_gen(num_of_digits=7)
|
|
126
|
+
part2 = __class__._mod7_gen(num_of_digits=7) # type: ignore
|
|
134
127
|
|
|
135
128
|
# OUTPUT
|
|
136
129
|
return f"{part1}-{part2}"
|
|
@@ -141,42 +134,44 @@ class Keygen:
|
|
|
141
134
|
11-digit CD Key generator
|
|
142
135
|
|
|
143
136
|
Format: ``XXXX-XXXXXXX``
|
|
144
|
-
|
|
137
|
+
|
|
145
138
|
- ``XXXX``: Can be anything from ``0001`` to ``9991``. The last digit must be 3rd digit + ``1`` or ``2``. When the result is > ``9``, it overflows to ``0`` or ``1``.
|
|
146
139
|
- ``XXXXXXX``: Same as CD Key
|
|
147
|
-
|
|
140
|
+
|
|
148
141
|
Parameters
|
|
149
142
|
----------
|
|
150
143
|
fast : bool
|
|
151
|
-
Use pre-generated key
|
|
144
|
+
Use pre-generated key
|
|
152
145
|
(Default: ``False``)
|
|
153
|
-
|
|
146
|
+
|
|
154
147
|
Returns
|
|
155
148
|
-------
|
|
156
149
|
str:
|
|
157
150
|
Mod7 Key
|
|
158
151
|
"""
|
|
159
|
-
|
|
152
|
+
|
|
160
153
|
# Fast mode: pre-generated key
|
|
161
154
|
if fast:
|
|
162
155
|
return "0001-0000007"
|
|
163
|
-
|
|
156
|
+
|
|
164
157
|
# PART 01
|
|
165
158
|
part1_valid = False
|
|
166
159
|
part1: str = ""
|
|
167
160
|
while not part1_valid:
|
|
168
|
-
part1_1_num = random.randint(0, 999)
|
|
169
|
-
last_digit_choice = [1, 2]
|
|
170
|
-
part1_2_num = int(str(part1_1_num)[-1]) + random.choice(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
161
|
+
part1_1_num = random.randint(0, 999) # Random 3-digit number
|
|
162
|
+
last_digit_choice = [1, 2] # Choice for last digit
|
|
163
|
+
part1_2_num = int(str(part1_1_num)[-1]) + random.choice(
|
|
164
|
+
last_digit_choice
|
|
165
|
+
) # Make last digit
|
|
166
|
+
if part1_2_num > 9: # Check condition then overflow
|
|
167
|
+
part1_2_num = int(str(part1_2_num)[-1])
|
|
168
|
+
part1_str = f"{part1_1_num}{part1_2_num}" # Concat string
|
|
169
|
+
if int(part1_str) < 9991: # Check if < 9991
|
|
175
170
|
part1 = part1_str.rjust(4, "0")
|
|
176
171
|
part1_valid = True
|
|
177
172
|
|
|
178
173
|
# PART 02
|
|
179
|
-
part2 = __class__._mod7_gen(num_of_digits=7)
|
|
174
|
+
part2 = __class__._mod7_gen(num_of_digits=7) # type: ignore
|
|
180
175
|
|
|
181
176
|
# OUTPUT
|
|
182
177
|
return f"{part1}-{part2}"
|
|
@@ -196,19 +191,19 @@ class Keygen:
|
|
|
196
191
|
Parameters
|
|
197
192
|
----------
|
|
198
193
|
fast : bool
|
|
199
|
-
Use pre-generated key
|
|
194
|
+
Use pre-generated key
|
|
200
195
|
(Default: ``False``)
|
|
201
|
-
|
|
196
|
+
|
|
202
197
|
Returns
|
|
203
198
|
-------
|
|
204
199
|
str:
|
|
205
200
|
Mod7 Key
|
|
206
201
|
"""
|
|
207
|
-
|
|
202
|
+
|
|
208
203
|
# Fast mode: pre-generated key
|
|
209
204
|
if fast:
|
|
210
205
|
return "00100-OEM-0000007-00000"
|
|
211
|
-
|
|
206
|
+
|
|
212
207
|
# PART ABC
|
|
213
208
|
abc_part = str(random.randint(1, 365)).rjust(3, "0")
|
|
214
209
|
|
|
@@ -219,7 +214,7 @@ class Keygen:
|
|
|
219
214
|
y_part = random.choice(year_choice)
|
|
220
215
|
|
|
221
216
|
# NUM PART
|
|
222
|
-
num_part = __class__._mod7_gen(num_of_digits=6)
|
|
217
|
+
num_part = __class__._mod7_gen(num_of_digits=6) # type: ignore
|
|
223
218
|
|
|
224
219
|
# NUM PART 02
|
|
225
220
|
num_part_2 = str(random.randint(0, 99999)).rjust(5, "0")
|
|
@@ -235,18 +230,18 @@ class Keygen:
|
|
|
235
230
|
Parameters
|
|
236
231
|
----------
|
|
237
232
|
fast : bool
|
|
238
|
-
Use pre-generated key
|
|
233
|
+
Use pre-generated key
|
|
239
234
|
(Default: ``False``)
|
|
240
|
-
|
|
235
|
+
|
|
241
236
|
Returns
|
|
242
237
|
-------
|
|
243
238
|
dict:
|
|
244
239
|
Mod7 Key combo
|
|
245
240
|
"""
|
|
246
241
|
out = {
|
|
247
|
-
"CD Key": __class__.mod7_cd_key(fast=fast),
|
|
248
|
-
"OEM Key": __class__.mod7_oem_key(fast=fast),
|
|
249
|
-
"11-digit Key": __class__.mod7_11_digit_key(fast=fast)
|
|
242
|
+
"CD Key": __class__.mod7_cd_key(fast=fast), # type: ignore
|
|
243
|
+
"OEM Key": __class__.mod7_oem_key(fast=fast), # type: ignore
|
|
244
|
+
"11-digit Key": __class__.mod7_11_digit_key(fast=fast), # type: ignore
|
|
250
245
|
}
|
|
251
246
|
return out
|
|
252
247
|
|
|
@@ -255,4 +250,4 @@ class Keygen:
|
|
|
255
250
|
###########################################################################
|
|
256
251
|
if __name__ == "__main__":
|
|
257
252
|
test = Keygen()
|
|
258
|
-
print(test.mod7_combo())
|
|
253
|
+
print(test.mod7_combo())
|
absfuyu/tools/obfuscator.py
CHANGED
|
@@ -3,16 +3,13 @@ Absfuyu: Obfuscator
|
|
|
3
3
|
-------------------
|
|
4
4
|
Obfuscate code
|
|
5
5
|
|
|
6
|
-
Version: 2.0.
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 2.0.2
|
|
7
|
+
Date updated: 05/04/2024 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
# Module level
|
|
12
11
|
###########################################################################
|
|
13
|
-
__all__ = [
|
|
14
|
-
"Obfuscator"
|
|
15
|
-
]
|
|
12
|
+
__all__ = ["Obfuscator"]
|
|
16
13
|
|
|
17
14
|
|
|
18
15
|
# Library
|
|
@@ -22,9 +19,10 @@ import codecs
|
|
|
22
19
|
import random
|
|
23
20
|
import zlib
|
|
24
21
|
|
|
25
|
-
from absfuyu.logger import logger
|
|
26
|
-
from absfuyu.general.generator import Generator as gen, Charset
|
|
27
22
|
from absfuyu.general.data_extension import Text
|
|
23
|
+
from absfuyu.general.generator import Charset
|
|
24
|
+
from absfuyu.general.generator import Generator as gen
|
|
25
|
+
from absfuyu.logger import logger
|
|
28
26
|
|
|
29
27
|
|
|
30
28
|
# Class
|
|
@@ -33,17 +31,19 @@ class ObfuscatorLibraryList:
|
|
|
33
31
|
BASE64_ONLY = ["base64"]
|
|
34
32
|
FULL = ["base64", "codecs", "zlib"]
|
|
35
33
|
|
|
34
|
+
|
|
36
35
|
class Obfuscator:
|
|
37
36
|
"""Obfuscate code"""
|
|
37
|
+
|
|
38
38
|
def __init__(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
self,
|
|
40
|
+
code: str,
|
|
41
|
+
*,
|
|
42
|
+
base64_only: bool = False,
|
|
43
|
+
split_every: int = 60,
|
|
44
|
+
variable_length: int = 12,
|
|
45
|
+
fake_data: bool = False,
|
|
46
|
+
) -> None:
|
|
47
47
|
"""
|
|
48
48
|
code: Code text
|
|
49
49
|
base64_only: False: base64, compress, rot13 (default) | True: encode in base64 form only
|
|
@@ -62,17 +62,18 @@ class Obfuscator:
|
|
|
62
62
|
self._splited_variable_length = self.variable_length
|
|
63
63
|
self._decode_variable_length = self.variable_length + 3
|
|
64
64
|
# logger.debug("Class initiated.")
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
def __str__(self) -> str:
|
|
67
67
|
# temp = self.__dict__
|
|
68
68
|
temp = {
|
|
69
69
|
"base_code": "...",
|
|
70
70
|
"base64_only": self.base64_only,
|
|
71
|
-
"split_every_length": self.split_every_length,
|
|
71
|
+
"split_every_length": self.split_every_length,
|
|
72
72
|
"variable_length": self.variable_length,
|
|
73
|
-
"fake_data": self.fake_data
|
|
73
|
+
"fake_data": self.fake_data,
|
|
74
74
|
}
|
|
75
75
|
return f"{self.__class__.__name__}({temp})"
|
|
76
|
+
|
|
76
77
|
def __repr__(self) -> str:
|
|
77
78
|
return self.__str__()
|
|
78
79
|
|
|
@@ -88,7 +89,6 @@ class Obfuscator:
|
|
|
88
89
|
output = f"exec(bytes.fromhex('{newcode}').decode('utf-8'))"
|
|
89
90
|
return output
|
|
90
91
|
|
|
91
|
-
|
|
92
92
|
def _obfuscate(self) -> str:
|
|
93
93
|
"""
|
|
94
94
|
Convert multiple lines of code through multiple transformation
|
|
@@ -103,13 +103,13 @@ class Obfuscator:
|
|
|
103
103
|
else:
|
|
104
104
|
compressed_data = zlib.compress(b64_encode)
|
|
105
105
|
# log_debug(compressed_data)
|
|
106
|
-
logger.debug(f"Compressed data: {compressed_data}")
|
|
106
|
+
logger.debug(f"Compressed data: {compressed_data}") # type: ignore
|
|
107
107
|
b64_encode_2 = base64.b64encode(compressed_data)
|
|
108
108
|
# log_debug(b64_encode_2)
|
|
109
|
-
logger.debug(f"Base64 encode 2: {b64_encode_2}")
|
|
109
|
+
logger.debug(f"Base64 encode 2: {b64_encode_2}") # type: ignore
|
|
110
110
|
caesar_data = codecs.encode(b64_encode_2.decode(), "rot_13")
|
|
111
111
|
output = caesar_data
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
logger.debug(f"Output: {output}")
|
|
114
114
|
logger.debug("Code encoded.")
|
|
115
115
|
return output
|
|
@@ -118,7 +118,7 @@ class Obfuscator:
|
|
|
118
118
|
def _convert_to_base64_decode(text: str, raw: bool = False) -> str:
|
|
119
119
|
"""
|
|
120
120
|
Convert text into base64 and then return a code that decode that base64 code
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
text: Code that need to convert
|
|
123
123
|
raw: Return hex form only
|
|
124
124
|
"""
|
|
@@ -131,45 +131,47 @@ class Obfuscator:
|
|
|
131
131
|
return hex
|
|
132
132
|
return out
|
|
133
133
|
|
|
134
|
-
def _obfuscate_out(self) -> list:
|
|
134
|
+
def _obfuscate_out(self) -> list: # type: ignore
|
|
135
135
|
"""
|
|
136
136
|
Convert multiple lines of code through multiple transformation
|
|
137
137
|
(base64 -> compress -> base64 -> caesar (13))
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
Then return a list (obfuscated code) that can
|
|
140
140
|
be print or export into .txt file
|
|
141
|
-
"""
|
|
141
|
+
"""
|
|
142
142
|
# Obfuscated code
|
|
143
143
|
input_str = Text(self._obfuscate())
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
# Generate output
|
|
146
146
|
output = []
|
|
147
147
|
|
|
148
148
|
# Import library
|
|
149
|
-
library_list =
|
|
149
|
+
library_list = (
|
|
150
|
+
ObfuscatorLibraryList.BASE64_ONLY
|
|
151
|
+
if self.base64_only
|
|
152
|
+
else ObfuscatorLibraryList.FULL
|
|
153
|
+
)
|
|
150
154
|
temp = [f"import {lib}" for lib in library_list]
|
|
151
155
|
logger.debug(f"Lib: {temp}")
|
|
152
|
-
lib_hex = Text("\n".join(temp)).to_hex()
|
|
153
|
-
output.append(f"exec('{lib_hex}')")
|
|
156
|
+
lib_hex = Text("\n".join(temp)).to_hex() # Convert to hex
|
|
157
|
+
output.append(f"exec('{lib_hex}')")
|
|
154
158
|
logger.debug(f"Current output (import library): {output}")
|
|
155
159
|
|
|
156
160
|
# Append divided long text list
|
|
157
161
|
input_list = input_str.divide_with_variable(
|
|
158
162
|
split_size=self.split_every_length,
|
|
159
|
-
split_var_len=self._splited_variable_length
|
|
163
|
+
split_var_len=self._splited_variable_length,
|
|
160
164
|
)
|
|
161
|
-
encoded_str = input_list[-1]
|
|
162
|
-
output.extend(input_list[:-1])
|
|
165
|
+
encoded_str = input_list[-1] # Main var name that will later be used
|
|
166
|
+
output.extend(input_list[:-1]) # Append list minus the last element
|
|
163
167
|
logger.debug(f"Current output (encoded code): {output}")
|
|
164
168
|
|
|
165
169
|
# Decode: encoded_str
|
|
166
170
|
dc_name_lst = gen.generate_string(
|
|
167
|
-
charset=Charset.ALPHABET,
|
|
168
|
-
size=self._decode_variable_length,
|
|
169
|
-
times=3
|
|
171
|
+
charset=Charset.ALPHABET, size=self._decode_variable_length, times=3
|
|
170
172
|
)
|
|
171
|
-
encode_codec = "rot_13"
|
|
172
|
-
if not self.base64_only:
|
|
173
|
+
encode_codec = "rot_13" # full
|
|
174
|
+
if not self.base64_only: # full
|
|
173
175
|
hex_0 = self._convert_to_base64_decode(encode_codec)
|
|
174
176
|
output.append(f"{dc_name_lst[0]}={hex_0}")
|
|
175
177
|
hex_1 = Text("<string>").to_hex()
|
|
@@ -178,13 +180,13 @@ class Obfuscator:
|
|
|
178
180
|
output.append(f"{dc_name_lst[2]}='{hex_2}'")
|
|
179
181
|
logger.debug(f"Current output (decode variables): {output}")
|
|
180
182
|
|
|
181
|
-
if self.base64_only:
|
|
183
|
+
if self.base64_only: # b64
|
|
182
184
|
pre_hex = (
|
|
183
185
|
f"eval(compile(base64."
|
|
184
186
|
f"b64decode({encoded_str}),{dc_name_lst[1]},"
|
|
185
187
|
f"{dc_name_lst[2]}))"
|
|
186
188
|
)
|
|
187
|
-
else:
|
|
189
|
+
else: # full
|
|
188
190
|
pre_hex = (
|
|
189
191
|
f"eval(compile(base64."
|
|
190
192
|
f"b64decode(zlib.decompress(base64."
|
|
@@ -202,20 +204,22 @@ class Obfuscator:
|
|
|
202
204
|
charset=Charset.DEFAULT,
|
|
203
205
|
size=len(input_str),
|
|
204
206
|
times=1,
|
|
205
|
-
string_type_if_1=True
|
|
206
|
-
)
|
|
207
|
-
f2 = Text(f1).divide_with_variable(
|
|
207
|
+
string_type_if_1=True,
|
|
208
|
+
) # Generate fake data with len of original data
|
|
209
|
+
f2 = Text(f1).divide_with_variable(
|
|
210
|
+
self.split_every_length, self._splited_variable_length
|
|
211
|
+
)
|
|
208
212
|
output.extend(f2[:-1])
|
|
209
|
-
|
|
213
|
+
|
|
210
214
|
# Random data
|
|
211
215
|
bait_lst = gen.generate_string(
|
|
212
|
-
charset=Charset.ALPHABET,
|
|
213
|
-
size=self._splited_variable_length,
|
|
214
|
-
times=25
|
|
216
|
+
charset=Charset.ALPHABET, size=self._splited_variable_length, times=25
|
|
215
217
|
)
|
|
216
218
|
for x in bait_lst:
|
|
217
|
-
output.append(
|
|
218
|
-
|
|
219
|
+
output.append(
|
|
220
|
+
f"{x}='{gen.generate_string(charset=Charset.DEFAULT,size=self.split_every_length,times=1,string_type_if_1=True)}'"
|
|
221
|
+
)
|
|
222
|
+
|
|
219
223
|
random_eval_text = str(random.randint(1, 100))
|
|
220
224
|
for _ in range(random.randint(10, 50)):
|
|
221
225
|
random_eval_text += f"+{random.randint(1, 100)}"
|
|
@@ -224,11 +228,11 @@ class Obfuscator:
|
|
|
224
228
|
|
|
225
229
|
logger.debug("Code obfuscated.")
|
|
226
230
|
return output
|
|
227
|
-
|
|
231
|
+
|
|
228
232
|
def obfuscate(self) -> str:
|
|
229
233
|
"""
|
|
230
234
|
Obfuscate code
|
|
231
|
-
|
|
235
|
+
|
|
232
236
|
:returns: Obfuscated code
|
|
233
237
|
:rtype: str
|
|
234
238
|
"""
|
|
@@ -241,4 +245,4 @@ if __name__ == "__main__":
|
|
|
241
245
|
logger.setLevel(10)
|
|
242
246
|
code = "print('Hello World')"
|
|
243
247
|
test = Obfuscator(code, fake_data=True)
|
|
244
|
-
print(test.obfuscate())
|
|
248
|
+
print(test.obfuscate())
|
absfuyu/tools/stats.py
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
+
# flake8: noqa
|
|
1
2
|
"""
|
|
2
3
|
Absfuyu: Stats
|
|
3
4
|
--------------
|
|
4
|
-
List's stats
|
|
5
|
+
List's stats (soon will be deprecated)
|
|
5
6
|
|
|
6
7
|
Version: 2.0.3
|
|
7
8
|
Date updated: 26/11/2023 (dd/mm/yyyy)
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
|
-
|
|
11
11
|
# Module level
|
|
12
12
|
###########################################################################
|
|
13
|
-
__all__ = [
|
|
14
|
-
"ListStats"
|
|
15
|
-
]
|
|
13
|
+
__all__ = ["ListStats"]
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
# Library
|
|
@@ -28,6 +26,7 @@ from absfuyu.logger import logger
|
|
|
28
26
|
###########################################################################
|
|
29
27
|
class ListStats(List[Union[int, float]]):
|
|
30
28
|
"""Stats"""
|
|
29
|
+
|
|
31
30
|
def mean(self) -> float:
|
|
32
31
|
"""
|
|
33
32
|
Mean/Average
|
|
@@ -45,12 +44,12 @@ class ListStats(List[Union[int, float]]):
|
|
|
45
44
|
3.5
|
|
46
45
|
"""
|
|
47
46
|
s = sum(self)
|
|
48
|
-
return s/len(self)
|
|
47
|
+
return s / len(self)
|
|
49
48
|
|
|
50
49
|
def median(self) -> Union[int, float]:
|
|
51
50
|
"""
|
|
52
51
|
Median/Middle
|
|
53
|
-
|
|
52
|
+
|
|
54
53
|
Returns
|
|
55
54
|
-------
|
|
56
55
|
int | float
|
|
@@ -76,9 +75,9 @@ class ListStats(List[Union[int, float]]):
|
|
|
76
75
|
def mode(self) -> List[Union[int, float]]:
|
|
77
76
|
"""
|
|
78
77
|
Mode:
|
|
79
|
-
|
|
78
|
+
|
|
80
79
|
The Mode value is the value that appears the most number of times
|
|
81
|
-
|
|
80
|
+
|
|
82
81
|
Returns
|
|
83
82
|
-------
|
|
84
83
|
list[int | float]
|
|
@@ -93,20 +92,20 @@ class ListStats(List[Union[int, float]]):
|
|
|
93
92
|
"""
|
|
94
93
|
lst = self
|
|
95
94
|
frequency = ListExt(lst).freq()
|
|
96
|
-
|
|
97
|
-
max_val = max(frequency.values())
|
|
95
|
+
|
|
96
|
+
max_val = max(frequency.values()) # type: ignore
|
|
98
97
|
keys = []
|
|
99
|
-
|
|
100
|
-
for k, v in frequency.items():
|
|
98
|
+
|
|
99
|
+
for k, v in frequency.items(): # type: ignore
|
|
101
100
|
if v == max_val:
|
|
102
101
|
keys.append(k)
|
|
103
|
-
|
|
102
|
+
|
|
104
103
|
return keys
|
|
105
104
|
|
|
106
105
|
def var(self) -> float:
|
|
107
106
|
"""
|
|
108
107
|
Variance
|
|
109
|
-
|
|
108
|
+
|
|
110
109
|
Returns
|
|
111
110
|
-------
|
|
112
111
|
float
|
|
@@ -121,14 +120,14 @@ class ListStats(List[Union[int, float]]):
|
|
|
121
120
|
"""
|
|
122
121
|
lst = self
|
|
123
122
|
MEAN = self.mean()
|
|
124
|
-
v = [(x-MEAN)**2 for x in lst]
|
|
125
|
-
out = sum(v)/len(v)
|
|
123
|
+
v = [(x - MEAN) ** 2 for x in lst]
|
|
124
|
+
out = sum(v) / len(v)
|
|
126
125
|
return out
|
|
127
126
|
|
|
128
127
|
def std(self) -> float:
|
|
129
128
|
"""
|
|
130
129
|
Standard deviation
|
|
131
|
-
|
|
130
|
+
|
|
132
131
|
Returns
|
|
133
132
|
-------
|
|
134
133
|
float
|
|
@@ -151,9 +150,9 @@ class ListStats(List[Union[int, float]]):
|
|
|
151
150
|
Parameters
|
|
152
151
|
----------
|
|
153
152
|
percent : int
|
|
154
|
-
Which percentile
|
|
153
|
+
Which percentile
|
|
155
154
|
(Default: ``50``)
|
|
156
|
-
|
|
155
|
+
|
|
157
156
|
Returns
|
|
158
157
|
-------
|
|
159
158
|
int | float
|
|
@@ -175,7 +174,7 @@ class ListStats(List[Union[int, float]]):
|
|
|
175
174
|
def summary(self):
|
|
176
175
|
"""
|
|
177
176
|
Quick summary of data
|
|
178
|
-
|
|
177
|
+
|
|
179
178
|
Returns
|
|
180
179
|
-------
|
|
181
180
|
dict
|
|
@@ -212,7 +211,7 @@ class ListStats(List[Union[int, float]]):
|
|
|
212
211
|
"1st Quartile": self.percentile(25),
|
|
213
212
|
"2nd Quartile": self.percentile(50),
|
|
214
213
|
"3rd Quartile": self.percentile(75),
|
|
215
|
-
}
|
|
214
|
+
},
|
|
216
215
|
}
|
|
217
216
|
return output
|
|
218
217
|
|
|
@@ -222,5 +221,6 @@ class ListStats(List[Union[int, float]]):
|
|
|
222
221
|
if __name__ == "__main__":
|
|
223
222
|
logger.setLevel(10)
|
|
224
223
|
from rich import print
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
|
|
225
|
+
test = ListStats([1, 8, 9, 2, 3, 4, 4])
|
|
226
|
+
print(test.summary())
|