diff --git a/Installer.xcodeproj/project.pbxproj b/Installer.xcodeproj/project.pbxproj index 4d132e4..fd247e6 100644 --- a/Installer.xcodeproj/project.pbxproj +++ b/Installer.xcodeproj/project.pbxproj @@ -23,7 +23,6 @@ 7D17C5011D658DB90066232A /* ErrorWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D17C4F81D658DB90066232A /* ErrorWindowController.xib */; }; 7D17C5041D658DEC0066232A /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D17C5021D658DEC0066232A /* MainMenu.xib */; }; 7D6245831D87C3D700870565 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7D6245821D87C3D700870565 /* Images.xcassets */; }; - 7D9A7DEB1D8BC4E40091C1AF /* OverSight.app in Resources */ = {isa = PBXBuildFile; fileRef = 7D9A7DEA1D8BC4E40091C1AF /* OverSight.app */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -55,7 +54,6 @@ 7D24C8651D2CDEA7009932EE /* OverSight_Installer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OverSight_Installer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7D6245821D87C3D700870565 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Images/Images.xcassets; sourceTree = ""; }; 7D9A7DE91D8A8BDA0091C1AF /* main.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = main.h; path = Installer/main.h; sourceTree = SOURCE_ROOT; }; - 7D9A7DEA1D8BC4E40091C1AF /* OverSight.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; name = OverSight.app; path = "/Users/patrickw/objective-see/OverSight/DerivedData/OverSight/Build/Products/Debug/OverSight.app"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -100,7 +98,6 @@ 7D24C85C1D2CDEA7009932EE = { isa = PBXGroup; children = ( - 7D9A7DEA1D8BC4E40091C1AF /* OverSight.app */, 7D17C4D71D658D9F0066232A /* Shared */, 7D24C8671D2CDEA7009932EE /* Source */, 7D24C8661D2CDEA7009932EE /* Products */, @@ -172,7 +169,7 @@ 7D24C85D1D2CDEA7009932EE /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0730; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Objective-See"; TargetAttributes = { 7D24C8641D2CDEA7009932EE = { @@ -204,7 +201,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 7D9A7DEB1D8BC4E40091C1AF /* OverSight.app in Resources */, 7D6245831D87C3D700870565 /* Images.xcassets in Resources */, 7D17C4E91D658D9F0066232A /* overSight.png in Resources */, 7D17C5011D658DB90066232A /* ErrorWindowController.xib in Resources */, @@ -229,7 +225,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#cp -R -f $BUILT_PRODUCTS_DIR/WhatsYourSign.appex $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources/WhatsYourSign.appex\n\n#for achiving\n# ->first build finder sync in release mode (don't archive it)\n# then archive (this) installer app\n#cp -R -f ~/objective-see/WhatsYourSign/DerivedData/WhatsYourSign/Build/Products/Release/WhatsYourSign.appex ~/objective-see/WhatsYourSign/DerivedData/WhatsYourSign/Build/Intermediates/ArchiveIntermediates/WhatsYourSign/BuildProductsPath/Release/WhatsYourSign.app/Contents/Resources/WhatsYourSign.appex\n"; + shellScript = "#for normal builds\n# ->just copy in app\ncp -R -f $BUILT_PRODUCTS_DIR/OverSight.app $BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Resources/\n\n#for achiving\n# ->first build finder sync in release mode (don't archive it)\n# then archive (this) installer app\n#cp -R -f ~/objective-see/WhatsYourSign/DerivedData/WhatsYourSign/Build/Products/Release/WhatsYourSign.app ~/objective-see/WhatsYourSign/DerivedData/WhatsYourSign/Build/Intermediates/ArchiveIntermediates/Installer/BuildProductsPath/Release/WhatsYourSign_Installer.app/Contents/Resources/\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -278,8 +274,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; @@ -322,8 +320,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; @@ -351,6 +351,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Developer ID Application: Objective-See, LLC (VBG97UB4TA)"; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = VBG97UB4TA; GCC_PREPROCESSOR_DEFINITIONS = ( "IS_INSTALLER_APP=1", "DEBUG=1", @@ -372,6 +373,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Developer ID Application: Objective-See, LLC (VBG97UB4TA)"; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = VBG97UB4TA; GCC_PREPROCESSOR_DEFINITIONS = "IS_INSTALLER_APP=1"; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; INFOPLIST_FILE = Installer/Info.plist; diff --git a/Installer/AppDelegate.m b/Installer/AppDelegate.m index 300e462..d3c046a 100644 --- a/Installer/AppDelegate.m +++ b/Installer/AppDelegate.m @@ -135,6 +135,4 @@ bail: return; } -- (IBAction)startLoginItem:(id)sender { -} @end diff --git a/Installer/Configure.m b/Installer/Configure.m index 549d0ac..16923a2 100644 --- a/Installer/Configure.m +++ b/Installer/Configure.m @@ -156,6 +156,10 @@ bail: //dbg msg logMsg(LOG_DEBUG, [NSString stringWithFormat:@"copied %@ -> %@", appPathSrc, appPathDest]); + //remove xattrs + // ->otherwise app translocation causes issues + execTask(XATTR, @[@"-cr", appPathDest]); + //init path to XPC service xpcServicePath = [appPathDest stringByAppendingPathComponent:@"Contents/Library/LoginItems/OverSight Helper.app/Contents/XPCServices/OverSightXPC.xpc"]; diff --git a/Installer/main.m b/Installer/main.m index f4d4b6f..3308e36 100644 --- a/Installer/main.m +++ b/Installer/main.m @@ -16,7 +16,7 @@ int main(int argc, const char * argv[]) @autoreleasepool { - + //check for r00t // ->then spawn self via auth exec if(0 != geteuid()) diff --git a/LoginItem/AVMonitor.m b/LoginItem/AVMonitor.m index d884f56..2957cef 100644 --- a/LoginItem/AVMonitor.m +++ b/LoginItem/AVMonitor.m @@ -456,26 +456,6 @@ bail: // ->ask for video procs from XPC if(YES == self.videoActive) { - /* - - //TODO remove - logMsg(LOG_DEBUG, @"launching video recorder!"); - - //task - NSTask* task = nil; - - //alloc task - task = [[NSTask alloc] init]; - - //set path - [task setLaunchPath:@"/Users/patrickw/Downloads/videosnap-master/release/videosnap/usr/local/bin/videosnap"]; - [task setArguments:@[@"-t", @"30"]]; - [task launch]; - - */ - - - //dbg msg logMsg(LOG_DEBUG, @"video is active, so querying XPC to get video process(s)"); @@ -505,6 +485,17 @@ bail: [self generateNotification:event]; } + //if no consumer process was found + // ->still alert user that webcam was activated, but without details/ability to block + if(0 == videoProcesses.count) + { + //set pid + event[EVENT_PROCESS_ID] = @0; + + //generate notification + [self generateNotification:event]; + } + //signal sema dispatch_semaphore_signal(waitSema); @@ -810,9 +801,10 @@ bail: details = ((AVCaptureDevice*)event[EVENT_DEVICE]).localizedName; //customize buttons - // ->for mic or inactive events, just say 'ok' + // ->for mic, inactive events, or when consumer proc couldn't be ID'd, just say 'ok' if( (YES == [event[EVENT_DEVICE] isKindOfClass:NSClassFromString(@"AVCaptureHALDevice")]) || - (YES == [DEVICE_INACTIVE isEqual:event[EVENT_DEVICE_STATUS]]) ) + (YES == [DEVICE_INACTIVE isEqual:event[EVENT_DEVICE_STATUS]]) || + (0 == [event[EVENT_PROCESS_ID] intValue]) ) { //set other button title notification.otherButtonTitle = @"ok"; @@ -822,7 +814,7 @@ bail: } //customize buttons - // ->for activatated video; allow/block + // ->for activated video; allow/block else { //get process name @@ -919,6 +911,43 @@ bail: //process id NSNumber* processID = nil; + //preferences + NSDictionary* preferences = nil; + + //log msg + NSMutableString* sysLogMsg = nil; + + //always (manually) load preferences + preferences = [NSDictionary dictionaryWithContentsOfFile:[APP_PREFERENCES stringByExpandingTildeInPath]]; + + //alloc log msg + sysLogMsg = [NSMutableString string]; + + //log event? + // ->but only allow/blocks (i.e. webcam activations) + if( (YES == [preferences[PREF_LOG_ACTIVITY] boolValue]) && + (YES == [notification.actionButtonTitle isEqualToString:@"block"]) ) + { + //init msg + [sysLogMsg appendString:@"OVERSIGHT: "]; + + //user clicked 'block' + if(notification.activationType == NSUserNotificationActivationTypeActionButtonClicked) + { + //add + [sysLogMsg appendFormat:@"user clicked 'block' for %@", notification.userInfo]; + } + //user clicked 'allow' + else + { + //add + [sysLogMsg appendFormat:@"user clicked 'allow' for %@", notification.userInfo]; + } + + //write it out to syslog + syslog(LOG_ERR, "%s\n", sysLogMsg.UTF8String); + } + //dbg msg logMsg(LOG_DEBUG, [NSString stringWithFormat:@"use responded to notification: %@", notification]); diff --git a/LoginItem/AppDelegate.m b/LoginItem/AppDelegate.m index 97b545b..f33a86a 100644 --- a/LoginItem/AppDelegate.m +++ b/LoginItem/AppDelegate.m @@ -65,7 +65,7 @@ logMsg(LOG_DEBUG, @"checking for update"); //check - [self isThereAndUpdate]; + [self isThereAnUpdate]; }); } @@ -98,7 +98,7 @@ } //check for an update --(void)isThereAndUpdate +-(void)isThereAnUpdate { //version string NSMutableString* versionString = nil; diff --git a/LoginItem/StatusBarMenu.m b/LoginItem/StatusBarMenu.m index 71abfcd..6d7ceed 100644 --- a/LoginItem/StatusBarMenu.m +++ b/LoginItem/StatusBarMenu.m @@ -6,7 +6,7 @@ // Copyright (c) 2015 Objective-See. All rights reserved. // - +#import "Consts.h" #import "Logging.h" #import "AppDelegate.h" #import "StatusBarMenu.h" @@ -233,29 +233,11 @@ // ->launch main application which will show prefs -(void)preferences:(id)sender { - //path components - NSArray* pathComponents = nil; - - //path to main app - NSString* mainApp = nil; - - //init path components - pathComponents = [[[NSBundle mainBundle] bundlePath] pathComponents]; - if(pathComponents.count <= 4) - { - //bail - goto bail; - } - - //init path to main app - // ->basically trim off last 4 path components - mainApp = [NSString pathWithComponents:[pathComponents subarrayWithRange:NSMakeRange(0, [pathComponents count] - 4)]]; - //dbg msg - logMsg(LOG_DEBUG, [NSString stringWithFormat:@"launching main app; %@", mainApp]); + logMsg(LOG_DEBUG, @"launching main app (from /Applications)"); //launch main app - [[NSWorkspace sharedWorkspace] launchApplication:mainApp]; + [[NSWorkspace sharedWorkspace] launchApplication:[APPS_FOLDER stringByAppendingPathComponent:APP_NAME]]; //bail bail: @@ -286,4 +268,4 @@ bail: return; } -@end \ No newline at end of file +@end diff --git a/MainApp/AppDelegate.h b/MainApp/AppDelegate.h index 6f4bfbf..cf2b95f 100644 --- a/MainApp/AppDelegate.h +++ b/MainApp/AppDelegate.h @@ -58,7 +58,7 @@ -(IBAction)check4Update:(id)sender; //check for an update --(void)isThereAndUpdate; +-(void)isThereAnUpdate; //start the login item -(IBAction)startLoginItem:(id)sender; diff --git a/MainApp/AppDelegate.m b/MainApp/AppDelegate.m index 4a60331..cabdb4e 100644 --- a/MainApp/AppDelegate.m +++ b/MainApp/AppDelegate.m @@ -199,13 +199,13 @@ bail: [self.spinner startAnimation:self]; //check for update - [self isThereAndUpdate]; + [self isThereAnUpdate]; return; } //check for an update --(void)isThereAndUpdate +-(void)isThereAnUpdate { //version string NSMutableString* versionString = nil; diff --git a/OverSight.xcodeproj/project.pbxproj b/OverSight.xcodeproj/project.pbxproj index e50ab5a..dbd90a7 100644 --- a/OverSight.xcodeproj/project.pbxproj +++ b/OverSight.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 7D17CFE41D811B4E0017B475 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D17C5381D659E580066232A /* Utilities.m */; }; 7D17CFE51D8133840017B475 /* AVMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D17CFE11D81121E0017B475 /* AVMonitor.m */; }; 7D17D0101D8136C60017B475 /* OverSightXPC.xpc in Embed XPC Services */ = {isa = PBXBuildFile; fileRef = 7DC9C8121D641A350017D143 /* OverSightXPC.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 7D3B524C1D9B3A74006568D9 /* libbsm.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D9A7DED1D8CACE30091C1AF /* libbsm.tbd */; }; 7D62457C1D84FB8900870565 /* Enumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D62457B1D84FB8900870565 /* Enumerator.m */; }; 7D6245801D85348E00870565 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D62457F1D85348E00870565 /* Utilities.m */; }; 7D6245851D87C43900870565 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7D6245841D87C43900870565 /* Images.xcassets */; }; @@ -32,7 +33,6 @@ 7D6245951D87E14800870565 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8B5755CD19DA3F9300799E6B /* MainMenu.xib */; }; 7D9A7DE81D893E4F0091C1AF /* InfoWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D62458C1D87D38400870565 /* InfoWindow.xib */; }; 7D9A7DEC1D8BE1E00091C1AF /* Exception.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D17C5311D659E580066232A /* Exception.m */; }; - 7D9A7DEE1D8CACE30091C1AF /* libbsm.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D9A7DED1D8CACE30091C1AF /* libbsm.tbd */; }; 7D9A7DF21D8F2C900091C1AF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7D6245841D87C43900870565 /* Images.xcassets */; }; 7DAF4B7F1D657192000DA31A /* StatusBarMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAF4B7D1D656FD3000DA31A /* StatusBarMenu.m */; }; 7DC9C8171D641A350017D143 /* OverSightXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC9C8161D641A350017D143 /* OverSightXPC.m */; }; @@ -143,7 +143,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 7D9A7DEE1D8CACE30091C1AF /* libbsm.tbd in Frameworks */, + 7D3B524C1D9B3A74006568D9 /* libbsm.tbd in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -361,7 +361,7 @@ 8B57559319DA3E9500799E6B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0730; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Cory Bohon"; TargetAttributes = { 7DC9C8111D641A350017D143 = { @@ -528,7 +528,7 @@ ENABLE_TESTABILITY = YES; GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OverSightXPC/Info.plist; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.OverSightXPC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -545,7 +545,7 @@ COPY_PHASE_STRIP = NO; GCC_NO_COMMON_BLOCKS = YES; INFOPLIST_FILE = OverSightXPC/Info.plist; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.OverSightXPC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -565,8 +565,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "Developer ID Application: Objective-See, LLC (VBG97UB4TA)"; @@ -574,6 +576,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -587,7 +590,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -607,8 +610,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "Developer ID Application: Objective-See, LLC (VBG97UB4TA)"; @@ -617,6 +622,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; @@ -624,7 +630,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; }; diff --git a/OverSight.xcodeproj/xcuserdata/patrickw.xcuserdatad/xcschemes/OverSight Login Item.xcscheme b/OverSight.xcodeproj/xcuserdata/patrickw.xcuserdatad/xcschemes/OverSight Login Item.xcscheme deleted file mode 100644 index c1ea95a..0000000 --- a/OverSight.xcodeproj/xcuserdata/patrickw.xcuserdatad/xcschemes/OverSight Login Item.xcscheme +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Shared/Consts.h b/Shared/Consts.h index ee0e20f..601d52f 100644 --- a/Shared/Consts.h +++ b/Shared/Consts.h @@ -84,7 +84,12 @@ //path to pkill #define PKILL @"/usr/bin/pkill" +//path to xattr +#define XATTR @"/usr/bin/xattr" + //path to facetime #define FACE_TIME @"/Applications/FaceTime.app/Contents/MacOS/FaceTime" + + #endif