module_tcp_synscan_proberesponse.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * ZMap Copyright 2013 Regents of the University of Michigan
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy
  6. * of the License at http://www.apache.org/licenses/LICENSE-2.0
  7. */
  8. // probe module for performing TCP SYN scans extended for probe response attacks
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <stdint.h>
  12. #include <unistd.h>
  13. #include <string.h>
  14. #include <assert.h>
  15. #include "../../lib/includes.h"
  16. #include "../fieldset.h"
  17. #include "probe_modules.h"
  18. #include "packet.h"
  19. #include "../../lib/logger.h"
  20. #include <inttypes.h>
  21. #define ICMP_SMALLEST_SIZE 5
  22. #define ICMP_TIMXCEED_UNREACH_HEADER_SIZE
  23. probe_module_t module_tcp_synscan_pra_proberesponse;
  24. static uint32_t num_ports;
  25. int synscan_pra_global_initialize(struct state_conf *state)
  26. {
  27. num_ports = state->source_port_last - state->source_port_first + 1;
  28. return EXIT_SUCCESS;
  29. }
  30. int synscan_pra_init_perthread(void* buf, macaddr_t *src,
  31. macaddr_t *gw, port_h_t dst_port,
  32. __attribute__((unused)) void **arg_ptr)
  33. {
  34. memset(buf, 0, MAX_PACKET_SIZE);
  35. struct ether_header *eth_header = (struct ether_header *) buf;
  36. make_eth_header(eth_header, src, gw);
  37. struct ip *ip_header = (struct ip*)(&eth_header[1]);
  38. uint16_t len = htons(sizeof(struct ip) + sizeof(struct tcphdr));
  39. make_ip_header(ip_header, IPPROTO_TCP, len);
  40. struct tcphdr *tcp_header = (struct tcphdr*)(&ip_header[1]);
  41. make_tcp_header(tcp_header, dst_port);
  42. return EXIT_SUCCESS;
  43. }
  44. int synscan_pra_make_packet(void *buf, ipaddr_n_t src_ip, ipaddr_n_t dst_ip,
  45. uint32_t *validation, int probe_num, __attribute__((unused)) void *arg)
  46. {
  47. //log_debug("encoder", "probe_num = %d", probe_num);
  48. // ipaddr_n_t = uint32_t
  49. struct ether_header *eth_header = (struct ether_header *)buf;
  50. struct ip *ip_header = (struct ip*)(&eth_header[1]);
  51. struct tcphdr *tcp_header = (struct tcphdr*)(&ip_header[1]);
  52. uint32_t tcp_seq = validation[0];
  53. // needed to reach the correct destination
  54. ip_header->ip_dst.s_addr = dst_ip;
  55. uint32_t marker_value = 0;
  56. // how many bits to be used for marker value and checksum
  57. int amount_bits_marker_value = zconf.markerbits_value;
  58. int amount_bits_checksum = zconf.markerbits_checksum;
  59. if(!zconf.use_markervalue) {
  60. // further calculations are based on host byte order
  61. // lib/types.h:typedef uint32_t ipaddr_n_t; // IPv4 address network order
  62. // Cut off IP: 1.2.3.4 -> 1.2 (based on amount of bits used)
  63. marker_value = ntohl(dst_ip) >> (32 - amount_bits_marker_value);
  64. }
  65. // take given marker value instead of destination address (Stage > 1)
  66. else {
  67. marker_value = (uint32_t)zconf.markervalue;
  68. }
  69. //log_debug("encoder", "marker value: 0x%.16" PRIX32, marker_value);
  70. // stores [destination IP][checksum(IP) | 0]
  71. /*
  72. 291 -> b"00000123" (hex) -> b"000123" (marker value: eg 3 bytes)
  73. -> chk = checksum(b"000123" -> b"00012300") = b"abcdefgh"
  74. -> b"000123" (marker value) + b"abcdefgh"[:checksum_len] (marker checksum)
  75. */
  76. uint64_t markervalue_and_checksum = 0;
  77. markervalue_and_checksum |= marker_value;
  78. // encode marker value (truncate to amount_bits_marker_value):
  79. // 0x00000000 00AAAAAA -> 0xAAAAAA00 00000000
  80. markervalue_and_checksum <<= (64 - amount_bits_marker_value);
  81. if (amount_bits_checksum != 0) {
  82. // encode marker checksum:
  83. //log_info("encoder", "encoding checksum bits: %d", amount_bits_checksum);
  84. // 0xAAAAAA00 00000000 -> 0x00000000 AAAAAA00 -> 0xAAAAAA00
  85. uint32_t marker_value_for_checksum = (markervalue_and_checksum >> 32);
  86. //log_debug("encoder", "marker value for checksum: 0x%.8" PRIX32, marker_value_for_checksum);
  87. marker_value_for_checksum = htonl(marker_value_for_checksum);
  88. // checksum is calculated over 4 bytes (padded from right with 0)
  89. // nw order -> fletcher32 -> host order -> nw order
  90. // return value: we need more space to shift more than 32 Bit (return value of fletcher32 if uint32_t)
  91. uint64_t sum_marker_value = (uint64_t)(fletcher32((uint16_t*)&marker_value_for_checksum, 2) & 0x00000000FFFFFFFF);
  92. //log_debug("encoder", "checksum: 0x%.16" PRIX64, sum_marker_value);
  93. // encode checksum:
  94. // 0x00000000 CCCCCCCC
  95. // 0xAAAAAA00 00000000 -> 0xAAAAAACC CCCCCC00
  96. // Unneeded trailing checksum bits don't need to be removed (we take the front most checksum bits): just stop reading after x bits
  97. markervalue_and_checksum |= (sum_marker_value << (32 - amount_bits_marker_value));
  98. }
  99. int amount_bits_to_encode = amount_bits_marker_value + amount_bits_checksum;
  100. //printf("total bits to encode : %d\n", amount_bits_to_encode);
  101. //printf("%u\n", markervalue_and_checksum >> 32);
  102. //printf("Value to encode: 0x%.16" PRIX64 "\n", markervalue_and_checksum);
  103. // will be overwritten if marker type is given
  104. ip_header->ip_src.s_addr = src_ip;
  105. // will be overwritten if marker type is given
  106. tcp_header->th_sport = htons(get_src_port(num_ports, probe_num, validation));
  107. int bitpos = 1;
  108. // encoded bits so far
  109. int marker_bitcount = 0;
  110. //log_debug("encoder", "encoding %d bits: 0x%.16" PRIX64, amount_bits_to_encode, markervalue_and_checksum);
  111. // check for every available encoder marker to place destination address (+checksum)
  112. // order of encoding: dport, source ip, sport (source ip should not be equal to destination to avoid filtering)
  113. if (amount_bits_to_encode)
  114. while (bitpos <= 5 && marker_bitcount < amount_bits_to_encode) {
  115. if ((zconf.marker_encoding & bitpos) == 1) {
  116. //log_debug("encoder", "encoding to dport");
  117. if (!zconf.marker_encoding_dst_small) {
  118. // encode into destination port
  119. tcp_header->th_dport = htons((uint16_t)( (markervalue_and_checksum & 0xFFFF000000000000) >> 48) );
  120. } else {
  121. // if marker_encoding_mitigation: assume destination port is the only marker and limited
  122. // to 10 bits: 0->1023 (0000 0000 00 -> 1111 1111 11)
  123. // IMPORTAND: needed config is "marker value bits = 5, cheskum bits = 5"
  124. tcp_header->th_dport = htons((uint16_t)( (markervalue_and_checksum & 0xFFC0000000000000) >> (64-10)) );
  125. tcp_header->th_dport = htons((uint16_t)( (markervalue_and_checksum & 0xFFC0000000000000) >> (64-10)) );
  126. // just use destination port, skip all other
  127. break;
  128. }
  129. marker_bitcount += 16;
  130. }
  131. else if ((zconf.marker_encoding & bitpos) == 2) {
  132. //log_debug("encoder", "encoding to src ip");
  133. // encode into source address
  134. ip_header->ip_src.s_addr = htonl((uint32_t)( (markervalue_and_checksum & (0xFFFFFFFF00000000 >> marker_bitcount)) >> (32 - marker_bitcount)) );
  135. //printf("source IP: %u\n", ip_header->ip_src.s_addr);
  136. marker_bitcount += 32;
  137. }
  138. else if ((zconf.marker_encoding & bitpos) == 4) {
  139. //log_debug("encoder", "encoding to sport");
  140. // encode into source port
  141. tcp_header->th_sport = htons((uint16_t)( (markervalue_and_checksum & (0xFFFF000000000000 >> marker_bitcount)) >> (48 - marker_bitcount)) );
  142. marker_bitcount += 16;
  143. }
  144. bitpos <<= 1;
  145. }
  146. tcp_header->th_seq = tcp_seq;
  147. tcp_header->th_sum = 0;
  148. tcp_header->th_sum = tcp_checksum(sizeof(struct tcphdr),
  149. ip_header->ip_src.s_addr, ip_header->ip_dst.s_addr, tcp_header);
  150. ip_header->ip_sum = 0;
  151. ip_header->ip_sum = zmap_ip_checksum((unsigned short *) ip_header);
  152. return EXIT_SUCCESS;
  153. }
  154. void synscan_pra_print_packet(FILE *fp, void* packet)
  155. {
  156. struct ether_header *ethh = (struct ether_header *) packet;
  157. struct ip *iph = (struct ip *) &ethh[1];
  158. struct tcphdr *tcph = (struct tcphdr *) &iph[1];
  159. fprintf(fp, "tcp { source: %u | dest: %u | seq: %u | checksum: %#04X }\n",
  160. ntohs(tcph->th_sport),
  161. ntohs(tcph->th_dport),
  162. ntohl(tcph->th_seq),
  163. ntohs(tcph->th_sum));
  164. fprintf_ip_header(fp, iph);
  165. fprintf_eth_header(fp, ethh);
  166. fprintf(fp, "------------------------------------------------------\n");
  167. }
  168. int synscan_pra_validate_packet(const struct ip *ip_hdr, uint32_t len,
  169. __attribute__((unused))uint32_t *src_ip,
  170. uint32_t *validation)
  171. {
  172. //log_debug("decoder", "got feedback packet");
  173. // We use the remote source address to derive source/dest port -> compare with source dest port
  174. // Using encoded addresses allows a fast and cheap comparison, using a self defined marker value wouldn't allow that
  175. // Scanner feedback is meant for first stage only
  176. if (zconf.use_markervalue) {
  177. //log_debug("decoder", "not collecting feedback: using marker value");
  178. return 0;
  179. }
  180. if ((zconf.marker_encoding & 2) == 2) {
  181. //log_debug("decoder", "not collecting feedback: spoofed address");
  182. // we won't get any answers for spoofed addresses -> only check in case of modes 1, 4, 5 (1+4)
  183. return 0;
  184. }
  185. if ((4*ip_hdr->ip_hl + sizeof(struct tcphdr)) > len) {
  186. //log_debug("decoder", "not collecting feedback: packet to large");
  187. // buffer not large enough to contain expected tcp header
  188. return 0;
  189. }
  190. // arriving packet
  191. uint16_t sport_remote = 0;
  192. uint16_t dport_remote = 0;
  193. uint32_t source_ip_remote = 0;
  194. uint32_t ack_remote = 0;
  195. // sent packet
  196. uint16_t sport_local = 0;
  197. //uint16_t sport_local_viamarker = 0;
  198. uint16_t dport_local = htons((uint16_t)zconf.target_port);
  199. if (ip_hdr->ip_p == IPPROTO_TCP) {
  200. //log_debug("decoder", "got TCP feedback");
  201. struct tcphdr *tcp = (struct tcphdr*)((char *) ip_hdr + 4*ip_hdr->ip_hl);
  202. sport_remote = tcp->th_sport;
  203. dport_remote = tcp->th_dport;
  204. ack_remote = tcp->th_ack;
  205. source_ip_remote = ip_hdr->ip_src.s_addr;
  206. }
  207. // in case of ICMP responses: extract IP and TCP structure
  208. else if (ip_hdr->ip_p == IPPROTO_ICMP) {
  209. //log_debug("decoder", "got ICMP feedback");
  210. if (((uint32_t) 4 * ip_hdr->ip_hl + ICMP_SMALLEST_SIZE) > len) {
  211. // buffer not large enough to contain expected icmp header
  212. //log_debug("decoder", "buffer not large enough to contain expected icmp header");
  213. return 0;
  214. }
  215. struct icmp *icmp_hdr = (struct icmp *) ((char *) ip_hdr + 4*ip_hdr->ip_hl);
  216. // for some packet types we must look inside the payload
  217. if (icmp_hdr->icmp_type == ICMP_TIMXCEED || icmp_hdr->icmp_type == ICMP_UNREACH) {
  218. //log_debug("decoder", "icmp type: %d, code: %d, checksum: %d",
  219. // icmp_hdr->icmp_type,
  220. // icmp_hdr->icmp_code,
  221. // ntohs(icmp_hdr->icmp_cksum));
  222. // get inner IP by skipping 4 bytes ICMP header, increment by unit size did not work
  223. struct ip *ip_inner_icmp = (struct ip *)(((char*)icmp_hdr) + 8);
  224. //log_debug("decoder", "ip hl in icmp: %d", ip_inner_icmp->ip_hl);
  225. struct tcphdr *tcp_inner_icmp = (struct tcphdr*)((char *) ip_inner_icmp + 4*ip_inner_icmp->ip_hl);
  226. // replace port and adress information
  227. // as we got the original message back we need to take the reverse order (src => dst, dst => srs)
  228. sport_remote = tcp_inner_icmp->th_dport;
  229. dport_remote = tcp_inner_icmp->th_sport;
  230. source_ip_remote = ip_inner_icmp->ip_dst.s_addr;
  231. // Avoid filtering duplicates on ICMP repsonses
  232. // ZMap sets source (remote) IP itself to filter out duplicates (see src/recv.c -> handle_packet())
  233. // ICMP responses can arrive from same source but "belong" to different targets -> replace source ip with
  234. // destination IP extracted from ICMP payload (the real intended target)
  235. //
  236. *src_ip = source_ip_remote;
  237. //log_debug("decoder", "extracted ICMP data: remote port source <-> dst: %d <-> %d",
  238. // ntohs(sport_remote),
  239. // ntohs(dport_remote));
  240. }
  241. else {
  242. //log_debug("decoder", "icmp message type was not checkable (other than ICMP_TIMXCEED or ICMP_UNREACH): %d",
  243. // icmp_hdr->icmp_type);
  244. return 0;
  245. }
  246. }
  247. else {
  248. // validation is based on IP, TCP and ICMP -> ignore all other
  249. //log_debug("decoder", "can't validate this protocol: %d", ip_hdr->ip_p);
  250. return 0;
  251. }
  252. uint16_t bitpos = 1;
  253. uint16_t marker_bitcount = 0;
  254. // extract source/destination port from source address (attack target)
  255. // destination IP = [[dport]...[sport]] -> sport (and dport) could be ommitted
  256. // we had at maximum markerbits_value Bits to encode sport abd dport
  257. if (zconf.markerbits_value) {
  258. uint32_t source_ip_remote_ho = ntohl(source_ip_remote);
  259. // remove not encoded bits if any
  260. int bits_to_remove = 32 - zconf.markerbits_value;
  261. source_ip_remote_ho = (source_ip_remote_ho >> bits_to_remove) << bits_to_remove;
  262. while (bitpos <= 31 && marker_bitcount <= zconf.markerbits_value) {
  263. if ((zconf.marker_encoding & bitpos) == 1) {
  264. //log_debug("decoder", "decoding dport");
  265. if (!zconf.marker_encoding_dst_small) {
  266. // assume full destination port was encoded
  267. dport_local = (source_ip_remote_ho & 0xFFFF0000) >> 16;
  268. //log_debug("decoder", "decoded dport: %d", dport_local);
  269. marker_bitcount += 16;
  270. } else {
  271. //log_debug("decoder", "small encoding");
  272. // if marker encoding mitigation: assume destination port is the only marker (see encoding)
  273. dport_local = (source_ip_remote_ho & 0xFFC00000) >> (32-10);
  274. // just destination port, skip all other
  275. break;
  276. }
  277. dport_local = htons(dport_local);
  278. }
  279. else if ((zconf.marker_encoding & bitpos) == 4) {
  280. //log_debug("decoder", "decoding sport");
  281. sport_local = (source_ip_remote_ho & (0xFFFF0000 >> marker_bitcount)) >> (16 - marker_bitcount);
  282. //log_debug("decoder", "decoded sport: %d", sport_local);
  283. // [dst][src] -> [src][dst]: remove checksum bits from remote dst
  284. uint32_t dport_remote_ho = ntohs(dport_remote);
  285. dport_remote_ho = (dport_remote_ho >> zconf.markerbits_checksum) << zconf.markerbits_checksum;
  286. dport_remote = htons(dport_remote_ho);
  287. //log_debug("decoder", "changed remote dport to: %d", dport_remote_ho);
  288. marker_bitcount += 16;
  289. //sport_local_viamarker = 1;
  290. sport_local = htons(sport_local);
  291. }
  292. /*
  293. else if ((zconf.marker_encoding & bitpos) == 8) {
  294. }
  295. else if ((zconf.marker_encoding & bitpos) == 16) {
  296. }
  297. */
  298. bitpos <<= 1;
  299. }
  300. }
  301. //log_debug("decoder", "local src/dst -> remote src/dst: %d %d -> %d %d", ntohs(sport_local), ntohs(dport_local), ntohs(sport_remote), ntohs(dport_remote));
  302. // validate remote source port. Check via "&" as source port could be only partially encoded
  303. if ((dport_local & sport_remote) != dport_local) {
  304. //log_debug("decoder", "ports did not match: local dst != remote src -> %d != %d", ntohs(dport_local), ntohs(sport_remote));
  305. return 0;
  306. }
  307. // validate remote destination port: extracted via arriving IP address or local config
  308. //if ((sport_local_viamarker && (sport_local != dport_remote)) || !check_dst_port(ntohs(dport_remote), num_ports, validation)) {
  309. if (sport_local != dport_remote) {
  310. /*
  311. log_debug("decoder", "ports did not match: local src != remote dst -> %d != %d (via marker? %d)",
  312. ntohs(sport_local),
  313. ntohs(dport_remote),
  314. sport_local_viamarker);
  315. */
  316. return 0;
  317. }
  318. // validate tcp acknowledgement number
  319. if (ack_remote != 0 && ( htonl(ack_remote) != htonl(validation[0])+1 ) ) {
  320. //log_debug("decoder", "sequence number did not match");
  321. return 0;
  322. }
  323. //log_debug("decoder", "This was an answer packet!!!");
  324. return 1;
  325. }
  326. /*
  327. Alternative implementation:
  328. Make sure only scanner is initiating new connections -> received RST/SYN/ICMP etc are triggered by the scanner.
  329. */
  330. int synscan_pra_validate_packet_(const struct ip *ip_hdr, uint32_t len,
  331. __attribute__((unused))uint32_t *src_ip,
  332. uint32_t *validation)
  333. {
  334. //log_debug("decoder", "got feedback packet");
  335. // We use the remote source address to derive source/dest port -> compare with source dest port
  336. // Using encoded addresses allows a fast and cheap comparison, using a self defined marker value wouldn't allow that
  337. if (zconf.use_markervalue) {
  338. //log_debug("decoder", "not collecting feedback: using marker value");
  339. return 0;
  340. }
  341. if ((zconf.marker_encoding & 2) == 2) {
  342. //log_debug("decoder", "not collecting feedback: spoofed address");
  343. // we won't get any answers for spoofed addresses -> only check in case of modes 1, 4, 5 (1+4)
  344. return 0;
  345. }
  346. if ((4*ip_hdr->ip_hl + sizeof(struct tcphdr)) > len) {
  347. //log_debug("decoder", "not collecting feedback: packet to large");
  348. // buffer not large enough to contain expected tcp header
  349. return 0;
  350. }
  351. // compare feedback with report responses later on
  352. return 1;
  353. }
  354. void synscan_pra_process_packet(const u_char *packet,
  355. __attribute__((unused)) uint32_t len, fieldset_t *fs)
  356. {
  357. //log_debug("encoder", "writing feedback packet to file");
  358. // Idea: how to correlate reponse <-> marker group? This has to be done by comparing
  359. // response IP addresses to groups.
  360. struct ip *ip_hdr = (struct ip *)&packet[sizeof(struct ether_header)];
  361. // WARNING: fields have to be written in the same order as defined in fields[]
  362. // That is the reason why this code looks a bit redundant
  363. if (ip_hdr->ip_p == IPPROTO_TCP) {
  364. //log_debug("encoder", "storing TCP response");
  365. struct tcphdr *tcp = (struct tcphdr*)((char *)ip_hdr + 4*ip_hdr->ip_hl);
  366. fs_add_uint64(fs, "sport", (uint64_t) ntohs(tcp->th_sport));
  367. fs_add_uint64(fs, "dport", (uint64_t) ntohs(tcp->th_dport));
  368. fs_add_uint64(fs, "seqnum", (uint64_t) ntohl(tcp->th_seq));
  369. fs_add_uint64(fs, "acknum", (uint64_t) ntohl(tcp->th_ack));
  370. fs_add_uint64(fs, "window", (uint64_t) ntohs(tcp->th_win));
  371. fs_add_string(fs, "daddr_inner_icmp", (char*) "(None)", 0);
  372. if (tcp->th_flags & TH_RST) { // RST packet
  373. fs_add_string(fs, "classification", (char*) "rst", 0);
  374. fs_add_uint64(fs, "success", 0);
  375. } else { // SYNACK packet
  376. fs_add_string(fs, "classification", (char*) "synack", 0);
  377. fs_add_uint64(fs, "success", 1);
  378. }
  379. }
  380. else {
  381. // prefiltering was already done in synscan_pra_validate_packet()
  382. //log_debug("encoder", "storing ICMP response");
  383. struct icmp *icmp_hdr = (struct icmp *) ((char *) ip_hdr + 4*ip_hdr->ip_hl);
  384. struct ip *ip_hdr_from_icmp = (struct ip *)(((char * )icmp_hdr) + 8);
  385. struct tcphdr *tcp = (struct tcphdr*)((char *)ip_hdr_from_icmp + 4*ip_hdr_from_icmp->ip_hl);
  386. // switch source/destination port: source is always the attacker
  387. fs_add_uint64(fs, "sport", (uint64_t) ntohs(tcp->th_dport));
  388. fs_add_uint64(fs, "dport", (uint64_t) ntohs(tcp->th_sport));
  389. fs_add_uint64(fs, "seqnum", (uint64_t) 0);
  390. fs_add_uint64(fs, "acknum", (uint64_t) 0);
  391. fs_add_uint64(fs, "window", (uint64_t) 0);
  392. fs_add_string(fs, "daddr_inner_icmp", make_ip_str(ip_hdr_from_icmp->ip_dst.s_addr), 0);
  393. if (icmp_hdr->icmp_type == ICMP_UNREACH)
  394. fs_add_string(fs, "classification", (char*) "icmp_unreach", 0);
  395. else if(icmp_hdr->icmp_type == ICMP_TIMXCEED)
  396. fs_add_string(fs, "classification", (char*) "icmp_timeexceed", 0);
  397. else
  398. fs_add_string(fs, "classification", (char*) "icmp_other", 0);
  399. fs_add_uint64(fs, "success", 1);
  400. }
  401. }
  402. static fielddef_t fields[] = {
  403. {.name = "sport", .type = "int", .desc = "TCP source port"},
  404. {.name = "dport", .type = "int", .desc = "TCP destination port"},
  405. {.name = "seqnum", .type = "int", .desc = "TCP sequence number"},
  406. {.name = "acknum", .type = "int", .desc = "TCP acknowledgement number"},
  407. {.name = "window", .type = "int", .desc = "TCP window"},
  408. {.name = "daddr_inner_icmp", .type="string", .desc = "Destination address of IP header contained in ICMP response"},
  409. {.name = "classification", .type="string", .desc = "packet classification"},
  410. {.name = "success", .type="int", .desc = "is response considered success"}
  411. };
  412. probe_module_t module_tcp_synscan_proberesponse = {
  413. .name = "tcp_synscan_pra",
  414. .packet_length = 60,
  415. //.packet_length = 82,
  416. .pcap_filter = "icmp || (tcp && tcp[13] & 4 != 0 || tcp[13] == 18)",
  417. .pcap_snaplen = 96,
  418. .port_args = 1,
  419. .global_initialize = &synscan_pra_global_initialize,
  420. .thread_initialize = &synscan_pra_init_perthread,
  421. .make_packet = &synscan_pra_make_packet,
  422. .print_packet = &synscan_pra_print_packet,
  423. .process_packet = &synscan_pra_process_packet,
  424. .validate_packet = &synscan_pra_validate_packet,
  425. .close = NULL,
  426. .helptext = "Extended TCP probe module for probe response attacks. ",
  427. .fields = fields,
  428. .numfields = 8};