示例#1
0
    def v(self, uuid):
        mindex = index.manage(sharedir=forbanshareroot,
                              forbanglobal=forbanpath)
        dloot = loot.loot(dynpath=os.path.join(forbanpath, "var"))
        missingfiles = mindex.howfar(uuid)
        html = htmlheader
        html += """<br/> <br/> <br/> <div class="left inner"> <h2>Missing files on your loot from %s </h2>""" % dloot.getname(
            uuid)
        html += htmlnav
        html += "<table>"

        if missingfiles is None:

            html += "You are not missing any files with %s " % dloot.getname(
                uuid)
        else:

            for filemissed in missingfiles:
                html += "<tr>"
                sourcev4 = dloot.getipv4(uuid)
                sourcev6 = dloot.getipv6(uuid)
                html += """<td>%s</td><td><a
                href="http://%s:12555/s/?g=%s&f=b64e">v4</a></td> """ % (
                    filemissed, sourcev4, base64e.encode(filemissed))
                if sourcev6 is not None:
                    html += """<td><a href="http://[%s]:12555/s/?g=%s&f=b64e">v6</a></td>""" % (
                        sourcev6, base64e.encode(filemissed))
                html += "</tr>"

        html += "</table>"
        html += htmlfooter
        return html
示例#2
0
    def l(self, uuid):
        mindex = index.manage(sharedir=forbanshareroot,
                              forbanglobal=forbanpath)
        dloot = loot.loot(dynpath=os.path.join(forbanpath, "var"))
        html = htmlheader

        html += """<br/> <br/> <br /> <div class="left inner"> <h2>Files available in loot %s </h2>""" % dloot.getname(
            uuid)
        html += htmlnav
        html += "<table>"
        html += "<tr><td>Filename</td><td>Fetch</td></tr>"
        tempindex = mindex.search("^((?!forban).)*$", uuid)
        tempindex.sort(key=string.lower)
        for fileinindex in tempindex:
            filei = fileinindex.rsplit(",", 1)[0]
            if re.search('/\.', filei):
                continue
            if re.search('^\+\.', filei):
                continue
            html += "<tr>"
            sourcev4 = dloot.getipv4(uuid)
            sourcev6 = dloot.getipv6(uuid)
            size = tools.convertbytes(
                mindex.getfilesize(filename=filei, uuid=uuid))
            html += """<td>%s (%s)</td><td><a href="/s/?g=%s&f=b64e">get</a></td> """ % (
                filei, size, base64e.encode(filei))
            html += "</tr>"

        html += "</table>"
        html += htmlfooter
        return html
示例#3
0
    def l(self, uuid):
        mindex = index.manage(sharedir=forbanshareroot, forbanglobal=forbanpath)
        dloot = loot.loot(dynpath=os.path.join(forbanpath, "var"))
        html = htmlheader

        html += """<br/> <br/> <br /> <div class="left inner"> <h2>Files available in loot %s </h2>""" % dloot.getname(
            uuid
        )
        html += htmlnav
        html += "<table>"
        html += "<tr><td>Filename</td><td>Fetch</td></tr>"
        tempindex = mindex.search("^((?!forban).)*$", uuid)
        tempindex.sort(key=string.lower)
        for fileinindex in tempindex:
            filei = fileinindex.rsplit(",", 1)[0]
            if re.search("/\.", filei):
                continue
            if re.search("^\+\.", filei):
                continue
            html += "<tr>"
            sourcev4 = dloot.getipv4(uuid)
            sourcev6 = dloot.getipv6(uuid)
            size = tools.convertbytes(mindex.getfilesize(filename=filei, uuid=uuid))
            html += """<td>%s (%s)</td><td><a href="/s/?g=%s&f=b64e">get</a></td> """ % (
                filei,
                size,
                base64e.encode(filei),
            )
            html += "</tr>"

        html += "</table>"
        html += htmlfooter
        return html
示例#4
0
def forban_geturl(uuid=None, filename=None, protocol="v4"):

    if uuid is None or filename is None:
        return False

    discoveredloot = loot.loot(dynpath=os.path.join(forbanpath,"var"))

    if not discoveredloot.exist(uuid):
        return False

    if protocol == "v4":
        ip = discoveredloot.getipv4(uuid)
    else:
        ip = discoveredloot.getipv6(uuid)

    if protocol == "v4":
        url = "http://%s:12555/s/?g=%s&f=b64e" % (ip,base64e.encode(filename))
    else:
        url = "http://[%s]:12555/s/?g=%s&f=b64e" % (ip,base64e.encode(filename))

    return url
示例#5
0
def forban_geturl(uuid=None, filename=None, protocol="v4"):

    if uuid is None or filename is None:
        return False

    discoveredloot = loot.loot(dynpath=os.path.join(forbanpath, "var"))

    if not discoveredloot.exist(uuid):
        return False

    if protocol == "v4":
        ip = discoveredloot.getipv4(uuid)
    else:
        ip = discoveredloot.getipv6(uuid)

    if protocol == "v4":
        url = "http://%s:12555/s/?g=%s&f=b64e" % (ip, base64e.encode(filename))
    else:
        url = "http://[%s]:12555/s/?g=%s&f=b64e" % (ip,
                                                    base64e.encode(filename))

    return url
示例#6
0
    def v(self, uuid):
        mindex = index.manage(sharedir=forbanshareroot, forbanglobal=forbanpath)
        dloot = loot.loot(dynpath=os.path.join(forbanpath, "var"))
        missingfiles = mindex.howfar(uuid)
        html = htmlheader
        html += (
            """<br/> <br/> <br/> <div class="left inner"> <h2>Missing files on your loot from %s </h2>"""
            % dloot.getname(uuid)
        )
        html += htmlnav
        html += "<table>"

        if missingfiles is None:

            html += "You are not missing any files with %s " % dloot.getname(uuid)
        else:

            for filemissed in missingfiles:
                html += "<tr>"
                sourcev4 = dloot.getipv4(uuid)
                sourcev6 = dloot.getipv6(uuid)
                html += """<td>%s</td><td><a
                href="http://%s:12555/s/?g=%s&f=b64e">v4</a></td> """ % (
                    filemissed,
                    sourcev4,
                    base64e.encode(filemissed),
                )
                if sourcev6 is not None:
                    html += """<td><a href="http://[%s]:12555/s/?g=%s&f=b64e">v6</a></td>""" % (
                        sourcev6,
                        base64e.encode(filemissed),
                    )
                html += "</tr>"

        html += "</table>"
        html += htmlfooter
        return html
示例#7
0
        if not discoveredloot.lastannounced(uuid):
            flogger.info("%s (%s) not seen recently, skipped" % (discoveredloot.getname(uuid),(uuid)))
            continue

        missingfiles = allindex.howfar(uuid)

        if (discoveredloot.whoami() == uuid):
            flogger.debug("we are not opportunistic on ourself %s (%s)" % (discoveredloot.getname(uuid),uuid))
        elif not missingfiles:
            flogger.info("missing no files with %s (%s)" % (discoveredloot.getname(uuid),uuid))
        else:
            for missedfile in missingfiles:
                if re.search(refilter, missedfile) and not (re.search(exfilter, missedfile) and efilter is not None):
                    sourcev4 = discoveredloot.getipv4(uuid)
                    url =  """http://%s:12555/s/?g=%s&f=b64e""" % (sourcev4, base64e.encode(missedfile))
                    localfile = forbanshareroot + "/" + missedfile
                    localsize = allindex.getfilesize(filename=missedfile)
                    remotesize = allindex.getfilesize(filename=missedfile,uuid=uuid)
                    if localsize < remotesize:
                        flogger.info("local file smaller - from %s fetching %s to be saved in %s" % (uuid,url,localfile))
                        fetch.urlget(url,localfile)
                    elif localsize is False:
                        flogger.info("local file not existing - from %s fetching %s to be saved in %s" % (uuid,url,localfile))
                        fetch.urlget(url,localfile)
                    elif remotesize is False:
                        flogger.info("remote file index issue for %s on loot %s" % (missedfile, uuid))
                    else:
                        flogger.info("local file larger or corrupt %s - don't fetch it" % (localfile))
                    allindex.build()