redhound 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -3
  3. data/Dockerfile +1 -1
  4. data/README.md +2 -2
  5. data/Rakefile +12 -1
  6. data/Steepfile +4 -0
  7. data/lib/redhound/analyzer.rb +19 -15
  8. data/lib/redhound/builder/packet_mreq.rb +56 -0
  9. data/lib/redhound/builder/socket.rb +35 -0
  10. data/lib/redhound/builder.rb +4 -0
  11. data/lib/redhound/command.rb +6 -1
  12. data/lib/redhound/l2/ether.rb +68 -0
  13. data/lib/redhound/l2/protocol.rb +33 -0
  14. data/lib/redhound/l2.rb +4 -0
  15. data/lib/redhound/l3/arp.rb +114 -0
  16. data/lib/redhound/l3/base.rb +49 -0
  17. data/lib/redhound/{header → l3}/ipv4.rb +27 -44
  18. data/lib/redhound/l3/ipv6.rb +69 -0
  19. data/lib/redhound/l3/protocol.rb +173 -0
  20. data/lib/redhound/l3/resolver.rb +30 -0
  21. data/lib/redhound/l3.rb +8 -0
  22. data/lib/redhound/l4/base.rb +31 -0
  23. data/lib/redhound/{header → l4}/icmp.rb +20 -26
  24. data/lib/redhound/l4/resolver.rb +28 -0
  25. data/lib/redhound/{header → l4}/udp.rb +19 -19
  26. data/lib/redhound/l4.rb +6 -0
  27. data/lib/redhound/receiver.rb +17 -5
  28. data/lib/redhound/resolver.rb +22 -0
  29. data/lib/redhound/source/socket.rb +18 -0
  30. data/lib/redhound/source.rb +3 -0
  31. data/lib/redhound/version.rb +2 -1
  32. data/lib/redhound/writer.rb +9 -2
  33. data/lib/redhound.rb +6 -3
  34. data/rbs_collection.lock.yaml +20 -0
  35. data/rbs_collection.yaml +17 -0
  36. data/sig/generated/redhound/analyzer.rbs +14 -0
  37. data/sig/generated/redhound/builder/packet_mreq.rbs +39 -0
  38. data/sig/generated/redhound/builder/socket.rbs +24 -0
  39. data/sig/generated/redhound/command.rbs +19 -0
  40. data/sig/generated/redhound/l2/ether.rbs +41 -0
  41. data/sig/generated/redhound/l2/protocol.rbs +15 -0
  42. data/sig/generated/redhound/l3/arp.rbs +57 -0
  43. data/sig/generated/redhound/l3/base.rbs +28 -0
  44. data/sig/generated/redhound/l3/ipv4.rbs +53 -0
  45. data/sig/generated/redhound/l3/ipv6.rbs +38 -0
  46. data/sig/generated/redhound/l3/protocol.rbs +16 -0
  47. data/sig/generated/redhound/l3/resolver.rbs +16 -0
  48. data/sig/generated/redhound/l4/base.rbs +19 -0
  49. data/sig/generated/redhound/l4/icmp.rbs +33 -0
  50. data/sig/generated/redhound/l4/resolver.rbs +16 -0
  51. data/sig/generated/redhound/l4/udp.rbs +36 -0
  52. data/sig/generated/redhound/receiver.rbs +19 -0
  53. data/sig/generated/redhound/resolver.rbs +11 -0
  54. data/sig/generated/redhound/source/socket.rbs +13 -0
  55. data/sig/generated/redhound/version.rbs +5 -0
  56. data/sig/generated/redhound/writer.rbs +25 -0
  57. metadata +48 -11
  58. data/lib/redhound/header/ether.rb +0 -67
  59. data/lib/redhound/header.rb +0 -6
  60. data/lib/redhound/packet_mreq.rb +0 -46
  61. data/lib/redhound/socket_builder.rb +0 -30
  62. data/sig/redhound.rbs +0 -4
@@ -0,0 +1,20 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: fileutils
5
+ version: '0'
6
+ source:
7
+ type: stdlib
8
+ - name: rake
9
+ version: '13.0'
10
+ source:
11
+ type: git
12
+ name: ruby/gem_rbs_collection
13
+ revision: f83c613ed7d038c0031f25fcbcdf12603ba36e79
14
+ remote: https://github.com/ruby/gem_rbs_collection.git
15
+ repo_dir: gems
16
+ - name: socket
17
+ version: '0'
18
+ source:
19
+ type: stdlib
20
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,17 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
16
+ gems:
17
+ - name: socket
@@ -0,0 +1,14 @@
1
+ # Generated from lib/redhound/analyzer.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class Analyzer
5
+ # @rbs (msg: String, count: Integer) -> void
6
+ def self.analyze: (msg: String, count: Integer) -> void
7
+
8
+ # @rbs (msg: String, count: Integer) -> void
9
+ def initialize: (msg: String, count: Integer) -> void
10
+
11
+ # @rbs () -> void
12
+ def analyze: () -> void
13
+ end
14
+ end
@@ -0,0 +1,39 @@
1
+ # Generated from lib/redhound/builder/packet_mreq.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ module Builder
5
+ class PacketMreq
6
+ PACKET_MR_PROMISC: ::Integer
7
+
8
+ # @rbs (ifname: String) -> void
9
+ def initialize: (ifname: String) -> void
10
+
11
+ # see: https://man7.org/linux/man-pages/man7/packet.7.html
12
+ # struct packet_mreq {
13
+ # int mr_ifindex; /* interface index */
14
+ # unsigned short mr_type; /* action */
15
+ # unsigned short mr_alen; /* address length */
16
+ # unsigned char mr_address[8]; /* physical-layer address */
17
+ # };
18
+ # @rbs () -> String
19
+ def build: () -> String
20
+
21
+ # @rbs () -> String
22
+ def mr_ifindex: () -> String
23
+
24
+ private
25
+
26
+ # @rbs () -> Integer?
27
+ def index: () -> Integer?
28
+
29
+ # @rbs () -> String
30
+ def mr_type: () -> String
31
+
32
+ # @rbs () -> String
33
+ def mr_alen: () -> String
34
+
35
+ # @rbs () -> String
36
+ def mr_address: () -> String
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,24 @@
1
+ # Generated from lib/redhound/builder/socket.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ module Builder
5
+ class Socket
6
+ SOL_PACKET: ::Integer
7
+
8
+ PACKET_ADD_MEMBERSHIP: ::Integer
9
+
10
+ ETH_P_ALL: ::Integer
11
+
12
+ PACKED_ETH_P_ALL: untyped
13
+
14
+ # @rbs (ifname: String) -> Redhound::Source::Socket
15
+ def self.build: (ifname: String) -> Redhound::Source::Socket
16
+
17
+ # @rbs (ifname: String) -> void
18
+ def initialize: (ifname: String) -> void
19
+
20
+ # @rbs () -> Redhound::Source::Socket
21
+ def build: () -> Redhound::Source::Socket
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ # Generated from lib/redhound/command.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class Command
5
+ # @rbs () -> void
6
+ def initialize: () -> void
7
+
8
+ # @rbs (Array[untyped] argv) -> void
9
+ def run: (Array[untyped] argv) -> void
10
+
11
+ # @rbs (Array[untyped] argv) -> void
12
+ def parse: (Array[untyped] argv) -> void
13
+
14
+ private
15
+
16
+ # @rbs () -> void
17
+ def list_interfaces: () -> void
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ # Generated from lib/redhound/l2/ether.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L2
5
+ class Ether
6
+ attr_reader type: Protocol
7
+
8
+ # @rbs (bytes: Array[Integer], count: Integer) -> Redhound::L2::Ether
9
+ def self.generate: (bytes: Array[Integer], count: Integer) -> Redhound::L2::Ether
10
+
11
+ # @rbs (bytes: Array[Integer], count: Integer) -> void
12
+ def initialize: (bytes: Array[Integer], count: Integer) -> void
13
+
14
+ # @rbs () -> Integer
15
+ def size: () -> Integer
16
+
17
+ # @rbs () -> Redhound::L2::Ether
18
+ def generate: () -> Redhound::L2::Ether
19
+
20
+ # @rbs () -> void
21
+ def dump: () -> void
22
+
23
+ # @rbs () -> String
24
+ def to_s: () -> String
25
+
26
+ # @rbs () -> bool
27
+ def supported_type?: () -> bool
28
+
29
+ private
30
+
31
+ # @rbs () -> String
32
+ def dhost: () -> String
33
+
34
+ # @rbs () -> String
35
+ def shost: () -> String
36
+
37
+ # @rbs (Array[Integer] type) -> Integer
38
+ def hex_type: (Array[Integer] type) -> Integer
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,15 @@
1
+ # Generated from lib/redhound/l2/protocol.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L2
5
+ class Protocol
6
+ PROTO_TABLE: ::Hash[untyped, untyped]
7
+
8
+ # @rbs (protocol: Integer) -> void
9
+ def initialize: (protocol: Integer) -> void
10
+
11
+ # @rbs () -> String
12
+ def to_s: () -> String
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,57 @@
1
+ # Generated from lib/redhound/l3/arp.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L3
5
+ class Arp < Base
6
+ # @rbs (bytes: Array[Integer]) -> Redhound::L3::Arp
7
+ def self.generate: (bytes: Array[Integer]) -> Redhound::L3::Arp
8
+
9
+ # @rbs (bytes: Array[Integer]) -> void
10
+ def initialize: (bytes: Array[Integer]) -> void
11
+
12
+ # @rbs () -> Redhound::L3::Arp
13
+ def generate: () -> Redhound::L3::Arp
14
+
15
+ # @rbs () -> Integer
16
+ def arp_size: () -> Integer
17
+
18
+ # @rbs () -> Integer
19
+ def size: () -> Integer
20
+
21
+ # @rbs () -> String
22
+ def to_s: () -> String
23
+
24
+ # @rbs () -> bool
25
+ def supported_protocol?: () -> bool
26
+
27
+ # @rbs () -> String?
28
+ def protocol: () -> String?
29
+
30
+ private
31
+
32
+ # @rbs () -> Integer
33
+ def htype: () -> Integer
34
+
35
+ # @rbs () -> Integer
36
+ def ptype: () -> Integer
37
+
38
+ # @rbs () -> Integer
39
+ def oper: () -> Integer
40
+
41
+ # @rbs () -> String
42
+ def sha: () -> String
43
+
44
+ # @rbs () -> String
45
+ def spa: () -> String
46
+
47
+ # @rbs () -> String
48
+ def tha: () -> String
49
+
50
+ # @rbs () -> String
51
+ def tpa: () -> String
52
+
53
+ # @rbs () -> Redhound::L3::Base?
54
+ def generate_l3: () -> Redhound::L3::Base?
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,28 @@
1
+ # Generated from lib/redhound/l3/base.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L3
5
+ class Base
6
+ # @rbs (bytes: Array[Integer]) -> Redhound::L3::Base
7
+ def self.generate: (bytes: Array[Integer]) -> Redhound::L3::Base
8
+
9
+ # @rbs (bytes: Array[Integer]) -> void
10
+ def initialize: (bytes: Array[Integer]) -> void
11
+
12
+ # @rbs () -> Redhound::L3::Base
13
+ def generate: () -> Redhound::L3::Base
14
+
15
+ # @rbs () -> void
16
+ def dump: () -> void
17
+
18
+ # @rbs () -> Integer
19
+ def size: () -> Integer
20
+
21
+ # @rbs () -> bool
22
+ def supported_protocol?: () -> bool
23
+
24
+ # @rbs () -> Protocol
25
+ def protocol: () -> Protocol
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,53 @@
1
+ # Generated from lib/redhound/l3/ipv4.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L3
5
+ class Ipv4 < Base
6
+ # @rbs (bytes: Array[Integer]) -> Redhound::L3::Ipv4
7
+ def self.generate: (bytes: Array[Integer]) -> Redhound::L3::Ipv4
8
+
9
+ attr_reader protocol: Protocol
10
+
11
+ # @rbs (bytes: Array[Integer]) -> void
12
+ def initialize: (bytes: Array[Integer]) -> void
13
+
14
+ # @rbs () -> Redhound::L3::Ipv4
15
+ def generate: () -> Redhound::L3::Ipv4
16
+
17
+ # @rbs () -> Integer
18
+ def size: () -> Integer
19
+
20
+ # @rbs () -> String
21
+ def to_s: () -> String
22
+
23
+ # @rbs () -> bool
24
+ def supported_protocol?: () -> bool
25
+
26
+ private
27
+
28
+ # @rbs () -> Integer
29
+ def version: () -> Integer
30
+
31
+ # @rbs () -> Integer
32
+ def ihl: () -> Integer
33
+
34
+ # @rbs () -> Integer
35
+ def tot_len: () -> Integer
36
+
37
+ # @rbs () -> Integer
38
+ def id: () -> Integer
39
+
40
+ # @rbs () -> Integer
41
+ def frag_off: () -> Integer
42
+
43
+ # @rbs () -> Integer
44
+ def check: () -> Integer
45
+
46
+ # @rbs () -> String
47
+ def saddr: () -> String
48
+
49
+ # @rbs () -> String
50
+ def daddr: () -> String
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,38 @@
1
+ # Generated from lib/redhound/l3/ipv6.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L3
5
+ class Ipv6 < Base
6
+ # @rbs (bytes: Array[Integer]) -> Redhound::L3::Ipv6
7
+ def self.generate: (bytes: Array[Integer]) -> Redhound::L3::Ipv6
8
+
9
+ attr_reader protocol: Protocol
10
+
11
+ # @rbs (bytes: Array[Integer]) -> void
12
+ def initialize: (bytes: Array[Integer]) -> void
13
+
14
+ # @rbs () -> Integer
15
+ def size: () -> Integer
16
+
17
+ # @rbs () -> Redhound::L3::Ipv6
18
+ def generate: () -> Redhound::L3::Ipv6
19
+
20
+ # @rbs () -> String
21
+ def to_s: () -> String
22
+
23
+ # @rbs () -> bool
24
+ def supported_protocol?: () -> bool
25
+
26
+ private
27
+
28
+ # @rbs () -> Integer
29
+ def payload_length: () -> Integer
30
+
31
+ # @rbs () -> Integer
32
+ def saddr: () -> Integer
33
+
34
+ # @rbs () -> Integer
35
+ def daddr: () -> Integer
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ # Generated from lib/redhound/l3/protocol.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L3
5
+ class Protocol
6
+ # refs: https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml#protocol-numbers-1
7
+ PROTO_TABLE: untyped
8
+
9
+ # @rbs (protocol: Integer) -> void
10
+ def initialize: (protocol: Integer) -> void
11
+
12
+ # @rbs () -> String
13
+ def to_s: () -> String
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # Generated from lib/redhound/l3/resolver.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L3
5
+ class Resolver
6
+ # @rbs (bytes: Array[Integer], l2: Redhound::L2::Ether) -> Redhound::L3::Base?
7
+ def self.resolve: (bytes: Array[Integer], l2: Redhound::L2::Ether) -> Redhound::L3::Base?
8
+
9
+ # @rbs (bytes: Array[Integer], l2: Redhound::L2::Ether) -> void
10
+ def initialize: (bytes: Array[Integer], l2: Redhound::L2::Ether) -> void
11
+
12
+ # @rbs () -> Redhound::L3::Base?
13
+ def resolve: () -> Redhound::L3::Base?
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ # Generated from lib/redhound/l4/base.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L4
5
+ class Base
6
+ # @rbs (bytes: Array[Integer]) -> Redhound::L4::Base
7
+ def self.generate: (bytes: Array[Integer]) -> Redhound::L4::Base
8
+
9
+ # @rbs (bytes: Array[Integer]) -> void
10
+ def initialize: (bytes: Array[Integer]) -> void
11
+
12
+ # @rbs () -> Redhound::L4::Base
13
+ def generate: () -> Redhound::L4::Base
14
+
15
+ # @rbs () -> void
16
+ def dump: () -> void
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ # Generated from lib/redhound/l4/icmp.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L4
5
+ class Icmp < Base
6
+ # @rbs (bytes: Array[Integer]) -> void
7
+ def initialize: (bytes: Array[Integer]) -> void
8
+
9
+ # @rbs () -> Redhound::L4::Icmp
10
+ def generate: () -> Redhound::L4::Icmp
11
+
12
+ # @rbs () -> Integer
13
+ def size: () -> Integer
14
+
15
+ # @rbs () -> String
16
+ def to_s: () -> String
17
+
18
+ private
19
+
20
+ # @rbs () -> Integer
21
+ def check: () -> Integer
22
+
23
+ # @rbs () -> Integer
24
+ def id: () -> Integer
25
+
26
+ # @rbs () -> Integer
27
+ def seq: () -> Integer
28
+
29
+ # @rbs () -> String
30
+ def data: () -> String
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ # Generated from lib/redhound/l4/resolver.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L4
5
+ class Resolver
6
+ # @rbs (bytes: Array[Integer], l3: Redhound::L3::Base) -> Redhound::L4::Base?
7
+ def self.resolve: (bytes: Array[Integer], l3: Redhound::L3::Base) -> Redhound::L4::Base?
8
+
9
+ # @rbs (bytes: Array[Integer], l3: Redhound::L3::Base) -> void
10
+ def initialize: (bytes: Array[Integer], l3: Redhound::L3::Base) -> void
11
+
12
+ # @rbs () -> Redhound::L4::Base?
13
+ def resolve: () -> Redhound::L4::Base?
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,36 @@
1
+ # Generated from lib/redhound/l4/udp.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class L4
5
+ class Udp < Base
6
+ # @rbs (bytes: Array[Integer]) -> void
7
+ def initialize: (bytes: Array[Integer]) -> void
8
+
9
+ # @rbs () -> Redhound::L4::Udp
10
+ def generate: () -> Redhound::L4::Udp
11
+
12
+ # @rbs () -> Integer
13
+ def size: () -> Integer
14
+
15
+ # @rbs () -> String
16
+ def to_s: () -> String
17
+
18
+ private
19
+
20
+ # @rbs () -> Integer
21
+ def sport: () -> Integer
22
+
23
+ # @rbs () -> Integer
24
+ def dport: () -> Integer
25
+
26
+ # @rbs () -> Integer
27
+ def len: () -> Integer
28
+
29
+ # @rbs () -> Integer
30
+ def check: () -> Integer
31
+
32
+ # @rbs () -> String
33
+ def data: () -> String
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ # Generated from lib/redhound/receiver.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class Receiver
5
+ # @rbs (ifname: String, filename: String) -> void
6
+ def self.run: (ifname: String, filename: String) -> void
7
+
8
+ # @rbs (ifname: String, filename: String) -> void
9
+ def initialize: (ifname: String, filename: String) -> void
10
+
11
+ # @rbs () -> void
12
+ def run: () -> void
13
+
14
+ private
15
+
16
+ # @rbs () -> Integer
17
+ def increment: () -> Integer
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ # Generated from lib/redhound/resolver.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ class Resolver
5
+ # @rbs (ifname: String) -> void
6
+ def self.resolve: (ifname: String) -> void
7
+
8
+ # @rbs (ifname: String) -> Redhound::Source::Socket
9
+ def resolve: (ifname: String) -> Redhound::Source::Socket
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # Generated from lib/redhound/source/socket.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ module Source
5
+ class Socket
6
+ # @rbs (socket: ::Socket) -> void
7
+ def initialize: (socket: ::Socket) -> void
8
+
9
+ # @rbs (Integer size) -> [String, Addrinfo]
10
+ def next_packet: (Integer size) -> [ String, Addrinfo ]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ # Generated from lib/redhound/version.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ VERSION: ::String
5
+ end
@@ -0,0 +1,25 @@
1
+ # Generated from lib/redhound/writer.rb with RBS::Inline
2
+
3
+ module Redhound
4
+ 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
24
+ end
25
+ end