mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-17 05:54:21 +01:00
add 'free' command to replace txtcmd
This commit is contained in:
@@ -10,6 +10,7 @@ __all__ = [
|
|||||||
'dice',
|
'dice',
|
||||||
'env',
|
'env',
|
||||||
'ethtool',
|
'ethtool',
|
||||||
|
'free',
|
||||||
'fs',
|
'fs',
|
||||||
'gcc',
|
'gcc',
|
||||||
'ifconfig',
|
'ifconfig',
|
||||||
|
|||||||
59
cowrie/commands/free.py
Normal file
59
cowrie/commands/free.py
Normal file
@@ -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
|
||||||
|
|
||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user