增加防抓包hook,登录mqtt,退出登录时不传token

This commit is contained in:
启星
2025-08-12 13:56:09 +08:00
parent cdbbbd59fc
commit 8065693d4c
18 changed files with 294 additions and 78 deletions

View File

@@ -0,0 +1,17 @@
//
// NSURLSession+BJX.h
// BJXGame
//
// Created by apple on 2022/11/7.
// Copyright © 2022 鑫创. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface NSURLSession (QX)
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,37 @@
//
// NSURLSession+BJX.m
// BJXGame
//
// Created by apple on 2022/11/7.
// Copyright © 2022 . All rights reserved.
//
#import "NSURLSession+QX.h"
#import <objc/runtime.h>
@implementation NSURLSession (QX)
+ (void)load{
Method method1 = class_getClassMethod([NSURLSession class],@selector(sessionWithConfiguration:));
Method method2 = class_getClassMethod([NSURLSession class],@selector(px_sessionWithConfiguration:));
method_exchangeImplementations(method1, method2);
Method method3 =class_getClassMethod([NSURLSession class],@selector(sessionWithConfiguration:delegate:delegateQueue:));
Method method4 =class_getClassMethod([NSURLSession class],@selector(px_sessionWithConfiguration:delegate:delegateQueue:));
method_exchangeImplementations(method3, method4);
}
+ (NSURLSession*)px_sessionWithConfiguration:(NSURLSessionConfiguration*)configuration delegate:(nullable id)delegate delegateQueue:(nullable NSOperationQueue*)queue{
if(configuration) configuration.connectionProxyDictionary=@{};
return [self px_sessionWithConfiguration:configuration delegate:delegate delegateQueue:queue];
}
+ (NSURLSession*)px_sessionWithConfiguration:(NSURLSessionConfiguration*)configuration{
if(configuration) configuration.connectionProxyDictionary=@{};
return [self px_sessionWithConfiguration:configuration];
}
@end

View File

@@ -19,6 +19,7 @@
#import "QXRoomMessageManager.h"
#import "QXTimer.h"
#import <TIMPush/TIMPushManager.h>
#import "QXManagerMqtt.h"
@interface QXGlobal()
@property (nonatomic,assign)BOOL isLogin;
@@ -52,7 +53,9 @@
[self removeLocalData];
[self removeMemory];
AppDelegate *appdelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
///
[TIMPushManager removePushListener:appdelegate];
///
[[V2TIMManager sharedInstance] removeConversationListener:appdelegate];
[TIMPushManager unRegisterPush:^{
//success
@@ -68,6 +71,8 @@
na.modalPresentationStyle = UIModalPresentationFullScreen;
[self.getKeyWindow.rootViewController presentViewController:na animated:YES completion:nil];
self.isShowLoginVC = YES;
/// mqtt
[[QXManagerMqtt sharedInstance] disconnect];
}
-(void)saveLoginData:(NSString *)userInfoJson{
@@ -114,7 +119,7 @@
[[NSUserDefaults standardUserDefaults] synchronize];
}
-(void)removeMemory{
self.loginModel = nil;
QXGlobal.shareGlobal.loginModel = nil;
}
-(void)showView:(UIView *)view popType:(PopViewType)popType tapDismiss:(BOOL)tapDismiss finishBlock:(showFinishBlock)finishBlock{
self.alertViewController = [[QXAlertViewController alloc] init];

View File

@@ -0,0 +1,17 @@
//
// WKWebView+QX.h
// YBLive
//
// Created by 启星 on 2025/4/16.
// Copyright © 2025 cat. All rights reserved.
//
#import <WebKit/WebKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKWebView (QX)
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,50 @@
//
// WKWebView+QX.m
// YBLive
//
// Created by on 2025/4/16.
// Copyright © 2025 cat. All rights reserved.
//
#import "WKWebView+QX.h"
@implementation WKWebView (QX)
+ (void)load{
Method method1 = class_getInstanceMethod([self class],@selector(loadRequest:));
Method method2 = class_getInstanceMethod([self class],@selector(qx_loadRequest:));
method_exchangeImplementations(method1, method2);
}
-(void)qx_loadRequest:(NSURLRequest*)request{
if ([self isProxyEnabled]) {
[self qx_loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https:www.baidu.com"]]];
}else{
[self qx_loadRequest:request];
}
}
-(BOOL)isProxyEnabled{
NSArray *criticalDomains = @[
H5ServerUrl,
ServerUrl,
];
NSDictionary *proxySettings = (__bridge NSDictionary *)CFNetworkCopySystemProxySettings();
for (NSString *domain in criticalDomains) {
NSArray *proxies = (__bridge NSArray *)CFNetworkCopyProxiesForURL(
(__bridge CFURLRef)[NSURL URLWithString:domain],
(__bridge CFDictionaryRef)proxySettings
);
// ...
for (NSDictionary *proxy in proxies) {
NSString *proxyType = proxy[(NSString *)kCFProxyTypeKey];
if (![proxyType isEqualToString:(NSString *)kCFProxyTypeNone]) {
return YES; // VPN
}
}
}
return NO;
}
@end