<s> from impacket . smb3structs import FILE_READ_DATA , FILE_WRITE_DATA <EOL> class RemoteFile : <EOL> def __init__ ( self , smbConnection , fileName , share = '<STR_LIT>' , access = FILE_READ_DATA | FILE_WRITE_DATA ) : <EOL> self . __smbConnection = smbConnection <EOL> self . __share = share <EOL> self . __access = access <EOL> self . __fileName = fileName <EOL> self . __tid = self . __smbConnection . connectTree ( share ) <EOL> self . __fid = None <EOL> self . __currentOffset = <NUM_LIT:0> <EOL> def open ( self ) : <EOL> self . __fid = self . __smbConnection . openFile ( self . __tid , self . __fileName , desiredAccess = self . __access ) <EOL> def seek ( self , offset , whence ) : <EOL> if whence == <NUM_LIT:0> : <EOL> self . __currentOffset = offset <EOL> def read ( self , bytesToRead ) : <EOL> if bytesToRead > <NUM_LIT:0> : <EOL> data = self . __smbConnection . readFile ( self . __tid , self . __fid , self . __currentOffset , bytesToRead ) <EOL> self . __currentOffset += len ( data ) <EOL> return data <EOL> return '<STR_LIT>' <EOL> def close ( self ) : <EOL> if self . __fid is not None : <EOL> self . __smbConnection . closeFile ( self . __tid , self . __fid ) <EOL> self . __fid = None <EOL> def delete ( self ) : <EOL> self . __smbConnection . deleteFile ( self . __share , self . __fileName ) <EOL> def tell ( self ) : <EOL> return self . __currentOffset <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . __smbConnection . getRemoteHost ( ) , self . __share , self . __fileName ) </s>
