Giter Club home page Giter Club logo

leoric's Introduction

Leoric

Leoric 是一个 Android 上的黑科技保活方法的 PoC,它可以对抗在任意 Android 版本上的 force-stop 杀进程。

Leoric 是 Dota 中的英雄"骷髅王",本项目名取自骷髅王的大招「重生」。

Leoric

编译环境

JDK 11 + NDK 19.2.5345600

重现方法

虽然理论上这个方法可以支持任意的 Android 版本,但本 PoC 在 Android 9.0 及 Android 10 上测试过。具体使用方式参见 demo 项目。

实现原理

应对方法

下面是一种简单的方法杀死 Leoric:

ps -A | grep `ps -A | grep me.weishu.leoric | awk '{print $1}' | head -1` | awk '{print $2}' | xargs kill -19 && am force-stop me.weishu.leoric

对于系统有两种思路可以选择:

  1. 加入在 force-stop 期间不允许启动新的进程的逻辑
  2. 修改 force-stop 的杀进程逻辑为:预先收集好所有进程再进行 kill(如有必要还可以先发送 SIGSTOP)

在 Android 14 中,系统加入了在强行停止前冻结应用全部 cgroup 的逻辑,本方案失效。

Contact me

Email: [email protected]

郑重声明

本项目仅做学习研究使用,出现任何问题概不负责。另外,本 PoC 离实际投入使用还有很长的路要走,请不要妄想直接接入代码就能得到永生。

之所以公开代码,是为了推动厂商对系统做出改进,提供应对之法;请不要滥用!!

License

Copyright (C) 2015, Mars Kwok

Copyright (C) 2020, weishu

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Credits

MarsDaemon

leoric's People

Contributors

aviraxp avatar fjddhd avatar liudongmiao avatar poseidonmrt avatar rikkaw avatar tiann avatar vvb2060 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leoric's Issues

如何保活主进程

我希望业务是在主进程完成的,如何保活主进程。
目前我的做法是在application的oncreate内直接启动主进程的服务。这样force-stop后子进程启动时,同时也会把主进程拉起来。但是我单独kill主进程,就会有问题!

这个日志信息,是被杀掉了吗?

020-01-16 17:35:23.421 4085-4337/? W/JavaExceptionHandler: Too noisy! skip duplicate java exception report:me.weishu.leoric:resident now=1579167323421 mLastReportTime=1579167300444 interval=60000
2020-01-16 17:35:23.425 1208-5579/? I/ActivityManager: Process me.weishu.leoric:resident (pid 11304) has died: fore SVC
2020-01-16 17:35:23.426 1208-5579/? I/AutoStartManagerService: MIUILOG- Reject RestartService packageName :me.weishu.leoric uid : 10588
2020-01-16 17:35:23.808 1208-2150/? D/MiuiGesture: add Window{a8e0470 u0 me.weishu.leoric/me.weishu.leoric.demo.MainActivity}, type=1
2020-01-16 17:35:23.815 1208-2150/? D/MiuiGesture: try to get iconInfo of me.weishu.leoric/.demo.MainActivity
2020-01-16 17:35:23.977 2186-2186/? D/RecentsImpl: startRecentsActivity runningTask: ComponentInfo{me.weishu.leoric/me.weishu.leoric.demo.MainActivity}
2020-01-16 17:35:24.025 1208-2150/? D/MiuiGesture: set AppWindowToken{b3f84c2 token=Token{7971d0d ActivityRecord{967eb36 u0 me.weishu.leoric/.demo.MainActivity t37639}}}, ignoreInput = true
2020-01-16 17:35:24.074 779-779/? I/GameEngine: last packageName: me.weishu.leoric
2020-01-16 17:35:24.635 1208-2150/? D/MiuiGesture: set AppWindowToken{b3f84c2 token=Token{7971d0d ActivityRecord{967eb36 u0 me.weishu.leoric/.demo.MainActivity t37639}}}, ignoreInput = false
2020-01-16 17:35:25.376 2772-2993/? D/Launcher: getLastLaunchApp, pkg=me.weishu.leoric
2020-01-16 17:35:31.059 11263-11297/me.weishu.leoric I/e.weishu.leori: ProcessProfilingInfo new_methods=24 is saved saved_to_disk=1 resolve_classes_delay=8000
2020-01-16 17:35:39.091 2186-2186/? D/RecentsActivity: removeTask: [id=37639 stackId=247 windowingMode=1 user=0 lastActiveTime=65188609] Leoric
2020-01-16 17:35:39.095 1208-10379/? D/WindowProcessUtils: remove task: TaskRecord{f513937 #37639 A=me.weishu.leoric U=0 StackId=247 sz=1}
2020-01-16 17:35:39.096 1208-10379/? I/ProcessManager: SwipeUpClean: force-stop me.weishu.leoric Adj=900 State=17
2020-01-16 17:35:39.133 1208-10379/? I/ActivityManager: Force stopping me.weishu.leoric appid=10588 user=0: SwipeUpClean
2020-01-16 17:35:39.134 1208-10379/? I/ActivityManager: Killing 11263:me.weishu.leoric/u0a588 (adj 905): stop me.weishu.leoric: SwipeUpClean

Leoric.java 引入的Reflection.java在哪里?

...
import me.weishu.reflection.Reflection;

public class Leoric {
...

想编译一下,结果找不到这个类文件。库里和app里都找不到,也没有看到有第三方库有这个类。

Android 11上监听进程死亡问题

机型: OPPO、RealMe
Android版本: 11
TargetSdkVersion:30

在监听到进程死亡后
public void onDaemonDead() { Log.e("log",""+Process.myPid()); // ILeoricProcess.Fetcher.fetchStrategy().onDaemonDead(); }
调用Process.myPid()直接崩溃...

Crash on samsung note 9 android 10.

2020-04-27 05:06:29.079 5265-5265/me.weishu.leoric E/AndroidRuntime: FATAL EXCEPTION: main Process: me.weishu.leoric, PID: 5265 android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{ccd4247 u0 me.weishu.leoric/.demo.Service1} at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2068) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:7811) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

vivo android9,10系统forcestop 无法保活

您好,我在测试该项目时发现在vivo android10手机上 forcestop杀进程时 孤儿进程可以检测到进程被杀死 且与binder完成通信,但程序未成功保活 vivo手机保活不成功了吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.