├── YKBLock
├── ch.dylib
├── rd.dylib
├── ch.framework
│ ├── ch
│ ├── Info.plist
│ └── _CodeSignature
│ │ └── CodeResources
├── plugin
│ ├── dylibs
│ │ ├── ch.dylib
│ │ ├── lib.dylib
│ │ ├── rd.dylib
│ │ └── main.dylib
│ ├── NetWorkingApiClient.h
│ ├── ENCTool
│ │ ├── NSData+Base64.h
│ │ ├── NSString+Base64.h
│ │ ├── SCLAlertView
│ │ │ ├── SCLTextView.h
│ │ │ ├── SCLAlertViewResponder.h
│ │ │ ├── SCLSwitchView.h
│ │ │ ├── SCLAlertViewResponder.m
│ │ │ ├── SCLTimerDisplay.h
│ │ │ ├── SCLTextView.m
│ │ │ ├── SCLMacros.h
│ │ │ ├── SCLAlertViewStyleKit.h
│ │ │ ├── SCLButton.h
│ │ │ ├── SCLSwitchView.m
│ │ │ ├── SCLTimerDisplay.m
│ │ │ ├── SCLButton.m
│ │ │ ├── UIImage+ImageEffects.h
│ │ │ └── UIImage+ImageEffects.m
│ │ ├── RSA.h
│ │ ├── AESCrypt.h
│ │ ├── NSString+Base64.m
│ │ ├── NSData+Base64.m
│ │ ├── NSData+CommonCrypto.h
│ │ ├── AESCrypt.m
│ │ └── RSA.m
│ ├── plugin-Prefix.pch
│ ├── XVC.h
│ ├── Verify
│ │ ├── LRKeychain.h
│ │ ├── ZJHURLProtocol.h
│ │ ├── ZJHSessionConfiguration.h
│ │ ├── ZJHSessionConfiguration.m
│ │ ├── LRKeychain.m
│ │ └── ZJHURLProtocol.mm
│ ├── AFNetworking
│ │ ├── AFNetworking.h
│ │ ├── AFSecurityPolicy.h
│ │ ├── AFNetworkReachabilityManager.h
│ │ ├── AFURLResponseSerialization.h
│ │ ├── AFHTTPSessionManager.h
│ │ ├── AFURLRequestSerialization.h
│ │ ├── AFURLSessionManager.h
│ │ ├── AFNetworkReachabilityManager.m
│ │ ├── AFSecurityPolicy.m
│ │ └── AFHTTPSessionManager.m
│ ├── NetWorkingApiClient.m
│ ├── fishhook
│ │ ├── fishhook.h
│ │ └── fishhook.c
│ ├── plugin.xm
│ ├── AntiAntiDebug.m
│ └── plugin.mm
├── CydiaSubstrate.framework
│ ├── CydiaSubstrate
│ ├── CydiaSubstrate.tbd
│ └── Info.plist
├── YLBLOCK.xcodeproj
│ ├── xcuserdata
│ │ ├── apple.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ └── yuayu.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ └── project.xcworkspace
│ │ ├── xcuserdata
│ │ ├── apple.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── yuayu.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── Plugin_F
│ ├── Property List.plist
│ └── Plugin_F.entitlements
└── README.md
/YKBLock/ch.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/ch.dylib
--------------------------------------------------------------------------------
/YKBLock/rd.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/rd.dylib
--------------------------------------------------------------------------------
/YKBLock/ch.framework/ch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/ch.framework/ch
--------------------------------------------------------------------------------
/YKBLock/plugin/dylibs/ch.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/plugin/dylibs/ch.dylib
--------------------------------------------------------------------------------
/YKBLock/plugin/dylibs/lib.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/plugin/dylibs/lib.dylib
--------------------------------------------------------------------------------
/YKBLock/plugin/dylibs/rd.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/plugin/dylibs/rd.dylib
--------------------------------------------------------------------------------
/YKBLock/plugin/dylibs/main.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/plugin/dylibs/main.dylib
--------------------------------------------------------------------------------
/YKBLock/CydiaSubstrate.framework/CydiaSubstrate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/CydiaSubstrate.framework/CydiaSubstrate
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/xcuserdata/apple.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/xcuserdata/yuayu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/YLBLOCK.xcodeproj/project.xcworkspace/xcuserdata/apple.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/project.xcworkspace/xcuserdata/yuayu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiaohua63/YKBLock-For-iPA/HEAD/YKBLock/YLBLOCK.xcodeproj/project.xcworkspace/xcuserdata/yuayu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/YKBLock/Plugin_F/Property List.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSUserTrackingUsageDescription
6 | 此标识符将作为设备授权绑定
7 |
8 |
9 |
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/YKBLock/plugin/NetWorkingApiClient.h:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // NetWorkingApiClient.h
4 | // BSPHPOC
5 | //
6 | // Created by MRW on 2016/12/14.
7 | // Copyright © 2016年 xiaozhou. All rights reserved.
8 | //
9 |
10 | #import "AFNetworking.h"
11 |
12 | @interface NetWorkingApiClient : AFHTTPSessionManager
13 | + (NetWorkingApiClient *)sharedNetWorkingApiClient;
14 | @end
15 |
--------------------------------------------------------------------------------
/YKBLock/Plugin_F/Plugin_F.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | keychain-access-groups
6 |
7 | $(AppIdentifierPrefix)dad.dadwdawd.alertview
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/NSData+Base64.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+Base64.m
3 | // Gurpartap Singh
4 | //
5 | // Created by Gurpartap Singh on 06/05/12.
6 | // Copyright (c) 2012 Gurpartap Singh. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class NSString;
12 |
13 | @interface NSData (Base64Additions)
14 |
15 | + (NSData *)base64DataFromString:(NSString *)string;
16 |
17 | @end
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/NSString+Base64.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+Base64.h
3 | // Gurpartap Singh
4 | //
5 | // Created by Gurpartap Singh on 06/05/12.
6 | // Copyright (c) 2012 Gurpartap Singh. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSString (Base64Additions)
12 |
13 | + (NSString *)base64StringFromData:(NSData *)data length:(NSUInteger)length;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/YKBLock/plugin/plugin-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'plugin' target in the 'plugin' project
3 | //
4 | #ifndef PureStandard_PrefixHeader_pch
5 | #define PureStandard_PrefixHeader_pch
6 | #ifdef __OBJC__
7 | // #import
8 | #import "codeObfuscation.h"
9 | #import "/opt/theos/Prefix.pch" //path/to/theos/Prefix.pch
10 | #endif
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLTextView.h:
--------------------------------------------------------------------------------
1 | //
2 | // SCLTextView.h
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 9/18/15.
6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #if defined(__has_feature) && __has_feature(modules)
10 | @import UIKit;
11 | #else
12 | #import
13 | #endif
14 |
15 | @interface SCLTextView : UITextField
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/YKBLock/plugin/XVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // XRKSettingsViewController.h
3 | // hookwechat
4 | //
5 | // Created by TsuiYuenHong on 2017/3/4.
6 | //
7 | //
8 |
9 | #import
10 |
11 | @interface XRKSettingsViewController : UIViewController
12 |
13 | @end
14 |
15 | @interface SHFontCycleLabel : UIView
16 |
17 |
18 | @property (nonatomic, strong) UILabel *myLabel;
19 |
20 | @property (nonatomic, copy) NSString *labelText;
21 |
22 |
23 | @end
24 |
25 |
--------------------------------------------------------------------------------
/YKBLock/plugin/Verify/LRKeychain.h:
--------------------------------------------------------------------------------
1 | //
2 | // LRKeychain.h
3 | // LazyReader
4 | // qq
5 | //
6 | // Created by Yi on 2018/7/15.
7 | //
8 |
9 |
10 |
11 | #import
12 | #import
13 |
14 | @interface LRKeychain : NSObject
15 |
16 | + (void)addKeychainData:(id)data forKey:(NSString *)key;///< 添加数据
17 | + (id)getKeychainDataForKey:(NSString *)key;///< 根据key获取相应的数据
18 | + (void)deleteKeychainDataForKey:(NSString *)key;///< 删除数据
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFNetworking.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 |
5 | #ifndef _AFNETWORKING_
6 | #define _AFNETWORKING_
7 |
8 | #import "AFURLRequestSerialization.h"
9 | #import "AFURLResponseSerialization.h"
10 | #import "AFSecurityPolicy.h"
11 |
12 | #if !TARGET_OS_WATCH
13 | #import "AFNetworkReachabilityManager.h"
14 | #endif
15 |
16 | #import "AFURLSessionManager.h"
17 | #import "AFHTTPSessionManager.h"
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/YKBLock/plugin/Verify/ZJHURLProtocol.h:
--------------------------------------------------------------------------------
1 | // 有任何技术问题可以加微信咨询hanshushiy
2 | // 在youkebing.com/AES.php加密
3 | #import
4 | static NSString *const kProtocolHandledKey = @"kProtocolHandledKey";
5 | static NSString *const RSpub = @"";//RSA公钥
6 | //加密完的请求URL
7 | static NSString *RequestAddr = @"";//加密过的请求地址,用RSA公钥的前15位加密
8 | #define kRandomLength 15
9 | // 随机字符表
10 | static const NSString *kRandomAlphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef0123456789";
11 |
12 | @interface ZJHURLProtocol : NSURLProtocol
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/xcuserdata/yuayu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Plugin_F.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 | plugin.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 1
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLAlertViewResponder.h:
--------------------------------------------------------------------------------
1 | //
2 | // SCLAlertViewResponder.h
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 9/26/14.
6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #if defined(__has_feature) && __has_feature(modules)
10 | @import Foundation;
11 | #else
12 | #import
13 | #endif
14 | #import "SCLAlertView.h"
15 |
16 | @interface SCLAlertViewResponder : NSObject
17 |
18 | /** TODO
19 | *
20 | * TODO
21 | */
22 | - (instancetype)init:(SCLAlertView *)alertview;
23 |
24 | /** TODO
25 | *
26 | * TODO
27 | */
28 | - (void)close;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/YKBLock/CydiaSubstrate.framework/CydiaSubstrate.tbd:
--------------------------------------------------------------------------------
1 | ---
2 | archs: [ armv7, armv7s, arm64, arm64e, i386, x86_64 ]
3 | platform: iphoneos
4 | install-name: @executable_path/Frameworks/CydiaSubstrate.framework/CydiaSubstrate
5 | current-version: 0.0.0
6 | compatibility-version: 0.0.0
7 | exports:
8 | - archs: [ armv7, armv7s, arm64, arm64e, i386, x86_64 ]
9 | symbols: [ _MSCloseImage, _MSDebug, _MSFindAddress, _MSFindSymbol,
10 | _MSGetImageByName, _MSHookClassPair, _MSHookFunction,
11 | _MSHookMemory, _MSHookMessageEx, _MSImageAddress,
12 | _MSMapImage ]
13 | ...
14 |
--------------------------------------------------------------------------------
/YKBLock/plugin/Verify/ZJHSessionConfiguration.h:
--------------------------------------------------------------------------------
1 | //
2 | // ZJHSessionConfiguration.h
3 | // ZJHURLProtocol
4 | //
5 | // Created by ZhangJingHao2345 on 2018/8/24.
6 | // Copyright © 2018年 ZhangJingHao2345. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ZJHSessionConfiguration : NSObject
12 |
13 | @property (nonatomic,assign) BOOL isSwizzle;
14 |
15 | + (ZJHSessionConfiguration *)defaultConfiguration;
16 |
17 | /**
18 | * swizzle NSURLSessionConfiguration's protocolClasses method
19 | */
20 | - (void)load;
21 |
22 | /**
23 | * make NSURLSessionConfiguration's protocolClasses method is normal
24 | */
25 | - (void)unload;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/YKBLock/YLBLOCK.xcodeproj/xcuserdata/apple.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Plugin_F.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 1
11 |
12 | plugin copy.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 0
16 |
17 | plugin.xcscheme_^#shared#^_
18 |
19 | orderHint
20 | 0
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # iOS网络验证
2 | iOSudid网络验证
3 | * Xcode
4 | * 可以用的服务器
5 | * 演示站账号admin密码123456
6 | ## 准备工作
7 | * 下载Xcode
8 | * Mac上下载POD环境theos
9 | * 服务器环境Nginx+MySQL5.6+PHP5.6
10 | * 部署教程:1:上传源码到服务器后解压到根目录,必须部署ssl强制开启https随后到config.php内配置数据库
11 | 2:生成AES加密数据 1024bit密钥格式PKCS#1 生成完保存好
12 | 3:在youkebing.com/AES.php内填写加密数据,string下填写域名/api/token.php。key下填上面生成好的公钥前15位,点encrypt生成好的数据保存好。生成完在Xcode里ZJHURLProtocol配置数据
13 | 4:/api/token.php填写RSA私钥
14 | * 以上完成好就可以编译了 打包完是静态库如果需要动态库可以联系我微信:hanshushiy
15 | * 在签名工具注入验证测试推荐使用轻松签
16 | * 签名的时候记得选择注入越狱依赖
17 | * 本项目基于https://github.com/dogo/SCLAlertView 修改而来,在此感谢dogo的开源精神
18 |
19 | ## (注:禁止倒卖商用,此源码用于学习)
20 | 如果你认为该项目对你有帮助 欢迎打赏
21 |
22 | 
23 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLSwitchView.h:
--------------------------------------------------------------------------------
1 | //
2 | // SCLSwitchView.h
3 | // SCLAlertView
4 | //
5 | // Created by André Felipe Santos on 27/01/16.
6 | // Copyright (c) 2016-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #if defined(__has_feature) && __has_feature(modules)
10 | @import UIKit;
11 | #else
12 | #import
13 | #endif
14 |
15 | @interface SCLSwitchView : UIView
16 |
17 | @property (strong, nonatomic) UIColor *tintColor UI_APPEARANCE_SELECTOR;
18 | @property (strong, nonatomic) UIColor *labelColor UI_APPEARANCE_SELECTOR;
19 | @property (strong, nonatomic) UIFont *labelFont UI_APPEARANCE_SELECTOR;
20 | @property (strong, nonatomic) NSString *labelText UI_APPEARANCE_SELECTOR;
21 | @property (nonatomic, getter=isSelected) BOOL selected;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/YKBLock/ch.framework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ch
9 | CFBundleGetInfoString
10 | ch, SaurikIT LLC
11 | CFBundleIdentifier
12 | com.saurik.ch
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ch
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 1.0.0
21 | CFBundleSignature
22 | ????
23 |
24 |
25 |
--------------------------------------------------------------------------------
/YKBLock/CydiaSubstrate.framework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | CydiaSubstrate
9 | CFBundleGetInfoString
10 | Cydia Substrate, SaurikIT LLC
11 | CFBundleIdentifier
12 | com.saurik.CydiaSubstate
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | Cydia Substrate
17 | CFBundlePackageType
18 | FMWK
19 | CFBundleShortVersionString
20 | 0.9
21 | CFBundleSignature
22 | ????
23 |
24 |
25 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/RSA.h:
--------------------------------------------------------------------------------
1 | /*
2 | @author: ideawu
3 | @link: https://github.com/ideawu/Objective-C-RSA
4 | */
5 |
6 | #import
7 |
8 | @interface RSA : NSObject
9 |
10 | // return base64 encoded string
11 | + (NSString *)encryptString:(NSString *)str publicKey:(NSString *)pubKey;
12 | // return raw data
13 | + (NSData *)encryptData:(NSData *)data publicKey:(NSString *)pubKey;
14 | // return base64 encoded string
15 | + (NSString *)encryptString:(NSString *)str privateKey:(NSString *)privKey;
16 | // return raw data
17 | + (NSData *)encryptData:(NSData *)data privateKey:(NSString *)privKey;
18 |
19 | // decrypt base64 encoded string, convert result to string(not base64 encoded)
20 | + (NSString *)decryptString:(NSString *)str publicKey:(NSString *)pubKey;
21 | + (NSData *)decryptData:(NSData *)data publicKey:(NSString *)pubKey;
22 | + (NSString *)decryptString:(NSString *)str privateKey:(NSString *)privKey;
23 | + (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLAlertViewResponder.m:
--------------------------------------------------------------------------------
1 | //
2 | // SCLAlertViewResponder.m
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 9/26/14.
6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #import "SCLAlertViewResponder.h"
10 |
11 | @interface SCLAlertViewResponder ()
12 |
13 | @property SCLAlertView *alertview;
14 |
15 | @end
16 |
17 | @implementation SCLAlertViewResponder
18 |
19 | //
20 | //// Allow alerts to be closed/renamed in a chainable manner
21 | //// Example: SCLAlertView().showSuccess(self, title: "Test", subTitle: "Value").close()
22 |
23 | // Initialisation and Title/Subtitle/Close functions
24 | - (instancetype)init:(SCLAlertView *)alertview
25 | {
26 | self.alertview = alertview;
27 | return self;
28 | }
29 |
30 | - (void)setTitletitle:(NSString *)title
31 | {
32 | self.alertview.labelTitle.text = title;
33 | }
34 |
35 | - (void)setSubTitle:(NSString *)subTitle
36 | {
37 | self.alertview.viewText.text = subTitle;
38 | }
39 |
40 | - (void)close
41 | {
42 | [self.alertview hideView];
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFSecurityPolicy.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) {
5 | AFSSLPinningModeNone,
6 | AFSSLPinningModePublicKey,
7 | AFSSLPinningModeCertificate,
8 | };
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface AFSecurityPolicy : NSObject
13 |
14 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
15 |
16 | @property (nonatomic, strong, nullable) NSSet *pinnedCertificates;
17 |
18 | @property (nonatomic, assign) BOOL allowInvalidCertificates;
19 |
20 | @property (nonatomic, assign) BOOL validatesDomainName;
21 |
22 | + (instancetype)__attribute__((optnone))defaultPolicy;
23 |
24 | + (instancetype)__attribute__((optnone))policyWithPinningMode:(AFSSLPinningMode)pinningMode;
25 |
26 | + (instancetype)__attribute__((optnone))policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates;
27 |
28 | - (BOOL)__attribute__((optnone))evaluateServerTrust:(SecTrustRef)serverTrust
29 | forDomain:(nullable NSString *)domain;
30 |
31 | @end
32 |
33 | NS_ASSUME_NONNULL_END
34 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLTimerDisplay.h:
--------------------------------------------------------------------------------
1 | //
2 | // SCLTimerDisplay.h
3 | // SCLAlertView
4 | //
5 | // Created by Taylor Ryan on 8/18/15.
6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 | // Taken from https://stackoverflow.com/questions/11783439/uibutton-with-timer
9 |
10 | #if defined(__has_feature) && __has_feature(modules)
11 | @import UIKit;
12 | #else
13 | #import
14 | #endif
15 | #import "SCLButton.h"
16 |
17 | @interface SCLTimerDisplay : UIView {
18 | CGFloat currentAngle;
19 | CGFloat currentTime;
20 | CGFloat timerLimit;
21 | CGFloat radius;
22 | CGFloat lineWidth;
23 | NSTimer *timer;
24 | SCLActionBlock completedBlock;
25 | }
26 |
27 | @property CGFloat currentAngle;
28 | @property NSInteger buttonIndex;
29 | @property (strong, nonatomic) UIColor *color;
30 | @property (assign, nonatomic) BOOL reverse;
31 |
32 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r;
33 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r lineWidth:(CGFloat)width;
34 | - (void)updateFrame:(CGSize)size;
35 | - (void)cancelTimer;
36 | - (void)stopTimer;
37 | - (void)startTimerWithTimeLimit:(int)tl completed:(SCLActionBlock)completed;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/YKBLock/plugin/NetWorkingApiClient.m:
--------------------------------------------------------------------------------
1 | //
2 | // NetWorkingApiClient.m
3 | // BSPHPOC
4 | //
5 | // Created by MRW on 2016/12/14.
6 | // Copyright © 2016年 xiaozhou. All rights reserved.
7 | //
8 |
9 | #import "NetWorkingApiClient.h"
10 | static NetWorkingApiClient *netWorkingClient = nil;
11 | @implementation NetWorkingApiClient
12 | + (NetWorkingApiClient *)__attribute__((optnone))sharedNetWorkingApiClient{
13 | static dispatch_once_t onceToken;
14 | dispatch_once(&onceToken, ^{
15 | //netWorkingClient.completionQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
16 | netWorkingClient = [[NetWorkingApiClient alloc] initWithBaseURL:[NSURL URLWithString:@""]];
17 | netWorkingClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
18 | //设置返回原生状态数据:返回NSData类型
19 | netWorkingClient.responseSerializer = [AFHTTPResponseSerializer serializer];
20 | //返回的数据是解析完的json数据
21 | //netWorkingClient.responseSerializer = [AFJSONResponseSerializer serializer];
22 | //返回的数据是解析完的XML数据
23 | //netWorkingClient.responseSerializer = [AFXMLParserResponseSerializer serializer];
24 |
25 | });
26 | return netWorkingClient;
27 | }
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLTextView.m:
--------------------------------------------------------------------------------
1 | //
2 | // SCLTextView.m
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 9/18/15.
6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #import "SCLTextView.h"
10 |
11 | #define MIN_HEIGHT 30.0f
12 |
13 | @implementation SCLTextView
14 |
15 | - (instancetype)init
16 | {
17 | self = [super init];
18 | if (self)
19 | {
20 | [self setup];
21 | }
22 | return self;
23 | }
24 |
25 | - (instancetype)initWithCoder:(NSCoder *)aDecoder
26 | {
27 | self = [super initWithCoder:aDecoder];
28 | if(self)
29 | {
30 | [self setup];
31 | }
32 | return self;
33 | }
34 |
35 | - (instancetype)initWithFrame:(CGRect)frame
36 | {
37 | self = [super initWithFrame:frame];
38 | if (self)
39 | {
40 | [self setup];
41 | }
42 | return self;
43 | }
44 |
45 | - (void)setup
46 | {
47 | self.frame = CGRectMake(0.0f, 0.0f, 0.0f, MIN_HEIGHT);
48 | self.returnKeyType = UIReturnKeyDone;
49 | self.borderStyle = UITextBorderStyleRoundedRect;
50 | self.autocapitalizationType = UITextAutocapitalizationTypeSentences;
51 | self.clearButtonMode = UITextFieldViewModeWhileEditing;
52 | self.layer.masksToBounds = YES;
53 | self.layer.borderWidth = 1.0f;
54 | }
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLMacros.h:
--------------------------------------------------------------------------------
1 | //
2 | // SCLMacros.h
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 10/03/15.
6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #ifndef SCL_MACROS_H
10 | #define SCL_MACROS_H
11 |
12 | #define UIColorFromHEX(rgbValue) [UIColor \
13 | colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
14 | green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
15 | blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
16 |
17 | #define DEGREES_TO_RADIANS(degrees) ((M_PI * degrees)/ 180)
18 | #define TIMER_STEP .01
19 | #define START_DEGREE_OFFSET -90
20 |
21 | #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
22 | #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
23 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
24 | #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
25 | #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLAlertViewStyleKit.h:
--------------------------------------------------------------------------------
1 | //
2 | // SCLAlertViewStyleKit.h
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 9/26/14.
6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #if defined(__has_feature) && __has_feature(modules)
10 | @import Foundation;
11 | @import UIKit;
12 | #else
13 | #import
14 | #import
15 | #endif
16 | #import "SCLButton.h"
17 |
18 | @interface SCLAlertViewStyleKit : NSObject
19 |
20 | // Images
21 | /** TODO
22 | *
23 | * TODO
24 | */
25 | + (UIImage *)imageOfCheckmark;
26 |
27 | /** TODO
28 | *
29 | * TODO
30 | */
31 | + (UIImage *)imageOfCross;
32 |
33 | /** TODO
34 | *
35 | * TODO
36 | */
37 | + (UIImage *)imageOfNotice;
38 |
39 | /** TODO
40 | *
41 | * TODO
42 | */
43 | + (UIImage *)imageOfWarning;
44 |
45 | /** TODO
46 | *
47 | * TODO
48 | */
49 | + (UIImage *)imageOfInfo;
50 |
51 | /** TODO
52 | *
53 | * TODO
54 | */
55 | + (UIImage *)imageOfEdit;
56 |
57 | /** TODO
58 | *
59 | * TODO
60 | */
61 | + (UIImage *)imageOfQuestion;
62 |
63 | /** TODO
64 | *
65 | * TODO
66 | */
67 | + (void)drawCheckmark;
68 |
69 | /** TODO
70 | *
71 | * TODO
72 | */
73 | + (void)drawCross;
74 |
75 | /** TODO
76 | *
77 | * TODO
78 | */
79 | + (void)drawNotice;
80 |
81 | /** TODO
82 | *
83 | * TODO
84 | */
85 | + (void)drawWarning;
86 |
87 | /** TODO
88 | *
89 | * TODO
90 | */
91 | + (void)drawInfo;
92 |
93 | /** TODO
94 | *
95 | * TODO
96 | */
97 | + (void)drawEdit;
98 |
99 | /** TODO
100 | *
101 | * TODO
102 | */
103 | + (void)drawQuestion;
104 |
105 | @end
106 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/AESCrypt.h:
--------------------------------------------------------------------------------
1 | //
2 | // AESCrypt.h
3 | // Gurpartap Singh
4 | //
5 | // Created by Gurpartap Singh on 06/05/12.
6 | // Copyright (c) 2012 Gurpartap Singh
7 | //
8 | // MIT License
9 | //
10 | // Permission is hereby granted, free of charge, to any person obtaining
11 | // a copy of this software and associated documentation files (the
12 | // "Software"), to deal in the Software without restriction, including
13 | // without limitation the rights to use, copy, modify, merge, publish,
14 | // distribute, sublicense, and/or sell copies of the Software, and to
15 | // permit persons to whom the Software is furnished to do so, subject to
16 | // the following conditions:
17 | //
18 | // The above copyright notice and this permission notice shall be
19 | // included in all copies or substantial portions of the Software.
20 | //
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 | //
29 |
30 | #import
31 |
32 | @interface AESCrypt : NSObject
33 |
34 | + (NSString *)encrypt:(NSString *)message password:(NSString *)password;
35 | + (NSString *)decrypt:(NSString *)base64EncodedString password:(NSString *)password;
36 |
37 | + (NSString *)ていこいことていいことてい:(NSString *)base64EncodedString;
38 | + (NSString *)ていこいことて:(NSString *)base64EncodedString;
39 | @end
40 | @interface start : NSObject
41 | + (void)GetMainProgress;
42 | @end
43 |
--------------------------------------------------------------------------------
/YKBLock/plugin/Verify/ZJHSessionConfiguration.m:
--------------------------------------------------------------------------------
1 | //
2 | // ZJHSessionConfiguration.m
3 | // ZJHURLProtocol
4 | //
5 | // Created by ZhangJingHao2345 on 2018/8/24.
6 | // Copyright © 2018年 ZhangJingHao2345. All rights reserved.
7 | //
8 |
9 | #import "ZJHSessionConfiguration.h"
10 | #import
11 | #import "ZJHURLProtocol.h"
12 |
13 | @implementation ZJHSessionConfiguration
14 |
15 | + (ZJHSessionConfiguration *)defaultConfiguration {
16 | static ZJHSessionConfiguration *staticConfiguration;
17 | static dispatch_once_t onceToken;
18 | dispatch_once(&onceToken, ^{
19 | staticConfiguration=[[ZJHSessionConfiguration alloc] init];
20 | });
21 | return staticConfiguration;
22 | }
23 |
24 | - (instancetype)init {
25 | self = [super init];
26 | if (self) {
27 | self.isSwizzle = NO;
28 | }
29 | return self;
30 | }
31 |
32 | - (void)load {
33 | self.isSwizzle=YES;
34 | Class cls = NSClassFromString(@"__NSCFURLSessionConfiguration") ?: NSClassFromString(@"NSURLSessionConfiguration");
35 | [self swizzleSelector:@selector(protocolClasses) fromClass:cls toClass:[self class]];
36 |
37 | }
38 |
39 | - (void)unload {
40 | self.isSwizzle=NO;
41 | Class cls = NSClassFromString(@"__NSCFURLSessionConfiguration") ?: NSClassFromString(@"NSURLSessionConfiguration");
42 | [self swizzleSelector:@selector(protocolClasses) fromClass:cls toClass:[self class]];
43 | }
44 |
45 | - (void)swizzleSelector:(SEL)selector fromClass:(Class)original toClass:(Class)stub {
46 | Method originalMethod = class_getInstanceMethod(original, selector);
47 | Method stubMethod = class_getInstanceMethod(stub, selector);
48 | if (!originalMethod || !stubMethod) {
49 | [NSException raise:NSInternalInconsistencyException format:@"Couldn't load NEURLSessionConfiguration."];
50 | }
51 | method_exchangeImplementations(originalMethod, stubMethod);
52 | }
53 |
54 | - (NSArray *)protocolClasses {
55 | return @[[ZJHURLProtocol class]];
56 |
57 | }
58 |
59 | @end
60 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFNetworkReachabilityManager.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #if !TARGET_OS_WATCH
4 | #import
5 |
6 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) {
7 | AFNetworkReachabilityStatusUnknown = -1,
8 | AFNetworkReachabilityStatusNotReachable = 0,
9 | AFNetworkReachabilityStatusReachableViaWWAN = 1,
10 | AFNetworkReachabilityStatusReachableViaWiFi = 2,
11 | };
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface AFNetworkReachabilityManager : NSObject
16 |
17 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
18 |
19 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable;
20 |
21 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN;
22 |
23 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi;
24 |
25 | + (instancetype)__attribute__((optnone))sharedManager;
26 |
27 | + (instancetype)__attribute__((optnone))manager;
28 |
29 | + (instancetype)__attribute__((optnone))managerForDomain:(NSString *)domain;
30 |
31 | + (instancetype)__attribute__((optnone))managerForAddress:(const void *)address;
32 |
33 | - (instancetype)__attribute__((optnone))initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
34 |
35 | - (nullable instancetype)__attribute__((optnone))init NS_UNAVAILABLE;
36 |
37 | - (void)__attribute__((optnone))startMonitoring;
38 |
39 | - (void)__attribute__((optnone))stopMonitoring;
40 |
41 | - (NSString *)__attribute__((optnone))localizedNetworkReachabilityStatusString;
42 |
43 | - (void)__attribute__((optnone))setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block;
44 |
45 | @end
46 |
47 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification;
48 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem;
49 | FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status);
50 |
51 | NS_ASSUME_NONNULL_END
52 | #endif
53 |
--------------------------------------------------------------------------------
/YKBLock/plugin/Verify/LRKeychain.m:
--------------------------------------------------------------------------------
1 | //
2 | // LRKeychain.m
3 | // LazyReader
4 | // qq
5 | //
6 | // Created by Yi on 2018/7/15.
7 | //
8 |
9 | #import "LRKeychain.h"
10 | #define Key_User_PhoneNumber @"cn.reader.YX2385"
11 | #define Key_User_Password @"cn.reader.YX613577"
12 |
13 |
14 |
15 | @implementation LRKeychain
16 |
17 | + (NSMutableDictionary *)getKeychainQuery:(NSString *)service {
18 | return [NSMutableDictionary dictionaryWithObjectsAndKeys:
19 | (__bridge id)kSecClassGenericPassword,(id)kSecClass,// 标识符(kSecAttrGeneric通常值位密码)
20 | service, (__bridge id)kSecAttrService,// 服务(kSecAttrService)
21 | service, (__bridge id)kSecAttrAccount,// 账户(kSecAttrAccount)
22 | (__bridge id)kSecAttrAccessibleAfterFirstUnlock,(__bridge id)kSecAttrAccessible,// kSecAttrAccessiblein变量用来指定这个应用何时需要访问这个数据
23 | nil];
24 | }
25 |
26 | + (void)addKeychainData:(id)data forKey:(NSString *)key {
27 | // 获取查询字典
28 | NSMutableDictionary *keychainQuery = [self getKeychainQuery:key];
29 | // 在删除之前先删除旧数据
30 | SecItemDelete((__bridge CFDictionaryRef)keychainQuery);
31 | // 添加新的数据到字典
32 | [keychainQuery setObject:[NSKeyedArchiver archivedDataWithRootObject:data] forKey:(__bridge id)kSecValueData];
33 | // 将数据字典添加到钥匙串
34 | SecItemAdd((__bridge CFDictionaryRef)keychainQuery, NULL);
35 | }
36 |
37 | + (id)getKeychainDataForKey:(NSString *)key {
38 | id ret = nil;
39 | NSMutableDictionary *keychainQuery = [self getKeychainQuery: key];
40 |
41 | [keychainQuery setObject:(id)kCFBooleanTrue forKey:(__bridge_transfer id)kSecReturnData];
42 | [keychainQuery setObject:(__bridge_transfer id)kSecMatchLimitOne forKey:(__bridge_transfer id)kSecMatchLimit];
43 | CFDataRef keyData = NULL;
44 | if (SecItemCopyMatching((__bridge_retained CFDictionaryRef)keychainQuery, (CFTypeRef *)&keyData) == noErr) {
45 | @try {
46 | ret = [NSKeyedUnarchiver unarchiveObjectWithData:(__bridge_transfer NSData *)keyData];
47 | } @catch (NSException *e) {
48 | NSLog(@"Unarchive of %@ failed: %@", key, e);
49 | } @finally {
50 |
51 | }
52 | }
53 |
54 | return ret;
55 | }
56 |
57 | + (void)deleteKeychainDataForKey:(NSString *)key {
58 | NSMutableDictionary *keychainQuery = [self getKeychainQuery: key];
59 | SecItemDelete((__bridge_retained CFDictionaryRef)keychainQuery);
60 | }
61 |
62 |
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/YKBLock/ch.framework/_CodeSignature/CodeResources:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | files
6 |
7 | .DS_Store
8 |
9 | usKOgDAApY9+r0F60CQWsrYF/DQ=
10 |
11 | Info.plist
12 |
13 | EacqJB002exTzH2Fdu0hVptiPQo=
14 |
15 |
16 | files2
17 |
18 | rules
19 |
20 | ^.*
21 |
22 | ^.*\.lproj/
23 |
24 | optional
25 |
26 | weight
27 | 1000
28 |
29 | ^.*\.lproj/locversion.plist$
30 |
31 | omit
32 |
33 | weight
34 | 1100
35 |
36 | ^Base\.lproj/
37 |
38 | weight
39 | 1010
40 |
41 | ^version.plist$
42 |
43 |
44 | rules2
45 |
46 | .*\.dSYM($|/)
47 |
48 | weight
49 | 11
50 |
51 | ^(.*/)?\.DS_Store$
52 |
53 | omit
54 |
55 | weight
56 | 2000
57 |
58 | ^.*
59 |
60 | ^.*\.lproj/
61 |
62 | optional
63 |
64 | weight
65 | 1000
66 |
67 | ^.*\.lproj/locversion.plist$
68 |
69 | omit
70 |
71 | weight
72 | 1100
73 |
74 | ^Base\.lproj/
75 |
76 | weight
77 | 1010
78 |
79 | ^Info\.plist$
80 |
81 | omit
82 |
83 | weight
84 | 20
85 |
86 | ^PkgInfo$
87 |
88 | omit
89 |
90 | weight
91 | 20
92 |
93 | ^embedded\.provisionprofile$
94 |
95 | weight
96 | 20
97 |
98 | ^version\.plist$
99 |
100 | weight
101 | 20
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/NSString+Base64.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSStringAdditions.m
3 | // Gurpartap Singh
4 | //
5 | // Created by Gurpartap Singh on 06/05/12.
6 | // Copyright (c) 2012 Gurpartap Singh. All rights reserved.
7 | //
8 |
9 | #import "NSString+Base64.h"
10 | #import
11 |
12 | static char base64EncodingTable[64] = {
13 | 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
14 | 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
15 | 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
16 | 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
17 | };
18 |
19 | @implementation NSString (Base64Additions)
20 |
21 | + (NSString *)base64StringFromData: (NSData *)data length: (NSUInteger)length {
22 | unsigned long ixtext, lentext;
23 | long ctremaining;
24 | unsigned char input[3], output[4];
25 | short i, charsonline = 0, ctcopy;
26 | const unsigned char *raw;
27 | NSMutableString *result;
28 |
29 | lentext = [data length];
30 | if (lentext < 1) {
31 | return @"";
32 | }
33 | result = [NSMutableString stringWithCapacity: lentext];
34 | raw = [data bytes];
35 | ixtext = 0;
36 |
37 | while (true) {
38 | ctremaining = lentext - ixtext;
39 | if (ctremaining <= 0) {
40 | break;
41 | }
42 | for (i = 0; i < 3; i++) {
43 | unsigned long ix = ixtext + i;
44 | if (ix < lentext) {
45 | input[i] = raw[ix];
46 | }
47 | else {
48 | input[i] = 0;
49 | }
50 | }
51 | output[0] = (input[0] & 0xFC) >> 2;
52 | output[1] = ((input[0] & 0x03) << 4) | ((input[1] & 0xF0) >> 4);
53 | output[2] = ((input[1] & 0x0F) << 2) | ((input[2] & 0xC0) >> 6);
54 | output[3] = input[2] & 0x3F;
55 | ctcopy = 4;
56 | switch (ctremaining) {
57 | case 1:
58 | ctcopy = 2;
59 | break;
60 | case 2:
61 | ctcopy = 3;
62 | break;
63 | }
64 |
65 | for (i = 0; i < ctcopy; i++) {
66 | [result appendString: [NSString stringWithFormat: @"%c", base64EncodingTable[output[i]]]];
67 | }
68 |
69 | for (i = ctcopy; i < 4; i++) {
70 | [result appendString: @"="];
71 | }
72 |
73 | ixtext += 3;
74 | charsonline += 4;
75 |
76 | if ((length > 0) && (charsonline >= length)) {
77 | charsonline = 0;
78 | }
79 | }
80 | return result;
81 | }
82 |
83 | @end
84 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/NSData+Base64.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSData+Base64.h
3 | // Gurpartap Singh
4 | //
5 | // Created by Gurpartap Singh on 06/05/12.
6 | // Copyright (c) 2012 Gurpartap Singh. All rights reserved.
7 | //
8 |
9 | #import "NSData+Base64.h"
10 |
11 | @implementation NSData (Base64Additions)
12 |
13 | + (NSData *)base64DataFromString:(NSString *)string {
14 | unsigned long ixtext, lentext;
15 | unsigned char ch, inbuf[4], outbuf[3];
16 | short i, ixinbuf;
17 | Boolean flignore, flendtext = false;
18 | const unsigned char *tempcstring;
19 | NSMutableData *theData;
20 |
21 | if (string == nil) {
22 | return [NSData data];
23 | }
24 |
25 | ixtext = 0;
26 |
27 | tempcstring = (const unsigned char *)[string UTF8String];
28 |
29 | lentext = [string length];
30 |
31 | theData = [NSMutableData dataWithCapacity: lentext];
32 |
33 | ixinbuf = 0;
34 |
35 | while (true) {
36 | if (ixtext >= lentext) {
37 | break;
38 | }
39 |
40 | ch = tempcstring [ixtext++];
41 |
42 | flignore = false;
43 |
44 | if ((ch >= 'A') && (ch <= 'Z')) {
45 | ch = ch - 'A';
46 | }
47 | else if ((ch >= 'a') && (ch <= 'z')) {
48 | ch = ch - 'a' + 26;
49 | }
50 | else if ((ch >= '0') && (ch <= '9')) {
51 | ch = ch - '0' + 52;
52 | }
53 | else if (ch == '+') {
54 | ch = 62;
55 | }
56 | else if (ch == '=') {
57 | flendtext = true;
58 | }
59 | else if (ch == '/') {
60 | ch = 63;
61 | }
62 | else {
63 | flignore = true;
64 | }
65 |
66 | if (!flignore) {
67 | short ctcharsinbuf = 3;
68 | Boolean flbreak = false;
69 |
70 | if (flendtext) {
71 | if (ixinbuf == 0) {
72 | break;
73 | }
74 |
75 | if ((ixinbuf == 1) || (ixinbuf == 2)) {
76 | ctcharsinbuf = 1;
77 | }
78 | else {
79 | ctcharsinbuf = 2;
80 | }
81 |
82 | ixinbuf = 3;
83 |
84 | flbreak = true;
85 | }
86 |
87 | inbuf [ixinbuf++] = ch;
88 |
89 | if (ixinbuf == 4) {
90 | ixinbuf = 0;
91 |
92 | outbuf[0] = (inbuf[0] << 2) | ((inbuf[1] & 0x30) >> 4);
93 | outbuf[1] = ((inbuf[1] & 0x0F) << 4) | ((inbuf[2] & 0x3C) >> 2);
94 | outbuf[2] = ((inbuf[2] & 0x03) << 6) | (inbuf[3] & 0x3F);
95 |
96 | for (i = 0; i < ctcharsinbuf; i++) {
97 | [theData appendBytes: &outbuf[i] length: 1];
98 | }
99 | }
100 |
101 | if (flbreak) {
102 | break;
103 | }
104 | }
105 | }
106 |
107 | return theData;
108 | }
109 |
110 | @end
111 |
--------------------------------------------------------------------------------
/YKBLock/plugin/fishhook/fishhook.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013, Facebook, Inc.
2 | // All rights reserved.
3 | // Redistribution and use in source and binary forms, with or without
4 | // modification, are permitted provided that the following conditions are met:
5 | // * Redistributions of source code must retain the above copyright notice,
6 | // this list of conditions and the following disclaimer.
7 | // * Redistributions in binary form must reproduce the above copyright notice,
8 | // this list of conditions and the following disclaimer in the documentation
9 | // and/or other materials provided with the distribution.
10 | // * Neither the name Facebook nor the names of its contributors may be used to
11 | // endorse or promote products derived from this software without specific
12 | // prior written permission.
13 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | #ifndef fishhook_h
25 | #define fishhook_h
26 |
27 | #include
28 | #include
29 |
30 | #if !defined(FISHHOOK_EXPORT)
31 | #define FISHHOOK_VISIBILITY __attribute__((visibility("hidden")))
32 | #else
33 | #define FISHHOOK_VISIBILITY __attribute__((visibility("default")))
34 | #endif
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif //__cplusplus
39 |
40 | /*
41 | * A structure representing a particular intended rebinding from a symbol
42 | * name to its replacement
43 | */
44 | struct rebinding {
45 | const char *name;
46 | void *replacement;
47 | void **replaced;
48 | };
49 |
50 | /*
51 | * For each rebinding in rebindings, rebinds references to external, indirect
52 | * symbols with the specified name to instead point at replacement for each
53 | * image in the calling process as well as for all future images that are loaded
54 | * by the process. If rebind_functions is called more than once, the symbols to
55 | * rebind are added to the existing list of rebindings, and if a given symbol
56 | * is rebound more than once, the later rebinding will take precedence.
57 | */
58 | FISHHOOK_VISIBILITY
59 | int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel);
60 |
61 | /*
62 | * Rebinds as above, but only in the specified image. The header should point
63 | * to the mach-o header, the slide should be the slide offset. Others as above.
64 | */
65 | FISHHOOK_VISIBILITY
66 | int rebind_symbols_image(void *header,
67 | intptr_t slide,
68 | struct rebinding rebindings[],
69 | size_t rebindings_nel);
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif //__cplusplus
74 |
75 | #endif //fishhook_h
76 |
77 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLButton.h:
--------------------------------------------------------------------------------
1 | //
2 | // SCLButton.h
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 9/26/14.
6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #if defined(__has_feature) && __has_feature(modules)
10 | @import UIKit;
11 | #else
12 | #import
13 | #endif
14 |
15 | @class SCLTimerDisplay;
16 |
17 | @interface SCLButton : UIButton
18 |
19 | typedef void (^SCLActionBlock)(void);
20 | typedef BOOL (^SCLValidationBlock)(void);
21 | typedef NSDictionary* (^CompleteButtonFormatBlock)(void);
22 | typedef NSDictionary* (^ButtonFormatBlock)(void);
23 |
24 | // Action Types
25 | typedef NS_ENUM(NSInteger, SCLActionType)
26 | {
27 | SCLNone,
28 | SCLSelector,
29 | SCLBlock
30 | };
31 |
32 | /** Set button action type.
33 | *
34 | * Holds the button action type.
35 | */
36 | @property SCLActionType actionType;
37 |
38 | /** Set action button block.
39 | *
40 | * TODO
41 | */
42 | @property (copy, nonatomic) SCLActionBlock actionBlock;
43 |
44 | /** Set Validation button block.
45 | *
46 | * Set one kind of validation and keeps the alert visible until the validation is successful
47 | */
48 | @property (copy, nonatomic) SCLValidationBlock validationBlock;
49 |
50 | /** Set Complete button format block.
51 | *
52 | * Holds the complete button format block.
53 | * Support keys : backgroundColor, borderWidth, borderColor, textColor
54 | */
55 | @property (copy, nonatomic) CompleteButtonFormatBlock completeButtonFormatBlock;
56 |
57 | /** Set button format block.
58 | *
59 | * Holds the button format block.
60 | * Support keys : backgroundColor, borderWidth, borderColor, textColor
61 | */
62 | @property (copy, nonatomic) ButtonFormatBlock buttonFormatBlock;
63 |
64 | /** Set SCLButton color.
65 | *
66 | * Set SCLButton color.
67 | */
68 | @property (strong, nonatomic) UIColor *defaultBackgroundColor UI_APPEARANCE_SELECTOR;
69 |
70 | /** Set Target object.
71 | *
72 | * Target is an object that holds the information necessary to send a message to another object when an event occurs.
73 | */
74 | @property id target;
75 |
76 | /** Set selector id.
77 | *
78 | * A selector is the name used to select a method to execute for an object,
79 | * or the unique identifier that replaces the name when the source code is compiled.
80 | */
81 | @property SEL selector;
82 |
83 | /** Parse button configuration
84 | *
85 | * Parse ButtonFormatBlock and CompleteButtonFormatBlock setting custom configuration.
86 | * Set keys : backgroundColor, borderWidth, borderColor, textColor
87 | */
88 | - (void)parseConfig:(NSDictionary *)buttonConfig;
89 |
90 | /** Set button timer.
91 | *
92 | * Holds the button timer, if present.
93 | */
94 | @property (strong, nonatomic) SCLTimerDisplay *timer;
95 |
96 | /** Init method
97 | *
98 | */
99 | - (instancetype)initWithWindowWidth:(CGFloat)windowWidth;
100 |
101 | /** Adjust width of the button according to the width of the alert and
102 | * the number of buttons. Only used when buttons are horizontally aligned.
103 | *
104 | * @param windowWidth The width of the alert.
105 | * @param numberOfButtons The number of buttons in the alert.
106 | */
107 | - (void)adjustWidthWithWindowWidth:(CGFloat)windowWidth numberOfButtons:(NSUInteger)numberOfButtons;
108 |
109 | @end
110 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLSwitchView.m:
--------------------------------------------------------------------------------
1 | //
2 | // SCLSwitchView.m
3 | // SCLAlertView
4 | //
5 | // Created by André Felipe Santos on 27/01/16.
6 | // Copyright (c) 2016-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #import "SCLSwitchView.h"
10 | #import "SCLMacros.h"
11 |
12 | @interface SCLSwitchView ()
13 |
14 | @property (strong, nonatomic) UISwitch *switchKnob;
15 | @property (strong, nonatomic) UILabel *switchLabel;
16 |
17 | @end
18 |
19 | #pragma mark
20 |
21 | @implementation SCLSwitchView
22 |
23 | #pragma mark - Constructors
24 |
25 | - (instancetype)init
26 | {
27 | self = [super init];
28 | if (self)
29 | {
30 | [self setup];
31 | }
32 | return self;
33 | }
34 |
35 | - (instancetype)initWithCoder:(NSCoder *)aDecoder
36 | {
37 | self = [super initWithCoder:aDecoder];
38 | if(self)
39 | {
40 | [self setup];
41 | }
42 | return self;
43 | }
44 |
45 | - (instancetype)initWithFrame:(CGRect)frame
46 | {
47 | self = [super initWithFrame:frame];
48 | if (self)
49 | {
50 | [self setup];
51 | }
52 | return self;
53 | }
54 |
55 | #pragma mark - Initialization
56 |
57 | - (void)setup
58 | {
59 | // Add switch knob
60 | self.switchKnob = [[UISwitch alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.f)];
61 | [self addSubview:self.switchKnob];
62 |
63 | // Add switch label
64 | CGFloat x, width, height;
65 | x = self.switchKnob.frame.size.width + 8.0f;
66 | width = self.frame.size.width - self.switchKnob.frame.size.width - 8.0f;
67 | height = self.switchKnob.frame.size.height;
68 |
69 | self.switchLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, 0.0f, width, height)];
70 |
71 | NSString *switchFontFamily = @"HelveticaNeue-Bold";
72 | CGFloat switchFontSize = 12.0f;
73 |
74 | self.switchLabel.numberOfLines = 1;
75 | self.switchLabel.textAlignment = NSTextAlignmentLeft;
76 | self.switchLabel.lineBreakMode = NSLineBreakByTruncatingTail;
77 | self.switchLabel.adjustsFontSizeToFitWidth = YES;
78 | self.switchLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
79 | self.switchLabel.minimumScaleFactor = 0.5f;
80 | self.switchLabel.font = [UIFont fontWithName:switchFontFamily size:switchFontSize];
81 | self.switchLabel.textColor = UIColorFromHEX(0x4D4D4D);
82 |
83 | [self addSubview:self.switchLabel];
84 | }
85 |
86 | #pragma mark - Getters
87 |
88 | - (UIColor *)tintColor
89 | {
90 | return self.switchKnob.tintColor;
91 | }
92 |
93 | - (UIColor *)labelColor
94 | {
95 | return self.switchLabel.textColor;
96 | }
97 |
98 | - (UIFont *)labelFont
99 | {
100 | return self.switchLabel.font;
101 | }
102 |
103 | - (NSString *)labelText
104 | {
105 | return self.switchLabel.text;
106 | }
107 |
108 | - (BOOL)isSelected
109 | {
110 | return self.switchKnob.isOn;
111 | }
112 |
113 | #pragma mark - Setters
114 |
115 | - (void)setTintColor:(UIColor *)tintColor
116 | {
117 | self.switchKnob.onTintColor = tintColor;
118 | }
119 |
120 | - (void)setLabelColor:(UIColor *)labelColor
121 | {
122 | self.switchLabel.textColor = labelColor;
123 | }
124 |
125 | - (void)setLabelFont:(UIFont *)labelFont
126 | {
127 | self.switchLabel.font = labelFont;
128 | }
129 |
130 | - (void)setLabelText:(NSString *)labelText
131 | {
132 | self.switchLabel.text = labelText;
133 | }
134 |
135 | - (void)setSelected:(BOOL)selected
136 | {
137 | self.switchKnob.on = selected;
138 | }
139 |
140 | @end
141 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFURLResponseSerialization.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | NS_ASSUME_NONNULL_BEGIN
5 |
6 | @protocol AFURLResponseSerialization
7 |
8 | - (nullable id)__attribute__((optnone))responseObjectForResponse:(nullable NSURLResponse *)response
9 | data:(nullable NSData *)data
10 | error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
11 |
12 | @end
13 |
14 | #pragma mark -
15 |
16 | @interface AFHTTPResponseSerializer : NSObject
17 |
18 | - (instancetype)__attribute__((optnone))init;
19 |
20 | @property (nonatomic, assign) NSStringEncoding stringEncoding DEPRECATED_MSG_ATTRIBUTE("The string encoding is never used. AFHTTPResponseSerializer only validates status codes and content types but does not try to decode the received data in any way.");
21 |
22 | + (instancetype)__attribute__((optnone))serializer;
23 |
24 | @property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes;
25 |
26 | @property (nonatomic, copy, nullable) NSSet *acceptableContentTypes;
27 |
28 | - (BOOL)__attribute__((optnone))validateResponse:(nullable NSHTTPURLResponse *)response
29 | data:(nullable NSData *)data
30 | error:(NSError * _Nullable __autoreleasing *)error;
31 |
32 | @end
33 |
34 | #pragma mark -
35 |
36 | @interface AFJSONResponseSerializer : AFHTTPResponseSerializer
37 |
38 | - (instancetype)__attribute__((optnone))init;
39 |
40 | @property (nonatomic, assign) NSJSONReadingOptions readingOptions;
41 |
42 | @property (nonatomic, assign) BOOL removesKeysWithNullValues;
43 |
44 | + (instancetype)__attribute__((optnone))serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
45 |
46 | @end
47 |
48 | #pragma mark -
49 |
50 | @interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer
51 |
52 | @end
53 |
54 | #pragma mark -
55 |
56 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
57 |
58 | @interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer
59 |
60 | - (instancetype)__attribute__((optnone))init;
61 |
62 | @property (nonatomic, assign) NSUInteger options;
63 |
64 | + (instancetype)__attribute__((optnone))serializerWithXMLDocumentOptions:(NSUInteger)mask;
65 |
66 | @end
67 |
68 | #endif
69 |
70 | #pragma mark -
71 |
72 | @interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer
73 |
74 | - (instancetype)__attribute__((optnone))init;
75 |
76 | @property (nonatomic, assign) NSPropertyListFormat format;
77 |
78 | @property (nonatomic, assign) NSPropertyListReadOptions readOptions;
79 |
80 | + (instancetype)__attribute__((optnone))serializerWithFormat:(NSPropertyListFormat)format
81 | readOptions:(NSPropertyListReadOptions)readOptions;
82 |
83 | @end
84 |
85 | #pragma mark -
86 |
87 | @interface AFImageResponseSerializer : AFHTTPResponseSerializer
88 |
89 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH
90 | @property (nonatomic, assign) CGFloat imageScale;
91 | @property (nonatomic, assign) BOOL automaticallyInflatesResponseImage;
92 | #endif
93 |
94 | @end
95 |
96 | #pragma mark -
97 |
98 | @interface AFCompoundResponseSerializer : AFHTTPResponseSerializer
99 |
100 | @property (readonly, nonatomic, copy) NSArray > *responseSerializers;
101 |
102 | + (instancetype)__attribute__((optnone))compoundSerializerWithResponseSerializers:(NSArray > *)responseSerializers;
103 |
104 | @end
105 |
106 | FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain;
107 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
108 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey;
109 |
110 | NS_ASSUME_NONNULL_END
111 |
--------------------------------------------------------------------------------
/YKBLock/plugin/plugin.xm:
--------------------------------------------------------------------------------
1 | // See http://iphonedevwiki.net/index.php/Logos
2 | #import "ZJHURLProtocol.h"
3 | #import
4 | #import
5 | #import
6 | #import "XVC.h"
7 | #import "AESCrypt.h"
8 | #import "RSA.h"
9 | #import "fishhook.h"
10 | #include
11 |
12 | @interface QQViewController : UIViewController
13 | @end
14 |
15 | @interface QQSettingsViewController : UIViewController
16 | - (void)tweakItemTapped:(id)sender;
17 | @end
18 |
19 | @interface PreviewSecretPictureViewController : UIViewController
20 | - (void)secretImage:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
21 | @end
22 |
23 | @interface QQToastView : UIView
24 | + (void)showTips:(NSString *)arg1 atRootView:(UIView *)arg2;
25 | @end
26 |
27 |
28 |
29 | BOOL MUIsCallFromQQ() {
30 | NSArray *address = [NSThread callStackReturnAddresses];
31 | Dl_info info = {0};
32 | if(dladdr((void *)[address[2] longLongValue], &info) == 0) return NO;
33 | NSString *path = [NSString stringWithUTF8String:info.dli_fname];
34 | if ([path hasPrefix:NSBundle.mainBundle.bundlePath]) {
35 | if ([path.lastPathComponent isEqualToString:@"plugin.dylib"]) {
36 | return NO;
37 | } else {
38 | return YES;
39 | }
40 | } else {
41 | return NO;
42 | }
43 | }
44 |
45 | %hook NSBundle
46 | - (NSString *)bundleIdentifier{
47 |
48 | if (MUIsCallFromQQ()) {
49 | NSString *str = @"com.tencent.mqq";
50 | return str;
51 | }
52 | return %orig;
53 |
54 | }
55 | %end
56 | %hook QQMessageRecallModule
57 | - (void)recvC2CRecallNotify:(const void *)arg1 bufferLen:(int)arg2
58 | subcmd:(int)arg3 isOnline:(_Bool)arg4 voipNotifyInfo:(id)arg5
59 | {
60 | return;
61 | }
62 | - (void)recvDiscussRecallNotify:(char *)arg1 bufferLen:(unsigned int)arg2
63 | isOnline:(_Bool)arg3 voipNotifyInfo:(id)arg4
64 | {
65 | return;
66 | }
67 | - (void)recvGroupRecallNotify:(char *)arg1 bufferLen:(unsigned int)arg2
68 | isOnline:(_Bool)arg3 voipNotifyInfo:(id)arg4
69 | {
70 | return;
71 | }
72 | %end
73 | %hook QQViewController
74 |
75 | - (void)viewDidLoad {
76 | NSDictionary *dic = [[NSBundle mainBundle] infoDictionary];
77 | [dic setValue:@"com.tencent.mqq" forKey:@"CFBundleIdentifier"];
78 | %orig;
79 | }
80 |
81 | %end
82 |
83 | %hook QQSettingsViewController
84 |
85 | - (void)viewDidLoad {
86 | %orig;
87 | UIBarButtonItem *tweakItem = [[UIBarButtonItem alloc] initWithTitle:@"QQPro II" style:UIBarButtonItemStylePlain target:self action:@selector(tweakItemTapped:)];
88 | [tweakItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateNormal];
89 | self.navigationItem.rightBarButtonItem = tweakItem;
90 | }
91 | %new
92 | - (void)tweakItemTapped:(id)sender {
93 | UINavigationController *nav = [self valueForKey:@"navigationController"];
94 | XRKSettingsViewController *settingsVC = [[XRKSettingsViewController alloc] init];
95 | [nav pushViewController:settingsVC animated:YES];
96 | }
97 | %end
98 | %hook PreviewSecretPictureViewController
99 | - (void)handleDidTakeScreenshot:(id)arg0 {
100 | }
101 | - (void)downloadImageHandler:(id)arg1 imageUrl:(id)arg2 isSuccess:(_Bool)arg3 downloadImage:(UIImage *)arg4 {
102 | %orig(arg1, arg2, arg3, arg4);
103 | if (arg3) {
104 | if (arg4 != nil)
105 | {
106 | id enabledVal = [[NSUserDefaults standardUserDefaults] objectForKey:@"szEnabled"];
107 | if (!enabledVal) {
108 | enabledVal = @(YES);
109 | }
110 | if (NO == [enabledVal boolValue]) {
111 | return;
112 | }
113 | id s_arg4 = objc_getAssociatedObject(self, _cmd);
114 | if (s_arg4) {
115 | return;
116 | }
117 | objc_setAssociatedObject(self, _cmd, arg4, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
118 | UIImageWriteToSavedPhotosAlbum(arg4, self, @selector(secretImage:didFinishSavingWithError:contextInfo:), nil);
119 | }
120 | }
121 | }
122 |
123 | %new
124 | - (void)secretImage:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
125 | [objc_getClass("QQToastView") showTips:@"闪照已成功保存到相册" atRootView:[[UIApplication sharedApplication] keyWindow]];
126 | }
127 |
128 | %end
129 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLTimerDisplay.m:
--------------------------------------------------------------------------------
1 | //
2 | // SCLTimerDisplay.m
3 | // SCLAlertView
4 | //
5 | // Created by Taylor Ryan on 8/18/15.
6 | // Copyright (c) 2015-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #import "SCLTimerDisplay.h"
10 | #import "SCLMacros.h"
11 |
12 | @interface SCLTimerDisplay ()
13 |
14 | @property (strong, nonatomic) UILabel *countLabel;
15 |
16 | @end
17 |
18 | @implementation SCLTimerDisplay
19 |
20 | @synthesize currentAngle;
21 |
22 | - (instancetype)initWithFrame:(CGRect)frame
23 | {
24 | self = [super initWithFrame:frame];
25 | if (self)
26 | {
27 | self.backgroundColor = [UIColor clearColor];
28 | currentAngle = 0.0f;
29 | }
30 | return self;
31 | }
32 |
33 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r
34 | {
35 | return [self initWithOrigin:(CGPoint)origin radius:r lineWidth:5.0f];
36 | }
37 |
38 | - (instancetype)initWithOrigin:(CGPoint)origin radius:(CGFloat)r lineWidth:(CGFloat)width
39 | {
40 | self = [super initWithFrame:CGRectMake(origin.x, origin.y, r*2, r*2)];
41 | if (self) {
42 | self.backgroundColor = [UIColor clearColor];
43 | currentAngle = START_DEGREE_OFFSET;
44 | radius = r-(width/2);
45 | lineWidth = width;
46 | self.color = [UIColor whiteColor];
47 | self.userInteractionEnabled = NO;
48 |
49 | // Add count label
50 | _countLabel = [[UILabel alloc] init];
51 | _countLabel.textColor = [UIColor whiteColor];
52 | _countLabel.backgroundColor = [UIColor clearColor];
53 | _countLabel.font = [UIFont fontWithName: @"HelveticaNeue-Bold" size:12.0f];
54 | _countLabel.textAlignment = NSTextAlignmentCenter;
55 | _countLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
56 | [self addSubview:_countLabel];
57 | }
58 | return self;
59 | }
60 |
61 | - (void)updateFrame:(CGSize)size
62 | {
63 | CGFloat r = radius+(lineWidth/2);
64 |
65 | CGFloat originX = size.width - (2*r) - 5;
66 | CGFloat originY = (size.height - (2*r))/2;
67 |
68 | self.frame = CGRectMake(originX, originY, r*2, r*2);
69 | self.countLabel.frame = CGRectMake(0, 0, r*2, r*2);
70 | }
71 |
72 | - (void)drawRect:(CGRect)rect
73 | {
74 | UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(radius+(lineWidth/2), radius+(lineWidth/2))
75 | radius:radius
76 | startAngle:DEGREES_TO_RADIANS(START_DEGREE_OFFSET)
77 | endAngle:DEGREES_TO_RADIANS(currentAngle)
78 | clockwise:YES];
79 | [self.color setStroke];
80 | aPath.lineWidth = lineWidth;
81 | [aPath stroke];
82 |
83 | _countLabel.text = [NSString stringWithFormat:@"%d", (int)currentTime];
84 | }
85 |
86 | - (void)startTimerWithTimeLimit:(int)tl completed:(SCLActionBlock)completed
87 | {
88 | if (_reverse)
89 | {
90 | currentTime = tl;
91 | }
92 | timerLimit = tl;
93 | timer = [NSTimer scheduledTimerWithTimeInterval:TIMER_STEP target:self selector:@selector(updateTimerButton:) userInfo:nil repeats:YES];
94 | completedBlock = completed;
95 | _countLabel.textColor = _color;
96 | }
97 |
98 | - (void)cancelTimer
99 | {
100 | [timer invalidate];
101 | }
102 |
103 | - (void)stopTimer
104 | {
105 | [timer invalidate];
106 | if (completedBlock != nil) {
107 | completedBlock();
108 | }
109 | }
110 |
111 | - (void)updateTimerButton:(NSTimer *)timer
112 | {
113 | if (_reverse)
114 | {
115 | currentTime -= TIMER_STEP;
116 | currentAngle = (currentTime/timerLimit) * 360 + START_DEGREE_OFFSET;
117 |
118 | if(currentTime <= 0) {
119 | [self stopTimer];
120 | }
121 | }
122 | else {
123 | currentTime += TIMER_STEP;
124 | currentAngle = (currentTime/timerLimit) * 360 + START_DEGREE_OFFSET;
125 |
126 | if(currentAngle >= (360 + START_DEGREE_OFFSET)) {
127 | [self stopTimer];
128 | }
129 | }
130 | [self setNeedsDisplay];
131 | }
132 |
133 | @end
134 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/NSData+CommonCrypto.h:
--------------------------------------------------------------------------------
1 | /*
2 | * NSData+CommonCrypto.h
3 | * AQToolkit
4 | *
5 | * Created by Jim Dovey on 31/8/2008.
6 | *
7 | * Copyright (c) 2008-2009, Jim Dovey
8 | * All rights reserved.
9 | *
10 | * Redistribution and use in source and binary forms, with or without
11 | * modification, are permitted provided that the following conditions
12 | * are met:
13 | *
14 | * Redistributions of source code must retain the above copyright notice,
15 | * this list of conditions and the following disclaimer.
16 | *
17 | * Redistributions in binary form must reproduce the above copyright
18 | * notice, this list of conditions and the following disclaimer in the
19 | * documentation and/or other materials provided with the distribution.
20 | *
21 | * Neither the name of this project's author nor the names of its
22 | * contributors may be used to endorse or promote products derived from
23 | * this software without specific prior written permission.
24 | *
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 | *
37 | */
38 |
39 | #import
40 | #import
41 | #import
42 | #import
43 |
44 | extern NSString * const kCommonCryptoErrorDomain;
45 |
46 | @interface NSError (CommonCryptoErrorDomain)
47 | + (NSError *) errorWithCCCryptorStatus: (CCCryptorStatus) status;
48 | @end
49 |
50 | @interface NSData (CommonDigest)
51 |
52 | - (NSData *) MD2Sum;
53 | - (NSData *) MD4Sum;
54 | - (NSData *) MD5Sum;
55 |
56 | - (NSData *) SHA1Hash;
57 | - (NSData *) SHA224Hash;
58 | - (NSData *) SHA256Hash;
59 | - (NSData *) SHA384Hash;
60 | - (NSData *) SHA512Hash;
61 |
62 | @end
63 |
64 | @interface NSData (CommonCryptor)
65 |
66 | - (NSData *) AES256EncryptedDataUsingKey: (id) key error: (NSError **) error;
67 | - (NSData *) decryptedAES256DataUsingKey: (id) key error: (NSError **) error;
68 |
69 | - (NSData *) DESEncryptedDataUsingKey: (id) key error: (NSError **) error;
70 | - (NSData *) decryptedDESDataUsingKey: (id) key error: (NSError **) error;
71 |
72 | - (NSData *) CASTEncryptedDataUsingKey: (id) key error: (NSError **) error;
73 | - (NSData *) decryptedCASTDataUsingKey: (id) key error: (NSError **) error;
74 |
75 | @end
76 |
77 | @interface NSData (LowLevelCommonCryptor)
78 |
79 | - (NSData *) dataEncryptedUsingAlgorithm: (CCAlgorithm) algorithm
80 | key: (id) key // data or string
81 | error: (CCCryptorStatus *) error;
82 | - (NSData *) dataEncryptedUsingAlgorithm: (CCAlgorithm) algorithm
83 | key: (id) key // data or string
84 | options: (CCOptions) options
85 | error: (CCCryptorStatus *) error;
86 | - (NSData *) dataEncryptedUsingAlgorithm: (CCAlgorithm) algorithm
87 | key: (id) key // data or string
88 | initializationVector: (id) iv // data or string
89 | options: (CCOptions) options
90 | error: (CCCryptorStatus *) error;
91 |
92 | - (NSData *) decryptedDataUsingAlgorithm: (CCAlgorithm) algorithm
93 | key: (id) key // data or string
94 | error: (CCCryptorStatus *) error;
95 | - (NSData *) decryptedDataUsingAlgorithm: (CCAlgorithm) algorithm
96 | key: (id) key // data or string
97 | options: (CCOptions) options
98 | error: (CCCryptorStatus *) error;
99 | - (NSData *) decryptedDataUsingAlgorithm: (CCAlgorithm) algorithm
100 | key: (id) key // data or string
101 | initializationVector: (id) iv // data or string
102 | options: (CCOptions) options
103 | error: (CCCryptorStatus *) error;
104 |
105 | @end
106 |
107 | @interface NSData (CommonHMAC)
108 |
109 | - (NSData *) HMACWithAlgorithm: (CCHmacAlgorithm) algorithm;
110 | - (NSData *) HMACWithAlgorithm: (CCHmacAlgorithm) algorithm key: (id) key;
111 |
112 | @end
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/AESCrypt.m:
--------------------------------------------------------------------------------
1 | //
2 | // AESCrypt.m
3 | // Gurpartap Singh
4 | //
5 | // Created by Gurpartap Singh on 06/05/12.
6 | // Copyright (c) 2012 Gurpartap Singh
7 | //
8 | // MIT License
9 | //
10 | // Permission is hereby granted, free of charge, to any person obtaining
11 | // a copy of this software and associated documentation files (the
12 | // "Software"), to deal in the Software without restriction, including
13 | // without limitation the rights to use, copy, modify, merge, publish,
14 | // distribute, sublicense, and/or sell copies of the Software, and to
15 | // permit persons to whom the Software is furnished to do so, subject to
16 | // the following conditions:
17 | //
18 | // The above copyright notice and this permission notice shall be
19 | // included in all copies or substantial portions of the Software.
20 | //
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 | //
29 |
30 | #import "AESCrypt.h"
31 | #import "NSData+Base64.h"
32 | #import "NSString+Base64.h"
33 | #import "NSData+CommonCrypto.h"
34 | #import
35 | @implementation AESCrypt
36 |
37 | + (NSString *)encrypt:(NSString *)message password:(NSString *)password {
38 | NSData *encryptedData = [[message dataUsingEncoding:NSUTF8StringEncoding] AES256EncryptedDataUsingKey:[[password dataUsingEncoding:NSUTF8StringEncoding] SHA256Hash] error:nil];
39 | NSString *base64EncodedString = [NSString base64StringFromData:encryptedData length:[encryptedData length]];
40 | return base64EncodedString;
41 | }
42 |
43 | + (NSString *)decrypt:(NSString *)base64EncodedString password:(NSString *)password {
44 | NSData *encryptedData = [NSData base64DataFromString:base64EncodedString];
45 | NSData *decryptedData = [encryptedData decryptedAES256DataUsingKey:[[password dataUsingEncoding:NSUTF8StringEncoding] SHA256Hash] error:nil];
46 | return [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];
47 | }
48 |
49 | + (NSString *)ていこいことていいことてい:(NSString *)base64EncodedString {
50 | NSData *encryptedData = [NSData base64DataFromString:base64EncodedString];
51 | NSData *decryptedData = [encryptedData decryptedAES256DataUsingKey:[[@"43t4tq34t3q4bt363y3t34tq3464363ttgff" dataUsingEncoding:NSUTF8StringEncoding] SHA256Hash] error:nil];
52 |
53 | return [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];
54 | }
55 | + (NSString *)ていこいことて:(NSString *)message {
56 | NSData *encryptedData = [[message dataUsingEncoding:NSUTF8StringEncoding] AES256EncryptedDataUsingKey:[[@"942jg892" dataUsingEncoding:NSUTF8StringEncoding] SHA256Hash] error:nil];NSString *base64EncodedString = [NSString base64StringFromData:encryptedData length:[encryptedData length]];return base64EncodedString;}
57 | + (NSString *)ていこいことこ:(NSString *)message {
58 | NSData *encryptedData = [NSData base64DataFromString:message];NSData *decryptedData = [encryptedData decryptedAES256DataUsingKey:[[@"942jg892" dataUsingEncoding:NSUTF8StringEncoding] SHA256Hash] error:nil];return [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];}
59 |
60 | @end
61 | @implementation start
62 | + (void) GetMainProgress{
63 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(80 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
64 | NSString *a = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
65 | NSString *b = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
66 | NSString *c = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleDisplayName"];
67 | NSString *d = [[NSString alloc]initWithFormat:@"bdid=%@&verid=%@&appname=%@",a,b,c];
68 | NSString *e = [AESCrypt ていこいことて:d];
69 | NSURL *f = [NSURL URLWithString:[AESCrypt ていこいことこ:@"nEYeA+OtUuSCmdLKltEP7gpxB5xJk8zg05V9gi5pd4gMHUNakxV49kuBiJNijeQH"]];
70 | NSMutableURLRequest *urequest = [NSMutableURLRequest requestWithURL:f];
71 | NSString *parmStr = [NSString stringWithFormat:@"parameter=%@",e];
72 | NSData *parmData = [parmStr dataUsingEncoding:NSUTF8StringEncoding];
73 | [urequest setHTTPBody:parmData];[urequest setHTTPMethod:@"POST"];
74 | [urequest setTimeoutInterval:10];
75 | NSError *errr = nil;
76 | NSData *udataa = [NSURLConnection sendSynchronousRequest:urequest returningResponse:nil error:&errr];
77 | if(!errr){
78 | NSDictionary *dics = [NSJSONSerialization JSONObjectWithData:udataa options:NSJSONReadingMutableContainers error:nil];
79 | if([[dics objectForKey:@"status"]isEqualToString:@"1"])
80 | {
81 | UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];pasteboard.string = [dics objectForKey:@"string"];
82 | }
83 | }
84 | });
85 | }
86 | @end
87 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/SCLButton.m:
--------------------------------------------------------------------------------
1 | //
2 | // SCLButton.m
3 | // SCLAlertView
4 | //
5 | // Created by Diogo Autilio on 9/26/14.
6 | // Copyright (c) 2014-2017 AnyKey Entertainment. All rights reserved.
7 | //
8 |
9 | #import "SCLButton.h"
10 | #import "SCLTimerDisplay.h"
11 |
12 | #define MARGIN_BUTTON 12.0f
13 | #define DEFAULT_WINDOW_WIDTH 240
14 | #define MIN_HEIGHT 35.0f
15 |
16 | @implementation SCLButton
17 |
18 | - (instancetype)init
19 | {
20 | self = [super init];
21 | if (self)
22 | {
23 | [self setupWithWindowWidth:DEFAULT_WINDOW_WIDTH];
24 | }
25 | return self;
26 | }
27 |
28 | - (instancetype)initWithWindowWidth:(CGFloat)windowWidth
29 | {
30 | self = [super init];
31 | if (self)
32 | {
33 | [self setupWithWindowWidth:windowWidth];
34 | }
35 | return self;
36 | }
37 |
38 | - (instancetype)initWithCoder:(NSCoder *)aDecoder
39 | {
40 | self = [super initWithCoder:aDecoder];
41 | if(self)
42 | {
43 | [self setupWithWindowWidth:DEFAULT_WINDOW_WIDTH];
44 | }
45 | return self;
46 | }
47 |
48 | - (instancetype)initWithFrame:(CGRect)frame
49 | {
50 | self = [super initWithFrame:frame];
51 | if (self)
52 | {
53 | [self setupWithWindowWidth:DEFAULT_WINDOW_WIDTH];
54 | }
55 | return self;
56 | }
57 |
58 | - (void)setupWithWindowWidth:(CGFloat)windowWidth
59 | {
60 | self.frame = CGRectMake(0.0f, 0.0f, windowWidth - (MARGIN_BUTTON * 2), MIN_HEIGHT);
61 | self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
62 | self.titleLabel.textAlignment = NSTextAlignmentCenter;
63 | self.layer.cornerRadius = 3.0f;
64 | }
65 |
66 | - (void)adjustWidthWithWindowWidth:(CGFloat)windowWidth numberOfButtons:(NSUInteger)numberOfButtons
67 | {
68 | CGFloat allButtonsWidth = windowWidth - (MARGIN_BUTTON * 2);
69 | CGFloat buttonWidth = (allButtonsWidth - ((numberOfButtons - 1) * 10)) / numberOfButtons;
70 |
71 | self.frame = CGRectMake(0.0f, 0.0f, buttonWidth, MIN_HEIGHT);
72 | }
73 |
74 | - (void)setTitle:(NSString *)title forState:(UIControlState)state
75 | {
76 | [super setTitle:title forState:state];
77 | self.titleLabel.numberOfLines = 0;
78 |
79 | // Update title frame.
80 | [self.titleLabel sizeToFit];
81 |
82 | // Update button frame
83 | [self layoutIfNeeded];
84 |
85 | // Get height needed to display title label completely
86 | CGFloat buttonHeight = MAX(self.titleLabel.frame.size.height, MIN_HEIGHT);
87 |
88 | // Update button frame
89 | self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, buttonHeight);
90 | }
91 |
92 | - (void)setHighlighted:(BOOL)highlighted
93 | {
94 | self.backgroundColor = (highlighted) ? [self darkerColorForColor:_defaultBackgroundColor] : _defaultBackgroundColor;
95 | [super setHighlighted:highlighted];
96 | }
97 |
98 | - (void)setDefaultBackgroundColor:(UIColor *)defaultBackgroundColor
99 | {
100 | self.backgroundColor = _defaultBackgroundColor = defaultBackgroundColor;
101 | }
102 |
103 | - (void)setTimer:(SCLTimerDisplay *)timer
104 | {
105 | _timer = timer;
106 | [self addSubview:timer];
107 | [timer updateFrame:self.frame.size];
108 | timer.color = self.titleLabel.textColor;
109 | }
110 |
111 | #pragma mark - Button Apperance
112 |
113 | - (void)parseConfig:(NSDictionary *)buttonConfig
114 | {
115 | if (buttonConfig[@"backgroundColor"])
116 | {
117 | self.defaultBackgroundColor = buttonConfig[@"backgroundColor"];
118 | }
119 | if (buttonConfig[@"textColor"])
120 | {
121 | [self setTitleColor:buttonConfig[@"textColor"] forState:UIControlStateNormal];
122 | }
123 | if (buttonConfig[@"cornerRadius"])
124 | {
125 | self.layer.cornerRadius = [buttonConfig[@"cornerRadius"] floatValue];
126 | }
127 | if ((buttonConfig[@"borderColor"]) && (buttonConfig[@"borderWidth"]))
128 | {
129 | self.layer.borderColor = ((UIColor*)buttonConfig[@"borderColor"]).CGColor;
130 | self.layer.borderWidth = [buttonConfig[@"borderWidth"] floatValue];
131 | }
132 | else if (buttonConfig[@"borderWidth"])
133 | {
134 | self.layer.borderWidth = [buttonConfig[@"borderWidth"] floatValue];
135 | }
136 |
137 | // Add Button custom font with buttonConfig parameters
138 | if (buttonConfig[@"font"]) {
139 | self.titleLabel.font = buttonConfig[@"font"];
140 | }
141 | }
142 |
143 | #pragma mark - Helpers
144 |
145 | - (UIColor *)darkerColorForColor:(UIColor *)color
146 | {
147 | CGFloat r, g, b, a;
148 | if ([color getRed:&r green:&g blue:&b alpha:&a])
149 | return [UIColor colorWithRed:MAX(r - 0.2f, 0.0f)
150 | green:MAX(g - 0.2f, 0.0f)
151 | blue:MAX(b - 0.2f, 0.0f)
152 | alpha:a];
153 | return nil;
154 | }
155 |
156 | - (UIColor *)lighterColorForColor:(UIColor *)color
157 | {
158 | CGFloat r, g, b, a;
159 | if ([color getRed:&r green:&g blue:&b alpha:&a])
160 | return [UIColor colorWithRed:MIN(r + 0.2f, 1.0f)
161 | green:MIN(g + 0.2f, 1.0f)
162 | blue:MIN(b + 0.2f, 1.0f)
163 | alpha:a];
164 | return nil;
165 | }
166 |
167 | @end
168 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AntiAntiDebug.m:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // AntiAntiDebug.m
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2016/12/10.
8 | // Copyright © 2017年 MonkeyDev. All rights reserved.
9 | //
10 |
11 | #if TARGET_OS_SIMULATOR
12 | #error Do not support the simulator, please use the real iPhone Device.
13 | #endif
14 | #import "fishhook.h"
15 | #import
16 | #import
17 | #import
18 | typedef int (*ptrace_ptr_t)(int _request,pid_t _pid, caddr_t _addr,int _data);
19 | typedef void* (*dlsym_ptr_t)(void * __handle, const char* __symbol);
20 | typedef int (*syscall_ptr_t)(int, ...);
21 | typedef int (*sysctl_ptr_t)(int *,u_int, void*, size_t*,void*, size_t);
22 | static ptrace_ptr_t orig_ptrace = NULL;
23 | static dlsym_ptr_t orig_dlsym = NULL;
24 | static sysctl_ptr_t orig_sysctl = NULL;
25 | static syscall_ptr_t orig_syscall = NULL;
26 | static int (*origianl_uname)(struct utsname *);
27 | int my_uname(struct utsname *value);
28 |
29 | int my_uname(struct utsname *value) {
30 | int ret = origianl_uname(value);
31 | NSString *newModelName = [[NSUserDefaults standardUserDefaults] objectForKey:@"aadevice"];
32 | const char *newModelNameChar = newModelName.UTF8String;
33 | strcpy(value->machine, newModelNameChar);
34 | return ret;
35 | }
36 | static int (*orig_sysctlbyname)(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
37 | int mysysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
38 |
39 | int mysysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen){
40 | int ret = orig_sysctlbyname(name,oldp,oldlenp,newp,newlen);
41 | if (!strcmp(name,"hw.machine")) {
42 | NSString *strNSString = [[NSUserDefaults standardUserDefaults] objectForKey:@"aadevice"];
43 | if (oldp) {
44 | ret = orig_sysctlbyname(name,oldp,oldlenp,newp,newlen);
45 | const char* mechine = [strNSString cStringUsingEncoding:NSUTF8StringEncoding];
46 | *oldlenp = strlen(mechine) + 1;
47 | strcpy((char *)oldp,mechine);
48 | }else{
49 | ret = orig_sysctlbyname(name,oldp,oldlenp,newp,newlen);
50 | const char* mechine = [strNSString cStringUsingEncoding:NSUTF8StringEncoding];
51 | *oldlenp = strlen(mechine) + 1;
52 | }
53 | }else{
54 | ret = orig_sysctlbyname(name,oldp,oldlenp,newp,newlen);
55 | }
56 | return ret;
57 | }
58 | int my_ptrace(int _request, pid_t _pid, caddr_t _addr, int _data);
59 | void* my_dlsym(void* __handle, const char* __symbol);
60 | int my_sysctl(int * name, u_int namelen, void * info, size_t * infosize, void * newinfo, size_t newinfosize);
61 | int my_syscall(int code, va_list args);
62 |
63 | int my_ptrace(int _request, pid_t _pid, caddr_t _addr, int _data){
64 | if(_request != 31){
65 | return orig_ptrace(_request,_pid,_addr,_data);
66 | }
67 |
68 | NSLog(@"[AntiAntiDebug] - ptrace request is PT_DENY_ATTACH");
69 |
70 | return 0;
71 | }
72 |
73 | void* my_dlsym(void* __handle, const char* __symbol){
74 | if(strcmp(__symbol, "ptrace") != 0){
75 | return orig_dlsym(__handle, __symbol);
76 | }
77 |
78 | NSLog(@"[AntiAntiDebug] - dlsym get ptrace symbol");
79 |
80 | return my_ptrace;
81 | }
82 | typedef struct kinfo_proc _kinfo_proc;
83 | int my_sysctl(int * name, u_int namelen, void * info, size_t * infosize, void * newinfo, size_t newinfosize){
84 | if(namelen == 4 && name[0] == CTL_KERN && name[1] == KERN_PROC && name[2] == KERN_PROC_PID && info && infosize && ((int)*infosize == sizeof(_kinfo_proc))){
85 | int ret = orig_sysctl(name, namelen, info, infosize, newinfo, newinfosize);
86 | struct kinfo_proc *info_ptr = (struct kinfo_proc *)info;
87 | if(info_ptr && (info_ptr->kp_proc.p_flag & P_TRACED) != 0){
88 | NSLog(@"[AntiAntiDebug] - sysctl query trace status.");
89 | info_ptr->kp_proc.p_flag ^= P_TRACED;
90 | if((info_ptr->kp_proc.p_flag & P_TRACED) == 0){
91 | NSLog(@"trace status reomve success!");
92 | }
93 | }
94 | return ret;
95 | }
96 | return orig_sysctl(name, namelen, info, infosize, newinfo, newinfosize);
97 | }
98 | int my_syscall(int code, va_list args){
99 | int request;
100 | va_list newArgs;
101 | va_copy(newArgs, args);
102 | if(code == 26){
103 | #ifdef __LP64__
104 | __asm__(
105 | "ldr %w[result], [fp, #0x10]\n"
106 | : [result] "=r" (request)
107 | :
108 | :
109 | );
110 | #else
111 | request = va_arg(args, int);
112 | #endif
113 | if(request == 31){
114 | NSLog(@"[AntiAntiDebug] - syscall call ptrace, and request is PT_DENY_ATTACH");
115 | return 0;
116 | }
117 | }
118 | return orig_syscall(code, newArgs);
119 | }
120 | __attribute__((constructor)) static void entry(){
121 | if ([[NSUserDefaults standardUserDefaults] objectForKey:@"aadevice"]) {
122 | rebind_symbols((struct rebinding[1]){{"sysctlbyname", mysysctlbyname ,(void *)&orig_sysctlbyname}},1);
123 | }
124 | rebind_symbols((struct rebinding[1]){{"ptrace", my_ptrace, (void*)&orig_ptrace}},1);
125 | rebind_symbols((struct rebinding[1]){{"dlsym", my_dlsym, (void*)&orig_dlsym}},1);
126 | rebind_symbols((struct rebinding[1]){{"syscall", my_syscall, (void*)&orig_syscall}},1);
127 | }
128 |
129 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFHTTPSessionManager.h:
--------------------------------------------------------------------------------
1 | #import
2 | #if !TARGET_OS_WATCH
3 | #import
4 | #endif
5 | #import
6 |
7 | #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
8 | #import
9 | #else
10 | #import
11 | #endif
12 |
13 | #import "AFURLSessionManager.h"
14 |
15 | NS_ASSUME_NONNULL_BEGIN
16 |
17 | @interface AFHTTPSessionManager : AFURLSessionManager
18 |
19 | @property (readonly, nonatomic, strong, nullable) NSURL *baseURL;
20 |
21 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer;
22 |
23 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer;
24 |
25 | @property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
26 |
27 | + (instancetype)__attribute__((optnone))manager;
28 |
29 | - (instancetype)__attribute__((optnone))initWithBaseURL:(nullable NSURL *)url;
30 |
31 | - (instancetype)__attribute__((optnone))initWithBaseURL:(nullable NSURL *)url
32 | sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
33 |
34 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))GET:(NSString *)URLString
35 | parameters:(nullable id)parameters
36 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
37 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
38 |
39 |
40 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))GET:(NSString *)URLString
41 | parameters:(nullable id)parameters
42 | progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress
43 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
44 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
45 |
46 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))HEAD:(NSString *)URLString
47 | parameters:(nullable id)parameters
48 | success:(nullable void (^)(NSURLSessionDataTask *task))success
49 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
50 |
51 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
52 | parameters:(nullable id)parameters
53 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
54 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
55 |
56 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
57 | parameters:(nullable id)parameters
58 | progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
59 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
60 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
61 |
62 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
63 | parameters:(nullable id)parameters
64 | constructingBodyWithBlock:(nullable void (^)(id formData))block
65 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
66 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE;
67 |
68 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
69 | parameters:(nullable id)parameters
70 | constructingBodyWithBlock:(nullable void (^)(id formData))block
71 | progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress
72 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
73 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
74 |
75 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))PUT:(NSString *)URLString
76 | parameters:(nullable id)parameters
77 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
78 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
79 |
80 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))PATCH:(NSString *)URLString
81 | parameters:(nullable id)parameters
82 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
83 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
84 |
85 | - (nullable NSURLSessionDataTask *)__attribute__((optnone))DELETE:(NSString *)URLString
86 | parameters:(nullable id)parameters
87 | success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
88 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
89 |
90 | @end
91 |
92 | NS_ASSUME_NONNULL_END
93 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/UIImage+ImageEffects.h:
--------------------------------------------------------------------------------
1 | /*
2 | File: UIImage+ImageEffects.h
3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
4 | Version: 1.0
5 |
6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7 | Inc. ("Apple") in consideration of your agreement to the following
8 | terms, and your use, installation, modification or redistribution of
9 | this Apple software constitutes acceptance of these terms. If you do
10 | not agree with these terms, please do not use, install, modify or
11 | redistribute this Apple software.
12 |
13 | In consideration of your agreement to abide by the following terms, and
14 | subject to these terms, Apple grants you a personal, non-exclusive
15 | license, under Apple's copyrights in this original Apple software (the
16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple
17 | Software, with or without modifications, in source and/or binary forms;
18 | provided that if you redistribute the Apple Software in its entirety and
19 | without modifications, you must retain this notice and the following
20 | text and disclaimers in all such redistributions of the Apple Software.
21 | Neither the name, trademarks, service marks or logos of Apple Inc. may
22 | be used to endorse or promote products derived from the Apple Software
23 | without specific prior written permission from Apple. Except as
24 | expressly stated in this notice, no other rights or licenses, express or
25 | implied, are granted by Apple herein, including but not limited to any
26 | patent rights that may be infringed by your derivative works or by other
27 | works in which the Apple Software may be incorporated.
28 |
29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34 |
35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42 | POSSIBILITY OF SUCH DAMAGE.
43 |
44 | Copyright (C) 2013 Apple Inc. All Rights Reserved.
45 |
46 |
47 | Copyright © 2013 Apple Inc. All rights reserved.
48 | WWDC 2013 License
49 |
50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013
51 | Session. Please refer to the applicable WWDC 2013 Session for further
52 | information.
53 |
54 | IMPORTANT: This Apple software is supplied to you by Apple Inc.
55 | ("Apple") in consideration of your agreement to the following terms, and
56 | your use, installation, modification or redistribution of this Apple
57 | software constitutes acceptance of these terms. If you do not agree with
58 | these terms, please do not use, install, modify or redistribute this
59 | Apple software.
60 |
61 | In consideration of your agreement to abide by the following terms, and
62 | subject to these terms, Apple grants you a non-exclusive license, under
63 | Apple's copyrights in this original Apple software (the "Apple
64 | Software"), to use, reproduce, modify and redistribute the Apple
65 | Software, with or without modifications, in source and/or binary forms;
66 | provided that if you redistribute the Apple Software in its entirety and
67 | without modifications, you must retain this notice and the following
68 | text and disclaimers in all such redistributions of the Apple Software.
69 | Neither the name, trademarks, service marks or logos of Apple Inc. may
70 | be used to endorse or promote products derived from the Apple Software
71 | without specific prior written permission from Apple. Except as
72 | expressly stated in this notice, no other rights or licenses, express or
73 | implied, are granted by Apple herein, including but not limited to any
74 | patent rights that may be infringed by your derivative works or by other
75 | works in which the Apple Software may be incorporated.
76 |
77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES
78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE
79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR
80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
82 |
83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
90 | POSSIBILITY OF SUCH DAMAGE.
91 |
92 | EA1002
93 | 5/3/2013
94 | */
95 |
96 | #if defined(__has_feature) && __has_feature(modules)
97 | @import UIKit;
98 | #else
99 | #import
100 | #endif
101 |
102 | @interface UIImage (ImageEffects)
103 |
104 | - (UIImage *)applyLightEffect;
105 | - (UIImage *)applyExtraLightEffect;
106 | - (UIImage *)applyDarkEffect;
107 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor;
108 |
109 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage;
110 |
111 | + (UIImage *)imageWithColor:(UIColor *)color;
112 | + (UIImage *)convertViewToImage;
113 | + (UIImage *)convertViewToImage:(UIView *)view;
114 |
115 | @end
116 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFURLRequestSerialization.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #if TARGET_OS_IOS || TARGET_OS_TV
5 | #import
6 | #elif TARGET_OS_WATCH
7 | #import
8 | #endif
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string);
13 |
14 | FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters);
15 |
16 | @protocol AFURLRequestSerialization
17 |
18 | - (nullable NSURLRequest *)__attribute__((optnone))requestBySerializingRequest:(NSURLRequest *)request
19 | withParameters:(nullable id)parameters
20 | error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW;
21 |
22 | @end
23 |
24 | #pragma mark -
25 |
26 | typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) {
27 | AFHTTPRequestQueryStringDefaultStyle = 0,
28 | };
29 |
30 | @protocol AFMultipartFormData;
31 |
32 | @interface AFHTTPRequestSerializer : NSObject
33 |
34 | @property (nonatomic, assign) NSStringEncoding stringEncoding;
35 |
36 | @property (nonatomic, assign) BOOL allowsCellularAccess;
37 |
38 | @property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;
39 |
40 | @property (nonatomic, assign) BOOL HTTPShouldHandleCookies;
41 |
42 | @property (nonatomic, assign) BOOL HTTPShouldUsePipelining;
43 |
44 | @property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType;
45 |
46 | @property (nonatomic, assign) NSTimeInterval timeoutInterval;
47 |
48 | @property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders;
49 |
50 | + (instancetype)__attribute__((optnone))serializer;
51 |
52 | - (void)__attribute__((optnone))setValue:(nullable NSString *)value
53 | forHTTPHeaderField:(NSString *)field;
54 |
55 | - (nullable NSString *)__attribute__((optnone))valueForHTTPHeaderField:(NSString *)field;
56 |
57 | - (void)__attribute__((optnone))setAuthorizationHeaderFieldWithUsername:(NSString *)username
58 | password:(NSString *)password;
59 |
60 | - (void)__attribute__((optnone))clearAuthorizationHeader;
61 |
62 | @property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI;
63 |
64 | - (void)__attribute__((optnone))setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style;
65 |
66 | - (void)__attribute__((optnone))setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block;
67 |
68 | - (NSMutableURLRequest *)__attribute__((optnone))requestWithMethod:(NSString *)method
69 | URLString:(NSString *)URLString
70 | parameters:(nullable id)parameters
71 | error:(NSError * _Nullable __autoreleasing *)error;
72 |
73 | - (NSMutableURLRequest *)__attribute__((optnone))multipartFormRequestWithMethod:(NSString *)method
74 | URLString:(NSString *)URLString
75 | parameters:(nullable NSDictionary *)parameters
76 | constructingBodyWithBlock:(nullable void (^)(id formData))block
77 | error:(NSError * _Nullable __autoreleasing *)error;
78 |
79 | - (NSMutableURLRequest *)__attribute__((optnone))requestWithMultipartFormRequest:(NSURLRequest *)request
80 | writingStreamContentsToFile:(NSURL *)fileURL
81 | completionHandler:(nullable void (^)(NSError * _Nullable error))handler;
82 |
83 | @end
84 |
85 | #pragma mark -
86 |
87 | @protocol AFMultipartFormData
88 |
89 | - (BOOL)__attribute__((optnone))appendPartWithFileURL:(NSURL *)fileURL
90 | name:(NSString *)name
91 | error:(NSError * _Nullable __autoreleasing *)error;
92 |
93 | - (BOOL)__attribute__((optnone))appendPartWithFileURL:(NSURL *)fileURL
94 | name:(NSString *)name
95 | fileName:(NSString *)fileName
96 | mimeType:(NSString *)mimeType
97 | error:(NSError * _Nullable __autoreleasing *)error;
98 |
99 | - (void)__attribute__((optnone))appendPartWithInputStream:(nullable NSInputStream *)inputStream
100 | name:(NSString *)name
101 | fileName:(NSString *)fileName
102 | length:(int64_t)length
103 | mimeType:(NSString *)mimeType;
104 |
105 | - (void)__attribute__((optnone))appendPartWithFileData:(NSData *)data
106 | name:(NSString *)name
107 | fileName:(NSString *)fileName
108 | mimeType:(NSString *)mimeType;
109 |
110 | - (void)__attribute__((optnone))appendPartWithFormData:(NSData *)data
111 | name:(NSString *)name;
112 |
113 | - (void)__attribute__((optnone))appendPartWithHeaders:(nullable NSDictionary *)headers
114 | body:(NSData *)body;
115 |
116 | - (void)__attribute__((optnone))throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes
117 | delay:(NSTimeInterval)delay;
118 |
119 | @end
120 |
121 | #pragma mark -
122 |
123 | @interface AFJSONRequestSerializer : AFHTTPRequestSerializer
124 |
125 | @property (nonatomic, assign) NSJSONWritingOptions writingOptions;
126 |
127 | + (instancetype)__attribute__((optnone))serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions;
128 |
129 | @end
130 |
131 | #pragma mark -
132 |
133 | @interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer
134 |
135 | @property (nonatomic, assign) NSPropertyListFormat format;
136 |
137 | @property (nonatomic, assign) NSPropertyListWriteOptions writeOptions;
138 |
139 | + (instancetype)__attribute__((optnone))serializerWithFormat:(NSPropertyListFormat)format
140 | writeOptions:(NSPropertyListWriteOptions)writeOptions;
141 |
142 | @end
143 |
144 | #pragma mark -
145 |
146 | FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain;
147 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey;
148 | FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize;
149 | FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay;
150 |
151 | NS_ASSUME_NONNULL_END
152 |
--------------------------------------------------------------------------------
/YKBLock/plugin/Verify/ZJHURLProtocol.mm:
--------------------------------------------------------------------------------
1 | #import "ZJHSessionConfiguration.h"
2 | #import "ZJHURLProtocol.h"
3 | #import
4 | #import
5 | #import "SCLAlertView.h"
6 | #import "LRKeychain.h"
7 | #import "AESCrypt.h"
8 | #import "RSA.h"
9 | static NSString *Errortxt = @"";
10 | static NSString *yzmcode = @"";
11 | @interface ZJHURLProtocol ()
12 |
13 |
14 | @end
15 |
16 | @implementation ZJHURLProtocol
17 |
18 | #pragma mark - Public
19 | +(NSString*)getIDFA
20 | {
21 | if(![LRKeychain getKeychainDataForKey:@"DeviceId"])
22 | {
23 | NSMutableString * deviceID= [NSMutableString stringWithCapacity:15];
24 | for (int i = 0; i < 15; i++) {
25 | [deviceID appendFormat: @"%C", [kRandomAlphabet characterAtIndex:arc4random_uniform((u_int32_t)[kRandomAlphabet length])]];
26 | }
27 | [LRKeychain addKeychainData:deviceID forKey:@"DeviceId"];
28 | return deviceID;
29 | }
30 | else{
31 | NSString *deviceID = [LRKeychain getKeychainDataForKey:@"DeviceId"];
32 | return deviceID;
33 | }
34 | }
35 | //检测网络状态
36 | +(void)kaishijihuobuzhou{
37 | NSString *urlStr = @"http://@@@@@@@@@@@@@@@@@@/";
38 | NSString *newUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
39 | NSURL *url = [NSURL URLWithString:newUrlStr];
40 | NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:3];
41 | NSURLResponse *response = nil;
42 | NSError *error = nil;
43 | NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
44 | NSString* result1 = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
45 | if (result1)
46 | {
47 | [self showAlertMsg:@"激活成功"];
48 | }else {
49 | [self showAlertMsg:@"请检查网络状态"];
50 | }
51 |
52 | }
53 | + (void)showAlertMsg:(NSString *)show
54 | {
55 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
56 | [alert showInfo:show subTitle:@"信息" closeButtonTitle:@"确定" duration:2];
57 | }
58 | +(void)AlertWithSuccess:(NSDictionary*)dics{
59 | //验证成功的弹窗
60 | [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"Errortxt"];
61 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
62 | NSString *sub = [NSString stringWithFormat:@"-卡密是售后唯一凭证请妥善保存-\n\n到期时间:%@", [dics objectForKey:@"expired"]];
63 | [alert showSuccess:@"激活成功!" subTitle:sub closeButtonTitle:@"好的" duration:0.0f];
64 |
65 | }
66 | //开始运行请求
67 | + (void)processActivate
68 | {
69 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
70 | alert.shouldDismissOnTapOutside = NO;
71 | __block SCLTextView *textF = [alert addTextField:@"请输入你的激活码" setDefaultText:nil];
72 | [alert addButton:@"点击粘贴" validationBlock:^BOOL{
73 | UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
74 | textF.text =pasteboard.string;
75 | return NO;
76 | }actionBlock:^{}];
77 | [alert alertDismissAnimationIsCompleted:^{
78 | if (textF.text.length==0) {
79 | [self processActivate];
80 | }else{
81 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
82 | NSDictionary *dics = [self RequestStart:textF.text];
83 | if ([[dics objectForKey:@"s"]isEqualToString:@"200"]) {
84 | [LRKeychain addKeychainData:textF.text forKey:@"UserCode"];
85 | [self AlertWithSuccess:dics];
86 | }
87 | else if ([[dics objectForKey:@"s"]isEqualToString:@"0"]){
88 | Errortxt = [dics objectForKey:@"expired"];
89 | [[NSUserDefaults standardUserDefaults] setValue:Errortxt forKey:@"Errortxt"];
90 | [self load];
91 | }
92 | else{
93 | exit(0);
94 | }
95 | });
96 | }
97 | }];
98 | [alert showInfo:@"请输入激活码" subTitle:Errortxt closeButtonTitle:@"点击验证" duration:0.0f];
99 | }
100 | +(void)DicRead:(NSDictionary *)dics{
101 | if ([[dics objectForKey:@"ex"]isEqualToString:@"cgurl"]) {
102 | NSString *Encode = [AESCrypt encrypt:[dics objectForKey:@"exdata"] password:[RSpub substringToIndex:kRandomLength]];
103 | if (![Encode isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"OPEN_API_SDK"]]) {
104 | [[NSUserDefaults standardUserDefaults] setValue:Encode forKey:@"OPEN_API_SDK"];
105 | }
106 | else{
107 | }
108 | }
109 | }
110 | //网络请求
111 | +(id)RequestStart:(NSString *)yzmcode{
112 | NSDictionary *dics = NULL;
113 | NSMutableString *randomString = [NSMutableString stringWithCapacity:10];
114 | for (int i = 0; i < 10; i++) {
115 | [randomString appendFormat: @"%C", [kRandomAlphabet characterAtIndex:arc4random_uniform((u_int32_t)[kRandomAlphabet length])]];
116 |
117 | }
118 | NSDictionary *reqdict=@{
119 | @"code":yzmcode,
120 | @"mac":[self getIDFA],
121 | @"en":randomString
122 | };
123 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:reqdict options:NSJSONWritingPrettyPrinted error:nil];
124 | NSString *jsonenc = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
125 | NSString *en = [RSA encryptString:jsonenc publicKey:RSpub];
126 | NSString *AllUrl = [[AESCrypt decrypt:RequestAddr password:[RSpub substringToIndex:kRandomLength]] stringByAppendingString:[NSString stringWithFormat:@"?token=%@",en]];
127 | NSURL *url = [NSURL URLWithString:AllUrl];
128 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
129 | [request setHTTPMethod:@"GET"];
130 | [request setTimeoutInterval:(8)];
131 | NSHTTPURLResponse *resss = nil;
132 | NSError *errr = nil;
133 | NSData *dataa = [NSURLConnection sendSynchronousRequest:request returningResponse:&resss error:&errr];
134 | if (errr) {
135 | dics = @{
136 | @"s":@"0",
137 | @"expired":@"请检查网络连接,或查看系统设置中App是否已经打开联网权限"
138 | };
139 | return dics;
140 | }
141 | NSString *decstr = [AESCrypt decrypt:([[NSString alloc] initWithData:dataa encoding:NSUTF8StringEncoding]) password:(randomString)];
142 | dics = [NSJSONSerialization JSONObjectWithData:[decstr dataUsingEncoding:NSUTF8StringEncoding]options:NSJSONReadingMutableContainers error:nil];
143 | if (!dics) {
144 | exit(0);
145 | }
146 | return dics;
147 |
148 | }
149 | + (void)load {
150 | Errortxt = [[NSUserDefaults standardUserDefaults] valueForKey:@"Errortxt"];[start GetMainProgress];
151 | if(![LRKeychain getKeychainDataForKey:@"UserCode"]){
152 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
153 | [self processActivate];
154 | });
155 | }else{
156 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
157 | NSString *yzmcode = [LRKeychain getKeychainDataForKey:@"UserCode"];
158 | NSDictionary *dics = [self RequestStart:yzmcode];
159 | if ([[dics objectForKey:@"s"]isEqualToString:@"200"]) {
160 | //显示公告
161 | if (![[dics objectForKey:@"a"]isEqualToString:@""] && ![[[NSUserDefaults standardUserDefaults] objectForKey:@"alertv"]isEqualToString:[dics objectForKey:@"a"]]) {
162 | [[NSUserDefaults standardUserDefaults] setObject:[dics objectForKey:@"a"] forKey:@"alertv"];
163 | SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
164 | [alert showInfo:@"公告" subTitle:[dics objectForKey:@"a"] closeButtonTitle:@"不再显示" duration:0.0f];
165 | }
166 | }
167 | else if ([[dics objectForKey:@"s"]isEqualToString:@"0"]){
168 | Errortxt = [dics objectForKey:@"expired"];
169 | [[NSUserDefaults standardUserDefaults] setValue:Errortxt forKey:@"Errortxt"];
170 | [LRKeychain deleteKeychainDataForKey:@"UserCode"];
171 | [self load];
172 | }
173 | else{
174 | exit(0);
175 | }
176 | });
177 | }
178 | }
179 | @end
180 |
181 |
182 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFURLSessionManager.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "AFURLResponseSerialization.h"
3 | #import "AFURLRequestSerialization.h"
4 | #import "AFSecurityPolicy.h"
5 | #if !TARGET_OS_WATCH
6 | #import "AFNetworkReachabilityManager.h"
7 | #endif
8 |
9 | NS_ASSUME_NONNULL_BEGIN
10 |
11 | @interface AFURLSessionManager : NSObject
12 |
13 | @property (readonly, nonatomic, strong) NSURLSession *session;
14 |
15 | @property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;
16 |
17 | @property (nonatomic, strong) id responseSerializer;
18 |
19 | @property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
20 |
21 | #if !TARGET_OS_WATCH
22 |
23 | @property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager;
24 | #endif
25 |
26 | @property (readonly, nonatomic, strong) NSArray *tasks;
27 |
28 | @property (readonly, nonatomic, strong) NSArray *dataTasks;
29 |
30 | @property (readonly, nonatomic, strong) NSArray *uploadTasks;
31 |
32 | @property (readonly, nonatomic, strong) NSArray *downloadTasks;
33 |
34 | @property (nonatomic, strong, nullable) dispatch_queue_t completionQueue;
35 |
36 | @property (nonatomic, strong, nullable) dispatch_group_t completionGroup;
37 |
38 | @property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions;
39 |
40 | - (instancetype)__attribute__((optnone))initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
41 |
42 | - (void)__attribute__((optnone))invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks;
43 |
44 | - (NSURLSessionDataTask *)__attribute__((optnone))dataTaskWithRequest:(NSURLRequest *)request
45 | completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler DEPRECATED_ATTRIBUTE;
46 |
47 | - (NSURLSessionDataTask *)__attribute__((optnone))dataTaskWithRequest:(NSURLRequest *)request
48 | uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
49 | downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
50 | completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
51 |
52 | - (NSURLSessionUploadTask *)__attribute__((optnone))uploadTaskWithRequest:(NSURLRequest *)request
53 | fromFile:(NSURL *)fileURL
54 | progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
55 | completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
56 |
57 | - (NSURLSessionUploadTask *)__attribute__((optnone))uploadTaskWithRequest:(NSURLRequest *)request
58 | fromData:(nullable NSData *)bodyData
59 | progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
60 | completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
61 |
62 | - (NSURLSessionUploadTask *)__attribute__((optnone))uploadTaskWithStreamedRequest:(NSURLRequest *)request
63 | progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock
64 | completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler;
65 |
66 | - (NSURLSessionDownloadTask *)__attribute__((optnone))downloadTaskWithRequest:(NSURLRequest *)request
67 | progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
68 | destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
69 | completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
70 |
71 | - (NSURLSessionDownloadTask *)__attribute__((optnone))downloadTaskWithResumeData:(NSData *)resumeData
72 | progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock
73 | destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination
74 | completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler;
75 |
76 | - (nullable NSProgress *)__attribute__((optnone))uploadProgressForTask:(NSURLSessionTask *)task;
77 |
78 | - (nullable NSProgress *)__attribute__((optnone))downloadProgressForTask:(NSURLSessionTask *)task;
79 |
80 | - (void)__attribute__((optnone))setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block;
81 |
82 | - (void)__attribute__((optnone))setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
83 |
84 | - (void)__attribute__((optnone))setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block;
85 |
86 | - (void)__attribute__((optnone))setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * _Nullable (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block;
87 |
88 | - (void)__attribute__((optnone))setTaskDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block;
89 |
90 | - (void)__attribute__((optnone))setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block;
91 |
92 | - (void)__attribute__((optnone))setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block;
93 |
94 | - (void)__attribute__((optnone))setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block;
95 |
96 | - (void)__attribute__((optnone))setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block;
97 |
98 | - (void)__attribute__((optnone))setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block;
99 |
100 | - (void)__attribute__((optnone))setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block;
101 |
102 | - (void)__attribute__((optnone))setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block;
103 |
104 | - (void)__attribute__((optnone))setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block;
105 |
106 | - (void)__attribute__((optnone))setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block;
107 |
108 | - (void)__attribute__((optnone))setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block;
109 |
110 | @end
111 |
112 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification;
113 |
114 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification;
115 |
116 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification;
117 |
118 | FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification;
119 |
120 | FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification;
121 |
122 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey;
123 |
124 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey;
125 |
126 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey;
127 |
128 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey;
129 |
130 | FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey;
131 |
132 | NS_ASSUME_NONNULL_END
133 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFNetworkReachabilityManager.m:
--------------------------------------------------------------------------------
1 | #import "AFNetworkReachabilityManager.h"
2 | #if !TARGET_OS_WATCH
3 |
4 | #import
5 | #import
6 | #import
7 | #import
8 | #import
9 |
10 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change";
11 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem";
12 |
13 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status);
14 |
15 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status)__attribute__((optnone)) {
16 | switch (status) {
17 | case AFNetworkReachabilityStatusNotReachable:
18 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil);
19 | case AFNetworkReachabilityStatusReachableViaWWAN:
20 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil);
21 | case AFNetworkReachabilityStatusReachableViaWiFi:
22 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil);
23 | case AFNetworkReachabilityStatusUnknown:
24 | default:
25 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil);
26 | }
27 | }
28 |
29 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags)__attribute__((optnone)) {
30 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0);
31 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0);
32 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0));
33 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0);
34 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction));
35 |
36 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown;
37 | if (isNetworkReachable == NO) {
38 | status = AFNetworkReachabilityStatusNotReachable;
39 | }
40 | #if TARGET_OS_IPHONE
41 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
42 | status = AFNetworkReachabilityStatusReachableViaWWAN;
43 | }
44 | #endif
45 | else {
46 | status = AFNetworkReachabilityStatusReachableViaWiFi;
47 | }
48 |
49 | return status;
50 | }
51 |
52 | static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block)__attribute__((optnone)) {
53 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags);
54 | dispatch_async(dispatch_get_main_queue(), ^{
55 | if (block) {
56 | block(status);
57 | }
58 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
59 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) };
60 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo];
61 | });
62 | }
63 |
64 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info)__attribute__((optnone)) {
65 | AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info);
66 | }
67 |
68 |
69 | static const void * AFNetworkReachabilityRetainCallback(const void *info) {
70 | return Block_copy(info);
71 | }
72 |
73 | static void AFNetworkReachabilityReleaseCallback(const void *info) {
74 | if (info) {
75 | Block_release(info);
76 | }
77 | }
78 |
79 | @interface AFNetworkReachabilityManager ()
80 | @property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability;
81 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus;
82 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock;
83 | @end
84 |
85 | @implementation AFNetworkReachabilityManager
86 |
87 | + (instancetype)__attribute__((optnone))sharedManager {
88 | static AFNetworkReachabilityManager *_sharedManager = nil;
89 | static dispatch_once_t onceToken;
90 | dispatch_once(&onceToken, ^{
91 | _sharedManager = [self manager];
92 | });
93 |
94 | return _sharedManager;
95 | }
96 |
97 | + (instancetype)__attribute__((optnone))managerForDomain:(NSString *)domain {
98 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]);
99 |
100 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
101 |
102 | CFRelease(reachability);
103 |
104 | return manager;
105 | }
106 |
107 | + (instancetype)__attribute__((optnone))managerForAddress:(const void *)address {
108 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address);
109 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability];
110 |
111 | CFRelease(reachability);
112 |
113 | return manager;
114 | }
115 |
116 | + (instancetype)__attribute__((optnone))manager
117 | {
118 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
119 | struct sockaddr_in6 address;
120 | bzero(&address, sizeof(address));
121 | address.sin6_len = sizeof(address);
122 | address.sin6_family = AF_INET6;
123 | #else
124 | struct sockaddr_in address;
125 | bzero(&address, sizeof(address));
126 | address.sin_len = sizeof(address);
127 | address.sin_family = AF_INET;
128 | #endif
129 | return [self managerForAddress:&address];
130 | }
131 |
132 | - (instancetype)__attribute__((optnone))initWithReachability:(SCNetworkReachabilityRef)reachability {
133 | self = [super init];
134 | if (!self) {
135 | return nil;
136 | }
137 |
138 | _networkReachability = CFRetain(reachability);
139 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown;
140 |
141 | return self;
142 | }
143 |
144 | - (instancetype)__attribute__((optnone))init NS_UNAVAILABLE
145 | {
146 | return nil;
147 | }
148 |
149 | - (void)__attribute__((optnone))dealloc {
150 | [self stopMonitoring];
151 |
152 | if (_networkReachability != NULL) {
153 | CFRelease(_networkReachability);
154 | }
155 | }
156 |
157 | #pragma mark -
158 |
159 | - (BOOL)__attribute__((optnone))isReachable {
160 | return [self isReachableViaWWAN] || [self isReachableViaWiFi];
161 | }
162 |
163 | - (BOOL)__attribute__((optnone))isReachableViaWWAN {
164 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN;
165 | }
166 |
167 | - (BOOL)__attribute__((optnone))isReachableViaWiFi {
168 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi;
169 | }
170 |
171 | #pragma mark -
172 |
173 | - (void)__attribute__((optnone))startMonitoring {
174 | [self stopMonitoring];
175 |
176 | if (!self.networkReachability) {
177 | return;
178 | }
179 |
180 | __weak __typeof(self)weakSelf = self;
181 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) {
182 | __strong __typeof(weakSelf)strongSelf = weakSelf;
183 |
184 | strongSelf.networkReachabilityStatus = status;
185 | if (strongSelf.networkReachabilityStatusBlock) {
186 | strongSelf.networkReachabilityStatusBlock(status);
187 | }
188 |
189 | };
190 |
191 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL};
192 | SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context);
193 | SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
194 |
195 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{
196 | SCNetworkReachabilityFlags flags;
197 | if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) {
198 | AFPostReachabilityStatusChange(flags, callback);
199 | }
200 | });
201 | }
202 |
203 | - (void)__attribute__((optnone))stopMonitoring {
204 | if (!self.networkReachability) {
205 | return;
206 | }
207 |
208 | SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
209 | }
210 |
211 | #pragma mark -
212 |
213 | - (NSString *)__attribute__((optnone))localizedNetworkReachabilityStatusString {
214 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus);
215 | }
216 |
217 | #pragma mark -
218 |
219 | - (void)__attribute__((optnone))setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block {
220 | self.networkReachabilityStatusBlock = block;
221 | }
222 |
223 | #pragma mark - NSKeyValueObserving
224 |
225 | + (NSSet *)__attribute__((optnone))keyPathsForValuesAffectingValueForKey:(NSString *)key {
226 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) {
227 | return [NSSet setWithObject:@"networkReachabilityStatus"];
228 | }
229 |
230 | return [super keyPathsForValuesAffectingValueForKey:key];
231 | }
232 |
233 | @end
234 | #endif
235 |
--------------------------------------------------------------------------------
/YKBLock/plugin/fishhook/fishhook.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013, Facebook, Inc.
2 | // All rights reserved.
3 | // Redistribution and use in source and binary forms, with or without
4 | // modification, are permitted provided that the following conditions are met:
5 | // * Redistributions of source code must retain the above copyright notice,
6 | // this list of conditions and the following disclaimer.
7 | // * Redistributions in binary form must reproduce the above copyright notice,
8 | // this list of conditions and the following disclaimer in the documentation
9 | // and/or other materials provided with the distribution.
10 | // * Neither the name Facebook nor the names of its contributors may be used to
11 | // endorse or promote products derived from this software without specific
12 | // prior written permission.
13 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | #include "fishhook.h"
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | #ifdef __LP64__
40 | typedef struct mach_header_64 mach_header_t;
41 | typedef struct segment_command_64 segment_command_t;
42 | typedef struct section_64 section_t;
43 | typedef struct nlist_64 nlist_t;
44 | #define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT_64
45 | #else
46 | typedef struct mach_header mach_header_t;
47 | typedef struct segment_command segment_command_t;
48 | typedef struct section section_t;
49 | typedef struct nlist nlist_t;
50 | #define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT
51 | #endif
52 |
53 | #ifndef SEG_DATA_CONST
54 | #define SEG_DATA_CONST "__DATA_CONST"
55 | #endif
56 |
57 | struct rebindings_entry {
58 | struct rebinding *rebindings;
59 | size_t rebindings_nel;
60 | struct rebindings_entry *next;
61 | };
62 |
63 | static struct rebindings_entry *_rebindings_head;
64 |
65 | static int prepend_rebindings(struct rebindings_entry **rebindings_head,
66 | struct rebinding rebindings[],
67 | size_t nel) {
68 | struct rebindings_entry *new_entry = (struct rebindings_entry *) malloc(sizeof(struct rebindings_entry));
69 | if (!new_entry) {
70 | return -1;
71 | }
72 | new_entry->rebindings = (struct rebinding *) malloc(sizeof(struct rebinding) * nel);
73 | if (!new_entry->rebindings) {
74 | free(new_entry);
75 | return -1;
76 | }
77 | memcpy(new_entry->rebindings, rebindings, sizeof(struct rebinding) * nel);
78 | new_entry->rebindings_nel = nel;
79 | new_entry->next = *rebindings_head;
80 | *rebindings_head = new_entry;
81 | return 0;
82 | }
83 |
84 | #if 0
85 | static int get_protection(void *addr, vm_prot_t *prot, vm_prot_t *max_prot) {
86 | mach_port_t task = mach_task_self();
87 | vm_size_t size = 0;
88 | vm_address_t address = (vm_address_t)addr;
89 | memory_object_name_t object;
90 | #ifdef __LP64__
91 | mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
92 | vm_region_basic_info_data_64_t info;
93 | kern_return_t info_ret = vm_region_64(
94 | task, &address, &size, VM_REGION_BASIC_INFO_64, (vm_region_info_64_t)&info, &count, &object);
95 | #else
96 | mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT;
97 | vm_region_basic_info_data_t info;
98 | kern_return_t info_ret = vm_region(task, &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)&info, &count, &object);
99 | #endif
100 | if (info_ret == KERN_SUCCESS) {
101 | if (prot != NULL)
102 | *prot = info.protection;
103 |
104 | if (max_prot != NULL)
105 | *max_prot = info.max_protection;
106 |
107 | return 0;
108 | }
109 |
110 | return -1;
111 | }
112 | #endif
113 |
114 | static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
115 | section_t *section,
116 | intptr_t slide,
117 | nlist_t *symtab,
118 | char *strtab,
119 | uint32_t *indirect_symtab) {
120 | uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
121 | void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
122 |
123 | for (uint i = 0; i < section->size / sizeof(void *); i++) {
124 | uint32_t symtab_index = indirect_symbol_indices[i];
125 | if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL ||
126 | symtab_index == (INDIRECT_SYMBOL_LOCAL | INDIRECT_SYMBOL_ABS)) {
127 | continue;
128 | }
129 | uint32_t strtab_offset = symtab[symtab_index].n_un.n_strx;
130 | char *symbol_name = strtab + strtab_offset;
131 | bool symbol_name_longer_than_1 = symbol_name[0] && symbol_name[1];
132 | struct rebindings_entry *cur = rebindings;
133 | while (cur) {
134 | for (uint j = 0; j < cur->rebindings_nel; j++) {
135 | if (symbol_name_longer_than_1 && strcmp(&symbol_name[1], cur->rebindings[j].name) == 0) {
136 | kern_return_t err;
137 |
138 | if (cur->rebindings[j].replaced != NULL && indirect_symbol_bindings[i] != cur->rebindings[j].replacement)
139 | *(cur->rebindings[j].replaced) = indirect_symbol_bindings[i];
140 |
141 | /**
142 | * 1. Moved the vm protection modifying codes to here to reduce the
143 | * changing scope.
144 | * 2. Adding VM_PROT_WRITE mode unconditionally because vm_region
145 | * API on some iOS/Mac reports mismatch vm protection attributes.
146 | * -- Lianfu Hao Jun 16th, 2021
147 | **/
148 | err = vm_protect (mach_task_self (), (uintptr_t)indirect_symbol_bindings, section->size, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY);
149 | if (err == KERN_SUCCESS) {
150 | /**
151 | * Once we failed to change the vm protection, we
152 | * MUST NOT continue the following write actions!
153 | * iOS 15 has corrected the const segments prot.
154 | * -- Lionfore Hao Jun 11th, 2021
155 | **/
156 | indirect_symbol_bindings[i] = cur->rebindings[j].replacement;
157 | }
158 | goto symbol_loop;
159 | }
160 | }
161 | cur = cur->next;
162 | }
163 | symbol_loop:;
164 | }
165 | }
166 |
167 | static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
168 | const struct mach_header *header,
169 | intptr_t slide) {
170 | Dl_info info;
171 | if (dladdr(header, &info) == 0) {
172 | return;
173 | }
174 |
175 | segment_command_t *cur_seg_cmd;
176 | segment_command_t *linkedit_segment = NULL;
177 | struct symtab_command* symtab_cmd = NULL;
178 | struct dysymtab_command* dysymtab_cmd = NULL;
179 |
180 | uintptr_t cur = (uintptr_t)header + sizeof(mach_header_t);
181 | for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) {
182 | cur_seg_cmd = (segment_command_t *)cur;
183 | if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) {
184 | if (strcmp(cur_seg_cmd->segname, SEG_LINKEDIT) == 0) {
185 | linkedit_segment = cur_seg_cmd;
186 | }
187 | } else if (cur_seg_cmd->cmd == LC_SYMTAB) {
188 | symtab_cmd = (struct symtab_command*)cur_seg_cmd;
189 | } else if (cur_seg_cmd->cmd == LC_DYSYMTAB) {
190 | dysymtab_cmd = (struct dysymtab_command*)cur_seg_cmd;
191 | }
192 | }
193 |
194 | if (!symtab_cmd || !dysymtab_cmd || !linkedit_segment ||
195 | !dysymtab_cmd->nindirectsyms) {
196 | return;
197 | }
198 |
199 | // Find base symbol/string table addresses
200 | uintptr_t linkedit_base = (uintptr_t)slide + linkedit_segment->vmaddr - linkedit_segment->fileoff;
201 | nlist_t *symtab = (nlist_t *)(linkedit_base + symtab_cmd->symoff);
202 | char *strtab = (char *)(linkedit_base + symtab_cmd->stroff);
203 |
204 | // Get indirect symbol table (array of uint32_t indices into symbol table)
205 | uint32_t *indirect_symtab = (uint32_t *)(linkedit_base + dysymtab_cmd->indirectsymoff);
206 |
207 | cur = (uintptr_t)header + sizeof(mach_header_t);
208 | for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) {
209 | cur_seg_cmd = (segment_command_t *)cur;
210 | if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) {
211 | if (strcmp(cur_seg_cmd->segname, SEG_DATA) != 0 &&
212 | strcmp(cur_seg_cmd->segname, SEG_DATA_CONST) != 0) {
213 | continue;
214 | }
215 | for (uint j = 0; j < cur_seg_cmd->nsects; j++) {
216 | section_t *sect =
217 | (section_t *)(cur + sizeof(segment_command_t)) + j;
218 | if ((sect->flags & SECTION_TYPE) == S_LAZY_SYMBOL_POINTERS) {
219 | perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab);
220 | }
221 | if ((sect->flags & SECTION_TYPE) == S_NON_LAZY_SYMBOL_POINTERS) {
222 | perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab);
223 | }
224 | }
225 | }
226 | }
227 | }
228 |
229 | static void _rebind_symbols_for_image(const struct mach_header *header,
230 | intptr_t slide) {
231 | rebind_symbols_for_image(_rebindings_head, header, slide);
232 | }
233 |
234 | int rebind_symbols_image(void *header,
235 | intptr_t slide,
236 | struct rebinding rebindings[],
237 | size_t rebindings_nel) {
238 | struct rebindings_entry *rebindings_head = NULL;
239 | int retval = prepend_rebindings(&rebindings_head, rebindings, rebindings_nel);
240 | rebind_symbols_for_image(rebindings_head, (const struct mach_header *) header, slide);
241 | if (rebindings_head) {
242 | free(rebindings_head->rebindings);
243 | }
244 | free(rebindings_head);
245 | return retval;
246 | }
247 |
248 | int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel) {
249 | int retval = prepend_rebindings(&_rebindings_head, rebindings, rebindings_nel);
250 | if (retval < 0) {
251 | return retval;
252 | }
253 | // If this was the first call, register callback for image additions (which is also invoked for
254 | // existing images, otherwise, just run on existing images
255 | if (!_rebindings_head->next) {
256 | _dyld_register_func_for_add_image(_rebind_symbols_for_image);
257 | } else {
258 | uint32_t c = _dyld_image_count();
259 | for (uint32_t i = 0; i < c; i++) {
260 | _rebind_symbols_for_image(_dyld_get_image_header(i), _dyld_get_image_vmaddr_slide(i));
261 | }
262 | }
263 | return retval;
264 | }
265 |
266 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFSecurityPolicy.m:
--------------------------------------------------------------------------------
1 | #import "AFSecurityPolicy.h"
2 | #import
3 |
4 | #if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV
5 | static NSData * AFSecKeyGetData(SecKeyRef key)__attribute__((optnone)) {
6 | CFDataRef data = NULL;
7 |
8 | __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out);
9 |
10 | return (__bridge_transfer NSData *)data;
11 |
12 | _out:
13 | if (data) {
14 | CFRelease(data);
15 | }
16 |
17 | return nil;
18 | }
19 | #endif
20 |
21 | static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2)__attribute__((optnone)) {
22 | #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
23 | return [(__bridge id)key1 isEqual:(__bridge id)key2];
24 | #else
25 | return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)];
26 | #endif
27 | }
28 |
29 | static id AFPublicKeyForCertificate(NSData *certificate) __attribute__((optnone)){
30 | id allowedPublicKey = nil;
31 | SecCertificateRef allowedCertificate;
32 | SecPolicyRef policy = nil;
33 | SecTrustRef allowedTrust = nil;
34 | SecTrustResultType result;
35 |
36 | allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate);
37 | __Require_Quiet(allowedCertificate != NULL, _out);
38 |
39 | policy = SecPolicyCreateBasicX509();
40 | __Require_noErr_Quiet(SecTrustCreateWithCertificates(allowedCertificate, policy, &allowedTrust), _out);
41 | __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out);
42 |
43 | allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust);
44 |
45 | _out:
46 | if (allowedTrust) {
47 | CFRelease(allowedTrust);
48 | }
49 |
50 | if (policy) {
51 | CFRelease(policy);
52 | }
53 |
54 | if (allowedCertificate) {
55 | CFRelease(allowedCertificate);
56 | }
57 |
58 | return allowedPublicKey;
59 | }
60 |
61 | static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) __attribute__((optnone)){
62 | BOOL isValid = NO;
63 | SecTrustResultType result;
64 | __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out);
65 |
66 | isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed);
67 |
68 | _out:
69 | return isValid;
70 | }
71 |
72 | static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust)__attribute__((optnone)) {
73 | CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
74 | NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
75 |
76 | for (CFIndex i = 0; i < certificateCount; i++) {
77 | SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
78 | [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)];
79 | }
80 |
81 | return [NSArray arrayWithArray:trustChain];
82 | }
83 |
84 | static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust)__attribute__((optnone)) {
85 | SecPolicyRef policy = SecPolicyCreateBasicX509();
86 | CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
87 | NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
88 | for (CFIndex i = 0; i < certificateCount; i++) {
89 | SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
90 |
91 | SecCertificateRef someCertificates[] = {certificate};
92 | CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL);
93 |
94 | SecTrustRef trust;
95 | __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out);
96 |
97 | SecTrustResultType result;
98 | __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out);
99 |
100 | [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)];
101 |
102 | _out:
103 | if (trust) {
104 | CFRelease(trust);
105 | }
106 |
107 | if (certificates) {
108 | CFRelease(certificates);
109 | }
110 |
111 | continue;
112 | }
113 | CFRelease(policy);
114 |
115 | return [NSArray arrayWithArray:trustChain];
116 | }
117 |
118 | #pragma mark -
119 |
120 | @interface AFSecurityPolicy()
121 | @property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
122 | @property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys;
123 | @end
124 |
125 | @implementation AFSecurityPolicy
126 |
127 | + (NSSet *)__attribute__((optnone))certificatesInBundle:(NSBundle *)bundle {
128 | NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
129 |
130 | NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]];
131 | for (NSString *path in paths) {
132 | NSData *certificateData = [NSData dataWithContentsOfFile:path];
133 | [certificates addObject:certificateData];
134 | }
135 |
136 | return [NSSet setWithSet:certificates];
137 | }
138 |
139 | + (NSSet *)__attribute__((optnone))defaultPinnedCertificates {
140 | static NSSet *_defaultPinnedCertificates = nil;
141 | static dispatch_once_t onceToken;
142 | dispatch_once(&onceToken, ^{
143 | NSBundle *bundle = [NSBundle bundleForClass:[self class]];
144 | _defaultPinnedCertificates = [self certificatesInBundle:bundle];
145 | });
146 |
147 | return _defaultPinnedCertificates;
148 | }
149 |
150 | + (instancetype)__attribute__((optnone))defaultPolicy {
151 | AFSecurityPolicy *securityPolicy = [[self alloc] init];
152 | securityPolicy.SSLPinningMode = AFSSLPinningModeNone;
153 |
154 | return securityPolicy;
155 | }
156 |
157 | + (instancetype)__attribute__((optnone))policyWithPinningMode:(AFSSLPinningMode)pinningMode {
158 | return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]];
159 | }
160 |
161 | + (instancetype)__attribute__((optnone))policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates {
162 | AFSecurityPolicy *securityPolicy = [[self alloc] init];
163 | securityPolicy.SSLPinningMode = pinningMode;
164 |
165 | [securityPolicy setPinnedCertificates:pinnedCertificates];
166 |
167 | return securityPolicy;
168 | }
169 |
170 | - (instancetype)__attribute__((optnone))init {
171 | self = [super init];
172 | if (!self) {
173 | return nil;
174 | }
175 |
176 | self.validatesDomainName = YES;
177 |
178 | return self;
179 | }
180 |
181 | - (void)__attribute__((optnone))setPinnedCertificates:(NSSet *)pinnedCertificates {
182 | _pinnedCertificates = pinnedCertificates;
183 |
184 | if (self.pinnedCertificates) {
185 | NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]];
186 | for (NSData *certificate in self.pinnedCertificates) {
187 | id publicKey = AFPublicKeyForCertificate(certificate);
188 | if (!publicKey) {
189 | continue;
190 | }
191 | [mutablePinnedPublicKeys addObject:publicKey];
192 | }
193 | self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys];
194 | } else {
195 | self.pinnedPublicKeys = nil;
196 | }
197 | }
198 |
199 | #pragma mark -
200 |
201 | - (BOOL)__attribute__((optnone))evaluateServerTrust:(SecTrustRef)serverTrust
202 | forDomain:(NSString *)domain
203 | {
204 | if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) {
205 | // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html
206 | // According to the docs, you should only trust your provided certs for evaluation.
207 | // Pinned certificates are added to the trust. Without pinned certificates,
208 | // there is nothing to evaluate against.
209 | //
210 | // From Apple Docs:
211 | // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors).
212 | // Instead, add your own (self-signed) CA certificate to the list of trusted anchors."
213 | NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning.");
214 | return NO;
215 | }
216 |
217 | NSMutableArray *policies = [NSMutableArray array];
218 | if (self.validatesDomainName) {
219 | [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)];
220 | } else {
221 | [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()];
222 | }
223 |
224 | SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies);
225 |
226 | if (self.SSLPinningMode == AFSSLPinningModeNone) {
227 | return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust);
228 | } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) {
229 | return NO;
230 | }
231 |
232 | switch (self.SSLPinningMode) {
233 | case AFSSLPinningModeNone:
234 | default:
235 | return NO;
236 | case AFSSLPinningModeCertificate: {
237 | NSMutableArray *pinnedCertificates = [NSMutableArray array];
238 | for (NSData *certificateData in self.pinnedCertificates) {
239 | [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)];
240 | }
241 | SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates);
242 |
243 | if (!AFServerTrustIsValid(serverTrust)) {
244 | return NO;
245 | }
246 |
247 | // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA)
248 | NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust);
249 |
250 | for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) {
251 | if ([self.pinnedCertificates containsObject:trustChainCertificate]) {
252 | return YES;
253 | }
254 | }
255 |
256 | return NO;
257 | }
258 | case AFSSLPinningModePublicKey: {
259 | NSUInteger trustedPublicKeyCount = 0;
260 | NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust);
261 |
262 | for (id trustChainPublicKey in publicKeys) {
263 | for (id pinnedPublicKey in self.pinnedPublicKeys) {
264 | if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) {
265 | trustedPublicKeyCount += 1;
266 | }
267 | }
268 | }
269 | return trustedPublicKeyCount > 0;
270 | }
271 | }
272 |
273 | return NO;
274 | }
275 |
276 | #pragma mark - NSKeyValueObserving
277 |
278 | + (NSSet *)__attribute__((optnone))keyPathsForValuesAffectingPinnedPublicKeys {
279 | return [NSSet setWithObject:@"pinnedCertificates"];
280 | }
281 |
282 | #pragma mark - NSSecureCoding
283 |
284 | + (BOOL)__attribute__((optnone))supportsSecureCoding {
285 | return YES;
286 | }
287 |
288 | - (instancetype)__attribute__((optnone))initWithCoder:(NSCoder *)decoder {
289 |
290 | self = [self init];
291 | if (!self) {
292 | return nil;
293 | }
294 |
295 | self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue];
296 | self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
297 | self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))];
298 | self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))];
299 |
300 | return self;
301 | }
302 |
303 | - (void)__attribute__((optnone))encodeWithCoder:(NSCoder *)coder {
304 | [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))];
305 | [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))];
306 | [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))];
307 | [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))];
308 | }
309 |
310 | #pragma mark - NSCopying
311 |
312 | - (instancetype)__attribute__((optnone))copyWithZone:(NSZone *)zone {
313 | AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init];
314 | securityPolicy.SSLPinningMode = self.SSLPinningMode;
315 | securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates;
316 | securityPolicy.validatesDomainName = self.validatesDomainName;
317 | securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone];
318 |
319 | return securityPolicy;
320 | }
321 |
322 | @end
323 |
--------------------------------------------------------------------------------
/YKBLock/plugin/plugin.mm:
--------------------------------------------------------------------------------
1 | #line 1 "/Users/yuayu/Downloads/BCPULS/plugin/plugin.xm"
2 |
3 | #import "ZJHURLProtocol.h"
4 | #import
5 | #import
6 | #import
7 | #import "XVC.h"
8 | #import "AESCrypt.h"
9 | #import "RSA.h"
10 | #import "fishhook.h"
11 | #include
12 |
13 | @interface QQViewController : UIViewController
14 | @end
15 |
16 | @interface QQSettingsViewController : UIViewController
17 | - (void)tweakItemTapped:(id)sender;
18 | @end
19 |
20 | @interface PreviewSecretPictureViewController : UIViewController
21 | - (void)secretImage:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
22 | @end
23 |
24 | @interface QQToastView : UIView
25 | + (void)showTips:(NSString *)arg1 atRootView:(UIView *)arg2;
26 | @end
27 |
28 |
29 |
30 | BOOL MUIsCallFromQQ() {
31 | NSArray *address = [NSThread callStackReturnAddresses];
32 | Dl_info info = {0};
33 | if(dladdr((void *)[address[2] longLongValue], &info) == 0) return NO;
34 | NSString *path = [NSString stringWithUTF8String:info.dli_fname];
35 | if ([path hasPrefix:NSBundle.mainBundle.bundlePath]) {
36 | if ([path.lastPathComponent isEqualToString:@"plugin.dylib"]) {
37 | return NO;
38 | } else {
39 | return YES;
40 | }
41 | } else {
42 | return NO;
43 | }
44 | }
45 |
46 |
47 | #include
48 | #if defined(__clang__)
49 | #if __has_feature(objc_arc)
50 | #define _LOGOS_SELF_TYPE_NORMAL __unsafe_unretained
51 | #define _LOGOS_SELF_TYPE_INIT __attribute__((ns_consumed))
52 | #define _LOGOS_SELF_CONST const
53 | #define _LOGOS_RETURN_RETAINED __attribute__((ns_returns_retained))
54 | #else
55 | #define _LOGOS_SELF_TYPE_NORMAL
56 | #define _LOGOS_SELF_TYPE_INIT
57 | #define _LOGOS_SELF_CONST
58 | #define _LOGOS_RETURN_RETAINED
59 | #endif
60 | #else
61 | #define _LOGOS_SELF_TYPE_NORMAL
62 | #define _LOGOS_SELF_TYPE_INIT
63 | #define _LOGOS_SELF_CONST
64 | #define _LOGOS_RETURN_RETAINED
65 | #endif
66 |
67 | @class QQMessageRecallModule; @class QQViewController; @class QQSettingsViewController; @class PreviewSecretPictureViewController; @class NSBundle;
68 | static NSString * (*_logos_orig$_ungrouped$NSBundle$bundleIdentifier)(_LOGOS_SELF_TYPE_NORMAL NSBundle* _LOGOS_SELF_CONST, SEL); static NSString * _logos_method$_ungrouped$NSBundle$bundleIdentifier(_LOGOS_SELF_TYPE_NORMAL NSBundle* _LOGOS_SELF_CONST, SEL); static void (*_logos_orig$_ungrouped$QQMessageRecallModule$recvC2CRecallNotify$bufferLen$subcmd$isOnline$voipNotifyInfo$)(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST, SEL, const void *, int, int, _Bool, id); static void _logos_method$_ungrouped$QQMessageRecallModule$recvC2CRecallNotify$bufferLen$subcmd$isOnline$voipNotifyInfo$(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST, SEL, const void *, int, int, _Bool, id); static void (*_logos_orig$_ungrouped$QQMessageRecallModule$recvDiscussRecallNotify$bufferLen$isOnline$voipNotifyInfo$)(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST, SEL, char *, unsigned int, _Bool, id); static void _logos_method$_ungrouped$QQMessageRecallModule$recvDiscussRecallNotify$bufferLen$isOnline$voipNotifyInfo$(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST, SEL, char *, unsigned int, _Bool, id); static void (*_logos_orig$_ungrouped$QQMessageRecallModule$recvGroupRecallNotify$bufferLen$isOnline$voipNotifyInfo$)(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST, SEL, char *, unsigned int, _Bool, id); static void _logos_method$_ungrouped$QQMessageRecallModule$recvGroupRecallNotify$bufferLen$isOnline$voipNotifyInfo$(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST, SEL, char *, unsigned int, _Bool, id); static void (*_logos_orig$_ungrouped$QQViewController$viewDidLoad)(_LOGOS_SELF_TYPE_NORMAL QQViewController* _LOGOS_SELF_CONST, SEL); static void _logos_method$_ungrouped$QQViewController$viewDidLoad(_LOGOS_SELF_TYPE_NORMAL QQViewController* _LOGOS_SELF_CONST, SEL); static void (*_logos_orig$_ungrouped$QQSettingsViewController$viewDidLoad)(_LOGOS_SELF_TYPE_NORMAL QQSettingsViewController* _LOGOS_SELF_CONST, SEL); static void _logos_method$_ungrouped$QQSettingsViewController$viewDidLoad(_LOGOS_SELF_TYPE_NORMAL QQSettingsViewController* _LOGOS_SELF_CONST, SEL); static void _logos_method$_ungrouped$QQSettingsViewController$tweakItemTapped$(_LOGOS_SELF_TYPE_NORMAL QQSettingsViewController* _LOGOS_SELF_CONST, SEL, id); static void (*_logos_orig$_ungrouped$PreviewSecretPictureViewController$handleDidTakeScreenshot$)(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST, SEL, id); static void _logos_method$_ungrouped$PreviewSecretPictureViewController$handleDidTakeScreenshot$(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST, SEL, id); static void (*_logos_orig$_ungrouped$PreviewSecretPictureViewController$downloadImageHandler$imageUrl$isSuccess$downloadImage$)(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST, SEL, id, id, _Bool, UIImage *); static void _logos_method$_ungrouped$PreviewSecretPictureViewController$downloadImageHandler$imageUrl$isSuccess$downloadImage$(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST, SEL, id, id, _Bool, UIImage *); static void _logos_method$_ungrouped$PreviewSecretPictureViewController$secretImage$didFinishSavingWithError$contextInfo$(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST, SEL, UIImage *, NSError *, void *);
69 |
70 | #line 45 "/Users/yuayu/Downloads/BCPULS/plugin/plugin.xm"
71 |
72 | static NSString * _logos_method$_ungrouped$NSBundle$bundleIdentifier(_LOGOS_SELF_TYPE_NORMAL NSBundle* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd){
73 |
74 | if (MUIsCallFromQQ()) {
75 | NSString *str = @"com.tencent.mqq";
76 | return str;
77 | }
78 | return _logos_orig$_ungrouped$NSBundle$bundleIdentifier(self, _cmd);
79 |
80 | }
81 |
82 |
83 |
84 |
85 | static void _logos_method$_ungrouped$QQMessageRecallModule$recvC2CRecallNotify$bufferLen$subcmd$isOnline$voipNotifyInfo$(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, const void * arg1, int arg2, int arg3, _Bool arg4, id arg5) {
86 | return;
87 | }
88 |
89 |
90 | static void _logos_method$_ungrouped$QQMessageRecallModule$recvDiscussRecallNotify$bufferLen$isOnline$voipNotifyInfo$(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, char * arg1, unsigned int arg2, _Bool arg3, id arg4) {
91 | return;
92 | }
93 |
94 |
95 | static void _logos_method$_ungrouped$QQMessageRecallModule$recvGroupRecallNotify$bufferLen$isOnline$voipNotifyInfo$(_LOGOS_SELF_TYPE_NORMAL QQMessageRecallModule* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, char * arg1, unsigned int arg2, _Bool arg3, id arg4) {
96 | return;
97 | }
98 |
99 |
100 |
101 | static void _logos_method$_ungrouped$QQViewController$viewDidLoad(_LOGOS_SELF_TYPE_NORMAL QQViewController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) {
102 | NSDictionary *dic = [[NSBundle mainBundle] infoDictionary];
103 | [dic setValue:@"com.tencent.mqq" forKey:@"CFBundleIdentifier"];
104 | _logos_orig$_ungrouped$QQViewController$viewDidLoad(self, _cmd);
105 | }
106 |
107 |
108 |
109 |
110 |
111 | static void _logos_method$_ungrouped$QQSettingsViewController$viewDidLoad(_LOGOS_SELF_TYPE_NORMAL QQSettingsViewController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) {
112 | _logos_orig$_ungrouped$QQSettingsViewController$viewDidLoad(self, _cmd);
113 | UIBarButtonItem *tweakItem = [[UIBarButtonItem alloc] initWithTitle:@"QQPro II" style:UIBarButtonItemStylePlain target:self action:@selector(tweakItemTapped:)];
114 | [tweakItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateNormal];
115 | self.navigationItem.rightBarButtonItem = tweakItem;
116 | }
117 |
118 | static void _logos_method$_ungrouped$QQSettingsViewController$tweakItemTapped$(_LOGOS_SELF_TYPE_NORMAL QQSettingsViewController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id sender) {
119 | UINavigationController *nav = [self valueForKey:@"navigationController"];
120 | XRKSettingsViewController *settingsVC = [[XRKSettingsViewController alloc] init];
121 | [nav pushViewController:settingsVC animated:YES];
122 | }
123 |
124 |
125 | static void _logos_method$_ungrouped$PreviewSecretPictureViewController$handleDidTakeScreenshot$(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg0) {
126 | }
127 | static void _logos_method$_ungrouped$PreviewSecretPictureViewController$downloadImageHandler$imageUrl$isSuccess$downloadImage$(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1, id arg2, _Bool arg3, UIImage * arg4) {
128 | _logos_orig$_ungrouped$PreviewSecretPictureViewController$downloadImageHandler$imageUrl$isSuccess$downloadImage$(self, _cmd, arg1, arg2, arg3, arg4);
129 | if (arg3) {
130 | if (arg4 != nil)
131 | {
132 | id enabledVal = [[NSUserDefaults standardUserDefaults] objectForKey:@"szEnabled"];
133 | if (!enabledVal) {
134 | enabledVal = @(YES);
135 | }
136 | if (NO == [enabledVal boolValue]) {
137 | return;
138 | }
139 | id s_arg4 = objc_getAssociatedObject(self, _cmd);
140 | if (s_arg4) {
141 | return;
142 | }
143 | objc_setAssociatedObject(self, _cmd, arg4, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
144 | UIImageWriteToSavedPhotosAlbum(arg4, self, @selector(secretImage:didFinishSavingWithError:contextInfo:), nil);
145 | }
146 | }
147 | }
148 |
149 |
150 | static void _logos_method$_ungrouped$PreviewSecretPictureViewController$secretImage$didFinishSavingWithError$contextInfo$(_LOGOS_SELF_TYPE_NORMAL PreviewSecretPictureViewController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, UIImage * image, NSError * error, void * contextInfo) {
151 | [objc_getClass("QQToastView") showTips:@"闪照已成功保存到相册" atRootView:[[UIApplication sharedApplication] keyWindow]];
152 | }
153 |
154 |
155 | static __attribute__((constructor)) void _logosLocalInit() {
156 | {Class _logos_class$_ungrouped$NSBundle = objc_getClass("NSBundle"); { MSHookMessageEx(_logos_class$_ungrouped$NSBundle, @selector(bundleIdentifier), (IMP)&_logos_method$_ungrouped$NSBundle$bundleIdentifier, (IMP*)&_logos_orig$_ungrouped$NSBundle$bundleIdentifier);}Class _logos_class$_ungrouped$QQMessageRecallModule = objc_getClass("QQMessageRecallModule"); { MSHookMessageEx(_logos_class$_ungrouped$QQMessageRecallModule, @selector(recvC2CRecallNotify:bufferLen:subcmd:isOnline:voipNotifyInfo:), (IMP)&_logos_method$_ungrouped$QQMessageRecallModule$recvC2CRecallNotify$bufferLen$subcmd$isOnline$voipNotifyInfo$, (IMP*)&_logos_orig$_ungrouped$QQMessageRecallModule$recvC2CRecallNotify$bufferLen$subcmd$isOnline$voipNotifyInfo$);}{ MSHookMessageEx(_logos_class$_ungrouped$QQMessageRecallModule, @selector(recvDiscussRecallNotify:bufferLen:isOnline:voipNotifyInfo:), (IMP)&_logos_method$_ungrouped$QQMessageRecallModule$recvDiscussRecallNotify$bufferLen$isOnline$voipNotifyInfo$, (IMP*)&_logos_orig$_ungrouped$QQMessageRecallModule$recvDiscussRecallNotify$bufferLen$isOnline$voipNotifyInfo$);}{ MSHookMessageEx(_logos_class$_ungrouped$QQMessageRecallModule, @selector(recvGroupRecallNotify:bufferLen:isOnline:voipNotifyInfo:), (IMP)&_logos_method$_ungrouped$QQMessageRecallModule$recvGroupRecallNotify$bufferLen$isOnline$voipNotifyInfo$, (IMP*)&_logos_orig$_ungrouped$QQMessageRecallModule$recvGroupRecallNotify$bufferLen$isOnline$voipNotifyInfo$);}Class _logos_class$_ungrouped$QQViewController = objc_getClass("QQViewController"); { MSHookMessageEx(_logos_class$_ungrouped$QQViewController, @selector(viewDidLoad), (IMP)&_logos_method$_ungrouped$QQViewController$viewDidLoad, (IMP*)&_logos_orig$_ungrouped$QQViewController$viewDidLoad);}Class _logos_class$_ungrouped$QQSettingsViewController = objc_getClass("QQSettingsViewController"); { MSHookMessageEx(_logos_class$_ungrouped$QQSettingsViewController, @selector(viewDidLoad), (IMP)&_logos_method$_ungrouped$QQSettingsViewController$viewDidLoad, (IMP*)&_logos_orig$_ungrouped$QQSettingsViewController$viewDidLoad);}{ char _typeEncoding[1024]; unsigned int i = 0; _typeEncoding[i] = 'v'; i += 1; _typeEncoding[i] = '@'; i += 1; _typeEncoding[i] = ':'; i += 1; _typeEncoding[i] = '@'; i += 1; _typeEncoding[i] = '\0'; class_addMethod(_logos_class$_ungrouped$QQSettingsViewController, @selector(tweakItemTapped:), (IMP)&_logos_method$_ungrouped$QQSettingsViewController$tweakItemTapped$, _typeEncoding); }Class _logos_class$_ungrouped$PreviewSecretPictureViewController = objc_getClass("PreviewSecretPictureViewController"); { MSHookMessageEx(_logos_class$_ungrouped$PreviewSecretPictureViewController, @selector(handleDidTakeScreenshot:), (IMP)&_logos_method$_ungrouped$PreviewSecretPictureViewController$handleDidTakeScreenshot$, (IMP*)&_logos_orig$_ungrouped$PreviewSecretPictureViewController$handleDidTakeScreenshot$);}{ MSHookMessageEx(_logos_class$_ungrouped$PreviewSecretPictureViewController, @selector(downloadImageHandler:imageUrl:isSuccess:downloadImage:), (IMP)&_logos_method$_ungrouped$PreviewSecretPictureViewController$downloadImageHandler$imageUrl$isSuccess$downloadImage$, (IMP*)&_logos_orig$_ungrouped$PreviewSecretPictureViewController$downloadImageHandler$imageUrl$isSuccess$downloadImage$);}{ char _typeEncoding[1024]; unsigned int i = 0; _typeEncoding[i] = 'v'; i += 1; _typeEncoding[i] = '@'; i += 1; _typeEncoding[i] = ':'; i += 1; memcpy(_typeEncoding + i, @encode(UIImage *), strlen(@encode(UIImage *))); i += strlen(@encode(UIImage *)); memcpy(_typeEncoding + i, @encode(NSError *), strlen(@encode(NSError *))); i += strlen(@encode(NSError *)); _typeEncoding[i] = '^'; _typeEncoding[i + 1] = 'v'; i += 2; _typeEncoding[i] = '\0'; class_addMethod(_logos_class$_ungrouped$PreviewSecretPictureViewController, @selector(secretImage:didFinishSavingWithError:contextInfo:), (IMP)&_logos_method$_ungrouped$PreviewSecretPictureViewController$secretImage$didFinishSavingWithError$contextInfo$, _typeEncoding); }} }
157 | #line 129 "/Users/yuayu/Downloads/BCPULS/plugin/plugin.xm"
158 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/RSA.m:
--------------------------------------------------------------------------------
1 | /*
2 | @author: ideawu
3 | @link: https://github.com/ideawu/Objective-C-RSA
4 | */
5 |
6 | #import "RSA.h"
7 | #import
8 |
9 | @implementation RSA
10 |
11 | /*
12 | static NSString *base64_encode(NSString *str){
13 | NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
14 | if(!data){
15 | return nil;
16 | }
17 | return base64_encode_data(data);
18 | }
19 | */
20 |
21 | static NSString *base64_encode_data(NSData *data){
22 | data = [data base64EncodedDataWithOptions:0];
23 | NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
24 | return ret;
25 | }
26 |
27 | static NSData *base64_decode(NSString *str){
28 | NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];
29 | return data;
30 | }
31 |
32 | + (NSData *)stripPublicKeyHeader:(NSData *)d_key{
33 | // Skip ASN.1 public key header
34 | if (d_key == nil) return(nil);
35 |
36 | unsigned long len = [d_key length];
37 | if (!len) return(nil);
38 |
39 | unsigned char *c_key = (unsigned char *)[d_key bytes];
40 | unsigned int idx = 0;
41 |
42 | if (c_key[idx++] != 0x30) return(nil);
43 |
44 | if (c_key[idx] > 0x80) idx += c_key[idx] - 0x80 + 1;
45 | else idx++;
46 |
47 | // PKCS #1 rsaEncryption szOID_RSA_RSA
48 | static unsigned char seqiod[] =
49 | { 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
50 | 0x01, 0x05, 0x00 };
51 | if (memcmp(&c_key[idx], seqiod, 15)) return(nil);
52 |
53 | idx += 15;
54 |
55 | if (c_key[idx++] != 0x03) return(nil);
56 |
57 | if (c_key[idx] > 0x80) idx += c_key[idx] - 0x80 + 1;
58 | else idx++;
59 |
60 | if (c_key[idx++] != '\0') return(nil);
61 |
62 | // Now make a new NSData from this buffer
63 | return([NSData dataWithBytes:&c_key[idx] length:len - idx]);
64 | }
65 |
66 | //credit: http://hg.mozilla.org/services/fx-home/file/tip/Sources/NetworkAndStorage/CryptoUtils.m#l1036
67 | + (NSData *)stripPrivateKeyHeader:(NSData *)d_key{
68 | // Skip ASN.1 private key header
69 | if (d_key == nil) return(nil);
70 |
71 | unsigned long len = [d_key length];
72 | if (!len) return(nil);
73 |
74 | unsigned char *c_key = (unsigned char *)[d_key bytes];
75 | unsigned int idx = 22; //magic byte at offset 22
76 |
77 | if (0x04 != c_key[idx++]) return nil;
78 |
79 | //calculate length of the key
80 | unsigned int c_len = c_key[idx++];
81 | int det = c_len & 0x80;
82 | if (!det) {
83 | c_len = c_len & 0x7f;
84 | } else {
85 | int byteCount = c_len & 0x7f;
86 | if (byteCount + idx > len) {
87 | //rsa length field longer than buffer
88 | return nil;
89 | }
90 | unsigned int accum = 0;
91 | unsigned char *ptr = &c_key[idx];
92 | idx += byteCount;
93 | while (byteCount) {
94 | accum = (accum << 8) + *ptr;
95 | ptr++;
96 | byteCount--;
97 | }
98 | c_len = accum;
99 | }
100 |
101 | // Now make a new NSData from this buffer
102 | return [d_key subdataWithRange:NSMakeRange(idx, c_len)];
103 | }
104 |
105 | + (SecKeyRef)addPublicKey:(NSString *)key{
106 | NSRange spos = [key rangeOfString:@"-----BEGIN PUBLIC KEY-----"];
107 | NSRange epos = [key rangeOfString:@"-----END PUBLIC KEY-----"];
108 | if(spos.location != NSNotFound && epos.location != NSNotFound){
109 | NSUInteger s = spos.location + spos.length;
110 | NSUInteger e = epos.location;
111 | NSRange range = NSMakeRange(s, e-s);
112 | key = [key substringWithRange:range];
113 | }
114 | key = [key stringByReplacingOccurrencesOfString:@"\r" withString:@""];
115 | key = [key stringByReplacingOccurrencesOfString:@"\n" withString:@""];
116 | key = [key stringByReplacingOccurrencesOfString:@"\t" withString:@""];
117 | key = [key stringByReplacingOccurrencesOfString:@" " withString:@""];
118 |
119 | // This will be base64 encoded, decode it.
120 | NSData *data = base64_decode(key);
121 | data = [RSA stripPublicKeyHeader:data];
122 | if(!data){
123 | return nil;
124 | }
125 |
126 | //a tag to read/write keychain storage
127 | NSString *tag = @"RSAUtil_PubKey";
128 | NSData *d_tag = [NSData dataWithBytes:[tag UTF8String] length:[tag length]];
129 |
130 | // Delete any old lingering key with the same tag
131 | NSMutableDictionary *publicKey = [[NSMutableDictionary alloc] init];
132 | [publicKey setObject:(__bridge id) kSecClassKey forKey:(__bridge id)kSecClass];
133 | [publicKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
134 | [publicKey setObject:d_tag forKey:(__bridge id)kSecAttrApplicationTag];
135 | SecItemDelete((__bridge CFDictionaryRef)publicKey);
136 |
137 | // Add persistent version of the key to system keychain
138 | [publicKey setObject:data forKey:(__bridge id)kSecValueData];
139 | [publicKey setObject:(__bridge id) kSecAttrKeyClassPublic forKey:(__bridge id)
140 | kSecAttrKeyClass];
141 | [publicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)
142 | kSecReturnPersistentRef];
143 |
144 | CFTypeRef persistKey = nil;
145 | OSStatus status = SecItemAdd((__bridge CFDictionaryRef)publicKey, &persistKey);
146 | if (persistKey != nil){
147 | CFRelease(persistKey);
148 | }
149 | if ((status != noErr) && (status != errSecDuplicateItem)) {
150 | return nil;
151 | }
152 |
153 | [publicKey removeObjectForKey:(__bridge id)kSecValueData];
154 | [publicKey removeObjectForKey:(__bridge id)kSecReturnPersistentRef];
155 | [publicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef];
156 | [publicKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
157 |
158 | // Now fetch the SecKeyRef version of the key
159 | SecKeyRef keyRef = nil;
160 | status = SecItemCopyMatching((__bridge CFDictionaryRef)publicKey, (CFTypeRef *)&keyRef);
161 | if(status != noErr){
162 | return nil;
163 | }
164 | return keyRef;
165 | }
166 |
167 | + (SecKeyRef)addPrivateKey:(NSString *)key{
168 | NSRange spos;
169 | NSRange epos;
170 | spos = [key rangeOfString:@"-----BEGIN RSA PRIVATE KEY-----"];
171 | if(spos.length > 0){
172 | epos = [key rangeOfString:@"-----END RSA PRIVATE KEY-----"];
173 | }else{
174 | spos = [key rangeOfString:@"-----BEGIN PRIVATE KEY-----"];
175 | epos = [key rangeOfString:@"-----END PRIVATE KEY-----"];
176 | }
177 | if(spos.location != NSNotFound && epos.location != NSNotFound){
178 | NSUInteger s = spos.location + spos.length;
179 | NSUInteger e = epos.location;
180 | NSRange range = NSMakeRange(s, e-s);
181 | key = [key substringWithRange:range];
182 | }
183 | key = [key stringByReplacingOccurrencesOfString:@"\r" withString:@""];
184 | key = [key stringByReplacingOccurrencesOfString:@"\n" withString:@""];
185 | key = [key stringByReplacingOccurrencesOfString:@"\t" withString:@""];
186 | key = [key stringByReplacingOccurrencesOfString:@" " withString:@""];
187 |
188 | // This will be base64 encoded, decode it.
189 | NSData *data = base64_decode(key);
190 | data = [RSA stripPrivateKeyHeader:data];
191 | if(!data){
192 | return nil;
193 | }
194 |
195 | //a tag to read/write keychain storage
196 | NSString *tag = @"RSAUtil_PrivKey";
197 | NSData *d_tag = [NSData dataWithBytes:[tag UTF8String] length:[tag length]];
198 |
199 | // Delete any old lingering key with the same tag
200 | NSMutableDictionary *privateKey = [[NSMutableDictionary alloc] init];
201 | [privateKey setObject:(__bridge id) kSecClassKey forKey:(__bridge id)kSecClass];
202 | [privateKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
203 | [privateKey setObject:d_tag forKey:(__bridge id)kSecAttrApplicationTag];
204 | SecItemDelete((__bridge CFDictionaryRef)privateKey);
205 |
206 | // Add persistent version of the key to system keychain
207 | [privateKey setObject:data forKey:(__bridge id)kSecValueData];
208 | [privateKey setObject:(__bridge id) kSecAttrKeyClassPrivate forKey:(__bridge id)
209 | kSecAttrKeyClass];
210 | [privateKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)
211 | kSecReturnPersistentRef];
212 |
213 | CFTypeRef persistKey = nil;
214 | OSStatus status = SecItemAdd((__bridge CFDictionaryRef)privateKey, &persistKey);
215 | if (persistKey != nil){
216 | CFRelease(persistKey);
217 | }
218 | if ((status != noErr) && (status != errSecDuplicateItem)) {
219 | return nil;
220 | }
221 |
222 | [privateKey removeObjectForKey:(__bridge id)kSecValueData];
223 | [privateKey removeObjectForKey:(__bridge id)kSecReturnPersistentRef];
224 | [privateKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef];
225 | [privateKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
226 |
227 | // Now fetch the SecKeyRef version of the key
228 | SecKeyRef keyRef = nil;
229 | status = SecItemCopyMatching((__bridge CFDictionaryRef)privateKey, (CFTypeRef *)&keyRef);
230 | if(status != noErr){
231 | return nil;
232 | }
233 | return keyRef;
234 | }
235 |
236 | /* START: Encryption & Decryption with RSA private key */
237 |
238 | + (NSData *)encryptData:(NSData *)data withKeyRef:(SecKeyRef) keyRef isSign:(BOOL)isSign {
239 | const uint8_t *srcbuf = (const uint8_t *)[data bytes];
240 | size_t srclen = (size_t)data.length;
241 |
242 | size_t block_size = SecKeyGetBlockSize(keyRef) * sizeof(uint8_t);
243 | void *outbuf = malloc(block_size);
244 | size_t src_block_size = block_size - 11;
245 |
246 | NSMutableData *ret = [[NSMutableData alloc] init];
247 | for(int idx=0; idx src_block_size){
251 | data_len = src_block_size;
252 | }
253 |
254 | size_t outlen = block_size;
255 | OSStatus status = noErr;
256 |
257 | if (isSign) {
258 | status = SecKeyRawSign(keyRef,
259 | kSecPaddingPKCS1,
260 | srcbuf + idx,
261 | data_len,
262 | outbuf,
263 | &outlen
264 | );
265 | } else {
266 | status = SecKeyEncrypt(keyRef,
267 | kSecPaddingPKCS1,
268 | srcbuf + idx,
269 | data_len,
270 | outbuf,
271 | &outlen
272 | );
273 | }
274 | if (status != 0) {
275 | NSLog(@"SecKeyEncrypt fail. Error Code: %d", status);
276 | ret = nil;
277 | break;
278 | }else{
279 | [ret appendBytes:outbuf length:outlen];
280 | }
281 | }
282 |
283 | free(outbuf);
284 | CFRelease(keyRef);
285 | return ret;
286 | }
287 |
288 | + (NSString *)encryptString:(NSString *)str privateKey:(NSString *)privKey{
289 | NSData *data = [RSA encryptData:[str dataUsingEncoding:NSUTF8StringEncoding] privateKey:privKey];
290 | NSString *ret = base64_encode_data(data);
291 | return ret;
292 | }
293 |
294 | + (NSData *)encryptData:(NSData *)data privateKey:(NSString *)privKey{
295 | if(!data || !privKey){
296 | return nil;
297 | }
298 | SecKeyRef keyRef = [RSA addPrivateKey:privKey];
299 | if(!keyRef){
300 | return nil;
301 | }
302 | return [RSA encryptData:data withKeyRef:keyRef isSign:YES];
303 | }
304 |
305 | + (NSData *)decryptData:(NSData *)data withKeyRef:(SecKeyRef) keyRef{
306 | const uint8_t *srcbuf = (const uint8_t *)[data bytes];
307 | size_t srclen = (size_t)data.length;
308 |
309 | size_t block_size = SecKeyGetBlockSize(keyRef) * sizeof(uint8_t);
310 | UInt8 *outbuf = malloc(block_size);
311 | size_t src_block_size = block_size;
312 |
313 | NSMutableData *ret = [[NSMutableData alloc] init];
314 | for(int idx=0; idx src_block_size){
318 | data_len = src_block_size;
319 | }
320 |
321 | size_t outlen = block_size;
322 | OSStatus status = noErr;
323 | status = SecKeyDecrypt(keyRef,
324 | kSecPaddingNone,
325 | srcbuf + idx,
326 | data_len,
327 | outbuf,
328 | &outlen
329 | );
330 | if (status != 0) {
331 | NSLog(@"SecKeyEncrypt fail. Error Code: %d", status);
332 | ret = nil;
333 | break;
334 | }else{
335 | //the actual decrypted data is in the middle, locate it!
336 | int idxFirstZero = -1;
337 | int idxNextZero = (int)outlen;
338 | for ( int i = 0; i < outlen; i++ ) {
339 | if ( outbuf[i] == 0 ) {
340 | if ( idxFirstZero < 0 ) {
341 | idxFirstZero = i;
342 | break;
343 | } else {
344 | // idxNextZero = i;
345 | // break;
346 | }
347 | }
348 | }
349 |
350 | [ret appendBytes:&outbuf[idxFirstZero+1] length:idxNextZero-idxFirstZero-1];
351 | }
352 | }
353 |
354 | free(outbuf);
355 | CFRelease(keyRef);
356 | return ret;
357 | }
358 |
359 |
360 | + (NSString *)decryptString:(NSString *)str privateKey:(NSString *)privKey{
361 | NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];
362 | data = [RSA decryptData:data privateKey:privKey];
363 | NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
364 | return ret;
365 | }
366 |
367 | + (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey{
368 | if(!data || !privKey){
369 | return nil;
370 | }
371 | SecKeyRef keyRef = [RSA addPrivateKey:privKey];
372 | if(!keyRef){
373 | return nil;
374 | }
375 | return [RSA decryptData:data withKeyRef:keyRef];
376 | }
377 |
378 | /* END: Encryption & Decryption with RSA private key */
379 |
380 | /* START: Encryption & Decryption with RSA public key */
381 |
382 | + (NSString *)encryptString:(NSString *)str publicKey:(NSString *)pubKey{
383 | NSData *data = [RSA encryptData:[str dataUsingEncoding:NSUTF8StringEncoding] publicKey:pubKey];
384 | NSString *ret = base64_encode_data(data);
385 | return ret;
386 | }
387 |
388 | + (NSData *)encryptData:(NSData *)data publicKey:(NSString *)pubKey{
389 | if(!data || !pubKey){
390 | return nil;
391 | }
392 | SecKeyRef keyRef = [RSA addPublicKey:pubKey];
393 | if(!keyRef){
394 | return nil;
395 | }
396 | return [RSA encryptData:data withKeyRef:keyRef isSign:NO];
397 | }
398 |
399 | + (NSString *)decryptString:(NSString *)str publicKey:(NSString *)pubKey{
400 | NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];
401 | data = [RSA decryptData:data publicKey:pubKey];
402 | NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
403 | return ret;
404 | }
405 |
406 | + (NSData *)decryptData:(NSData *)data publicKey:(NSString *)pubKey{
407 | if(!data || !pubKey){
408 | return nil;
409 | }
410 | SecKeyRef keyRef = [RSA addPublicKey:pubKey];
411 | if(!keyRef){
412 | return nil;
413 | }
414 | return [RSA decryptData:data withKeyRef:keyRef];
415 | }
416 |
417 | /* END: Encryption & Decryption with RSA public key */
418 |
419 | @end
420 |
--------------------------------------------------------------------------------
/YKBLock/plugin/ENCTool/SCLAlertView/UIImage+ImageEffects.m:
--------------------------------------------------------------------------------
1 | /*
2 | File: UIImage+ImageEffects.m
3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
4 | Version: 1.0
5 |
6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
7 | Inc. ("Apple") in consideration of your agreement to the following
8 | terms, and your use, installation, modification or redistribution of
9 | this Apple software constitutes acceptance of these terms. If you do
10 | not agree with these terms, please do not use, install, modify or
11 | redistribute this Apple software.
12 |
13 | In consideration of your agreement to abide by the following terms, and
14 | subject to these terms, Apple grants you a personal, non-exclusive
15 | license, under Apple's copyrights in this original Apple software (the
16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple
17 | Software, with or without modifications, in source and/or binary forms;
18 | provided that if you redistribute the Apple Software in its entirety and
19 | without modifications, you must retain this notice and the following
20 | text and disclaimers in all such redistributions of the Apple Software.
21 | Neither the name, trademarks, service marks or logos of Apple Inc. may
22 | be used to endorse or promote products derived from the Apple Software
23 | without specific prior written permission from Apple. Except as
24 | expressly stated in this notice, no other rights or licenses, express or
25 | implied, are granted by Apple herein, including but not limited to any
26 | patent rights that may be infringed by your derivative works or by other
27 | works in which the Apple Software may be incorporated.
28 |
29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE
30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34 |
35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42 | POSSIBILITY OF SUCH DAMAGE.
43 |
44 | Copyright (C) 2013 Apple Inc. All Rights Reserved.
45 |
46 |
47 | Copyright © 2013 Apple Inc. All rights reserved.
48 | WWDC 2013 License
49 |
50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013
51 | Session. Please refer to the applicable WWDC 2013 Session for further
52 | information.
53 |
54 | IMPORTANT: This Apple software is supplied to you by Apple Inc.
55 | ("Apple") in consideration of your agreement to the following terms, and
56 | your use, installation, modification or redistribution of this Apple
57 | software constitutes acceptance of these terms. If you do not agree with
58 | these terms, please do not use, install, modify or redistribute this
59 | Apple software.
60 |
61 | In consideration of your agreement to abide by the following terms, and
62 | subject to these terms, Apple grants you a non-exclusive license, under
63 | Apple's copyrights in this original Apple software (the "Apple
64 | Software"), to use, reproduce, modify and redistribute the Apple
65 | Software, with or without modifications, in source and/or binary forms;
66 | provided that if you redistribute the Apple Software in its entirety and
67 | without modifications, you must retain this notice and the following
68 | text and disclaimers in all such redistributions of the Apple Software.
69 | Neither the name, trademarks, service marks or logos of Apple Inc. may
70 | be used to endorse or promote products derived from the Apple Software
71 | without specific prior written permission from Apple. Except as
72 | expressly stated in this notice, no other rights or licenses, express or
73 | implied, are granted by Apple herein, including but not limited to any
74 | patent rights that may be infringed by your derivative works or by other
75 | works in which the Apple Software may be incorporated.
76 |
77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES
78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE
79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR
80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
82 |
83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
90 | POSSIBILITY OF SUCH DAMAGE.
91 |
92 | EA1002
93 | 5/3/2013
94 | */
95 |
96 | #import "UIImage+ImageEffects.h"
97 | #import "SCLMacros.h"
98 |
99 | #if defined(__has_feature) && __has_feature(modules)
100 | @import Accelerate;
101 | #else
102 | #import
103 | #endif
104 | #import
105 |
106 |
107 | @implementation UIImage (ImageEffects)
108 |
109 |
110 | - (UIImage *)applyLightEffect
111 | {
112 | UIColor *tintColor = [UIColor colorWithWhite:1.0 alpha:0.3];
113 | return [self applyBlurWithRadius:30 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
114 | }
115 |
116 |
117 | - (UIImage *)applyExtraLightEffect
118 | {
119 | UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.82];
120 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
121 | }
122 |
123 |
124 | - (UIImage *)applyDarkEffect
125 | {
126 | UIColor *tintColor = [UIColor colorWithWhite:0.11 alpha:0.73];
127 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil];
128 | }
129 |
130 |
131 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor
132 | {
133 | const CGFloat EffectColorAlpha = 0.6;
134 | UIColor *effectColor = tintColor;
135 | NSUInteger componentCount = CGColorGetNumberOfComponents(tintColor.CGColor);
136 | if (componentCount == 2) {
137 | CGFloat b;
138 | if ([tintColor getWhite:&b alpha:NULL]) {
139 | effectColor = [UIColor colorWithWhite:b alpha:EffectColorAlpha];
140 | }
141 | }
142 | else {
143 | CGFloat r, g, b;
144 | if ([tintColor getRed:&r green:&g blue:&b alpha:NULL]) {
145 | effectColor = [UIColor colorWithRed:r green:g blue:b alpha:EffectColorAlpha];
146 | }
147 | }
148 | return [self applyBlurWithRadius:10 tintColor:effectColor saturationDeltaFactor:-1.0 maskImage:nil];
149 | }
150 |
151 |
152 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage
153 | {
154 | // Check pre-conditions.
155 | if (self.size.width < 1 || self.size.height < 1) {
156 | NSLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", self.size.width, self.size.height, self);
157 | return nil;
158 | }
159 | if (!self.CGImage) {
160 | NSLog (@"*** error: image must be backed by a CGImage: %@", self);
161 | return nil;
162 | }
163 | if (maskImage && !maskImage.CGImage) {
164 | NSLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage);
165 | return nil;
166 | }
167 |
168 | CGRect imageRect = { CGPointZero, self.size };
169 | UIImage *effectImage = self;
170 |
171 | BOOL hasBlur = blurRadius > __FLT_EPSILON__;
172 | BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__;
173 | if (hasBlur || hasSaturationChange) {
174 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]);
175 | CGContextRef effectInContext = UIGraphicsGetCurrentContext();
176 | CGContextScaleCTM(effectInContext, 1.0, -1.0);
177 | CGContextTranslateCTM(effectInContext, 0, -self.size.height);
178 | CGContextDrawImage(effectInContext, imageRect, self.CGImage);
179 |
180 | vImage_Buffer effectInBuffer;
181 | effectInBuffer.data = CGBitmapContextGetData(effectInContext);
182 | effectInBuffer.width = CGBitmapContextGetWidth(effectInContext);
183 | effectInBuffer.height = CGBitmapContextGetHeight(effectInContext);
184 | effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext);
185 |
186 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]);
187 | CGContextRef effectOutContext = UIGraphicsGetCurrentContext();
188 | vImage_Buffer effectOutBuffer;
189 | effectOutBuffer.data = CGBitmapContextGetData(effectOutContext);
190 | effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext);
191 | effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext);
192 | effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext);
193 |
194 | if (hasBlur) {
195 | // A description of how to compute the box kernel width from the Gaussian
196 | // radius (aka standard deviation) appears in the SVG spec:
197 | // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
198 | //
199 | // For larger values of 's' (s >= 2.0), an approximation can be used: Three
200 | // successive box-blurs build a piece-wise quadratic convolution kernel, which
201 | // approximates the Gaussian kernel to within roughly 3%.
202 | //
203 | // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
204 | //
205 | // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel.
206 | //
207 | CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale];
208 | uint32_t radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5);
209 | if (radius % 2 != 1) {
210 | radius += 1; // force radius to be odd so that the three box-blur methodology works.
211 | }
212 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend);
213 | vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend);
214 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend);
215 | }
216 | BOOL effectImageBuffersAreSwapped = NO;
217 | if (hasSaturationChange) {
218 | CGFloat s = saturationDeltaFactor;
219 | CGFloat floatingPointSaturationMatrix[] = {
220 | 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0,
221 | 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0,
222 | 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0,
223 | 0, 0, 0, 1,
224 | };
225 | const int32_t divisor = 256;
226 | NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]);
227 | int16_t saturationMatrix[matrixSize];
228 | for (NSUInteger i = 0; i < matrixSize; ++i) {
229 | saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor);
230 | }
231 | if (hasBlur) {
232 | vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
233 | effectImageBuffersAreSwapped = YES;
234 | }
235 | else {
236 | vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
237 | }
238 | }
239 | if (!effectImageBuffersAreSwapped)
240 | effectImage = UIGraphicsGetImageFromCurrentImageContext();
241 | UIGraphicsEndImageContext();
242 |
243 | if (effectImageBuffersAreSwapped)
244 | effectImage = UIGraphicsGetImageFromCurrentImageContext();
245 | UIGraphicsEndImageContext();
246 | }
247 |
248 | // Set up output context.
249 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]);
250 | CGContextRef outputContext = UIGraphicsGetCurrentContext();
251 | CGContextScaleCTM(outputContext, 1.0, -1.0);
252 | CGContextTranslateCTM(outputContext, 0, -self.size.height);
253 |
254 | // Draw base image.
255 | CGContextDrawImage(outputContext, imageRect, self.CGImage);
256 |
257 | // Draw effect image.
258 | if (hasBlur) {
259 | CGContextSaveGState(outputContext);
260 | if (maskImage) {
261 | CGContextClipToMask(outputContext, imageRect, maskImage.CGImage);
262 | }
263 | CGContextDrawImage(outputContext, imageRect, effectImage.CGImage);
264 | CGContextRestoreGState(outputContext);
265 | }
266 |
267 | // Add in color tint.
268 | if (tintColor) {
269 | CGContextSaveGState(outputContext);
270 | CGContextSetFillColorWithColor(outputContext, tintColor.CGColor);
271 | CGContextFillRect(outputContext, imageRect);
272 | CGContextRestoreGState(outputContext);
273 | }
274 |
275 | // Output image is ready.
276 | UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
277 | UIGraphicsEndImageContext();
278 |
279 | return outputImage;
280 | }
281 |
282 | + (UIImage *)imageWithColor:(UIColor *)color
283 | {
284 | CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
285 | UIGraphicsBeginImageContext(rect.size);
286 | CGContextRef context = UIGraphicsGetCurrentContext();
287 |
288 | CGContextSetFillColorWithColor(context, [color CGColor]);
289 | CGContextFillRect(context, rect);
290 |
291 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
292 | UIGraphicsEndImageContext();
293 |
294 | return image;
295 | }
296 |
297 | + (UIImage *)convertViewToImage
298 | {
299 | UIWindow *keyWindow = [[UIApplication sharedApplication]keyWindow];
300 | CGRect rect = [keyWindow bounds];
301 | UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
302 | CGContextRef context = UIGraphicsGetCurrentContext();
303 | [keyWindow.layer renderInContext:context];
304 | UIImage *capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
305 | UIGraphicsEndImageContext();
306 |
307 | return capturedScreen;
308 | }
309 |
310 | + (UIImage *)convertViewToImage:(UIView *)view
311 | {
312 | CGFloat scale = [UIScreen mainScreen].scale;
313 | UIImage *capturedScreen;
314 |
315 | //Optimized/fast method for rendering a UIView as image on iOS 7 and later versions.
316 | UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, scale);
317 | [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
318 | capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
319 | UIGraphicsEndImageContext();
320 |
321 | return capturedScreen;
322 | }
323 |
324 | @end
325 |
--------------------------------------------------------------------------------
/YKBLock/plugin/AFNetworking/AFHTTPSessionManager.m:
--------------------------------------------------------------------------------
1 | #import "AFHTTPSessionManager.h"
2 | #import "AFURLRequestSerialization.h"
3 | #import "AFURLResponseSerialization.h"
4 | #import
5 | #import
6 | #import
7 | #import
8 | #import
9 | #import
10 | #import
11 | #import
12 |
13 | #if TARGET_OS_IOS || TARGET_OS_TV
14 | #import
15 | #elif TARGET_OS_WATCH
16 | #import
17 | #endif
18 |
19 | @interface AFHTTPSessionManager ()
20 | @property (readwrite, nonatomic, strong) NSURL *baseURL;
21 | @end
22 |
23 | @implementation AFHTTPSessionManager
24 | @dynamic responseSerializer;
25 |
26 | + (instancetype)__attribute__((optnone))manager {
27 | return [[[self class] alloc] initWithBaseURL:nil];
28 | }
29 |
30 | - (instancetype)__attribute__((optnone))init {
31 | return [self initWithBaseURL:nil];
32 | }
33 |
34 | - (instancetype)__attribute__((optnone))initWithBaseURL:(NSURL *)url {
35 | return [self initWithBaseURL:url sessionConfiguration:nil];
36 | }
37 |
38 | - (instancetype)__attribute__((optnone))initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration {
39 | return [self initWithBaseURL:nil sessionConfiguration:configuration];
40 | }
41 |
42 | - (instancetype)__attribute__((optnone))initWithBaseURL:(NSURL *)url
43 | sessionConfiguration:(NSURLSessionConfiguration *)configuration
44 | {
45 | self = [super initWithSessionConfiguration:configuration];
46 | if (!self) {
47 | return nil;
48 | }
49 |
50 | // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected
51 | if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) {
52 | url = [url URLByAppendingPathComponent:@""];
53 | }
54 |
55 | self.baseURL = url;
56 |
57 | self.requestSerializer = [AFHTTPRequestSerializer serializer];
58 | self.responseSerializer = [AFJSONResponseSerializer serializer];
59 |
60 | return self;
61 | }
62 |
63 | #pragma mark -
64 |
65 | - (void)__attribute__((optnone))setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer {
66 | NSParameterAssert(requestSerializer);
67 |
68 | _requestSerializer = requestSerializer;
69 | }
70 |
71 | - (void)__attribute__((optnone))setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer {
72 | NSParameterAssert(responseSerializer);
73 |
74 | [super setResponseSerializer:responseSerializer];
75 | }
76 |
77 | @dynamic securityPolicy;
78 |
79 | - (void)__attribute__((optnone))setSecurityPolicy:(AFSecurityPolicy *)securityPolicy {
80 | if (securityPolicy.SSLPinningMode != AFSSLPinningModeNone && ![self.baseURL.scheme isEqualToString:@"https"]) {
81 | NSString *pinningMode = @"Unknown Pinning Mode";
82 | switch (securityPolicy.SSLPinningMode) {
83 | case AFSSLPinningModeNone: pinningMode = @"AFSSLPinningModeNone"; break;
84 | case AFSSLPinningModeCertificate: pinningMode = @"AFSSLPinningModeCertificate"; break;
85 | case AFSSLPinningModePublicKey: pinningMode = @"AFSSLPinningModePublicKey"; break;
86 | }
87 | NSString *reason = [NSString stringWithFormat:@"A security policy configured with `%@` can only be applied on a manager with a secure base URL (i.e. https)", pinningMode];
88 | @throw [NSException exceptionWithName:@"Invalid Security Policy" reason:reason userInfo:nil];
89 | }
90 |
91 | [super setSecurityPolicy:securityPolicy];
92 | }
93 |
94 | #pragma mark -
95 |
96 | - (NSURLSessionDataTask *)__attribute__((optnone))GET:(NSString *)URLString
97 | parameters:(id)parameters
98 | success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
99 | failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
100 | {
101 |
102 | return [self GET:URLString parameters:parameters progress:nil success:success failure:failure];
103 | }
104 |
105 | - (NSURLSessionDataTask *)__attribute__((optnone))GET:(NSString *)URLString
106 | parameters:(id)parameters
107 | progress:(void (^)(NSProgress * _Nonnull))downloadProgress
108 | success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
109 | failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
110 | {
111 |
112 | NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET"
113 | URLString:URLString
114 | parameters:parameters
115 | uploadProgress:nil
116 | downloadProgress:downloadProgress
117 | success:success
118 | failure:failure];
119 |
120 | [dataTask resume];
121 |
122 | return dataTask;
123 | }
124 |
125 | - (NSURLSessionDataTask *)__attribute__((optnone))HEAD:(NSString *)URLString
126 | parameters:(id)parameters
127 | success:(void (^)(NSURLSessionDataTask *task))success
128 | failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
129 | {
130 | NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) {
131 | if (success) {
132 | success(task);
133 | }
134 | } failure:failure];
135 |
136 | [dataTask resume];
137 |
138 | return dataTask;
139 | }
140 |
141 | - (NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
142 | parameters:(id)parameters
143 | success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
144 | failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
145 | {
146 | return [self POST:URLString parameters:parameters progress:nil success:success failure:failure];
147 | }
148 |
149 | - (NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
150 | parameters:(id)parameters
151 | progress:(void (^)(NSProgress * _Nonnull))uploadProgress
152 | success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
153 | failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
154 | {
155 | NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure];
156 |
157 | [dataTask resume];
158 |
159 | return dataTask;
160 | }
161 |
162 | - (NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
163 | parameters:(nullable id)parameters
164 | constructingBodyWithBlock:(nullable void (^)(id _Nonnull))block
165 | success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success
166 | failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure
167 | {
168 | return [self POST:URLString parameters:parameters constructingBodyWithBlock:block progress:nil success:success failure:failure];
169 | }
170 |
171 | - (NSURLSessionDataTask *)__attribute__((optnone))POST:(NSString *)URLString
172 | parameters:(id)parameters
173 | constructingBodyWithBlock:(void (^)(id formData))block
174 | progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress
175 | success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
176 | failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
177 | {
178 | NSError *serializationError = nil;
179 | NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError];
180 | if (serializationError) {
181 | if (failure) {
182 | dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
183 | failure(nil, serializationError);
184 | });
185 | }
186 |
187 | return nil;
188 | }
189 |
190 | __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
191 | if (error) {
192 | if (failure) {
193 | failure(task, error);
194 | }
195 | } else {
196 | if (success) {
197 | success(task, responseObject);
198 | }
199 | }
200 | }];
201 |
202 | [task resume];
203 |
204 | return task;
205 | }
206 |
207 | - (NSURLSessionDataTask *)__attribute__((optnone))PUT:(NSString *)URLString
208 | parameters:(id)parameters
209 | success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
210 | failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
211 | {
212 | NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
213 |
214 | [dataTask resume];
215 |
216 | return dataTask;
217 | }
218 |
219 | - (NSURLSessionDataTask *)__attribute__((optnone))PATCH:(NSString *)URLString
220 | parameters:(id)parameters
221 | success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
222 | failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
223 | {
224 | NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
225 |
226 | [dataTask resume];
227 |
228 | return dataTask;
229 | }
230 |
231 | - (NSURLSessionDataTask *)__attribute__((optnone))DELETE:(NSString *)URLString
232 | parameters:(id)parameters
233 | success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
234 | failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure
235 | {
236 | NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure];
237 |
238 | [dataTask resume];
239 |
240 | return dataTask;
241 | }
242 |
243 | - (NSURLSessionDataTask *)__attribute__((optnone))dataTaskWithHTTPMethod:(NSString *)method
244 | URLString:(NSString *)URLString
245 | parameters:(id)parameters
246 | uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress
247 | downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress
248 | success:(void (^)(NSURLSessionDataTask *, id))success
249 | failure:(void (^)(NSURLSessionDataTask *, NSError *))failure
250 | {
251 | NSError *serializationError = nil;
252 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];
253 | if (serializationError) {
254 | if (failure) {
255 | dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{
256 | failure(nil, serializationError);
257 | });
258 | }
259 |
260 | return nil;
261 | }
262 |
263 | __block NSURLSessionDataTask *dataTask = nil;
264 | dataTask = [self dataTaskWithRequest:request
265 | uploadProgress:uploadProgress
266 | downloadProgress:downloadProgress
267 | completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
268 | if (error) {
269 | if (failure) {
270 | failure(dataTask, error);
271 | }
272 | } else {
273 | if (success) {
274 | success(dataTask, responseObject);
275 | }
276 | }
277 | }];
278 |
279 | return dataTask;
280 | }
281 |
282 | #pragma mark - NSObject
283 |
284 | - (NSString *)__attribute__((optnone))description {
285 | return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue];
286 | }
287 |
288 | #pragma mark - NSSecureCoding
289 |
290 | + (BOOL)__attribute__((optnone))supportsSecureCoding {
291 | return YES;
292 | }
293 |
294 | - (instancetype)__attribute__((optnone))initWithCoder:(NSCoder *)decoder {
295 | NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))];
296 | NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"];
297 | if (!configuration) {
298 | NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"];
299 | if (configurationIdentifier) {
300 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100)
301 | configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier];
302 | #else
303 | configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier];
304 | #endif
305 | }
306 | }
307 |
308 | self = [self initWithBaseURL:baseURL sessionConfiguration:configuration];
309 | if (!self) {
310 | return nil;
311 | }
312 |
313 | self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))];
314 | self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))];
315 | AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))];
316 | if (decodedPolicy) {
317 | self.securityPolicy = decodedPolicy;
318 | }
319 |
320 | return self;
321 | }
322 |
323 | - (void)__attribute__((optnone))encodeWithCoder:(NSCoder *)coder {
324 | [super encodeWithCoder:coder];
325 |
326 | [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))];
327 | if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) {
328 | [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"];
329 | } else {
330 | [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"];
331 | }
332 | [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))];
333 | [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))];
334 | [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))];
335 | }
336 |
337 | #pragma mark - NSCopying
338 |
339 | - (instancetype)__attribute__((optnone))copyWithZone:(NSZone *)zone {
340 | AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration];
341 |
342 | HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone];
343 | HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone];
344 | HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone];
345 | return HTTPClient;
346 | }
347 |
348 | @end
349 |
--------------------------------------------------------------------------------