#NEWLINE# def success( self , data , outfile ) : #NEWLINE# #INDENT# if ( not os . path . isfile ( self . safeoutfile ) ) : #NEWLINE# #INDENT# log . msg ( ( "there's no file " + self . safeoutfile ) ) #NEWLINE# self . exit ( ) #NEWLINE# #UNINDENT# shasum = hashlib . sha256 ( open ( self . safeoutfile , 'rb' ) . read ( ) ) . hexdigest ( ) #NEWLINE# hash_path = ( '%s/%s' % ( self . download_path , shasum ) ) #NEWLINE# if ( not os . path . exists ( hash_path ) ) : #NEWLINE# #INDENT# os . rename ( self . safeoutfile , hash_path ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# os . remove ( self . safeoutfile ) #NEWLINE# log . msg ( ( 'Not storing duplicate content ' + shasum ) ) #NEWLINE# #UNINDENT# self . protocol . logDispatch ( eventid = 'cowrie.session.file_download' , format = 'Downloaded URL (%(url)s) with SHA-256 %(shasum)s to %(outfile)s' , url = self . url , outfile = hash_path , shasum = shasum ) #NEWLINE# log . msg ( eventid = 'cowrie.session.file_download' , format = 'Downloaded URL (%(url)s) with SHA-256 %(shasum)s to %(outfile)s' , url = self . url , outfile = hash_path , shasum = shasum ) #NEWLINE# os . symlink ( shasum , self . safeoutfile ) #NEWLINE# self . safeoutfile = hash_path #NEWLINE# f = self . fs . getfile ( outfile ) #NEWLINE# f [ A_REALFILE ] = hash_path #NEWLINE# self . exit ( )