예제 #1
0
def _setDNSProxy():

    if conf.dnsproxy:

        conf.nametodns = dict()

        for qtype in RDMAP.keys():

            conf.nametodns[qtype] = dict()

        if conf.ipv6:
            infoMsg = "Enable ipv6 mode."
            logger.info(infoMsg)
            if conf.interface == "127.0.0.1":
                conf.interface = "::1"

            if conf.nameserver == "8.8.8.8":
                conf.nameserver = "2001:4860:4860:8888"

        if conf.nameserver:
            conf.nameserver = conf.nameserver.split(",")

        if conf.fakeipv6 or conf.fakeip or conf.fakemail or conf.fakealias or conf.fakens:

            if conf.fakedomain:

                for domain in conf.fakedomain.split(","):

                    domain = domain.lower()
                    domain = domain.strip()

                    if conf.fakeip:
                        conf.nametodns["A"][domain] = conf.fakeip
                        msg = "Cooking A replies to point to %s matching: %s" % (
                            conf.fakeip, domain)
                        logger.info(msg)

                    if conf.fakeipv6:
                        conf.nametodns["AAAA"][domain] = conf.fakeipv6
                        msg = "Cooking AAAA replies to point to %s matching: %s" % (
                            conf.fakeipv6, domain)
                        logger.info(msg)

                    if conf.fakemail:
                        conf.nametodns["MX"][domain] = conf.fakemail
                        msg = "Cooking MX replies to point to %s matching: %s" % (
                            conf.fakemail, domain)
                        logger.info(msg)

                    if conf.fakens:
                        conf.nametodns["NS"][domain] = conf.fakens
                        msg = "Cooking NS replies to point to %s matching: %s" % (
                            conf.fakens, domain)
                        logger.info(msg)

                    if conf.fakealias:
                        conf.nametodns["CNAME"][domain] = conf.fakealias
                        msg = "Cooking CNAME replies to point to %s matching: %s" % (
                            conf.fakealias, domain)
                        logger.info(msg)

            elif conf.truedomain:

                for domain in conf.truedomain.split(","):

                    doamin = domain.lower()
                    domain = domain.strip()

                    if conf.fakeip:
                        conf.nametodns["A"][doamin] = False
                        conf.nametodns["A"][
                            '*.*.*.*.*.*.*.*.*.*'] = conf.fakeip
                        msg = "Cooking A replies to point to %s not matching: %s" % (
                            conf.fakeip, domain)
                        logger.info(msg)

                    if conf.fakeipv6:
                        conf.nametodns["AAAA"][doamin] = False
                        conf.nametodns["AAAA"][
                            "*.*.*.*.*.*.*.*.*.*"] = conf.fakeipv6
                        msg = "Cooking AAAA replies to point to %s not matching: %s" % (
                            conf.fakeipv6, domain)
                        logger.info(msg)

                    if conf.fakemail:
                        conf.nametodns["MX"][domain] = False
                        conf.nametodns["MX"][
                            "*.*.*.*.*.*.*.*.*.*"] = conf.fakemail
                        msg = "Cooking MX replies to point to %s not matching: %s" % (
                            conf.fakemail, domain)
                        logger.info(msg)

                    if conf.fakens:
                        conf.nametodns["NS"][domain] = False
                        conf.nametodns["NS"][
                            "*.*.*.*.*.*.*.*.*.*"] = conf.fakens
                        msg = "Cooking NS replies to point to %s not matching: %s" % (
                            conf.fakens, domain)
                        logger.info(msg)

                    if conf.fakealias:
                        conf.nametodns["CNAME"][domain] = False
                        conf.nametodns["CNAME"][
                            "*.*.*.*.*.*.*.*.*.*"] = conf.fakealias
                        msg = "Cooking CNAME replies to point to %s not matching: %s" % (
                            conf.fakealias, domain)
                        logger.info(msg)

            else:

                if conf.fakeip:
                    conf.nametodns["A"]['*.*.*.*.*.*.*.*.*.*'] = conf.fakeip
                    msg = "Cooking all A replies to point to %s" % conf.fakeip
                    logger.info(msg)

                if conf.fakeipv6:
                    conf.nametodns["AAAA"][
                        "*.*.*.*.*.*.*.*.*.*"] = conf.fakeipv6
                    msg = "Cooking all AAAA replies to point to %s" % conf.fakeipv6
                    logger.info(msg)

                if conf.fakemail:
                    conf.nametodns["MX"]["*.*.*.*.*.*.*.*.*.*"] = conf.fakemail
                    msg = "Cooking all MX replies to point to %s" % conf.fakemail
                    logger.info(msg)

                if conf.fakens:
                    conf.nametodns["NS"]["*.*.*.*.*.*.*.*.*.*"] = conf.fakens
                    msg = "Cooking all NS replies to point to %s" % conf.fakens
                    logger.info(msg)

                if conf.fakealias:
                    conf.nametodns["CNAME"][
                        "*.*.*.*.*.*.*.*.*.*"] = conf.fakealias
                    msg = "Cooking all CNAME replies to point to %s" % conf.fakealias
                    logger.info(msg)
예제 #2
0
                        action="store_false",
                        dest="verbose",
                        default=True,
                        help="Don't show headers.")
    parser.add_option_group(rungroup)

    (options, args) = parser.parse_args()

    # Print program header
    if options.verbose:
        print header

    # Main storage of domain filters
    # NOTE: RDMAP is a dictionary map of qtype strings to handling classes
    nametodns = dict()
    for qtype in RDMAP.keys():
        nametodns[qtype] = dict()

    # Incorrect or incomplete command line arguments
    if options.fakedomains and options.truedomains:
        print(
            "[!] You can not specify both 'fakedomains' and 'truedomains' parameters."
        )
        exit(0)

    elif not (options.fakeip or options.fakeipv6) and (options.fakedomains
                                                       or options.truedomains):
        print(
            "[!] You have forgotten to specify which IP to use for fake responses"
        )
        exit(0)