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.
- data/.document +4 -0
- data/.rspec +1 -0
- data/.yardopts +5 -0
- data/{History.txt → ChangeLog.md} +15 -15
- data/Gemfile +42 -0
- data/README.md +224 -0
- data/Rakefile +65 -33
- data/bin/ronin +18 -5
- data/bin/ronin-campaigns +25 -0
- data/bin/ronin-console +18 -5
- data/bin/ronin-creds +25 -0
- data/bin/ronin-database +25 -0
- data/bin/ronin-emails +25 -0
- data/bin/ronin-exec +25 -0
- data/bin/ronin-help +18 -5
- data/bin/ronin-hosts +25 -0
- data/bin/ronin-ips +25 -0
- data/bin/ronin-repos +25 -0
- data/bin/ronin-urls +25 -0
- data/gemspec.yml +71 -0
- data/lib/ronin/address.rb +93 -0
- data/lib/ronin/arch.rb +30 -25
- data/lib/ronin/author.rb +12 -42
- data/lib/ronin/bootstrap.rb +26 -0
- data/lib/ronin/cached_file.rb +249 -0
- data/lib/ronin/campaign.rb +130 -0
- data/lib/ronin/class_methods.rb +27 -0
- data/lib/ronin/config.rb +23 -17
- data/lib/ronin/credential.rb +114 -0
- data/lib/ronin/database/database.rb +180 -52
- data/lib/ronin/database/exceptions/invalid_config.rb +2 -2
- data/lib/ronin/{platform/exceptions/extension_not_found.rb → database/exceptions/unknown_repository.rb} +3 -3
- data/lib/ronin/database/exceptions.rb +2 -1
- data/lib/ronin/database/migrations/create_addresses_table.rb +52 -0
- data/lib/ronin/database/migrations/create_arches_table.rb +44 -0
- data/lib/ronin/database/migrations/create_authors_table.rb +47 -0
- data/lib/ronin/database/migrations/create_cached_files_table.rb +47 -0
- data/lib/ronin/database/migrations/create_campaigns_table.rb +42 -0
- data/lib/ronin/database/migrations/create_countries_table.rb +44 -0
- data/lib/ronin/database/migrations/create_credentials_table.rb +59 -0
- data/lib/ronin/database/migrations/create_email_addresses_table.rb +51 -0
- data/lib/ronin/database/migrations/create_host_name_ip_addresses_table.rb +45 -0
- data/lib/ronin/database/migrations/create_ip_address_mac_addresses_table.rb +45 -0
- data/lib/ronin/database/migrations/create_licenses_table.rb +44 -0
- data/lib/ronin/database/migrations/create_open_ports_table.rb +55 -0
- data/lib/ronin/database/migrations/create_organizations_table.rb +47 -0
- data/lib/ronin/database/migrations/create_os_guesses_table.rb +45 -0
- data/lib/ronin/database/migrations/create_os_table.rb +43 -0
- data/lib/ronin/{extensions/array.rb → database/migrations/create_passwords_table.rb} +17 -23
- data/lib/ronin/{ui/command_line/commands/uninstall.rb → database/migrations/create_ports_table.rb} +20 -24
- data/lib/ronin/database/migrations/create_proxies_table.rb +55 -0
- data/lib/ronin/database/migrations/create_remote_files_table.rb +53 -0
- data/lib/ronin/database/migrations/create_repositories_table.rb +61 -0
- data/lib/ronin/{ui/command_line/commands/remove.rb → database/migrations/create_services_table.rb} +20 -24
- data/lib/ronin/database/migrations/create_softwares_table.rb +46 -0
- data/lib/ronin/database/migrations/create_taggings_table.rb +46 -0
- data/lib/ronin/database/migrations/create_tags_table.rb +42 -0
- data/lib/ronin/database/migrations/create_targets_table.rb +50 -0
- data/lib/ronin/{network/imap.rb → database/migrations/create_url_query_params_table.rb} +16 -22
- data/lib/ronin/database/migrations/create_url_schemes_table.rb +40 -0
- data/lib/ronin/database/migrations/create_urls_table.rb +61 -0
- data/lib/ronin/{network/pop3.rb → database/migrations/create_user_names_table.rb} +16 -21
- data/lib/ronin/database/migrations/create_vendors_table.rb +42 -0
- data/lib/ronin/database/migrations/exceptions/duplicate_migration.rb +30 -0
- data/lib/ronin/{network/http/exceptions/unknown_request.rb → database/migrations/exceptions/unknown_migration.rb} +4 -4
- data/lib/ronin/{platform → database/migrations}/exceptions.rb +3 -3
- data/lib/ronin/database/migrations/graph.rb +278 -0
- data/lib/ronin/database/migrations/migration.rb +67 -0
- data/lib/ronin/database/migrations/migrations.rb +186 -0
- data/lib/ronin/database/migrations.rb +55 -0
- data/lib/ronin/database.rb +2 -1
- data/lib/ronin/email_address.rb +133 -0
- data/lib/ronin/engine/buildable.rb +125 -0
- data/lib/ronin/engine/class_methods.rb +133 -0
- data/lib/ronin/engine/deployable.rb +180 -0
- data/lib/ronin/engine/engine.rb +69 -0
- data/lib/ronin/{rpc/exceptions/response_missing.rb → engine/exceptions/deploy_failed.rb} +3 -3
- data/lib/ronin/{rpc/exceptions/not_implemented.rb → engine/exceptions/not_built.rb} +3 -3
- data/lib/ronin/{platform/exceptions/overlay_cached.rb → engine/exceptions/verification_failed.rb} +3 -3
- data/lib/ronin/{rpc → engine}/exceptions.rb +4 -3
- data/lib/ronin/engine/instance_methods.rb +95 -0
- data/lib/ronin/engine/verifiable.rb +334 -0
- data/lib/ronin/{yard.rb → engine.rb} +2 -2
- data/lib/ronin/environment.rb +5 -14
- data/lib/ronin/{platform/exceptions/overlay_not_found.rb → exceptions/duplicate_repository.rb} +2 -4
- data/lib/ronin/exceptions/repository_not_found.rb +24 -0
- data/lib/ronin/{network/http/exceptions.rb → exceptions.rb} +3 -2
- data/lib/ronin/host_name.rb +181 -0
- data/lib/ronin/host_name_ip_address.rb +42 -0
- data/lib/ronin/installation.rb +169 -0
- data/lib/ronin/ip_address.rb +273 -0
- data/lib/ronin/ip_address_mac_address.rb +42 -0
- data/lib/ronin/license.rb +17 -20
- data/lib/ronin/mac_address.rb +68 -0
- data/lib/ronin/model/cacheable/cacheable.rb +280 -0
- data/lib/ronin/model/cacheable/class_methods.rb +61 -0
- data/lib/ronin/model/cacheable.rb +22 -0
- data/lib/ronin/{rpc/response.rb → model/class_methods.rb} +17 -21
- data/lib/ronin/{code/emittable.rb → model/has_authors/class_methods.rb} +27 -34
- data/lib/ronin/model/has_authors/has_authors.rb +63 -0
- data/lib/ronin/model/has_authors.rb +22 -0
- data/lib/ronin/model/has_description/class_methods.rb +44 -0
- data/lib/ronin/model/has_description/has_description.rb +42 -0
- data/lib/ronin/model/has_description.rb +3 -59
- data/lib/ronin/{network/helpers/helper.rb → model/has_license/class_methods.rb} +16 -22
- data/lib/ronin/model/has_license/has_license.rb +64 -0
- data/lib/ronin/model/has_license.rb +3 -38
- data/lib/ronin/model/has_name/class_methods.rb +47 -0
- data/lib/ronin/model/has_name/has_name.rb +53 -0
- data/lib/ronin/model/has_name.rb +3 -33
- data/lib/ronin/model/has_title/class_methods.rb +43 -0
- data/lib/ronin/model/has_title/has_title.rb +41 -0
- data/lib/ronin/model/has_title.rb +22 -0
- data/lib/ronin/model/has_unique_name.rb +52 -0
- data/lib/ronin/model/has_version/class_methods.rb +47 -0
- data/lib/ronin/model/has_version/has_version.rb +41 -0
- data/lib/ronin/model/has_version.rb +3 -37
- data/lib/ronin/model/model.rb +27 -32
- data/lib/ronin/model/types/description.rb +60 -0
- data/lib/ronin/{extensions/meta.rb → model/types.rb} +2 -2
- data/lib/ronin/model.rb +1 -1
- data/lib/ronin/network/mixins/esmtp.rb +152 -0
- data/lib/ronin/network/{helpers → mixins}/http.rb +79 -61
- data/lib/ronin/network/mixins/imap.rb +140 -0
- data/lib/ronin/network/mixins/pop3.rb +130 -0
- data/lib/ronin/network/mixins/smtp.rb +146 -0
- data/lib/ronin/network/{helpers → mixins}/tcp.rb +97 -98
- data/lib/ronin/network/{helpers → mixins}/telnet.rb +71 -41
- data/lib/ronin/network/mixins/udp.rb +210 -0
- data/lib/ronin/network/mixins.rb +29 -0
- data/lib/ronin/open_port.rb +112 -0
- data/lib/ronin/organization.rb +49 -0
- data/lib/ronin/os.rb +61 -11
- data/lib/ronin/os_guess.rb +42 -0
- data/lib/ronin/password.rb +126 -0
- data/lib/ronin/port.rb +71 -0
- data/lib/ronin/proxy.rb +179 -0
- data/lib/ronin/proxy_credential.rb +30 -0
- data/lib/ronin/remote_file.rb +150 -0
- data/lib/ronin/repository.rb +681 -0
- data/lib/ronin/ronin.rb +31 -0
- data/lib/ronin/service.rb +52 -0
- data/lib/ronin/service_credential.rb +30 -0
- data/lib/ronin/{product.rb → software.rb} +12 -34
- data/lib/ronin/spec/database.rb +42 -0
- data/lib/ronin/{extensions/uri/http.rb → spec/ui/output.rb} +6 -8
- data/lib/ronin/target.rb +78 -0
- data/lib/ronin/tcp_port.rb +41 -0
- data/lib/ronin/udp_port.rb +37 -0
- data/lib/ronin/ui/async_console.rb +130 -0
- data/lib/ronin/ui/cli/cli.rb +147 -0
- data/lib/ronin/ui/cli/command.rb +316 -0
- data/lib/ronin/ui/cli/commands/campaigns.rb +130 -0
- data/lib/ronin/ui/{command_line → cli}/commands/console.rb +27 -22
- data/lib/ronin/ui/cli/commands/creds.rb +87 -0
- data/lib/ronin/ui/cli/commands/database.rb +179 -0
- data/lib/ronin/ui/cli/commands/emails.rb +108 -0
- data/lib/ronin/ui/cli/commands/exec.rb +124 -0
- data/lib/ronin/ui/{command_line → cli}/commands/help.rb +17 -14
- data/lib/ronin/ui/cli/commands/hosts.rb +177 -0
- data/lib/ronin/ui/cli/commands/ips.rb +172 -0
- data/lib/ronin/ui/cli/commands/repos.rb +236 -0
- data/lib/ronin/ui/cli/commands/urls.rb +144 -0
- data/lib/ronin/ui/cli/commands.rb +37 -0
- data/lib/ronin/ui/cli/engine_command.rb +104 -0
- data/lib/ronin/ui/{command_line → cli}/exceptions/unknown_command.rb +2 -2
- data/lib/ronin/{formatting/digest.rb → ui/cli/exceptions.rb} +2 -2
- data/lib/ronin/ui/cli/model_command.rb +247 -0
- data/lib/ronin/{formatting/binary.rb → ui/cli.rb} +3 -2
- data/lib/ronin/ui/console.rb +104 -109
- data/lib/ronin/ui/hexdump/extensions/file.rb +1 -1
- data/lib/ronin/ui/hexdump/extensions/kernel.rb +1 -1
- data/lib/ronin/ui/hexdump/extensions.rb +1 -1
- data/lib/ronin/ui/hexdump/hexdump.rb +5 -3
- data/lib/ronin/ui/hexdump.rb +1 -1
- data/lib/ronin/ui/output/helpers.rb +97 -9
- data/lib/ronin/ui/output/output.rb +30 -54
- data/lib/ronin/ui/output/terminal/color.rb +97 -0
- data/lib/ronin/ui/output/terminal/raw.rb +91 -0
- data/lib/ronin/{extensions/uri.rb → ui/output/terminal.rb} +3 -2
- data/lib/ronin/ui/output.rb +1 -1
- data/lib/ronin/ui/shell.rb +55 -90
- data/lib/ronin/ui.rb +1 -1
- data/lib/ronin/url.rb +343 -0
- data/lib/ronin/url_query_param.rb +40 -0
- data/lib/ronin/url_scheme.rb +37 -0
- data/lib/ronin/user_name.rb +45 -0
- data/lib/ronin/vendor.rb +40 -0
- data/lib/ronin/version.rb +2 -2
- data/lib/ronin/web_credential.rb +32 -0
- data/lib/ronin.rb +2 -2
- data/ronin.gemspec +10 -0
- data/spec/arch_spec.rb +1 -2
- data/spec/author_spec.rb +18 -2
- data/spec/cached_file_spec.rb +211 -0
- data/spec/campaign_spec.rb +30 -0
- data/spec/database_spec.rb +5 -0
- data/spec/email_address_spec.rb +35 -0
- data/spec/engine/buildable_spec.rb +51 -0
- data/spec/engine/classes/buildable_class.rb +15 -0
- data/spec/engine/classes/deployable_class.rb +13 -0
- data/spec/engine/classes/engine_class.rb +19 -0
- data/spec/engine/classes/verifiable_class.rb +19 -0
- data/spec/engine/deployable_spec.rb +55 -0
- data/spec/engine/engine_spec.rb +55 -0
- data/spec/engine/verifiable_spec.rb +117 -0
- data/spec/{static/helpers/static1/dir/two.txt → helpers/repos/hello/cache/.keep} +0 -0
- data/spec/helpers/repos/hello/lib/init.rb +1 -0
- data/spec/{platform/helpers/overlays → helpers/repos}/hello/lib/stuff/another_test.rb +0 -0
- data/spec/{platform/helpers/overlays → helpers/repos}/hello/lib/stuff/test.rb +0 -0
- data/spec/helpers/repos/hello/ronin.yml +7 -0
- data/spec/{static/helpers/static1/one.txt → helpers/repos/random/cache/.keep} +0 -0
- data/spec/helpers/repos/random/ronin.yml +7 -0
- data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +15 -0
- data/spec/helpers/repos/test1/ronin.yml +7 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +7 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/load_errors.rb +9 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +9 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +7 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +15 -0
- data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +9 -0
- data/spec/helpers/repos/test2/ronin.yml +7 -0
- data/spec/helpers/repositories.rb +11 -0
- data/spec/host_name_spec.rb +51 -0
- data/spec/installation_spec.rb +45 -0
- data/spec/ip_address.rb +67 -0
- data/spec/license_spec.rb +1 -2
- data/spec/mac_address_spec.rb +18 -0
- data/spec/model/cacheable_spec.rb +93 -0
- data/spec/model/has_description_spec.rb +45 -26
- data/spec/model/has_license_spec.rb +18 -17
- data/spec/model/has_name_spec.rb +35 -0
- data/spec/model/has_title_spec.rb +27 -0
- data/spec/model/model_spec.rb +27 -19
- data/spec/model/{classes → models}/basic_model.rb +0 -0
- data/spec/model/models/cacheable_model.rb +15 -0
- data/spec/model/{classes → models}/custom_model.rb +1 -1
- data/spec/model/{classes → models}/described_model.rb +0 -0
- data/spec/model/models/lazy_model.rb +9 -0
- data/spec/model/{classes → models}/licensed_model.rb +0 -0
- data/spec/model/models/named_model.rb +10 -0
- data/spec/model/models/titled_model.rb +10 -0
- data/spec/model/spec_helper.rb +22 -0
- data/spec/os_spec.rb +1 -2
- data/spec/password_spec.rb +35 -0
- data/spec/repository_spec.rb +291 -0
- data/spec/ronin_spec.rb +19 -5
- data/spec/software_spec.rb +23 -0
- data/spec/spec_helper.rb +35 -4
- data/spec/support/inflector_spec.rb +20 -0
- data/spec/ui/cli/classes/test_command.rb +11 -0
- data/spec/ui/cli/command_spec.rb +21 -0
- data/spec/ui/output_spec.rb +20 -17
- data/spec/url_spec.rb +111 -0
- data/spec/vendor_spec.rb +18 -0
- metadata +761 -421
- data/Manifest.txt +0 -290
- data/README.txt +0 -206
- data/bin/ronin-add +0 -12
- data/bin/ronin-install +0 -12
- data/bin/ronin-list +0 -12
- data/bin/ronin-remove +0 -12
- data/bin/ronin-uninstall +0 -12
- data/bin/ronin-update +0 -12
- data/lib/ronin/cacheable.rb +0 -307
- data/lib/ronin/code/reference.rb +0 -130
- data/lib/ronin/code/symbol_table.rb +0 -100
- data/lib/ronin/code/token.rb +0 -69
- data/lib/ronin/extensions/file.rb +0 -38
- data/lib/ronin/extensions/ip_addr.rb +0 -147
- data/lib/ronin/extensions/kernel.rb +0 -97
- data/lib/ronin/extensions/meta/object.rb +0 -24
- data/lib/ronin/extensions/string.rb +0 -119
- data/lib/ronin/extensions/uri/query_params.rb +0 -126
- data/lib/ronin/extensions.rb +0 -26
- data/lib/ronin/formatting/extensions/binary/file.rb +0 -35
- data/lib/ronin/formatting/extensions/binary/integer.rb +0 -106
- data/lib/ronin/formatting/extensions/binary/string.rb +0 -285
- data/lib/ronin/formatting/extensions/binary.rb +0 -22
- data/lib/ronin/formatting/extensions/digest/string.rb +0 -87
- data/lib/ronin/formatting/extensions/digest.rb +0 -21
- data/lib/ronin/formatting/extensions/http/string.rb +0 -88
- data/lib/ronin/formatting/extensions/http.rb +0 -21
- data/lib/ronin/formatting/extensions/text/array.rb +0 -77
- data/lib/ronin/formatting/extensions/text/string.rb +0 -162
- data/lib/ronin/formatting/extensions/text.rb +0 -22
- data/lib/ronin/formatting/extensions.rb +0 -22
- data/lib/ronin/formatting/http.rb +0 -21
- data/lib/ronin/formatting/text.rb +0 -21
- data/lib/ronin/formatting.rb +0 -25
- data/lib/ronin/network/esmtp.rb +0 -21
- data/lib/ronin/network/extensions/esmtp/net.rb +0 -96
- data/lib/ronin/network/extensions/esmtp.rb +0 -21
- data/lib/ronin/network/extensions/http/net.rb +0 -607
- data/lib/ronin/network/extensions/http.rb +0 -21
- data/lib/ronin/network/extensions/imap/net.rb +0 -119
- data/lib/ronin/network/extensions/imap.rb +0 -21
- data/lib/ronin/network/extensions/pop3/net.rb +0 -88
- data/lib/ronin/network/extensions/pop3.rb +0 -21
- data/lib/ronin/network/extensions/smtp/net.rb +0 -108
- data/lib/ronin/network/extensions/smtp.rb +0 -21
- data/lib/ronin/network/extensions/tcp/net.rb +0 -313
- data/lib/ronin/network/extensions/tcp.rb +0 -21
- data/lib/ronin/network/extensions/telnet/net.rb +0 -151
- data/lib/ronin/network/extensions/telnet.rb +0 -21
- data/lib/ronin/network/extensions/udp/net.rb +0 -224
- data/lib/ronin/network/extensions/udp.rb +0 -21
- data/lib/ronin/network/extensions.rb +0 -28
- data/lib/ronin/network/helpers/esmtp.rb +0 -129
- data/lib/ronin/network/helpers/imap.rb +0 -115
- data/lib/ronin/network/helpers/pop3.rb +0 -110
- data/lib/ronin/network/helpers/smtp.rb +0 -123
- data/lib/ronin/network/helpers/udp.rb +0 -197
- data/lib/ronin/network/helpers.rb +0 -29
- data/lib/ronin/network/http/http.rb +0 -214
- data/lib/ronin/network/http/proxy.rb +0 -308
- data/lib/ronin/network/http.rb +0 -23
- data/lib/ronin/network/smtp/email.rb +0 -142
- data/lib/ronin/network/smtp/smtp.rb +0 -67
- data/lib/ronin/network/smtp.rb +0 -23
- data/lib/ronin/network/tcp.rb +0 -21
- data/lib/ronin/network/telnet.rb +0 -108
- data/lib/ronin/network/udp.rb +0 -21
- data/lib/ronin/network.rb +0 -28
- data/lib/ronin/path.rb +0 -90
- data/lib/ronin/platform/extension.rb +0 -446
- data/lib/ronin/platform/extension_cache.rb +0 -143
- data/lib/ronin/platform/maintainer.rb +0 -69
- data/lib/ronin/platform/object_cache.rb +0 -124
- data/lib/ronin/platform/overlay.rb +0 -353
- data/lib/ronin/platform/overlay_cache.rb +0 -447
- data/lib/ronin/platform/platform.rb +0 -304
- data/lib/ronin/platform/ronin.rb +0 -97
- data/lib/ronin/platform/tasks/spec.rb +0 -9
- data/lib/ronin/platform.rb +0 -24
- data/lib/ronin/rpc/call.rb +0 -72
- data/lib/ronin/rpc/client.rb +0 -88
- data/lib/ronin/rpc/console.rb +0 -78
- data/lib/ronin/rpc/service.rb +0 -66
- data/lib/ronin/rpc/shell.rb +0 -63
- data/lib/ronin/rpc.rb +0 -24
- data/lib/ronin/scanners/exceptions/unknown_category.rb +0 -26
- data/lib/ronin/scanners/exceptions.rb +0 -21
- data/lib/ronin/scanners/scanner.rb +0 -295
- data/lib/ronin/scanners.rb +0 -22
- data/lib/ronin/static/finders.rb +0 -165
- data/lib/ronin/static/static.rb +0 -62
- data/lib/ronin/static.rb +0 -22
- data/lib/ronin/templates/erb.rb +0 -70
- data/lib/ronin/templates/template.rb +0 -130
- data/lib/ronin/templates.rb +0 -22
- data/lib/ronin/ui/command_line/command.rb +0 -216
- data/lib/ronin/ui/command_line/command_line.rb +0 -151
- data/lib/ronin/ui/command_line/commands/add.rb +0 -79
- data/lib/ronin/ui/command_line/commands/install.rb +0 -69
- data/lib/ronin/ui/command_line/commands/list.rb +0 -105
- data/lib/ronin/ui/command_line/commands/update.rb +0 -59
- data/lib/ronin/ui/command_line/exceptions.rb +0 -21
- data/lib/ronin/ui/command_line.rb +0 -22
- data/lib/ronin/ui/output/handler.rb +0 -121
- data/lib/ronin/yard/handlers/ruby/base.rb +0 -27
- data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +0 -45
- data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +0 -18
- data/lib/ronin/yard/handlers/ruby/has_handler.rb +0 -49
- data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +0 -41
- data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +0 -19
- data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +0 -34
- data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +0 -21
- data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +0 -41
- data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +0 -61
- data/lib/ronin/yard/handlers/ruby/legacy.rb +0 -26
- data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +0 -18
- data/lib/ronin/yard/handlers/ruby/property_handler.rb +0 -45
- data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +0 -66
- data/lib/ronin/yard/handlers/ruby.rb +0 -27
- data/lib/ronin/yard/handlers.rb +0 -24
- data/spec/cacheable_spec.rb +0 -150
- data/spec/classes/cacheable_model.rb +0 -15
- data/spec/code/classes/thing.rb +0 -17
- data/spec/code/reference_spec.rb +0 -63
- data/spec/code/symbol_table_spec.rb +0 -45
- data/spec/extensions/array_spec.rb +0 -34
- data/spec/extensions/classes/some_class.rb +0 -2
- data/spec/extensions/ip_addr_spec.rb +0 -44
- data/spec/extensions/kernel_spec.rb +0 -76
- data/spec/extensions/string_spec.rb +0 -103
- data/spec/extensions/uri/http_spec.rb +0 -9
- data/spec/extensions/uri/query_params_spec.rb +0 -46
- data/spec/formatting/binary/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/hexdump_repeated.txt +0 -6
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_ints.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_quads.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_ints.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_quads.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_hex_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_bytes.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_ints.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_quads.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_octal_shorts.txt +0 -17
- data/spec/formatting/binary/helpers/hexdumps/od_repeated.txt +0 -6
- data/spec/formatting/binary/helpers/hexdumps/repeated.bin +0 -1
- data/spec/formatting/binary/helpers/hexdumps.rb +0 -14
- data/spec/formatting/binary/integer_spec.rb +0 -131
- data/spec/formatting/binary/string_spec.rb +0 -251
- data/spec/formatting/digest/string_spec.rb +0 -80
- data/spec/formatting/http/string_spec.rb +0 -80
- data/spec/formatting/text/array_spec.rb +0 -64
- data/spec/formatting/text/string_spec.rb +0 -147
- data/spec/helpers/cacheable.rb +0 -7
- data/spec/helpers/contexts/ronin_cacheable_model.rb +0 -13
- data/spec/helpers/database.rb +0 -5
- data/spec/network/helpers/classes/test_helper.rb +0 -11
- data/spec/network/helpers/classes/uses_test_helper.rb +0 -10
- data/spec/network/helpers/helper_spec.rb +0 -25
- data/spec/network/http/http_spec.rb +0 -197
- data/spec/network/http/proxy_spec.rb +0 -116
- data/spec/path_spec.rb +0 -32
- data/spec/platform/extension_cache_spec.rb +0 -64
- data/spec/platform/extension_spec.rb +0 -73
- data/spec/platform/helpers/overlays/hello/hello/extension.rb +0 -7
- data/spec/platform/helpers/overlays/hello/lib/init.rb +0 -1
- data/spec/platform/helpers/overlays/hello/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/random/random/extension.rb +0 -7
- data/spec/platform/helpers/overlays/random/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/test1/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/test1/test/extension.rb +0 -7
- data/spec/platform/helpers/overlays/test2/ronin.xml +0 -26
- data/spec/platform/helpers/overlays/test2/test/extension.rb +0 -7
- data/spec/platform/helpers/overlays.rb +0 -18
- data/spec/platform/helpers/overlays.yaml.erb +0 -13
- data/spec/platform/maintainer_spec.rb +0 -30
- data/spec/platform/overlay_cache_spec.rb +0 -65
- data/spec/platform/overlay_spec.rb +0 -63
- data/spec/platform/platform_spec.rb +0 -22
- data/spec/platform/ronin_spec.rb +0 -34
- data/spec/product_spec.rb +0 -23
- data/spec/scanners/classes/another_scanner.rb +0 -16
- data/spec/scanners/classes/example_scanner.rb +0 -22
- data/spec/scanners/scanner_spec.rb +0 -148
- data/spec/static/classes/static_class.rb +0 -7
- data/spec/static/finders_spec.rb +0 -55
- data/spec/static/helpers/static.rb +0 -10
- data/spec/static/helpers/static2/dir/two.txt +0 -0
- data/spec/static/static_spec.rb +0 -25
- data/spec/templates/classes/example_erb.rb +0 -11
- data/spec/templates/classes/example_template.rb +0 -21
- data/spec/templates/erb_spec.rb +0 -20
- data/spec/templates/helpers/static/templates/_relative.erb +0 -1
- data/spec/templates/helpers/static/templates/example.erb +0 -1
- data/spec/templates/helpers/static.rb +0 -5
- data/spec/templates/template_spec.rb +0 -41
- data/spec/ui/command_line/classes/test_command.rb +0 -23
- data/spec/ui/command_line/command_spec.rb +0 -31
- data/static/ronin/platform/overlay.xsl +0 -203
- data/tasks/spec.rb +0 -10
- data/tasks/yard.rb +0 -18
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
@@ -1,119 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
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.
|
10
|
-
#
|
11
|
-
# This program 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 General Public License for more details.
|
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
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'ronin/network/imap'
|
22
|
-
|
23
|
-
require 'net/imap'
|
24
|
-
|
25
|
-
module Net
|
26
|
-
#
|
27
|
-
# Creates a connection to the IMAP server.
|
28
|
-
#
|
29
|
-
# @param [String] host
|
30
|
-
# The host to connect to.
|
31
|
-
#
|
32
|
-
# @param [Hash] options
|
33
|
-
# Additional options.
|
34
|
-
#
|
35
|
-
# @option options [Integer] :port (IMAP.default_port)
|
36
|
-
# The port the IMAP server is running on.
|
37
|
-
#
|
38
|
-
# @option options [String] :certs
|
39
|
-
# The path to the file containing CA certs of the server.
|
40
|
-
#
|
41
|
-
# @option options [Symbol] :auth
|
42
|
-
# The type of authentication to perform when connecting to the server.
|
43
|
-
# May be either +:login+ or +:cram_md5+.
|
44
|
-
#
|
45
|
-
# @option options [String] :user
|
46
|
-
# The user to authenticate as when connecting to the server.
|
47
|
-
#
|
48
|
-
# @option options [String] :password
|
49
|
-
# The password to authenticate with when connecting to the server.
|
50
|
-
#
|
51
|
-
# @yield [session]
|
52
|
-
# If a _block_ is given, it will be passed the newly created IMAP
|
53
|
-
# session.
|
54
|
-
#
|
55
|
-
# @yieldparam [Net::IMAP] session
|
56
|
-
# The newly created IMAP session object.
|
57
|
-
#
|
58
|
-
# @return [Net::IMAP]
|
59
|
-
# The newly created IMAP session object.
|
60
|
-
#
|
61
|
-
def Net.imap_connect(host,options={},&block)
|
62
|
-
port = (options[:port] || Ronin::Net::IMAP.default_port)
|
63
|
-
certs = options[:certs]
|
64
|
-
auth = options[:auth]
|
65
|
-
user = options[:user]
|
66
|
-
passwd = options[:password]
|
67
|
-
|
68
|
-
if options[:ssl]
|
69
|
-
ssl = true
|
70
|
-
ssl_certs = options[:ssl][:certs]
|
71
|
-
ssl_verify = options[:ssl][:verify]
|
72
|
-
else
|
73
|
-
ssl = false
|
74
|
-
ssl_verify = false
|
75
|
-
end
|
76
|
-
|
77
|
-
sess = Net::IMAP.new(host,port,ssl,ssl_certs,ssl_verify)
|
78
|
-
|
79
|
-
if user
|
80
|
-
if auth==:cram_md5
|
81
|
-
sess.authenticate('CRAM-MD5',user,passwd)
|
82
|
-
else
|
83
|
-
sess.authenticate('LOGIN',user,passwd)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
block.call(sess) if block
|
88
|
-
return sess
|
89
|
-
end
|
90
|
-
|
91
|
-
#
|
92
|
-
# Starts an IMAP session with the IMAP server.
|
93
|
-
#
|
94
|
-
# @param [String] host
|
95
|
-
# The host to connect to.
|
96
|
-
#
|
97
|
-
# @param [Hash] options
|
98
|
-
# Additional options.
|
99
|
-
#
|
100
|
-
# @yield [session]
|
101
|
-
# If a _block_ is given, it will be passed the newly created IMAP
|
102
|
-
# session. After the _block_ has returned, the session will be closed.
|
103
|
-
#
|
104
|
-
# @yieldparam [Net::IMAP] session
|
105
|
-
# The newly created IMAP session object.
|
106
|
-
#
|
107
|
-
# @see Net.imap_connect
|
108
|
-
#
|
109
|
-
def Net.imap_session(host,options={},&block)
|
110
|
-
Net.imap_connect(host,options) do |sess|
|
111
|
-
block.call(sess) if block
|
112
|
-
sess.logout if options[:user]
|
113
|
-
sess.close
|
114
|
-
sess.disconnect
|
115
|
-
end
|
116
|
-
|
117
|
-
return nil
|
118
|
-
end
|
119
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
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.
|
10
|
-
#
|
11
|
-
# This program 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 General Public License for more details.
|
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
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'ronin/network/extensions/imap/net'
|
@@ -1,88 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
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.
|
10
|
-
#
|
11
|
-
# This program 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 General Public License for more details.
|
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
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'ronin/network/pop3'
|
22
|
-
|
23
|
-
require 'net/pop'
|
24
|
-
|
25
|
-
module Net
|
26
|
-
#
|
27
|
-
# Creates a connection to the POP3 server.
|
28
|
-
#
|
29
|
-
# @param [String] host
|
30
|
-
# The host to connect to.
|
31
|
-
#
|
32
|
-
# @param [Hash] options
|
33
|
-
# Additional options.
|
34
|
-
#
|
35
|
-
# @option options [Integer] :port (Ronin::Network::POP3.default_port)
|
36
|
-
# The port the POP3 server is running on.
|
37
|
-
#
|
38
|
-
# @option options [String] :user
|
39
|
-
# The user to authenticate with when connecting to the POP3 server.
|
40
|
-
#
|
41
|
-
# @option options [String] :password
|
42
|
-
# The password to authenticate with when connecting to the POP3 server.
|
43
|
-
#
|
44
|
-
# @yield [session]
|
45
|
-
# If a _block_ is given, it will be passed the newly created POP3
|
46
|
-
# session.
|
47
|
-
#
|
48
|
-
# @yieldparam [Net::POP3] session
|
49
|
-
# The newly created POP3 session.
|
50
|
-
#
|
51
|
-
# @return [Net::POP3]
|
52
|
-
# The newly created POP3 session.
|
53
|
-
#
|
54
|
-
def Net.pop3_connect(host,options={},&block)
|
55
|
-
port = (options[:port] || Ronin::Network::POP3.default_port)
|
56
|
-
user = options[:user]
|
57
|
-
password = options[:password]
|
58
|
-
|
59
|
-
sess Net::POP3.start(host,port,user,password)
|
60
|
-
block.call(sess) if block
|
61
|
-
return sess
|
62
|
-
end
|
63
|
-
|
64
|
-
#
|
65
|
-
# Starts a session with the POP3 server.
|
66
|
-
#
|
67
|
-
# @param [String] host
|
68
|
-
# The host to connect to.
|
69
|
-
#
|
70
|
-
# @param [Hash] options
|
71
|
-
# Additional options.
|
72
|
-
#
|
73
|
-
# @yield [session]
|
74
|
-
# If a _block_ is given, it will be passed the newly created POP3
|
75
|
-
# session. After the _block_ has returned, the session will be closed.
|
76
|
-
#
|
77
|
-
# @yieldparam [Net::POP3] session
|
78
|
-
# The newly created POP3 session.
|
79
|
-
#
|
80
|
-
def Net.pop3_session(host,options={},&block)
|
81
|
-
Net.pop3_connect(host,options) do |sess|
|
82
|
-
block.call(sess) if block
|
83
|
-
sess.finish
|
84
|
-
end
|
85
|
-
|
86
|
-
return nil
|
87
|
-
end
|
88
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
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.
|
10
|
-
#
|
11
|
-
# This program 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 General Public License for more details.
|
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
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'ronin/network/extensions/pop3/net'
|
@@ -1,108 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
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.
|
10
|
-
#
|
11
|
-
# This program 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 General Public License for more details.
|
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
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'ronin/network/smtp/email'
|
22
|
-
|
23
|
-
require 'net/smtp'
|
24
|
-
|
25
|
-
module Net
|
26
|
-
#
|
27
|
-
# @see Ronin::Network::SMTP.message
|
28
|
-
#
|
29
|
-
def Net.smtp_message(options={},&block)
|
30
|
-
Ronin::Network::SMTP.message(options,&block)
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Creates a connection to the SMTP server.
|
35
|
-
#
|
36
|
-
# @param [String] host
|
37
|
-
# The host to connect to.
|
38
|
-
#
|
39
|
-
# @param [Hash] options
|
40
|
-
# Additional options.
|
41
|
-
#
|
42
|
-
# @option options [Integer] :port (Ronin::Network::SMTP.default_port)
|
43
|
-
# The port to connect to.
|
44
|
-
#
|
45
|
-
# @option options [String] :helo
|
46
|
-
# The HELO domain.
|
47
|
-
#
|
48
|
-
# @option options [Symbol] :auth
|
49
|
-
# The type of authentication to use. Can be either +:login+, +:plain+,
|
50
|
-
# or +:cram_md5+.
|
51
|
-
#
|
52
|
-
# @option options [String] :user
|
53
|
-
# The user-name to authenticate with.
|
54
|
-
#
|
55
|
-
# @option options [String] :password
|
56
|
-
# The password to authenticate with.
|
57
|
-
#
|
58
|
-
# @yield [session]
|
59
|
-
# If a block is given, it will be passed an SMTP session object.
|
60
|
-
#
|
61
|
-
# @yieldparam [Net::SMTP] session
|
62
|
-
# The SMTP session.
|
63
|
-
#
|
64
|
-
# @return [Net::SMTP]
|
65
|
-
# The SMTP session.
|
66
|
-
#
|
67
|
-
def Net.smtp_connect(host,options={},&block)
|
68
|
-
port = (options[:port] || Ronin::Network::SMTP.default_port)
|
69
|
-
|
70
|
-
helo = options[:helo]
|
71
|
-
|
72
|
-
auth = options[:auth]
|
73
|
-
user = options[:user]
|
74
|
-
password = options[:password]
|
75
|
-
|
76
|
-
sess = Net::SMTP.start(host,port,helo,user,password,auth)
|
77
|
-
|
78
|
-
block.call(sess) if block
|
79
|
-
return sess
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# Starts a session with the SMTP server.
|
84
|
-
#
|
85
|
-
# @param [String] host
|
86
|
-
# The host to connect to.
|
87
|
-
#
|
88
|
-
# @param [Hash] options
|
89
|
-
# Additional options.
|
90
|
-
#
|
91
|
-
# @yield [session]
|
92
|
-
# If a block is given, it will be passed an SMTP session object.
|
93
|
-
# After the block has returned, the session will be closed.
|
94
|
-
#
|
95
|
-
# @yieldparam [Net::SMTP] session
|
96
|
-
# The SMTP session.
|
97
|
-
#
|
98
|
-
# @see Net.smtp_connect
|
99
|
-
#
|
100
|
-
def Net.smtp_session(host,options={},&block)
|
101
|
-
Net.smtp_connect(host,options) do |sess|
|
102
|
-
block.call(sess) if block
|
103
|
-
sess.finish
|
104
|
-
end
|
105
|
-
|
106
|
-
return nil
|
107
|
-
end
|
108
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
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.
|
10
|
-
#
|
11
|
-
# This program 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 General Public License for more details.
|
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
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'ronin/network/extensions/smtp/net'
|
@@ -1,313 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
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.
|
10
|
-
#
|
11
|
-
# This program 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 General Public License for more details.
|
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
|
19
|
-
#
|
20
|
-
|
21
|
-
require 'socket'
|
22
|
-
|
23
|
-
module Net
|
24
|
-
#
|
25
|
-
# Creates a new TCPSocket object with the specified _host_, _port_
|
26
|
-
# and the given _local_host_ and _local_port_.
|
27
|
-
#
|
28
|
-
# @param [String] host
|
29
|
-
# The host to connect to.
|
30
|
-
#
|
31
|
-
# @param [Integer] port
|
32
|
-
# The port to connect to.
|
33
|
-
#
|
34
|
-
# @param [String] local_host
|
35
|
-
# The local host to bind to.
|
36
|
-
#
|
37
|
-
# @param [Integer] local_port
|
38
|
-
# The local port to bind to.
|
39
|
-
#
|
40
|
-
# @yield [socket]
|
41
|
-
# If a block is given, it will be passed the newly created socket.
|
42
|
-
#
|
43
|
-
# @yieldparam [TCPsocket] socket
|
44
|
-
# The newly created TCPSocket object.
|
45
|
-
#
|
46
|
-
# @return [TCPSocket]
|
47
|
-
# The newly created TCPSocket object.
|
48
|
-
#
|
49
|
-
# @example
|
50
|
-
# Net.tcp_connect('www.hackety.org',80) # => TCPSocket
|
51
|
-
#
|
52
|
-
# @example
|
53
|
-
# Net.tcp_connect('www.wired.com',80) do |sock|
|
54
|
-
# sock.write("GET /\n\n")
|
55
|
-
# puts sock.readlines
|
56
|
-
# sock.close
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
def Net.tcp_connect(host,port,local_host=nil,local_port=nil,&block)
|
60
|
-
sock = TCPSocket.new(host,port,local_host,local_port)
|
61
|
-
block.call(sock) if block
|
62
|
-
|
63
|
-
return sock
|
64
|
-
end
|
65
|
-
|
66
|
-
#
|
67
|
-
# Creates a new TCPSocket object with the specified _host_, _port_, and
|
68
|
-
# the given _local_host_ and _local_port_. The specified _data_ will
|
69
|
-
# then be written to the newly created TCPSocket.
|
70
|
-
#
|
71
|
-
# @param [String] data
|
72
|
-
# The data to send through the connection.
|
73
|
-
#
|
74
|
-
# @param [String] host
|
75
|
-
# The host to connect to.
|
76
|
-
#
|
77
|
-
# @param [Integer] port
|
78
|
-
# The port to connect to.
|
79
|
-
#
|
80
|
-
# @param [String] local_host
|
81
|
-
# The local host to bind to.
|
82
|
-
#
|
83
|
-
# @param [Integer] local_port
|
84
|
-
# The local port to bind to.
|
85
|
-
#
|
86
|
-
# @yield [socket]
|
87
|
-
# If a block is given, it will be passed the newly created socket.
|
88
|
-
#
|
89
|
-
# @yieldparam [TCPsocket] socket
|
90
|
-
# The newly created TCPSocket object.
|
91
|
-
#
|
92
|
-
def Net.tcp_connect_and_send(data,host,port,local_host=nil,local_port=nil,&block)
|
93
|
-
Net.tcp_connect(host,port,local_host,local_port) do |sock|
|
94
|
-
sock.write(data)
|
95
|
-
|
96
|
-
block.call(sock) if block
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
#
|
101
|
-
# Creates a new TCPSocket object with the specified _host_, _port_
|
102
|
-
# and the given _local_host_ and _local_port_. If _block_ is given, it
|
103
|
-
# will be passed the newly created TCPSocket object. After the TCPSocket
|
104
|
-
# object has been passed to the given _block_ it will be closed.
|
105
|
-
#
|
106
|
-
# @param [String] host
|
107
|
-
# The host to connect to.
|
108
|
-
#
|
109
|
-
# @param [Integer] port
|
110
|
-
# The port to connect to.
|
111
|
-
#
|
112
|
-
# @param [String] local_host
|
113
|
-
# The local host to bind to.
|
114
|
-
#
|
115
|
-
# @param [Integer] local_port
|
116
|
-
# The local port to bind to.
|
117
|
-
#
|
118
|
-
# @yield [socket]
|
119
|
-
# If a block is given, it will be passed the newly created socket.
|
120
|
-
# After the block has returned, the socket will then be closed.
|
121
|
-
#
|
122
|
-
# @yieldparam [TCPsocket] socket
|
123
|
-
# The newly created TCPSocket object.
|
124
|
-
#
|
125
|
-
def Net.tcp_session(host,port,local_host=nil,local_port=nil,&block)
|
126
|
-
Net.tcp_connect(host,port,local_host,local_port) do |sock|
|
127
|
-
block.call(sock) if block
|
128
|
-
sock.close
|
129
|
-
end
|
130
|
-
|
131
|
-
return nil
|
132
|
-
end
|
133
|
-
|
134
|
-
#
|
135
|
-
# Connects to the specified _host_ and _port_ with the given
|
136
|
-
# _local_host_ and _local_port_, reads the banner then closes the
|
137
|
-
# connection.
|
138
|
-
#
|
139
|
-
# @param [String] host
|
140
|
-
# The host to connect to.
|
141
|
-
#
|
142
|
-
# @param [Integer] port
|
143
|
-
# The port to connect to.
|
144
|
-
#
|
145
|
-
# @param [String] local_host
|
146
|
-
# The local host to bind to.
|
147
|
-
#
|
148
|
-
# @param [Integer] local_port
|
149
|
-
# The local port to bind to.
|
150
|
-
#
|
151
|
-
# @yield [banner]
|
152
|
-
# If a block is given, it will be passed the grabbed banner.
|
153
|
-
#
|
154
|
-
# @yieldparam [String] banner
|
155
|
-
# The grabbed banner.
|
156
|
-
#
|
157
|
-
# @return [String]
|
158
|
-
# The grabbed banner.
|
159
|
-
#
|
160
|
-
# @example
|
161
|
-
# Net.tcp_banner('pop.gmail.com',25)
|
162
|
-
# # => "220 mx.google.com ESMTP c20sm3096959rvf.1"
|
163
|
-
#
|
164
|
-
def Net.tcp_banner(host,port,local_host=nil,local_port=nil,&block)
|
165
|
-
banner = nil
|
166
|
-
|
167
|
-
Net.tcp_session(host,port,local_host,local_port) do |sock|
|
168
|
-
banner = sock.readline.strip
|
169
|
-
end
|
170
|
-
|
171
|
-
block.call(banner) if block
|
172
|
-
return banner
|
173
|
-
end
|
174
|
-
|
175
|
-
#
|
176
|
-
# Connects to the specified _host_ and _port_ with the given _local_host_
|
177
|
-
# and _local_port_, sends the specified _data_ and then closes the
|
178
|
-
# connection.
|
179
|
-
#
|
180
|
-
# @param [String] data
|
181
|
-
# The data to send through the connection.
|
182
|
-
#
|
183
|
-
# @param [String] host
|
184
|
-
# The host to connect to.
|
185
|
-
#
|
186
|
-
# @param [Integer] port
|
187
|
-
# The port to connect to.
|
188
|
-
#
|
189
|
-
# @param [String] local_host
|
190
|
-
# The local host to bind to.
|
191
|
-
#
|
192
|
-
# @param [Integer] local_port
|
193
|
-
# The local port to bind to.
|
194
|
-
#
|
195
|
-
# @return [true]
|
196
|
-
# The data was successfully sent.
|
197
|
-
#
|
198
|
-
# @example
|
199
|
-
# buffer = "GET /" + ('A' * 4096) + "\n\r"
|
200
|
-
# Net.tcp_send(buffer,'victim.com',80)
|
201
|
-
# # => true
|
202
|
-
#
|
203
|
-
def Net.tcp_send(data,host,port,local_host=nil,local_port=nil)
|
204
|
-
Net.tcp_session(host,port,local_host,local_port) do |sock|
|
205
|
-
sock.write(data)
|
206
|
-
end
|
207
|
-
|
208
|
-
return true
|
209
|
-
end
|
210
|
-
|
211
|
-
#
|
212
|
-
# Creates a new TCPServer listening on the specified _host_ and _port_.
|
213
|
-
#
|
214
|
-
# @param [Integer] port
|
215
|
-
# The local port to listen on.
|
216
|
-
#
|
217
|
-
# @param [String] host
|
218
|
-
# The host to bind to.
|
219
|
-
#
|
220
|
-
# @return [TCPServer]
|
221
|
-
# The new TCP server.
|
222
|
-
#
|
223
|
-
# @example
|
224
|
-
# Net.tcp_server(1337)
|
225
|
-
#
|
226
|
-
# @since 0.3.0
|
227
|
-
#
|
228
|
-
def Net.tcp_server(port,host='0.0.0.0',&block)
|
229
|
-
server = TCPServer.new(host,port)
|
230
|
-
server.listen(3)
|
231
|
-
|
232
|
-
block.call(server) if block
|
233
|
-
return server
|
234
|
-
end
|
235
|
-
|
236
|
-
#
|
237
|
-
# Creates a new TCPServer listening on the specified _host_ and _port_,
|
238
|
-
# passing it to the given _block_ and then closing the server.
|
239
|
-
#
|
240
|
-
# @param [Integer] port
|
241
|
-
# The local port to bind to.
|
242
|
-
#
|
243
|
-
# @param [String] host
|
244
|
-
# The host to bind to.
|
245
|
-
#
|
246
|
-
# @yield [server]
|
247
|
-
# The block which will be called after the _server_ has been created.
|
248
|
-
# After the block has finished, the _server_ will be closed.
|
249
|
-
#
|
250
|
-
# @yieldparam [TCPServer] server
|
251
|
-
# The newly created TCP server.
|
252
|
-
#
|
253
|
-
# @return [nil]
|
254
|
-
#
|
255
|
-
# @example
|
256
|
-
# Net.tcp_server_session(1337) do |server|
|
257
|
-
# client1 = server.accept
|
258
|
-
# client2 = server.accept
|
259
|
-
#
|
260
|
-
# client2.write(server.read_line)
|
261
|
-
#
|
262
|
-
# client1.close
|
263
|
-
# client2.close
|
264
|
-
# end
|
265
|
-
#
|
266
|
-
# @since 0.3.0
|
267
|
-
#
|
268
|
-
def Net.tcp_server_session(port,host='0.0.0.0',&block)
|
269
|
-
server = Net.tcp_server(port,host,&block)
|
270
|
-
server.close()
|
271
|
-
return nil
|
272
|
-
end
|
273
|
-
|
274
|
-
#
|
275
|
-
# Creates a new TCPServer listening on the specified _host_ and _port_,
|
276
|
-
# then accepts only one client.
|
277
|
-
#
|
278
|
-
# @param [Integer] port
|
279
|
-
# The local port to listen on.
|
280
|
-
#
|
281
|
-
# @param [String] host
|
282
|
-
# The host to bind to.
|
283
|
-
#
|
284
|
-
# @yield [client]
|
285
|
-
# The block which will be passed the newly connected _client_.
|
286
|
-
# After the block has finished, the _client_ and the server will be
|
287
|
-
# closed.
|
288
|
-
#
|
289
|
-
# @yieldparam [TCPSocket] client
|
290
|
-
# The newly connected client.
|
291
|
-
#
|
292
|
-
# @return [nil]
|
293
|
-
#
|
294
|
-
# @example
|
295
|
-
# Net.tcp_single_server(1337) do |client|
|
296
|
-
# client.puts 'lol'
|
297
|
-
# end
|
298
|
-
#
|
299
|
-
# @since 0.3.0
|
300
|
-
#
|
301
|
-
def Net.tcp_single_server(port,host='0.0.0.0',&block)
|
302
|
-
server = TCPServer.new(host,port)
|
303
|
-
server.listen(1)
|
304
|
-
|
305
|
-
client = server.accept
|
306
|
-
|
307
|
-
block.call(client) if block
|
308
|
-
|
309
|
-
client.close
|
310
|
-
server.close
|
311
|
-
return nil
|
312
|
-
end
|
313
|
-
end
|