Skip to content

Commit

Permalink
update version to 0.7.15
Browse files Browse the repository at this point in the history
  • Loading branch information
胡霁 committed Apr 18, 2023
1 parent be7195f commit db7d8c5
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 98 deletions.
14 changes: 12 additions & 2 deletions .github/scripts/prepare-publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,27 @@
if __name__ == '__main__':
root_path = os.path.abspath(os.path.join(__file__, "..", "..", "..", "src", "linktools"))

######################################################################
# 处理版本号和release标志位
######################################################################
version = os.environ["VERSION"]
if version.startswith("v"):
version = version[len("v"):]

patten = re.compile(r"^__version__\s+=\s*\"\S*\"$")
version_patten = re.compile(r"^__version__\s+=\s*\"\S*\".*$")
release_patten = re.compile(r"^__release__\s+=\s*\w+.*$")
with open(os.path.join(root_path, "version.py"), "rt") as fd:
file_data = fd.read()
with open(os.path.join(root_path, "version.py"), "wt") as fd:
for line in file_data.splitlines(keepends=True):
fd.write(patten.sub(f"__version__ = \"{version}\"", line))
result = line
result = version_patten.sub(f"__version__ = \"{version}\"", result)
result = release_patten.sub(f"__release__ = True", result)
fd.write(result)

######################################################################
# 将tools.yml转为tools.json
######################################################################
with open(os.path.join(root_path, "assets", "tools.yml"), "rb") as fd:
file_data = yaml.safe_load(fd)
with open(os.path.join(root_path, "assets", "tools.json"), "wt") as fd:
Expand Down
47 changes: 41 additions & 6 deletions agent/frida/lib/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export class AndroidHelper {
Java.perform(function () {
const arraysClass = Java.use("java.util.Arrays");

ignoreError(() =>
JavaHelper.hookMethods("com.android.org.conscrypt.TrustManagerImpl", "checkServerTrusted", function (_obj, args) {
ignoreError(() => JavaHelper.hookMethods(
"com.android.org.conscrypt.TrustManagerImpl",
"checkServerTrusted",
(obj, args) => {
Log.d('Bypassing TrustManagerImpl checkServerTrusted');
if (this.returnType.type == 'void') {
return;
Expand All @@ -59,17 +61,50 @@ export class AndroidHelper {
})
);

ignoreError(() =>
JavaHelper.hookMethods("com.google.android.gms.org.conscrypt.Platform", "checkServerTrusted", function (_obj, _args) {
ignoreError(() => JavaHelper.hookMethods(
"com.google.android.gms.org.conscrypt.Platform",
"checkServerTrusted",
(obj, args) => {
Log.d('Bypassing Platform checkServerTrusted {1}');
})
);

ignoreError(() =>
JavaHelper.hookMethods("com.android.org.conscrypt.Platform", "checkServerTrusted", function (_obj, _args) {
ignoreError(() => JavaHelper.hookMethods(
"com.android.org.conscrypt.Platform",
"checkServerTrusted", (obj, args) => {
Log.d('Bypassing Platform checkServerTrusted {2}');
})
);

ignoreError(() => JavaHelper.hookMethods(
"okhttp3.CertificatePinner",
"check",
(obj, args) => true
));

ignoreError(() => JavaHelper.hookMethods(
"okhttp3.CertificatePinner",
"check$okhttp",
(obj, args) => void 0
));

ignoreError(() => JavaHelper.hookMethods(
"com.android.okhttp.CertificatePinner",
"check",
(obj, args) => true
));

ignoreError(() => JavaHelper.hookMethods(
"com.android.okhttp.CertificatePinner",
"check$okhttp",
(obj, args) => void 0
));

ignoreError(() => JavaHelper.hookMethods(
"com.android.org.conscrypt.TrustManagerImpl",
"verifyChain",
(obj, args) => args[0]
));
});
}

Expand Down
6 changes: 2 additions & 4 deletions agent/frida/lib/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ export class JavaHelper {
}
const method = this.getClassMethod(targetClass, methodName);
if (method === void 0 || method.overloads === void 0) {
Log.w("Cannot find method: " + this.getClassName(targetClass) + "." + methodName);
return;
throw Error("Cannot find method: " + this.getClassName(targetClass) + "." + methodName);
}
if (signatures != null) {
var targetSignatures: any[] = signatures;
Expand Down Expand Up @@ -306,8 +305,7 @@ export class JavaHelper {
}
var method = this.getClassMethod(targetClass, methodName);
if (method === void 0 || method.overloads === void 0) {
Log.w("Cannot find method: " + this.getClassName(targetClass) + "." + methodName);
return;
throw Error("Cannot find method: " + this.getClassName(targetClass) + "." + methodName);
}
for (var i = 0; i < method.overloads.length; i++) {
const targetMethod = method.overloads[i];
Expand Down
2 changes: 0 additions & 2 deletions src/linktools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
/_==__==========__==_ooo__ooo=_/' /___________,"
"""

from .version import __name__, __version__, __author__, __email__, __url__, __description__

from . import utils
from . import decorator
from ._logging import LogHandler
Expand Down
32 changes: 13 additions & 19 deletions src/linktools/_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@

from rich.prompt import Prompt, IntPrompt, FloatPrompt

from . import utils
from . import utils, version
from .decorator import cached_property, cached_classproperty
from .version import \
__name__ as __module_name__, \
__description__ as __module_description__, \
__version__ as __module_version__

T = TypeVar("T")
root_path = os.path.dirname(__file__)
Expand All @@ -53,7 +49,7 @@
missing = object()


class _ConfigLoader(abc.ABC):
class ConfigLoader(abc.ABC):
__lock__ = threading.RLock()

def __init__(self):
Expand All @@ -77,7 +73,7 @@ def _load(self, env: "BaseEnviron", key: Any):
pass


class _ConfigPrompt(_ConfigLoader):
class ConfigPrompt(ConfigLoader):

def __init__(
self,
Expand Down Expand Up @@ -158,7 +154,7 @@ def process_result(data):
return result


class _ConfigLazy(_ConfigLoader):
class ConfigLazy(ConfigLoader):

def __init__(self, func: Callable[["BaseEnviron"], Any]):
super().__init__()
Expand All @@ -173,8 +169,8 @@ class Config(dict):
def from_pyfile(self, filename: str, silent: bool = False) -> bool:
d = ModuleType("config")
d.__file__ = filename
d.prompt = _ConfigPrompt
d.lazy = _ConfigLazy
d.prompt = ConfigPrompt
d.lazy = ConfigLazy
try:
with open(filename, "rb") as config_file:
exec(compile(config_file.read(), filename, "exec"), d.__dict__)
Expand Down Expand Up @@ -341,15 +337,13 @@ def _internal_config(self) -> Config:
# 初始化全局存储路径配置,优先级低于data、temp路径
config["STORAGE_PATH"] = os.path.join(
str(pathlib.Path.home()),
f".{__module_name__}"
f".{version.__name__}"
)

# 导入configs文件夹中的配置文件
tools_path = self._get_path(asset_path, "tools.json")
if os.path.exists(tools_path):
if version.__release__:
# 只有发布版本才会有这个文件
config.from_file(
tools_path,
self._get_path(asset_path, "tools.json"),
json.load
)
else:
Expand Down Expand Up @@ -413,7 +407,7 @@ def get_config(self, key: str, type: Type[T] = None, empty: bool = False, defaul
try:
if key in self._config:
value = self._config.get(key)
if isinstance(value, _ConfigLoader):
if isinstance(value, ConfigLoader):
value = value.load(self, key)
if empty or value:
return value if type is None else type(value)
Expand Down Expand Up @@ -588,9 +582,9 @@ def system(self) -> str:


class Environ(BaseEnviron):
name = __module_name__
version = __module_version__
description = __module_description__
name = version.__name__
description = version.__description__
version = version.__version__
root_path = root_path

def _init_config(self, config: Config):
Expand Down
Loading

0 comments on commit db7d8c5

Please sign in to comment.