Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pyrasite
Commits
9f27706e
Commit
9f27706e
authored
Mar 24, 2012
by
Luke Macken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a ptrace check in our CLI
parent
275fbbf0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
3 deletions
+29
-3
pyrasite/main.py
pyrasite/main.py
+29
-3
No files found.
pyrasite/main.py
View file @
9f27706e
...
...
@@ -18,15 +18,41 @@
import
os
import
sys
import
argparse
import
subprocess
import
pyrasite
def
ptrace_check
():
ptrace_scope
=
'/proc/sys/kernel/yama/ptrace_scope'
if
os
.
path
.
exists
(
ptrace_scope
):
f
=
open
(
ptrace_scope
)
value
=
int
(
f
.
read
().
strip
())
f
.
close
()
if
value
==
1
:
print
(
"WARNING: ptrace is disabled. Injection will not work."
)
print
(
"You can enable it by running the following:"
)
print
(
"echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope"
)
print
(
""
)
else
:
getsebool
=
'/usr/sbin/getsebool'
if
os
.
path
.
exists
(
getsebool
):
p
=
subprocess
.
Popen
([
getsebool
,
'deny_ptrace'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
if
out
.
decode
(
'utf-8'
)
==
u'deny_ptrace --> off
\
n
'
:
print
(
"WARNING: ptrace is disabled. Injection will not work."
)
print
(
"You can enable it by running the following:"
)
print
(
"sudo setsebool -P deny_ptrace=off"
)
print
(
""
)
def
main
():
ptrace_check
()
parser
=
argparse
.
ArgumentParser
(
description
=
'pyrasite - inject code into a running python process'
,
epilog
=
"For updates, visit https://github.com/lmacken/pyrasite"
)
description
=
'pyrasite - inject code into a running python process'
,
epilog
=
"For updates, visit https://github.com/lmacken/pyrasite"
)
parser
.
add_argument
(
'pid'
,
help
=
"The ID of the process to inject code into"
)
parser
.
add_argument
(
'filename'
,
...
...
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