Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 9700393

Browse files
committed
Add long missing NSURLConnection Delegate Methods
1 parent 368c6ac commit 9700393

File tree

5 files changed

+61
-23
lines changed

5 files changed

+61
-23
lines changed

DOCS/HackingGuide.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#Hacking Guide
2-
##This is the guide for you to start adding modules/tools to the repo
1+
# Hacking Guide
2+
## This is the guide for you to start adding modules/tools to the repo
33

44

5-
###Modules
5+
### Modules
66
Modules can be generated by running ./Template.py Type Name
77

88
Current Types:
@@ -20,44 +20,45 @@ Also.There is a init_XXX_hook function inside each module,which XXX in your modu
2020

2121
The main tweak will call that to init your hook.Check below for details
2222

23-
####Names
24-
#####For Modules.
23+
#### Names
24+
##### For Modules.
2525
All these must be the same.
2626

2727
1. Module File Name
2828
2. init function name component (see Modules Part)
2929

3030
*Please make sure the names are short and descriptive. We generate settings button text base on module name*
3131

32-
####For Third Party Components
33-
**Read ThirdPartyTools/README.md for detailed info **
32+
#### For Third Party Components
3433

34+
**Read ThirdPartyTools/README.md for detailed info**
3535

36-
####Prototype Codes
36+
37+
#### Prototype Codes
3738
Some codes, you might not want to expose them directly. Either because they have bugs, or, they are incomplete.
3839

3940
Put These Codes Inside **#ifdef PROTOTYPE** and **#endif**
4041

4142
These codes will be enabled only when PROTOTYPE Flag for build.py is *Implicitly* turned on.(See Below)
4243

4344

44-
####Custom Preferences
45+
#### Custom Preferences
4546
Add Your Own Preferences in **Preferences/** With Filename **MODULENAME.plist**
4647

4748
They will be injected into the *items* of the final Preferences Loader PLIST file
4849

49-
####Marcos
50+
#### Marcos
5051
Two Groups Of Marcos Has Been Created For Logging Purposes.
5152
Please Call Exactly In The Following Sequence
52-
#####Common Logging
53+
##### Common Logging
5354
1. WTInit(ClassName,methodName) **(For C Functions. Change ClassName to Library Name. For Example dlopen corresponds to dlfcn because it's in dlfcn.h)**
5455
2. WTAdd(Argument,Name) **The First is the argument itself. The second is the argument name**
5556
3. WTReturn(Return) **Return is the return value to add**
5657
4. WTSave **No Arguments. It saves the log to database.**
5758
5. WTRelease **Release The Memory Of The Logger**
5859
6. WTShouldLog **if(WTShouldLog){} to check if it's called by the app itself**
5960

60-
#####Hooking
61+
##### Hooking
6162
Wrappers of MS API Are in Hooks/Misc/WTSubstrate.h
6263

6364
Currently
@@ -70,7 +71,7 @@ Are available with the exact same usage with their MS* Equivalent
7071
Use them instead of MS** Ones as they take care of jailed situation
7172

7273

73-
#####dyld CallBack
74+
##### dyld CallBack
7475
1. WTCallBack(LibraryName,FunctionToCall) **Generate A Function That Call FunctionToCall() when an image which path containing LibraryName is loaded. You Can Init Hooks inside FunctionToCall**
7576
2. WTAddCallBack(Loader) **Register the callback with dyld and execute Loader().Please Note That Loader Should Be The Function That Actually Init The Hooks,Not The CallBack**
7677

@@ -82,7 +83,7 @@ Please Note:
8283
4. Don't add semicolon to WTCallBack
8384
5. Only One Set Of **dyld CallBack** Marcos Can Be Called In A Module
8485

85-
####Building
86+
#### Building
8687
You Probably Need The Latest Substrate Header. Check [Issues#1](https://github.com/Naville/WTFJH/issues/1) In Case Something Went Wrong.
8788

8889
Usually. Simple run **./build.py** is enough
@@ -96,7 +97,7 @@ Other Arguments(Upper/Lower Case Doesn't Matter):
9697

9798

9899

99-
####Misc
100+
#### Misc
100101
Some functions don't come with the binary and you'll have to wait the related library to be loaded
101102

102103
**Example: libMobileGestalt**
@@ -117,7 +118,7 @@ Make sure it's correctly signed
117118
Everything in BuildConfig should be pretty self-explainary. Except *CreateExtraSegs* , which is a dict, used to inject file-on-disk into the tweak. Key is SegmentName and Value is path to the file
118119

119120

120-
####Limitations
121+
#### Limitations
121122

122123
syscall and its variations are no longer hooked as it's unstable and they are only barely a wrapper for corresponding assembly instruction, which is impossible to hook
123124

Hooks/Utils/NSURLConnectionDelegateProx.m

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
#import "../Global.h"
44

55

6-
@implementation NSURLConnectionDelegateProx
6+
@implementation NSURLConnectionDelegateProx{
7+
NSMutableData* responseData;
8+
NSString* originalDelegateName;
9+
}
710

811

912
@synthesize originalDelegate;
@@ -14,6 +17,7 @@ - (NSURLConnectionDelegateProx*) initWithOriginalDelegate:(id)origDeleg {
1417

1518
if (self) { // Store original delegate
1619
[self setOriginalDelegate:(origDeleg)];
20+
self->originalDelegateName=NSStringFromClass([origDeleg class]);
1721
}
1822
return self;
1923
}
@@ -58,5 +62,40 @@ - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSUR
5862
[tracer release];
5963
return origResult;
6064
}
65+
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
66+
self->responseData=[NSMutableData new];
67+
[originalDelegate connection:connection didReceiveResponse:response];
68+
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"NSURLConnectionDelegate" andMethod:@"connection:didReceiveResponse:"];
69+
[tracer addArgFromPlistObject:[NSNumber numberWithUnsignedInt: (unsigned int) connection] withKey:@"connection"];
70+
[tracer addArgFromPlistObject:[PlistObjectConverter convertNSURLResponse:response] withKey:@"response"];
71+
[traceStorage saveTracedCall:tracer];
72+
[tracer release];
73+
return;
74+
75+
}
76+
77+
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
78+
[self->responseData appendData:data];
79+
[originalDelegate connection:connection didReceiveData:data];
80+
}
81+
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
82+
[originalDelegate connectionDidFinishLoading:connection];
83+
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"NSURLConnectionDelegate" andMethod:@"connectionDidFinishLoading:"];
84+
[tracer addArgFromPlistObject:[NSNumber numberWithUnsignedInt: (unsigned int) connection] withKey:@"connection"];
85+
[tracer addArgFromPlistObject:[self->responseData copy] withKey:@"Data"];
86+
[traceStorage saveTracedCall:tracer];
87+
[tracer release];
88+
[self->responseData release];
89+
return ;
90+
91+
}
92+
93+
/*- (nullable NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)request;
94+
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten
95+
totalBytesWritten:(NSInteger)totalBytesWritten
96+
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
97+
- (void)connection:(NSURLConnection *)connection didWriteData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long) expectedTotalBytes;
98+
- (void)connectionDidResumeDownloading:(NSURLConnection *)connection totalBytesWritten:(long long)totalBytesWritten expectedTotalBytes:(long long) expectedTotalBytes;
99+
- (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *) destinationURL;*/
61100

62101
@end

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# What The Fuck Just Happened
22

3-
*DO NOT USE PRE-BUILT BINARY*
4-
53
*Theos-Legacy is no longer Supported. Run ./CIScripts/InstallTheos.sh To Install The Latest Version of Theos*
64

75
**You Must Be THIS TALL To Ride**
86

97
> A Modern Replacement For IntroSpy [iSECPartners/Introspy-iOS][1]
108
11-
> Feel Free To Send Us Pull Requests.
9+
> Feel Free To Send Us Pull Requests.
1210
1311
> It's a project too big for two part-time developers
1412
@@ -29,7 +27,7 @@
2927
>Standard User:
3028
3129
1. ./Setup.sh **This should be executed everytime after you pull from the repo**
32-
2. ./build.py
30+
2. ./build.py DEBUG
3331
3. PROFIT??!!
3432

3533
>Tools/ Contains Important Tools

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
517
1+
518

capstone

0 commit comments

Comments
 (0)