badpacket.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <unistd.h>
  15. #include <config.h>
  16. #include "command_options.h"
  17. #include "scan.h"
  18. /// \brief Perform Bad Packet Scan
  19. ///
  20. /// Scans the server by sending a sequence of (potentially) bad packets and
  21. /// printing the packet settings and the response received. The principle
  22. /// raison d'etre for this is to check if a bad packet will cause a crash.
  23. ///
  24. /// This particular version of the code allows a set of ranges to be set for
  25. /// each field in the "flags" word (the third and fourth bytes) of a DNS
  26. /// message. (Most of the flags are single-bit values, so the range is just 0-1.
  27. /// The OPCODE and RCODE are both four bits wide, so the range is 0-15.) The
  28. /// program then sends packets containing each combination of values.
  29. ///
  30. /// TODO: Extend the program to other bad values.
  31. /// Examples of this would be to make the count fields invalid, to add data
  32. /// to sections that should be empty, and to deliberately mangle the names in
  33. /// these sections.
  34. using namespace isc::badpacket;
  35. /// \brief Main Program
  36. int main(int argc, char* argv[]) {
  37. CommandOptions command_line;
  38. command_line.parse(argc, argv);
  39. // Construct the scan object and perform the scan.
  40. Scan scanner;
  41. scanner.scan(command_line);
  42. return 0;
  43. }