当前位置:首页 > iOS > 正文内容

iPhone HOOK将所有请求保存到txt

4年前 (2017-09-18)iOS

%hook NSURL

- (NSString *)absoluteString{

NSString *orig = %orig;

if (![orig containsString:@"mzstatic.com"]&&![orig containsString:@"file:"]) {

        //NSLog(@"XHOOK-URL:%@",orig);

    }

return orig;

}

%end


%hook _AKAppleIDAuthenticationContextManager

- (void)shouldContinueWithAuthenticationResults:(id)arg1 error:(id)arg2 forContextID:(id)arg3 completion:(id /* block */)arg4{

    NSString *str = [NSString stringWithFormat:@"arg1:%@\nerror:%@\nforContextID:%@\ncompletion:%@\n\n",arg1,arg2,arg3,arg4];

    NSLog(@"XHOOK-%@",str);

    NSString *filepath = @"/var/mobile/Media/Results.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 

    %orig;

}

%end


%hook AKAbsintheSigner

+ (id)sharedSigner{

    NSLog(@"XHOOK-AKAbsintheSigner");

    return %orig;

}

- (id)signatureForURLRequest:(id)arg1{

    NSLog(@"XHOOK-AKAbsintheSigner");

    return %orig;

}

%end


%hook AKCircleRequestPayload

+ (id)payloadWithInfo:(id)arg1{

    id orig = %orig;

    NSLog(@"XHOOK-payloadWithInfo:,%@",orig);

    return orig;

}

%end


%hook AKAnisetteData

- (id)machineID{

    id orig = %orig;

    return orig;

}

- (id)oneTimePassword{

    id orig = %orig;

    return orig;

}

%end



%hook AKAppleIDSession

- (id)appleIDHeadersForRequest:(id)arg1{

    id orig = %orig;

    NSLog(@"XHOOK-appleIDHeadersForRequest:,%@,%@",arg1,orig);

    return orig;

}


- (void)_generateAppleIDHeadersForRequest:(id)arg1 withCompletion:(id /* block */)arg2{

    NSLog(@"XHOOK-_generateAppleIDHeadersForRequest:%@,%@",arg1,arg2);

    %orig;

}

%end

%hook AKAnisetteProvisioningController

- (id)anisetteDataForURLRequest:(id)arg1 error:(id*)arg2{

    id orig = %orig;

    NSLog(@"XHOOK-anisetteDataForURLRequest:,%@,%@",arg1,orig);

    return orig;

}

%end

%hook AKCertificatePinning

+ (BOOL)isValidCertificateTrust:(id)arg1 forHostname:(id)arg2{

    BOOL orig = %orig;

    NSLog(@"XHOOK-AKCertificatePinning:%@,,,%d",arg2,orig);

    return orig;

}

%end


%hook AKToken

+ (id)tokenWithBase64String:(id)arg1{

    id orig = %orig;

    NSLog(@"XHOOK-tokenWithBase64String:%@",orig);

    return orig;

}

+ (id)tokenWithValue:(id)arg1 lifetime:(id)arg2{

    id orig = %orig;

    NSLog(@"XHOOK-tokenWithValue:%@",orig);

    return orig;

}

%end


%hook ISURLOperation

- (NSURLRequest *)_activeURLRequest{

    NSURLRequest *orig = %orig;

    NSString *str = [NSString stringWithFormat:@"Request-URL:%@\nRequest-HTTPMethod:%@\nRequest-HEAD:%@\nRequest-DATA:%@\n\n",orig.URL.absoluteString,orig.HTTPMethod,orig.allHTTPHeaderFields,[[NSString alloc] initWithData:orig.HTTPBody  encoding:NSUTF8StringEncoding]];

    NSString *filepath = @"/var/mobile/Media/operation.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 

    return orig;

}

%end


%hook NSMutableURLRequest

- (NSString *)allHTTPHeaderFields{

 

    NSString *orig = %orig;

    

    NSString *str = [NSString stringWithFormat:@"Request-URL:%@\nRequest-HTTPMethod:%@\nRequest-HEAD:%@\nRequest-DATA:%@\n\n",[self URL].absoluteString,[self HTTPMethod],orig,[[NSString alloc] initWithData:[self HTTPBody]  encoding:NSUTF8StringEncoding]];

    

    NSString *filepath = @"/var/mobile/Media/allrequest.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 

    return orig;

}

%end


%hook OAHMAC_SHA1Signer

+ (id)signatureForText:(id)arg1 withKey:(id)arg2{

    NSLog(@"XHOOK-OAHMAC_SHA1Signer");

    return %orig;

}

%end

%hook OAPlainTextSigner

+ (id)signatureForText:(id)arg1 withKey:(id)arg2{

    NSLog(@"XHOOK-OAPlainTextSigner");

    return %orig;

}

%end

%hook OAURLRequestSigner

- (id)applyApplicationID:(id)arg1 toRequest:(id)arg2 containsMultiPartData:(BOOL)arg3{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)initWithCredential:(id)arg1{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)oauthAuthorizationHeaderWithSignature:(id)arg1 nonce:(id)arg2 timestamp:(id)arg3{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)oauthNonce{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)oauthParametersWithNonce:(id)arg1 timeStamp:(id)arg2{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (int)signatureMethod{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)signatureMethodString{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)signedURLRequestWithRequest:(id)arg1{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)signedURLRequestWithRequest:(id)arg1 applicationID:(id)arg2 timestamp:(id)arg3{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

- (id)timestamp:(id)arg1{

    NSLog(@"XHOOK-OAURLRequestSigner");

    return %orig;

}

%end


%hook ISAuthenticationChallenge

- (id)password{

    id orig = %orig;

    NSLog(@"XHOOK-password:%@",orig);

    return orig;

}

%end

%hook ISURLAuthenticationChallenge

- (id)password{

    id orig = %orig;

    NSLog(@"XHOOK-password:%@",orig);

    return orig;

}

%end


%hook ISStoreURLOperation

+ (void)_addITunesStoreHeadersToRequest:(NSMutableURLRequest *)arg1 withURLBag:(id)arg2 account:(id)arg3 clientBundleIdentifier:(id)arg4{

    //NSLog(@"XHOOK-ISStoreURLOperation-_addITunesStoreHeadersToRequest1:%@",arg1);

    

    NSMutableURLRequest *orig = arg1;

    //NSLog(@"XHOOK-AIASRequest1-URL:%@",orig.URL.absoluteString);

    NSString *str = [NSString stringWithFormat:@"Request-URL:%@\nRequest-HTTPMethod:%@\nRequest-HEAD:%@\nRequest-DATA:%@\n\n",orig.URL.absoluteString,orig.HTTPMethod,orig.allHTTPHeaderFields,[[NSString alloc] initWithData:orig.HTTPBody  encoding:NSUTF8StringEncoding]];

    NSString *filepath = @"/var/mobile/Media/auth.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 

    

    %orig;

}

+ (void)_addITunesStoreHeadersToRequest:(NSMutableURLRequest *)arg1 withURLBag:(id)arg2 accountIdentifier:(id)arg3 clientBundleIdentifier:(id)arg4{

    //NSLog(@"XHOOK-ISStoreURLOperation-_addITunesStoreHeadersToRequest2:%@",arg1);

    

    NSMutableURLRequest *orig = arg1;

    //NSLog(@"XHOOK-AIASRequest2-URL:%@",orig.URL.absoluteString);

    NSString *str = [NSString stringWithFormat:@"Request-URL:%@\nRequest-HTTPMethod:%@\nRequest-HEAD:%@\nRequest-DATA:%@\n\n",orig.URL.absoluteString,orig.HTTPMethod,orig.allHTTPHeaderFields,[[NSString alloc] initWithData:orig.HTTPBody  encoding:NSUTF8StringEncoding]];

    NSString *filepath = @"/var/mobile/Media/auth.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 

    

    %orig;

}

%end


%hook ISURLRequest

- (id)HTTPBodyStream{

    //NSLog(@"XHOOK-ISURLRequest-HTTPBodyStream");

    return %orig;

}

- (NSData *)HTTPBody{

    //NSLog(@"XHOOK-ISURLRequest-HTTPBody");

    NSData * orig = %orig;

    NSString *str = [NSString stringWithFormat:@"%@\n\n",[[NSString alloc] initWithData:orig  encoding:NSUTF8StringEncoding]];

    NSString *filepath = @"/var/mobile/Media/req_data.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"开始了:\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 

    

    return orig;

}

%end


%hook AIASRequest

- (NSMutableURLRequest *)URLRequest{

    NSMutableURLRequest *orig = %orig;

    //NSLog(@"XHOOK-AIASRequest-URL:%@",orig.URL.absoluteString);

    NSString *str = [NSString stringWithFormat:@"Request-URL:%@\nRequest-HTTPMethod:%@\nRequest-HEAD:%@\nRequest-DATA:%@\n\n",orig.URL.absoluteString,orig.HTTPMethod,orig.allHTTPHeaderFields,[[NSString alloc] initWithData:orig.HTTPBody  encoding:NSUTF8StringEncoding]];

    NSString *filepath = @"/var/mobile/Media/gsa.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 

    return orig;

}


- (NSData *)data{

    NSData *orig = %orig;

    NSString *str = [NSString stringWithFormat:@"%@\n\n",[[NSString alloc] initWithData:orig  encoding:NSUTF8StringEncoding]];

    

    NSString *filepath = @"/var/mobile/Media/gsaresponse.txt";

    NSFileManager *fileManager = [NSFileManager defaultManager];

     if (![fileManager fileExistsAtPath:filepath]) {

        NSString *s = [NSString stringWithFormat:@"开始了:\r"];  

        [s writeToFile:filepath atomically:YES encoding:NSUTF8StringEncoding error:nil];

    }

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filepath];

    [fileHandle seekToEndOfFile];

    NSData* stringData  = [str dataUsingEncoding:NSUTF8StringEncoding];

    [fileHandle writeData:stringData];

    [fileHandle closeFile]; 


    return orig;

}



%end


扫描二维码推送至手机访问。

版权声明:本文由小祥子的博客发布,如需转载请注明出处。

本文地址:http://www.xiaoxiangzi.com/post/64.html

相关文章

iOS10越狱后yalu102无法连接SSH的解决办法

用Filza修改/private/var/containers/Bundle/Application/{UUID}/yalu102.app/dropbear.plist把里面有个参数127.0.0.1...

AuthKit之AKAccountManager

+ (BOOL)isAccountsFrameworkAvailable;检测服务是否可用- (id)_tokenWithName:(id)arg1 forAccount:(id)arg2;生成tok...

APPStore协议之下载接口

两次下载抓包发现所提交参数只有两个地方不一样,一个自然是软件的id,另外一个则是kbsync。接口地址:https://buy.itunes.apple.com/WebObjects/MZBuy.wo...

APPStore协议研究

最近闲来无事研究iOS逆向,逆向了手机淘宝,HOOK淘宝的任意类和函数,后来又研究了APPStore,用抓包工具发现分析不到传输过程,分析他可能是指定了通讯用的证书,通过代理的证书他不信任。后来分析内...

IOS开发已学完

最近一直在学习IOS开发,swift基本学会了,IOS编程基本就是语法与各种类库、UI组件的使用。有点编程基础很容易上手。Objective C的类库比swift多的多,不过还好swift可以调用Ob...

iTunes&AppStore登录窗口

今天逆向找了半天,找出在设置里的itunes store与appstore点击登录后显示的登录框。涉及framework有authkit与authkitui.framework其中一个可疑的方法- (...