Last active
December 28, 2023 20:34
-
-
Save p4yl0ad/5b24edae8629eeac3f54b92a99f91d0a to your computer and use it in GitHub Desktop.
poc to test symbolic link for specific target
This file contains hidden or 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
/* gcc -framework Foundation hardlinktest.m -o hardlinktest */ | |
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
if (argc < 2) { | |
NSLog(@"Usage: hardlinktest <path>"); | |
return 1; // Indicate error | |
} | |
NSFileManager * fm = [NSFileManager defaultManager]; | |
NSString * currentDirectoryPath = [fm currentDirectoryPath]; | |
NSLog(@"[INFO] Current directory is %@", currentDirectoryPath); | |
NSArray *arguments = [[NSProcessInfo processInfo] arguments]; | |
NSString *path = arguments[1]; | |
NSLog(@"[INFO] File passed on cli is %@", path); | |
NSString *filePath = [currentDirectoryPath stringByAppendingPathComponent:path]; | |
NSLog(@"[INFO] Full file path is %@", filePath); | |
NSDictionary* dict = [fm attributesOfItemAtPath:filePath error:nil]; | |
NSString* o = [dict objectForKey:NSFileType]; | |
BOOL b = [o isEqualToString:NSFileTypeSymbolicLink]; | |
NSLog(@"b is? %hdd", b); | |
BOOL b2 = [o isEqualToString:NSFileTypeSymbolicLink] != 0x0 ? 0x1 : 0x0; | |
NSLog(@"b2 is? %hdd", b2); | |
NSLog(@"is? %d", b & 0x1 & 0xff); | |
if (((b2 & 0x1 & 0xff) & 0x1 ) != 0x0 ) { | |
NSLog(@"IS SYMBOLIC LINK!! BAD!!"); | |
} | |
} | |
NSLog(@"LE FIN!!!"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment