From 7324bc4c7b0ff7685ffd75d9228383f7070375ef Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Tue, 8 Dec 2015 12:04:35 +0400 Subject: [PATCH] don't call terminal functions directly --- cowrie/commands/curl.py | 5 +---- cowrie/commands/scp.py | 20 ++++++++++---------- cowrie/commands/wget.py | 6 +++--- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/cowrie/commands/curl.py b/cowrie/commands/curl.py index f38a150..2154ba7 100644 --- a/cowrie/commands/curl.py +++ b/cowrie/commands/curl.py @@ -234,8 +234,6 @@ class HTTPProgressDownloader(client.HTTPDownloader): (self.curl.url,)) self.fileName = os.path.devnull self.nomore = True - #self.curl.writeln('Saving to: `%s' % self.fakeoutfile) - #self.curl.protocol.terminal.nextLine() if self.fakeoutfile: self.curl.writeln(' % Total % Received % Xferd Average Speed Time Time Time Current') @@ -293,10 +291,9 @@ class HTTPProgressDownloader(client.HTTPDownloader): # self.fakeoutfile, self.currentlength, self.totallength)) if self.fakeoutfile: - self.curl.write("\r100 %d 100 %d 0 0 %d 0 --:--:-- --:--:-- --:--:-- %d" % \ + self.curl.writeln("\r100 %d 100 %d 0 0 %d 0 --:--:-- --:--:-- --:--:-- %d" % \ (self.currentlength, self.currentlength , 63673, 65181) ) - self.curl.protocol.terminal.nextLine() self.curl.fs.mkfile(self.fakeoutfile, 0, 0, self.totallength, 33188) self.curl.fs.update_realfile( diff --git a/cowrie/commands/scp.py b/cowrie/commands/scp.py index ea9c99b..9e366f5 100644 --- a/cowrie/commands/scp.py +++ b/cowrie/commands/scp.py @@ -46,16 +46,16 @@ class command_scp(HoneyPotCommand): self.help() self.exit() return - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) - self.protocol.terminal.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) + self.write( '\x00' ) def lineReceived(self, line): log.msg( eventid='KIPP0008', realm='scp', input=line, diff --git a/cowrie/commands/wget.py b/cowrie/commands/wget.py index a7b70ae..cee1716 100644 --- a/cowrie/commands/wget.py +++ b/cowrie/commands/wget.py @@ -243,7 +243,7 @@ class HTTPProgressDownloader(client.HTTPDownloader): self.nomore = True if self.quiet == False: self.wget.writeln('Saving to: `%s' % self.fakeoutfile) - self.wget.protocol.terminal.nextLine() + self.wget.nextLine() return client.HTTPDownloader.gotHeaders(self, headers) @@ -290,8 +290,8 @@ class HTTPProgressDownloader(client.HTTPDownloader): ('%s>' % (38 * '='), splitthousands(str(int(self.totallength))).ljust(12), self.speed / 1000)) - self.wget.protocol.terminal.nextLine() - self.wget.protocol.terminal.nextLine() + self.wget.nextLine() + self.wget.nextLine() self.wget.writeln( '%s (%d KB/s) - `%s\' saved [%d/%d]' % \ (time.strftime('%Y-%m-%d %H:%M:%S'),