Skip to content

Commit

Permalink
Refactor project structure (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
sledgeh4w authored Apr 22, 2024
1 parent d2c63e0 commit 85fa04e
Show file tree
Hide file tree
Showing 16 changed files with 960 additions and 1,022 deletions.
41 changes: 20 additions & 21 deletions examples/example_ios_ali_vmp_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import os
import uuid

from chomper.core import Chomper
from chomper.const import OS_IOS
from chomper.os.ios.options import IosOptions
from chomper import Chomper
from chomper.const import ARCH_ARM64, OS_IOS

base_path = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -18,14 +17,14 @@


def create_emulator():
options = IosOptions(enable_objc=True, enable_ui_kit=True)
emu = Chomper(
return Chomper(
arch=ARCH_ARM64,
os_type=OS_IOS,
logger=logger,
rootfs_path=os.path.join(base_path, "ios/rootfs"),
os_options=options,
enable_objc=True,
enable_ui_kit=True,
)
return emu


def objc_get_class(emu, class_name):
Expand All @@ -36,7 +35,7 @@ def objc_sel_register_name(emu, sel_name):
return emu.call_symbol("_sel_registerName", emu.create_string(sel_name))


def create_ns_string(emu, s):
def objc_create_ns_string(emu, s):
ns_string_class = objc_get_class(emu, "NSString")
string_with_utf8_string_sel = objc_sel_register_name(emu, "stringWithUTF8String:")
obj = emu.call_symbol(
Expand All @@ -48,7 +47,7 @@ def create_ns_string(emu, s):
return obj


def read_ns_string(emu, obj):
def objc_read_ns_string(emu, obj):
c_string_using_encoding_sel = objc_sel_register_name(emu, "cStringUsingEncoding:")
ptr = emu.call_symbol("_objc_msgSend", obj, c_string_using_encoding_sel, 4)
return emu.read_string(ptr)
Expand All @@ -70,24 +69,24 @@ def hook_ns_bundle(emu):
dictionary_with_object_for_key_sel = objc_sel_register_name(emu, "dictionaryWithObject:forKey:")
add_object_for_key_sel = objc_sel_register_name(emu, "addObject:forKey:")

bundle_identifier = create_ns_string(emu, "com.ceair.b2m")
executable_path = create_ns_string(emu, f"/var/containers/Bundle/Application"
bundle_identifier = objc_create_ns_string(emu, "com.ceair.b2m")
executable_path = objc_create_ns_string(emu, f"/var/containers/Bundle/Application"
f"/{uuid.uuid4()}/com.ceair.b2m/ceair_iOS_branch")

bundle_info_directory = emu.call_symbol(
"_objc_msgSend",
ns_mutable_dictionary_cls,
dictionary_with_object_for_key_sel,
create_ns_string(emu, "9.4.7"),
create_ns_string(emu, "CFBundleShortVersionString"),
objc_create_ns_string(emu, "9.4.7"),
objc_create_ns_string(emu, "CFBundleShortVersionString"),
)

emu.call_symbol(
"_objc_msgSend",
bundle_info_directory,
add_object_for_key_sel,
executable_path,
create_ns_string(emu, "CFBundleExecutable"),
objc_create_ns_string(emu, "CFBundleExecutable"),
)

emu.add_interceptor("-[NSBundle initWithPath:]", hook_pass)
Expand All @@ -104,16 +103,16 @@ def hook_ns_locale(emu):
"_objc_msgSend",
ns_array_cls,
array_with_object_sel,
create_ns_string(emu, "zh-cn"),
objc_create_ns_string(emu, "zh-cn"),
)

emu.add_interceptor("+[NSLocale preferredLanguages]", hook_retval(preferred_languages))


def hook_ui_device(emu):
system_version = create_ns_string(emu, "14.4.0")
device_name = create_ns_string(emu, "iPhone")
device_model = create_ns_string(emu, "iPhone13,1")
system_version = objc_create_ns_string(emu, "14.4.0")
device_name = objc_create_ns_string(emu, "iPhone")
device_model = objc_create_ns_string(emu, "iPhone13,1")

emu.add_interceptor("-[UIDevice systemVersion]", hook_retval(system_version))
emu.add_interceptor("-[UIDevice name]", hook_retval(device_name))
Expand All @@ -140,15 +139,15 @@ def main():

ali_tiger_tally_instance = emu.call_symbol("_objc_msgSend", ali_tiger_tally_class, shared_instance_sel)

app_key = create_ns_string(emu, "xPEj7uv0KuziQnXUyPIBNUjnDvvHuW09VOYFuLYBcY-jV6fgqmfy5B1y75_iSuRM5U2zNq7MRoR9N1F-UthTEgv-QBWk68gr95BrAySzWuDzt08FrkeBZWQCGyZ0iAybalYLOJEF7nkKBtmDGLewcw==",)
app_key = objc_create_ns_string(emu, "xPEj7uv0KuziQnXUyPIBNUjnDvvHuW09VOYFuLYBcY-jV6fgqmfy5B1y75_iSuRM5U2zNq7MRoR9N1F-UthTEgv-QBWk68gr95BrAySzWuDzt08FrkeBZWQCGyZ0iAybalYLOJEF7nkKBtmDGLewcw==", )
emu.call_symbol("_objc_msgSend", ali_tiger_tally_instance, initialize_sel, app_key)

encrypt_str = create_ns_string(emu, '{"biClassId":["2","3","4"]}')
encrypt_str = objc_create_ns_string(emu, '{"biClassId":["2","3","4"]}')
encrypt_bytes = emu.call_symbol("_objc_msgSend", encrypt_str, data_using_encoding_sel, 1)

vmp_sign = emu.call_symbol("_objc_msgSend", ali_tiger_tally_instance, vmp_sign_sel, encrypt_bytes)

logger.info("vmp sign: %s", read_ns_string(emu, vmp_sign))
logger.info("vmp sign: %s", objc_read_ns_string(emu, vmp_sign))


if __name__ == "__main__":
Expand Down
33 changes: 16 additions & 17 deletions examples/example_ios_bangbang.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import logging
import os

from chomper.core import Chomper
from chomper.const import OS_IOS
from chomper.os.ios.options import IosOptions
from chomper import Chomper
from chomper.const import ARCH_ARM64, OS_IOS

base_path = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -17,14 +16,14 @@


def create_emulator():
options = IosOptions(enable_objc=True, enable_ui_kit=True)
emu = Chomper(
return Chomper(
arch=ARCH_ARM64,
os_type=OS_IOS,
logger=logger,
rootfs_path=os.path.join(base_path, "ios/rootfs"),
os_options=options,
enable_objc=True,
enable_ui_kit=True,
)
return emu


def objc_get_class(emu, class_name):
Expand All @@ -35,7 +34,7 @@ def objc_sel_register_name(emu, sel_name):
return emu.call_symbol("_sel_registerName", emu.create_string(sel_name))


def create_ns_string(emu, s):
def objc_create_ns_string(emu, s):
ns_string_class = objc_get_class(emu, "NSString")
string_with_utf8_string_sel = objc_sel_register_name(emu, "stringWithUTF8String:")
obj = emu.call_symbol(
Expand All @@ -47,7 +46,7 @@ def create_ns_string(emu, s):
return obj


def read_ns_string(emu, obj):
def objc_read_ns_string(emu, obj):
c_string_using_encoding_sel = objc_sel_register_name(emu, "cStringUsingEncoding:")
ptr = emu.call_symbol("_objc_msgSend", obj, c_string_using_encoding_sel, 4)
return emu.read_string(ptr)
Expand All @@ -67,16 +66,16 @@ def hook_sec_item(emu):


def hook_ns_user_defaults(emu):
bangcle_debug_log_key = create_ns_string(emu, "N")
bangcle_debug_log_key = objc_create_ns_string(emu, "N")

emu.add_interceptor("+[NSUserDefaults(NSUserDefaults) standardUserDefaults]", hook_retval(0))
emu.add_interceptor("-[NSUserDefaults(NSUserDefaults) objectForKey:]", hook_retval(bangcle_debug_log_key))


def hook_ui_device(emu):
system_version = create_ns_string(emu, "14.4.0")
device_name = create_ns_string(emu, "iPhone")
device_model = create_ns_string(emu, "iPhone13,1")
system_version = objc_create_ns_string(emu, "14.4.0")
device_name = objc_create_ns_string(emu, "iPhone")
device_model = objc_create_ns_string(emu, "iPhone13,1")

emu.add_interceptor("-[UIDevice systemVersion]", hook_retval(system_version))
emu.add_interceptor("-[UIDevice name]", hook_retval(device_name))
Expand All @@ -98,18 +97,18 @@ def main():
decheckcode_sel = objc_sel_register_name(emu, "decheckcode:")

encrypt_data = 'S{"osVersion":"14.2.1","os":"iOS","deviceModel":"iPhone","channelNo":"APPSTORE"}'
encrypt_input = create_ns_string(emu, encrypt_data)
encrypt_input = objc_create_ns_string(emu, encrypt_data)

encrypt_result = emu.call_symbol("_objc_msgSend", bang_safe_sdk_class, checkcode_data_style_sel, encrypt_input, 2)

logger.info("encrypt_result: %s", read_ns_string(emu, encrypt_result))
logger.info("encrypt_result: %s", objc_read_ns_string(emu, encrypt_result))

decrypt_data = "F5usBNAQFKA6GVTwxynosqc1lMnCDVgedezMeCJh5bsGr6I+1/Ar+0zvwO/mt5v3DM/lPobNuOZqpMQwoh4HxH8KQRtGW/GVaE1+mEkXrKg2s7K5Kl7mHPRUpHzHzr064Nc3Fa1Mwm7OwUiEeSHUU+lbB3m7HHlFjDZmIra9NZ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hTOhV/LXI8gytO4vDmouGJNMQhHYDNfa/VU2UGk6KzHdHpTfZVQzQICg=="
decrypt_input = create_ns_string(emu, decrypt_data)
decrypt_input = objc_create_ns_string(emu, decrypt_data)

decrypt_result = emu.call_symbol("_objc_msgSend", bang_safe_sdk_class, decheckcode_sel, decrypt_input)

logger.info("decrypt_result: %s", read_ns_string(emu, decrypt_result))
logger.info("decrypt_result: %s", objc_read_ns_string(emu, decrypt_result))


if __name__ == "__main__":
Expand Down
25 changes: 12 additions & 13 deletions examples/example_ios_ijm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import logging
import os

from chomper.core import Chomper
from chomper.const import OS_IOS
from chomper.os.ios.options import IosOptions
from chomper import Chomper
from chomper.const import ARCH_ARM64, OS_IOS

base_path = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -17,14 +16,14 @@


def create_emulator():
options = IosOptions(enable_objc=True, enable_ui_kit=True)
emu = Chomper(
return Chomper(
arch=ARCH_ARM64,
os_type=OS_IOS,
logger=logger,
rootfs_path=os.path.join(base_path, "ios/rootfs"),
os_options=options,
enable_objc=True,
enable_ui_kit=True,
)
return emu


def objc_get_class(emu, class_name):
Expand All @@ -35,7 +34,7 @@ def objc_sel_register_name(emu, sel_name):
return emu.call_symbol("_sel_registerName", emu.create_string(sel_name))


def create_ns_string(emu, s):
def objc_create_ns_string(emu, s):
ns_string_class = objc_get_class(emu, "NSString")
string_with_utf8_string_sel = objc_sel_register_name(emu, "stringWithUTF8String:")
obj = emu.call_symbol(
Expand All @@ -47,7 +46,7 @@ def create_ns_string(emu, s):
return obj


def read_ns_string(emu, obj):
def objc_read_ns_string(emu, obj):
c_string_using_encoding_sel = objc_sel_register_name(emu, "cStringUsingEncoding:")
ptr = emu.call_symbol("_objc_msgSend", obj, c_string_using_encoding_sel, 4)
return emu.read_string(ptr)
Expand Down Expand Up @@ -77,18 +76,18 @@ def main():
jm_box_153_jm_box_501_sel = objc_sel_register_name(emu, "JMBox153:JMBox501:")

encrypt_data = '{"biClassId":["2","3","4"]}'
encrypt_input = create_ns_string(emu, encrypt_data)
encrypt_input = objc_create_ns_string(emu, encrypt_data)

encrypt_result = emu.call_symbol("_objc_msgSend", jm_box_125_class, jm_box_167_jm_box_501_sel, encrypt_input, 1)

logger.info("encrypt_result: %s", read_ns_string(emu, encrypt_result))
logger.info("encrypt_result: %s", objc_read_ns_string(emu, encrypt_result))

decrypt_data = "XKQYFMCP9Eb0IUzrQ9KaRRvTeFcYYyLcInrS/IWp6be1+VZa14GanCrzeb3DR45HW+XH0xiZLA5WUjUcXnlpM+CC6EtauUDUxCLap3QPWRyewLUosCB/ESHE7341DQca6lx5KFcP0XCkBpGlEKpACR5v7TwNBxc62auNBDvmEY422LTAUEEBrC8FDE+Y4DS2IJTLN6h9f7hdmQ4zUnY4cwyZXwgdIoH+bVuNy6TSw1JjQaFF/fLLHVZOQovrMcjtTpMZGr8xOSoW/+msiZzKwET3"
decrypt_input = create_ns_string(emu, decrypt_data)
decrypt_input = objc_create_ns_string(emu, decrypt_data)

decrypt_result = emu.call_symbol("_objc_msgSend", jm_box_125_class, jm_box_153_jm_box_501_sel, decrypt_input, 1)

logger.info("decrypt_result: %s", read_ns_string(emu, decrypt_result))
logger.info("decrypt_result: %s", objc_read_ns_string(emu, decrypt_result))


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 85fa04e

Please sign in to comment.