ronin-support 0.4.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.github/workflows/ruby.yml +28 -0
  4. data/.ruby-version +1 -0
  5. data/.yardopts +1 -1
  6. data/ChangeLog.md +121 -33
  7. data/Gemfile +17 -18
  8. data/README.md +57 -33
  9. data/Rakefile +10 -3
  10. data/gemspec.yml +16 -7
  11. data/lib/ronin/binary.rb +21 -0
  12. data/lib/ronin/binary/hexdump.rb +20 -0
  13. data/lib/ronin/binary/hexdump/parser.rb +403 -0
  14. data/lib/ronin/binary/struct.rb +567 -0
  15. data/lib/ronin/binary/template.rb +454 -0
  16. data/lib/ronin/extensions.rb +5 -5
  17. data/lib/ronin/extensions/enumerable.rb +5 -5
  18. data/lib/ronin/extensions/file.rb +39 -33
  19. data/lib/ronin/extensions/ip_addr.rb +29 -31
  20. data/lib/ronin/extensions/kernel.rb +5 -5
  21. data/lib/ronin/extensions/meta.rb +5 -5
  22. data/lib/ronin/extensions/regexp.rb +50 -5
  23. data/lib/ronin/extensions/resolv.rb +7 -9
  24. data/lib/ronin/extensions/string.rb +10 -10
  25. data/lib/ronin/formatting.rb +5 -5
  26. data/lib/ronin/formatting/binary.rb +5 -5
  27. data/lib/ronin/formatting/digest.rb +5 -5
  28. data/lib/ronin/formatting/extensions.rb +5 -5
  29. data/lib/ronin/formatting/extensions/binary.rb +7 -5
  30. data/lib/ronin/formatting/extensions/binary/array.rb +61 -0
  31. data/lib/ronin/formatting/extensions/binary/base64.rb +106 -0
  32. data/lib/ronin/formatting/extensions/binary/file.rb +44 -11
  33. data/lib/ronin/formatting/extensions/binary/float.rb +65 -0
  34. data/lib/ronin/formatting/extensions/binary/integer.rb +66 -50
  35. data/lib/ronin/formatting/extensions/binary/string.rb +81 -205
  36. data/lib/ronin/formatting/extensions/digest.rb +5 -5
  37. data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
  38. data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
  39. data/lib/ronin/formatting/extensions/html.rb +5 -5
  40. data/lib/ronin/formatting/extensions/html/integer.rb +9 -13
  41. data/lib/ronin/formatting/extensions/html/string.rb +31 -39
  42. data/lib/ronin/formatting/extensions/http.rb +5 -5
  43. data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
  44. data/lib/ronin/formatting/extensions/http/string.rb +7 -7
  45. data/lib/ronin/formatting/extensions/sql.rb +5 -5
  46. data/lib/ronin/formatting/extensions/sql/string.rb +22 -24
  47. data/lib/ronin/formatting/extensions/text.rb +5 -5
  48. data/lib/ronin/formatting/extensions/text/array.rb +13 -11
  49. data/lib/ronin/formatting/extensions/text/string.rb +70 -13
  50. data/lib/ronin/formatting/html.rb +5 -5
  51. data/lib/ronin/formatting/http.rb +5 -5
  52. data/lib/ronin/formatting/sql.rb +5 -5
  53. data/lib/ronin/formatting/text.rb +5 -5
  54. data/lib/ronin/fuzzing.rb +5 -5
  55. data/lib/ronin/fuzzing/extensions.rb +5 -5
  56. data/lib/ronin/fuzzing/extensions/string.rb +42 -213
  57. data/lib/ronin/fuzzing/fuzzer.rb +110 -0
  58. data/lib/ronin/fuzzing/fuzzing.rb +33 -26
  59. data/lib/ronin/fuzzing/mutator.rb +161 -0
  60. data/lib/ronin/fuzzing/repeater.rb +81 -0
  61. data/lib/ronin/fuzzing/template.rb +133 -0
  62. data/lib/ronin/mixin.rb +2 -2
  63. data/lib/ronin/network.rb +7 -5
  64. data/lib/ronin/network/dns.rb +64 -24
  65. data/lib/ronin/network/esmtp.rb +5 -5
  66. data/lib/ronin/network/extensions.rb +5 -5
  67. data/lib/ronin/network/extensions/dns.rb +5 -5
  68. data/lib/ronin/network/extensions/dns/net.rb +5 -5
  69. data/lib/ronin/network/extensions/esmtp.rb +5 -5
  70. data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
  71. data/lib/ronin/network/extensions/http.rb +5 -5
  72. data/lib/ronin/network/extensions/http/net.rb +5 -5
  73. data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
  74. data/lib/ronin/network/extensions/imap.rb +5 -5
  75. data/lib/ronin/network/extensions/imap/net.rb +5 -5
  76. data/lib/ronin/network/extensions/pop3.rb +5 -5
  77. data/lib/ronin/network/extensions/pop3/net.rb +5 -5
  78. data/lib/ronin/network/extensions/smtp.rb +5 -5
  79. data/lib/ronin/network/extensions/smtp/net.rb +5 -5
  80. data/lib/ronin/network/extensions/ssl.rb +5 -5
  81. data/lib/ronin/network/extensions/ssl/net.rb +5 -5
  82. data/lib/ronin/network/extensions/tcp.rb +5 -5
  83. data/lib/ronin/network/extensions/tcp/net.rb +5 -5
  84. data/lib/ronin/network/extensions/telnet.rb +5 -5
  85. data/lib/ronin/network/extensions/telnet/net.rb +5 -5
  86. data/lib/ronin/network/extensions/udp.rb +5 -5
  87. data/lib/ronin/network/extensions/udp/net.rb +5 -5
  88. data/lib/ronin/network/ftp.rb +149 -0
  89. data/lib/ronin/network/http.rb +5 -5
  90. data/lib/ronin/network/http/exceptions.rb +5 -5
  91. data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
  92. data/lib/ronin/network/http/http.rb +65 -70
  93. data/lib/ronin/network/http/proxy.rb +5 -5
  94. data/lib/ronin/network/imap.rb +16 -15
  95. data/lib/ronin/network/mixins.rb +6 -5
  96. data/lib/ronin/network/mixins/dns.rb +5 -5
  97. data/lib/ronin/network/mixins/esmtp.rb +5 -5
  98. data/lib/ronin/network/mixins/ftp.rb +155 -0
  99. data/lib/ronin/network/mixins/http.rb +58 -587
  100. data/lib/ronin/network/mixins/imap.rb +5 -5
  101. data/lib/ronin/network/mixins/mixin.rb +5 -5
  102. data/lib/ronin/network/mixins/pop3.rb +5 -5
  103. data/lib/ronin/network/mixins/smtp.rb +5 -5
  104. data/lib/ronin/network/mixins/ssl.rb +5 -5
  105. data/lib/ronin/network/mixins/tcp.rb +43 -10
  106. data/lib/ronin/network/mixins/telnet.rb +5 -5
  107. data/lib/ronin/network/mixins/udp.rb +126 -6
  108. data/lib/ronin/network/mixins/unix.rb +279 -0
  109. data/lib/ronin/network/network.rb +5 -5
  110. data/lib/ronin/network/pop3.rb +10 -10
  111. data/lib/ronin/network/proxy.rb +578 -0
  112. data/lib/ronin/network/smtp.rb +5 -5
  113. data/lib/ronin/network/smtp/email.rb +6 -6
  114. data/lib/ronin/network/smtp/smtp.rb +12 -13
  115. data/lib/ronin/network/ssl.rb +16 -17
  116. data/lib/ronin/network/tcp.rb +7 -310
  117. data/lib/ronin/network/tcp/proxy.rb +417 -0
  118. data/lib/ronin/network/tcp/tcp.rb +452 -0
  119. data/lib/ronin/network/telnet.rb +34 -28
  120. data/lib/ronin/network/udp.rb +7 -271
  121. data/lib/ronin/network/udp/proxy.rb +191 -0
  122. data/lib/ronin/network/udp/udp.rb +452 -0
  123. data/lib/ronin/network/unix.rb +286 -0
  124. data/lib/ronin/path.rb +35 -39
  125. data/lib/ronin/spec/ui/output.rb +6 -12
  126. data/lib/ronin/support.rb +6 -5
  127. data/lib/ronin/support/inflector.rb +8 -12
  128. data/lib/ronin/support/support.rb +7 -5
  129. data/lib/ronin/support/version.rb +6 -6
  130. data/lib/ronin/templates.rb +5 -5
  131. data/lib/ronin/templates/erb.rb +5 -5
  132. data/lib/ronin/templates/template.rb +5 -5
  133. data/lib/ronin/ui/output.rb +5 -5
  134. data/lib/ronin/ui/output/helpers.rb +42 -28
  135. data/lib/ronin/ui/output/output.rb +17 -21
  136. data/lib/ronin/ui/output/terminal.rb +5 -5
  137. data/lib/ronin/ui/output/terminal/color.rb +15 -9
  138. data/lib/ronin/ui/output/terminal/raw.rb +5 -5
  139. data/lib/ronin/ui/shell.rb +8 -11
  140. data/lib/ronin/wordlist.rb +110 -30
  141. data/ronin-support.gemspec +39 -109
  142. data/spec/binary/hexdump/helpers/hexdumps.rb +13 -0
  143. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/ascii.bin +0 -0
  144. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -0
  145. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_bytes.txt +0 -0
  146. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_shorts.txt +0 -0
  147. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_bytes.txt +0 -0
  148. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_shorts.txt +0 -0
  149. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_repeated.txt +0 -0
  150. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_bytes.txt +0 -0
  151. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_ints.txt +0 -0
  152. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_quads.txt +0 -0
  153. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_shorts.txt +0 -0
  154. data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +17 -0
  155. data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +17 -0
  156. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_bytes.txt +0 -0
  157. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_ints.txt +0 -0
  158. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_quads.txt +0 -0
  159. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_shorts.txt +0 -0
  160. data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +17 -0
  161. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_bytes.txt +0 -0
  162. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_ints.txt +0 -0
  163. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_quads.txt +0 -0
  164. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_shorts.txt +0 -0
  165. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_repeated.txt +0 -0
  166. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/repeated.bin +0 -0
  167. data/spec/binary/hexdump/parser_spec.rb +302 -0
  168. data/spec/binary/struct_spec.rb +496 -0
  169. data/spec/binary/template_spec.rb +416 -0
  170. data/spec/extensions/enumerable_spec.rb +4 -4
  171. data/spec/extensions/file_spec.rb +12 -14
  172. data/spec/extensions/ip_addr_spec.rb +76 -50
  173. data/spec/extensions/kernel_spec.rb +7 -7
  174. data/spec/extensions/regexp_spec.rb +119 -59
  175. data/spec/extensions/resolv_spec.rb +2 -2
  176. data/spec/extensions/string_spec.rb +31 -30
  177. data/spec/formatting/binary/array_spec.rb +26 -0
  178. data/spec/formatting/binary/base64_spec.rb +50 -0
  179. data/spec/formatting/binary/float_spec.rb +36 -0
  180. data/spec/formatting/binary/integer_spec.rb +76 -50
  181. data/spec/formatting/binary/string_spec.rb +91 -198
  182. data/spec/formatting/digest/string_spec.rb +5 -5
  183. data/spec/formatting/html/integer_spec.rb +6 -6
  184. data/spec/formatting/html/string_spec.rb +10 -10
  185. data/spec/formatting/http/integer_spec.rb +3 -3
  186. data/spec/formatting/http/string_spec.rb +5 -5
  187. data/spec/formatting/sql/string_spec.rb +21 -19
  188. data/spec/formatting/text/array_spec.rb +15 -15
  189. data/spec/formatting/text/string_spec.rb +58 -28
  190. data/spec/fuzzing/extensions/string_spec.rb +87 -0
  191. data/spec/fuzzing/fuzzer_spec.rb +109 -0
  192. data/spec/fuzzing/fuzzing_spec.rb +24 -0
  193. data/spec/fuzzing/mutator_spec.rb +112 -0
  194. data/spec/fuzzing/repeater_spec.rb +57 -0
  195. data/spec/fuzzing/template_spec.rb +54 -0
  196. data/spec/mixin_spec.rb +10 -12
  197. data/spec/network/dns_spec.rb +89 -23
  198. data/spec/network/ftp_spec.rb +81 -0
  199. data/spec/network/http/http_spec.rb +237 -144
  200. data/spec/network/http/proxy_spec.rb +37 -37
  201. data/spec/network/network_spec.rb +2 -2
  202. data/spec/network/proxy_spec.rb +121 -0
  203. data/spec/network/shared/unix_server.rb +31 -0
  204. data/spec/network/smtp/email_spec.rb +14 -14
  205. data/spec/network/ssl_spec.rb +53 -3
  206. data/spec/network/tcp/proxy_spec.rb +118 -0
  207. data/spec/network/tcp/tcp_spec.rb +316 -0
  208. data/spec/network/telnet_spec.rb +67 -0
  209. data/spec/network/udp/udp_spec.rb +298 -0
  210. data/spec/network/unix_spec.rb +182 -0
  211. data/spec/path_spec.rb +43 -18
  212. data/spec/spec_helper.rb +2 -3
  213. data/spec/support/inflector_spec.rb +4 -4
  214. data/spec/support_spec.rb +1 -1
  215. data/spec/templates/erb_spec.rb +3 -3
  216. data/spec/templates/template_spec.rb +10 -10
  217. data/spec/ui/shell_spec.rb +15 -15
  218. data/spec/wordlist_spec.rb +80 -19
  219. metadata +176 -121
  220. data/.gemtest +0 -0
  221. data/spec/formatting/binary/helpers/hexdumps.rb +0 -16
  222. data/spec/fuzzing/string_spec.rb +0 -158
  223. data/spec/network/tcp_spec.rb +0 -247
  224. data/spec/network/udp_spec.rb +0 -248
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/ui/output/helpers'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -64,6 +64,29 @@ module Ronin
64
64
 
65
65
  protected
66
66
 
67
+ #
68
+ # Tests whether the TCP port, specified by the `host` and `port`
69
+ # parameters, is open.
70
+ #
71
+ # @param [Integer] timeout (5)
72
+ # The maximum time to attempt connecting.
73
+ #
74
+ # @return [Boolean, nil]
75
+ # Specifies whether the remote TCP port is open.
76
+ # If the connection was not accepted, `nil` will be returned.
77
+ #
78
+ # @see Network::TCP#tcp_open?
79
+ #
80
+ # @api public
81
+ #
82
+ # @since 0.5.0
83
+ #
84
+ def tcp_open?(timeout=nil)
85
+ print_info "Testing if #{host_port} is open ..."
86
+
87
+ super(self.host,self.port,self.local_host,self.local_port,timeout)
88
+ end
89
+
67
90
  #
68
91
  # Opens a TCP connection to the host and port specified by the
69
92
  # `host` and `port` parameters. If the `local_host` and
@@ -147,7 +170,7 @@ module Ronin
147
170
  def tcp_session(&block)
148
171
  print_info "Connecting to #{host_port} ..."
149
172
 
150
- Net.tcp_session(self.host,self.port,self.local_host,self.local_port,&block)
173
+ super(self.host,self.port,self.local_host,self.local_port,&block)
151
174
 
152
175
  print_info "Disconnected from #{host_port}"
153
176
  return nil
@@ -189,7 +212,7 @@ module Ronin
189
212
  #
190
213
  # @example
191
214
  # buffer = "GET /" + ('A' * 4096) + "\n\r"
192
- # Net.tcp_send(buffer)
215
+ # tcp_send(buffer)
193
216
  # # => true
194
217
  #
195
218
  # @see Network::TCP#tcp_send
@@ -287,15 +310,17 @@ module Ronin
287
310
  # @return [nil]
288
311
  #
289
312
  # @example
290
- # tcp_single_server do |client|
313
+ # tcp_accept do |client|
291
314
  # client.puts 'lol'
292
315
  # end
293
316
  #
294
- # @see Network::TCP#tcp_server_single_server
317
+ # @see Network::TCP#tcp_accept
295
318
  #
296
319
  # @api public
297
320
  #
298
- def tcp_single_server(&block)
321
+ # @since 0.5.0
322
+ #
323
+ def tcp_accept(&block)
299
324
  print_info "Listening on #{server_host_port} ..."
300
325
 
301
326
  super(self.server_port,self.server_host) do |client|
@@ -314,6 +339,14 @@ module Ronin
314
339
  return nil
315
340
  end
316
341
 
342
+ #
343
+ # @deprecated
344
+ # Deprecated as of 0.5.0. Use {#tcp_accept} instead.
345
+ #
346
+ def tcp_single_server(&block)
347
+ tcp_accept(&block)
348
+ end
349
+
317
350
  private
318
351
 
319
352
  #
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -64,6 +64,27 @@ module Ronin
64
64
 
65
65
  protected
66
66
 
67
+ #
68
+ # Tests whether the UDP port, specified by the `host` and `port`
69
+ # parameters, is open.
70
+ #
71
+ # @param [Integer] timeout (5)
72
+ # The maximum time to attempt connecting.
73
+ #
74
+ # @return [Boolean, nil]
75
+ # Specifies whether the remote UDP port is open.
76
+ # If no data or ICMP error were received, `nil` will be returned.
77
+ #
78
+ # @api public
79
+ #
80
+ # @since 0.5.0
81
+ #
82
+ def udp_open?(timeout=nil)
83
+ print_info "Testing if #{host_port} is open ..."
84
+
85
+ super(self.host,self.port,self.local_host,self.local_port,timeout)
86
+ end
87
+
67
88
  #
68
89
  # Opens a UDP connection to the host and port specified by the
69
90
  # `host` and `port` parameters. If the `local_host` and
@@ -164,7 +185,7 @@ module Ronin
164
185
  #
165
186
  # @example
166
187
  # buffer = "GET /" + ('A' * 4096) + "\n\r"
167
- # Net.udp_send(buffer)
188
+ # udp_send(buffer)
168
189
  # # => true
169
190
  #
170
191
  # @see Network::UDP#udp_send
@@ -240,6 +261,105 @@ module Ronin
240
261
  return nil
241
262
  end
242
263
 
264
+ #
265
+ # Creates a new UDPServer listening on the `server_host` and
266
+ # `server_port` parameters, accepting messages from clients in a loop.
267
+ #
268
+ # @yield [server, (client_host, client_port), mesg]
269
+ # The given block will be passed the client host/port and the received
270
+ # message.
271
+ #
272
+ # @yieldparam [UDPServer] server
273
+ # The UDPServer.
274
+ #
275
+ # @yieldparam [String] client_host
276
+ # The source host of the mesg.
277
+ #
278
+ # @yieldparam [Integer] client_port
279
+ # The source port of the mesg.
280
+ #
281
+ # @yieldparam [String] mesg
282
+ # The received message.
283
+ #
284
+ # @return [nil]
285
+ #
286
+ # @example
287
+ # udp_server_loop do |server,(host,port),mesg|
288
+ # server.send('hello',host,port)
289
+ # end
290
+ #
291
+ # @see Network::UDP#udp_server_loop
292
+ #
293
+ # @api public
294
+ #
295
+ # @since 0.5.0
296
+ #
297
+ def udp_server_loop(&block)
298
+ print_info "Listening on #{self.server_host_port} ..."
299
+
300
+ super(self.server_port,self.server_host,&block)
301
+
302
+ print_info "Closed #{self.server_host_port}"
303
+ return nil
304
+ end
305
+
306
+ #
307
+ # Creates a new UDPServer listening on the `server_host` and
308
+ # `server_port` parameters, accepts only one message from a client.
309
+ #
310
+ # @yield [server, (client_host, client_port), mesg]
311
+ # The given block will be passed the client host/port and the received
312
+ # message.
313
+ #
314
+ # @yieldparam [UDPServer] server
315
+ # The UDPServer.
316
+ #
317
+ # @yieldparam [String] client_host
318
+ # The source host of the mesg.
319
+ #
320
+ # @yieldparam [Integer] client_port
321
+ # The source port of the mesg.
322
+ #
323
+ # @yieldparam [String] mesg
324
+ # The received message.
325
+ #
326
+ # @return [nil]
327
+ #
328
+ # @example
329
+ # udp_recv do |server,(host,port),mesg|
330
+ # server.send('hello',host,port)
331
+ # end
332
+ #
333
+ # @see Network::UDP#udp_recv
334
+ #
335
+ # @api public
336
+ #
337
+ # @since 0.5.0
338
+ #
339
+ def udp_recv(&block)
340
+ print_info "Listening on #{self.server_host_port} ..."
341
+
342
+ super(self.server_port,self.server_host) do |server,(host,port),mesg|
343
+ print_info "Received message from #{host}:#{port}"
344
+ print_debug mesg
345
+
346
+ yield server, [host, port], mesg if block_given?
347
+ end
348
+
349
+ print_info "Closed #{self.server_host_port}"
350
+ return nil
351
+ end
352
+
353
+ #
354
+ # @deprecated
355
+ # Deprecated as of 0.5.0. Use {#udp_recv} instead.
356
+ #
357
+ # @since 0.5.0
358
+ #
359
+ def udp_single_server(&block)
360
+ udp_recv(&block)
361
+ end
362
+
243
363
  private
244
364
 
245
365
  #
@@ -0,0 +1,279 @@
1
+ #
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
+ #
4
+ # This file is part of ronin-support.
5
+ #
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # ronin-support is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ require 'ronin/network/mixins/mixin'
21
+ require 'ronin/network/unix'
22
+
23
+ module Ronin
24
+ module Network
25
+ module Mixins
26
+ #
27
+ # Adds UNIX Socket convenience methods and connection parameters to a
28
+ # class.
29
+ #
30
+ # Defines the following parameters:
31
+ #
32
+ # * `path` (`String`) - UNIX Socket path.
33
+ #
34
+ # @since 0.5.0
35
+ #
36
+ module UNIX
37
+ include Mixin, Network::UNIX
38
+
39
+ # UNIX path
40
+ parameter :path, :type => String,
41
+ :description => 'UNIX Socket path'
42
+
43
+ protected
44
+
45
+ #
46
+ # Connects to a UNIX socket specified by the `path` parameter.
47
+ #
48
+ # @yield [socket]
49
+ # If a block is given, it will be passed an UNIX socket object.
50
+ #
51
+ # @yieldparam [UNIXSocket] socket
52
+ # The UNIX socket.
53
+ #
54
+ # @return [UNIXSocket]
55
+ # The UNIX socket.
56
+ #
57
+ # @example
58
+ # socket = unix_connect
59
+ #
60
+ # @see Network::UNIX#unix_connect
61
+ #
62
+ # @api public
63
+ #
64
+ def unix_connect(&block)
65
+ print_info "Connecting to #{self.path} ..."
66
+
67
+ super(self.path,&block)
68
+ end
69
+
70
+ #
71
+ # Creates a new UNIXSocket object, connected to the `path` parameter.
72
+ # The given data will then be written to the newly created UNIXSocket.
73
+ #
74
+ # @param [String] data
75
+ # The data to send to the socket.
76
+ #
77
+ # @yield [socket]
78
+ # If a block is given, it will be passed the newly created socket.
79
+ #
80
+ # @yieldparam [UNIXSocket] socket
81
+ # The newly created UNIXSocket object.
82
+ #
83
+ # @return [UNIXSocket]
84
+ # The newly created UNIXSocket object.
85
+ #
86
+ # @see Network::UNIX#unix_connect_and_send
87
+ #
88
+ # @api public
89
+ #
90
+ def unix_connect_and_send(data,&block)
91
+ print_info "Connecting to #{self.path} ..."
92
+ print_debug "Sending data: #{data.inspect}"
93
+
94
+ return super(data,self.path,&block)
95
+ end
96
+
97
+ #
98
+ # Creates a UNIX session to the host and port specified by the
99
+ # `host` and `port` parameters. If the `local_host` and `local_port`
100
+ # parameters are set, they will be used for the local host and port
101
+ # of the UNIX connection.
102
+ #
103
+ # @yield [socket]
104
+ # If a block is given, it will be passed the newly created socket.
105
+ # After the block has returned, the socket will then be closed.
106
+ #
107
+ # @yieldparam [UNIXsocket] socket
108
+ # The newly created UNIXSocket object.
109
+ #
110
+ # @see Network::UNIX#unix_session
111
+ #
112
+ # @api public
113
+ #
114
+ def unix_session(&block)
115
+ print_info "Connecting to #{self.path} ..."
116
+
117
+ super(self.host,&block)
118
+
119
+ print_info "Disconnected from #{self.path}"
120
+ return nil
121
+ end
122
+
123
+ #
124
+ # Connects to the UNIX socket, specified by the `path` parameter,
125
+ # sends the given data and then disconnects.
126
+ #
127
+ # @param [String] data
128
+ # The data to send to the UNIX socket.
129
+ #
130
+ # @return [true]
131
+ # The data was successfully sent.
132
+ #
133
+ # @example
134
+ # buffer = "GET /" + ('A' * 4096) + "\n\r"
135
+ # unix_send(buffer)
136
+ # # => true
137
+ #
138
+ # @see Network::UNIX#unix_send
139
+ #
140
+ # @api public
141
+ #
142
+ # @since 0.4.0
143
+ #
144
+ def unix_send(data)
145
+ print_info "Connecting to #{self.path} ..."
146
+ print_debug "Sending data: #{data.inspect}"
147
+
148
+ super(data,self.path,&block)
149
+
150
+ print_info "Disconnected from #{self.path}"
151
+ return true
152
+ end
153
+
154
+ #
155
+ # Opens a UNIX socket, listening on the `path` parameter.
156
+ #
157
+ # @yield [server]
158
+ # The given block will be passed the newly created server.
159
+ #
160
+ # @yieldparam [UNIXServer] server
161
+ # The newly created server.
162
+ #
163
+ # @return [UNIXServer]
164
+ # The newly created server.
165
+ #
166
+ # @example
167
+ # unix_server
168
+ #
169
+ # @see Network::UNIX#unix_server
170
+ #
171
+ # @api public
172
+ #
173
+ def unix_server(&block)
174
+ print_info "Listening on #{self.path} ..."
175
+
176
+ return super(self.path,&block)
177
+ end
178
+
179
+ #
180
+ # Opens a UNIX socket temporarily, listening on the `path` parameter.
181
+ #
182
+ # @yield [server]
183
+ # The given block will be passed the newly created server.
184
+ # When the block has finished, the server will be closed.
185
+ #
186
+ # @yieldparam [UNIXServer] server
187
+ # The newly created server.
188
+ #
189
+ # @return [nil]
190
+ #
191
+ # @example
192
+ # unix_server_session do |server|
193
+ # # ...
194
+ # end
195
+ #
196
+ # @see Network::UNIX#unix_server_session
197
+ #
198
+ # @api public
199
+ #
200
+ def unix_server_session(&block)
201
+ print_info "Listening on #{self.path} ..."
202
+
203
+ super(self.path,&block)
204
+
205
+ print_info "Closed #{self.path}"
206
+ return nil
207
+ end
208
+
209
+ #
210
+ # Opens a UNIX socket specified by the `path` parameter,
211
+ # accepts a connection, then closes the socket.
212
+ #
213
+ # @yield [client]
214
+ # If a block is given, it will be passed the accepted connection.
215
+ #
216
+ # @yieldparam [UNIXSocket] client
217
+ # The accepted connection to UNIX socket.
218
+ #
219
+ # @example
220
+ # unix_accept do |client|
221
+ # # ...
222
+ # end
223
+ #
224
+ # @see Network::UNIX#unix_accept
225
+ #
226
+ # @api public
227
+ #
228
+ def unix_accept
229
+ print_info "Listening on #{self.path} ..."
230
+
231
+ super(self.path) do |client|
232
+ print_info "Client connected to #{self.path}"
233
+
234
+ yield client if block_given?
235
+
236
+ print_info "Client disconnecting from #{self.path} ..."
237
+ end
238
+
239
+ print_info "Closed #{self.path}"
240
+ return nil
241
+ end
242
+
243
+ #
244
+ # Opens a UNIX socket specified by the `path` parameter,
245
+ # accepts connections in a loop.
246
+ #
247
+ # @yield [client]
248
+ # If a block is given, it will be passed each accepted connection.
249
+ #
250
+ # @yieldparam [UNIXSocket] client
251
+ # An accepted connection to UNIX socket.
252
+ #
253
+ # @example
254
+ # unix_server_loop do |client|
255
+ # # ...
256
+ # end
257
+ #
258
+ # @see Network::UNIX#unix_server_loop
259
+ #
260
+ # @api public
261
+ #
262
+ def unix_server_loop
263
+ print_info "Listening on #{self.path} ..."
264
+
265
+ super(self.path) do |client|
266
+ print_info "Client connected: #{self.path}"
267
+
268
+ yield client if block_given?
269
+
270
+ print_info "Client disconnecting: #{self.path} ..."
271
+ end
272
+
273
+ print_info "Closed #{self.path}"
274
+ return nil
275
+ end
276
+ end
277
+ end
278
+ end
279
+ end