Created
December 17, 2010 05:19
-
-
Save staktrace/744522 to your computer and use it in GitHub Desktop.
Mac OS X cookie dumper (for google.com)
This file contains 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
#import <stdio.h> | |
#import <Foundation/NSHTTPCookieStorage.h> | |
#import <Foundation/NSHTTPCookie.h> | |
#import <Foundation/NSURL.h> | |
#import <Foundation/NSString.h> | |
#import <Foundation/NSArray.h> | |
#import <Foundation/NSEnumerator.h> | |
int main( int argc, const char* argv[] ) { | |
NSURL *url = [[NSURL alloc] initWithString: @"http://google.com"]; | |
NSArray* cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url]; | |
printf( "%lu cookies found\n", [cookies count] ); | |
NSEnumerator* i = [cookies objectEnumerator]; | |
id obj; | |
while (obj = [i nextObject]) { | |
if ([obj isMemberOfClass: [NSHTTPCookie class]] == YES) { | |
const char* name = [[obj name] UTF8String]; | |
const char* value = [[obj value] UTF8String]; | |
printf( "cookie: [%s]=[%s]\n", name, value ); | |
} | |
} | |
printf( "all done\n" ); | |
return 0; | |
} | |
// to make: | |
// gcc test.m /System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment