From d6661784bfc201eb5bdbddf40724b1684a2d32c3 Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Fri, 11 Dec 2015 14:22:28 +0000 Subject: [PATCH] Create parent directory & multi folders with fsctl.py --- utils/fsctl.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/utils/fsctl.py b/utils/fsctl.py index c3a4461..f42beaa 100755 --- a/utils/fsctl.py +++ b/utils/fsctl.py @@ -1,21 +1,22 @@ #!/usr/bin/python -############################################################### +################################################################ # This program creates a command line interpreter used to edit # cowrie file system pickle files. # -# It is intended to mimic a basic bash shell and supports relative -# file references. +# It is intended to mimic a basic bash shell and supports +# relative file references. # -# This isn't meant to build a brand new file system. Instead it -# should be used to edit existing file systems such as the default -# /opt/cowrie/data/fs.pickle. +# Do not use to build a complete file system. Use: +# /opt/cowrie/utils/createfs.py +# Instead it should be used to edit existing file systems +# such as the default: /opt/cowrie/data/fs.pickle. # # Donovan Hubbard # Douglas Hubbard # March 2013 # -############################################################### +################################################################ import os, pickle, sys, locale, time, cmd from stat import * @@ -241,13 +242,14 @@ class fseditCmd(cmd.Cmd): def do_mkdir(self, args): """Add a new directory in the target directory. Handles relative or absolute file paths. \n - Usage: mkdir """ + Usage: mkdir ...""" arg_list=args.split() - if len(arg_list) != 1: - print "usage: mkdir " + if len(arg_list) < 1: + print "usage: mkdir ..." else: - self.mkfile(arg_list, T_DIR) + for arg in arg_list: + self.mkfile(arg.split(), T_DIR) def do_touch(self, args): """Add a new file in the target directory. @@ -270,10 +272,9 @@ class fseditCmd(cmd.Cmd): fileName = pathList[len(pathList) - 1] if not exists(self.fs, parentdir): - print ('Parent directory %s doesn\'t exist! ' + - 'Please create it first.') % \ + print ('Parent directory %s doesn\'t exist!') % \ (parentdir,) - return + self.mkfile(parentdir.split(), T_DIR) if exists(self.fs, path): print 'Error: %s already exists!' % (path,)