Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12789581
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 25 2018, 5:13 PM
2018-01-25 17:13:29 (UTC+0)
Size
893 B
Referenced Files
None
Subscribers
None
naughty_detector.py
View Options
#! /usr/bin/env python3
import
datetime
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
(
'[
%s
] PID
%s
:
%s
'
%
((
datetime
.
datetime
.
now
()
.
isoformat
(),)
+
v
))
time
.
sleep
(
10
)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5436680
Default Alt Text
naughty_detector.py (893 B)
Attached To
Mode
P6507 naughty_detector.py
Attached
Detach File
Event Timeline
Log In to Comment