ronin 0.3.0 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (465) hide show
  1. data/.document +4 -0
  2. data/.rspec +1 -0
  3. data/.yardopts +5 -0
  4. data/{History.txt → ChangeLog.md} +15 -15
  5. data/Gemfile +42 -0
  6. data/README.md +224 -0
  7. data/Rakefile +65 -33
  8. data/bin/ronin +18 -5
  9. data/bin/ronin-campaigns +25 -0
  10. data/bin/ronin-console +18 -5
  11. data/bin/ronin-creds +25 -0
  12. data/bin/ronin-database +25 -0
  13. data/bin/ronin-emails +25 -0
  14. data/bin/ronin-exec +25 -0
  15. data/bin/ronin-help +18 -5
  16. data/bin/ronin-hosts +25 -0
  17. data/bin/ronin-ips +25 -0
  18. data/bin/ronin-repos +25 -0
  19. data/bin/ronin-urls +25 -0
  20. data/gemspec.yml +71 -0
  21. data/lib/ronin/address.rb +93 -0
  22. data/lib/ronin/arch.rb +30 -25
  23. data/lib/ronin/author.rb +12 -42
  24. data/lib/ronin/bootstrap.rb +26 -0
  25. data/lib/ronin/cached_file.rb +249 -0
  26. data/lib/ronin/campaign.rb +130 -0
  27. data/lib/ronin/class_methods.rb +27 -0
  28. data/lib/ronin/config.rb +23 -17
  29. data/lib/ronin/credential.rb +114 -0
  30. data/lib/ronin/database/database.rb +180 -52
  31. data/lib/ronin/database/exceptions/invalid_config.rb +2 -2
  32. data/lib/ronin/{platform/exceptions/extension_not_found.rb → database/exceptions/unknown_repository.rb} +3 -3
  33. data/lib/ronin/database/exceptions.rb +2 -1
  34. data/lib/ronin/database/migrations/create_addresses_table.rb +52 -0
  35. data/lib/ronin/database/migrations/create_arches_table.rb +44 -0
  36. data/lib/ronin/database/migrations/create_authors_table.rb +47 -0
  37. data/lib/ronin/database/migrations/create_cached_files_table.rb +47 -0
  38. data/lib/ronin/database/migrations/create_campaigns_table.rb +42 -0
  39. data/lib/ronin/database/migrations/create_countries_table.rb +44 -0
  40. data/lib/ronin/database/migrations/create_credentials_table.rb +59 -0
  41. data/lib/ronin/database/migrations/create_email_addresses_table.rb +51 -0
  42. data/lib/ronin/database/migrations/create_host_name_ip_addresses_table.rb +45 -0
  43. data/lib/ronin/database/migrations/create_ip_address_mac_addresses_table.rb +45 -0
  44. data/lib/ronin/database/migrations/create_licenses_table.rb +44 -0
  45. data/lib/ronin/database/migrations/create_open_ports_table.rb +55 -0
  46. data/lib/ronin/database/migrations/create_organizations_table.rb +47 -0
  47. data/lib/ronin/database/migrations/create_os_guesses_table.rb +45 -0
  48. data/lib/ronin/database/migrations/create_os_table.rb +43 -0
  49. data/lib/ronin/{extensions/array.rb → database/migrations/create_passwords_table.rb} +17 -23
  50. data/lib/ronin/{ui/command_line/commands/uninstall.rb → database/migrations/create_ports_table.rb} +20 -24
  51. data/lib/ronin/database/migrations/create_proxies_table.rb +55 -0
  52. data/lib/ronin/database/migrations/create_remote_files_table.rb +53 -0
  53. data/lib/ronin/database/migrations/create_repositories_table.rb +61 -0
  54. data/lib/ronin/{ui/command_line/commands/remove.rb → database/migrations/create_services_table.rb} +20 -24
  55. data/lib/ronin/database/migrations/create_softwares_table.rb +46 -0
  56. data/lib/ronin/database/migrations/create_taggings_table.rb +46 -0
  57. data/lib/ronin/database/migrations/create_tags_table.rb +42 -0
  58. data/lib/ronin/database/migrations/create_targets_table.rb +50 -0
  59. data/lib/ronin/{network/imap.rb → database/migrations/create_url_query_params_table.rb} +16 -22
  60. data/lib/ronin/database/migrations/create_url_schemes_table.rb +40 -0
  61. data/lib/ronin/database/migrations/create_urls_table.rb +61 -0
  62. data/lib/ronin/{network/pop3.rb → database/migrations/create_user_names_table.rb} +16 -21
  63. data/lib/ronin/database/migrations/create_vendors_table.rb +42 -0
  64. data/lib/ronin/database/migrations/exceptions/duplicate_migration.rb +30 -0
  65. data/lib/ronin/{network/http/exceptions/unknown_request.rb → database/migrations/exceptions/unknown_migration.rb} +4 -4
  66. data/lib/ronin/{platform → database/migrations}/exceptions.rb +3 -3
  67. data/lib/ronin/database/migrations/graph.rb +278 -0
  68. data/lib/ronin/database/migrations/migration.rb +67 -0
  69. data/lib/ronin/database/migrations/migrations.rb +186 -0
  70. data/lib/ronin/database/migrations.rb +55 -0
  71. data/lib/ronin/database.rb +2 -1
  72. data/lib/ronin/email_address.rb +133 -0
  73. data/lib/ronin/engine/buildable.rb +125 -0
  74. data/lib/ronin/engine/class_methods.rb +133 -0
  75. data/lib/ronin/engine/deployable.rb +180 -0
  76. data/lib/ronin/engine/engine.rb +69 -0
  77. data/lib/ronin/{rpc/exceptions/response_missing.rb → engine/exceptions/deploy_failed.rb} +3 -3
  78. data/lib/ronin/{rpc/exceptions/not_implemented.rb → engine/exceptions/not_built.rb} +3 -3
  79. data/lib/ronin/{platform/exceptions/overlay_cached.rb → engine/exceptions/verification_failed.rb} +3 -3
  80. data/lib/ronin/{rpc → engine}/exceptions.rb +4 -3
  81. data/lib/ronin/engine/instance_methods.rb +95 -0
  82. data/lib/ronin/engine/verifiable.rb +334 -0
  83. data/lib/ronin/{yard.rb → engine.rb} +2 -2
  84. data/lib/ronin/environment.rb +5 -14
  85. data/lib/ronin/{platform/exceptions/overlay_not_found.rb → exceptions/duplicate_repository.rb} +2 -4
  86. data/lib/ronin/exceptions/repository_not_found.rb +24 -0
  87. data/lib/ronin/{network/http/exceptions.rb → exceptions.rb} +3 -2
  88. data/lib/ronin/host_name.rb +181 -0
  89. data/lib/ronin/host_name_ip_address.rb +42 -0
  90. data/lib/ronin/installation.rb +169 -0
  91. data/lib/ronin/ip_address.rb +273 -0
  92. data/lib/ronin/ip_address_mac_address.rb +42 -0
  93. data/lib/ronin/license.rb +17 -20
  94. data/lib/ronin/mac_address.rb +68 -0
  95. data/lib/ronin/model/cacheable/cacheable.rb +280 -0
  96. data/lib/ronin/model/cacheable/class_methods.rb +61 -0
  97. data/lib/ronin/model/cacheable.rb +22 -0
  98. data/lib/ronin/{rpc/response.rb → model/class_methods.rb} +17 -21
  99. data/lib/ronin/{code/emittable.rb → model/has_authors/class_methods.rb} +27 -34
  100. data/lib/ronin/model/has_authors/has_authors.rb +63 -0
  101. data/lib/ronin/model/has_authors.rb +22 -0
  102. data/lib/ronin/model/has_description/class_methods.rb +44 -0
  103. data/lib/ronin/model/has_description/has_description.rb +42 -0
  104. data/lib/ronin/model/has_description.rb +3 -59
  105. data/lib/ronin/{network/helpers/helper.rb → model/has_license/class_methods.rb} +16 -22
  106. data/lib/ronin/model/has_license/has_license.rb +64 -0
  107. data/lib/ronin/model/has_license.rb +3 -38
  108. data/lib/ronin/model/has_name/class_methods.rb +47 -0
  109. data/lib/ronin/model/has_name/has_name.rb +53 -0
  110. data/lib/ronin/model/has_name.rb +3 -33
  111. data/lib/ronin/model/has_title/class_methods.rb +43 -0
  112. data/lib/ronin/model/has_title/has_title.rb +41 -0
  113. data/lib/ronin/model/has_title.rb +22 -0
  114. data/lib/ronin/model/has_unique_name.rb +52 -0
  115. data/lib/ronin/model/has_version/class_methods.rb +47 -0
  116. data/lib/ronin/model/has_version/has_version.rb +41 -0
  117. data/lib/ronin/model/has_version.rb +3 -37
  118. data/lib/ronin/model/model.rb +27 -32
  119. data/lib/ronin/model/types/description.rb +60 -0
  120. data/lib/ronin/{extensions/meta.rb → model/types.rb} +2 -2
  121. data/lib/ronin/model.rb +1 -1
  122. data/lib/ronin/network/mixins/esmtp.rb +152 -0
  123. data/lib/ronin/network/{helpers → mixins}/http.rb +79 -61
  124. data/lib/ronin/network/mixins/imap.rb +140 -0
  125. data/lib/ronin/network/mixins/pop3.rb +130 -0
  126. data/lib/ronin/network/mixins/smtp.rb +146 -0
  127. data/lib/ronin/network/{helpers → mixins}/tcp.rb +97 -98
  128. data/lib/ronin/network/{helpers → mixins}/telnet.rb +71 -41
  129. data/lib/ronin/network/mixins/udp.rb +210 -0
  130. data/lib/ronin/network/mixins.rb +29 -0
  131. data/lib/ronin/open_port.rb +112 -0
  132. data/lib/ronin/organization.rb +49 -0
  133. data/lib/ronin/os.rb +61 -11
  134. data/lib/ronin/os_guess.rb +42 -0
  135. data/lib/ronin/password.rb +126 -0
  136. data/lib/ronin/port.rb +71 -0
  137. data/lib/ronin/proxy.rb +179 -0
  138. data/lib/ronin/proxy_credential.rb +30 -0
  139. data/lib/ronin/remote_file.rb +150 -0
  140. data/lib/ronin/repository.rb +681 -0
  141. data/lib/ronin/ronin.rb +31 -0
  142. data/lib/ronin/service.rb +52 -0
  143. data/lib/ronin/service_credential.rb +30 -0
  144. data/lib/ronin/{product.rb → software.rb} +12 -34
  145. data/lib/ronin/spec/database.rb +42 -0
  146. data/lib/ronin/{extensions/uri/http.rb → spec/ui/output.rb} +6 -8
  147. data/lib/ronin/target.rb +78 -0
  148. data/lib/ronin/tcp_port.rb +41 -0
  149. data/lib/ronin/udp_port.rb +37 -0
  150. data/lib/ronin/ui/async_console.rb +130 -0
  151. data/lib/ronin/ui/cli/cli.rb +147 -0
  152. data/lib/ronin/ui/cli/command.rb +316 -0
  153. data/lib/ronin/ui/cli/commands/campaigns.rb +130 -0
  154. data/lib/ronin/ui/{command_line → cli}/commands/console.rb +27 -22
  155. data/lib/ronin/ui/cli/commands/creds.rb +87 -0
  156. data/lib/ronin/ui/cli/commands/database.rb +179 -0
  157. data/lib/ronin/ui/cli/commands/emails.rb +108 -0
  158. data/lib/ronin/ui/cli/commands/exec.rb +124 -0
  159. data/lib/ronin/ui/{command_line → cli}/commands/help.rb +17 -14
  160. data/lib/ronin/ui/cli/commands/hosts.rb +177 -0
  161. data/lib/ronin/ui/cli/commands/ips.rb +172 -0
  162. data/lib/ronin/ui/cli/commands/repos.rb +236 -0
  163. data/lib/ronin/ui/cli/commands/urls.rb +144 -0
  164. data/lib/ronin/ui/cli/commands.rb +37 -0
  165. data/lib/ronin/ui/cli/engine_command.rb +104 -0
  166. data/lib/ronin/ui/{command_line → cli}/exceptions/unknown_command.rb +2 -2
  167. data/lib/ronin/{formatting/digest.rb → ui/cli/exceptions.rb} +2 -2
  168. data/lib/ronin/ui/cli/model_command.rb +247 -0
  169. data/lib/ronin/{formatting/binary.rb → ui/cli.rb} +3 -2
  170. data/lib/ronin/ui/console.rb +104 -109
  171. data/lib/ronin/ui/hexdump/extensions/file.rb +1 -1
  172. data/lib/ronin/ui/hexdump/extensions/kernel.rb +1 -1
  173. data/lib/ronin/ui/hexdump/extensions.rb +1 -1
  174. data/lib/ronin/ui/hexdump/hexdump.rb +5 -3
  175. data/lib/ronin/ui/hexdump.rb +1 -1
  176. data/lib/ronin/ui/output/helpers.rb +97 -9
  177. data/lib/ronin/ui/output/output.rb +30 -54
  178. data/lib/ronin/ui/output/terminal/color.rb +97 -0
  179. data/lib/ronin/ui/output/terminal/raw.rb +91 -0
  180. data/lib/ronin/{extensions/uri.rb → ui/output/terminal.rb} +3 -2
  181. data/lib/ronin/ui/output.rb +1 -1
  182. data/lib/ronin/ui/shell.rb +55 -90
  183. data/lib/ronin/ui.rb +1 -1
  184. data/lib/ronin/url.rb +343 -0
  185. data/lib/ronin/url_query_param.rb +40 -0
  186. data/lib/ronin/url_scheme.rb +37 -0
  187. data/lib/ronin/user_name.rb +45 -0
  188. data/lib/ronin/vendor.rb +40 -0
  189. data/lib/ronin/version.rb +2 -2
  190. data/lib/ronin/web_credential.rb +32 -0
  191. data/lib/ronin.rb +2 -2
  192. data/ronin.gemspec +10 -0
  193. data/spec/arch_spec.rb +1 -2
  194. data/spec/author_spec.rb +18 -2
  195. data/spec/cached_file_spec.rb +211 -0
  196. data/spec/campaign_spec.rb +30 -0
  197. data/spec/database_spec.rb +5 -0
  198. data/spec/email_address_spec.rb +35 -0
  199. data/spec/engine/buildable_spec.rb +51 -0
  200. data/spec/engine/classes/buildable_class.rb +15 -0
  201. data/spec/engine/classes/deployable_class.rb +13 -0
  202. data/spec/engine/classes/engine_class.rb +19 -0
  203. data/spec/engine/classes/verifiable_class.rb +19 -0
  204. data/spec/engine/deployable_spec.rb +55 -0
  205. data/spec/engine/engine_spec.rb +55 -0
  206. data/spec/engine/verifiable_spec.rb +117 -0
  207. data/spec/{static/helpers/static1/dir/two.txt → helpers/repos/hello/cache/.keep} +0 -0
  208. data/spec/helpers/repos/hello/lib/init.rb +1 -0
  209. data/spec/{platform/helpers/overlays → helpers/repos}/hello/lib/stuff/another_test.rb +0 -0
  210. data/spec/{platform/helpers/overlays → helpers/repos}/hello/lib/stuff/test.rb +0 -0
  211. data/spec/helpers/repos/hello/ronin.yml +7 -0
  212. data/spec/{static/helpers/static1/one.txt → helpers/repos/random/cache/.keep} +0 -0
  213. data/spec/helpers/repos/random/ronin.yml +7 -0
  214. data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +15 -0
  215. data/spec/helpers/repos/test1/ronin.yml +7 -0
  216. data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +7 -0
  217. data/spec/helpers/repos/test2/cache/cacheable_model/load_errors.rb +9 -0
  218. data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +9 -0
  219. data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +7 -0
  220. data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +15 -0
  221. data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +9 -0
  222. data/spec/helpers/repos/test2/ronin.yml +7 -0
  223. data/spec/helpers/repositories.rb +11 -0
  224. data/spec/host_name_spec.rb +51 -0
  225. data/spec/installation_spec.rb +45 -0
  226. data/spec/ip_address.rb +67 -0
  227. data/spec/license_spec.rb +1 -2
  228. data/spec/mac_address_spec.rb +18 -0
  229. data/spec/model/cacheable_spec.rb +93 -0
  230. data/spec/model/has_description_spec.rb +45 -26
  231. data/spec/model/has_license_spec.rb +18 -17
  232. data/spec/model/has_name_spec.rb +35 -0
  233. data/spec/model/has_title_spec.rb +27 -0
  234. data/spec/model/model_spec.rb +27 -19
  235. data/spec/model/{classes → models}/basic_model.rb +0 -0
  236. data/spec/model/models/cacheable_model.rb +15 -0
  237. data/spec/model/{classes → models}/custom_model.rb +1 -1
  238. data/spec/model/{classes → models}/described_model.rb +0 -0
  239. data/spec/model/models/lazy_model.rb +9 -0
  240. data/spec/model/{classes → models}/licensed_model.rb +0 -0
  241. data/spec/model/models/named_model.rb +10 -0
  242. data/spec/model/models/titled_model.rb +10 -0
  243. data/spec/model/spec_helper.rb +22 -0
  244. data/spec/os_spec.rb +1 -2
  245. data/spec/password_spec.rb +35 -0
  246. data/spec/repository_spec.rb +291 -0
  247. data/spec/ronin_spec.rb +19 -5
  248. data/spec/software_spec.rb +23 -0
  249. data/spec/spec_helper.rb +35 -4
  250. data/spec/support/inflector_spec.rb +20 -0
  251. data/spec/ui/cli/classes/test_command.rb +11 -0
  252. data/spec/ui/cli/command_spec.rb +21 -0
  253. data/spec/ui/output_spec.rb +20 -17
  254. data/spec/url_spec.rb +111 -0
  255. data/spec/vendor_spec.rb +18 -0
  256. metadata +761 -421
  257. data/Manifest.txt +0 -290
  258. data/README.txt +0 -206
  259. data/bin/ronin-add +0 -12
  260. data/bin/ronin-install +0 -12
  261. data/bin/ronin-list +0 -12
  262. data/bin/ronin-remove +0 -12
  263. data/bin/ronin-uninstall +0 -12
  264. data/bin/ronin-update +0 -12
  265. data/lib/ronin/cacheable.rb +0 -307
  266. data/lib/ronin/code/reference.rb +0 -130
  267. data/lib/ronin/code/symbol_table.rb +0 -100
  268. data/lib/ronin/code/token.rb +0 -69
  269. data/lib/ronin/extensions/file.rb +0 -38
  270. data/lib/ronin/extensions/ip_addr.rb +0 -147
  271. data/lib/ronin/extensions/kernel.rb +0 -97
  272. data/lib/ronin/extensions/meta/object.rb +0 -24
  273. data/lib/ronin/extensions/string.rb +0 -119
  274. data/lib/ronin/extensions/uri/query_params.rb +0 -126
  275. data/lib/ronin/extensions.rb +0 -26
  276. data/lib/ronin/formatting/extensions/binary/file.rb +0 -35
  277. data/lib/ronin/formatting/extensions/binary/integer.rb +0 -106
  278. data/lib/ronin/formatting/extensions/binary/string.rb +0 -285
  279. data/lib/ronin/formatting/extensions/binary.rb +0 -22
  280. data/lib/ronin/formatting/extensions/digest/string.rb +0 -87
  281. data/lib/ronin/formatting/extensions/digest.rb +0 -21
  282. data/lib/ronin/formatting/extensions/http/string.rb +0 -88
  283. data/lib/ronin/formatting/extensions/http.rb +0 -21
  284. data/lib/ronin/formatting/extensions/text/array.rb +0 -77
  285. data/lib/ronin/formatting/extensions/text/string.rb +0 -162
  286. data/lib/ronin/formatting/extensions/text.rb +0 -22
  287. data/lib/ronin/formatting/extensions.rb +0 -22
  288. data/lib/ronin/formatting/http.rb +0 -21
  289. data/lib/ronin/formatting/text.rb +0 -21
  290. data/lib/ronin/formatting.rb +0 -25
  291. data/lib/ronin/network/esmtp.rb +0 -21
  292. data/lib/ronin/network/extensions/esmtp/net.rb +0 -96
  293. data/lib/ronin/network/extensions/esmtp.rb +0 -21
  294. data/lib/ronin/network/extensions/http/net.rb +0 -607
  295. data/lib/ronin/network/extensions/http.rb +0 -21
  296. data/lib/ronin/network/extensions/imap/net.rb +0 -119
  297. data/lib/ronin/network/extensions/imap.rb +0 -21
  298. data/lib/ronin/network/extensions/pop3/net.rb +0 -88
  299. data/lib/ronin/network/extensions/pop3.rb +0 -21
  300. data/lib/ronin/network/extensions/smtp/net.rb +0 -108
  301. data/lib/ronin/network/extensions/smtp.rb +0 -21
  302. data/lib/ronin/network/extensions/tcp/net.rb +0 -313
  303. data/lib/ronin/network/extensions/tcp.rb +0 -21
  304. data/lib/ronin/network/extensions/telnet/net.rb +0 -151
  305. data/lib/ronin/network/extensions/telnet.rb +0 -21
  306. data/lib/ronin/network/extensions/udp/net.rb +0 -224
  307. data/lib/ronin/network/extensions/udp.rb +0 -21
  308. data/lib/ronin/network/extensions.rb +0 -28
  309. data/lib/ronin/network/helpers/esmtp.rb +0 -129
  310. data/lib/ronin/network/helpers/imap.rb +0 -115
  311. data/lib/ronin/network/helpers/pop3.rb +0 -110
  312. data/lib/ronin/network/helpers/smtp.rb +0 -123
  313. data/lib/ronin/network/helpers/udp.rb +0 -197
  314. data/lib/ronin/network/helpers.rb +0 -29
  315. data/lib/ronin/network/http/http.rb +0 -214
  316. data/lib/ronin/network/http/proxy.rb +0 -308
  317. data/lib/ronin/network/http.rb +0 -23
  318. data/lib/ronin/network/smtp/email.rb +0 -142
  319. data/lib/ronin/network/smtp/smtp.rb +0 -67
  320. data/lib/ronin/network/smtp.rb +0 -23
  321. data/lib/ronin/network/tcp.rb +0 -21
  322. data/lib/ronin/network/telnet.rb +0 -108
  323. data/lib/ronin/network/udp.rb +0 -21
  324. data/lib/ronin/network.rb +0 -28
  325. data/lib/ronin/path.rb +0 -90
  326. data/lib/ronin/platform/extension.rb +0 -446
  327. data/lib/ronin/platform/extension_cache.rb +0 -143
  328. data/lib/ronin/platform/maintainer.rb +0 -69
  329. data/lib/ronin/platform/object_cache.rb +0 -124
  330. data/lib/ronin/platform/overlay.rb +0 -353
  331. data/lib/ronin/platform/overlay_cache.rb +0 -447
  332. data/lib/ronin/platform/platform.rb +0 -304
  333. data/lib/ronin/platform/ronin.rb +0 -97
  334. data/lib/ronin/platform/tasks/spec.rb +0 -9
  335. data/lib/ronin/platform.rb +0 -24
  336. data/lib/ronin/rpc/call.rb +0 -72
  337. data/lib/ronin/rpc/client.rb +0 -88
  338. data/lib/ronin/rpc/console.rb +0 -78
  339. data/lib/ronin/rpc/service.rb +0 -66
  340. data/lib/ronin/rpc/shell.rb +0 -63
  341. data/lib/ronin/rpc.rb +0 -24
  342. data/lib/ronin/scanners/exceptions/unknown_category.rb +0 -26
  343. data/lib/ronin/scanners/exceptions.rb +0 -21
  344. data/lib/ronin/scanners/scanner.rb +0 -295
  345. data/lib/ronin/scanners.rb +0 -22
  346. data/lib/ronin/static/finders.rb +0 -165
  347. data/lib/ronin/static/static.rb +0 -62
  348. data/lib/ronin/static.rb +0 -22
  349. data/lib/ronin/templates/erb.rb +0 -70
  350. data/lib/ronin/templates/template.rb +0 -130
  351. data/lib/ronin/templates.rb +0 -22
  352. data/lib/ronin/ui/command_line/command.rb +0 -216
  353. data/lib/ronin/ui/command_line/command_line.rb +0 -151
  354. data/lib/ronin/ui/command_line/commands/add.rb +0 -79
  355. data/lib/ronin/ui/command_line/commands/install.rb +0 -69
  356. data/lib/ronin/ui/command_line/commands/list.rb +0 -105
  357. data/lib/ronin/ui/command_line/commands/update.rb +0 -59
  358. data/lib/ronin/ui/command_line/exceptions.rb +0 -21
  359. data/lib/ronin/ui/command_line.rb +0 -22
  360. data/lib/ronin/ui/output/handler.rb +0 -121
  361. data/lib/ronin/yard/handlers/ruby/base.rb +0 -27
  362. data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +0 -45
  363. data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +0 -18
  364. data/lib/ronin/yard/handlers/ruby/has_handler.rb +0 -49
  365. data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +0 -41
  366. data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +0 -19
  367. data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +0 -34
  368. data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +0 -21
  369. data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +0 -41
  370. data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +0 -61
  371. data/lib/ronin/yard/handlers/ruby/legacy.rb +0 -26
  372. data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +0 -18
  373. data/lib/ronin/yard/handlers/ruby/property_handler.rb +0 -45
  374. data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +0 -66
  375. data/lib/ronin/yard/handlers/ruby.rb +0 -27
  376. data/lib/ronin/yard/handlers.rb +0 -24
  377. data/spec/cacheable_spec.rb +0 -150
  378. data/spec/classes/cacheable_model.rb +0 -15
  379. data/spec/code/classes/thing.rb +0 -17
  380. data/spec/code/reference_spec.rb +0 -63
  381. data/spec/code/symbol_table_spec.rb +0 -45
  382. data/spec/extensions/array_spec.rb +0 -34
  383. data/spec/extensions/classes/some_class.rb +0 -2
  384. data/spec/extensions/ip_addr_spec.rb +0 -44
  385. data/spec/extensions/kernel_spec.rb +0 -76
  386. data/spec/extensions/string_spec.rb +0 -103
  387. data/spec/extensions/uri/http_spec.rb +0 -9
  388. data/spec/extensions/uri/query_params_spec.rb +0 -46
  389. data/spec/formatting/binary/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -17
  390. data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_bytes.txt +0 -17
  391. data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_shorts.txt +0 -17
  392. data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_bytes.txt +0 -17
  393. data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_shorts.txt +0 -17
  394. data/spec/formatting/binary/helpers/hexdumps/hexdump_repeated.txt +0 -6
  395. data/spec/formatting/binary/helpers/hexdumps/od_decimal_bytes.txt +0 -17
  396. data/spec/formatting/binary/helpers/hexdumps/od_decimal_ints.txt +0 -17
  397. data/spec/formatting/binary/helpers/hexdumps/od_decimal_quads.txt +0 -17
  398. data/spec/formatting/binary/helpers/hexdumps/od_decimal_shorts.txt +0 -17
  399. data/spec/formatting/binary/helpers/hexdumps/od_hex_bytes.txt +0 -17
  400. data/spec/formatting/binary/helpers/hexdumps/od_hex_ints.txt +0 -17
  401. data/spec/formatting/binary/helpers/hexdumps/od_hex_quads.txt +0 -17
  402. data/spec/formatting/binary/helpers/hexdumps/od_hex_shorts.txt +0 -17
  403. data/spec/formatting/binary/helpers/hexdumps/od_octal_bytes.txt +0 -17
  404. data/spec/formatting/binary/helpers/hexdumps/od_octal_ints.txt +0 -17
  405. data/spec/formatting/binary/helpers/hexdumps/od_octal_quads.txt +0 -17
  406. data/spec/formatting/binary/helpers/hexdumps/od_octal_shorts.txt +0 -17
  407. data/spec/formatting/binary/helpers/hexdumps/od_repeated.txt +0 -6
  408. data/spec/formatting/binary/helpers/hexdumps/repeated.bin +0 -1
  409. data/spec/formatting/binary/helpers/hexdumps.rb +0 -14
  410. data/spec/formatting/binary/integer_spec.rb +0 -131
  411. data/spec/formatting/binary/string_spec.rb +0 -251
  412. data/spec/formatting/digest/string_spec.rb +0 -80
  413. data/spec/formatting/http/string_spec.rb +0 -80
  414. data/spec/formatting/text/array_spec.rb +0 -64
  415. data/spec/formatting/text/string_spec.rb +0 -147
  416. data/spec/helpers/cacheable.rb +0 -7
  417. data/spec/helpers/contexts/ronin_cacheable_model.rb +0 -13
  418. data/spec/helpers/database.rb +0 -5
  419. data/spec/network/helpers/classes/test_helper.rb +0 -11
  420. data/spec/network/helpers/classes/uses_test_helper.rb +0 -10
  421. data/spec/network/helpers/helper_spec.rb +0 -25
  422. data/spec/network/http/http_spec.rb +0 -197
  423. data/spec/network/http/proxy_spec.rb +0 -116
  424. data/spec/path_spec.rb +0 -32
  425. data/spec/platform/extension_cache_spec.rb +0 -64
  426. data/spec/platform/extension_spec.rb +0 -73
  427. data/spec/platform/helpers/overlays/hello/hello/extension.rb +0 -7
  428. data/spec/platform/helpers/overlays/hello/lib/init.rb +0 -1
  429. data/spec/platform/helpers/overlays/hello/ronin.xml +0 -26
  430. data/spec/platform/helpers/overlays/random/random/extension.rb +0 -7
  431. data/spec/platform/helpers/overlays/random/ronin.xml +0 -26
  432. data/spec/platform/helpers/overlays/test1/ronin.xml +0 -26
  433. data/spec/platform/helpers/overlays/test1/test/extension.rb +0 -7
  434. data/spec/platform/helpers/overlays/test2/ronin.xml +0 -26
  435. data/spec/platform/helpers/overlays/test2/test/extension.rb +0 -7
  436. data/spec/platform/helpers/overlays.rb +0 -18
  437. data/spec/platform/helpers/overlays.yaml.erb +0 -13
  438. data/spec/platform/maintainer_spec.rb +0 -30
  439. data/spec/platform/overlay_cache_spec.rb +0 -65
  440. data/spec/platform/overlay_spec.rb +0 -63
  441. data/spec/platform/platform_spec.rb +0 -22
  442. data/spec/platform/ronin_spec.rb +0 -34
  443. data/spec/product_spec.rb +0 -23
  444. data/spec/scanners/classes/another_scanner.rb +0 -16
  445. data/spec/scanners/classes/example_scanner.rb +0 -22
  446. data/spec/scanners/scanner_spec.rb +0 -148
  447. data/spec/static/classes/static_class.rb +0 -7
  448. data/spec/static/finders_spec.rb +0 -55
  449. data/spec/static/helpers/static.rb +0 -10
  450. data/spec/static/helpers/static2/dir/two.txt +0 -0
  451. data/spec/static/static_spec.rb +0 -25
  452. data/spec/templates/classes/example_erb.rb +0 -11
  453. data/spec/templates/classes/example_template.rb +0 -21
  454. data/spec/templates/erb_spec.rb +0 -20
  455. data/spec/templates/helpers/static/templates/_relative.erb +0 -1
  456. data/spec/templates/helpers/static/templates/example.erb +0 -1
  457. data/spec/templates/helpers/static.rb +0 -5
  458. data/spec/templates/template_spec.rb +0 -41
  459. data/spec/ui/command_line/classes/test_command.rb +0 -23
  460. data/spec/ui/command_line/command_spec.rb +0 -31
  461. data/static/ronin/platform/overlay.xsl +0 -203
  462. data/tasks/spec.rb +0 -10
  463. data/tasks/yard.rb +0 -18
  464. data.tar.gz.sig +0 -0
  465. metadata.gz.sig +0 -0
@@ -1,39 +1,76 @@
1
1
  #
2
2
  # Ronin - A Ruby platform for exploit development and security research.
3
3
  #
4
- # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
4
+ # Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
5
5
  #
6
- # This program is free software; you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation; either version 2 of the License, or
9
- # (at your option) any later version.
6
+ # This library is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU Lesser General Public
8
+ # License as published by the Free Software Foundation; either
9
+ # version 2.1 of the License, or (at your option) any later version.
10
10
  #
11
- # This program is distributed in the hope that it will be useful,
11
+ # This library is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
15
  #
16
- # You should have received a copy of the GNU General Public License
17
- # along with this program; if not, write to the Free Software
18
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
+ # Boston, MA 02110-1301 USA
19
20
  #
20
21
 
21
- require 'ronin/network/helpers/helper'
22
22
  require 'ronin/network/http'
23
23
 
24
+ require 'parameters'
25
+
24
26
  module Ronin
25
27
  module Network
26
- module Helpers
28
+ module Mixins
29
+ #
30
+ # Adds HTTP convenience methods and connection parameters to a class.
31
+ #
27
32
  module HTTP
28
- include Helper
33
+ include Parameters
34
+
35
+ # HTTP host
36
+ parameter :host,
37
+ :type => String,
38
+ :description => 'HTTP host'
39
+
40
+ # HTTP port
41
+ parameter :port,
42
+ :type => Integer,
43
+ :description => 'HTTP port'
44
+
45
+ # HTTP `Host` header to send
46
+ parameter :http_vhost,
47
+ :type => String,
48
+ :description => 'HTTP Host header to send'
49
+
50
+ # HTTP user to authenticate as
51
+ parameter :http_user,
52
+ :type => String,
53
+ :description => 'HTTP user to authenticate as'
54
+
55
+ # HTTP password to authenticate with
56
+ parameter :http_password,
57
+ :type => String,
58
+ :description => 'HTTP password to authenticate with'
59
+
60
+ # HTTP proxy information
61
+ parameter :http_proxy,
62
+ :description => 'HTTP proxy information'
63
+
64
+ # HTTP `User-Agent` header to send
65
+ parameter :http_user_agent,
66
+ :type => String,
67
+ :description => 'HTTP User-Agent header to send'
29
68
 
30
69
  protected
31
70
 
32
71
  #
33
72
  # Resets the HTTP proxy settings.
34
73
  #
35
- # @since 0.3.0
36
- #
37
74
  def disable_http_proxy
38
75
  @http_proxy = nil
39
76
  end
@@ -74,15 +111,12 @@ module Ronin
74
111
  # @return [Net::HTTP]
75
112
  # The HTTP session object.
76
113
  #
77
- # @since 0.3.0
78
- #
79
114
  def http_session(options={},&block)
80
115
  Net.http_session(http_merge_options(options),&block)
81
116
  end
82
117
 
83
118
  #
84
- # Connects to the HTTP server and sends an HTTP Request using the
85
- # given _options_.
119
+ # Connects to the HTTP server and sends an HTTP Request.
86
120
  #
87
121
  # @param [Hash] options
88
122
  # Additional options.
@@ -95,26 +129,25 @@ module Ronin
95
129
  # @yield [request, (options)]
96
130
  # If a block is given, it will be passed the HTTP request object.
97
131
  # If the block has an arity of 2, it will also be passed the
98
- # expanded version of the given _options_.
132
+ # expanded version of the given options.
99
133
  #
100
134
  # @yieldparam [Net::HTTP::Request] request
101
135
  # The HTTP request object to use in the request.
102
136
  #
103
137
  # @yieldparam [Hash] options
104
- # The expanded version of the given _options_.
138
+ # The expanded version of the given options.
105
139
  #
106
140
  # @return [Net::HTTP::Response]
107
141
  # The response of the HTTP request.
108
142
  #
109
143
  # @see http_session
110
- # @since 0.3.0
111
144
  #
112
145
  def http_request(options={},&block)
113
146
  Net.http_request(http_merge_options(options),&block)
114
147
  end
115
148
 
116
149
  #
117
- # Performes an HTTP Copy request with the given _options_.
150
+ # Performs an HTTP Copy request.
118
151
  #
119
152
  # @yield [response]
120
153
  # If a block is given, it will be passed the response received
@@ -127,14 +160,13 @@ module Ronin
127
160
  # The response of the HTTP request.
128
161
  #
129
162
  # @see http_request
130
- # @since 0.3.0
131
163
  #
132
164
  def http_copy(options={},&block)
133
165
  Net.http_copy(http_merge_options(options),&block)
134
166
  end
135
167
 
136
168
  #
137
- # Performes an HTTP Delete request with the given _options_.
169
+ # Performs an HTTP Delete request.
138
170
  #
139
171
  # @yield [response]
140
172
  # If a block is given, it will be passed the response received
@@ -147,14 +179,13 @@ module Ronin
147
179
  # The response of the HTTP request.
148
180
  #
149
181
  # @see http_request
150
- # @since 0.3.0
151
182
  #
152
183
  def http_delete(options={},&block)
153
184
  Net.http_delete(http_merge_options(options),&block)
154
185
  end
155
186
 
156
187
  #
157
- # Performes an HTTP Get request with the given _options_.
188
+ # Performs an HTTP Get request.
158
189
  #
159
190
  # @yield [response]
160
191
  # If a block is given, it will be passed the response received
@@ -167,14 +198,13 @@ module Ronin
167
198
  # The response of the HTTP request.
168
199
  #
169
200
  # @see http_request
170
- # @since 0.3.0
171
201
  #
172
202
  def http_get(options={},&block)
173
203
  Net.http_get(http_merge_options(options),&block)
174
204
  end
175
205
 
176
206
  #
177
- # Performes an HTTP Get request with the given _options_.
207
+ # Performs an HTTP Get request.
178
208
  #
179
209
  # @yield [response]
180
210
  # If a block is given, it will be passed the response received
@@ -187,14 +217,13 @@ module Ronin
187
217
  # The body of the HTTP Get request.
188
218
  #
189
219
  # @see http_get
190
- # @since 0.3.0
191
220
  #
192
221
  def http_get_body(options={},&block)
193
222
  Net.http_get_body(http_merge_options(options),&block)
194
223
  end
195
224
 
196
225
  #
197
- # Performes an HTTP Head request with the given _options_.
226
+ # Performs an HTTP Head request.
198
227
  #
199
228
  # @yield [response]
200
229
  # If a block is given, it will be passed the response received
@@ -207,14 +236,13 @@ module Ronin
207
236
  # The response of the HTTP request.
208
237
  #
209
238
  # @see http_request
210
- # @since 0.3.0
211
239
  #
212
240
  def http_head(options={},&block)
213
241
  Net.http_head(http_merge_options(options),&block)
214
242
  end
215
243
 
216
244
  #
217
- # Performes an HTTP Lock request with the given _options_.
245
+ # Performs an HTTP Lock request.
218
246
  #
219
247
  # @yield [response]
220
248
  # If a block is given, it will be passed the response received
@@ -227,14 +255,13 @@ module Ronin
227
255
  # The response of the HTTP request.
228
256
  #
229
257
  # @see http_request
230
- # @since 0.3.0
231
258
  #
232
259
  def http_lock(options={},&block)
233
260
  Net.http_lock(http_merge_options(options),&block)
234
261
  end
235
262
 
236
263
  #
237
- # Performes an HTTP Mkcol request with the given _options_.
264
+ # Performs an HTTP Mkcol request.
238
265
  #
239
266
  # @yield [response]
240
267
  # If a block is given, it will be passed the response received
@@ -247,14 +274,13 @@ module Ronin
247
274
  # The response of the HTTP request.
248
275
  #
249
276
  # @see http_request
250
- # @since 0.3.0
251
277
  #
252
278
  def http_mkcol(options={},&block)
253
279
  Net.http_mkcol(http_merge_options(options),&block)
254
280
  end
255
281
 
256
282
  #
257
- # Performes an HTTP Move request with the given _options_.
283
+ # Performs an HTTP Move request.
258
284
  #
259
285
  # @yield [response]
260
286
  # If a block is given, it will be passed the response received
@@ -267,14 +293,13 @@ module Ronin
267
293
  # The response of the HTTP request.
268
294
  #
269
295
  # @see http_request
270
- # @since 0.3.0
271
296
  #
272
297
  def http_move(options={},&block)
273
298
  Net.http_move(http_merge_options(options),&block)
274
299
  end
275
300
 
276
301
  #
277
- # Performes an HTTP Options request with the given _options_.
302
+ # Performs an HTTP Options request.
278
303
  #
279
304
  # @yield [response]
280
305
  # If a block is given, it will be passed the response received
@@ -287,20 +312,19 @@ module Ronin
287
312
  # The response of the HTTP request.
288
313
  #
289
314
  # @see http_request
290
- # @since 0.3.0
291
315
  #
292
316
  def http_options(options={},&block)
293
317
  Net.http_options(http_merge_options(options),&block)
294
318
  end
295
319
 
296
320
  #
297
- # Performes an HTTP Post request with the given _options_.
321
+ # Performs an HTTP Post request.
298
322
  #
299
323
  # @param [Hash] options
300
324
  # Additional options.
301
325
  #
302
326
  # @option options [String] :post_data
303
- # The +POSTDATA+ to send with the HTTP Post request.
327
+ # The `POSTDATA` to send with the HTTP Post request.
304
328
  #
305
329
  # @yield [response]
306
330
  # If a block is given, it will be passed the response received
@@ -313,14 +337,13 @@ module Ronin
313
337
  # The response of the HTTP request.
314
338
  #
315
339
  # @see http_request
316
- # @since 0.3.0
317
340
  #
318
341
  def http_post(options={},&block)
319
342
  Net.http_post(http_merge_options(options),&block)
320
343
  end
321
344
 
322
345
  #
323
- # Performes an HTTP Post request with the given _options_.
346
+ # Performs an HTTP Post request.
324
347
  #
325
348
  # @yield [response]
326
349
  # If a block is given, it will be passed the response received
@@ -333,14 +356,13 @@ module Ronin
333
356
  # The body of the Post request.
334
357
  #
335
358
  # @see http_post
336
- # @since 0.3.0
337
359
  #
338
360
  def http_post_body(options={},&block)
339
361
  Net.http_post_body(http_merge_options(options),&block)
340
362
  end
341
363
 
342
364
  #
343
- # Performes an HTTP Propfind request with the given _options_.
365
+ # Performs an HTTP Propfind request.
344
366
  #
345
367
  # @yield [response]
346
368
  # If a block is given, it will be passed the response received
@@ -353,14 +375,13 @@ module Ronin
353
375
  # The response of the HTTP request.
354
376
  #
355
377
  # @see http_request
356
- # @since 0.3.0
357
378
  #
358
379
  def http_prop_find(options={},&block)
359
380
  Net.http_prop_find(http_merge_options(options),&block)
360
381
  end
361
382
 
362
383
  #
363
- # Performes an HTTP Proppatch request with the given _options_.
384
+ # Performs an HTTP Proppatch request.
364
385
  #
365
386
  # @yield [response]
366
387
  # If a block is given, it will be passed the response received
@@ -373,14 +394,13 @@ module Ronin
373
394
  # The response of the HTTP request.
374
395
  #
375
396
  # @see http_request
376
- # @since 0.3.0
377
397
  #
378
398
  def http_prop_patch(options={},&block)
379
399
  Net.http_prop_patch(http_merge_options(options),&block)
380
400
  end
381
401
 
382
402
  #
383
- # Performes an HTTP Trace request with the given _options_.
403
+ # Performs an HTTP Trace request.
384
404
  #
385
405
  # @yield [response]
386
406
  # If a block is given, it will be passed the response received
@@ -393,14 +413,13 @@ module Ronin
393
413
  # The response of the HTTP request.
394
414
  #
395
415
  # @see http_request
396
- # @since 0.3.0
397
416
  #
398
417
  def http_trace(options={},&block)
399
418
  Net.http_trace(http_merge_options(options),&block)
400
419
  end
401
420
 
402
421
  #
403
- # Performes an HTTP Unlock request with the given _options_.
422
+ # Performs an HTTP Unlock request.
404
423
  #
405
424
  # @yield [response]
406
425
  # If a block is given, it will be passed the response received
@@ -413,7 +432,6 @@ module Ronin
413
432
  # The response of the HTTP request.
414
433
  #
415
434
  # @see http_request
416
- # @since 0.3.0
417
435
  #
418
436
  def http_unlock(options={},&block)
419
437
  Net.http_unlock(http_merge_options(options),&block)
@@ -422,19 +440,19 @@ module Ronin
422
440
  private
423
441
 
424
442
  def http_merge_options(options={})
425
- options[:host] ||= @host if @host
426
- options[:port] ||= @port if @port
443
+ options[:host] ||= self.host if self.host
444
+ options[:port] ||= self.port if self.port
427
445
 
428
446
  options[:headers] ||= {}
429
447
  headers = options[:headers]
430
448
 
431
- headers[:host] ||= @http_vhost if @http_vhost
449
+ headers[:host] ||= self.http_vhost if self.http_vhost
432
450
 
433
- options[:user] ||= @http_user if @http_user
434
- options[:password] ||= @http_password if @http_password
451
+ options[:user] ||= self.http_user if self.http_user
452
+ options[:password] ||= self.http_password if self.http_password
435
453
 
436
- options[:proxy] ||= @http_proxy if @http_proxy
437
- options[:user_agent] ||= @http_user_agent if @http_user_agent
454
+ options[:proxy] ||= self.http_proxy if self.http_proxy
455
+ options[:user_agent] ||= self.http_user_agent if self.http_user_agent
438
456
 
439
457
  return options
440
458
  end
@@ -0,0 +1,140 @@
1
+ #
2
+ # Ronin - A Ruby platform for exploit development and security research.
3
+ #
4
+ # Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ #
6
+ # This library is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU Lesser General Public
8
+ # License as published by the Free Software Foundation; either
9
+ # version 2.1 of the License, or (at your option) any later version.
10
+ #
11
+ # This library 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 GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
+ # Boston, MA 02110-1301 USA
20
+ #
21
+
22
+ require 'ronin/network/imap'
23
+
24
+ require 'parameters'
25
+
26
+ module Ronin
27
+ module Network
28
+ module Mixins
29
+ #
30
+ # Adds IMAP convenience methods and connection parameters to a class.
31
+ #
32
+ module IMAP
33
+ include Parameters
34
+
35
+ # IMAP host
36
+ parameter :host,
37
+ :type => String,
38
+ :description => 'IMAP host'
39
+
40
+ # IMAP port
41
+ parameter :port,
42
+ :type => Integer,
43
+ :description => 'IMAP port'
44
+
45
+ # IMAP auth
46
+ parameter :imap_auth,
47
+ :type => String,
48
+ :description => 'IMAP authentication method'
49
+
50
+ # IMAP user to login as
51
+ parameter :imap_user,
52
+ :type => String,
53
+ :description => 'IMAP user to login as'
54
+
55
+ # IMAP password to login with
56
+ parameter :imap_password,
57
+ :type => String,
58
+ :description => 'IMAP password to login with'
59
+
60
+ protected
61
+
62
+ #
63
+ # Creates a connection to the IMAP server. The {#host}, {#port},
64
+ # {#imap_auth}, {#imap_user} and {#imap_password} parameters
65
+ # will also be used to make the connection.
66
+ #
67
+ # @param [Hash] options
68
+ # Additional options.
69
+ #
70
+ # @option options [Integer] :port (IMAP.default_port)
71
+ # The port the IMAP server is running on.
72
+ #
73
+ # @option options [String] :certs
74
+ # The path to the file containing CA certs of the server.
75
+ #
76
+ # @option options [Symbol] :auth
77
+ # The type of authentication to perform when connecting to the
78
+ # server. May be either `:login` or `:cram_md5`.
79
+ #
80
+ # @option options [String] :user
81
+ # The user to authenticate as when connecting to the server.
82
+ #
83
+ # @option options [String] :password
84
+ # The password to authenticate with when connecting to the
85
+ # server.
86
+ #
87
+ # @option options [Boolean]
88
+ # Indicates wether or not to use SSL when connecting to the
89
+ # server.
90
+ #
91
+ def imap_connect(options={},&block)
92
+ options[:port] ||= self.port
93
+ options[:auth] ||= self.imap_auth
94
+ options[:user] ||= self.imap_user
95
+ options[:password] ||= self.imap_password
96
+
97
+ if self.port
98
+ print_info "Connecting to #{self.host}:#{self.port} ..."
99
+ else
100
+ print_info "Connecting to #{self.host} ..."
101
+ end
102
+
103
+ return ::Net.imap_connect(self.host,options,&block)
104
+ end
105
+
106
+ #
107
+ # Starts a session with the IMAP server. The {#host}, {#port},
108
+ # {#imap_auth}, {#imap_user} and {#imap_password} parameters
109
+ # will also be used to make the connection.
110
+ #
111
+ # @yield [session]
112
+ # If a block is given, it will be passed the newly created
113
+ # IMAP session. After the block has returned, the session will
114
+ # be closed.
115
+ #
116
+ # @yieldparam [Net::IMAP] session
117
+ # The newly created IMAP session object.
118
+ #
119
+ # @see imap_connect
120
+ #
121
+ def imap_session(options={})
122
+ imap_connect(options) do |sess|
123
+ yield sess if block_given?
124
+
125
+ print_info "Logging out ..."
126
+
127
+ sess.close
128
+ sess.logout
129
+
130
+ if self.port
131
+ print_info "Disconnecting from #{self.host}:#{self.port}"
132
+ else
133
+ print_info "Disconnecting from #{self.host}"
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,130 @@
1
+ #
2
+ # Ronin - A Ruby platform for exploit development and security research.
3
+ #
4
+ # Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ #
6
+ # This library is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU Lesser General Public
8
+ # License as published by the Free Software Foundation; either
9
+ # version 2.1 of the License, or (at your option) any later version.
10
+ #
11
+ # This library 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 GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
+ # Boston, MA 02110-1301 USA
20
+ #
21
+
22
+ require 'ronin/network/pop3'
23
+
24
+ require 'parameters'
25
+
26
+ module Ronin
27
+ module Network
28
+ module Mixins
29
+ #
30
+ # Adds POP3 convenience methods and connection parameters to a class.
31
+ #
32
+ module POP3
33
+ include Parameters
34
+
35
+ # POP3 host
36
+ parameter :host,
37
+ :type => String,
38
+ :description => 'POP3 host'
39
+
40
+ # POP3 port
41
+ parameter :port,
42
+ :type => Integer,
43
+ :description => 'POP3 port'
44
+
45
+ # POP3 user
46
+ parameter :pop3_user,
47
+ :type => String,
48
+ :description => 'POP3 user to login as'
49
+
50
+ # POP3 password
51
+ parameter :pop3_password,
52
+ :type => String,
53
+ :description => 'POP3 password to login with'
54
+
55
+ protected
56
+
57
+ #
58
+ # Creates a connection to the POP3 server. The {#host}, {#port},
59
+ # {#pop3_user} and {#pop3_password} parameters will also be used
60
+ # to connect to the server.
61
+ #
62
+ # @param [Hash] options
63
+ # Additional options.
64
+ #
65
+ # @option options [Integer] :port (Ronin::Network::POP3.default_port)
66
+ # The port the POP3 server is running on.
67
+ #
68
+ # @option options [String] :user
69
+ # The user to authenticate with when connecting to the POP3
70
+ # server.
71
+ #
72
+ # @option options [String] :password
73
+ # The password to authenticate with when connecting to the POP3
74
+ # server.
75
+ #
76
+ # @yield [session]
77
+ # If a block is given, it will be passed the newly created
78
+ # POP3 session.
79
+ #
80
+ # @yieldparam [Net::POP3] session
81
+ # The newly created POP3 session.
82
+ #
83
+ # @return [Net::POP3]
84
+ # The newly created POP3 session.
85
+ #
86
+ def pop3_connect(options={},&block)
87
+ options[:port] ||= self.port
88
+ options[:user] ||= self.pop3_user
89
+ options[:password] ||= self.pop3_password
90
+
91
+ if self.port
92
+ print_info "Connecting to #{self.host}:#{self.port} ..."
93
+ else
94
+ print_info "Connecting to #{self.host} ..."
95
+ end
96
+
97
+ return ::Net.pop3_connect(self.host,options,&block)
98
+ end
99
+
100
+ #
101
+ # Starts a session with the POP3 server. The {#host}, {#port},
102
+ # {#pop3_user} and {#pop3_password} parameters will also be used
103
+ # to connect to the server.
104
+ #
105
+ # @yield [session]
106
+ # If a block is given, it will be passed the newly created
107
+ # POP3 session. After the block has returned, the session
108
+ # will be closed.
109
+ #
110
+ # @yieldparam [Net::POP3] session
111
+ # The newly created POP3 session.
112
+ #
113
+ # @see pop3_connect
114
+ #
115
+ def pop3_session(options={})
116
+ pop3_connect(options) do |sess|
117
+ yield sess if block_given?
118
+ sess.finish
119
+
120
+ if @port
121
+ print_info "Disconnecting to #{self.host}:#{self.port}"
122
+ else
123
+ print_info "Disconnecting to #{self.host}"
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end