mirror of
https://github.com/aljazceru/cowrie.git
synced 2025-12-24 01:14:27 +01:00
create full directory paths if needed when untarring
git-svn-id: https://kippo.googlecode.com/svn/trunk@153 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
@@ -9,6 +9,13 @@ import time, random, tarfile, os
|
|||||||
commands = {}
|
commands = {}
|
||||||
|
|
||||||
class command_tar(HoneyPotCommand):
|
class command_tar(HoneyPotCommand):
|
||||||
|
def mkfullpath(self, path, f):
|
||||||
|
l, d = path.split('/'), []
|
||||||
|
while len(l):
|
||||||
|
d.append(l.pop(0))
|
||||||
|
if not self.fs.exists('/'.join(d)):
|
||||||
|
self.fs.mkdir('/'.join(d), 0, 0, 4096, f.mode, f.mtime)
|
||||||
|
|
||||||
def call(self):
|
def call(self):
|
||||||
if len(self.args) < 2:
|
if len(self.args) < 2:
|
||||||
self.writeln('tar: You must specify one of the `-Acdtrux\' options')
|
self.writeln('tar: You must specify one of the `-Acdtrux\' options')
|
||||||
@@ -57,9 +64,7 @@ class command_tar(HoneyPotCommand):
|
|||||||
if f.isdir():
|
if f.isdir():
|
||||||
self.fs.mkdir(dest, 0, 0, 4096, f.mode, f.mtime)
|
self.fs.mkdir(dest, 0, 0, 4096, f.mode, f.mtime)
|
||||||
elif f.isfile():
|
elif f.isfile():
|
||||||
if not self.fs.exists(os.path.dirname(dest)):
|
self.mkfullpath(os.path.dirname(dest), f)
|
||||||
self.fs.mkdir(os.path.dirname(dest),
|
|
||||||
0, 0, 4096, f.mode, f.mtime)
|
|
||||||
self.fs.mkfile(dest, 0, 0, f.size, f.mode, f.mtime)
|
self.fs.mkfile(dest, 0, 0, f.size, f.mode, f.mtime)
|
||||||
self.honeypot.commands[dest] = random.choice(dice.clist)
|
self.honeypot.commands[dest] = random.choice(dice.clist)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user