#NEWLINE# def __init__( self , protocol , * args ) : #NEWLINE# #INDENT# self . protocol = protocol #NEWLINE# self . args = list ( args ) #NEWLINE# self . environ = args . protocol . cmdstack [ 0 ] . environ #NEWLINE# self . fs = self . protocol . fs #NEWLINE# if ( '>' in self . args ) : #NEWLINE# #INDENT# self . writtenBytes = 0 #NEWLINE# self . write = self . writeToFile #NEWLINE# index = self . args . index ( '>' ) #NEWLINE# self . outfile = self . fs . resolve_path ( str ( self . args [ ( index + 1 ) ] ) , self . protocol . cwd ) #NEWLINE# del self . args [ index : ] #NEWLINE# self . safeoutfile = ( '%s/%s-%s-%s-redir_%s' % ( self . protocol . cfg . get ( 'honeypot' , 'download_path' ) , time . strftime ( '%Y%m%d-%H%M%S' ) , self . protocol . terminal . transport . session . conn . transport . transportId , self . protocol . terminal . transport . session . id , re . sub ( '[^A-Za-z0-9]' , '_' , self . outfile ) ) ) #NEWLINE# perm = ( ( ( stat . S_IRUSR | stat . S_IWUSR ) | stat . S_IRGRP ) | stat . S_IROTH ) #NEWLINE# self . fs . mkfile ( self . outfile , 0 , 0 , 0 , ( stat . S_IFREG | perm ) ) #NEWLINE# with open ( self . safeoutfile , 'a' ) : #NEWLINE# #INDENT# self . fs . update_realfile ( self . fs . getfile ( self . outfile ) , self . safeoutfile ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . write = self . protocol . terminal . write