def __hackersh_preprocessor(source, sym_tbl): orig_source = source # i.e. nmap if source in sym_tbl and not isinstance(sym_tbl[source], types.FunctionType): source = "%s()" % source # i.e. /usr/bin/nmap or ./nmap if source.startswith('/') or source.startswith('./') or source.startswith( '../'): expression_cmd = shlex.split(source) external_component_path = os.path.abspath(expression_cmd[0]) external_component_name = os.path.splitext( os.path.basename(external_component_path))[0] external_component_kwargs = '**{}' # External binary? (i.e. /bin/ls) if external_component_name not in sym_tbl: if not os.path.isfile(external_component_path): external_component_path = miscellaneous.which( expression_cmd[0])[0] if not external_component_path: print '%s: command not found' % expression_cmd[0] return False external_component_kwargs = "**{'path':'%s'}" % external_component_path external_component_name = "system" external_component_args = "*(%s)" % ','.join( __quotes_wrap(expression_cmd[1:]) + [' ']) source = "%s(%s, %s)" % (external_component_name, external_component_args, external_component_kwargs) # print '%s => %s' % (orig_source, source) return source
def __hackersh_preprocessor(source, sym_tbl): orig_source = source # i.e. nmap if source in sym_tbl and not isinstance(sym_tbl[source], types.FunctionType): source = "%s()" % source # i.e. /usr/bin/nmap or ./nmap if source.startswith('/') or source.startswith('./') or source.startswith('../'): expression_cmd = shlex.split(source) external_component_path = os.path.abspath(expression_cmd[0]) external_component_name = os.path.splitext(os.path.basename(external_component_path))[0] external_component_kwargs = '**{}' # External binary? (i.e. /bin/ls) if external_component_name not in sym_tbl: if not os.path.isfile(external_component_path): external_component_path = miscellaneous.which(expression_cmd[0])[0] if not external_component_path: print '%s: command not found' % expression_cmd[0] return False external_component_kwargs = "**{'path':'%s'}" % external_component_path external_component_name = "system" external_component_args = "*(%s)" % ','.join(__quotes_wrap(expression_cmd[1:]) + [' ']) source = "%s(%s, %s)" % (external_component_name, external_component_args, external_component_kwargs) # print '%s => %s' % (orig_source, source) return source
def run(self, argv, context): filename = self._kwargs.get('filename', self.DEFAULT_FILENAME) self.logger.debug('FILENAME = ' + filename) path = miscellaneous.which(filename)[:1] if not path: self.logger.debug("NO PATH!") raise exceptions.HackershError(context, "%s: command not found" % self._kwargs.get('filename', self.DEFAULT_FILENAME)) self.logger.debug('PATH = ' + path[0]) return self._processor(context, self._execute(path + argv, context))
def run(self, argv, context): filename = self._kwargs.get("filename", self.DEFAULT_FILENAME) self.logger.debug("FILENAME = " + filename) path = miscellaneous.which(filename)[:1] if not path: self.logger.debug("NO PATH!") raise exceptions.HackershError( context, "%s: command not found" % self._kwargs.get("filename", self.DEFAULT_FILENAME) ) self.logger.debug("PATH = " + path[0]) return self._processor(context, self._execute(path + argv, context))
def run(self, argv, context): return self._processor(context, self._execute(miscellaneous.which(self._kwargs.get('filename', self.DEFAULT_FILENAME))[:1] + argv, context))