redhound 1.0.1 → 2.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -0
  3. data/README.md +97 -31
  4. data/docs/API.md +104 -0
  5. data/docs/FILTERS.md +37 -0
  6. data/docs/MIGRATION.md +23 -0
  7. data/docs/PROTOCOLS.md +54 -0
  8. data/docs/USAGE.md +86 -0
  9. data/docs/VALIDATION.md +175 -0
  10. data/docs/json-schema.json +64 -0
  11. data/exe/redhound +2 -1
  12. data/lib/redhound/analysis/flow_key.rb +59 -0
  13. data/lib/redhound/analysis/flow_table.rb +124 -0
  14. data/lib/redhound/analysis/ip_reassembler.rb +209 -0
  15. data/lib/redhound/analysis/stats.rb +150 -0
  16. data/lib/redhound/analysis/tcp_analysis.rb +43 -0
  17. data/lib/redhound/analysis/tcp_reassembler.rb +176 -0
  18. data/lib/redhound/analysis/tcp_stream.rb +156 -0
  19. data/lib/redhound/analysis.rb +157 -0
  20. data/lib/redhound/capture/bsd/bpf_device.rb +155 -0
  21. data/lib/redhound/capture/bsd/constants.rb +29 -0
  22. data/lib/redhound/capture/bsd/ifreq.rb +41 -0
  23. data/lib/redhound/capture/file_source.rb +214 -0
  24. data/lib/redhound/capture/interface.rb +70 -0
  25. data/lib/redhound/capture/linktype.rb +30 -0
  26. data/lib/redhound/capture/linux/constants.rb +37 -0
  27. data/lib/redhound/capture/linux/cooked.rb +18 -0
  28. data/lib/redhound/capture/linux/ifreq.rb +42 -0
  29. data/lib/redhound/capture/linux/packet_socket.rb +224 -0
  30. data/lib/redhound/capture/linux/sockaddr_ll.rb +33 -0
  31. data/lib/redhound/capture/linux/tpacket_v3.rb +137 -0
  32. data/lib/redhound/capture/source.rb +79 -0
  33. data/lib/redhound/capture/stats.rb +22 -0
  34. data/lib/redhound/capture.rb +70 -0
  35. data/lib/redhound/cli/command.rb +42 -0
  36. data/lib/redhound/cli/options.rb +133 -0
  37. data/lib/redhound/cli/privileges.rb +29 -0
  38. data/lib/redhound/cli/runner.rb +129 -0
  39. data/lib/redhound/context.rb +20 -0
  40. data/lib/redhound/cursor.rb +69 -0
  41. data/lib/redhound/diagnostic.rb +7 -0
  42. data/lib/redhound/dissector.rb +152 -0
  43. data/lib/redhound/engine.rb +69 -0
  44. data/lib/redhound/errors.rb +38 -0
  45. data/lib/redhound/field.rb +62 -0
  46. data/lib/redhound/file/format.rb +63 -0
  47. data/lib/redhound/file/pcap_reader.rb +43 -0
  48. data/lib/redhound/file/pcap_writer.rb +79 -0
  49. data/lib/redhound/file/pcapng_reader.rb +221 -0
  50. data/lib/redhound/file/pcapng_writer.rb +151 -0
  51. data/lib/redhound/file/rotating_writer.rb +98 -0
  52. data/lib/redhound/filter/analyzer.rb +197 -0
  53. data/lib/redhound/filter/bpf/assembler.rb +121 -0
  54. data/lib/redhound/filter/bpf/disassembler.rb +58 -0
  55. data/lib/redhound/filter/bpf/validator.rb +77 -0
  56. data/lib/redhound/filter/bpf/vm.rb +109 -0
  57. data/lib/redhound/filter/codegen.rb +413 -0
  58. data/lib/redhound/filter/lexer.rb +46 -0
  59. data/lib/redhound/filter/parser.rb +206 -0
  60. data/lib/redhound/filter/program.rb +55 -0
  61. data/lib/redhound/filter.rb +30 -0
  62. data/lib/redhound/layer.rb +75 -0
  63. data/lib/redhound/output/fields.rb +20 -0
  64. data/lib/redhound/output/follow.rb +64 -0
  65. data/lib/redhound/output/hexdump.rb +29 -0
  66. data/lib/redhound/output/json.rb +32 -0
  67. data/lib/redhound/output/summary.rb +84 -0
  68. data/lib/redhound/output/timestamp.rb +34 -0
  69. data/lib/redhound/output/tree.rb +25 -0
  70. data/lib/redhound/packet.rb +77 -0
  71. data/lib/redhound/protocols/arp.rb +39 -0
  72. data/lib/redhound/protocols/checksum.rb +38 -0
  73. data/lib/redhound/protocols/data.rb +23 -0
  74. data/lib/redhound/protocols/dhcp.rb +140 -0
  75. data/lib/redhound/protocols/dns.rb +268 -0
  76. data/lib/redhound/protocols/ethernet.rb +24 -0
  77. data/lib/redhound/protocols/http.rb +185 -0
  78. data/lib/redhound/protocols/icmp.rb +205 -0
  79. data/lib/redhound/protocols/ipv4.rb +56 -0
  80. data/lib/redhound/protocols/ipv6.rb +68 -0
  81. data/lib/redhound/protocols/link.rb +70 -0
  82. data/lib/redhound/protocols/llc.rb +37 -0
  83. data/lib/redhound/protocols/ntp.rb +45 -0
  84. data/lib/redhound/protocols/tcp.rb +88 -0
  85. data/lib/redhound/protocols/tls.rb +218 -0
  86. data/lib/redhound/protocols/tunnel.rb +48 -0
  87. data/lib/redhound/protocols/udp.rb +32 -0
  88. data/lib/redhound/protocols/vlan.rb +23 -0
  89. data/lib/redhound/reader.rb +8 -0
  90. data/lib/redhound/registry.rb +64 -0
  91. data/lib/redhound/stream_dissector.rb +168 -0
  92. data/lib/redhound/util/seq.rb +21 -0
  93. data/lib/redhound/version.rb +2 -1
  94. data/lib/redhound/writer.rb +25 -43
  95. data/lib/redhound.rb +81 -9
  96. data/sig/generated/redhound/analysis/flow_key.rbs +15 -0
  97. data/sig/generated/redhound/analysis/flow_table.rbs +102 -0
  98. data/sig/generated/redhound/analysis/ip_reassembler.rbs +52 -0
  99. data/sig/generated/redhound/analysis/stats.rbs +80 -0
  100. data/sig/generated/redhound/analysis/tcp_analysis.rbs +15 -0
  101. data/sig/generated/redhound/analysis/tcp_reassembler.rbs +39 -0
  102. data/sig/generated/redhound/analysis/tcp_stream.rbs +60 -0
  103. data/sig/generated/redhound/analysis.rbs +38 -0
  104. data/sig/generated/redhound/capture/bsd/bpf_device.rbs +39 -0
  105. data/sig/generated/redhound/capture/bsd/constants.rbs +40 -0
  106. data/sig/generated/redhound/capture/bsd/ifreq.rbs +15 -0
  107. data/sig/generated/redhound/capture/file_source.rbs +67 -0
  108. data/sig/generated/redhound/capture/interface.rbs +53 -0
  109. data/sig/generated/redhound/capture/linktype.rbs +20 -0
  110. data/sig/generated/redhound/capture/linux/constants.rbs +58 -0
  111. data/sig/generated/redhound/capture/linux/cooked.rbs +15 -0
  112. data/sig/generated/redhound/capture/linux/ifreq.rbs +18 -0
  113. data/sig/generated/redhound/capture/linux/packet_socket.rbs +64 -0
  114. data/sig/generated/redhound/capture/linux/sockaddr_ll.rbs +31 -0
  115. data/sig/generated/redhound/capture/linux/tpacket_v3.rbs +35 -0
  116. data/sig/generated/redhound/capture/source.rbs +44 -0
  117. data/sig/generated/redhound/capture/stats.rbs +25 -0
  118. data/sig/generated/redhound/capture.rbs +14 -0
  119. data/sig/generated/redhound/cli/command.rbs +12 -0
  120. data/sig/generated/redhound/cli/options.rbs +25 -0
  121. data/sig/generated/redhound/cli/privileges.rbs +12 -0
  122. data/sig/generated/redhound/cli/runner.rbs +27 -0
  123. data/sig/generated/redhound/context.rbs +27 -0
  124. data/sig/generated/redhound/cursor.rbs +59 -0
  125. data/sig/generated/redhound/diagnostic.rbs +21 -0
  126. data/sig/generated/redhound/dissector.rbs +117 -0
  127. data/sig/generated/redhound/engine.rbs +23 -0
  128. data/sig/generated/redhound/errors.rbs +56 -0
  129. data/sig/generated/redhound/field.rbs +74 -0
  130. data/sig/generated/redhound/file/format.rbs +39 -0
  131. data/sig/generated/redhound/file/pcap_reader.rbs +19 -0
  132. data/sig/generated/redhound/file/pcap_writer.rbs +38 -0
  133. data/sig/generated/redhound/file/pcapng_reader.rbs +54 -0
  134. data/sig/generated/redhound/file/pcapng_writer.rbs +50 -0
  135. data/sig/generated/redhound/file/rotating_writer.rbs +42 -0
  136. data/sig/generated/redhound/filter/analyzer.rbs +42 -0
  137. data/sig/generated/redhound/filter/bpf/assembler.rbs +39 -0
  138. data/sig/generated/redhound/filter/bpf/disassembler.rbs +18 -0
  139. data/sig/generated/redhound/filter/bpf/validator.rbs +30 -0
  140. data/sig/generated/redhound/filter/bpf/vm.rbs +28 -0
  141. data/sig/generated/redhound/filter/codegen.rbs +101 -0
  142. data/sig/generated/redhound/filter/lexer.rbs +15 -0
  143. data/sig/generated/redhound/filter/parser.rbs +65 -0
  144. data/sig/generated/redhound/filter/program.rbs +48 -0
  145. data/sig/generated/redhound/filter.rbs +10 -0
  146. data/sig/generated/redhound/layer.rbs +81 -0
  147. data/sig/generated/redhound/output/fields.rbs +15 -0
  148. data/sig/generated/redhound/output/follow.rbs +21 -0
  149. data/sig/generated/redhound/output/hexdump.rbs +15 -0
  150. data/sig/generated/redhound/output/json.rbs +18 -0
  151. data/sig/generated/redhound/output/summary.rbs +21 -0
  152. data/sig/generated/redhound/output/timestamp.rbs +21 -0
  153. data/sig/generated/redhound/output/tree.rbs +15 -0
  154. data/sig/generated/redhound/packet.rbs +82 -0
  155. data/sig/generated/redhound/protocols/arp.rbs +15 -0
  156. data/sig/generated/redhound/protocols/checksum.rbs +15 -0
  157. data/sig/generated/redhound/protocols/data.rbs +17 -0
  158. data/sig/generated/redhound/protocols/dhcp.rbs +31 -0
  159. data/sig/generated/redhound/protocols/dns.rbs +42 -0
  160. data/sig/generated/redhound/protocols/ethernet.rbs +15 -0
  161. data/sig/generated/redhound/protocols/http.rbs +36 -0
  162. data/sig/generated/redhound/protocols/icmp.rbs +41 -0
  163. data/sig/generated/redhound/protocols/ipv4.rbs +15 -0
  164. data/sig/generated/redhound/protocols/ipv6.rbs +24 -0
  165. data/sig/generated/redhound/protocols/link.rbs +33 -0
  166. data/sig/generated/redhound/protocols/llc.rbs +15 -0
  167. data/sig/generated/redhound/protocols/ntp.rbs +17 -0
  168. data/sig/generated/redhound/protocols/tcp.rbs +25 -0
  169. data/sig/generated/redhound/protocols/tls.rbs +51 -0
  170. data/sig/generated/redhound/protocols/tunnel.rbs +24 -0
  171. data/sig/generated/redhound/protocols/udp.rbs +18 -0
  172. data/sig/generated/redhound/protocols/vlan.rbs +12 -0
  173. data/sig/generated/redhound/reader.rbs +7 -0
  174. data/sig/generated/redhound/registry.rbs +45 -0
  175. data/sig/generated/redhound/stream_dissector.rbs +44 -0
  176. data/sig/generated/redhound/util/seq.rbs +20 -0
  177. data/sig/generated/redhound/version.rbs +1 -0
  178. data/sig/generated/redhound/writer.rbs +6 -19
  179. data/sig/generated/redhound.rbs +18 -0
  180. data/sig/shims/io.rbs +7 -0
  181. data/sig/shims/process.rbs +3 -0
  182. metadata +177 -55
  183. data/CODE_OF_CONDUCT.md +0 -132
  184. data/Dockerfile +0 -7
  185. data/Rakefile +0 -15
  186. data/Steepfile +0 -4
  187. data/docker-compose.yml +0 -9
  188. data/lib/redhound/analyzer.rb +0 -34
  189. data/lib/redhound/builder/packet_mreq.rb +0 -56
  190. data/lib/redhound/builder/socket.rb +0 -35
  191. data/lib/redhound/builder.rb +0 -4
  192. data/lib/redhound/command.rb +0 -67
  193. data/lib/redhound/l2/ether.rb +0 -68
  194. data/lib/redhound/l2/protocol.rb +0 -33
  195. data/lib/redhound/l2.rb +0 -4
  196. data/lib/redhound/l3/arp.rb +0 -114
  197. data/lib/redhound/l3/base.rb +0 -49
  198. data/lib/redhound/l3/ipv4.rb +0 -95
  199. data/lib/redhound/l3/ipv6.rb +0 -69
  200. data/lib/redhound/l3/protocol.rb +0 -173
  201. data/lib/redhound/l3/resolver.rb +0 -30
  202. data/lib/redhound/l3.rb +0 -9
  203. data/lib/redhound/l4/base.rb +0 -31
  204. data/lib/redhound/l4/icmp.rb +0 -71
  205. data/lib/redhound/l4/resolver.rb +0 -28
  206. data/lib/redhound/l4/udp.rb +0 -63
  207. data/lib/redhound/l4.rb +0 -6
  208. data/lib/redhound/receiver.rb +0 -45
  209. data/lib/redhound/resolver.rb +0 -22
  210. data/lib/redhound/source/socket.rb +0 -18
  211. data/lib/redhound/source.rb +0 -3
  212. data/rbs_collection.lock.yaml +0 -20
  213. data/rbs_collection.yaml +0 -17
  214. data/sig/generated/redhound/analyzer.rbs +0 -14
  215. data/sig/generated/redhound/builder/packet_mreq.rbs +0 -39
  216. data/sig/generated/redhound/builder/socket.rbs +0 -24
  217. data/sig/generated/redhound/command.rbs +0 -19
  218. data/sig/generated/redhound/l2/ether.rbs +0 -41
  219. data/sig/generated/redhound/l2/protocol.rbs +0 -15
  220. data/sig/generated/redhound/l3/arp.rbs +0 -57
  221. data/sig/generated/redhound/l3/base.rbs +0 -28
  222. data/sig/generated/redhound/l3/ipv4.rbs +0 -53
  223. data/sig/generated/redhound/l3/ipv6.rbs +0 -38
  224. data/sig/generated/redhound/l3/protocol.rbs +0 -16
  225. data/sig/generated/redhound/l3/resolver.rbs +0 -16
  226. data/sig/generated/redhound/l4/base.rbs +0 -19
  227. data/sig/generated/redhound/l4/icmp.rbs +0 -33
  228. data/sig/generated/redhound/l4/resolver.rbs +0 -16
  229. data/sig/generated/redhound/l4/udp.rbs +0 -36
  230. data/sig/generated/redhound/receiver.rbs +0 -19
  231. data/sig/generated/redhound/resolver.rbs +0 -11
  232. data/sig/generated/redhound/source/socket.rbs +0 -13
@@ -0,0 +1,15 @@
1
+ # Generated from lib/redhound/protocols/ethernet.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Ethernet < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> void
9
+ def dissect: (Context ctx, Layer layer) -> void
10
+
11
+ # @rbs (Context ctx, Layer layer) -> untyped
12
+ def next_dissector: (Context ctx, Layer layer) -> untyped
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,36 @@
1
+ # Generated from lib/redhound/protocols/http.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Http < StreamDissector
8
+ HEADER_LIMIT: ::Integer
9
+
10
+ TOKEN: ::Regexp
11
+
12
+ HEADERS: untyped
13
+
14
+ # @rbs (Context ctx, Cursor cursor) -> bool
15
+ def self.heuristic?: (Context ctx, Cursor cursor) -> bool
16
+
17
+ # @rbs (Context ctx, Layer layer) -> void
18
+ def dissect: (Context ctx, Layer layer) -> void
19
+
20
+ # @rbs (Layer layer, String line, Integer offset, bool response) -> Integer
21
+ def start_line: (Layer layer, String line, Integer offset, bool response) -> Integer
22
+
23
+ # @rbs (Layer layer, String bytes, Integer pos, Integer ending) -> Hash[String, Array[String]]
24
+ def parse_headers: (Layer layer, String bytes, Integer pos, Integer ending) -> Hash[String, Array[String]]
25
+
26
+ # @rbs (Layer layer, String bytes, Integer pos) -> [String, Integer]
27
+ def chunked: (Layer layer, String bytes, Integer pos) -> [ String, Integer ]
28
+
29
+ # @rbs (Layer layer, String name, untyped value, Symbol type, Integer offset, Integer length) -> void
30
+ def put: (Layer layer, String name, untyped value, Symbol type, Integer offset, Integer length) -> void
31
+
32
+ # @rbs (Layer layer) -> String
33
+ def summary: (Layer layer) -> String
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,41 @@
1
+ # Generated from lib/redhound/protocols/icmp.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Icmp < Dissector
8
+ TYPES: untyped
9
+
10
+ CODES: untyped
11
+
12
+ # @rbs (Context ctx, Layer layer) -> void
13
+ def dissect: (Context ctx, Layer layer) -> void
14
+
15
+ # @rbs (Context ctx, Layer layer) -> untyped
16
+ def next_dissector: (Context ctx, Layer layer) -> untyped
17
+
18
+ # @rbs (Layer layer) -> String
19
+ def summary: (Layer layer) -> String
20
+ end
21
+
22
+ # @api private
23
+ class Icmpv6 < Dissector
24
+ TYPES: untyped
25
+
26
+ CODES: untyped
27
+
28
+ # @rbs (Context ctx, Layer layer) -> void
29
+ def dissect: (Context ctx, Layer layer) -> void
30
+
31
+ # @rbs (Context ctx, Layer layer) -> untyped
32
+ def next_dissector: (Context ctx, Layer layer) -> untyped
33
+ end
34
+
35
+ # @api private
36
+ class Igmp < Dissector
37
+ # @rbs (Context ctx, Layer layer) -> void
38
+ def dissect: (Context ctx, Layer layer) -> void
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,15 @@
1
+ # Generated from lib/redhound/protocols/ipv4.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Ipv4 < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> void
9
+ def dissect: (Context ctx, Layer layer) -> void
10
+
11
+ # @rbs (Context ctx, Layer layer) -> untyped
12
+ def next_dissector: (Context ctx, Layer layer) -> untyped
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ # Generated from lib/redhound/protocols/ipv6.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Ipv6 < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> void
9
+ def dissect: (Context ctx, Layer layer) -> void
10
+
11
+ # @rbs (Context ctx, Layer layer) -> untyped
12
+ def next_dissector: (Context ctx, Layer layer) -> untyped
13
+ end
14
+
15
+ # @api private
16
+ class Ipv6Ext < Dissector
17
+ # @rbs (Context ctx, Layer layer) -> void
18
+ def dissect: (Context ctx, Layer layer) -> void
19
+
20
+ # @rbs (Context ctx, Layer layer) -> untyped
21
+ def next_dissector: (Context ctx, Layer layer) -> untyped
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # Generated from lib/redhound/protocols/link.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Sll < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> untyped
9
+ def next_dissector: (Context ctx, Layer layer) -> untyped
10
+ end
11
+
12
+ # @api private
13
+ class Sll2 < Dissector
14
+ # @rbs (Context ctx, Layer layer) -> untyped
15
+ def next_dissector: (Context ctx, Layer layer) -> untyped
16
+ end
17
+
18
+ # @api private
19
+ class Null < Dissector
20
+ # @rbs (Context ctx, Layer layer) -> void
21
+ def dissect: (Context ctx, Layer layer) -> void
22
+
23
+ # @rbs (Context ctx, Layer layer) -> untyped
24
+ def next_dissector: (Context ctx, Layer layer) -> untyped
25
+ end
26
+
27
+ # @api private
28
+ class Raw < Dissector
29
+ # @rbs (Context ctx, Layer layer) -> untyped
30
+ def next_dissector: (Context ctx, Layer layer) -> untyped
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ # Generated from lib/redhound/protocols/llc.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Llc < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> void
9
+ def dissect: (Context ctx, Layer layer) -> void
10
+
11
+ # @rbs (Context ctx, Layer layer) -> untyped
12
+ def next_dissector: (Context ctx, Layer layer) -> untyped
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ # Generated from lib/redhound/protocols/ntp.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Ntp < Dissector
8
+ MODES: untyped
9
+
10
+ # @rbs (Context ctx, Layer layer) -> void
11
+ def dissect: (Context ctx, Layer layer) -> void
12
+
13
+ # @rbs (Layer layer) -> String
14
+ def summary: (Layer layer) -> String
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # Generated from lib/redhound/protocols/tcp.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Tcp < Dissector
8
+ FLAGS: untyped
9
+
10
+ FLAG_FIELDS: untyped
11
+
12
+ # @rbs (Context ctx, Layer layer) -> void
13
+ def dissect: (Context ctx, Layer layer) -> void
14
+
15
+ # @rbs (Cursor cursor, Layer layer, Integer hlen) -> void
16
+ def options: (Cursor cursor, Layer layer, Integer hlen) -> void
17
+
18
+ # @rbs (Context ctx, Layer layer) -> untyped
19
+ def next_dissector: (Context ctx, Layer layer) -> untyped
20
+
21
+ # @rbs (Layer layer) -> String
22
+ def summary: (Layer layer) -> String
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ # Generated from lib/redhound/protocols/tls.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Tls < StreamDissector
8
+ # @type ivar @ranges: Array[untyped]
9
+ # @api private
10
+ class BadLength < StandardError
11
+ end
12
+
13
+ CONTENT_TYPES: untyped
14
+
15
+ HANDSHAKES: untyped
16
+
17
+ # @rbs (Context ctx, Cursor cursor) -> bool
18
+ def self.heuristic?: (Context ctx, Cursor cursor) -> bool
19
+
20
+ # @rbs (Context ctx, Layer layer) -> void
21
+ def dissect: (Context ctx, Layer layer) -> void
22
+
23
+ # @rbs (Layer layer, Cursor cursor) -> void
24
+ def handshakes: (Layer layer, Cursor cursor) -> void
25
+
26
+ # @rbs (Layer layer, Cursor cursor, Integer type) -> void
27
+ def hello: (Layer layer, Cursor cursor, Integer type) -> void
28
+
29
+ # @rbs (Layer layer, Cursor cursor, Integer pos, bool client) -> void
30
+ def extensions: (Layer layer, Cursor cursor, Integer pos, bool client) -> void
31
+
32
+ # @rbs (Layer layer, Cursor cursor) -> void
33
+ def server_names: (Layer layer, Cursor cursor) -> void
34
+
35
+ # @rbs (Layer layer, Cursor cursor) -> void
36
+ def alpn: (Layer layer, Cursor cursor) -> void
37
+
38
+ # @rbs (Layer layer, Cursor cursor, bool client) -> void
39
+ def versions: (Layer layer, Cursor cursor, bool client) -> void
40
+
41
+ # @rbs (Integer logical) -> Integer
42
+ def wire_offset: (Integer logical) -> Integer
43
+
44
+ # @rbs (Layer layer, String name, untyped value, Symbol type, Integer offset, Integer length, ?bool handshake) -> void
45
+ def put: (Layer layer, String name, untyped value, Symbol type, Integer offset, Integer length, ?bool handshake) -> void
46
+
47
+ # @rbs (Layer layer) -> String
48
+ def summary: (Layer layer) -> String
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,24 @@
1
+ # Generated from lib/redhound/protocols/tunnel.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Gre < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> void
9
+ def dissect: (Context ctx, Layer layer) -> void
10
+
11
+ # @rbs (Context ctx, Layer layer) -> untyped
12
+ def next_dissector: (Context ctx, Layer layer) -> untyped
13
+ end
14
+
15
+ # @api private
16
+ class Vxlan < Dissector
17
+ # @rbs (Context ctx, Layer layer) -> void
18
+ def dissect: (Context ctx, Layer layer) -> void
19
+
20
+ # @rbs (Context ctx, Layer layer) -> untyped
21
+ def next_dissector: (Context ctx, Layer layer) -> untyped
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ # Generated from lib/redhound/protocols/udp.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Udp < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> void
9
+ def dissect: (Context ctx, Layer layer) -> void
10
+
11
+ # @rbs (Context ctx, Layer layer) -> untyped
12
+ def next_dissector: (Context ctx, Layer layer) -> untyped
13
+
14
+ # @rbs (Layer layer) -> String
15
+ def summary: (Layer layer) -> String
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # Generated from lib/redhound/protocols/vlan.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Protocols
6
+ # @api private
7
+ class Vlan < Dissector
8
+ # @rbs (Context ctx, Layer layer) -> untyped
9
+ def next_dissector: (Context ctx, Layer layer) -> untyped
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ # Generated from lib/redhound/reader.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # Enumerable pcap/pcapng reader; inherited capture-source methods include stop and close.
5
+ class Reader < Capture::FileSource
6
+ end
7
+ end
@@ -0,0 +1,45 @@
1
+ # Generated from lib/redhound/registry.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # Protocol dispatch and per-session decode-as rules.
5
+ class Registry
6
+ # @rbs () -> Registry
7
+ # Shared registry populated by built-in and custom dissectors.
8
+ def self.default: () -> Registry
9
+
10
+ # Registered protocol identities and dispatch tables.
11
+ attr_reader protocols: untyped
12
+
13
+ # @rbs () -> void
14
+ # Create empty protocol dispatch tables.
15
+ def initialize: () -> void
16
+
17
+ # @rbs (String key, Integer value, untyped klass) -> void
18
+ # Register a class under a dispatch key and value.
19
+ def register: (String key, Integer value, untyped klass) -> void
20
+
21
+ # @rbs (untyped klass) -> void
22
+ # Register a protocol class by its declared identity.
23
+ def register_protocol: (untyped klass) -> void
24
+
25
+ # @rbs (String key, Integer value) -> untyped
26
+ # Look up a protocol class for a dispatch key and value.
27
+ def lookup: (String key, Integer value) -> untyped
28
+
29
+ # @rbs (String key, Integer src, Integer dst) -> untyped
30
+ # Resolve decode-as rules before registered low/high port dispatch.
31
+ def by_port: (String key, Integer src, Integer dst) -> untyped
32
+
33
+ # @rbs (Symbol parent, Context ctx, Cursor cursor) -> untyped
34
+ # Run registered transport heuristics on the bounded payload.
35
+ def heuristic: (Symbol parent, Context ctx, Cursor cursor) -> untyped
36
+
37
+ # @rbs (String rule) -> void
38
+ # Apply a transport-port override such as udp.port==8443,dns.
39
+ def decode_as: (String rule) -> void
40
+
41
+ # @rbs () -> Registry
42
+ # Copy tables and overrides for an independent analysis session.
43
+ def copy: () -> Registry
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ # Generated from lib/redhound/stream_dissector.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # A stateful TCP dissector. Instances belong to one bidirectional flow.
5
+ # Override on_data/on_gap for custom stream protocols; built-in framing is
6
+ # shared with the packet dissectors so validation has one implementation.
7
+ class StreamDissector < Dissector
8
+ # @rbs (?registry: Registry, ?max_bytes: Integer) -> void
9
+ def initialize: (?registry: Registry, ?max_bytes: Integer) -> void
10
+
11
+ # @rbs (untyped stream, Integer direction, String data, Integer frame) -> Array[Layer]
12
+ def on_data: (untyped stream, Integer direction, String data, Integer frame) -> Array[Layer]
13
+
14
+ # @rbs (untyped stream, Integer direction, Integer length) -> Array[Layer]
15
+ def on_gap: (untyped stream, Integer direction, Integer length) -> Array[Layer]
16
+
17
+ # @rbs (untyped stream, Integer direction) -> Array[Layer]
18
+ def on_close: (untyped stream, Integer direction) -> Array[Layer]
19
+
20
+ # @rbs () -> Integer
21
+ def bytesize: () -> Integer
22
+
23
+ # @rbs (Integer direction, Integer length) -> Array[Integer]
24
+ def consume_origins: (Integer direction, Integer length) -> Array[Integer]
25
+
26
+ # @rbs (String bytes, ?tls_encrypted: bool, ?head_response: bool) -> Layer
27
+ def parse_pdu: (String bytes, ?tls_encrypted: bool, ?head_response: bool) -> Layer
28
+
29
+ # @rbs (String buffer, ?Integer direction, ?head_response: bool) -> Integer?
30
+ def pdu_length: (String buffer, ?Integer direction, ?head_response: bool) -> Integer?
31
+
32
+ # @rbs (String buffer, ?head_response: bool) -> Integer?
33
+ def http_length: (String buffer, ?head_response: bool) -> Integer?
34
+
35
+ # @rbs (untyped stream, Integer direction, String buffer) -> bool
36
+ def head_response?: (untyped stream, Integer direction, String buffer) -> bool
37
+
38
+ # @rbs (untyped stream, Integer direction, Layer layer) -> void
39
+ def record_http: (untyped stream, Integer direction, Layer layer) -> void
40
+
41
+ # @rbs (String buffer, Integer direction) -> Integer?
42
+ def tls_length: (String buffer, Integer direction) -> Integer?
43
+ end
44
+ end
@@ -0,0 +1,20 @@
1
+ # Generated from lib/redhound/util/seq.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ # @api private
5
+ module Util
6
+ # @api private
7
+ module Seq
8
+ MOD: ::Integer
9
+
10
+ # @rbs (Integer a, Integer b) -> Integer
11
+ def self.diff: (Integer a, Integer b) -> Integer
12
+
13
+ # @rbs (Integer a, Integer b) -> bool
14
+ def self.lt: (Integer a, Integer b) -> bool
15
+
16
+ # @rbs (Integer a, Integer b) -> Integer
17
+ def self.signed_diff: (Integer a, Integer b) -> Integer
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,6 @@
1
1
  # Generated from lib/redhound/version.rb with RBS::Inline
2
2
 
3
3
  module Redhound
4
+ # Published gem version.
4
5
  VERSION: ::String
5
6
  end
@@ -1,25 +1,12 @@
1
1
  # Generated from lib/redhound/writer.rb with RBS::Inline
2
2
 
3
3
  module Redhound
4
+ # Open pcap/pcapng outputs, optionally with bounded rotation.
4
5
  class Writer
5
- # @rbs (filename: String) -> void
6
- def initialize: (filename: String) -> void
7
-
8
- # @rbs () -> void
9
- def start: () -> void
10
-
11
- # @rbs (msg: String) -> void
12
- def write: (msg: String) -> void
13
-
14
- # @rbs () -> void
15
- def stop: () -> void
16
-
17
- private
18
-
19
- # @rbs () -> String
20
- def file_header: () -> String
21
-
22
- # @rbs (Time timestamp, Integer captured_length, Integer original_length) -> String
23
- def packet_record: (Time timestamp, Integer captured_length, Integer original_length) -> String
6
+ # @rbs (untyped output, ?linktype: Integer | Symbol | String, ?format: Symbol | String | nil, ?snaplen: Integer, ?precision: Symbol, ?packet_buffered: bool, ?forbidden_input: String?, **untyped options) -> untyped
7
+ # @rbs [T] (untyped output, ?linktype: Integer | Symbol | String, ?format: Symbol | String | nil, ?snaplen: Integer, ?precision: Symbol, ?packet_buffered: bool, ?forbidden_input: String?, **untyped options) { (untyped) -> T } -> T
8
+ # Open a path or binary IO; close automatically with a block. See docs/API.md for options.
9
+ def self.open: (untyped output, ?linktype: Integer | Symbol | String, ?format: Symbol | String | nil, ?snaplen: Integer, ?precision: Symbol, ?packet_buffered: bool, ?forbidden_input: String?, **untyped options) -> untyped
10
+ | [T] (untyped output, ?linktype: Integer | Symbol | String, ?format: Symbol | String | nil, ?snaplen: Integer, ?precision: Symbol, ?packet_buffered: bool, ?forbidden_input: String?, **untyped options) { (untyped) -> T } -> T
24
11
  end
25
12
  end
@@ -0,0 +1,18 @@
1
+ # Generated from lib/redhound.rb with RBS::Inline
2
+
3
+ # Capture, inspect and save network packets using Ruby standard libraries.
4
+ module Redhound
5
+ # @rbs (String bytes, ?linktype: (Integer | Symbol), **untyped metadata) -> Packet
6
+ # Create a packet with lazy, bounded protocol dissection. See docs/API.md.
7
+ def self.dissect: (String bytes, ?linktype: Integer | Symbol, **untyped metadata) -> Packet
8
+
9
+ # @rbs (untyped input, ?filter: String?) -> Reader
10
+ # @rbs [T] (untyped input, ?filter: String?) { (Reader) -> T } -> T
11
+ # Read a pcap/pcapng path or binary IO; a block closes the reader automatically.
12
+ def self.open: (untyped input, ?filter: String?) -> Reader
13
+ | [T] (untyped input, ?filter: String?) { (Reader) -> T } -> T
14
+
15
+ # @rbs (interface: String | Integer, ?count: Integer?, **untyped options) { (Packet) -> void } -> void
16
+ # Yield live packets until count is reached or capture stops; always close the source.
17
+ def self.capture: (interface: String | Integer, ?count: Integer?, **untyped options) { (Packet) -> void } -> void
18
+ end
data/sig/shims/io.rbs ADDED
@@ -0,0 +1,7 @@
1
+ class IO
2
+ def self.select: (Array[IO]?, ?Array[IO]?, ?Array[IO]?, ?Numeric?) -> [Array[IO], Array[IO], Array[IO]]?
3
+ end
4
+
5
+ module Shellwords
6
+ def self.split: (String) -> Array[String]
7
+ end
@@ -0,0 +1,3 @@
1
+ module Process
2
+ def self.spawn: (*untyped, **untyped) -> Integer
3
+ end