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

Commit

Permalink
More OpenSSL/AES
Browse files Browse the repository at this point in the history
  • Loading branch information
Naville committed Feb 23, 2016
1 parent b7c3c1d commit 1ca07fe
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 458 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ CompileDefines.xm
theos/
.theos/
.DS_Store
*.deb
33 changes: 30 additions & 3 deletions Hooks/SDKHooks/OpenSSLAES.xm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "../SharedDefine.pch"
#import "string.h"
# define AES_ENCRYPT 1
# define AES_DECRYPT 0

Expand All @@ -22,17 +23,43 @@ typedef struct aes_key_st AES_KEY;

int (*old_AES_set_encrypt_key)(const unsigned char *userKey, const int bits,
AES_KEY *key);
int (*old_AES_set_decrypt_key)(const unsigned char *userKey, const int bits,
AES_KEY *key);
void (*old_AES_ecb_encrypt)(const unsigned char *in, unsigned char *out,
const AES_KEY *key, const int enc);
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,AES_KEY *key){
NSData* Keydata=[NSData dataWithBytes:userKey length:bits];
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"OpenSSL/AES" andMethod:@"AES_set_encrypt_key"];
[tracer addArgFromPlistObject:Keydata withKey:@"Key"];
[Keydata release];
[tracer addArgFromPlistObject:[NSData dataWithBytes:userKey length:bits] withKey:@"Key"];
[traceStorage saveTracedCall: tracer];
[tracer release];
return old_AES_set_encrypt_key(userKey,bits,key);//Call Original


}
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,AES_KEY *key){
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"OpenSSL/AES" andMethod:@"AES_set_decrypt_key"];
[tracer addArgFromPlistObject:[NSData dataWithBytes:userKey length:bits] withKey:@"Key"];
[traceStorage saveTracedCall: tracer];
[tracer release];
return old_AES_set_decrypt_key(userKey,bits,key);//Call Original


}
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key, const int enc){
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"OpenSSL/AES" andMethod:@"AES_ecb_encrypt"];
[tracer addArgFromPlistObject:[NSData dataWithBytes:in length:enc] withKey:@"InputData"];
old_AES_ecb_encrypt(in,out,key,enc);//Call Original
[tracer addArgFromPlistObject:[NSData dataWithBytes:out length:enc] withKey:@"OutputData"];
[traceStorage saveTracedCall: tracer];
[tracer release];

}
extern void init_OpenSSLAES_hook() {
MSHookFunction(((void*)MSFindSymbol(NULL, "_AES_set_encrypt_key")),(void*)AES_set_encrypt_key, (void**)&old_AES_set_encrypt_key);
MSHookFunction(((void*)MSFindSymbol(NULL, "_AES_set_decrypt_key")),(void*)AES_set_decrypt_key, (void**)&old_AES_set_decrypt_key);
MSHookFunction(((void*)MSFindSymbol(NULL, "_AES_ecb_encrypt")),(void*)AES_ecb_encrypt, (void**)&old_AES_ecb_encrypt);
#ifdef PROTOTYPE

#endif
}
9 changes: 0 additions & 9 deletions Hooks/SDKHooks/OpenSSLUnimplemented/aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,10 @@ struct aes_key_st {
typedef struct aes_key_st AES_KEY;

const char *AES_options(void);

int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
AES_KEY *key);
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
AES_KEY *key);

void AES_encrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key);
void AES_decrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key);

void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key, const int enc);
void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
size_t length, const AES_KEY *key,
unsigned char *ivec, const int enc);
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export CFLAGS=-Wp,"-DWTFJHTWEAKNAME=@\"HMD7CP87LA6Q6V2\",-DPROTOTYPE"
export CFLAGS=-Wp,"-DWTFJHTWEAKNAME=@\"D1Z4121CQR03M3R\""
include theos/makefiles/common.mk
export ARCHS = armv7 armv7s arm64
export TARGET = iphone:clang:7.0:7.0
TWEAK_NAME = HMD7CP87LA6Q6V2
HMD7CP87LA6Q6V2_FILES = Tweak.xm CompileDefines.xm Hooks/APIHooks/CommonCryptor.xm Hooks/APIHooks/CommonDigest.xm Hooks/APIHooks/CommonHMAC.xm Hooks/APIHooks/CommonKeyDerivation.xm Hooks/APIHooks/CoreTelephony.xm Hooks/APIHooks/dlfcn.xm Hooks/APIHooks/Keychain.xm Hooks/APIHooks/libC.xm Hooks/APIHooks/libMobileGestalt.xm Hooks/APIHooks/NSData.xm Hooks/APIHooks/NSFileHandle.xm Hooks/APIHooks/NSFileManager.xm Hooks/APIHooks/NSHTTPCookie.xm Hooks/APIHooks/NSInputStream.xm Hooks/APIHooks/NSKeyedArchiver.xm Hooks/APIHooks/NSKeyedUnarchiver.xm Hooks/APIHooks/NSOutputStream.xm Hooks/APIHooks/NSURLConnection.xm Hooks/APIHooks/NSURLCredential.xm Hooks/APIHooks/NSURLSession.xm Hooks/APIHooks/NSUserDefaults.xm Hooks/APIHooks/NSXMLParser.xm Hooks/APIHooks/Security.xm Hooks/APIHooks/SSLKillSwitch.xm Hooks/APIHooks/UIPasteboard.xm Hooks/SDKHooks/FclBlowfish.xm Hooks/SDKHooks/OpenSSLAES.xm Hooks/SDKHooks/OpenSSLBlowFish.xm Hooks/SDKHooks/OpenSSLMD5.xm Hooks/SDKHooks/OpenSSLSHA1.xm Hooks/SDKHooks/OpenSSLSHA512.xm Hooks/Utils/CallStackInspector.m Hooks/Utils/CallTracer.m Hooks/Utils/DelegateProxies.m Hooks/Utils/NSURLConnectionDelegateProx.m Hooks/Utils/NSURLSessionDelegateProxy.m Hooks/Utils/PlistObjectConverter.m Hooks/Utils/RuntimeUtils.m Hooks/Utils/SQLiteStorage.m Hooks/Utils/Utils.m
TWEAK_NAME = D1Z4121CQR03M3R
D1Z4121CQR03M3R_FILES = Tweak.xm CompileDefines.xm Hooks/APIHooks/CommonCryptor.xm Hooks/APIHooks/CommonDigest.xm Hooks/APIHooks/CommonHMAC.xm Hooks/APIHooks/CommonKeyDerivation.xm Hooks/APIHooks/CoreTelephony.xm Hooks/APIHooks/dlfcn.xm Hooks/APIHooks/Keychain.xm Hooks/APIHooks/libC.xm Hooks/APIHooks/libMobileGestalt.xm Hooks/APIHooks/NSData.xm Hooks/APIHooks/NSFileHandle.xm Hooks/APIHooks/NSFileManager.xm Hooks/APIHooks/NSHTTPCookie.xm Hooks/APIHooks/NSInputStream.xm Hooks/APIHooks/NSKeyedArchiver.xm Hooks/APIHooks/NSKeyedUnarchiver.xm Hooks/APIHooks/NSOutputStream.xm Hooks/APIHooks/NSURLConnection.xm Hooks/APIHooks/NSURLCredential.xm Hooks/APIHooks/NSURLSession.xm Hooks/APIHooks/NSUserDefaults.xm Hooks/APIHooks/NSXMLParser.xm Hooks/APIHooks/Security.xm Hooks/APIHooks/SSLKillSwitch.xm Hooks/APIHooks/UIPasteboard.xm Hooks/SDKHooks/FclBlowfish.xm Hooks/SDKHooks/OpenSSLAES.xm Hooks/SDKHooks/OpenSSLBlowFish.xm Hooks/SDKHooks/OpenSSLMD5.xm Hooks/SDKHooks/OpenSSLSHA1.xm Hooks/SDKHooks/OpenSSLSHA512.xm Hooks/Utils/CallStackInspector.m Hooks/Utils/CallTracer.m Hooks/Utils/DelegateProxies.m Hooks/Utils/NSURLConnectionDelegateProx.m Hooks/Utils/NSURLSessionDelegateProxy.m Hooks/Utils/PlistObjectConverter.m Hooks/Utils/RuntimeUtils.m Hooks/Utils/SQLiteStorage.m Hooks/Utils/Utils.m
ADDITIONAL_CCFLAGS = -Qunused-arguments
ADDITIONAL_LDFLAGS = -Wl,-segalign,4000,-sectcreate,WTFJH,SIGDB,./SignatureDatabase.plist
HMD7CP87LA6Q6V2_LIBRARIES = sqlite3 substrate
HMD7CP87LA6Q6V2_FRAMEWORKS = Foundation UIKit Security
D1Z4121CQR03M3R_LIBRARIES = sqlite3 substrate
D1Z4121CQR03M3R_FRAMEWORKS = Foundation UIKit Security
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
235
238
Loading

0 comments on commit 1ca07fe

Please sign in to comment.