badpacket.cc 2.1 KB

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