v1.4 candidate

-improved auth window prompt (delay after success)
 -added extraction/printing of obj-c objects from exception.reason
 -ensures comparison of dylib to main binary image name now handles symbolic links
 -new icon
This commit is contained in:
Patrick Wardle
2016-03-24 21:17:00 -10:00
parent b99b05888c
commit 242d4021c9
23 changed files with 124 additions and 111 deletions
-17
View File
@@ -20,9 +20,6 @@
//TODO: autolayout vertically
//TODO: show 'from where' via quarantine attrz or database!! (simon email)
//TODO: detect as procs die via GCD (simon blog post)
//TODO: missing icon (128) - new icon?
//TODO: exception handling for mutated array!
//TODO: check for "Apple Mac OS Application Signing" for Apple Apps - and add to 'OBJ-See' TODO doc
@implementation AppDelegate
@@ -270,17 +267,6 @@
break;
//'i' (info)
//case KEYCODE_I:
//info
//TODO...this will take some work, search, flagged, item....
//set flag
//wasHandled = YES;
//break;
//'w' (close window)
case KEYCODE_W:
@@ -1746,9 +1732,6 @@ bail:
//unselect current task
self.currentTask = nil;
//TODO: don't reset filtered items?
// ...will require some smart filtering :/
//unset filter flag
self.taskTableController.isFiltered = NO;
+4
View File
@@ -17,4 +17,8 @@ void signalHandler(int signal, siginfo_t *info, void *context);
//display an alert
void showAlert();
//given an error reason (e.g. '*** Collection <__NSArrayM: 0x7fdb36a72b80> was mutated while being enumerated'
// ->extract and grab objective-c object's description; 0x7fdb36a72b80 (NSArray*)
void displayObject(NSException* exception);
+67
View File
@@ -80,6 +80,9 @@ void exceptionHandler(NSException *exception)
//err msg
syslog(LOG_ERR, "OBJECTIVE-SEE ERROR: %s", [[[NSThread callStackSymbols] description] UTF8String]);
//try print any objective-c objects in exception's 'reason'
displayObject(exception);
//main thread
// ->just show UI alert
if(YES == [NSThread isMainThread])
@@ -153,3 +156,67 @@ void signalHandler(int signal, siginfo_t *info, void *context)
return;
}
//given an error reason (e.g. '*** Collection <__NSArrayM: 0x7fdb36a72b80> was mutated while being enumerated'
// ->extract and grab objective-c object's description; 0x7fdb36a72b80 (NSArray*)
void displayObject(NSException* exception)
{
//object description
NSString* objectDescription = nil;
//start
NSRange start = {0};
//end
NSRange end = {0};
//extracted addr
NSString* extractedAddr = nil;
//scanner
// ->used to convert hex string to pointer
NSScanner* scanner = nil;
//address
unsigned long long objAddress = 0;
//find start
// ->find '0x' in something like: *** Collection <__NSArrayM: 0x7fdb36a72b80>
start = [exception.reason rangeOfString:@"0x"];
if(NSNotFound == start.location)
{
//bail
goto bail;
}
//find end
// ->find '>' in something like: *** Collection <__NSArrayM: 0x7fdb36a72b80>
end = [exception.reason rangeOfString:@">"];
if(NSNotFound == end.location)
{
//bail
goto bail;
}
//extract address
// ->will still be a (hex) string, but will be converted below
extractedAddr = [exception.reason substringWithRange:NSMakeRange(start.location + start.length, end.location - start.location- start.length)];
//init scanner
scanner = [NSScanner scannerWithString:extractedAddr];
//convert extracted address from hex string to pointer
[scanner scanHexLongLong:&objAddress];
//cast to obj-c object
// ->then get description
objectDescription = [(__bridge_transfer NSArray*)((void*)objAddress) description];
//err msg
syslog(LOG_ERR, "OBJECTIVE-SEE ERROR: object: %s", [objectDescription UTF8String]);
//bail
bail:
return;
}
+3
View File
@@ -18,6 +18,9 @@
//auth button
@property (weak) IBOutlet NSButton *authButton;
//cancel button
@property (weak) IBOutlet NSButton *cancelButton;
//arrow icon
@property (weak) IBOutlet NSImageView *arrowIcon;
+36 -25
View File
@@ -19,6 +19,7 @@
@synthesize statusMsg;
@synthesize authButton;
@synthesize shouldExit;
@synthesize cancelButton;
//automatically called when nib is loaded
// ->center window
@@ -76,9 +77,6 @@
// ->auth user, then set XPC service as root/setuid
-(IBAction)authenticate:(id)sender
{
//status var
BOOL authdOK = NO;
//authorization ref
AuthorizationRef authorizationRef = {0};
@@ -154,8 +152,6 @@
//2nd arg: permissions
// ->note: 4 at front is setuid
//TODO: change b4 release
// ->make 4755 before deploy (for testing, 777 makes Xcode be able to del it during build!)
installArgs[1] = "4755";
//3rd arg: XPC service
@@ -166,8 +162,6 @@
//chmod XPC service w/ setuid
osStatus = AuthorizationExecuteWithPrivileges(authorizationRef, "/bin/chmod", 0, (char* const*)installArgs, NULL);
//check
if(errAuthorizationSuccess != osStatus)
{
//err msg
@@ -182,23 +176,46 @@
//bail
goto bail;
}
//no errors
authdOK = YES;
//no exit
self.shouldExit = NO;
//make sure app's key window is (still) font
[((AppDelegate*)[[NSApplication sharedApplication] delegate]).window makeKeyAndOrderFront:self];
//disable auth button
self.authButton.enabled = NO;
//make sure app is (still) front
[NSApp activateIgnoringOtherApps:YES];
//disable cancel button
self.cancelButton.enabled = NO;
//call back into app delegate
// ->kick off task enum, etc
[((AppDelegate*)[[NSApplication sharedApplication] delegate]) go];
//update auth message
self.statusMsg.stringValue = @"ok: authorization successful";
//wait a bit
// ->then hide window & kick off action
{
//dispatch, then action
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.50 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//close window
[self.window close];
//exec UI actions etc on main thread
dispatch_async(dispatch_get_main_queue(), ^{
//make sure app's key window is (still) font
[((AppDelegate*)[[NSApplication sharedApplication] delegate]).window makeKeyAndOrderFront:self];
//make sure app is (still) front
[NSApp activateIgnoringOtherApps:YES];
//call back into app delegate
// ->kick off task enum, etc
[((AppDelegate*)[[NSApplication sharedApplication] delegate]) go];
});
});
}
//bail
bail:
@@ -210,13 +227,7 @@ bail:
AuthorizationFree(authorizationRef, kAuthorizationFlagDestroyRights);
}
//on auth/'install' success
// ->close window
if(YES == authdOK)
{
//close window
[self.window close];
}
return;
}
+2 -2
View File
@@ -304,8 +304,8 @@ bail:
for(NSString* dylibPath in dylibPaths)
{
//skip main executable image
//TODO: also check realpath() or obj-c equiv!
if(YES == [dylibPath isEqualToString:self.binary.path])
// ->making sure to resolve symlinks
if(YES == [dylibPath isEqualToString:[self.binary.path stringByResolvingSymlinksInPath]])
{
//skip
continue;
+2 -2
View File
@@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.0</string>
<string>1.4.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.0</string>
<string>1.4.0</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>1ECDBF86-1DFC-4002-A5BE-41FC31ACB68B</string>
<key>IDESourceControlProjectName</key>
<string>project</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>A9FFC1B124E25027A0E10FB456DBA9E2803FAE9D</key>
<string>https://bitbucket.org/objective-see/knockknock.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>KnockKnock.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>A9FFC1B124E25027A0E10FB456DBA9E2803FAE9D</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://bitbucket.org/objective-see/knockknock.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>A9FFC1B124E25027A0E10FB456DBA9E2803FAE9D</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>A9FFC1B124E25027A0E10FB456DBA9E2803FAE9D</string>
<key>IDESourceControlWCCName</key>
<string>KnockKnock</string>
</dict>
</array>
</dict>
</plist>
+4 -11
View File
@@ -6,25 +6,18 @@
// Copyright (c) 2015 Objective-See. All rights reserved.
//
//TODO: list of what's running on my Mac on website!!!!
#import "KKRow.h"
#import "Binary.h"
#import "Consts.h"
#import "ItemBase.h"
#import "ItemView.h"
#import "VTButton.h"
#import "kkRowCell.h"
#import "Utilities.h"
#import "AppDelegate.h"
#import "ItemBase.h"
#import "TaskTableController.h"
#import "InfoWindowController.h"
#import "KKRow.h"
#import "kkRowCell.h"
#import <AppKit/AppKit.h>
@implementation TaskTableController
@synthesize itemView;
@@ -823,7 +816,7 @@ bail:
//draw
[selectedView setNeedsDisplay:YES];
//make hide it after .33 second
//make hidden it after .33 second
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.33 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//reset color
+6 -5
View File
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="RequestRootWindowController">
<connections>
<outlet property="arrowIcon" destination="JGI-8Z-D0q" id="gEn-iQ-dvN"/>
<outlet property="authButton" destination="sNs-lK-0YZ" id="kpr-Lu-dOv"/>
<outlet property="cancelButton" destination="HZZ-Es-mpy" id="FSw-6j-5zU"/>
<outlet property="helpButton" destination="gwN-t1-KG9" id="vn3-vU-fZA"/>
<outlet property="statusMsg" destination="OSm-xS-Dmd" id="mh0-TD-SLI"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
@@ -19,7 +20,7 @@
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" texturedBackground="YES" unifiedTitleAndToolbar="YES"/>
<rect key="contentRect" x="196" y="240" width="422" height="148"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="-2" width="422" height="148"/>
<autoresizingMask key="autoresizingMask"/>
@@ -47,7 +48,7 @@
</connections>
</button>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lEv-Wj-6S5">
<rect key="frame" x="11" y="22" width="110" height="106"/>
<rect key="frame" x="11" y="34" width="110" height="106"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="flatIcon" id="xKf-GK-m0k"/>
</imageView>
<button focusRingType="none" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gwN-t1-KG9">
@@ -84,7 +85,7 @@
</objects>
<resources>
<image name="arrow" width="256" height="256"/>
<image name="flatIcon" width="1024" height="1024"/>
<image name="flatIcon" width="256" height="256"/>
<image name="teText" width="460.55999755859375" height="85.919998168945312"/>
</resources>
</document>
-2
View File
@@ -84,7 +84,6 @@ bail:
return version;
}
//TODO: calling 'isApple' does this all over again!?
//get the signing info of a file
NSDictionary* extractSigningInfo(NSString* path)
{
@@ -299,7 +298,6 @@ bail:
CFRelease(staticCode);
}
return isApple;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 173 KiB

-6
View File
@@ -549,12 +549,6 @@ bail:
//remove dups
[dylibs setArray:[[[NSSet setWithArray:dylibs] allObjects] mutableCopy]];
//TODO: remove
if(pid.intValue == 13084)
{
syslog(LOG_ERR, "TASK-EXPLORER: %s\n", dylibs.description.UTF8String);
}
//bail
bail: