Skip to content

Commit

Permalink
v0.9.5. RC: allow kernel traffic, process args in UI, gray listing im…
Browse files Browse the repository at this point in the history
…proved

-traffic originated from the kernel (pid 0), allowed
  ...this fixes issues with SMB, etc.

-alert window now shows process args

-added more items to graylist (e.g. perl5)

-uninstaller invokes kextcache to rebuild kernel cache

-other UI tweaks/improvements
  • Loading branch information
Patrick Wardle committed May 30, 2018
1 parent df819a0 commit 2384323
Show file tree
Hide file tree
Showing 23 changed files with 181 additions and 122 deletions.
1 change: 0 additions & 1 deletion configure/Configure/Configure.m
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ -(BOOL)install

//save result
wasInstalled = (BOOL)(result.intValue == 0);

};

//install
Expand Down
49 changes: 25 additions & 24 deletions configure/Configure/ConfigureWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ -(void)lifeCycleEvent:(NSInteger)event
status = YES;

//for install
// wait until kext cache rebuild is done
// wait until enum'ing of installed apps is done
if(ACTION_INSTALL_FLAG == event)
{
//nap
Expand Down Expand Up @@ -259,34 +259,35 @@ -(void)lifeCycleEvent:(NSInteger)event

//dbg msg
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"'%@' completed", SYSTEM_PROFILER]);
}

//update status msg
dispatch_async(dispatch_get_main_queue(),
^{
//set status msg
[self.statusMsg setStringValue:@"Rebuilding kernel cache\n\t\t ...please wait!"];
});

//for both install and uninstall
//wait until 'kextcache' has exited
while(YES)
{
//dbg msg
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"waiting for '%@' to complete", KEXT_CACHE]);

//update status msg
dispatch_async(dispatch_get_main_queue(),
^{
//set status msg
[self.statusMsg setStringValue:@"Rebuilding kernel cache\n\t\t ...please wait!"];
});
//nap
[NSThread sleepForTimeInterval:1.0];

//wait until 'kextcache' has exited
while(YES)
//exit'd?
if(0 == [getProcessIDs(KEXT_CACHE, -1) count])
{
//dbg msg
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"waiting for '%@' to complete", KEXT_CACHE]);

//nap
[NSThread sleepForTimeInterval:1.0];

//exit'd?
if(0 == [getProcessIDs(KEXT_CACHE, -1) count])
{
//bye
break;
}
//bye
break;
}

//dbg msg
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"'%@' completed", KEXT_CACHE]);
}

//dbg msg
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"'%@' completed", KEXT_CACHE]);
}

//error occurred
Expand Down
2 changes: 1 addition & 1 deletion configure/Configure/ErrorWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ -(void)display
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 100 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{

//make close button active
[self.window makeFirstResponder:closeButton];
[self.window makeFirstResponder:self.closeButton];

});

Expand Down
3 changes: 3 additions & 0 deletions configure/Configure/Script/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ elif [ "${1}" == "-uninstall" ]; then

echo "kext removed"

#rebuild cache, full path
/usr/sbin/kextcache -invalidate / &

echo "uninstall complete"
exit 0
fi
Expand Down
5 changes: 2 additions & 3 deletions configure/Configure/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ int main(int argc, char *argv[])
goto bail;
}

//kick main app logic
//default run mode
// just kick off main app logic
status = NSApplicationMain(argc, (const char **) argv);

bail:
Expand Down Expand Up @@ -150,8 +151,6 @@ BOOL cmdlineInterface(int action)
break;
}
}


}

//happy
Expand Down
4 changes: 3 additions & 1 deletion configure/configure.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0920;
LastUpgradeCheck = 0930;
TargetAttributes = {
4BE4905C10445E0A006BE471 = {
DevelopmentTeam = VBG97UB4TA;
Expand Down Expand Up @@ -541,6 +541,7 @@
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
Expand Down Expand Up @@ -592,6 +593,7 @@
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
Expand Down Expand Up @@ -82,7 +82,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -102,7 +101,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
6 changes: 5 additions & 1 deletion kernelExtension/kernelExtension.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
7D5208E81E41C23900832F57 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Objective-See";
TargetAttributes = {
7D5208F01E41C23900832F57 = {
Expand Down Expand Up @@ -204,13 +204,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -258,13 +260,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
8 changes: 8 additions & 0 deletions kernelExtension/kernelExtension/socketEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@ static kern_return_t data_out(void *cookie, socket_t so, const struct sockaddr *
// socket we're watching?
if(NULL == cookie)
{
//ignore
// but no errors
result = kIOReturnSuccess;

//bail
goto bail;
}
Expand Down Expand Up @@ -722,6 +726,10 @@ static kern_return_t connect_out(void *cookie, socket_t so, const struct sockadd
// socket we're watching?
if(NULL == cookie)
{
//ignore
// but no errors
result = kIOReturnSuccess;

//bail
goto bail;
}
Expand Down
6 changes: 5 additions & 1 deletion launchDaemon/launchDaemon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
7D7755C81F02DF9400D0017D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Objective-See";
TargetAttributes = {
7D7755CF1F02DF9500D0017D = {
Expand Down Expand Up @@ -367,13 +367,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -420,13 +422,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
7 changes: 7 additions & 0 deletions launchDaemon/launchDaemon/Alerts.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ -(NSMutableDictionary*)create:(struct networkOutEvent_s*)event process:(Process*
//add pid
alert[ALERT_PID] = [NSNumber numberWithUnsignedInt:event->pid];

//add args
if(0 != process.arguments.count)
{
//add
alert[ALERT_ARGS] = process.arguments;
}

//add path
alert[ALERT_PATH] = process.path;

Expand Down
6 changes: 6 additions & 0 deletions launchDaemon/launchDaemon/GrayList.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
@"com.apple.curl",
@"com.apple.ruby",
@"com.apple.perl",
@"com.apple.perl5",
@"com.apple.python",
@"com.apple.python2",
@"com.apple.pythonw",
@"com.apple.openssh",
@"com.apple.osascript"
};
Expand Down Expand Up @@ -64,6 +67,9 @@ -(BOOL)isGrayListed:(Process*)process
//process signing info
NSDictionary* signingInfo = nil;

//dbg info
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"checking if %@ is graylisted (signing info: %@)", process.path, process.binary.signingInfo]);

//has to be apple
if(YES != process.binary.isApple)
{
Expand Down
65 changes: 1 addition & 64 deletions launchDaemon/launchDaemon/KextListener.m
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ -(void)processNetworkOut:(struct networkOutEvent_s*)event
logMsg(LOG_DEBUG, [NSString stringWithFormat:@"no (saved) rule found for %@ (%d)", process.binary.name, process.pid]);

//if it's an apple process and that preference is set; allow!
// unless the binary is something like `curl` which malware could abuse (still alert!)
// unless the binary is something like 'curl' which malware could abuse (still alert!)
if( (YES == [preferences.preferences[PREF_ALLOW_APPLE] boolValue]) &&
(YES == process.binary.isApple))
{
Expand Down Expand Up @@ -873,67 +873,4 @@ -(Process*)findProcess:(pid_t)pid
return process;
}

//create an alert object
// note: can treat sockaddr_in and sockaddr_in6 as 'same same' for family, port, etc
-(NSMutableDictionary*)createAlert:(struct networkOutEvent_s*)event process:(Process*)process
{
//event for alert
NSMutableDictionary* alertInfo = nil;

//remote ip address
NSString* remoteAddress = nil;

//remote host name
NSString* remoteHost = nil;

//alloc
alertInfo = [NSMutableDictionary dictionary];

//covert IP address to string
remoteAddress = convertSocketAddr((struct sockaddr*)&(event->remoteAddress));

//add pid
alertInfo[ALERT_PID] = [NSNumber numberWithUnsignedInt:event->pid];

//add path
alertInfo[ALERT_PATH] = process.path;

//add (remote) ip
alertInfo[ALERT_IPADDR] = convertSocketAddr((struct sockaddr*)&(event->remoteAddress));

//try get host name from DNS cache
// since it's based on recv'ing data from kernel, try for a bit...
for(int i=0; i<5; i++)
{
//try grab host name
remoteHost = self.dnsCache[alertInfo[ALERT_IPADDR]];
if(nil != remoteHost)
{
//add
alertInfo[ALERT_HOSTNAME] = remoteHost;

//done
break;
}

//nap
[NSThread sleepForTimeInterval:0.10f];
}

//add (remote) port
alertInfo[ALERT_PORT] = [NSNumber numberWithUnsignedShort:ntohs(event->remoteAddress.sin6_port)];

//add protocol (socket type)
alertInfo[ALERT_PROTOCOL] = [NSNumber numberWithInt:event->socketType];

//add signing info
if(nil != process.binary.signingInfo)
{
//add
alertInfo[ALERT_SIGNINGINFO] = process.binary.signingInfo;
}

return alertInfo;
}

@end
1 change: 0 additions & 1 deletion launchDaemon/launchDaemon/ProcListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@
//setup/start process monitoring
-(void)monitor;


@end
Loading

0 comments on commit 2384323

Please sign in to comment.