Skip to content

Commit

Permalink
v2.2
Browse files Browse the repository at this point in the history
- M1 native support
- Safari plugins/extensions
- Improved: UI, OS compatibility, etc.
  • Loading branch information
Patrick Wardle committed Feb 26, 2021
1 parent 7d689d5 commit 52406d4
Show file tree
Hide file tree
Showing 42 changed files with 617 additions and 814 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.xcscheme
*.xcuserstate
KnockKnock.xcodeproj/xcuserdata/*
KnockKnock.xcodeproj/xcuserdata/*
Carthage/Build
Carthage/Checkouts
5 changes: 4 additions & 1 deletion AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ extern Filter* itemFilter;
/* PROPERTIES */

//friends
@property (weak) IBOutlet NSWindow *friends;
@property (weak) IBOutlet NSWindow* friends;

//close button
@property (weak) IBOutlet NSButton* closeButton;

//flag for secondary scan
// ->need to restart shared enumerator
Expand Down
37 changes: 15 additions & 22 deletions AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ -(void)applicationDidFinishLaunching:(NSNotification *)notification
//show friends window
[self.friends makeKeyAndOrderFront:self];

//then make action button first responder
[self.friends makeFirstResponder:self.closeButton];

//close after a few seconds
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

Expand Down Expand Up @@ -246,7 +249,7 @@ -(void)requestFullDiskAcces
infoAlert.messageText = @"Open 'System Preferences' to give KnockKnock Full Disk Access?";

//detailed test
infoAlert.informativeText = @"This allows the app to perform a comprehensive scan.\n\nIn System Preferences:\rclick the 🔒 to authenticate\rclick the ➕ to add KnockKnock.app\n";
infoAlert.informativeText = @"This allows the app to perform a comprehensive scan.\n\nIn System Preferences:\rClick the 🔒 to authenticate\rClick the ➕ to add KnockKnock.app\n";

//ok button
[infoAlert addButtonWithTitle:@"OK"];
Expand Down Expand Up @@ -481,7 +484,7 @@ -(void)scan
self.statusText.hidden = NO;

//update
[self.statusText setStringValue:[NSString stringWithFormat:@"scanning %@", plugin.name]];
[self.statusText setStringValue:[NSString stringWithFormat:@"Scanning: %@", plugin.name]];

});

Expand Down Expand Up @@ -694,28 +697,18 @@ -(void)itemsProcessed:(PluginBase*)plugin
// ->reload category table (to trigger title turning red)
if(0 != plugin.flaggedItems.count)
{
//execute on main (UI) thread
dispatch_sync(dispatch_get_main_queue(), ^{

//reload category table
[self.categoryTableController customReload];

});
//reload category table
[self.categoryTableController customReload];
}

//check if active plugin matches
if(plugin == self.selectedPlugin)
{
//execute on main (UI) thread
dispatch_sync(dispatch_get_main_queue(), ^{

//scroll to top of item table
[self.itemTableController scrollToTop];
//scroll to top of item table
[self.itemTableController scrollToTop];

//reload item table
[self.itemTableController.itemTableView reloadData];

});
//reload item table
[self.itemTableController.itemTableView reloadData];
}

return;
Expand Down Expand Up @@ -931,7 +924,7 @@ -(void)stopScanUI:(NSString*)statusMsg
[self.progressIndicator stopAnimation:nil];

//hide progress indicator
self.progressIndicator.hidden = YES;
//self.progressIndicator.hidden = YES;

//shift over status msg
self.statusTextConstraint.constant = 10;
Expand Down Expand Up @@ -992,7 +985,7 @@ -(void)displayScanStats
flaggedItemCount += plugin.flaggedItems.count;

//init detailed msg
details = [NSMutableString stringWithFormat:@"found %lu items", (unsigned long)itemCount];
details = [NSMutableString stringWithFormat:@"Found %lu items", (unsigned long)itemCount];
}
//otherwise just unknown items
else
Expand All @@ -1013,7 +1006,7 @@ -(void)displayScanStats
}

//init detailed msg
details = [NSMutableString stringWithFormat:@"found %lu non-OS items", (unsigned long)itemCount];
details = [NSMutableString stringWithFormat:@"Found %lu non-OS items", (unsigned long)itemCount];
}
}

Expand All @@ -1026,7 +1019,7 @@ -(void)displayScanStats
if(YES != self.isConnected)
{
//add disconnected msg
[details appendFormat:@" \r\nunable to query VirusTotal (network)"];
[details appendFormat:@" \r\nUnable to query VirusTotal (network)"];
}
//otherwise
// ->add details about # of flagged items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"images" : [
{
"idiom" : "mac",
"filename" : "malwarebytes.pdf"
"filename" : "darkMode.png"
},
{
"idiom" : "mac",
"filename" : "malwarebytesLight.pdf",
"filename" : "lightMode.png",
"appearances" : [
{
"appearance" : "luminosity",
Expand All @@ -16,7 +16,7 @@
},
{
"idiom" : "mac",
"filename" : "malwarebytesDark.pdf",
"filename" : "darkMode.png",
"appearances" : [
{
"appearance" : "luminosity",
Expand All @@ -32,4 +32,4 @@
"properties" : {
"preserves-vector-representation" : true
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions Assets.xcassets/FriendsAiro.imageset/Contents.json

This file was deleted.

Binary file removed Assets.xcassets/FriendsAiro.imageset/airo.png
Binary file not shown.
35 changes: 35 additions & 0 deletions Assets.xcassets/FriendsJamf.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"images" : [
{
"idiom" : "mac",
"filename" : "darkMode.png"
},
{
"idiom" : "mac",
"filename" : "lightMode.png",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
]
},
{
"idiom" : "mac",
"filename" : "darkMode.png",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
]
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file added Assets.xcassets/FriendsJamf.imageset/darkMode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions Assets.xcassets/FriendsMacPaw.imageset/Contents.json

This file was deleted.

Binary file removed Assets.xcassets/FriendsMacPaw.imageset/macpaw.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "getsentry/sentry-cocoa" "4.1.0"
github "getsentry/sentry-cocoa" "6.2.0"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "getsentry/sentry-cocoa" "4.1.0"
github "getsentry/sentry-cocoa" "6.2.0"
13 changes: 6 additions & 7 deletions Consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@
//supported plugins
static NSString * const SUPPORTED_PLUGINS[] = {@"AuthorizationPlugins", @"BrowserExtensions", @"CronJobs", @"DirectoryServicesPlugins", @"EventRules", @"Extensions", @"Kexts", @"LaunchItems", @"DylibInserts", @"DylibProxies", @"LoginItems", @"LogInOutHooks", @"PeriodicScripts", @"QuicklookPlugins", @"SpotlightImporters", @"StartupScripts"};

//sentry crash reporting URL
#define SENTRY_DSN @"https://ba5d094e87014a529b25d90bae010b1c@sentry.io/1321683"

//button text, start scan
#define START_SCAN @"Start Scan"

//button text, stop scan
#define STOP_SCAN @"Stop Scan"

//status msg
#define SCAN_MSG_STARTED @"scanning started"
#define SCAN_MSG_STARTED @"Scanning Started"

//status msg
#define SCAN_MSG_STOPPED @"scan stopped"
#define SCAN_MSG_STOPPED @"Scan Stopped"

//status msg
#define SCAN_MSG_COMPLETE @"scan complete"
#define SCAN_MSG_COMPLETE @"Scan Complete"

//prefs
// ->filter out OS/known
Expand Down Expand Up @@ -183,10 +186,6 @@ enum Signer{None, Apple, AppStore, DevID, AdHoc};
//id (tag) for 'show' button
#define TABLE_ROW_SHOW_BUTTON 107

//ellipis
// ->for long paths...
#define ELLIPIS @"..."

//known kexts
#define WHITE_LISTED_KEXTS @"whitelistedKexts"

Expand Down
32 changes: 13 additions & 19 deletions Filter.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,25 @@ -(BOOL)isTrustedKext:(File*)file
// either list of hashes, or dev id
id whitelistInfo = nil;

//ignore any signing issues
if(noErr != [file.signingInfo[KEY_SIGNATURE_STATUS] intValue]) goto bail;

//lookup based on name
whitelistInfo = self.trustedKexts[file.path];

//hashes?
if( (YES == [whitelistInfo isKindOfClass:[NSArray class]]) &&
(YES == [whitelistInfo containsObject:[file.hashes[KEY_HASH_MD5] lowercaseString]]) )
//dev id?
if( (YES == [((NSArray*)whitelistInfo).firstObject hasPrefix:@"Developer ID Application"]) &&
(YES == [[file.signingInfo[KEY_SIGNATURE_AUTHORITIES] lastObject] isEqualToString:@"Apple Root CA"]) )
{
//got match
isTrusted = YES;

//bail
goto bail;
//check
isTrusted = [whitelistInfo containsObject:[file.signingInfo[KEY_SIGNATURE_AUTHORITIES] firstObject]];
if(YES == isTrusted) goto bail;
}

//dev id?
// note: these are only for kexts that ship with macOS!
if( (YES == [whitelistInfo isKindOfClass:[NSString class]]) &&
(YES == [[file.signingInfo[KEY_SIGNATURE_AUTHORITIES] lastObject] isEqualToString:@"Apple Root CA"]) &&
(YES == [file.signingInfo[KEY_SIGNATURE_AUTHORITIES] containsObject:whitelistInfo]) )
//hash
else
{
//got match
isTrusted = YES;

//bail
goto bail;
isTrusted = [whitelistInfo containsObject:[file.hashes[KEY_HASH_MD5] lowercaseString]];
if(YES == isTrusted) goto bail;
}

//check for apple signature
Expand Down
2 changes: 1 addition & 1 deletion ItemTableController.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ -(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
self.noItemsLabel.hidden = NO;

//set string
self.noItemsLabel.stringValue = [NSString stringWithFormat:@"no %@ found", [selectedPluginObj.name lowercaseString]];
self.noItemsLabel.stringValue = [NSString stringWithFormat:@"No %@ found", [selectedPluginObj.name lowercaseString]];
}

//there *are* items
Expand Down
2 changes: 1 addition & 1 deletion KKRow.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ -(void)drawSelectionInRect:(NSRect)dirtyRect
if(self.selectionHighlightStyle != NSTableViewSelectionHighlightStyleNone)
{
//make selection rect
selectionRect = NSInsetRect(self.bounds, 2.5, 2.5);
selectionRect = NSInsetRect(self.bounds, 10.0, 1.0);

//dark mode highlight
if(YES == isDarkMode())
Expand Down
Loading

0 comments on commit 52406d4

Please sign in to comment.