Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
4lDO2
acid
Commits
532621cb
Verified
Commit
532621cb
authored
Jul 17, 2019
by
jD91mZM2
Browse files
WIP(ptrace): Test ptrace security
parent
666e28d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main.rs
View file @
532621cb
...
...
@@ -132,7 +132,8 @@ pub fn ptrace() -> Result<(), String> {
}
}
println!
(
"Waiting until child is ready to be traced..."
);
println!
(
"My PID: {}"
,
e
(
syscall
::
getpid
())
?
);
println!
(
"Waiting until child (pid {}) is ready to be traced..."
,
pid
);
let
mut
status
=
0
;
e
(
syscall
::
waitpid
(
pid
,
&
mut
status
,
syscall
::
WUNTRACED
))
?
;
...
...
@@ -245,6 +246,15 @@ pub fn ptrace() -> Result<(), String> {
assert
!
(
syscall
::
wifexited
(
status
));
assert_eq!
(
syscall
::
wexitstatus
(
status
),
123
);
println!
(
"Trying to do illegal things..."
);
for
id
in
0
..=
1_000_000
{
let
err
=
File
::
open
(
format!
(
"proc:{}/regs/int"
,
id
))
.map
(|
_
|
None
)
.unwrap_or_else
(|
err
|
err
.raw_os_error
());
assert
!
(
err
==
Some
(
syscall
::
EPERM
)
||
err
==
Some
(
syscall
::
ESRCH
),
"The cops ignored that I tried to illegally open PID {}: {:?}"
,
id
,
err
);
}
println!
(
"All done and tested!"
);
Ok
(())
...
...
Write
Preview
Supports
Markdown
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