|
/* |
|
#include <mach-o/dyld.h> |
|
#include <mach-o/getsect.h> |
|
*/ |
|
#import <substrate.h> |
|
|
|
%hook NSMutableURLRequest |
|
-(NSMutableURLRequest*)initWithURL:(NSURL *)URL |
|
cachePolicy:(NSURLRequestCachePolicy)cachePolicy |
|
timeoutInterval:(NSTimeInterval)timeoutInterval |
|
{ |
|
if ([[URL host] isEqualToString: @"arcapi.lowiro.com"]) { |
|
NSURLComponents *components = [NSURLComponents componentsWithURL:URL resolvingAgainstBaseURL:YES]; |
|
components.host = @"arc.estertion.win"; |
|
URL = components.URL; |
|
#ifdef DEBUG |
|
NSLog(@"[ArcApiServer] redirected to %@", URL); |
|
#endif |
|
return %orig(URL, cachePolicy, timeoutInterval); |
|
} else if ([[URL host] isEqualToString: @"truecolor.kirara.ca"]) { |
|
// DereGuide image server fix, because i'm iOS 9 |
|
NSURLComponents *components = [NSURLComponents componentsWithURL:URL resolvingAgainstBaseURL:YES]; |
|
components.host = @"hidamarirhodonite.kirara.ca"; |
|
URL = components.URL; |
|
#ifdef DEBUG |
|
NSLog(@"[ArcApiServer] redirected to %@", URL); |
|
#endif |
|
return %orig(URL, cachePolicy, timeoutInterval); |
|
} else { |
|
return %orig; |
|
} |
|
} |
|
%end |
|
/* |
|
// attempt to hook strcpy, which seems to be called when game initializing, but failed |
|
|
|
static const char* originalServer = "https://arcapi.lowiro.com/4/"; |
|
static const char* modifiedServer = "https://arc.estertion.win/4/"; |
|
%hookf(char *, strcpy, char * destination, const char * source) { |
|
if (strlen(source) == 28) |
|
NSLog(@"[ArcApiServer] %s", source); |
|
if (strcmp(source, originalServer) == 0) { |
|
NSLog(@"[ArcApiServer] api endpoint hijacked"); |
|
return %orig(destination, modifiedServer); |
|
} |
|
return %orig; |
|
}*/ |
|
/* |
|
// attempt to modify executable binary in memory, but failed because of execution protection (memory address can't be both executable and writable) |
|
|
|
%ctor { |
|
const char* imgName = _dyld_get_image_name(0); |
|
NSLog(@"[ArcApiServer] Image #%d: %s", 0, imgName); |
|
const struct mach_header_64 *mhp = (const struct mach_header_64*)_dyld_get_image_header(0); |
|
uint64_t sectionSize = 0; |
|
char *textSectionPtr = getsectdatafromheader_64(mhp, "__TEXT", "__cstring", §ionSize); |
|
NSLog(@"[ArcApiServer] __TEXT __cstring %p data size: %llu", textSectionPtr, sectionSize); |
|
textSectionPtr++; |
|
|
|
const char* originalServer = "https://arcapi.lowiro.com/4/"; |
|
const char* modifiedServer = "https://arc.estertion.win/4/"; |
|
while (sectionSize > 0) { |
|
uint32_t len = strlen(textSectionPtr); |
|
//NSLog(@"[ArcApiServer] string size: %u", len); |
|
if (len == 28 && strcmp(textSectionPtr, originalServer) == 0) { |
|
NSLog(@"[ArcApiServer] Found server string at %p, %s", textSectionPtr, textSectionPtr); |
|
@try{ |
|
for (uint32_t i=0; i < 28; i++) { |
|
*(textSectionPtr + i) = *(modifiedServer + i); |
|
} |
|
} @catch (NSException* e) { |
|
NSLog(@"[ArcApiServer] %@", e); |
|
} |
|
break; |
|
} else { |
|
textSectionPtr += len + 1; |
|
sectionSize -= len + 1; |
|
} |
|
} |
|
}*/ |