Example #1
0
def queryDNS_192(db, footprint_id):
    try:
        net_range = dbfunctions.getDnsLookupPositions(db, footprint_id)[2]
        if net_range != "192.168.0.0/16":
            return

        new_range = net_range
        #cmd = "nmap {0} -sL -T5 | grep report | grep \( | cut -d \  -f 5,6".format(new_range)
        #cmd = "nmap {0} -PS -n -p 22,445 --open -T5 -Pn --min-rate 500 | grep report | cut -d \  -f 5".format(new_range)
        cmd = "nmap {0} -PS -p 22,80,443,445,3389 --open -n | grep report | cut -d \  -f 5".format(
            new_range)

        data = os.popen(cmd).read().split("\n")
        for i in data:
            if i == "":
                continue

            dbfunctions.addIP(db, footprint_id, i)
            #db.commit()

            #ii = i.split(" ")
            #host_name = ii[0]
            #ip = ii[1][1:-1]

            #if host_name != "rfc.private.address.invalid.query":
            #    dbfunctions.updateHostDNS_wo_commit(db,  footprint_id,  ip,  host_name)
            #    db.commit()

        dbfunctions.updateDnsLookupPosition(db, footprint_id,
                                            "192_range_position",
                                            "192.168.255.255/16")
        #db.commit()
    except:
        print "error in 192"
        queryDNS_192(db, footprint_id)
def queryDNS_192(db, footprint_id):
    try:
        net_range = dbfunctions.getDnsLookupPositions(db, footprint_id)[2]
        if net_range != "192.168.0.0/16":
            return

        new_range = net_range
        #cmd = "nmap {0} -sL -T5 | grep report | grep \( | cut -d \  -f 5,6".format(new_range)
        #cmd = "nmap {0} -PS -n -p 22,445 --open -T5 -Pn --min-rate 500 | grep report | cut -d \  -f 5".format(new_range)
        cmd = "nmap {0} -PS -p 22,80,443,445,3389 --open -n | grep report | cut -d \  -f 5".format(new_range)

        data = os.popen(cmd).read().split("\n")
        for i in data:
            if i == "":
                continue

            dbfunctions.addIP(db,  footprint_id,  i)
            #db.commit()

            #ii = i.split(" ")
            #host_name = ii[0]
            #ip = ii[1][1:-1]

            #if host_name != "rfc.private.address.invalid.query":
            #    dbfunctions.updateHostDNS_wo_commit(db,  footprint_id,  ip,  host_name)
            #    db.commit()

        dbfunctions.updateDnsLookupPosition(db, footprint_id, "192_range_position", "192.168.255.255/16")
        #db.commit()
    except:
        print "error in 192"
        queryDNS_192(db, footprint_id)
Example #3
0
def queryDNS_172(db, footprint_id):
    net_range = dbfunctions.getDnsLookupPositions(db, footprint_id)[1]
    octs = net_range.split(".")

    if int(octs[1]) >= 31:
        return

    while True:
        try:
            new_range = "{0}.{1}.0.0/16".format(octs[0], octs[1])
            #cmd = "nmap {0} -sn -n --open -T5 --min-parallelism 50 | grep report | cut -d \  -f 5".format(new_range)
            #cmd = "nmap {0} -sL | grep report | grep \( | cut -d \  -f 5,6".format(new_range)
            #print "host enumeration on {0}".format(new_range)
            #cmd = "nmap {0} -PS -n -p 22,445 --open -T5 -Pn --min-rate 500 | grep report | cut -d \  -f 5".format(new_range)
            cmd = "nmap {0} -PS -p 22,80,443,445,3389 --open -n | grep report | cut -d \  -f 5".format(
                new_range)

            data = os.popen(cmd).read().split("\n")
            for i in data:
                if i == "":
                    continue

                dbfunctions.addIP(db, footprint_id, i)
                #db.commit()

                #ii = i.split(" ")
                #host_name = ii[0]
                #ip = ii[1][1:-1]

                #if host_name != "rfc.private.address.invalid.query":
                #    dbfunctions.updateHostDNS_wo_commit(db,  footprint_id,  ip,  host_name)
                #    db.commit()

            dbfunctions.updateDnsLookupPosition(db, footprint_id,
                                                "172_range_position",
                                                new_range)
            #db.commit()

            #octs[2] = str(int(octs[2])+1)
            #if int(octs[2]) > 255:
            octs[1] = str(int(octs[1]) + 1)
            octs[2] = "0"

            if int(octs[1]) > 31:
                break
        except:
            print "error in 172"
            continue
def queryDNS_10(db, footprint_id):
    net_range = dbfunctions.getDnsLookupPositions(db, footprint_id)[0]
    octs = net_range.split(".")

    if int(octs[1]) >= 255:
        return

    while True:
        try:
            new_range = "{0}.{1}.0.0/16".format(octs[0], octs[1])
            #cmd = "nmap {0} -sn -n --open -T5 --min-parallelism 50 | grep report | cut -d \  -f 5".format(new_range)
            #cmd = "nmap {0} -sL -T5 | grep report | grep \( | cut -d \  -f 5,6".format(new_range)
            #print "host enumeration on {0}".format(new_range)
            #cmd = "nmap {0} -PS -n -p 22,445 --open -T5 -Pn --min-rate 500 | grep report | cut -d \  -f 5 2>/dev/null".format(new_range)
            cmd = "nmap {0} -PS -p 22,80,443,445,3389 --open -n | grep report | cut -d \  -f 5".format(new_range)

            data = os.popen(cmd).read().split("\n")
            for i in data:
                if i == "":
                    continue

                dbfunctions.addIP(db,  footprint_id,  i)
                #db.commit()

                #ii = i.split(" ")
                #host_name = ii[0]
                #ip = ii[1][1:-1]

                #if host_name != "rfc.private.address.invalid.query":
                #    dbfunctions.updateHostDNS_wo_commit(db,  footprint_id,  ip,  host_name)
                #    db.commit()

            dbfunctions.updateDnsLookupPosition(db, footprint_id, "10_range_position", new_range)
            #db.commit()

            #octs[2] = str(int(octs[2])+1)   
            #if int(octs[2]) > 255:
            octs[1] = str(int(octs[1])+1)
            octs[2] = "0"

            if int(octs[1]) > 255:
                break
        except:
            print "error in 10"
            continue