|
- 7 j, U2 h" M) i+ b% ]& k
- local function Table_exists(tables,value)
# X, {& O6 R7 A% k: c) b' t3 v/ ~ - for index,content in pairs(tables) do$ s. t: K- }8 F9 @% s/ z
- if content:find(value) then4 _2 C$ K+ v2 Z9 [5 m
- return true
9 E$ z7 X* s$ Y$ z& I ?' |# [% c- r - end
6 D, V- z2 ]% b: ~1 b6 v6 J8 X - end; [; l5 S: B+ ?* \- q) r! N
- end) j' G. u! T" S3 d8 o" J2 H% b ]% H, G6 y
- local function endsWith(sss,str)
7 b0 t' d+ Y6 H- `4 { - if sss:match(".") then
/ u2 d+ w4 p! a3 S - if str==tostring(sss):match("%.(.+)") then
) z0 o n U+ F5 R4 r8 z6 | - return true
3 ]! _8 G+ [# H - else" B* R n' h. I N
- return false. Y2 V! U0 D6 Z+ }4 o
- end0 ?: D! F- Z3 B. ~3 C
- end
* G- T1 ~( P5 P3 P& k4 P3 `! R7 } - 3 y: w! j, M" J
- end0 Z: U" Y) ^1 W) }) J+ `
8 M0 ~# w( K2 W8 F4 v% J1 t- local function lastIndexOf(text,z)* o- d3 A0 g, b
- a=历遍字符串位置(text,z)
3 e, e$ k8 l' S, c; e' z, ]1 ~) L - return a[#a]
& f2 d& z, F( K1 { - end1 k: m( I1 \; ]% `
- function 取所有应用包名(); `0 x, H+ A7 I$ p# ?/ z
- a={}
- b% q, m9 I, G: Y1 g2 J9 M& | - installedPackages = activity.getPackageManager().getInstalledPackages(0);
; m! ^) q, b* d6 h5 L7 W5 s, T - for index,content in pairs(luajava.astable(installedPackages)) do
! G2 `0 Z ]$ g9 N( v+ K - packageInfo = content.packageName;* Z1 @0 }4 r( d/ w
- table.insert(a,tostring(packageInfo))/ j1 g" Q% w- N3 U2 \* i! L& O
- end
& F( T9 P( W4 N4 a! M( ^* ` - return a; ^# e+ f. d9 X& `- g1 u
- end
" B5 n+ `* \! d2 O - function isHookByPackageName()4 H7 y3 v \7 j7 i* D4 P6 p4 k
- import "android.content.pm.PackageManager"3 X4 ^+ e7 N* y" s/ U I
- isHook = false;0 T1 q1 V/ G1 w$ F8 ^; T
- packageManager = activity.getPackageManager();. O* @& {4 {- Y) J9 c( n
- applicationInfoList = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);; `% T9 U8 l5 K
- if (nil== applicationInfoList) then+ A- x1 u6 R" u$ O. s9 ] D
- return isHook;% _! K! a$ g7 [7 ^
- end
7 ]/ @: M- i+ {5 Y9 k$ s. R - ! l3 j$ R# B" ?6 S
- if Table_exists(取所有应用包名(),"de.robv.android.xposed.installer") then: M8 e; P+ g' F, b6 F+ |$ l& R( q
- isHook=true
+ o. i! f8 D/ g# r - else. P3 U: b% J* p$ S
- [8 d' {% L; c6 n0 F% X. N/ K
- if Table_exists(取所有应用包名(),"com.saurik.substrate") then
4 W3 O3 c. m7 o) Y6 |" O* A$ x1 A- W) ^ - isHook=true7 ~2 c$ _. `7 t
- else; R" y) [3 k/ [+ S( N( T
- ! ~8 `1 F# R; j9 s7 d$ w5 Q
- end
2 j: g# s1 c# D% M - end8 `* h8 X# ` l. _& y V
- return isHook;( V6 J* e& }0 c5 f7 u$ h9 w
- % w+ p( H' ?2 m
- end; Y4 _- N& w j& c; u
- function isHookByJar()0 C3 o/ A0 B! u* w; s$ M2 L
- import"android.os.Process"/ F! l3 C6 v% F0 ^
- isHook = false; b. h2 y. W* l8 M9 I
- libraries = {};
9 A5 g8 e- m/ p8 x) p/ \! g - mapsFilename = "/proc/" .. Process.myPid() .. "/maps";
! C2 d) s( m, x* @ - reader = BufferedReader(FileReader(mapsFilename));
f% q# t! S5 c& Z. R3 k - while reader.readLine() ~= nil do
2 e) H9 @+ N. e3 i& h0 \ - if endsWith(tostring(reader.readLine()),"jar") ||endsWith(tostring(reader.readLine()),"so")then' r' ~: G# I/ l$ t
- line=tostring(reader.readLine())/ Y4 w# ~6 k" Q9 |4 @7 N I+ x% T9 S
- n= lastIndexOf(line," ");" @9 E4 ?2 E% W
- lines=string.sub(line,n+1,#line)1 k8 s* J6 ?9 t6 W1 }: {
- --print(lines)2 Z c% _2 ~9 i" E, o6 ]3 |
- table.insert(libraries,tostring(lines))
# F L6 Q- K/ D- }+ a: V8 h: A - end6 J* C# U- f" o* X5 @ }8 F
- end
# l- n1 z1 j( `4 {* e2 r% I' D
) q. t1 o* u# M! l1 U# q/ m! r- library=0( q' t# s2 ?( }/ e
- while library~=#libraries do9 G$ D9 e0 j, X0 q0 W
- library=library+1$ H4 ~* R( ? W. Q* _% c
- if libraries[library]:match("com.saurik.substrate") then( l) @4 h2 y& F
- Log.wtf("HookDetection", "Substrate shared object found: " + library);
4 F: `# w! }( s$ |3 S) F" N - isHook = true;
# i' E0 s3 D! A; _5 ~; Y3 ` - end
3 H. S; H( C* y) [ - if libraries[library]:match("Xposed") then1 R: Y: o Q- O( {
- Log.wtf("HookDetection", "Xposed JAR found: " + library);
, J5 Y, y m7 a" Y: R) r1 e9 n+ u W - isHook = true;
8 g4 s9 }& y3 ^4 f- ?. \* f" K5 \1 D - end
, m, M8 H* o# e6 X0 F- k) P - end9 v- V5 q; ^, M
- reader.close();
* ^# z! B) X% b9 l" i9 U - / \2 U' X& G; w5 i. E+ ?( I3 E% Y( ^
- return isHook;& b A. M7 {! h/ k( a' ]# S
- + `6 l" l& U# s! @7 c
- end
复制代码 |
|