nsrstplug.lua 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. --------------------------------------------------------------------------------
  2. -- 1. Define a new protocol
  3. --------------------------------------------------------------------------------
  4. local citrix_reset_proto = Proto("citrix_reset", "Citrix ADC Reset Codes")
  5. --------------------------------------------------------------------------------
  6. -- 2. Define the fields for this protocol
  7. --------------------------------------------------------------------------------
  8. citrix_reset_proto.fields.reset_window = ProtoField.uint16(
  9. "citrix_reset.window_size",
  10. "Citrix Reset Window Size",
  11. base.DEC
  12. )
  13. --------------------------------------------------------------------------------
  14. -- 3. Define field extractors from the existing TCP dissector
  15. --------------------------------------------------------------------------------
  16. local f_tcp_srcport = Field.new("tcp.srcport")
  17. local f_tcp_dstport = Field.new("tcp.dstport")
  18. local f_tcp_window_size = Field.new("tcp.window_size") -- or "tcp.window_size_value"
  19. local f_tcp_flags_reset = Field.new("tcp.flags.reset")
  20. --------------------------------------------------------------------------------
  21. -- 4. Define the lookup table for Citrix ADC reset codes
  22. --------------------------------------------------------------------------------
  23. local window_size_lookup = {
  24. [8196] = "SSL bad record.",
  25. [8201] = "NSDBG_RST_SSTRAY, 8201 – NSDBG_RST_SSTRAY",
  26. [8202] = "NSDBG_RST_CSTRAY: Triggered when the NetScaler receives data on a connection with an expired SYN cookie.",
  27. [8204] = "Client retransmitted SYN with the wrong sequence number.",
  28. [8205] = "ACK number in the final ACK from peer during connection establishment is wrong.",
  29. [8206] = "Received a bad packet in TCPS_SYN_SENT state (non-RST). Possibly reused 4-tuple from old connection.",
  30. [8207] = "Received SYN on an established connection within the window. Protects from spoofing attacks.",
  31. [8208] = "Reset after receiving more than the configured number of duplicate retransmissions.",
  32. [8209] = "Memory allocation failure (system out of memory).",
  33. [8210] = "HTTP DoS protection triggered by a bad client request.",
  34. [8211] = "Cleanup of idle connections.",
  35. [8212] = "Stray SYN packet with no listening service or invalid SYN cookie.",
  36. [8213] = "Sure Connect feature, bad client sending post on a closing connection.",
  37. [8214] = "MSS in SYN exceeded NIC/VLAN MTU.",
  38. [9100] = "NSDBG_RST_ORP: Orphan HTTP connection timed out waiting for completion.",
  39. [9212] = "HTTP invalid request.",
  40. [9214] = "Cache resource store failed.",
  41. [9216] = "Cache async no memory.",
  42. [9217] = "HTTP state machine error from receiving content longer than specified Content-Length.",
  43. [9218] = "Terminated due to extra orphan data.",
  44. [9219] = "NSB allocation failure.",
  45. [9220] = "Could not allocate new NSB (various reasons).",
  46. [9221] = "vurl includes an invalid domain shard.",
  47. [9222] = "Response was RFC-noncompliant (e.g., both Content-Length and Transfer-Encoding invalid).",
  48. [9300] = "NSDBG_RST_ZSSSR: Zombie timer/idle timeout or service-down event.",
  49. [9301] = "NSDBG_RST_ZSSSR: Zombie timer/idle timeout or service-down event.",
  50. [9302] = "NSDBG_RST_ZSSSR: Zombie timer/idle timeout or service-down event.",
  51. [9303] = "NSDBG_RST_ZSSSR: Zombie timer/idle timeout or service-down event.",
  52. [9304] = "NSDBG_RST_LINK_GIVEUPS: Freed session after zero window probe limit exceeded.",
  53. [9305] = "Server ACK to SYN had an invalid ACK number.",
  54. [9306] = "TCP buffering undone due to duplicate TCPB enablement.",
  55. [9307] = "Small window protection triggered reset.",
  56. [9308] = "Small window protection triggered reset.",
  57. [9309] = "Small window protection triggered reset.",
  58. [9310] = "TCP keepalive probing failed.",
  59. [9311] = "DHT retry failed.",
  60. [9400] = "Reset server connections in reusepool that are not reusable.",
  61. [9401] = "Reset older connections to free capacity for new ones or when removing an entity with active connections.",
  62. [9450] = "SQL HS failed.",
  63. [9451] = "SQL response failed.",
  64. [9452] = "SQL request list failed.",
  65. [9453] = "SQL UNK not linked.",
  66. [9454] = "SQL NSB hold failed.",
  67. [9455] = "SQL Server First Packet.",
  68. [9456] = "SQL login response arrived before request.",
  69. [9457] = "SQL server login failed.",
  70. [9458] = "SQL no memory.",
  71. [9459] = "SQL bad server.",
  72. [9460] = "SQL link failed.",
  73. [9600] = "Reset if # of pkts with Sequence/ACK mismatch > nscfg_max_orphan_pkts.",
  74. [9601] = "Reset if # of data pkts with Sequence/ACK mismatch > nscfg_max_orphan_pkts.",
  75. [9602] = "SSL VPN CS probe limit exceeded.",
  76. [9700] = "NSDBG_RST_PASS: RST forwarded from client or server.",
  77. [9701] = "NSDBG_RST_ACK_PASS: RST + ACK forwarded from client or server.",
  78. [9702] = "Data received after FIN.",
  79. [9704] = "NSB dropped (hold limit or transaction error).",
  80. [9800] = "NSDBG_RST_PROBE: Monitoring service reset due to timeout.",
  81. [9810] = "Responses match the configured NAI status code.",
  82. [9811] = "NSDBG_RST_ERRHANDLER: Used with SSL after sending a Fatal Alert.",
  83. [9812] = "Connection flushing: existing IP removed from configuration.",
  84. [9813] = "Closing the SSF connection.",
  85. [9814] = "NSDBG_RST_PETRIGGER: Reset triggered by policy engine match.",
  86. [9816] = "Bad SSL record.",
  87. [9817] = "SSL connection changed while updating bound certificate.",
  88. [9818] = "Bad SSL header value.",
  89. [9819] = "Failed to allocate memory for SPCB.",
  90. [9820] = "SSL card operation failed.",
  91. [9821] = "SSL feature disabled; resetting the connection.",
  92. [9822] = "SSL cipher changed; old-cipher connection flush.",
  93. [9823] = "Malformed NSC_AAAC cookie or memory failure in certificate processing.",
  94. [9824] = "Reset on AAA orphan connections.",
  95. [9825] = "DBG_WRONG_GSLBRECDLEN: MEP error reset code, typically from version mismatch.",
  96. [9826] = "Insufficient memory for NET buffers.",
  97. [9827] = "Reset on SSL config change.",
  98. [9829] = "Reset on GSLB other site down/out of reach.",
  99. [9830] = "Reset for sessions matching ACL DENY rule.",
  100. [9831] = "Connection had no application data but needed it.",
  101. [9832] = "Application error.",
  102. [9833] = "Fatal SSL error.",
  103. [9834] = "Reset while flushing all SPCB (fips or hsm init).",
  104. [9835] = "DTLS record too large.",
  105. [9836] = "DTLS record zero length.",
  106. [9837] = "SSLv2 record too large.",
  107. [9838] = "NSBE_DBG_RST_SSL_BAD_RECORD: SSL record lookup error.",
  108. [9839] = "SSL max NSB hold limit reached.",
  109. [9841] = "SSL/DTLS split packet failure.",
  110. [9842] = "SSL NSB allocation failure.",
  111. [9843] = "Monitor wide IP probe.",
  112. [9844] = "SSL reneg max NSB limit or allocation failure.",
  113. [9845] = "Reset on Appsec policy.",
  114. [9846] = "Delta compression aborted or failed.",
  115. [9847] = "Delta compression aborted or failed.",
  116. [9848] = "Reset on new SSL connection accepted during config change.",
  117. [9849] = "GSLB conflict from misconfiguration.",
  118. [9850] = "DNS TCP connection untrackable (compact NSB failure, etc.).",
  119. [9851] = "DNS TCP failure (invalid payload length, etc.).",
  120. [9852] = "RTSP (ALG) session handling error.",
  121. [9853] = "MSSQL Auth response error.",
  122. [9854] = "Indirect GSLB sites tried to establish connection.",
  123. [9855] = "For HTTP/SSL vservers, SO threshold reached.",
  124. [9856] = "AppFW ASYNC failure.",
  125. [9857] = "Reset while flushing HTTP waiting PCB.",
  126. [9858] = "Reset on re-chunk abort.",
  127. [9859] = "New client connection deferrable by server on the label.",
  128. [9860] = "pcb->link cleaned, connection reset.",
  129. [9861] = "Push vserver connection reset if push disabled on client vserver.",
  130. [9862] = "Reset to client for duplicate server connection.",
  131. [9863] = "Reset old connection if new connection established but old one not freed.",
  132. [9864] = "CVPN HINFO restore failed.",
  133. [9865] = "CVPN MCMX error.",
  134. [9866] = "URL policy transform error.",
  135. [9868] = "MSSQL login errors.",
  136. [9870] = "SQL login parse error.",
  137. [9871] = "MSSQL memory allocation failure.",
  138. [9872] = "Websocket upgrade request dropped due to disabled Websocket in HTTP profile.",
  139. [9873] = "Agsvc MCMX failure.",
  140. [9874] = "NSB hold limit reached.",
  141. [9875] = "RADIUS request parse error.",
  142. [9876] = "RADIUS response parse error.",
  143. [9877] = "RADIUS request dropped.",
  144. [9878] = "RADIUS response dropped.",
  145. [9879] = "Invalid RADIUS request.",
  146. [9880] = "Invalid RADIUS response.",
  147. [9881] = "RADIUS no memory.",
  148. [9882] = "RADIUS link failed.",
  149. [9883] = "RADIUS unlinked.",
  150. [9884] = "RADIUS unexpected error.",
  151. [9885] = "RADIUS unhandled response.",
  152. [9886] = "RADIUS unhandled request.",
  153. [9887] = "RADIUS missing UNK.",
  154. [9888] = "RADIUS wrong UNK.",
  155. [9889] = "RADIUS UNK refcnt.",
  156. [9890] = "RADIUS UNK purge.",
  157. [9891] = "RADIUS tunnel reject.",
  158. [9892] = "RADIUS unknown error.",
  159. [9893] = "Monitor probe reset.",
  160. [9894] = "Monitor mark down.",
  161. [9895] = "Monitor probe flush.",
  162. [9896] = "Monitor payload too small.",
  163. [9897] = "SNMP wrong packet.",
  164. [9898] = "SNMP wrong version.",
  165. [9899] = "SNMP wrong community.",
  166. [9900] = "SNMP wrong community.",
  167. [9901] = "SNMP wrong PDU.",
  168. [9902] = "SNMP wrong type.",
  169. [9903] = "SNMP wrong request ID.",
  170. [9904] = "SNMP wrong error status.",
  171. [9905] = "SNMP wrong error index.",
  172. [9906] = "SNMP no such object.",
  173. [9907] = "SNMP no such instance.",
  174. [9908] = "SNMP too big.",
  175. [9909] = "SNMP read only.",
  176. [9910] = "SNMP gen error.",
  177. [9911] = "SNMP wrong encoding.",
  178. [9912] = "SNMP wrong length.",
  179. [9913] = "SNMP wrong value.",
  180. [9914] = "SNMP no memory.",
  181. [9915] = "SNMP no response.",
  182. [9916] = "SNMP not writable.",
  183. [9917] = "SNMP auth error.",
  184. [9918] = "SNMP wrong digest.",
  185. [9919] = "SNMP bad value.",
  186. [9920] = "SNMP not in MIB.",
  187. [9921] = "SNMP too many indices.",
  188. [9922] = "SNMP not enough indices.",
  189. [9923] = "SNMP wrong index type.",
  190. [9924] = "SNMP wrong index length.",
  191. [9925] = "SNMP wrong index value.",
  192. [9926] = "SNMP no such name.",
  193. [9927] = "SNMP wrong varbind list.",
  194. [9928] = "SNMP end of MIB.",
  195. [9929] = "SNMP too big for packet.",
  196. [9930] = "SNMP no such view.",
  197. [9931] = "SNMP no such context.",
  198. [9932] = "SNMP no such user.",
  199. [9933] = "SNMP not in view.",
  200. [9934] = "SNMP unsupported security level.",
  201. [9935] = "SNMP unsupported auth protocol.",
  202. [9936] = "SNMP unsupported priv protocol.",
  203. [9937] = "SNMP unknown user name.",
  204. [9938] = "SNMP unknown engine ID.",
  205. [9939] = "SNMP wrong security model.",
  206. [9940] = "SNMP bad security level.",
  207. [9941] = "SNMP bad engine ID.",
  208. [9942] = "SNMP bad user name.",
  209. [9943] = "SNMP bad auth protocol.",
  210. [9944] = "SNMP bad priv protocol.",
  211. [9945] = "SNMP bad security name.",
  212. [9946] = "SNMP bad security model.",
  213. [9947] = "SNMP bad message.",
  214. [9948] = "SNMP bad PDU.",
  215. [9949] = "SNMP bad SPI.",
  216. [9950] = "SNMP bad context.",
  217. [9951] = "SNMP bad security state ref.",
  218. [9952] = "SNMP bad security name.",
  219. [9953] = "SNMP bad community.",
  220. [9954] = "SNMP bad community uses.",
  221. [9955] = "SNMP bad community name.",
  222. [9956] = "SNMP bad community indexing.",
  223. [9957] = "SNMP bad party.",
  224. [9958] = "SNMP bad party uses.",
  225. [9959] = "SNMP bad party name.",
  226. [9960] = "SNMP bad party indexing.",
  227. [9961] = "SNMP bad party TDomain.",
  228. [9962] = "SNMP bad party TAddress.",
  229. [9963] = "SNMP bad party identity.",
  230. [9964] = "SNMP bad party TTimeout.",
  231. [9965] = "SNMP bad party TMaxMessageSize.",
  232. [9966] = "SNMP bad party priv proto.",
  233. [9967] = "SNMP bad party auth clock.",
  234. [9968] = "SNMP bad party auth lifetime.",
  235. [9969] = "SNMP bad party auth private.",
  236. [9970] = "SNMP bad party auth public.",
  237. [9971] = "SNMP bad party auth clock skew.",
  238. [9972] = "SNMP bad party auth truncated.",
  239. [9973] = "SNMP bad party auth wrong digest.",
  240. [9974] = "SNMP bad party auth wrong.",
  241. [9975] = "SNMP bad context.",
  242. [9976] = "SNMP bad context uses.",
  243. [9977] = "SNMP bad context name.",
  244. [9978] = "SNMP bad context indexing.",
  245. [9979] = "SNMP bad ACL.",
  246. [9980] = "SNMP bad ACL uses.",
  247. [9981] = "SNMP bad ACL name.",
  248. [9982] = "SNMP bad ACL indexing.",
  249. [9983] = "SNMP bad ACL party.",
  250. [9984] = "SNMP bad ACL context.",
  251. [9985] = "SNMP bad ACL privs.",
  252. [9986] = "SNMP bad view.",
  253. [9987] = "SNMP bad view uses.",
  254. [9988] = "SNMP bad view name.",
  255. [9989] = "SNMP bad view indexing.",
  256. [9990] = "SNMP bad view subtree.",
  257. [9991] = "SNMP bad view mask.",
  258. [9992] = "SNMP bad view type.",
  259. [9993] = "SNMP bad view storage.",
  260. [9994] = "SNMP bad view status.",
  261. [9995] = "SNMP bad MIB.",
  262. [9996] = "SNMP bad MIB name.",
  263. [9997] = "SNMP bad MIB syntax.",
  264. [9998] = "SNMP bad MIB write syntax.",
  265. [9999] = "SNMP bad MIB access.",
  266. [10000] = "SNMP bad MIB status.",
  267. [10001] = "SNMP bad MIB indexes.",
  268. [10002] = "SNMP bad MIB deps.",
  269. [10003] = "SNMP bad MIB inits."
  270. }
  271. --------------------------------------------------------------------------------
  272. -- 5. Dissection function
  273. --------------------------------------------------------------------------------
  274. function citrix_reset_proto.dissector(buffer, pinfo, tree)
  275. -- Fetch extracted fields
  276. local tcp_srcport = f_tcp_srcport()
  277. local tcp_dstport = f_tcp_dstport()
  278. local tcp_rstflag = f_tcp_flags_reset()
  279. local tcp_win = f_tcp_window_size()
  280. -- If any required fields are nil, no further processing
  281. if not (tcp_srcport and tcp_dstport and tcp_rstflag and tcp_win) then
  282. return
  283. end
  284. -- Convert to numeric
  285. local rst_val = tonumber(tostring(tcp_rstflag))
  286. local win_val = tonumber(tostring(tcp_win))
  287. -- Check if the RST flag is set
  288. if rst_val == 1 and win_val then
  289. local description = window_size_lookup[win_val]
  290. if description then
  291. -- Create a subtree for Citrix ADC info
  292. local subtree = tree:add(
  293. citrix_reset_proto,
  294. buffer(),
  295. "Citrix ADC Reset Info"
  296. )
  297. -- Add window size field
  298. local item = subtree:add(
  299. citrix_reset_proto.fields.reset_window,
  300. buffer(),
  301. win_val
  302. )
  303. -- Append textual description
  304. item:append_text(" (" .. description .. ")")
  305. end
  306. end
  307. end
  308. --------------------------------------------------------------------------------
  309. -- 6. Register the post-dissector
  310. --------------------------------------------------------------------------------
  311. register_postdissector(citrix_reset_proto)