Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MHProxyFactory.m
- // MineHelmet
- //
- // Created by Dylan Lukes on 10/22/10.
- // Copyright 2010 Dylan Lukes. All rights reserved.
- //
- #import "MHProxyManager.h"
- #import "APELite.h"
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <netdb.h>
- @interface MHProxyManager (PrivateMethods)
- - (int)handleConnectAttempt:(int)socket addr:(const struct sockaddr *)addr addrlen:(socklen_t)addrlen;
- - (void)proxyCreateThread:(NSValue *)saObj;
- - (void)startWorkerThreadRunLoop;
- @end
- static MHProxyManager *instance_pointer;
- static int connect_override(int socket, const struct sockaddr *address, socklen_t addrlen){
- return [instance_pointer handleConnectAttempt:socket addr:address addrlen:addrlen];
- }
- @implementation MHProxyManager
- + (id)sharedInstance {
- static dispatch_once_t pred;
- static MHProxyManager *instance = nil;
- dispatch_once(&pred, ^{ instance = [[self alloc] init]; });
- return instance;
- }
- - (id)init {
- if (self = [super init]) {
- connectReentry = APEPatchCreate(connect, connect_override);
- instance_pointer = self;
- // Instantiate a thread object
- proxyThread = [[NSThread alloc] init];
- }
- return self;
- }
- - (int)handleConnectAttempt:(int)socket addr:(const struct sockaddr *)addr addrlen:(socklen_t)addrlen {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- if (addr->sa_family == AF_INET6) {
- struct sockaddr_in6 *sa = (struct sockaddr_in6 *)addr;
- in_port_t port = ntohs(sa->sin6_port);
- if(!(port > 50000 || port == 80)) {
- /* HIDDEN CODE :O */
- }
- }
- [pool drain];
- return connectReentry(socket, addr, addrlen);
- }
- - (void)proxyCreateThread:(NSValue *)saObj {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- proxy = [[MHProxy alloc] initWithDestAddress:NULL];
- [pool drain];
- }
- - (void)startWorkerThreadRunLoop {
- [[NSRunLoop currentRunLoop] run];
- }
- @end
Add Comment
Please, Sign In to add comment