You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.3 KiB

  1. Subject: Fix "-N" command line argument
  2. Author: Guillaume Delacour <gui@iroqwa.org>
  3. Bug-Debian: http://bugs.debian.org/482844
  4. Last-Update: 2009-05-13
  5. --- a/docs/hping2.8
  6. +++ b/docs/hping2.8
  7. @@ -343,7 +343,7 @@ options. If in doubt try
  8. .I -N --id
  9. Set ip->id field. Default id is random but if fragmentation is turned on
  10. and id isn't specified it will be
  11. -.BR "getpid() & 0xFF" ,
  12. +.BR "getpid() & 0xFFFF" ,
  13. to implement a better solution is in TODO list.
  14. .TP
  15. .I -H --ipproto
  16. @@ -714,4 +714,4 @@ On solaris hping does not work on the lo
  17. a solaris problem, as stated in the tcpdump-workers mailing list,
  18. so the libpcap can't do nothing to handle it properly.
  19. .SH SEE ALSO
  20. -ping(8), traceroute(8), ifconfig(8), nmap(1)
  21. \ No newline at end of file
  22. +ping(8), traceroute(8), ifconfig(8), nmap(1)
  23. --- a/docs/hping3.8
  24. +++ b/docs/hping3.8
  25. @@ -352,7 +352,7 @@ options. If in doubt try
  26. .I -N --id
  27. Set ip->id field. Default id is random but if fragmentation is turned on
  28. and id isn't specified it will be
  29. -.BR "getpid() & 0xFF" ,
  30. +.BR "getpid() & 0xFFFF" ,
  31. to implement a better solution is in TODO list.
  32. .TP
  33. .I -H --ipproto
  34. --- a/hping2.h
  35. +++ b/hping2.h
  36. @@ -121,7 +121,7 @@
  37. #define DEFAULT_ICMP_IP_IHL (IPHDR_SIZE >> 2)
  38. #define DEFAULT_ICMP_IP_TOS 0
  39. #define DEFAULT_ICMP_IP_TOT_LEN 0 /* computed by send_icmp_*() */
  40. -#define DEFAULT_ICMP_IP_ID 0 /* rand */
  41. +#define DEFAULT_ICMP_IP_ID -1 /* rand */
  42. #define DEFAULT_ICMP_CKSUM -1 /* -1 means compute the cksum */
  43. #define DEFAULT_ICMP_IP_PROTOCOL 6 /* TCP */
  44. #define DEFAULT_RAW_IP_PROTOCOL 6 /* TCP */
  45. --- a/parseoptions.c
  46. +++ b/parseoptions.c
  47. @@ -468,6 +468,10 @@ int parse_options(int argc, char **argv)
  48. break;
  49. case OPT_ICMP_IPID:
  50. icmp_ip_id = strtol(ago_optarg, NULL, 0);
  51. + if (icmp_ip_id < 0 || icmp_ip_id > 0xffff) {
  52. + fprintf(stderr, "Bad ICMP IP ID, resetting to random.\n");
  53. + icmp_ip_id = DEFAULT_ICMP_IP_ID;
  54. + }
  55. break;
  56. case OPT_ICMP_IPPROTO:
  57. icmp_ip_protocol = strtol(ago_optarg, NULL, 0);
  58. --- a/sendicmp.c
  59. +++ b/sendicmp.c
  60. @@ -83,7 +83,7 @@ void send_icmp_echo(void)
  61. icmp->type = opt_icmptype; /* echo replay or echo request */
  62. icmp->code = opt_icmpcode; /* should be indifferent */
  63. icmp->checksum = 0;
  64. - icmp->un.echo.id = getpid() & 0xffff;
  65. + icmp->un.echo.id = icmp_ip_id == DEFAULT_ICMP_IP_ID ? getpid() & 0xffff : icmp_ip_id;
  66. icmp->un.echo.sequence = _icmp_seq;
  67. /* data */