ronin 1.5.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (499) hide show
  1. checksums.yaml +4 -4
  2. data/.document +0 -1
  3. data/.github/workflows/ruby.yml +4 -5
  4. data/.gitignore +1 -0
  5. data/.mailmap +1 -0
  6. data/.ruby-version +1 -1
  7. data/.yardopts +0 -2
  8. data/ChangeLog.md +239 -148
  9. data/Gemfile +58 -45
  10. data/README.md +147 -178
  11. data/Rakefile +3 -50
  12. data/bin/ronin +2 -3
  13. data/data/new/project/.gitignore +15 -0
  14. data/data/new/project/.ruby-version.erb +1 -0
  15. data/data/new/project/Dockerfile.erb +9 -0
  16. data/data/new/project/Gemfile.erb +16 -0
  17. data/data/new/project/Rakefile +43 -0
  18. data/data/new/project/project.rb.erb +14 -0
  19. data/data/new/script.rb.erb +6 -0
  20. data/data/tips/cli/console.txt +4 -0
  21. data/data/tips/cli/help.txt +12 -0
  22. data/data/tips/ruby/array_join.txt +5 -0
  23. data/data/tips/ruby/binary_string.txt +4 -0
  24. data/data/tips/ruby/file_binread.txt +4 -0
  25. data/data/tips/ruby/file_each_line.txt +6 -0
  26. data/data/tips/ruby/force_encoding.txt +4 -0
  27. data/data/tips/ruby/integer_binary_format.txt +10 -0
  28. data/data/tips/ruby/integer_chr.txt +5 -0
  29. data/data/tips/ruby/integer_hex_format.txt +10 -0
  30. data/data/tips/ruby/string_bytes.txt +17 -0
  31. data/data/tips/ruby/string_chars.txt +17 -0
  32. data/data/tips/ruby/string_ord.txt +5 -0
  33. data/data/tips/ruby/string_split.txt +13 -0
  34. data/data/tips/scripting/array_pack.txt +5 -0
  35. data/data/tips/scripting/base64_decode.txt +5 -0
  36. data/data/tips/scripting/base64_encode.txt +5 -0
  37. data/data/tips/scripting/build_wordlist.txt +9 -0
  38. data/data/tips/scripting/chars.txt +8 -0
  39. data/data/tips/scripting/chars_strings_in.txt +12 -0
  40. data/data/tips/scripting/dir_traversal.txt +5 -0
  41. data/data/tips/scripting/dns_get_address.txt +5 -0
  42. data/data/tips/scripting/dns_get_addresses.txt +5 -0
  43. data/data/tips/scripting/extract_ips.txt +6 -0
  44. data/data/tips/scripting/file_each_row.txt +6 -0
  45. data/data/tips/scripting/file_hexdump.txt +4 -0
  46. data/data/tips/scripting/float_pack.txt +5 -0
  47. data/data/tips/scripting/ftp_connect.txt +14 -0
  48. data/data/tips/scripting/generate_self_signed_cert.txt +20 -0
  49. data/data/tips/scripting/http_get_body.txt +5 -0
  50. data/data/tips/scripting/http_get_headers.txt +17 -0
  51. data/data/tips/scripting/integer_pack.txt +5 -0
  52. data/data/tips/scripting/ip_range_cidr.txt +6 -0
  53. data/data/tips/scripting/ip_range_glob.txt +6 -0
  54. data/data/tips/scripting/load_cert.txt +5 -0
  55. data/data/tips/scripting/md5.txt +5 -0
  56. data/data/tips/scripting/printing_messages.txt +11 -0
  57. data/data/tips/scripting/random_alpha.txt +5 -0
  58. data/data/tips/scripting/random_alpha_numeric.txt +5 -0
  59. data/data/tips/scripting/random_hex.txt +5 -0
  60. data/data/tips/scripting/read_wordlist.txt +7 -0
  61. data/data/tips/scripting/ronin_support.txt +5 -0
  62. data/data/tips/scripting/sha1.txt +5 -0
  63. data/data/tips/scripting/sha256.txt +5 -0
  64. data/data/tips/scripting/sha512.txt +5 -0
  65. data/data/tips/scripting/ssl_cert.txt +10 -0
  66. data/data/tips/scripting/ssl_socket.txt +12 -0
  67. data/data/tips/scripting/string_hexdump.txt +5 -0
  68. data/data/tips/scripting/string_random_case.txt +5 -0
  69. data/data/tips/scripting/string_unpack.txt +5 -0
  70. data/data/tips/scripting/tcp_accept.txt +6 -0
  71. data/data/tips/scripting/tcp_banner.txt +5 -0
  72. data/data/tips/scripting/tcp_connect.txt +12 -0
  73. data/data/tips/scripting/tcp_open.txt +5 -0
  74. data/data/tips/scripting/tcp_send.txt +5 -0
  75. data/data/tips/scripting/tcp_server_loop.txt +6 -0
  76. data/data/tips/scripting/try.txt +4 -0
  77. data/data/tips/scripting/udp_connect.txt +8 -0
  78. data/data/tips/scripting/udp_open.txt +5 -0
  79. data/data/tips/scripting/udp_recv.txt +7 -0
  80. data/data/tips/scripting/udp_send.txt +5 -0
  81. data/data/tips/scripting/udp_server_loop.txt +7 -0
  82. data/data/tips/scripting/unix_accept.txt +7 -0
  83. data/data/tips/scripting/unix_connect.txt +12 -0
  84. data/data/tips/scripting/zlib_deflate.txt +5 -0
  85. data/data/tips/scripting/zlib_inflate.txt +5 -0
  86. data/gemspec.yml +73 -57
  87. data/lib/ronin/cli/char_set_options.rb +181 -0
  88. data/lib/ronin/cli/cipher_command.rb +149 -0
  89. data/lib/ronin/{script/exceptions/build_failed.rb → cli/command.rb} +11 -6
  90. data/lib/ronin/cli/commands/asn.rb +284 -0
  91. data/lib/ronin/cli/commands/banner_grab.rb +84 -0
  92. data/lib/ronin/cli/commands/bitflip.rb +132 -0
  93. data/lib/ronin/cli/commands/cert_dump.rb +285 -0
  94. data/lib/ronin/cli/commands/cert_gen.rb +395 -0
  95. data/lib/ronin/cli/commands/cert_grab.rb +128 -0
  96. data/lib/ronin/cli/commands/decode.rb +143 -0
  97. data/lib/ronin/cli/commands/decrypt.rb +67 -0
  98. data/lib/ronin/cli/commands/dns.rb +183 -0
  99. data/lib/ronin/cli/commands/email_addr.rb +127 -0
  100. data/lib/ronin/cli/commands/encode.rb +143 -0
  101. data/lib/ronin/cli/commands/encrypt.rb +67 -0
  102. data/lib/ronin/cli/commands/entropy.rb +75 -0
  103. data/lib/ronin/cli/commands/escape.rb +121 -0
  104. data/lib/ronin/cli/commands/extract.rb +138 -0
  105. data/lib/ronin/cli/commands/grep.rb +238 -0
  106. data/lib/ronin/cli/commands/hexdump.rb +475 -0
  107. data/lib/ronin/cli/commands/highlight.rb +121 -0
  108. data/lib/ronin/cli/commands/hmac.rb +102 -0
  109. data/lib/ronin/cli/commands/homoglyph.rb +98 -0
  110. data/lib/ronin/cli/commands/host.rb +305 -0
  111. data/lib/ronin/cli/commands/http.rb +354 -0
  112. data/lib/ronin/cli/commands/ip.rb +242 -0
  113. data/lib/ronin/cli/commands/iprange.rb +138 -0
  114. data/lib/ronin/cli/commands/irb.rb +106 -0
  115. data/lib/ronin/cli/commands/md5.rb +67 -0
  116. data/lib/ronin/cli/commands/netcat.rb +419 -0
  117. data/lib/ronin/cli/commands/new/project.rb +119 -0
  118. data/lib/ronin/cli/commands/new/script.rb +68 -0
  119. data/lib/ronin/cli/commands/new.rb +65 -0
  120. data/lib/ronin/cli/commands/proxy.rb +519 -0
  121. data/lib/ronin/cli/commands/public_suffix_list.rb +118 -0
  122. data/lib/ronin/cli/commands/quote.rb +114 -0
  123. data/lib/ronin/cli/commands/rot.rb +114 -0
  124. data/lib/ronin/cli/commands/sha1.rb +58 -0
  125. data/lib/ronin/cli/commands/sha256.rb +67 -0
  126. data/lib/ronin/cli/commands/sha512.rb +67 -0
  127. data/lib/ronin/cli/commands/strings.rb +151 -0
  128. data/lib/ronin/cli/commands/tips.rb +190 -0
  129. data/lib/ronin/cli/commands/tld_list.rb +118 -0
  130. data/lib/ronin/cli/commands/typo.rb +80 -0
  131. data/lib/ronin/cli/commands/typosquat.rb +123 -0
  132. data/lib/ronin/cli/commands/unescape.rb +121 -0
  133. data/lib/ronin/cli/commands/unhexdump.rb +213 -0
  134. data/lib/ronin/cli/commands/unquote.rb +114 -0
  135. data/lib/ronin/cli/commands/url.rb +151 -0
  136. data/lib/ronin/cli/commands/xor.rb +91 -0
  137. data/lib/ronin/cli/file_processor_command.rb +94 -0
  138. data/lib/ronin/cli/http_shell.rb +362 -0
  139. data/lib/ronin/cli/key_options.rb +61 -0
  140. data/lib/ronin/cli/method_options.rb +71 -0
  141. data/lib/ronin/cli/pattern_options.rb +343 -0
  142. data/lib/ronin/cli/printing/http.rb +153 -0
  143. data/lib/ronin/cli/printing/syntax_highlighting.rb +96 -0
  144. data/lib/ronin/{ui/cli/commands.rb → cli/string_methods_command.rb} +23 -12
  145. data/lib/ronin/cli/string_processor_command.rb +185 -0
  146. data/lib/ronin/cli/typo_options.rb +80 -0
  147. data/lib/ronin/cli/value_processor_command.rb +97 -0
  148. data/lib/ronin/cli.rb +70 -0
  149. data/lib/ronin/config.rb +2 -10
  150. data/lib/ronin/{database/exceptions/invalid_config.rb → root.rb} +6 -7
  151. data/lib/ronin/ui.rb +4 -4
  152. data/lib/ronin/version.rb +3 -4
  153. data/lib/ronin.rb +9 -5
  154. data/man/ronin-asn.1 +124 -0
  155. data/man/ronin-asn.1.md +86 -0
  156. data/man/ronin-banner-grab.1 +45 -0
  157. data/man/ronin-banner-grab.1.md +33 -0
  158. data/man/ronin-bitflip.1 +123 -0
  159. data/man/ronin-bitflip.1.md +92 -0
  160. data/man/ronin-cert-dump.1 +99 -0
  161. data/man/ronin-cert-dump.1.md +68 -0
  162. data/man/ronin-cert-gen.1 +144 -0
  163. data/man/ronin-cert-gen.1.md +104 -0
  164. data/man/ronin-cert-grab.1 +68 -0
  165. data/man/ronin-cert-grab.1.md +47 -0
  166. data/man/ronin-decode.1 +103 -0
  167. data/man/ronin-decode.1.md +77 -0
  168. data/man/ronin-decrypt.1 +75 -0
  169. data/man/ronin-decrypt.1.md +56 -0
  170. data/man/ronin-dns.1 +45 -0
  171. data/man/ronin-dns.1.md +33 -0
  172. data/man/ronin-email-addr.1 +76 -0
  173. data/man/ronin-email-addr.1.md +54 -0
  174. data/man/ronin-encode.1 +103 -0
  175. data/man/ronin-encode.1.md +77 -0
  176. data/man/ronin-encrypt.1 +75 -0
  177. data/man/ronin-encrypt.1.md +56 -0
  178. data/man/ronin-entropy.1 +43 -0
  179. data/man/ronin-entropy.1.md +32 -0
  180. data/man/ronin-escape.1 +94 -0
  181. data/man/ronin-escape.1.md +70 -0
  182. data/man/ronin-extract.1 +263 -0
  183. data/man/ronin-extract.1.md +197 -0
  184. data/man/ronin-grep.1 +275 -0
  185. data/man/ronin-grep.1.md +206 -0
  186. data/man/ronin-help.1 +3 -15
  187. data/man/ronin-help.1.md +3 -12
  188. data/man/ronin-hexdump.1 +323 -0
  189. data/man/ronin-hexdump.1.md +197 -0
  190. data/man/ronin-highlight.1 +42 -0
  191. data/man/ronin-highlight.1.md +31 -0
  192. data/man/ronin-hmac.1 +66 -0
  193. data/man/ronin-hmac.1.md +49 -0
  194. data/man/ronin-homoglyph.1 +49 -0
  195. data/man/ronin-homoglyph.1.md +36 -0
  196. data/man/ronin-host.1 +99 -0
  197. data/man/ronin-host.1.md +74 -0
  198. data/man/ronin-http.1 +141 -0
  199. data/man/ronin-http.1.md +105 -0
  200. data/man/ronin-ip.1 +145 -0
  201. data/man/ronin-ip.1.md +103 -0
  202. data/man/ronin-iprange.1 +46 -0
  203. data/man/ronin-iprange.1.md +34 -0
  204. data/man/ronin-irb.1 +35 -0
  205. data/man/ronin-irb.1.md +25 -0
  206. data/man/ronin-md5.1 +54 -0
  207. data/man/ronin-md5.1.md +40 -0
  208. data/man/ronin-netcat.1 +110 -0
  209. data/man/ronin-netcat.1.md +82 -0
  210. data/man/ronin-new-project.1 +54 -0
  211. data/man/ronin-new-project.1.md +40 -0
  212. data/man/ronin-new-script.1 +37 -0
  213. data/man/ronin-new-script.1.md +27 -0
  214. data/man/ronin-new.1 +51 -0
  215. data/man/ronin-new.1.md +38 -0
  216. data/man/{ronin-net-proxy.1 → ronin-proxy.1} +45 -37
  217. data/man/{ronin-net-proxy.1.md → ronin-proxy.1.md} +39 -32
  218. data/man/ronin-public-suffix-list.1 +55 -0
  219. data/man/ronin-public-suffix-list.1.md +41 -0
  220. data/man/ronin-quote.1 +78 -0
  221. data/man/ronin-quote.1.md +58 -0
  222. data/man/ronin-rot.1 +62 -0
  223. data/man/ronin-rot.1.md +46 -0
  224. data/man/ronin-sha1.1 +54 -0
  225. data/man/ronin-sha1.1.md +40 -0
  226. data/man/ronin-sha256.1 +54 -0
  227. data/man/ronin-sha256.1.md +40 -0
  228. data/man/ronin-sha512.1 +54 -0
  229. data/man/ronin-sha512.1.md +40 -0
  230. data/man/ronin-strings.1 +115 -0
  231. data/man/ronin-strings.1.md +86 -0
  232. data/man/ronin-tips.1 +35 -0
  233. data/man/ronin-tips.1.md +25 -0
  234. data/man/ronin-tld-list.1 +55 -0
  235. data/man/ronin-tld-list.1.md +41 -0
  236. data/man/ronin-typo.1 +61 -0
  237. data/man/ronin-typo.1.md +45 -0
  238. data/man/ronin-typosquat.1 +65 -0
  239. data/man/ronin-typosquat.1.md +48 -0
  240. data/man/ronin-unescape.1 +94 -0
  241. data/man/ronin-unescape.1.md +70 -0
  242. data/man/ronin-unhexdump.1 +187 -0
  243. data/man/ronin-unhexdump.1.md +107 -0
  244. data/man/ronin-unquote.1 +78 -0
  245. data/man/ronin-unquote.1.md +58 -0
  246. data/man/ronin-url.1 +85 -0
  247. data/man/ronin-url.1.md +63 -0
  248. data/man/ronin-xor.1 +62 -0
  249. data/man/ronin-xor.1.md +46 -0
  250. data/man/ronin.1 +25 -6
  251. data/man/ronin.1.md +20 -5
  252. data/ronin.gemspec +1 -1
  253. data/spec/cli/command_spec.rb +10 -0
  254. data/spec/cli/commands/decode_spec.rb +152 -0
  255. data/spec/cli/commands/encode_spec.rb +152 -0
  256. data/spec/cli/commands/escape_spec.rb +128 -0
  257. data/spec/cli/commands/quote_spec.rb +76 -0
  258. data/spec/cli/commands/unescape_spec.rb +128 -0
  259. data/spec/cli/commands/unquote_spec.rb +80 -0
  260. data/spec/cli/fixtures/file.txt +3 -0
  261. data/spec/cli/fixtures/file2.txt +3 -0
  262. data/spec/cli/key_options_spec.rb +56 -0
  263. data/spec/cli/method_options_spec.rb +71 -0
  264. data/spec/cli/string_methods_command_spec.rb +25 -0
  265. data/spec/cli/string_processor_command_spec.rb +258 -0
  266. data/spec/cli/value_processor_command_spec.rb +127 -0
  267. data/spec/spec_helper.rb +2 -57
  268. data/spec/version_spec.rb +11 -0
  269. metadata +301 -455
  270. data/bin/ronin-campaigns +0 -20
  271. data/bin/ronin-console +0 -20
  272. data/bin/ronin-creds +0 -20
  273. data/bin/ronin-database +0 -20
  274. data/bin/ronin-emails +0 -20
  275. data/bin/ronin-exec +0 -20
  276. data/bin/ronin-fuzzer +0 -20
  277. data/bin/ronin-help +0 -20
  278. data/bin/ronin-hosts +0 -20
  279. data/bin/ronin-install +0 -20
  280. data/bin/ronin-ips +0 -20
  281. data/bin/ronin-net-proxy +0 -20
  282. data/bin/ronin-repos +0 -20
  283. data/bin/ronin-uninstall +0 -20
  284. data/bin/ronin-update +0 -20
  285. data/bin/ronin-urls +0 -20
  286. data/bin/ronin-wordlist +0 -20
  287. data/lib/bond/completions/ronin.rb +0 -154
  288. data/lib/ronin/address.rb +0 -124
  289. data/lib/ronin/arch.rb +0 -136
  290. data/lib/ronin/author.rb +0 -66
  291. data/lib/ronin/auto_load.rb +0 -91
  292. data/lib/ronin/bootstrap.rb +0 -27
  293. data/lib/ronin/campaign.rb +0 -129
  294. data/lib/ronin/credential.rb +0 -119
  295. data/lib/ronin/database/database.rb +0 -325
  296. data/lib/ronin/database/exceptions/unknown_repository.rb +0 -25
  297. data/lib/ronin/database/exceptions.rb +0 -21
  298. data/lib/ronin/database/migrations/1.0.0.rb +0 -569
  299. data/lib/ronin/database/migrations/1.1.0.rb +0 -125
  300. data/lib/ronin/database/migrations/exceptions/duplicate_migration.rb +0 -29
  301. data/lib/ronin/database/migrations/exceptions/unknown_migration.rb +0 -27
  302. data/lib/ronin/database/migrations/exceptions.rb +0 -21
  303. data/lib/ronin/database/migrations/graph.rb +0 -300
  304. data/lib/ronin/database/migrations/migration.rb +0 -66
  305. data/lib/ronin/database/migrations/migrations.rb +0 -185
  306. data/lib/ronin/database/migrations.rb +0 -22
  307. data/lib/ronin/database.rb +0 -21
  308. data/lib/ronin/email_address.rb +0 -257
  309. data/lib/ronin/environment.rb +0 -30
  310. data/lib/ronin/exceptions/duplicate_repository.rb +0 -23
  311. data/lib/ronin/exceptions/repository_not_found.rb +0 -23
  312. data/lib/ronin/exceptions.rb +0 -21
  313. data/lib/ronin/host_name.rb +0 -271
  314. data/lib/ronin/host_name_ip_address.rb +0 -45
  315. data/lib/ronin/installation.rb +0 -225
  316. data/lib/ronin/ip_address.rb +0 -348
  317. data/lib/ronin/ip_address_mac_address.rb +0 -45
  318. data/lib/ronin/license.rb +0 -121
  319. data/lib/ronin/mac_address.rb +0 -111
  320. data/lib/ronin/model/has_authors.rb +0 -111
  321. data/lib/ronin/model/has_description.rb +0 -73
  322. data/lib/ronin/model/has_license.rb +0 -129
  323. data/lib/ronin/model/has_name.rb +0 -91
  324. data/lib/ronin/model/has_title.rb +0 -71
  325. data/lib/ronin/model/has_unique_name.rb +0 -127
  326. data/lib/ronin/model/has_version.rb +0 -77
  327. data/lib/ronin/model/importable.rb +0 -65
  328. data/lib/ronin/model/model.rb +0 -165
  329. data/lib/ronin/model/types/description.rb +0 -60
  330. data/lib/ronin/model/types.rb +0 -20
  331. data/lib/ronin/model.rb +0 -20
  332. data/lib/ronin/open_port.rb +0 -112
  333. data/lib/ronin/organization.rb +0 -46
  334. data/lib/ronin/os.rb +0 -157
  335. data/lib/ronin/os_guess.rb +0 -45
  336. data/lib/ronin/password.rb +0 -165
  337. data/lib/ronin/port.rb +0 -126
  338. data/lib/ronin/repositories.rb +0 -23
  339. data/lib/ronin/repository.rb +0 -771
  340. data/lib/ronin/ronin.rb +0 -43
  341. data/lib/ronin/script/buildable.rb +0 -156
  342. data/lib/ronin/script/deployable.rb +0 -202
  343. data/lib/ronin/script/exceptions/deploy_failed.rb +0 -27
  344. data/lib/ronin/script/exceptions/exception.rb +0 -25
  345. data/lib/ronin/script/exceptions/not_built.rb +0 -27
  346. data/lib/ronin/script/exceptions/test_failed.rb +0 -27
  347. data/lib/ronin/script/exceptions.rb +0 -24
  348. data/lib/ronin/script/path.rb +0 -293
  349. data/lib/ronin/script/script.rb +0 -384
  350. data/lib/ronin/script/testable.rb +0 -365
  351. data/lib/ronin/script.rb +0 -21
  352. data/lib/ronin/service.rb +0 -39
  353. data/lib/ronin/service_credential.rb +0 -31
  354. data/lib/ronin/software.rb +0 -55
  355. data/lib/ronin/spec/database.rb +0 -56
  356. data/lib/ronin/target.rb +0 -66
  357. data/lib/ronin/tcp_port.rb +0 -36
  358. data/lib/ronin/udp_port.rb +0 -32
  359. data/lib/ronin/ui/cli/class_command.rb +0 -137
  360. data/lib/ronin/ui/cli/cli.rb +0 -148
  361. data/lib/ronin/ui/cli/command.rb +0 -649
  362. data/lib/ronin/ui/cli/commands/campaigns.rb +0 -165
  363. data/lib/ronin/ui/cli/commands/console.rb +0 -106
  364. data/lib/ronin/ui/cli/commands/creds.rb +0 -108
  365. data/lib/ronin/ui/cli/commands/database.rb +0 -204
  366. data/lib/ronin/ui/cli/commands/emails.rb +0 -86
  367. data/lib/ronin/ui/cli/commands/exec.rb +0 -127
  368. data/lib/ronin/ui/cli/commands/fuzzer.rb +0 -306
  369. data/lib/ronin/ui/cli/commands/help.rb +0 -87
  370. data/lib/ronin/ui/cli/commands/hosts.rb +0 -177
  371. data/lib/ronin/ui/cli/commands/install.rb +0 -136
  372. data/lib/ronin/ui/cli/commands/ips.rb +0 -178
  373. data/lib/ronin/ui/cli/commands/net/proxy.rb +0 -411
  374. data/lib/ronin/ui/cli/commands/repos.rb +0 -164
  375. data/lib/ronin/ui/cli/commands/uninstall.rb +0 -90
  376. data/lib/ronin/ui/cli/commands/update.rb +0 -125
  377. data/lib/ronin/ui/cli/commands/urls.rb +0 -141
  378. data/lib/ronin/ui/cli/commands/wordlist.rb +0 -181
  379. data/lib/ronin/ui/cli/exceptions/unknown_command.rb +0 -27
  380. data/lib/ronin/ui/cli/exceptions.rb +0 -20
  381. data/lib/ronin/ui/cli/model_command.rb +0 -182
  382. data/lib/ronin/ui/cli/printing.rb +0 -167
  383. data/lib/ronin/ui/cli/resources_command.rb +0 -117
  384. data/lib/ronin/ui/cli/script_command.rb +0 -212
  385. data/lib/ronin/ui/cli.rb +0 -21
  386. data/lib/ronin/ui/console/commands.rb +0 -86
  387. data/lib/ronin/ui/console/console.rb +0 -215
  388. data/lib/ronin/ui/console/context.rb +0 -106
  389. data/lib/ronin/ui/console/shell.rb +0 -184
  390. data/lib/ronin/ui/console.rb +0 -22
  391. data/lib/ronin/url.rb +0 -546
  392. data/lib/ronin/url_query_param.rb +0 -73
  393. data/lib/ronin/url_query_param_name.rb +0 -89
  394. data/lib/ronin/url_scheme.rb +0 -53
  395. data/lib/ronin/user_name.rb +0 -47
  396. data/lib/ronin/vendor.rb +0 -39
  397. data/lib/ronin/web_credential.rb +0 -76
  398. data/man/ronin-campaigns.1 +0 -105
  399. data/man/ronin-campaigns.1.md +0 -78
  400. data/man/ronin-console.1 +0 -96
  401. data/man/ronin-console.1.md +0 -72
  402. data/man/ronin-creds.1 +0 -89
  403. data/man/ronin-creds.1.md +0 -66
  404. data/man/ronin-database.1 +0 -111
  405. data/man/ronin-database.1.md +0 -82
  406. data/man/ronin-emails.1 +0 -97
  407. data/man/ronin-emails.1.md +0 -72
  408. data/man/ronin-exec.1 +0 -65
  409. data/man/ronin-exec.1.md +0 -49
  410. data/man/ronin-fuzzer.1 +0 -95
  411. data/man/ronin-fuzzer.1.md +0 -73
  412. data/man/ronin-hosts.1 +0 -105
  413. data/man/ronin-hosts.1.md +0 -78
  414. data/man/ronin-install.1 +0 -104
  415. data/man/ronin-install.1.md +0 -79
  416. data/man/ronin-ips.1 +0 -109
  417. data/man/ronin-ips.1.md +0 -81
  418. data/man/ronin-repos.1 +0 -102
  419. data/man/ronin-repos.1.md +0 -77
  420. data/man/ronin-uninstall.1 +0 -88
  421. data/man/ronin-uninstall.1.md +0 -67
  422. data/man/ronin-update.1 +0 -88
  423. data/man/ronin-update.1.md +0 -67
  424. data/man/ronin-urls.1 +0 -113
  425. data/man/ronin-urls.1.md +0 -84
  426. data/man/ronin-wordlist.1 +0 -71
  427. data/man/ronin-wordlist.1.md +0 -54
  428. data/spec/arch_spec.rb +0 -77
  429. data/spec/author_spec.rb +0 -26
  430. data/spec/campaign_spec.rb +0 -13
  431. data/spec/classes/my_script.rb +0 -21
  432. data/spec/credential_spec.rb +0 -29
  433. data/spec/database_spec.rb +0 -28
  434. data/spec/email_address_spec.rb +0 -83
  435. data/spec/helpers/repos/installed/ronin.yml +0 -7
  436. data/spec/helpers/repos/installed/scripts/.keep +0 -0
  437. data/spec/helpers/repos/local/lib/init.rb +0 -1
  438. data/spec/helpers/repos/local/lib/stuff/another_test.rb +0 -6
  439. data/spec/helpers/repos/local/lib/stuff/test.rb +0 -4
  440. data/spec/helpers/repos/local/ronin.yml +0 -7
  441. data/spec/helpers/repos/local/scripts/.keep +0 -0
  442. data/spec/helpers/repos/remote/ronin.yml +0 -7
  443. data/spec/helpers/repos/remote/scripts/.keep +0 -0
  444. data/spec/helpers/repos/scripts/ronin.yml +0 -7
  445. data/spec/helpers/repos/scripts/scripts/cached/cached.rb +0 -10
  446. data/spec/helpers/repos/scripts/scripts/cached/missing.rb +0 -10
  447. data/spec/helpers/repos/scripts/scripts/cached/modified.rb +0 -10
  448. data/spec/helpers/repos/scripts/scripts/cached/unmodified.rb +0 -10
  449. data/spec/helpers/repos/scripts/scripts/failures/exceptions.rb +0 -11
  450. data/spec/helpers/repos/scripts/scripts/failures/load_errors.rb +0 -11
  451. data/spec/helpers/repos/scripts/scripts/failures/name_errors.rb +0 -8
  452. data/spec/helpers/repos/scripts/scripts/failures/no_method_errors.rb +0 -10
  453. data/spec/helpers/repos/scripts/scripts/failures/syntax_errors.rb +0 -11
  454. data/spec/helpers/repos/scripts/scripts/failures/validation_errors.rb +0 -11
  455. data/spec/helpers/repos/scripts/scripts/my_scripts/test.rb +0 -16
  456. data/spec/helpers/repositories.rb +0 -11
  457. data/spec/host_name_spec.rb +0 -92
  458. data/spec/installation_spec.rb +0 -40
  459. data/spec/ip_address_spec.rb +0 -109
  460. data/spec/license_spec.rb +0 -25
  461. data/spec/mac_address_spec.rb +0 -47
  462. data/spec/model/has_authors_spec.rb +0 -79
  463. data/spec/model/has_description_spec.rb +0 -76
  464. data/spec/model/has_license_spec.rb +0 -73
  465. data/spec/model/has_name_spec.rb +0 -54
  466. data/spec/model/has_title_spec.rb +0 -42
  467. data/spec/model/has_version_spec.rb +0 -87
  468. data/spec/model/model_spec.rb +0 -98
  469. data/spec/model/models/authored_model.rb +0 -11
  470. data/spec/model/models/base_model.rb +0 -13
  471. data/spec/model/models/described_model.rb +0 -9
  472. data/spec/model/models/inherited_model.rb +0 -16
  473. data/spec/model/models/licensed_model.rb +0 -11
  474. data/spec/model/models/named_model.rb +0 -9
  475. data/spec/model/models/titled_model.rb +0 -9
  476. data/spec/model/models/versioned_model.rb +0 -11
  477. data/spec/os_spec.rb +0 -48
  478. data/spec/password_spec.rb +0 -47
  479. data/spec/port_spec.rb +0 -51
  480. data/spec/repository_spec.rb +0 -270
  481. data/spec/ronin_spec.rb +0 -25
  482. data/spec/script/buildable_spec.rb +0 -51
  483. data/spec/script/classes/buildable_class.rb +0 -15
  484. data/spec/script/classes/deployable_class.rb +0 -13
  485. data/spec/script/classes/script_class.rb +0 -19
  486. data/spec/script/classes/testable_class.rb +0 -19
  487. data/spec/script/deployable_spec.rb +0 -55
  488. data/spec/script/path_spec.rb +0 -185
  489. data/spec/script/script_spec.rb +0 -128
  490. data/spec/script/testable_spec.rb +0 -117
  491. data/spec/service_spec.rb +0 -24
  492. data/spec/software_spec.rb +0 -46
  493. data/spec/ui/cli/classes/test_command.rb +0 -26
  494. data/spec/ui/cli/cli_spec.rb +0 -34
  495. data/spec/ui/cli/command_spec.rb +0 -291
  496. data/spec/url_query_param_spec.rb +0 -41
  497. data/spec/url_scheme_spec.rb +0 -21
  498. data/spec/url_spec.rb +0 -179
  499. data/spec/vendor_spec.rb +0 -25
@@ -0,0 +1,475 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
4
+ #
5
+ # Ronin is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Ronin is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with Ronin. If not, see <https://www.gnu.org/licenses/>.
17
+ #
18
+
19
+ require 'ronin/cli/file_processor_command'
20
+
21
+ require 'hexdump'
22
+
23
+ module Ronin
24
+ class CLI
25
+ module Commands
26
+ #
27
+ # Hexdumps data in a variety of encodings and formats.
28
+ #
29
+ # ## Usage
30
+ #
31
+ # ronin hexdump [options] [FILE ...]
32
+ #
33
+ # ## Options
34
+ #
35
+ # -t int8|uint8|char|uchar|byte|int16|int16_le|int16_be|int16_ne|uint16|uint16_le|uint16_be|uint16_ne|short|short_le|short_be|short_ne|ushort|ushort_le|ushort_be|ushort_ne|int32|int32_le|int32_be|int32_ne|uint32|uint32_le|uint32_be|uint32_ne|int|long|long_le|long_be|long_ne|uint|ulong|ulong_le|ulong_be|ulong_ne|int64|int64_le|int64_be|int64_ne|uint64|uint64_le|uint64_be|uint64_ne|long_long|long_long_le|long_long_be|long_long_ne|ulong_long|ulong_long_le|ulong_long_be|ulong_long_ne|float|float_le|float_be|float_ne|double|double_le|double_be|double_ne,
36
+ # --type The binary data type to decode the data as (Default: byte)
37
+ # -O, --offset INDEX Offset within the data to start hexdumping at
38
+ # -L, --length LEN Length of data to hexdump
39
+ # -Z, --zero-pad Enables zero-padding the input data
40
+ # -c, --columns WIDTH The number of bytes to hexdump per line
41
+ # -g, --group-columns WIDTH Groups columns together
42
+ # -G, --group-chars WIDTH|type Group characters into columns
43
+ # -r, --[no-]repeating Allows repeating lines in hexdump output
44
+ # -b, --base 2|8|10|16 Base to print numbers in
45
+ # -B, --index-base 2|8|10|16 Base to print the index addresses in
46
+ # -I, --index-offset INT Starting number for the index addresses
47
+ # -C, --[no-]chars-column Enables/disables the characters column
48
+ # -E, --encoding ascii|utf8 Encoding to display the characters in (Default: ascii)
49
+ # --style-index STYLE ANSI styles the index column
50
+ # --style-numeric STYLE ANSI styles the numeric columns
51
+ # --style-chars STYLE ANSI styles the characters column
52
+ # --highlight-index PATTERN:STYLE
53
+ # Applies ANSI highlighting to the index column
54
+ # --highlight-numeric PATTERN:STYLE
55
+ # Applies ANSI highlighting to the numeric column
56
+ # --highlight-chars PATTERN:STYLE
57
+ # Applies ANSI highlighting to the characters column
58
+ # -h, --help Print help information
59
+ #
60
+ # ## Arguments
61
+ #
62
+ # [FILE] Optional file to hexdump
63
+ #
64
+ class Hexdump < FileProcessorCommand
65
+
66
+ # Supported types for the `-t,--type` option.
67
+ TYPES = [
68
+ :int8,
69
+ :uint8,
70
+ :char,
71
+ :uchar,
72
+ :byte, # default
73
+ :int16,
74
+ :int16_le,
75
+ :int16_be,
76
+ :int16_ne,
77
+ :uint16,
78
+ :uint16_le,
79
+ :uint16_be,
80
+ :uint16_ne,
81
+ :short,
82
+ :short_le,
83
+ :short_be,
84
+ :short_ne,
85
+ :ushort,
86
+ :ushort_le,
87
+ :ushort_be,
88
+ :ushort_ne,
89
+ :int32,
90
+ :int32_le,
91
+ :int32_be,
92
+ :int32_ne,
93
+ :uint32,
94
+ :uint32_le,
95
+ :uint32_be,
96
+ :uint32_ne,
97
+ :int,
98
+ :long,
99
+ :long_le,
100
+ :long_be,
101
+ :long_ne,
102
+ :uint,
103
+ :ulong,
104
+ :ulong_le,
105
+ :ulong_be,
106
+ :ulong_ne,
107
+ :int64,
108
+ :int64_le,
109
+ :int64_be,
110
+ :int64_ne,
111
+ :uint64,
112
+ :uint64_le,
113
+ :uint64_be,
114
+ :uint64_ne,
115
+ :long_long,
116
+ :long_long_le,
117
+ :long_long_be,
118
+ :long_long_ne,
119
+ :ulong_long,
120
+ :ulong_long_le,
121
+ :ulong_long_be,
122
+ :ulong_long_ne,
123
+ :float,
124
+ :float_le,
125
+ :float_be,
126
+ :float_ne,
127
+ :double,
128
+ :double_le,
129
+ :double_be,
130
+ :double_ne
131
+ ]
132
+
133
+ usage '[options] [FILE]'
134
+
135
+ option :type, short: '-t',
136
+ value: {
137
+ type: TYPES,
138
+ default: :byte
139
+ },
140
+ desc: 'The binary data type to decode the data as'
141
+
142
+ option :offset, short: '-O',
143
+ value: {
144
+ type: Integer,
145
+ usage: 'INDEX'
146
+ },
147
+ desc: 'Offset within the data to start hexdumping at'
148
+
149
+ option :length, short: '-L',
150
+ value: {
151
+ type: Integer,
152
+ usage: 'LEN',
153
+ },
154
+ desc: 'Length of data to hexdump'
155
+
156
+ option :zero_pad, short: '-Z',
157
+ desc: 'Enables zero-padding the input data'
158
+
159
+ option :columns, short: '-c',
160
+ value: {
161
+ type: Integer,
162
+ usage: 'WIDTH'
163
+ },
164
+ desc: 'The number of bytes to hexdump per line'
165
+
166
+ option :group_columns, short: '-g',
167
+ value: {
168
+ type: Integer,
169
+ usage: 'WIDTH'
170
+ },
171
+ desc: 'Groups columns together'
172
+
173
+ option :group_chars, short: '-G',
174
+ value: {usage: 'WIDTH|type'},
175
+ desc: 'Group characters into columns' do |value|
176
+ options[:group_chars] = parse_group_chars(value)
177
+ end
178
+
179
+ option :repeating, short: '-r',
180
+ long: '--[no-]repeating',
181
+ desc: 'Allows repeating lines in hexdump output'
182
+
183
+ # Mapping of supported values for the `-b,--base` option.
184
+ BASES = {'2' => 2, '8' => 8, '10' => 10, '16' => 16}
185
+
186
+ option :base, short: '-b',
187
+ value: {type: BASES},
188
+ desc: 'Base to print numbers in'
189
+
190
+ option :index_base, short: '-B',
191
+ value: {type: BASES},
192
+ desc: 'Base to print the index addresses in'
193
+
194
+ option :index_offset, short: '-I',
195
+ value: {type: Integer},
196
+ desc: 'Starting number for the index addresses'
197
+
198
+ option :chars_column, short: '-C',
199
+ long: '--[no-]chars-column',
200
+ desc: 'Enables/disables the characters column'
201
+
202
+ option :encoding, short: '-E',
203
+ value: {
204
+ type: [:ascii, :utf8],
205
+ default: :ascii
206
+ },
207
+ desc: 'Encoding to display the characters in'
208
+
209
+ option :style_index, value: {usage: 'STYLE'},
210
+ desc: 'ANSI styles the index column' do |value|
211
+ options[:style_index] = parse_style(value)
212
+ end
213
+
214
+ option :style_numeric, value: {usage: 'STYLE'},
215
+ desc: 'ANSI styles the numeric columns' do |value|
216
+ options[:style_numeric] = parse_style(value)
217
+ end
218
+
219
+ option :style_chars, value: {usage: 'STYLE'},
220
+ desc: 'ANSI styles the characts column' do |value|
221
+ options[:style_chars] = parse_style(value)
222
+ end
223
+
224
+ option :highlight_index, value: {usage: 'PATTERN:STYLE'},
225
+ desc: 'Applies ANSI highlighting to the index column' do |value|
226
+ pattern, style = parse_highlight(value)
227
+
228
+ @highlight_index[pattern] = style
229
+ end
230
+
231
+ option :highlight_numeric, value: {usage: 'PATTERN:STYLE'},
232
+ desc: 'Applies ANSI highlighting to the numeric column' do |value|
233
+ pattern, style = parse_highlight(value)
234
+
235
+ @highlight_numeric[pattern] = style
236
+ end
237
+
238
+ option :highlight_chars, value: {usage: 'PATTERN:STYLE'},
239
+ desc: 'Applies ANSI highlighting to the characters column' do |value|
240
+ pattern, style = parse_highlight(value)
241
+
242
+ @highlight_chars[pattern] = style
243
+ end
244
+
245
+ description 'Hexdumps data in a variaty of encodings and formats'
246
+
247
+ man_page 'ronin-hexdump.1'
248
+
249
+ # The highlighting rules to apply to the index column.
250
+ #
251
+ # @return [Array<(Regexp, Array<Symbol>)>,
252
+ # Array<(String, Array<Symbol>)>]
253
+ attr_reader :highlight_index
254
+
255
+ # The highlighting rules to apply to the numeric column.
256
+ #
257
+ # @return [Array<(Regexp, Array<Symbol>)>,
258
+ # Array<(String, Array<Symbol>)>]
259
+ attr_reader :highlight_numeric
260
+
261
+ # The highlighting rules to apply to the characters column.
262
+ #
263
+ # @return [Array<(Regexp, Array<Symbol>)>,
264
+ # Array<(String, Array<Symbol>)>]
265
+ attr_reader :highlight_chars
266
+
267
+ #
268
+ # Initializes the `hexdump` command.
269
+ #
270
+ def initialize(**kwargs)
271
+ super(**kwargs)
272
+
273
+ @highlight_index = {}
274
+ @highlight_numeric = {}
275
+ @highlight_chars = {}
276
+ end
277
+
278
+ def run(*files)
279
+ @hexdump = ::Hexdump::Hexdump.new(**hexdump_options)
280
+
281
+ super(*files)
282
+ end
283
+
284
+ #
285
+ # Opens the file in binary mode.
286
+ #
287
+ # @yield [file]
288
+ # If a block is given, the newly opened file will be yielded.
289
+ # Once the block returns the file will automatically be closed.
290
+ #
291
+ # @yieldparam [File] file
292
+ # The newly opened file.
293
+ #
294
+ # @return [File, nil]
295
+ # If no block is given, the newly opened file object will be returned.
296
+ # If no block was given, then `nil` will be returned.
297
+ #
298
+ def open_file(file,&block)
299
+ File.open(file,'rb',&block)
300
+ end
301
+
302
+ #
303
+ # Hexdumps the input stream.
304
+ #
305
+ # @param [IO, StringIO] input
306
+ # The input stream to hexdump.
307
+ #
308
+ def process_input(input)
309
+ @hexdump.hexdump(input)
310
+ end
311
+
312
+ #
313
+ # Parses the value passed to the `-G,--group-chars` option.
314
+ #
315
+ # @param [String] value
316
+ # The `-G,--group-chars` argument value.
317
+ #
318
+ # @return [Integer, :type]
319
+ # The parsed integer or `:type` if the `type` argument was given.
320
+ #
321
+ def parse_group_chars(value)
322
+ case value
323
+ when 'type' then :type
324
+ when /^\d+$/ then value.to_i
325
+ else
326
+ raise(OptionParser::InvalidArgument,"invalid value: #{value}")
327
+ end
328
+ end
329
+
330
+ # Mapping of style names to Symbols.
331
+ STYLES = {
332
+ # font styling
333
+ 'bold' => :bold,
334
+ 'faint' => :faint,
335
+ 'italic' => :italic,
336
+ 'underline' => :underline,
337
+ 'invert' => :invert,
338
+ 'strike' => :strike,
339
+
340
+ # foreground colors
341
+ 'black' => :black,
342
+ 'red' => :red,
343
+ 'green' => :green,
344
+ 'yellow' => :yellow,
345
+ 'blue' => :blue,
346
+ 'magenta' => :magenta,
347
+ 'cyan' => :cyan,
348
+ 'white' => :white,
349
+
350
+ # background colors
351
+ 'on_black' => :on_black,
352
+ 'on_red' => :on_red,
353
+ 'on_green' => :on_green,
354
+ 'on_yellow' => :on_yellow,
355
+ 'on_blue' => :on_blue,
356
+ 'on_magenta' => :on_magenta,
357
+ 'on_cyan' => :on_cyan,
358
+ 'on_white' => :on_white
359
+ }
360
+
361
+ #
362
+ # Parses a style string.
363
+ #
364
+ # @param [String] value
365
+ # The comma-separated list of style names.
366
+ #
367
+ # @return [Array<Symbol>]
368
+ # The array of parsed style names.
369
+ #
370
+ def parse_style(value)
371
+ value.split(/\s*,\s*/).map do |style_name|
372
+ STYLES.fetch(style_name) do
373
+ raise(OptionParser::InvalidArgument,"unknown style name: #{style_name}")
374
+ end
375
+ end
376
+ end
377
+
378
+ #
379
+ # Parses a highlight rule of the form `/REGEXP/:STYLE` or
380
+ # `STRING:STYLE`.
381
+ #
382
+ # @param [String] value
383
+ # The raw string value to parse.
384
+ #
385
+ # @return [(Regexp, Array<Symbol>), (String, Array<Symbol>)]
386
+ # The Regexp or String pattern to match and the style rules to apply
387
+ # to it.
388
+ #
389
+ def parse_highlight(value)
390
+ if value.start_with?('/')
391
+ unless (index = value.rindex('/:'))
392
+ raise(OptionParser::InvalidArgument,"argument must be of the form /REGEXP/:STYLE but was: #{value}")
393
+ end
394
+
395
+ regexp = Regexp.new(value[1...index])
396
+ style = parse_style(value[index+2..])
397
+
398
+ return [regexp, style]
399
+ else
400
+ unless (index = value.rindex(':'))
401
+ raise(OptionParser::InvalidArgument,"argument must be of the form STRING:STYLE but was: #{value}")
402
+ end
403
+
404
+ pattern = value[0...index]
405
+ style = parse_style(value[index+1..])
406
+
407
+ return [pattern, style]
408
+ end
409
+ end
410
+
411
+ # List of command `options` that directly map to the keyword arguments
412
+ # of `Hexdump.hexdump`.
413
+ HEXDUMP_OPTIONS = [
414
+ :format,
415
+ :offset,
416
+ :length,
417
+ :zero_pad,
418
+ :columns,
419
+ :group_columns,
420
+ :group_chars,
421
+ :repeating,
422
+ :base,
423
+ :index_base,
424
+ :index_offset,
425
+ :chars_column,
426
+ :encoding
427
+ ]
428
+
429
+ #
430
+ # Creates a keyword arguments `Hash` of all command `options` that will
431
+ # be directly passed to `Hexdump.hexdump`.
432
+ #
433
+ # @return [Hash{Symbol => Object}]
434
+ #
435
+ def hexdump_options
436
+ kwargs = {}
437
+
438
+ HEXDUMP_OPTIONS.each do |key|
439
+ kwargs[key] = options[key] if options.has_key?(key)
440
+ end
441
+
442
+ if (index_style = options[:style_index]) ||
443
+ (numeric_style = options[:style_numeric]) ||
444
+ (chars_style = options[:style_chars])
445
+ kwargs[:style] = {}
446
+ kwargs[:style][:index] = index_style if index_style
447
+ kwargs[:style][:numeric] = numeric_style if numeric_style
448
+ kwargs[:style][:chars] = chars_style if chars_style
449
+ end
450
+
451
+ if !@highlight_index.empty? ||
452
+ !@highlight_numeric.empty? ||
453
+ !@highlight_chars.empty?
454
+ kwargs[:highlights] = {}
455
+
456
+ unless @highlight_index.empty?
457
+ kwargs[:highlights][:index] = @highlight_index
458
+ end
459
+
460
+ unless @highlight_numeric.empty?
461
+ kwargs[:highlights][:numeric] = @highlight_numeric
462
+ end
463
+
464
+ unless @highlight_chars.empty?
465
+ kwargs[:highlights][:chars] = @highlight_chars
466
+ end
467
+ end
468
+
469
+ return kwargs
470
+ end
471
+
472
+ end
473
+ end
474
+ end
475
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
4
+ #
5
+ # Ronin is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Ronin is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with Ronin. If not, see <https://www.gnu.org/licenses/>.
17
+ #
18
+
19
+ require 'ronin/cli/file_processor_command'
20
+ require 'ronin/cli/printing/syntax_highlighting'
21
+
22
+ require 'command_kit/pager'
23
+
24
+ module Ronin
25
+ class CLI
26
+ module Commands
27
+ #
28
+ # Syntax highlights a file(s).
29
+ #
30
+ # ## Usage
31
+ #
32
+ # ronin highlight [options] [FILES ...]
33
+ #
34
+ # ## Options
35
+ #
36
+ # -s, --syntax Specifies the syntax to highlight
37
+ # -L, --less Display the output in a pager
38
+ # -h, --help Print help information
39
+ #
40
+ # ## Arguments
41
+ #
42
+ # [FILE ...] Option file(s) to process
43
+ #
44
+ class Highlight < FileProcessorCommand
45
+
46
+ include Printing::SyntaxHighlighting
47
+ include CommandKit::Pager
48
+
49
+ usage '[options] [FILE ...]'
50
+
51
+ option :syntax, short: '-s',
52
+ desc: 'Specifies the syntax to highlight' do |syntax|
53
+ unless (lexer = syntax_lexer(options[:syntax]))
54
+ raise(OptionParser::InvalidArgument,"unknown syntax: #{options[:syntax]}")
55
+ end
56
+
57
+ @syntax_lexer = lexer.new
58
+ end
59
+
60
+ option :less, short: '-L',
61
+ desc: 'Display the output in a pager'
62
+
63
+ description 'Syntax highlights file(s).'
64
+
65
+ man_page 'ronin-highlight.1'
66
+
67
+ #
68
+ # Indicates that ANSI mode is always enabled.
69
+ #
70
+ # @return [true]
71
+ #
72
+ def ansi?
73
+ true
74
+ end
75
+
76
+ #
77
+ # Syntax highlights a file.
78
+ #
79
+ # @param [String] file
80
+ #
81
+ def process_file(file)
82
+ @syntax_lexer ||= syntax_lexer_for(filename: file)
83
+
84
+ super(file)
85
+ end
86
+
87
+ #
88
+ # Syntax highlights an input strema.
89
+ #
90
+ # @param [File, IO] input
91
+ # The input file or `stdin`.
92
+ #
93
+ def process_input(input)
94
+ if options[:less]
95
+ pager do |less|
96
+ syntax_highlight(input, output: less)
97
+ end
98
+ else
99
+ syntax_highlight(input)
100
+ end
101
+ end
102
+
103
+ #
104
+ # Syntax highlights the input stream and prints to the output stream.
105
+ #
106
+ # @param [File, IO] input
107
+ # The input file or `stdin`.
108
+ #
109
+ # @param [IO] output
110
+ # The `less` output stream or `stdout`.
111
+ #
112
+ def syntax_highlight(input, output: stdout)
113
+ input.each_line do |line|
114
+ output.print(@syntax_formatter.format(@syntax_lexer.lex(line)))
115
+ end
116
+ end
117
+
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
4
+ #
5
+ # Ronin is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Ronin is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with Ronin. If not, see <https://www.gnu.org/licenses/>.
17
+ #
18
+
19
+ require 'ronin/cli/string_processor_command'
20
+ require 'ronin/cli/key_options'
21
+
22
+ require 'ronin/support/crypto'
23
+
24
+ module Ronin
25
+ class CLI
26
+ module Commands
27
+ #
28
+ # Calculates a [Hash-based Message Authentication Code (HMAC)][HMAC] for
29
+ # data.
30
+ #
31
+ # [HMAC]: https://en.wikipedia.org/wiki/HMAC
32
+ #
33
+ # ## Usage
34
+ #
35
+ # ronin hmac [options] [FILE ...]
36
+ #
37
+ # ## Options
38
+ #
39
+ # -f, --file FILE Optional file to process
40
+ # --string STRING Optional string to process
41
+ # -M, --multiline Process each line separately
42
+ # -n, --keep-newlines Preserves newlines at the end of each line
43
+ # -H md5|sha1|sha256|sha512, Hash algorithm to use (Default: sha1)
44
+ # --hash
45
+ # -k, --key STRING The key String
46
+ # -K, --key-file FILE The key file
47
+ # -h, --help Print help information
48
+ #
49
+ # ## Arguments
50
+ #
51
+ # [FILE ...] Optional file(s) to process
52
+ #
53
+ class Hmac < StringProcessorCommand
54
+
55
+ include KeyOptions
56
+
57
+ option :hash, short: '-H',
58
+ value: {
59
+ type: [:md5, :sha1, :sha256, :sha512],
60
+ default: :sha1,
61
+ },
62
+ desc: 'Hash algorithm to use'
63
+
64
+ description "Calculates a Hash-based Message Authentication Code (HMAC)"
65
+
66
+ man_page 'ronin-hmac.1'
67
+
68
+ #
69
+ # Runs the `ronin hmac` command.
70
+ #
71
+ # @param [Array<String>] files
72
+ # Additional files to process.
73
+ #
74
+ def run(*files)
75
+ unless @key
76
+ print_error "must specify --key or --key-file"
77
+ exit(-1)
78
+ end
79
+
80
+ super(*files)
81
+ end
82
+
83
+ #
84
+ # Calculates the Hash-based Message Authentication Code (HMAC) for the
85
+ # given string.
86
+ #
87
+ # @param [String] string
88
+ # The input string.
89
+ #
90
+ # @return [String]
91
+ # The HMAC string.
92
+ #
93
+ def process_string(string)
94
+ hmac = Support::Crypto.hmac(string, key: self.key,
95
+ digest: options[:hash])
96
+ hmac.hexdigest
97
+ end
98
+
99
+ end
100
+ end
101
+ end
102
+ end