Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SandHook
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
SandHook
Commits
4cbbcb53
Commit
4cbbcb53
authored
Jan 24, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test case
parent
779037e4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
92 additions
and
12 deletions
+92
-12
MainActivity.java
app/src/main/java/com/swift/sandhook/MainActivity.java
+9
-0
MyApp.java
app/src/main/java/com/swift/sandhook/MyApp.java
+6
-5
TestClass.java
app/src/main/java/com/swift/sandhook/test/TestClass.java
+22
-0
ActivityHooker.java
...n/java/com/swift/sandhook/testHookers/ActivityHooker.java
+1
-1
CtrHook.java
...src/main/java/com/swift/sandhook/testHookers/CtrHook.java
+49
-0
CustmizeHooker.java
...n/java/com/swift/sandhook/testHookers/CustmizeHooker.java
+1
-1
LogHooker.java
...c/main/java/com/swift/sandhook/testHookers/LogHooker.java
+1
-1
ObjectHooker.java
...ain/java/com/swift/sandhook/testHookers/ObjectHooker.java
+1
-1
arm64.S
hooklib/src/main/cpp/trampoline/arch/arm64.S
+2
-2
SandHookMethodResolver.java
.../main/java/com/swift/sandhook/SandHookMethodResolver.java
+0
-1
No files found.
app/src/main/java/com/swift/sandhook/MainActivity.java
View file @
4cbbcb53
...
@@ -12,6 +12,7 @@ import android.view.Menu;
...
@@ -12,6 +12,7 @@ import android.view.Menu;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.swift.sandhook.test.TestClass
;
import
com.swift.sandhook.wrapper.HookErrorException
;
import
com.swift.sandhook.wrapper.HookErrorException
;
import
com.swift.sandhook.wrapper.HookWrapper
;
import
com.swift.sandhook.wrapper.HookWrapper
;
...
@@ -54,6 +55,14 @@ public class MainActivity extends AppCompatActivity {
...
@@ -54,6 +55,14 @@ public class MainActivity extends AppCompatActivity {
// Example of a call to a native method
// Example of a call to a native method
TextView
tv
=
(
TextView
)
findViewById
(
R
.
id
.
sample_text
);
TextView
tv
=
(
TextView
)
findViewById
(
R
.
id
.
sample_text
);
TestClass
str
=
new
TestClass
(
1
);
str
.
add1
();
str
.
add2
();
Log
.
e
(
"dd"
,
str
.
a
+
""
);
}
}
public
static
Field
getField
(
Class
topClass
,
String
fieldName
)
throws
NoSuchFieldException
{
public
static
Field
getField
(
Class
topClass
,
String
fieldName
)
throws
NoSuchFieldException
{
...
...
app/src/main/java/com/swift/sandhook/MyApp.java
View file @
4cbbcb53
...
@@ -2,10 +2,11 @@ package com.swift.sandhook;
...
@@ -2,10 +2,11 @@ package com.swift.sandhook;
import
android.app.Application
;
import
android.app.Application
;
import
com.swift.sandhook.test.ActivityHooker
;
import
com.swift.sandhook.testHookers.ActivityHooker
;
import
com.swift.sandhook.test.CustmizeHooker
;
import
com.swift.sandhook.testHookers.CtrHook
;
import
com.swift.sandhook.test.LogHooker
;
import
com.swift.sandhook.testHookers.CustmizeHooker
;
import
com.swift.sandhook.test.ObjectHooker
;
import
com.swift.sandhook.testHookers.LogHooker
;
import
com.swift.sandhook.testHookers.ObjectHooker
;
import
com.swift.sandhook.wrapper.HookErrorException
;
import
com.swift.sandhook.wrapper.HookErrorException
;
public
class
MyApp
extends
Application
{
public
class
MyApp
extends
Application
{
...
@@ -13,7 +14,7 @@ public class MyApp extends Application {
...
@@ -13,7 +14,7 @@ public class MyApp extends Application {
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
try
{
try
{
SandHook
.
addHookClass
(
LogHooker
.
class
,
CustmizeHooker
.
class
,
ActivityHooker
.
class
,
ObjectHooker
.
class
);
SandHook
.
addHookClass
(
CtrHook
.
class
,
LogHooker
.
class
,
CustmizeHooker
.
class
,
ActivityHooker
.
class
,
ObjectHooker
.
class
);
}
catch
(
HookErrorException
e
)
{
}
catch
(
HookErrorException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
app/src/main/java/com/swift/sandhook/test/TestClass.java
0 → 100644
View file @
4cbbcb53
package
com
.
swift
.
sandhook
.
test
;
public
class
TestClass
{
public
int
a
=
1
;
int
b
=
2
;
public
TestClass
(
int
a
)
{
this
.
a
=
a
+
1
;
}
public
void
add1
()
{
a
++;
b
++;
}
public
void
add2
()
{
a
++;
b
++;
}
}
app/src/main/java/com/swift/sandhook/test/ActivityHooker.java
→
app/src/main/java/com/swift/sandhook/test
Hookers
/ActivityHooker.java
View file @
4cbbcb53
package
com
.
swift
.
sandhook
.
test
;
package
com
.
swift
.
sandhook
.
test
Hookers
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
...
app/src/main/java/com/swift/sandhook/testHookers/CtrHook.java
0 → 100644
View file @
4cbbcb53
package
com
.
swift
.
sandhook
.
testHookers
;
import
android.util.Log
;
import
com.swift.sandhook.test.TestClass
;
import
com.swift.sandhook.wrapper.HookClass
;
import
com.swift.sandhook.wrapper.HookMethod
;
import
com.swift.sandhook.wrapper.HookMethodBackup
;
import
com.swift.sandhook.wrapper.MethodParams
;
@HookClass
(
TestClass
.
class
)
public
class
CtrHook
{
@HookMethod
@MethodParams
(
int
.
class
)
public
static
void
onCtr
(
TestClass
thiz
,
int
a
)
{
Log
.
e
(
"TestClassHook"
,
"TestClass(int) been hooked"
);
onCtrBackup
(
thiz
,
a
);
}
@HookMethodBackup
@MethodParams
(
int
.
class
)
public
static
void
onCtrBackup
(
TestClass
thiz
,
int
a
)
{
onCtrBackup
(
thiz
,
a
);
}
@HookMethod
(
"add1"
)
public
static
void
onAdd1
(
TestClass
thiz
)
{
Log
.
e
(
"TestClassHook"
,
"add1 been hooked"
);
onAdd1Backup
(
thiz
);
}
@HookMethodBackup
(
"add1"
)
public
static
void
onAdd1Backup
(
TestClass
thiz
)
{
onAdd1Backup
(
thiz
);
}
@HookMethod
(
"add2"
)
public
static
void
onAdd2
(
TestClass
thiz
)
{
Log
.
e
(
"TestClassHook"
,
"add2 been hooked"
);
onAdd2Backup
(
thiz
);
}
@HookMethodBackup
(
"add2"
)
public
static
void
onAdd2Backup
(
TestClass
thiz
)
{
onAdd2Backup
(
thiz
);
}
}
app/src/main/java/com/swift/sandhook/test/CustmizeHooker.java
→
app/src/main/java/com/swift/sandhook/test
Hookers
/CustmizeHooker.java
View file @
4cbbcb53
package
com
.
swift
.
sandhook
.
test
;
package
com
.
swift
.
sandhook
.
test
Hookers
;
import
android.util.Log
;
import
android.util.Log
;
...
...
app/src/main/java/com/swift/sandhook/test/LogHooker.java
→
app/src/main/java/com/swift/sandhook/test
Hookers
/LogHooker.java
View file @
4cbbcb53
package
com
.
swift
.
sandhook
.
test
;
package
com
.
swift
.
sandhook
.
test
Hookers
;
import
android.util.Log
;
import
android.util.Log
;
...
...
app/src/main/java/com/swift/sandhook/test/ObjectHooker.java
→
app/src/main/java/com/swift/sandhook/test
Hookers
/ObjectHooker.java
View file @
4cbbcb53
package
com
.
swift
.
sandhook
.
test
;
package
com
.
swift
.
sandhook
.
test
Hookers
;
import
android.util.Log
;
import
android.util.Log
;
...
...
hooklib/src/main/cpp/trampoline/arch/arm64.S
View file @
4cbbcb53
...
@@ -64,8 +64,8 @@ x22 - x28 貌似可以使用
...
@@ -64,8 +64,8 @@ x22 - x28 貌似可以使用
#if defined(__aarch64__)
#if defined(__aarch64__)
#define Reg0 x2
4
#define Reg0 x2
3
#define Reg1 x2
5
#define Reg1 x2
4
#define RegMethod x0
#define RegMethod x0
FUNCTION_START(REPLACEMENT_HOOK_TRAMPOLINE)
FUNCTION_START(REPLACEMENT_HOOK_TRAMPOLINE)
...
...
hooklib/src/main/java/com/swift/sandhook/SandHookMethodResolver.java
View file @
4cbbcb53
...
@@ -45,7 +45,6 @@ public class SandHookMethodResolver {
...
@@ -45,7 +45,6 @@ public class SandHookMethodResolver {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment