Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76393173
jadx
提交
bb4d88cc
J
jadx
项目概览
2301_76393173
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
bb4d88cc
编写于
11月 07, 2022
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(gui): add template for constructor and void methods to Frida snippet (#1714)
上级
4aaea2b9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
42 deletion
+41
-42
jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java
jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java
+41
-42
未找到文件。
jadx-gui/src/main/java/jadx/gui/ui/codearea/FridaAction.java
浏览文件 @
bb4d88cc
...
@@ -23,7 +23,6 @@ import jadx.api.utils.CodeUtils;
...
@@ -23,7 +23,6 @@ import jadx.api.utils.CodeUtils;
import
jadx.core.codegen.TypeGen
;
import
jadx.core.codegen.TypeGen
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JClass
;
...
@@ -76,45 +75,48 @@ public final class FridaAction extends JNodeAction {
...
@@ -76,45 +75,48 @@ public final class FridaAction extends JNodeAction {
}
}
private
String
generateMethodSnippet
(
JMethod
jMth
)
{
private
String
generateMethodSnippet
(
JMethod
jMth
)
{
JavaMethod
javaMethod
=
jMth
.
getJavaMethod
();
MethodNode
mth
=
jMth
.
getJavaMethod
().
getMethodNode
();
MethodInfo
methodInfo
=
javaMethod
.
getMethodNode
().
getMethodInfo
();
MethodInfo
methodInfo
=
mth
.
getMethodInfo
();
String
methodName
=
StringEscapeUtils
.
escapeEcmaScript
(
methodInfo
.
getName
());
String
methodName
;
if
(
methodInfo
.
isConstructor
())
{
if
(
methodInfo
.
isConstructor
())
{
methodName
=
"$init"
;
methodName
=
"$init"
;
}
else
{
methodName
=
StringEscapeUtils
.
escapeEcmaScript
(
methodInfo
.
getName
());
}
}
String
overload
;
String
callMethodName
=
methodName
;
if
(
isOverloaded
(
mth
))
{
String
shortClassName
=
javaMethod
.
getDeclaringClass
().
getName
();
String
overloadArgs
=
methodInfo
.
getArgumentsTypes
().
stream
()
.
map
(
this
::
parseArgType
).
collect
(
Collectors
.
joining
(
", "
));
String
functionUntilImplementation
;
overload
=
".overload("
+
overloadArgs
+
")"
;
if
(
isOverloaded
(
javaMethod
.
getMethodNode
()))
{
List
<
ArgType
>
methodArgs
=
methodInfo
.
getArgumentsTypes
();
String
overloadStr
=
methodArgs
.
stream
().
map
(
this
::
parseArgType
).
collect
(
Collectors
.
joining
(
", "
));
functionUntilImplementation
=
String
.
format
(
"%s[\"%s\"].overload(%s).implementation"
,
shortClassName
,
methodName
,
overloadStr
);
}
else
{
}
else
{
functionUntilImplementation
=
String
.
format
(
"%s[\"%s\"].implementation"
,
shortClassName
,
methodName
)
;
overload
=
""
;
}
}
List
<
String
>
argNames
=
collectMethodArgNames
(
jMth
.
getJavaMethod
());
List
<
String
>
methodArgNames
=
collectMethodArgNames
(
javaMethod
);
String
args
=
String
.
join
(
", "
,
argNames
);
String
logArgs
;
String
functionParametersString
=
String
.
join
(
", "
,
methodArgNames
);
if
(
argNames
.
isEmpty
())
{
String
logParametersString
=
logArgs
=
""
;
methodArgNames
.
stream
().
map
(
e
->
String
.
format
(
"'%s: ' + %s"
,
e
,
e
)).
collect
(
Collectors
.
joining
(
" + ', ' + "
));
}
else
{
if
(
logParametersString
.
length
()
>
0
)
{
String
joinStr
=
" + ', ' + "
;
log
ParametersString
=
" + ', ' + "
+
logParametersString
;
log
Args
=
joinStr
+
argNames
.
stream
().
map
(
a
->
"'"
+
a
+
": ' + "
+
a
).
collect
(
Collectors
.
joining
(
joinStr
))
;
}
}
String
functionParameterAndBody
=
String
.
format
(
String
shortClassName
=
mth
.
getParentClass
().
getShortName
();
"%s = function (%s) {\n"
String
classSnippet
=
generateClassSnippet
(
jMth
.
getJParent
());
+
" console.log('%s is called'%s);\n"
if
(
methodInfo
.
isConstructor
()
||
methodInfo
.
getReturnType
()
==
ArgType
.
VOID
)
{
+
" let ret = this.%s(%s);\n"
// no return value
+
" console.log('%s ret value is ' + ret);\n"
return
classSnippet
+
"\n"
+
" return ret;\n"
+
shortClassName
+
"[\""
+
methodName
+
"\"]"
+
overload
+
".implementation = function ("
+
args
+
") {\n"
+
"};"
,
+
" console.log('"
+
shortClassName
+
"."
+
methodName
+
" is called'"
+
logArgs
+
");\n"
functionUntilImplementation
,
functionParametersString
,
methodName
,
logParametersString
,
callMethodName
,
+
" this[\""
+
methodName
+
"\"]("
+
args
+
");\n"
functionParametersString
,
methodName
);
+
"};"
;
}
return
generateClassSnippet
(
jMth
.
getJParent
())
+
"\n"
+
functionParameterAndBody
;
return
classSnippet
+
"\n"
+
shortClassName
+
"[\""
+
methodName
+
"\"]"
+
overload
+
".implementation = function ("
+
args
+
") {\n"
+
" console.log('"
+
shortClassName
+
"."
+
methodName
+
" is called'"
+
logArgs
+
");\n"
+
" let ret = this[\""
+
methodName
+
"\"]("
+
args
+
");\n"
+
" console.log('"
+
shortClassName
+
"."
+
methodName
+
" return: ' + ret);\n"
+
" return ret;\n"
+
"};"
;
}
}
private
List
<
String
>
collectMethodArgNames
(
JavaMethod
javaMethod
)
{
private
List
<
String
>
collectMethodArgNames
(
JavaMethod
javaMethod
)
{
...
@@ -159,27 +161,24 @@ public final class FridaAction extends JNodeAction {
...
@@ -159,27 +161,24 @@ public final class FridaAction extends JNodeAction {
break
;
break
;
}
}
}
}
JClass
jc
=
jf
.
getRootClass
();
JClass
jc
=
jf
.
getRootClass
();
String
classSnippet
=
generateClassSnippet
(
jc
);
String
classSnippet
=
generateClassSnippet
(
jc
);
return
String
.
format
(
"%s\n%s = %s.%s.value;"
,
classSnippet
,
fieldName
,
jc
.
getName
(),
rawFieldName
);
return
String
.
format
(
"%s\n%s = %s.%s.value;"
,
classSnippet
,
fieldName
,
jc
.
getName
(),
rawFieldName
);
}
}
public
Boolean
isOverloaded
(
MethodNode
methodNode
)
{
public
Boolean
isOverloaded
(
MethodNode
methodNode
)
{
ClassNode
parentClass
=
methodNode
.
getParentClass
();
return
methodNode
.
getParentClass
().
getMethods
().
stream
()
List
<
MethodNode
>
methods
=
parentClass
.
getMethods
();
return
methods
.
stream
()
.
anyMatch
(
m
->
m
.
getName
().
equals
(
methodNode
.
getName
())
.
anyMatch
(
m
->
m
.
getName
().
equals
(
methodNode
.
getName
())
&&
!
Objects
.
equals
(
methodNode
.
getMethodInfo
().
getShortId
(),
m
.
getMethodInfo
().
getShortId
()));
&&
!
Objects
.
equals
(
methodNode
.
getMethodInfo
().
getShortId
(),
m
.
getMethodInfo
().
getShortId
()));
}
}
private
String
parseArgType
(
ArgType
x
)
{
private
String
parseArgType
(
ArgType
x
)
{
String
Builder
parsedArgType
=
new
StringBuilder
(
"'"
)
;
String
typeStr
;
if
(
x
.
isArray
())
{
if
(
x
.
isArray
())
{
parsedArgType
.
append
(
TypeGen
.
signature
(
x
).
replace
(
"/"
,
"."
)
);
typeStr
=
TypeGen
.
signature
(
x
).
replace
(
"/"
,
"."
);
}
else
{
}
else
{
parsedArgType
.
append
(
x
);
typeStr
=
x
.
toString
(
);
}
}
return
parsedArgType
.
append
(
"'"
).
toString
()
;
return
"'"
+
typeStr
+
"'"
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录