Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12181715
naughty_detector.py
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
zhuyifei1999
Jan 1 2018, 5:58 AM
2018-01-01 05:58:31 (UTC+0)
Size
830 B
Referenced Files
None
Subscribers
None
naughty_detector.py
View Options
#! /usr/bin/env python3
import
os
import
time
os
.
chdir
(
'/proc'
)
next_data
=
set
()
while
True
:
last_data
,
next_data
=
next_data
,
set
()
for
proc
in
os
.
listdir
():
try
:
int
(
proc
)
except
ValueError
:
continue
try
:
with
open
(
os
.
path
.
join
(
proc
,
'stat'
),
'rb'
)
as
f
:
data
=
f
.
read
()
.
split
(
b
' '
)
except
OSError
:
continue
if
data
[
2
]
==
b
'D'
:
try
:
with
open
(
os
.
path
.
join
(
proc
,
'cmdline'
),
'rb'
)
as
f
:
cmdline
=
repr
(
f
.
read
()
.
rstrip
(
b
'
\x00
'
)
.
split
(
b
'
\x00
'
))
except
OSError
:
cmdline
=
'(Unknown)'
v
=
proc
,
cmdline
next_data
.
add
(
v
)
if
v
in
last_data
:
print
(
'PID
%s
:
%s
'
%
v
)
time
.
sleep
(
10
)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5357655
Default Alt Text
naughty_detector.py (830 B)
Attached To
Mode
P6507 naughty_detector.py
Attached
Detach File
Event Timeline
Log In to Comment