]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/dnsscan.cc
7 // this is needed because boost multi_index also uses 'L', as do we (which is sad enough)
13 #include <boost/format.hpp>
14 #include <boost/utility.hpp>
15 #include <boost/multi_index_container.hpp>
16 #include <boost/multi_index/ordered_index.hpp>
17 #include <boost/multi_index/key_extractors.hpp>
20 #include "namespaces.hh"
21 using namespace ::boost::multi_index
;
22 #include "namespaces.hh"
25 int main(int argc
, char** argv
)
28 Socket
sock(InterNetwork
, Datagram
);
31 IPEndpoint remote(argc > 2 ? argv[2] : "127.0.0.1",
32 argc > 3 ? atoi(argv[3]) : 5300);
37 cerr
<<"Syntax: dnsscan file1 [file2 ..] "<<endl
;
41 unsigned int counts
[256];
42 for(unsigned int n
=0 ; n
< 256; ++n
)
45 for(int n
=1; n
< argc
; ++n
) {
46 PcapPacketReader
pr(argv
[n
]);
48 while(pr
.getUDPPacket()) {
50 MOADNSParser
mdp((const char*)pr
.d_payload
, pr
.d_len
);
52 counts
[mdp
.d_qtype
]++;
54 for(unsigned int i
=0; i
< mdp
.d_qname
.length(); ++i
)
55 if(!isalnum(mdp
.d_qname
[i
]) && mdp
.d_qname
[i
]!='.' && mdp
.d_qname
[i
]!='-' && mdp
.d_qname
[i
]!='_') {
56 // cout<<mdp.d_qname<<"|"<<mdp.d_qtype<<"|"<<mdp.d_qclass<<"\n";
57 // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
60 if(mdp
.d_qtype
> 256 || mdp
.d_qclass
!=1 ) {
61 // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
64 for(MOADNSParser::answers_t::const_iterator i
=mdp
.d_answers
.begin(); i
!=mdp
.d_answers
.end(); ++i
) {
69 catch(MOADNSException
&e
) {
70 cout
<<"Error from remote "<<U32ToIP(ntohl(*((uint32_t*)&pr
.d_ip
->ip_src
)))<<": "<<e
.what()<<"\n";
71 // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
75 for(unsigned int n
=0 ; n
< 256; ++n
) {
77 cout
<< n
<< "\t" << counts
[n
] << "\n";
81 catch(std::exception
& e
)
83 cout
<<"Fatal: "<<e
.what()<<endl
;