def run_netcat(self, path, host, port): """ Test run with netcat """ time.sleep(self.SLEEPTIME) flags = self.get_flags('nofile', 0) command = 'echo %s is sending %s with flags "%s" | nc %s %s' % (self.whoami, path, ' '.join(flags), host, port) return RunAsyncLoopLog.run(command)
def run_netcat(self, path, host, port): """ Test run with netcat """ time.sleep(self.SLEEPTIME) flags = self.get_flags('nofile', 0) command = 'echo %s is sending %s with flags "%s" | nc %s %s' % ( self.whoami, path, ' '.join(flags), host, port) return RunAsyncLoopLog.run(command)
def attempt_run(self, command, queue_path, attempts=3): """ Try to run a command x times, on failure add to failed queue """ attempt = 1 while (attempt <= attempts): code, output = RunAsyncLoopLog.run(command) if code == 0: self.completed_queue.put(queue_path) return code, output else: attempt += 1 self.log.error('There were issues with path %s!' % queue_path) self.failed_queue.put(queue_path) return 0, output # otherwise client get stuck
def run_rsync(self, encpath, host, port): """ Runs the rsync command with or without recursion, delete or dry-run option. It uses the destination module linked with this session. """ path, recursive = decode_path(encpath) gfile = self.generate_file(path) flags = self.get_flags(gfile, recursive) self.log.info('%s is sending path %s to %s %s' % (self.whoami, path, host, port)) self.log.debug('Used flags: "%s"' % ' '.join(flags)) command = 'rsync %s %s/ rsync://%s:%s/%s' % (' '.join(flags), self.rsyncpath, host, port, self.module) code, output = RunAsyncLoopLog.run(command) os.remove(gfile) parsed = self.parse_output(output) return code, parsed
def run_rsync(self, encpath, host, port): """ Runs the rsync command with or without recursion, delete or dry-run option. It uses the destination module linked with this session. """ path, recursive = decode_path(encpath) gfile = self.generate_file(path) flags = self.get_flags(gfile, recursive) self.log.info('%s is sending path %s to %s %s' % (self.whoami, path, host, port)) self.log.debug('Used flags: "%s"' % ' '.join(flags)) command = 'rsync %s %s/ rsync://%s:%s/%s' % ( ' '.join(flags), self.rsyncpath, host, port, self.module) code, output = RunAsyncLoopLog.run(command) os.remove(gfile) parsed = self.parse_output(output) return code, parsed
def run_rsync(self, encpath, host, port): """ Runs the rsync command with or without recursion, delete or dry-run option. It uses the destination module linked with this session. """ path, recursive = decode_path(encpath) file = self.generate_file(path) # Start rsync recursive or non recursive; archive mode (a) is equivalent to -rlptgoD (see man rsync) flags = ['--stats', '--numeric-ids', '-lptgoD', '--files-from=%s' % file] if recursive: flags.append('-r') if self.rsync_delete: flags.append('--delete') if self.rsync_dry: flags.append('-n') self.log.debug('echo %s is sending %s to %s %s' % (self.whoami, path, host, port)) command = 'rsync %s %s/ rsync://%s:%s/%s' % (' '.join(flags), self.rsyncpath, host, port, self.module) code, output = RunAsyncLoopLog.run(command) os.remove(file) return code, output
def run_netcat(self, path, host, port): """ Test run with netcat """ time.sleep(self.SLEEPTIME) command = 'echo %s is sending %s | nc %s %s' % (self.whoami, path, host, port) return RunAsyncLoopLog.run(command)