Download fulltext - DiVA Portal

Transcript
D
ms-scanner-clamav.py
max_mw_id = max_mw_id + 1
i d = max_mw_id
f i l e n a m e = b a s e n a m e ( mw_filename )
c h e c k s u m = s t r i n g . s p l i t ( b a s e n a m e ( mw_filename ) ,
".")[0]
f o r x in range ( len ( c i x ) ) :
if
c i x [ x ] == c h e c k s u m :
break
u r l = s t r i n g . s p l i t ( cdx [ x ] ) [ 2 ] . l o w e r ( )
size = 0
d a t e = s t r i n g . s p l i t ( cdx [ x ] ) [ 0 ]
d a t e S = d a t e [ : 4 ] + " −" + d a t e [ 4 : 6 ] + " −" + d a t e [ 6 : 8 ] + " " +
date [ 8 : 1 0 ] + ":" +
date [ 1 0 : 1 2 ] + ":" + date [ 1 2 : 1 4 ]
q="INSERT INTO b l a c k l i s t VALUES (% s , ' % s ' , ' % s ' , ' % s ' , ' % s ' ) " % (
i d , u r l , c h e c k s u m , d a t e S , mw_name)
db . q u e r y ( q )
db . c l o s e ( )
def
main ( ) :
if
( l e n ( sys . argv )
usage ( )
sys . exit (2)
if
not os . path . e x i s t s ( s y s . argv [ 1 ] ) :
p r i n t " E r r o r : Path d o e s n o t e x i s t
sys . exit (2)
if
!=
2):
or
don ' t
have
the
needed
not os . path . i s d i r ( s y s . argv [ 1 ] ) :
usage ( )
sys . exit (2)
#c h d i r t o w h e r e t h e a r c
workdir = sys . argv [ 1 ]
os . chdir ( workdir )
print
' Scanning
folder
#S c a n d i r e c t o r y w i t h
os . system (" clamdscan
os . system (" clamdscan
file
%s
for
resides
viruses
with
print
ClamAV '
% workdir ,
c l a m a v and g e n e r a t e r e p o r t
file
−V > c l a m a v . r e p o r t " )
| g r e p FOUND >> c l a m a v . r e p o r t " )
parseReportFile ()
if
you
'. '
__name__ == "__main__ " :
main ( )
49
permissions "