diff --git a/cowrie/commands/__init__.py b/cowrie/commands/__init__.py index e9663001..da471a26 100644 --- a/cowrie/commands/__init__.py +++ b/cowrie/commands/__init__.py @@ -10,6 +10,7 @@ __all__ = [ 'dice', 'env', 'ethtool', + 'free', 'fs', 'gcc', 'ifconfig', diff --git a/cowrie/commands/free.py b/cowrie/commands/free.py new file mode 100644 index 00000000..5abf47f9 --- /dev/null +++ b/cowrie/commands/free.py @@ -0,0 +1,59 @@ +# + +import getopt + +from cowrie.core.honeypot import HoneyPotCommand + +commands = {} + +class command_free(HoneyPotCommand): + """ + free + """ + def call(self): + """ + """ + # Parse options or display no files + try: + opts, args = getopt.getopt(self.args, 'mh') + except getopt.GetoptError as err: + self.no_files() + return + + # Parse options + for o, a in opts: + if o in ('-h'): + self.free(format='human') + return + elif m in ('-m'): + self.free(format='megabytes') + return + self.free() + + def free(format='bytes') + """ + print free statistics + """ + + if (format eq 'bytes'): + self.writeln( +""" total used free shared buffers cached +Mem: 8069256 7872920 196336 0 410340 5295748 +-/+ buffers/cache: 2166832 5902424 +Swap: 3764220 133080 3631140""") + elif (format eq 'megabytes'): + self.writeln( +""" total used free shared buffers cached +Mem: 7880 7690 189 0 400 5171 +-/+ buffers/cache: 2118 5761 +Swap: 3675 129 3546""") + elif (format eq 'human'): + self.writeln( +""" total used free shared buffers cached +Mem: 7.7G 7.5G 189M 0B 400M 5.1G +-/+ buffers/cache: 2.1G 5.6G +Swap: 3.6G 129M 3.5G""") + self.exit() + +commands['/usr/bin/free'] = command_free + diff --git a/txtcmds/usr/bin/free b/txtcmds/usr/bin/free deleted file mode 100644 index 7bfa75a9..00000000 --- a/txtcmds/usr/bin/free +++ /dev/null @@ -1,4 +0,0 @@ - total used free shared buffers cached -Mem: 242 238 3 0 15 64 --/+ buffers/cache: 159 83 -Swap: 342 76 266