From f1bb384290b34ee02e40d61d95d8ec7a6a70cd4d Mon Sep 17 00:00:00 2001 From: Michel Oosterhof Date: Thu, 24 Dec 2015 10:00:08 +0000 Subject: [PATCH] use local write(ln), not protocol.write(ln) --- cowrie/commands/ethtool.py | 8 ++++---- cowrie/commands/ifconfig.py | 2 +- cowrie/commands/netstat.py | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cowrie/commands/ethtool.py b/cowrie/commands/ethtool.py index c6fbfb4..abe9736 100644 --- a/cowrie/commands/ethtool.py +++ b/cowrie/commands/ethtool.py @@ -20,15 +20,15 @@ class command_ethtool(HoneyPotCommand): def do_ethtool_help(self): """No real help output.""" - self.protocol.writeln("""ethtool: bad command line argument(s) + self.writeln("""ethtool: bad command line argument(s) For more information run ethtool -h """) def do_ethtool_lo(self): - self.protocol.writeln("""Settings for lo: + self.writeln("""Settings for lo: Link detected: yes""") def do_ethtool_eth0(self): - self.protocol.writeln("""Settings for eth0: + self.writeln("""Settings for eth0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full @@ -58,7 +58,7 @@ Current message level: 0x00000033 (51) Link detected: yes""") def do_ethtool_eth1(self): - self.protocol.writeln("""Settings for eth1: + self.writeln("""Settings for eth1: Cannot get device settings: No such device Cannot get wake-on-lan settings: No such device Cannot get message level: No such device diff --git a/cowrie/commands/ifconfig.py b/cowrie/commands/ifconfig.py index 3c2c4b8..e543043 100644 --- a/cowrie/commands/ifconfig.py +++ b/cowrie/commands/ifconfig.py @@ -29,7 +29,7 @@ lo Link encap:Local Loopback RX bytes:19932 (19.9 KB) TX bytes:19932 (19.9 KB)""" % \ (self.protocol.kippoIP, self.protocol.kippoIP.rsplit('.', 1)[0]) - self.protocol.writeln(l) + self.writeln(l) commands['/sbin/ifconfig'] = command_ifconfig diff --git a/cowrie/commands/netstat.py b/cowrie/commands/netstat.py index f0dca42..89669ea 100644 --- a/cowrie/commands/netstat.py +++ b/cowrie/commands/netstat.py @@ -53,7 +53,7 @@ usage: netstat [-vWeenNcCF] [] -r netstat {-V|--version|-h|--help} x25 (CCITT X.25)""") def do_netstat_route(self): - self.protocol.writeln("""Kernel IP routing table + self.writeln("""Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface""") if self.show_numeric: default = "default" @@ -69,11 +69,11 @@ Destination Gateway Genmask Flags MSS Window irtt Iface"" l2 = "%s%s255.255.255.0 U 0 0 0 eth0" % \ ('{:<16}'.format(destination), '{:<16}'.format(lgateway)) - self.protocol.writeln(l1) - self.protocol.writeln(l2) + self.writeln(l1) + self.writeln(l2) def do_netstat_normal(self): - self.protocol.writeln("""Active Internet connections (w/o servers) + self.writeln("""Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State""") s_name = self.protocol.hostname c_port = str(self.protocol.realClientPort) @@ -85,24 +85,24 @@ Proto Recv-Q Send-Q Local Address Foreign Address State""") s_port = "ssh" c_name = socket.gethostbyaddr(self.protocol.clientIP)[0][:17] if self.show_listen or self.show_all: - self.protocol.writeln("tcp 0 0 *:ssh *:* LISTEN") + self.writeln("tcp 0 0 *:ssh *:* LISTEN") if not self.show_listen or self.show_all: l = 'tcp 0 308 %s:%s%s%s:%s%s%s' % \ (s_name, s_port, " "*(24-len(s_name+s_port)-1), c_name, c_port, " "*(24-len(c_name+c_port)-1), "ESTABLISHED") - self.protocol.writeln(l) + self.writeln(l) if self.show_listen or self.show_all: - self.protocol.writeln("tcp6 0 0 [::]:ssh [::]:* LISTEN") - self.protocol.writeln("""Active UNIX domain sockets (only servers) + self.writeln("tcp6 0 0 [::]:ssh [::]:* LISTEN") + self.writeln("""Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node Path""") if self.show_listen: - self.protocol.writeln("""unix 2 [ ACC ] STREAM LISTENING 8969 /var/run/acpid.socket + self.writeln("""unix 2 [ ACC ] STREAM LISTENING 8969 /var/run/acpid.socket unix 2 [ ACC ] STREAM LISTENING 6807 @/com/ubuntu/upstart unix 2 [ ACC ] STREAM LISTENING 7299 /var/run/dbus/system_bus_socket unix 2 [ ACC ] SEQPACKET LISTENING 7159 /run/udev/control""") elif self.show_all: - self.protocol.writeln("""unix 2 [ ACC ] STREAM LISTENING 8969 /var/run/acpid.socket + self.writeln("""unix 2 [ ACC ] STREAM LISTENING 8969 /var/run/acpid.socket unix 4 [ ] DGRAM 7445 /dev/log unix 2 [ ACC ] STREAM LISTENING 6807 @/com/ubuntu/upstart unix 2 [ ACC ] STREAM LISTENING 7299 /var/run/dbus/system_bus_socket @@ -124,7 +124,7 @@ unix 3 [ ] DGRAM 7198 unix 2 [ ] DGRAM 9570 unix 3 [ ] STREAM CONNECTED 8619 @/com/ubuntu/upstart""") else: - self.protocol.writeln("""unix 4 [ ] DGRAM 7445 /dev/log + self.writeln("""unix 4 [ ] DGRAM 7445 /dev/log unix 3 [ ] STREAM CONNECTED 7323 unix 3 [ ] STREAM CONNECTED 7348 /var/run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 7330