Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
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
Magisk
Commits
c9d4241a
Commit
c9d4241a
authored
Oct 03, 2016
by
Pierre-Hugues Husson
Committed by
topjohnwu
Oct 04, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PoC++ of hidesu
This uses logcat -b events to search for new process
parent
e1279c29
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
8 deletions
+62
-8
hidesu.c
jni/hidesu.c
+62
-8
No files found.
jni/hidesu.c
View file @
c9d4241a
typedef
unsigned
short
int
sa_family_t
;
//Linux includes
#define _LINUX_TIME_H
#define _GNU_SOURCE
#include <sched.h>
#include <sys/types.h>
#include <string.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <linux/connector.h>
#include <linux/cn_proc.h>
#include <linux/netlink.h>
#include <linux/fs.h>
#include <sys/socket.h>
#include <stdio.h>
#include <sys/mount.h>
#include <sys/syscall.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
2
)
exit
(
5
);
int
fd
=
open
(
argv
[
1
],
O_RDONLY
);
//WARNING: Calling this will change our current namespace
//We don't care because we don't want to run from here anyway
int
disableSu
(
int
pid
)
{
char
*
path
=
NULL
;
asprintf
(
&
path
,
"/proc/%d/ns/mnt"
,
pid
);
int
fd
=
open
(
path
,
O_RDONLY
);
if
(
fd
==
-
1
)
exit
(
2
);
//TODO: Fix non arm platforms
#define SYS_setns 375
...
...
@@ -18,5 +32,45 @@ int main(int argc, char **argv) {
//XXX: What to mount to /sbin...?
res
=
mount
(
"/system"
,
"/sbin"
,
"bind"
,
MS_BIND
,
""
);
if
(
res
==
-
1
)
exit
(
4
);
exit
(
0
);
return
0
;
}
int
main
(
int
argc
,
char
**
argv
,
char
**
envp
)
{
system
(
"logcat -b events -c"
);
FILE
*
p
=
popen
(
"logcat -b events -v raw -s am_proc_start"
,
"r"
);
while
(
!
feof
(
p
))
{
//Format of am_proc_start is (as of Android 5.1 and 6.0)
//UserID, pid, unix uid, processName, hostingType, hostingName
char
buffer
[
512
];
int
size
=
fgets
(
buffer
,
sizeof
(
buffer
),
p
);
{
char
*
pos
=
buffer
;
while
(
1
)
{
pos
=
index
(
pos
,
','
);
if
(
pos
==
NULL
)
break
;
pos
[
0
]
=
' '
;
}
}
int
user
,
pid
,
uid
;
char
processName
[
256
],
hostingType
[
16
],
hostingName
[
256
];
int
ret
=
sscanf
(
buffer
,
"[%d %d %d %256s %16s %256s]"
,
&
user
,
&
pid
,
&
uid
,
processName
,
hostingType
,
hostingName
);
if
(
ret
!=
6
)
{
printf
(
"sscanf returned %d on '%s'
\n
"
,
ret
,
buffer
);
exit
(
1
);
}
#define GMS_PROC "com.google.android.gms.unstable"
if
(
strcmp
(
processName
,
GMS_PROC
)
==
0
)
{
printf
(
"Disabling for PID = %d, UID = %d
\n
"
,
pid
,
uid
);
disableSu
(
pid
);
}
}
return
0
;
}
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