def _probe(self): if not self.support_vectors.get('exists').execute({ 'rpath' : self.args['remote_mount'] }): raise ProbeException(self.name, '%s \'%s\'' % (WARN_HTTPFS_MOUNTPOINT, self.args['remote_mount'])) self.args['remote_mount'] = self.support_vectors.get('normalize').execute({ 'path' : self.args['remote_mount'] }) if self.args['umount_all']: # Umount all httpfs partitions self.__umount_all() raise ProbeSucceed(self.name, 'Unmounted partitions') if not self.args['just_mount']: # Upload remote try: Upload2web._probe(self) except ProbeSucceed: pass if not self.args['just_install']: if not self.args['local_mount']: self.args['local_mount'] = mkdtemp() cmd = '%s mount %s %s %s' % (self.args['httpfs_path'], self.args['url'], self.args['local_mount'], self.args['remote_mount']) status, output = getstatusoutput(cmd) if status == 0: if output: raise ProbeException(self.name,'%s\nCOMMAND:\n$ %s\nOUTPUT:\n> %s\n%s' % (WARN_HTTPFS_OUTP, cmd, output.replace('\n', '\n> '), WARN_HTTPFS_CHECK)) else: raise ProbeException(self.name,'%s\nCOMMAND:\n$ %s\nOUTPUT:\n> %s\n%s' % (WARN_HTTPFS_RUN, cmd, output.replace('\n', '\n> '), WARN_HTTPFS_CHECK))
def _stringify_result(self): Upload2web._stringify_result(self) sess_filename = os.path.join( *(self.args['rpath'].split('/')[:-1] + ['sess_*'])) self._output = """Php proxy installed, point your browser to %s?u=http://www.google.com . Delete '%s' and '%s' at session end.""" % ( self.args['url'], self.args['rpath'], sess_filename )
def _stringify_result(self): Upload2web._stringify_result(self) sess_filename = os.path.join(*(self.args['rpath'].split('/')[:-1] + ['sess_*'])) self._output = """Php proxy installed, point your browser to %s?u=http://www.google.com . Delete '%s' and '%s' at session end.""" % (self.args['url'], self.args['rpath'], sess_filename)
def _output_result(self): Upload2web._output_result(self) sess_filename = os.path.join(*(self.args["rpath"].split("/")[:-1] + ["sess_*"])) self._output = """Php proxy installed, point your browser to %s?u=http://www.google.com . Delete '%s' and '%s' at session end.""" % ( self.args["url"], self.args["rpath"], sess_filename, )
def _prepare(self): self.__check_httpfs() # If not umount or just-mount URL, try installation if not self.args['umount_all'] and not self.args['just_mount']: self.__generate_httpfs() Upload2web._prepare(self) # If just mount, set remote url elif self.args['just_mount']: self.args['url'] = self.args['just_mount']
def _probe(self): if not self.support_vectors.get("exists").execute({"rpath": self.args["remote_mount"]}): raise ProbeException(self.name, "%s '%s'" % (WARN_HTTPFS_MOUNTPOINT, self.args["remote_mount"])) self.args["remote_mount"] = self.support_vectors.get("normalize").execute({"path": self.args["remote_mount"]}) if self.args["umount_all"]: # Umount all httpfs partitions self.__umount_all() raise ProbeSucceed(self.name, "Unmounted partitions") if not self.args["just_mount"]: # Upload remote try: Upload2web._probe(self) except ProbeSucceed: pass if not self.args["just_install"]: if not self.args["local_mount"]: self.args["local_mount"] = mkdtemp() cmd = "%s mount %s %s %s" % ( self.args["httpfs_path"], self.args["url"], self.args["local_mount"], self.args["remote_mount"], ) status, output = getstatusoutput(cmd) if status == 0: if output: raise ProbeException( self.name, "%s\nCOMMAND:\n$ %s\nOUTPUT:\n> %s\n%s" % (WARN_HTTPFS_OUTP, cmd, output.replace("\n", "\n> "), WARN_HTTPFS_CHECK), ) else: raise ProbeException( self.name, "%s\nCOMMAND:\n$ %s\nOUTPUT:\n> %s\n%s" % (WARN_HTTPFS_RUN, cmd, output.replace("\n", "\n> "), WARN_HTTPFS_CHECK), )
def _set_vectors(self): Upload2web._set_vectors(self) self.support_vectors.add_vector("exists", 'file.check', "$rpath exists".split(' '))
def _verify(self): # Verify Install if not self.args['umount_all'] and not self.args['just_mount']: Upload2web._verify(self)
# If no rpath, set content and remote final filename as random try: content = open(proxy_path, "r").read() except Exception, e: raise ProbeException(self.name, "'%s' %s" % (self.args["lpath"], WARN_NO_SUCH_FILE)) self.args["lpath"] = randstr(4) + ".php" self.args["content"] = content else: # Else, set lpath as proxy filename self.args["lpath"] = proxy_path self.args["content"] = None Upload2web._prepare(self) def _stringify_result(self): Upload2web._stringify_result(self) sess_filename = os.path.join(*(self.args["rpath"].split("/")[:-1] + ["sess_*"])) self._output = """Php proxy installed, point your browser to %s?u=http://www.google.com . Delete '%s' and '%s' at session end.""" % ( self.args["url"], self.args["rpath"], sess_filename, )
def _verify(self): # Verify Install if not self.args["umount_all"] and not self.args["just_mount"]: Upload2web._verify(self)
# If no rpath, set content and remote final filename as random try: content = open(proxy_path, 'r').read() except Exception, e: raise ProbeException( self.name, '\'%s\' %s' % (self.args['lpath'], WARN_NO_SUCH_FILE)) self.args['lpath'] = randstr(4) + '.php' self.args['content'] = content else: # Else, set lpath as proxy filename self.args['lpath'] = proxy_path self.args['content'] = None Upload2web._prepare(self) def _stringify_result(self): Upload2web._stringify_result(self) sess_filename = os.path.join(*(self.args['rpath'].split('/')[:-1] + ['sess_*'])) self._output = """Php proxy installed, point your browser to %s?u=http://www.google.com . Delete '%s' and '%s' at session end.""" % (self.args['url'], self.args['rpath'], sess_filename)
# If no rpath, set content and remote final filename as random try: content = open(proxy_path, "r").read() except Exception, e: raise ProbeException(self.name, "'%s' %s" % (self.args["lpath"], WARN_NO_SUCH_FILE)) self.args["lpath"] = randstr(4) + ".php" self.args["content"] = content else: # Else, set lpath as proxy filename self.args["lpath"] = proxy_path self.args["content"] = None Upload2web._prepare_probe(self) def _output_result(self): Upload2web._output_result(self) sess_filename = os.path.join(*(self.args["rpath"].split("/")[:-1] + ["sess_*"])) self._output = """Php proxy installed, point your browser to %s?u=http://www.google.com . Delete '%s' and '%s' at session end.""" % ( self.args["url"], self.args["rpath"], sess_filename, )