当前位置:首页 > 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

相关文章

iOS APP逆向工程资料

最近在研究iOS逆向工程,整理了如下资料以供今后参考。概览工具清单做 iOS 逆向开发,要有的基本意识是,首先要有一台越狱设备,其次,要至少了解以下工具。工具名称作用Cydia越狱机上的安装软件包的软...

IOS开发已学完

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

iOS layer addAnimation动画

使用方法:[view.layer addAnimation:<#(nonnull CAAnimation *)#> forKey:nil]+(CAT...

两次登录POST参数对比

接口地址https://p19-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate同一个账号进行两次登录对比X-Apple-AM...

cycript快速定位ViewController

打印当前视图层次UIApp.keyWindow.recursiveDescription().toString()获取上级响应者[#id nextResponder]通过这两个代码可以定位当...

iOS OC文件大小计算

+ (NSString *)fileSizeWithInterge:(NSInteger)size{     if (size&...