badpacket.cc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <iostream>
  16. #include <config.h>
  17. #include <exceptions/exceptions.h>
  18. #include <log/logger_support.h>
  19. #include "command_options.h"
  20. #include "scan.h"
  21. /// \brief Perform Bad Packet Scan
  22. ///
  23. /// Scans the server by sending a sequence of (potentially) bad packets and
  24. /// printing the packet settings and the response received. The principle
  25. /// raison d'etre for this is to check if a bad packet will cause a crash.
  26. ///
  27. /// This particular version of the code allows a set of ranges to be set for:
  28. /// - The flags fields in the message.
  29. /// - The section count fields, regardless of what is in the section.
  30. /// - The message size: the message can be truncated or extended.
  31. ///
  32. /// The program then sends a set of packets corresponding to all combinations
  33. /// of values in the ranges selected.
  34. // TODO: Extend to cover:
  35. // - Mangling the QNAME
  36. // - Adding names to the message sections
  37. // - Adding EDNS0 RR and magling the fields there
  38. using namespace isc::badpacket;
  39. /// \brief Main Program
  40. int main(int argc, char* argv[]) {
  41. isc::log::initLogger("badpacket");
  42. try {
  43. // Parse command
  44. CommandOptions options;
  45. options.parse(argc, argv);
  46. // Send the sequence of messages
  47. Scan scanner;
  48. scanner.scan(options);
  49. } catch (isc::Exception& e) {
  50. std::cout << "ERROR: " << e.what() << "\n";
  51. return 1;
  52. }
  53. return 0;
  54. }