Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

帮忙看下,我直接运行dcc.py文件,报错 #11

Open
gtict112 opened this issue Nov 16, 2019 · 44 comments
Open

帮忙看下,我直接运行dcc.py文件,报错 #11

gtict112 opened this issue Nov 16, 2019 · 44 comments

Comments

@gtict112
Copy link

nc <= well_known_classes.cpp
jni/nc/Dex2C.cpp: In function 'int64_t d2c_double_to_long(double)':
jni/nc/Dex2C.cpp:75:42: error: 'INT64_MAX' was not declared in this scope
} else if (val > static_cast(INT64_MAX)) {
^
jni/nc/Dex2C.cpp:77:42: error: 'INT64_MIN' was not declared in this scope
} else if (val < static_cast(INT64_MIN)) {
^
jni/nc/Dex2C.cpp: In function 'int64_t d2c_float_to_long(float)':
jni/nc/Dex2C.cpp:89:41: error: 'INT64_MAX' was not declared in this scope
} else if (val > static_cast(INT64_MAX)) {
^
jni/nc/Dex2C.cpp:91:41: error: 'INT64_MIN' was not declared in this scope
} else if (val < static_cast(INT64_MIN)) {
^
jni/nc/Dex2C.cpp: In function 'int32_t d2c_double_to_int(double)':
jni/nc/Dex2C.cpp:103:41: error: 'INT32_MAX' was not declared in this scope
} else if (val > static_cast(INT32_MAX)) {
^
jni/nc/Dex2C.cpp:105:41: error: 'INT32_MIN' was not declared in this scope
} else if (val < static_cast(INT32_MIN)) {
^
jni/nc/Dex2C.cpp: In function 'int32_t d2c_float_to_int(float)':
jni/nc/Dex2C.cpp:117:41: error: 'INT32_MAX' was not declared in this scope
} else if (val > static_cast(INT32_MAX)) {
^
jni/nc/Dex2C.cpp:119:41: error: 'INT32_MIN' was not declared in this scope
} else if (val < static_cast(INT32_MIN)) {
^
make: *** [obj/local/armeabi-v7a/objs/nc/nc/Dex2C.o] Error 1

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

ndk版本是多少,用最新的试试.

@gtict112
Copy link
Author

用是19.2.5345600版本,电脑是mac系统的

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

我都是在ubuntu下测试的,mac我没有测试过.你先网上看看" 'INT64_MAX' was not declared in this scope" 这种错误怎么解决的,有可能是哪个头文件没有include进来.我晚上看看.

@gtict112
Copy link
Author

换了ndk20版本,没有上面的问题了。现在有个
[ERROR ] dcc: Compile app-releasenode222.apk failed!
Traceback (most recent call last):
File "dcc.py", line 441, in
dcc_main(infile, filtercfg, outapk, do_compile, project_dir, source_archive)
File "dcc.py", line 395, in dcc_main
copy_compiled_libs(project_dir, decompiled_dir)
File "dcc.py", line 242, in copy_compiled_libs
raise Exception("ABI %s is not supported!" % abi)
Exception: ABI arm64-v8a is not supported!
这个问题怎么处理

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

vi project/jni/Application.mk

把第4行打开,第5行注释掉.
看来我这个提示做得很搓啊,之前有人问过,应该做成自动编译原包支持的abi的.

@gtict112
Copy link
Author

gtict112 commented Nov 16, 2019

[ERROR ] dcc: Compile app-releasenode222.apk failed!
Traceback (most recent call last):
File "dcc.py", line 441, in
dcc_main(infile, filtercfg, outapk, do_compile, project_dir, source_archive)
File "dcc.py", line 395, in dcc_main
copy_compiled_libs(project_dir, decompiled_dir)
File "dcc.py", line 242, in copy_compiled_libs
raise Exception("ABI %s is not supported!" % abi)
Exception: ABI x86 is not supported!
打开第四行了,还是错误,,应该是没判断libs目录存不存在,我这个app本身没有lib目录的

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

把第四行改成这样.加上x86

APP_ABI := armeabi-v7a arm64-v8a x86

@gtict112
Copy link
Author

gtict112 commented Nov 16, 2019 via email

@gtict112
Copy link
Author

1-16 15:05:05.252 25510-25510/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lfgam.xinji, PID: 25510
java.lang.UnsatisfiedLinkError: No implementation found for void com.lfgam.xinji.ActiveCodeActivity.onCreate(android.os.Bundle) (tried Java_com_lfgam_xinji_ActiveCodeActivity_onCreate and Java_com_lfgam_xinji_ActiveCodeActivity_onCreate__Landroid_os_Bundle_2) 安装报错。

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

需要插入加载libnc.so代码,参考这个回复

@gtict112
Copy link
Author

还是不太明白,是要原工程加入
try {
System.loadLibrary("nc");
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
}这代码,,还是处理过后的app加入smali 代码加载nc库文件

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

加载库有两种改法.
1.有工程源码,改源码,就用这个try catch
2.没有java源码,改smali.参考我回复的smali.

@gtict112
Copy link
Author

gtict112 commented Nov 16, 2019

按照第二种方法处理了一下
1:先把预先准备的好app,反编译加上nc代码
2:再重新打包成新包,
3:python3 dcc.py test2.apk -o out.apk 处理下生成out.apk,再生成签名安装,
可以安装成功并运行,nc库也在进去带app内存当中(b3b67000-b3b68000 rw-p 00029000 fe:00 999738 /data/app/com.gam.xinji-1/lib/arm/libnc.so)。 但是我反编译out.apk。。java代码并没有处理,还是原来带代码代码。不知道哪里问题了

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

你看这个方法的代码是不是已经隐藏了 "Java_com_lfgam_xinji_ActiveCodeActivity_onCreate".
如果你要隐藏所有方法,把filter.txt文件最后一行打开.

@gtict112
Copy link
Author

gtict112 commented Nov 16, 2019 via email

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

这是我在类型推导失败或者我检测到类型推导不正确抛的异常,程序应该还是能正常运行.
支持正则过滤需要编译和禁止编译的方法.filter.txt里面有,你看我处理demo和onCreate的写法.

@gtict112
Copy link
Author

gtict112 commented Nov 16, 2019 via email

@gtict112
Copy link
Author

No implementation found for void de.robv.android.xposed.mods.tutorial.AutoHook.loadPrefs()
filter.txt文件里面加入了.loadPrefs(. 规则,提示报错

反编译出来确实存在private native void loadPrefs();
public JApplication() {
System.loadLibrary("nc");
} 这个代码是放在application继承类里面
app运行也没有加载进去nc库,是什么情况

@amimo
Copy link
Owner

amimo commented Nov 16, 2019

加载的时机可能还是晚了。你在JApplication的静态代码块加载试试。
不行再把完整的错误栈发一下。

@gtict112
Copy link
Author

我这个是xposed插件
入口是auto这个类 public AutoHook() {
System.loadLibrary("nc");
}
Failed to load class de.robv.android.xposed.mods.tutorial.AutoHook
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.lfgam.xinji-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libnc.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at de.robv.android.xposed.mods.tutorial.AutoHook.(AutoHook.java:81)
at java.lang.Class.newInstance(Native Method)
at de.robv.android.xposed.XposedInit.loadModule(XposedInit.java:546)

@amimo
Copy link
Owner

amimo commented Nov 18, 2019

很久很久以前,我玩xposed的时候是这样加载native库的,不知道xposed的api现在变什么样了,你可以参考下.
我是在IXposedHookLoadPackage.handleLoadPackage使用下面的代码加载的

java.lang.System.load("/data/data/" + 插件包名 + "/lib/" + "libnc.so");

@gtict112
Copy link
Author

放在handleLoadPackage 下面也是找不到路径,不知道是不是系统版本问题,还在摸索中

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

确定so已经解压出来,并且加载路径是对的?
7+可能会有namespace的问题.

@gtict112
Copy link
Author

确定路径是对的,,现在我系统是6.0. 插件没处理先都是运行正常的,,处理后就是说找不到nc路径

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

Log看看,我之前在4.4上是可以加载native库的.

@gtict112
Copy link
Author

public void handleLoadPackage(LoadPackageParam loadPackageParam) throws Throwable {
    String str;
    Exception e;
    Throwable th;
    LoadPackageParam loadPackageParam2 = loadPackageParam;
    System.loadLibrary("/data/app/com.lfgam.xinji-1/lib/libnc.so");

这个是现在改成data/app目录下的代码。
报错
dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.lfgam.xinji-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "lib/data/app/com.lfgam.xinji-1/lib/libnc.so.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at de.robv.android.xposed.mods.tutorial.AutoHook.handleLoadPackage(AutoHook.java)
at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)
at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:61)
at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:106)
at de.robv.android.xposed.XposedInit$2.beforeHookedMethod(XposedInit.java:134)
改成data/app目录下参考下https://bbs.pediy.com/thread-251171.htm,,难道要改成callemethed这样

如果改成data/data/com.lfgam.xinji/lib/libnc.so目录,就会报错找不到data/data/下的文件

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

大佬,用这个api, java.lang.System.load,你这个路径下次安装就会变的.用我的那个写法,单用户下路径是固定的.

@gtict112
Copy link
Author

1:现在 改成 public AutoHook() {
System.load("/data/data/com.lfgam.xinji/lib/libnc.so");
}还是报错,多了armeabi-v7a
java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/data/com.lfgam.xinji/armeabi-v7a/lib/libnc.so" not found
at java.lang.Runtime.load(Runtime.java:332)
at java.lang.System.load(System.java:1069)
at com.example.hrst.xposedtest.Test.handleLoadPackage(Test.java:188)
at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)
at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:61)
在我手机里面多路径没有armeabiv7a的
/data/data/com.lfgam.xinji/lib
root@shamu:/data/data/com.lfgam.xinji/lib #

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

apk里面就没有这个so库吧。
你先手动复制一个libnc.so到lib下面,然后用绝对路径加载。

@gtict112
Copy link
Author

1:libnc.so这个文件都有,每个abi版本nc文件都有,安装后应该arm/libnc.so这目录的
2:/data/data/com.lfgam.xinji/lib/这目录是我写死的,libnc.so这确实也有,,但报错是另外一个目录

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

你复制一个到

cp libnc.so /data/data/com.lfgam.xinji/armeabi-v7a/lib/libnc.so
chmod +x /data/data/com.lfgam.xinji/armeabi-v7a/lib/libnc.so

如果可以你后面可以自己把so解压到files下面,然后用绝对路径加载。

@gtict112
Copy link
Author

/com.lfgam.xinji/armeabi-v7a/lib # ls -al
-rwx------ root root 378348 2019-11-20 19:34 libBaiduMapSDK_base_v5_4_4.so
-rwx------ root root 2480000 2019-11-20 19:34 libBaiduMapSDK_map_v5_4_4.so
-rwx------ root root 177692 2019-11-20 19:35 libindoor.so
-rwx------ root root 100328 2019-11-20 19:34 liblocSDK7d.so
-rwx------ root root 173840 2019-11-20 19:34 libnc.so
root@shamu:/data/data/com.lfgam.xinji/armeabi-v7a/lib #
提示还是找不到
java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/data/com.lfgam.xinji/armeabi-v7a/lib/libnc.so" not found
at java.lang.Runtime.load(Runtime.java:332)
at java.lang.System.load(System.java:1069)
at com.example.hrst.xposedtest.Test.handleLoadPackage(Test.java:188)
at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)
我晕了

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

chmod 777 /data/data/com.lfgam.xinji/armeabi-v7a/lib/libnc.so

@gtict112
Copy link
Author

目录,文件权限全加了,还是找不到,
-rwxrwxrwx root root 378348 2019-11-20 19:34 libBaiduMapSDK_base_v5_4_4.so
-rwxrwxrwx root root 2480000 2019-11-20 19:34 libBaiduMapSDK_map_v5_4_4.so
-rwxrwxrwx root root 177692 2019-11-20 19:35 libindoor.so
-rwxrwxrwx root root 100328 2019-11-20 19:34 liblocSDK7d.so
-rwxrwxrwx root root 173840 2019-11-20 19:34 libnc.so
root@shamu:/data/data/com.lfgam.xinji/armeabi-v7a/lib #

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

这都不行。
···
chmod 777 /data/data/com.lfgam.xinji/armeabi-v7a
chmod 777 /data/data/com.lfgam.xinji/armeabi-v7a/lib
···
还不行关闭selinux
···
setenforce 0
···
再不行我也没辙了。

@gtict112
Copy link
Author

可以了!!!晕晕
现在又报错,是不是nc文件位置不对,,我放在在init函数里面
Process: com.lfgam.xinji, PID: 14743
java.lang.UnsatisfiedLinkError: No implementation found for void com.lfgam.xinji.ActiveCodeActivity.onCreate(android.os.Bundle) (tried Java_com_lfgam_xinji_ActiveCodeActivity_onCreate and Java_com_lfgam_xinji_ActiveCodeActivity_onCreate__Landroid_os_Bundle_2)
at com.lfgam.xinji.ActiveCodeActivity.onCreate(Native Method)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)


.method public constructor ()V
.locals 3
invoke-direct {p0}, Ljava/lang/Object;->()V

.line 688
new-instance v0, Lde/robv/android/xposed/mods/tutorial/AutoHook$13;

invoke-direct {v0, p0}, Lde/robv/android/xposed/mods/tutorial/AutoHook$13;-><init>(Lde/robv/android/xposed/mods/tutorial/AutoHook;)V

iput-object v0, p0, Lde/robv/android/xposed/mods/tutorial/AutoHook;->hookStack:Lde/robv/android/xposed/XC_MethodHook;

const-string v3, "/data/data/com.lfgam.xinji/lib/libnc.so"  ///这里加载so文件路径

invoke-static {v3}, Ljava/lang/System;->load(Ljava/lang/String;)V

return-void

@amimo
Copy link
Owner

amimo commented Nov 20, 2019

代码还没有被执行吧。重复加载是没有问题的,原来的代码你不要删除。Java_com_lfgam_xinji_ActiveCodeActivity你在这个类的init里面也加上试试。

@gtict112
Copy link
Author

olchains/llvm/prebuilt/darwin-x86_64/bin/clang++: Argument list too long
make: *** [obj/local/armeabi-v7a/libnc.so] Error 127
make: Leaving directory `/private/var/folders/gj/5fhct7z93kz11w5k33k8n9740000gp/T/dcc-project-uwny_5kc'
[ERROR ] dcc: Compile test4.apk failed!
Traceback (most recent call last):
File "dcc.py", line 441, in
dcc_main(infile, filtercfg, outapk, do_compile, project_dir, source_archive)
File "dcc.py", line 390, in dcc_main
build_project(project_dir)
File "dcc.py", line 87, in build_project
subprocess.check_call([NDKBUILD, '-j%d' % cpu_count(), '-C', project_dir])
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 347, in check_call
这个是什么错误,,就是过滤文件全部函数处理.*; 如果不打开就没问题
难道是clang++ 不支持

@amimo
Copy link
Owner

amimo commented Nov 21, 2019

之前不能加载的问题好了?
我觉得像是系统限制,在linux下用最新的ndk试试。你也可以不加固第三方sdk,只加固自己代码.

@gtict112
Copy link
Author

之前也是处理一个函数没问题,开启全部就不行。主要是过滤规则不懂写,,混淆过后都是a,b,c那种函数

@amimo
Copy link
Owner

amimo commented Nov 21, 2019

我说的是库找不到的问题.

java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/data/com.lfgam.xinji/armeabi-v7a/lib/libnc.so" not found

这个问题怎么解决的?
规则你研究下主页文档和正则表达式.

@gtict112
Copy link
Author

还没有想到办法怎么处理路径问题,,想不明白怎么无缘多出armeabi-v7a这东西

@amimo
Copy link
Owner

amimo commented Nov 21, 2019

你先把流程跑通,有可能xposed模块就不能用这个加固,如果是这样的话,继续折腾这个玩意就没有意义了.

@coderstory
Copy link

还没有想到办法怎么处理路径问题,,想不明白怎么无缘多出armeabi-v7a这东西

这是因为系统还没初始化完成。。。遇到了
可以解决 但是很麻烦。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants