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
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redhound
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yudai Takada
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Redhound is a pure Ruby packet analyzer that can be used to capture and
13
13
  analyze network packets.
@@ -19,71 +19,193 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - CHANGELOG.md
22
- - CODE_OF_CONDUCT.md
23
- - Dockerfile
24
22
  - LICENSE.txt
25
23
  - README.md
26
- - Rakefile
27
- - Steepfile
28
- - docker-compose.yml
24
+ - docs/API.md
25
+ - docs/FILTERS.md
26
+ - docs/MIGRATION.md
27
+ - docs/PROTOCOLS.md
28
+ - docs/USAGE.md
29
+ - docs/VALIDATION.md
30
+ - docs/json-schema.json
29
31
  - exe/redhound
30
32
  - lib/redhound.rb
31
- - lib/redhound/analyzer.rb
32
- - lib/redhound/builder.rb
33
- - lib/redhound/builder/packet_mreq.rb
34
- - lib/redhound/builder/socket.rb
35
- - lib/redhound/command.rb
36
- - lib/redhound/l2.rb
37
- - lib/redhound/l2/ether.rb
38
- - lib/redhound/l2/protocol.rb
39
- - lib/redhound/l3.rb
40
- - lib/redhound/l3/arp.rb
41
- - lib/redhound/l3/base.rb
42
- - lib/redhound/l3/ipv4.rb
43
- - lib/redhound/l3/ipv6.rb
44
- - lib/redhound/l3/protocol.rb
45
- - lib/redhound/l3/resolver.rb
46
- - lib/redhound/l4.rb
47
- - lib/redhound/l4/base.rb
48
- - lib/redhound/l4/icmp.rb
49
- - lib/redhound/l4/resolver.rb
50
- - lib/redhound/l4/udp.rb
51
- - lib/redhound/receiver.rb
52
- - lib/redhound/resolver.rb
53
- - lib/redhound/source.rb
54
- - lib/redhound/source/socket.rb
33
+ - lib/redhound/analysis.rb
34
+ - lib/redhound/analysis/flow_key.rb
35
+ - lib/redhound/analysis/flow_table.rb
36
+ - lib/redhound/analysis/ip_reassembler.rb
37
+ - lib/redhound/analysis/stats.rb
38
+ - lib/redhound/analysis/tcp_analysis.rb
39
+ - lib/redhound/analysis/tcp_reassembler.rb
40
+ - lib/redhound/analysis/tcp_stream.rb
41
+ - lib/redhound/capture.rb
42
+ - lib/redhound/capture/bsd/bpf_device.rb
43
+ - lib/redhound/capture/bsd/constants.rb
44
+ - lib/redhound/capture/bsd/ifreq.rb
45
+ - lib/redhound/capture/file_source.rb
46
+ - lib/redhound/capture/interface.rb
47
+ - lib/redhound/capture/linktype.rb
48
+ - lib/redhound/capture/linux/constants.rb
49
+ - lib/redhound/capture/linux/cooked.rb
50
+ - lib/redhound/capture/linux/ifreq.rb
51
+ - lib/redhound/capture/linux/packet_socket.rb
52
+ - lib/redhound/capture/linux/sockaddr_ll.rb
53
+ - lib/redhound/capture/linux/tpacket_v3.rb
54
+ - lib/redhound/capture/source.rb
55
+ - lib/redhound/capture/stats.rb
56
+ - lib/redhound/cli/command.rb
57
+ - lib/redhound/cli/options.rb
58
+ - lib/redhound/cli/privileges.rb
59
+ - lib/redhound/cli/runner.rb
60
+ - lib/redhound/context.rb
61
+ - lib/redhound/cursor.rb
62
+ - lib/redhound/diagnostic.rb
63
+ - lib/redhound/dissector.rb
64
+ - lib/redhound/engine.rb
65
+ - lib/redhound/errors.rb
66
+ - lib/redhound/field.rb
67
+ - lib/redhound/file/format.rb
68
+ - lib/redhound/file/pcap_reader.rb
69
+ - lib/redhound/file/pcap_writer.rb
70
+ - lib/redhound/file/pcapng_reader.rb
71
+ - lib/redhound/file/pcapng_writer.rb
72
+ - lib/redhound/file/rotating_writer.rb
73
+ - lib/redhound/filter.rb
74
+ - lib/redhound/filter/analyzer.rb
75
+ - lib/redhound/filter/bpf/assembler.rb
76
+ - lib/redhound/filter/bpf/disassembler.rb
77
+ - lib/redhound/filter/bpf/validator.rb
78
+ - lib/redhound/filter/bpf/vm.rb
79
+ - lib/redhound/filter/codegen.rb
80
+ - lib/redhound/filter/lexer.rb
81
+ - lib/redhound/filter/parser.rb
82
+ - lib/redhound/filter/program.rb
83
+ - lib/redhound/layer.rb
84
+ - lib/redhound/output/fields.rb
85
+ - lib/redhound/output/follow.rb
86
+ - lib/redhound/output/hexdump.rb
87
+ - lib/redhound/output/json.rb
88
+ - lib/redhound/output/summary.rb
89
+ - lib/redhound/output/timestamp.rb
90
+ - lib/redhound/output/tree.rb
91
+ - lib/redhound/packet.rb
92
+ - lib/redhound/protocols/arp.rb
93
+ - lib/redhound/protocols/checksum.rb
94
+ - lib/redhound/protocols/data.rb
95
+ - lib/redhound/protocols/dhcp.rb
96
+ - lib/redhound/protocols/dns.rb
97
+ - lib/redhound/protocols/ethernet.rb
98
+ - lib/redhound/protocols/http.rb
99
+ - lib/redhound/protocols/icmp.rb
100
+ - lib/redhound/protocols/ipv4.rb
101
+ - lib/redhound/protocols/ipv6.rb
102
+ - lib/redhound/protocols/link.rb
103
+ - lib/redhound/protocols/llc.rb
104
+ - lib/redhound/protocols/ntp.rb
105
+ - lib/redhound/protocols/tcp.rb
106
+ - lib/redhound/protocols/tls.rb
107
+ - lib/redhound/protocols/tunnel.rb
108
+ - lib/redhound/protocols/udp.rb
109
+ - lib/redhound/protocols/vlan.rb
110
+ - lib/redhound/reader.rb
111
+ - lib/redhound/registry.rb
112
+ - lib/redhound/stream_dissector.rb
113
+ - lib/redhound/util/seq.rb
55
114
  - lib/redhound/version.rb
56
115
  - lib/redhound/writer.rb
57
- - rbs_collection.lock.yaml
58
- - rbs_collection.yaml
59
- - sig/generated/redhound/analyzer.rbs
60
- - sig/generated/redhound/builder/packet_mreq.rbs
61
- - sig/generated/redhound/builder/socket.rbs
62
- - sig/generated/redhound/command.rbs
63
- - sig/generated/redhound/l2/ether.rbs
64
- - sig/generated/redhound/l2/protocol.rbs
65
- - sig/generated/redhound/l3/arp.rbs
66
- - sig/generated/redhound/l3/base.rbs
67
- - sig/generated/redhound/l3/ipv4.rbs
68
- - sig/generated/redhound/l3/ipv6.rbs
69
- - sig/generated/redhound/l3/protocol.rbs
70
- - sig/generated/redhound/l3/resolver.rbs
71
- - sig/generated/redhound/l4/base.rbs
72
- - sig/generated/redhound/l4/icmp.rbs
73
- - sig/generated/redhound/l4/resolver.rbs
74
- - sig/generated/redhound/l4/udp.rbs
75
- - sig/generated/redhound/receiver.rbs
76
- - sig/generated/redhound/resolver.rbs
77
- - sig/generated/redhound/source/socket.rbs
116
+ - sig/generated/redhound.rbs
117
+ - sig/generated/redhound/analysis.rbs
118
+ - sig/generated/redhound/analysis/flow_key.rbs
119
+ - sig/generated/redhound/analysis/flow_table.rbs
120
+ - sig/generated/redhound/analysis/ip_reassembler.rbs
121
+ - sig/generated/redhound/analysis/stats.rbs
122
+ - sig/generated/redhound/analysis/tcp_analysis.rbs
123
+ - sig/generated/redhound/analysis/tcp_reassembler.rbs
124
+ - sig/generated/redhound/analysis/tcp_stream.rbs
125
+ - sig/generated/redhound/capture.rbs
126
+ - sig/generated/redhound/capture/bsd/bpf_device.rbs
127
+ - sig/generated/redhound/capture/bsd/constants.rbs
128
+ - sig/generated/redhound/capture/bsd/ifreq.rbs
129
+ - sig/generated/redhound/capture/file_source.rbs
130
+ - sig/generated/redhound/capture/interface.rbs
131
+ - sig/generated/redhound/capture/linktype.rbs
132
+ - sig/generated/redhound/capture/linux/constants.rbs
133
+ - sig/generated/redhound/capture/linux/cooked.rbs
134
+ - sig/generated/redhound/capture/linux/ifreq.rbs
135
+ - sig/generated/redhound/capture/linux/packet_socket.rbs
136
+ - sig/generated/redhound/capture/linux/sockaddr_ll.rbs
137
+ - sig/generated/redhound/capture/linux/tpacket_v3.rbs
138
+ - sig/generated/redhound/capture/source.rbs
139
+ - sig/generated/redhound/capture/stats.rbs
140
+ - sig/generated/redhound/cli/command.rbs
141
+ - sig/generated/redhound/cli/options.rbs
142
+ - sig/generated/redhound/cli/privileges.rbs
143
+ - sig/generated/redhound/cli/runner.rbs
144
+ - sig/generated/redhound/context.rbs
145
+ - sig/generated/redhound/cursor.rbs
146
+ - sig/generated/redhound/diagnostic.rbs
147
+ - sig/generated/redhound/dissector.rbs
148
+ - sig/generated/redhound/engine.rbs
149
+ - sig/generated/redhound/errors.rbs
150
+ - sig/generated/redhound/field.rbs
151
+ - sig/generated/redhound/file/format.rbs
152
+ - sig/generated/redhound/file/pcap_reader.rbs
153
+ - sig/generated/redhound/file/pcap_writer.rbs
154
+ - sig/generated/redhound/file/pcapng_reader.rbs
155
+ - sig/generated/redhound/file/pcapng_writer.rbs
156
+ - sig/generated/redhound/file/rotating_writer.rbs
157
+ - sig/generated/redhound/filter.rbs
158
+ - sig/generated/redhound/filter/analyzer.rbs
159
+ - sig/generated/redhound/filter/bpf/assembler.rbs
160
+ - sig/generated/redhound/filter/bpf/disassembler.rbs
161
+ - sig/generated/redhound/filter/bpf/validator.rbs
162
+ - sig/generated/redhound/filter/bpf/vm.rbs
163
+ - sig/generated/redhound/filter/codegen.rbs
164
+ - sig/generated/redhound/filter/lexer.rbs
165
+ - sig/generated/redhound/filter/parser.rbs
166
+ - sig/generated/redhound/filter/program.rbs
167
+ - sig/generated/redhound/layer.rbs
168
+ - sig/generated/redhound/output/fields.rbs
169
+ - sig/generated/redhound/output/follow.rbs
170
+ - sig/generated/redhound/output/hexdump.rbs
171
+ - sig/generated/redhound/output/json.rbs
172
+ - sig/generated/redhound/output/summary.rbs
173
+ - sig/generated/redhound/output/timestamp.rbs
174
+ - sig/generated/redhound/output/tree.rbs
175
+ - sig/generated/redhound/packet.rbs
176
+ - sig/generated/redhound/protocols/arp.rbs
177
+ - sig/generated/redhound/protocols/checksum.rbs
178
+ - sig/generated/redhound/protocols/data.rbs
179
+ - sig/generated/redhound/protocols/dhcp.rbs
180
+ - sig/generated/redhound/protocols/dns.rbs
181
+ - sig/generated/redhound/protocols/ethernet.rbs
182
+ - sig/generated/redhound/protocols/http.rbs
183
+ - sig/generated/redhound/protocols/icmp.rbs
184
+ - sig/generated/redhound/protocols/ipv4.rbs
185
+ - sig/generated/redhound/protocols/ipv6.rbs
186
+ - sig/generated/redhound/protocols/link.rbs
187
+ - sig/generated/redhound/protocols/llc.rbs
188
+ - sig/generated/redhound/protocols/ntp.rbs
189
+ - sig/generated/redhound/protocols/tcp.rbs
190
+ - sig/generated/redhound/protocols/tls.rbs
191
+ - sig/generated/redhound/protocols/tunnel.rbs
192
+ - sig/generated/redhound/protocols/udp.rbs
193
+ - sig/generated/redhound/protocols/vlan.rbs
194
+ - sig/generated/redhound/reader.rbs
195
+ - sig/generated/redhound/registry.rbs
196
+ - sig/generated/redhound/stream_dissector.rbs
197
+ - sig/generated/redhound/util/seq.rbs
78
198
  - sig/generated/redhound/version.rbs
79
199
  - sig/generated/redhound/writer.rbs
200
+ - sig/shims/io.rbs
201
+ - sig/shims/process.rbs
80
202
  homepage: https://github.com/ydah/redhound
81
203
  licenses:
82
204
  - MIT
83
205
  metadata:
84
206
  homepage_uri: https://github.com/ydah/redhound
85
- source_code_uri: https://github.com/ydah/redhound
86
- documentation_uri: https://github.com/ydah/redhound
207
+ source_code_uri: https://github.com/ydah/redhound/tree/main
208
+ documentation_uri: https://github.com/ydah/redhound/blob/main/docs/API.md
87
209
  changelog_uri: https://github.com/ydah/redhound/releases
88
210
  bug_tracker_uri: https://github.com/ydah/redhound/issues
89
211
  rubygems_mfa_required: 'true'
@@ -101,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
223
  - !ruby/object:Gem::Version
102
224
  version: '0'
103
225
  requirements: []
104
- rubygems_version: 3.7.0.dev
226
+ rubygems_version: 3.6.9
105
227
  specification_version: 4
106
228
  summary: Pure Ruby packet analyzer
107
229
  test_files: []
data/CODE_OF_CONDUCT.md DELETED
@@ -1,132 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, caste, color, religion, or sexual
10
- identity and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the overall
26
- community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or advances of
31
- any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email address,
35
- without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official email address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- [INSERT CONTACT METHOD].
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series of
86
- actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or permanent
93
- ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within the
113
- community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.1, available at
119
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
-
121
- Community Impact Guidelines were inspired by
122
- [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
-
124
- For answers to common questions about this code of conduct, see the FAQ at
125
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
- [https://www.contributor-covenant.org/translations][translations].
127
-
128
- [homepage]: https://www.contributor-covenant.org
129
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
- [Mozilla CoC]: https://github.com/mozilla/diversity
131
- [FAQ]: https://www.contributor-covenant.org/faq
132
- [translations]: https://www.contributor-covenant.org/translations
data/Dockerfile DELETED
@@ -1,7 +0,0 @@
1
- FROM ruby:3.3.4
2
- RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs iputils-ping iproute2 iptables
3
- WORKDIR /app
4
- COPY Gemfile /app/Gemfile
5
- RUN bundle install
6
- ENV LANG=ja_JP.UTF-8
7
- ENV TZ=Asia/Tokyo
data/Rakefile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
-
5
- desc "steep check"
6
- task :steep do
7
- sh "bundle exec steep check"
8
- end
9
-
10
- desc "Run rbs-inline"
11
- task :rbs_inline do
12
- sh "bundle exec rbs-inline --output lib/"
13
- end
14
-
15
- task default: %i[rbs_inline steep]
data/Steepfile DELETED
@@ -1,4 +0,0 @@
1
- target :lib do
2
- signature "sig"
3
- check "lib"
4
- end
data/docker-compose.yml DELETED
@@ -1,9 +0,0 @@
1
- version: '3.7'
2
- services:
3
- app:
4
- build: .
5
- tty: true
6
- ports:
7
- - 3000:3000
8
- volumes:
9
- - .:/app
@@ -1,34 +0,0 @@
1
- # rbs_inline: enabled
2
- # frozen_string_literal: true
3
-
4
- module Redhound
5
- class Analyzer
6
- # @rbs (msg: String, count: Integer) -> void
7
- def self.analyze(msg:, count:)
8
- new(msg:, count:).analyze
9
- end
10
-
11
- # @rbs (msg: String, count: Integer) -> void
12
- def initialize(msg:, count:)
13
- @msg = msg
14
- @count = count
15
- end
16
-
17
- # @rbs () -> void
18
- def analyze
19
- l2 = L2::Ether.generate(bytes: @msg.bytes[0..], count: @count)
20
- l2.dump
21
- return unless l2.supported_type?
22
-
23
- l3 = L3::Resolver.resolve(bytes: @msg.bytes[l2.size..], l2:)
24
- return if !l3 || @msg.bytes.size <= l2.size + l3.size
25
- l3.dump
26
- unless l3.supported_protocol?
27
- puts " └─ Unsupported protocol #{l3.protocol}"
28
- return
29
- end
30
-
31
- L4::Resolver.resolve(bytes: @msg.bytes[(l2.size + l3.size)..], l3:)&.dump
32
- end
33
- end
34
- end
@@ -1,56 +0,0 @@
1
- # rbs_inline: enabled
2
- # frozen_string_literal: true
3
-
4
- require 'socket'
5
-
6
- module Redhound
7
- module Builder
8
- class PacketMreq
9
- PACKET_MR_PROMISC = 0x0001 # NOTE: netpacket/packet.h
10
-
11
- # @rbs (ifname: String) -> void
12
- def initialize(ifname:)
13
- @ifname = ifname
14
- end
15
-
16
- # see: https://man7.org/linux/man-pages/man7/packet.7.html
17
- # struct packet_mreq {
18
- # int mr_ifindex; /* interface index */
19
- # unsigned short mr_type; /* action */
20
- # unsigned short mr_alen; /* address length */
21
- # unsigned char mr_address[8]; /* physical-layer address */
22
- # };
23
- # @rbs () -> String
24
- def build
25
- mr_ifindex + mr_type + mr_alen + mr_address
26
- end
27
-
28
- # @rbs () -> String
29
- def mr_ifindex
30
- @mr_ifindex ||= [[index].pack('I')].pack('a4')
31
- end
32
-
33
- private
34
-
35
- # @rbs () -> Integer?
36
- def index
37
- ::Socket.getifaddrs.find { |ifaddr| ifaddr.name == @ifname }&.ifindex
38
- end
39
-
40
- # @rbs () -> String
41
- def mr_type
42
- @mr_type ||= [PACKET_MR_PROMISC].pack('S')
43
- end
44
-
45
- # @rbs () -> String
46
- def mr_alen
47
- @mr_alen ||= [0].pack('S')
48
- end
49
-
50
- # @rbs () -> String
51
- def mr_address
52
- @mr_address ||= [0].pack('C') * 8
53
- end
54
- end
55
- end
56
- end
@@ -1,35 +0,0 @@
1
- # rbs_inline: enabled
2
- # frozen_string_literal: true
3
-
4
- require 'socket'
5
-
6
- module Redhound
7
- module Builder
8
- class Socket
9
- SOL_PACKET = 0x0107 # bits/socket.h
10
- PACKET_ADD_MEMBERSHIP = 0x0001 # NOTE: netpacket/packet.h
11
- ETH_P_ALL = 768 # NOTE: htons(ETH_P_ALL) => linux/if_ether.h
12
- PACKED_ETH_P_ALL = [ETH_P_ALL].pack('S').unpack1('S>')
13
-
14
- class << self
15
- # @rbs (ifname: String) -> Redhound::Source::Socket
16
- def build(ifname:)
17
- new(ifname:).build
18
- end
19
- end
20
-
21
- # @rbs (ifname: String) -> void
22
- def initialize(ifname:)
23
- @mq_req = PacketMreq.new(ifname:)
24
- end
25
-
26
- # @rbs () -> Redhound::Source::Socket
27
- def build
28
- socket = ::Socket.new(::Socket::AF_PACKET, ::Socket::SOCK_RAW, ETH_P_ALL)
29
- socket.bind([::Socket::AF_PACKET, PACKED_ETH_P_ALL, @mq_req.mr_ifindex].pack('SS>a16'))
30
- socket.setsockopt(SOL_PACKET, PACKET_ADD_MEMBERSHIP, @mq_req.build)
31
- Redhound::Source::Socket.new(socket:)
32
- end
33
- end
34
- end
35
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'builder/packet_mreq'
4
- require_relative 'builder/socket'
@@ -1,67 +0,0 @@
1
- # rbs_inline: enabled
2
- # frozen_string_literal: true
3
-
4
- require 'optparse'
5
- require 'socket'
6
-
7
- module Redhound
8
- class Command
9
- # @rbs () -> void
10
- def initialize
11
- @options = { ifname: nil }
12
- end
13
-
14
- # @rbs (Array[untyped] argv) -> void
15
- def run(argv)
16
- parse(argv)
17
- if @options[:ifname].nil?
18
- warn 'Error: interface is required'
19
- exit 1
20
- end
21
- Receiver.run(ifname: @options[:ifname], filename: @options[:filename])
22
- end
23
-
24
- # @rbs (Array[untyped] argv) -> void
25
- def parse(argv)
26
- OptionParser.new do |o| # steep:ignore
27
- o.banner = <<~'BANNER' + <<~BANNER2
28
- ___ ____ __
29
- / _ \___ ___/ / / ___ __ _____ ___/ /
30
- / , _/ -_) _ / _ \/ _ \/ // / _ \/ _ /
31
- /_/|_|\__/\_,_/_//_/\___/\_,_/_//_/\_,_/
32
-
33
- BANNER
34
- Version: #{Redhound::VERSION}
35
- Dump and analyze network packets.
36
-
37
- Usage: redhound [options] ...
38
- BANNER2
39
- o.separator ''
40
- o.separator 'Options:'
41
- o.on('-i', '--interface INTERFACE', 'name or idx of interface') { |v| @options[:ifname] = v }
42
- o.on('-D', '--list-interfaces', 'print list of interfaces and exit') do
43
- list_interfaces
44
- exit
45
- end
46
- o.on('-w FILE', 'write packets to a pcap capture file format to file') { |v| @options[:filename] = v }
47
- o.on('-h', '--help', 'display this help and exit') do
48
- puts o
49
- exit
50
- end
51
- o.on('-v', '--version', 'display version information and exit') do
52
- puts "Redhound #{Redhound::VERSION}"
53
- exit
54
- end
55
- o.on_tail
56
- o.parse!(argv)
57
- end
58
- end
59
-
60
- private
61
-
62
- # @rbs () -> void
63
- def list_interfaces
64
- ::Socket.getifaddrs.each { |ifaddr| puts ifaddr.name }
65
- end
66
- end
67
- end