From: Bert Hubert Date: Thu, 13 Apr 2006 19:49:56 +0000 (+0000) Subject: add tool dnsscan (mostly for internal use) X-Git-Tag: rec-3-0~62 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2353fffac9c82fd729fcc26fa5a0c7e75b75ab29;p=pdns add tool dnsscan (mostly for internal use) make dist-recursor package a version number improve stats, add some logging git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@691 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index f143f7ea3..edbfbf283 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -20,7 +20,7 @@ endif -EXTRA_PROGRAMS=pdns_recursor sdig dnspbench pdns_control qgen dnsscope dnsreplay_mindex dnswasher dnsreplay +EXTRA_PROGRAMS=pdns_recursor sdig dnspbench pdns_control qgen dnsscope dnsreplay_mindex dnswasher dnsreplay dnsscan pdns_server_SOURCES=dnspacket.cc nameserver.cc tcpreceiver.hh \ qtype.cc logger.cc arguments.cc packethandler.cc tcpreceiver.cc \ @@ -72,6 +72,12 @@ dnsreplay_SOURCES=dnsreplay.cc misc.cc qtype.cc anadns.hh \ dnsreplay_LDFLAGS= @DYNLINKFLAGS@ @THREADFLAGS@ +dnsscan_SOURCES=dnsscan.cc misc.cc qtype.cc anadns.hh \ + logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc dnsparser.hh \ + rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnswriter.hh \ + unix_utility.cc utility.hh + + dnsreplay_mindex_SOURCES=dnsreplay-mindex.cc misc.cc qtype.cc anadns.hh \ logger.cc statbag.cc dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc dnsparser.hh \ rcpgenerator.cc rcpgenerator.hh base64.cc base64.hh dnswriter.cc dnswriter.hh \ diff --git a/pdns/dist-recursor b/pdns/dist-recursor index e69ad5363..630b8d4ff 100755 --- a/pdns/dist-recursor +++ b/pdns/dist-recursor @@ -1,3 +1,5 @@ +VERSION=3.0-pre1 + INCLUDES="iputils.hh arguments.hh base64.hh zoneparser-tng.hh \ rcpgenerator.hh lock.hh dnswriter.hh dnsrecords.hh dnsparser.hh utility.hh \ recursor_cache.hh rec_channel.hh qtype.hh misc.hh dns.hh syncres.hh \ @@ -8,20 +10,20 @@ logger.cc arguments.cc lwres.cc pdns_recursor.cc \ recursor_cache.cc dnsparser.cc dnswriter.cc dnsrecords.cc rcpgenerator.cc \ base64.cc zoneparser-tng.cc rec_channel.cc rec_channel_rec.cc rec_control.cc" -cat $INCLUDES $CFILES | wc -rm -rf pdns-recursor -mkdir pdns-recursor -cp $INCLUDES $CFILES pdns-recursor -cp Makefile-recursor pdns-recursor/Makefile -cp README-recursor pdns-recursor/README -cp COPYING pdns-recursor/ -cp config-recursor.h pdns-recursor/config.h -mkdir pdns-recursor/rrd -cp tools/rrd/{create,update,makegraphs,index.html} pdns-recursor/rrd -cp ext/nedmalloc/malloc.c pdns-recursor -tar cf pdns-recursor.tar pdns-recursor -bzip2 -f pdns-recursor.tar # .. solaris +DIRNAME=pdns-recursor-$VERSION +rm -rf $DIRNAME +mkdir $DIRNAME +cp $INCLUDES $CFILES $DIRNAME +cp Makefile-recursor $DIRNAME/Makefile +cp README-recursor $DIRNAME/README +cp COPYING $DIRNAME/ +cp config-recursor.h $DIRNAME/config.h +mkdir $DIRNAME/rrd +cp tools/rrd/{create,update,makegraphs,index.html} $DIRNAME/rrd +cp ext/nedmalloc/malloc.c $DIRNAME +tar cf $DIRNAME.tar $DIRNAME +bzip2 -f $DIRNAME.tar # .. solaris diff --git a/pdns/dnsscan.cc b/pdns/dnsscan.cc new file mode 100644 index 000000000..6431ab649 --- /dev/null +++ b/pdns/dnsscan.cc @@ -0,0 +1,64 @@ +#include +#include "statbag.hh" +#include "dnspcap.hh" +#include "sstuff.hh" +#include "anadns.hh" + +// this is needed because boost multi_index also uses 'L', as do we (which is sad enough) +#undef L + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace boost; +using namespace ::boost::multi_index; +using namespace std; +StatBag S; + +int main(int argc, char** argv) +try +{ + PcapPacketReader pr(argv[1]); + Socket sock(InterNetwork, Datagram); + + IPEndpoint remote(argc > 2 ? argv[2] : "127.0.0.1", + argc > 3 ? atoi(argv[3]) : 5300); + + + while(pr.getUDPPacket()) { + try { + MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); + for(int i=0; i < mdp.d_qname.length(); ++i) + if(!isalnum(mdp.d_qname[i]) && mdp.d_qname[i]!='.' && mdp.d_qname[i]!='-' && mdp.d_qname[i]!='_') { + cout< 256 || mdp.d_qclass!=1 ) { + // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote); + + } + for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) { + + } + + } + catch(MOADNSException &e) { + cerr<<"Error: "< vpacket; DNSPacketWriter pw(vpacket, domain, type); @@ -67,6 +68,7 @@ int LWRes::asyncresolve(uint32_t ip, const char *domain, int type, bool doTCP, s d_inaxfr=false; d_rcode=0; + struct sockaddr_in toaddr; Utility::socklen_t addrlen=sizeof(toaddr); toaddr.sin_addr.s_addr=htonl(ip); @@ -139,6 +141,12 @@ LWRes::res_t LWRes::result() d_tcbit=mdp.d_header.tc; d_rcode=mdp.d_header.rcode; + if(d_domain != mdp.d_qname) { + L<first.d_place<<"\t"<first.d_label<<"\tIN\t"<first.d_type); @@ -162,7 +170,10 @@ LWRes::res_t LWRes::result() catch(...) { L< #include #include +#include "misc.hh" #ifndef WIN32 diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 53a1aa1de..f20a33d9e 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -358,6 +358,7 @@ struct RecursorStats uint64_t tcpClientOverflow; uint64_t clientParseError; uint64_t serverParseError; + uint64_t spoofedCount; }; extern RecursorStats g_stats;