]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/dnsscan.cc
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 #include <boost/format.hpp>
36 #include <boost/utility.hpp>
37 #include <boost/multi_index_container.hpp>
38 #include <boost/multi_index/ordered_index.hpp>
39 #include <boost/multi_index/key_extractors.hpp>
42 #include "namespaces.hh"
43 using namespace ::boost::multi_index
;
44 #include "namespaces.hh"
48 cerr
<<"syntax: dnsscan INFILE ..."<<endl
;
51 int main(int argc
, char** argv
)
54 Socket
sock(AF_INET
, SOCK_DGRAM
);
57 IPEndpoint remote(argc > 2 ? argv[2] : "127.0.0.1",
58 argc > 3 ? atoi(argv[3]) : 5300);
67 for(int n
=1; n
< argc
; ++n
) {
68 if ((string
) argv
[n
] == "--help") {
73 if ((string
) argv
[n
] == "--version") {
74 cerr
<<"dnsscan "<<VERSION
<<endl
;
79 unsigned int counts
[256];
80 for(unsigned int n
=0 ; n
< 256; ++n
)
83 for(int n
=1; n
< argc
; ++n
) {
84 PcapPacketReader
pr(argv
[n
]);
86 while(pr
.getUDPPacket()) {
88 MOADNSParser
mdp(false, (const char*)pr
.d_payload
, pr
.d_len
);
90 counts
[mdp
.d_qtype
]++;
93 catch(const MOADNSException
&mde
) {
94 cout
<<"Error from remote "<<pr
.getSource().toString()<<": "<<mde
.what()<<"\n";
95 // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
99 for(unsigned int n
=0 ; n
< 256; ++n
) {
101 cout
<< n
<< "\t" << counts
[n
] << "\n";
105 catch(std::exception
& e
)
107 cout
<<"Fatal: "<<e
.what()<<endl
;