ronin-masscan 0.1.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.document +4 -0
  3. data/.github/workflows/ruby.yml +47 -0
  4. data/.gitignore +14 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +11 -0
  7. data/.ruby-version +1 -0
  8. data/.yardopts +1 -0
  9. data/COPYING.txt +165 -0
  10. data/ChangeLog.md +10 -0
  11. data/Gemfile +40 -0
  12. data/README.md +204 -0
  13. data/Rakefile +43 -0
  14. data/bin/ronin-masscan +34 -0
  15. data/data/completions/ronin-masscan +83 -0
  16. data/data/templates/script.rb.erb +43 -0
  17. data/gemspec.yml +42 -0
  18. data/lib/ronin/masscan/cli/command.rb +40 -0
  19. data/lib/ronin/masscan/cli/commands/completion.rb +61 -0
  20. data/lib/ronin/masscan/cli/commands/convert.rb +133 -0
  21. data/lib/ronin/masscan/cli/commands/dump.rb +194 -0
  22. data/lib/ronin/masscan/cli/commands/grep.rb +235 -0
  23. data/lib/ronin/masscan/cli/commands/import.rb +94 -0
  24. data/lib/ronin/masscan/cli/commands/new.rb +203 -0
  25. data/lib/ronin/masscan/cli/commands/print.rb +162 -0
  26. data/lib/ronin/masscan/cli/commands/scan.rb +206 -0
  27. data/lib/ronin/masscan/cli/filtering_options.rb +312 -0
  28. data/lib/ronin/masscan/cli/importable.rb +68 -0
  29. data/lib/ronin/masscan/cli/port_list.rb +102 -0
  30. data/lib/ronin/masscan/cli.rb +50 -0
  31. data/lib/ronin/masscan/converter.rb +129 -0
  32. data/lib/ronin/masscan/converters/csv.rb +108 -0
  33. data/lib/ronin/masscan/converters/json.rb +142 -0
  34. data/lib/ronin/masscan/converters.rb +54 -0
  35. data/lib/ronin/masscan/exceptions.rb +47 -0
  36. data/lib/ronin/masscan/importer.rb +214 -0
  37. data/lib/ronin/masscan/root.rb +28 -0
  38. data/lib/ronin/masscan/version.rb +26 -0
  39. data/lib/ronin/masscan.rb +114 -0
  40. data/man/ronin-masscan-completion.1 +76 -0
  41. data/man/ronin-masscan-completion.1.md +78 -0
  42. data/man/ronin-masscan-convert.1 +37 -0
  43. data/man/ronin-masscan-convert.1.md +40 -0
  44. data/man/ronin-masscan-dump.1 +116 -0
  45. data/man/ronin-masscan-dump.1.md +94 -0
  46. data/man/ronin-masscan-grep.1 +56 -0
  47. data/man/ronin-masscan-grep.1.md +59 -0
  48. data/man/ronin-masscan-import.1 +52 -0
  49. data/man/ronin-masscan-import.1.md +57 -0
  50. data/man/ronin-masscan-new.1 +78 -0
  51. data/man/ronin-masscan-new.1.md +70 -0
  52. data/man/ronin-masscan-print.1 +53 -0
  53. data/man/ronin-masscan-print.1.md +56 -0
  54. data/man/ronin-masscan-scan.1 +86 -0
  55. data/man/ronin-masscan-scan.1.md +84 -0
  56. data/man/ronin-masscan.1 +61 -0
  57. data/man/ronin-masscan.1.md +58 -0
  58. data/ronin-masscan.gemspec +62 -0
  59. data/scripts/setup +161 -0
  60. metadata +168 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e0c3a282cb33716e8205bce6f3a3730995665d1c1f2c1a4eae901304567aa4d0
4
+ data.tar.gz: e27dfa90ab3baa821ea5571f43646cbdc52d1c7effdade086cb22ba62342a3d8
5
+ SHA512:
6
+ metadata.gz: 8f741731aa217b4f3ce680f7b049fa86d70f9a31e936ba14578fe73b9e9e0e88e0de19afcde7b561787e884a1cbebee96ef83ef0c171286cbf666f127bd345e1
7
+ data.tar.gz: ce1443615a48d87cad8da2f05bd0cde71c09f39008f749d4d1869f71e74c9a827a2c940640f88d7f7bd635e57e58c7c830c9f23846caa30d018d5787a81a6112
data/.document ADDED
@@ -0,0 +1,4 @@
1
+ lib/**/*.rb
2
+ -
3
+ ChangeLog.md
4
+ COPYING.txt
@@ -0,0 +1,47 @@
1
+ name: CI
2
+
3
+ on: [ push, pull_request ]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby:
12
+ - '3.0'
13
+ - '3.1'
14
+ - '3.2'
15
+ - '3.3'
16
+ - jruby
17
+ - truffleruby
18
+ name: Ruby ${{ matrix.ruby }}
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ # - name: Install dependencies
27
+ # run: |
28
+ # sudo apt update -y && \
29
+ # sudo apt install -y --no-install-recommends --no-install-suggests FIXME
30
+ - name: Install dependencies
31
+ run: bundle install --jobs 4 --retry 3
32
+ - name: Run tests
33
+ run: bundle exec rake test
34
+
35
+ # rubocop linting
36
+ rubocop:
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - name: Set up Ruby
41
+ uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: 3.0
44
+ - name: Install dependencies
45
+ run: bundle install --jobs 4 --retry 3
46
+ - name: Run rubocop
47
+ run: bundle exec rubocop --parallel
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /coverage
2
+ /data/completions/ronin-masscan
3
+ /doc
4
+ /pkg
5
+ /man/*.[1-9]
6
+ /vendor/bundle
7
+ /Gemfile.lock
8
+ /.bundle
9
+ /.yardoc
10
+ .DS_Store
11
+ *.db
12
+ *.log
13
+ *.swp
14
+ *~
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 3.1
5
+
6
+ inherit_gem:
7
+ rubocop-ronin: rubocop.yml
8
+
9
+ #
10
+ # ronin-FIXME specific exceptions
11
+ #
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.1
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title 'Ronin::Masscan Documentation' --protected
data/COPYING.txt ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/ChangeLog.md ADDED
@@ -0,0 +1,10 @@
1
+ ### 0.1.0 / 2024-XX-XX
2
+
3
+ * Initial release:
4
+ * Supports automating `masscan` using [ruby-masscan].
5
+ * Supports parsing and filtering masscan scan files.
6
+ * Supports converting masscan scan files into JSON or CSV.
7
+ * Supports importing masscan scan files into the [ronin-db] database.
8
+
9
+ [ruby-masscan]: https://github.com/postmodern/ruby-masscan#readme
10
+ [ronin-db]: https://github.com/ronin-rb/ronin-db#readme
data/Gemfile ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ platform :jruby do
8
+ gem 'jruby-openssl', '~> 0.7'
9
+ gem 'activerecord-jdbcsqlite3-adapter', '~> 70.0'
10
+ gem 'activerecord', '< 7.1.0'
11
+ end
12
+
13
+ # Ronin dependencies
14
+ # gem 'ronin-core', '~> 0.2', github: 'ronin-rb/ronin-core',
15
+ # branch: 'main'
16
+ # gem 'ronin-db', '~> 0.2', github: 'ronin-rb/ronin-db',
17
+ # branch: 'main'
18
+
19
+ group :development do
20
+ gem 'rake'
21
+ gem 'rubygems-tasks', '~> 0.2'
22
+
23
+ gem 'rspec', '~> 3.0'
24
+ gem 'simplecov', '~> 0.20'
25
+
26
+ gem 'kramdown', '~> 2.0'
27
+ gem 'kramdown-man', '~> 1.0'
28
+
29
+ gem 'redcarpet', platform: :mri
30
+ gem 'yard', '~> 0.9'
31
+ gem 'yard-spellcheck', require: false
32
+
33
+ gem 'dead_end', require: false
34
+ gem 'sord', require: false, platform: :mri
35
+ gem 'stackprof', require: false, platform: :mri
36
+ gem 'rubocop', require: false, platform: :mri
37
+ gem 'rubocop-ronin', require: false, platform: :mri
38
+
39
+ gem 'command_kit-completion', '~> 0.2', require: false
40
+ end
data/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # ronin-masscan
2
+
3
+ [![CI](https://github.com/ronin-rb/ronin-masscan/actions/workflows/ruby.yml/badge.svg)](https://github.com/ronin-rb/ronin-masscan/actions/workflows/ruby.yml)
4
+ [![Code Climate](https://codeclimate.com/github/ronin-rb/ronin-masscan.svg)](https://codeclimate.com/github/ronin-rb/ronin-masscan)
5
+
6
+ * [Website](https://ronin-rb.dev/)
7
+ * [Source](https://github.com/ronin-rb/ronin-masscan)
8
+ * [Issues](https://github.com/ronin-rb/ronin-masscan/issues)
9
+ * [Documentation](https://ronin-rb.dev/docs/ronin-masscan)
10
+ * [Discord](https://discord.gg/6WAb3PsVX9) |
11
+ [Mastodon](https://infosec.exchange/@ronin_rb)
12
+
13
+ ## Description
14
+
15
+ ronin-masscan is a Ruby library and CLI for working with masscan.
16
+
17
+ ## Features
18
+
19
+ * Supports automating `masscan` using [ruby-masscan].
20
+ * Supports parsing and filtering masscan scan files.
21
+ * Supports converting masscan scan files into JSON or CSV.
22
+ * Supports importing masscan scan files into the [ronin-db] database.
23
+
24
+ ## Synopsis
25
+
26
+ ```
27
+ Usage: ronin-masscan [options]
28
+
29
+ Options:
30
+ -V, --version Prints the version and exits
31
+ -h, --help Print help information
32
+
33
+ Arguments:
34
+ [COMMAND] The command name to run
35
+ [ARGS ...] Additional arguments for the command
36
+
37
+ Commands:
38
+ completion
39
+ convert
40
+ dump
41
+ grep
42
+ help
43
+ import
44
+ new
45
+ print
46
+ scan
47
+ ```
48
+
49
+ Import a binary `masscan` scan file:
50
+
51
+ ```shell
52
+ $ ronin-masscan import masscan.bin
53
+ ```
54
+
55
+ Perform a masscan scan and import it's results into the [ronin-db]\:
56
+
57
+ ```shell
58
+ $ ronin-masscan scan --import -- 192.168.1.1 -p22,25,80,443
59
+ ```
60
+
61
+ Parse and filter an nmap XML scan file:
62
+
63
+ Import a JSON `masscan` scan file:
64
+
65
+ ```shell
66
+ $ ronin-masscan import masscan.json
67
+ ```
68
+
69
+ Dumps a masscan scan file to a list of `IP:PORT` pairs:
70
+
71
+ ```shell
72
+ $ ronin-masscan dump --print-ip-ports masscan.bin
73
+ ```
74
+
75
+ Dump a masscan scan file to a list of `HOST:PORT` pairs:
76
+
77
+ ```shell
78
+ $ ronin-masscan dump --print-host-ports masscan.bin
79
+ ```
80
+
81
+ Dump a masscan scan file to a list of `http`://` or `https://` URIs:
82
+
83
+ ```shell
84
+ $ ronin-masscan dump --print-uris masscan.bin
85
+ ```
86
+
87
+ Convert a binary `masscan` scan file to CSV:
88
+
89
+ ```shell
90
+ $ ronin-masscan convert masscan.bin masscan.csv
91
+ ```
92
+
93
+ Convert a binary `masscan` scan file to JSON:
94
+
95
+ ```shell
96
+ $ ronin-masscan convert masscan.bin masscan.json
97
+ ```
98
+
99
+ Generate a new masscan scanner Ruby script:
100
+
101
+ ```shell
102
+ $ ronin-masscan new scanner.rb --ips '192.168.1.*' --ports 22,80,443,8000-9000
103
+ ```
104
+
105
+ Generate a new masscan output file parser script:
106
+
107
+ ```shell
108
+ $ ronin-masscan new parser.rb --parser --xml-file path/to/masscan.bin --printing
109
+ ```
110
+
111
+ ## Examples
112
+
113
+ ```ruby
114
+ require 'ronin/masscan'
115
+
116
+ output_file = Ronin::Masscan.scan('192.168.1.1', ports: [80,443])
117
+ # => #<Masscan::OutputFile:...>
118
+
119
+ output_file = Ronin::Masscan.scan do |masscan|
120
+ masscan.ports = [80,443]
121
+ masscan.ips = '192.168.1.1'
122
+ end
123
+ # => #<Masscan::OutputFile:...>
124
+ ```
125
+
126
+ Accessing the masscan scan data:
127
+
128
+ ```ruby
129
+ output_file.each do |record|
130
+ p record
131
+ end
132
+ ```
133
+
134
+ ```
135
+ #<struct Masscan::Status status=:open, protocol=:tcp, port=80, reason=[:syn, :ack], ttl=54, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:33 -0700, mac=nil>
136
+ #<struct Masscan::Status status=:open, protocol=:tcp, port=443, reason=[:syn, :ack], ttl=54, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:33 -0700, mac=nil>
137
+ #<struct Masscan::Status status=:open, protocol=:icmp, port=0, reason=[], ttl=54, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:33 -0700, mac=nil>
138
+ #<struct Masscan::Banner protocol=:tcp, port=443, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:35 -0700, app_protocol=:ssl3, payload="TLS/1.1 cipher:0xc013, www.example.org, www.example.org, example.com, example.edu, example.net, example.org, www.example.com, www.example.edu, www.example.net">
139
+ #<struct Masscan::Banner protocol=:tcp, port=443, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:35 -0700, app_protocol=:x509_cert, payload="MIIG1TCCBb2gAwIBAgIQD74IsIVNBXOKsMzhya/uyTANBgkqhkiG9w0BAQsFADBPMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMSkwJwYDVQQDEyBEaWdpQ2VydCBUTFMgUlNBIFNIQTI1NiAyMDIwIENBMTAeFw0yMDExMjQwMDAwMDBaFw0yMTEyMjUyMzU5NTlaMIGQMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEUMBIGA1UEBxMLTG9zIEFuZ2VsZXMxPDA6BgNVBAoTM0ludGVybmV0IENvcnBvcmF0aW9uIGZvciBBc3NpZ25lZCBOYW1lcyBhbmQgTnVtYmVyczEYMBYGA1UEAxMPd3d3LmV4YW1wbGUub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuvzuzMoKCP8Okx2zvgucA5YinrFPEK5RQP1TX7PEYUAoBO6i5hIAsIKFmFxtW2sghERilU5rdnxQcF3fEx3sY4OtY6VSBPLPhLrbKozHLrQ8ZN/rYTb+hgNUeT7NA1mP78IEkxAj4qG5tli4Jq41aCbUlCt7equGXokImhC+UY5IpQEZS0tKD4vu2ksZ04Qetp0k8jWdAvMA27W3EwgHHNeVGWbJPC0Dn7RqPw13r7hFyS5TpleywjdY1nB7ad6kcZXZbEcaFZ7ZuerA6RkPGE+PsnZRb1oFJkYoXimsuvkVFhWeHQXCGC1cuDWSrM3cpQvOzKH2vS7d15+zGls4IwIDAQABo4IDaTCCA2UwHwYDVR0jBBgwFoAUt2ui6qiqhIx56rTaD5iyxZV2ufQwHQYDVR0OBBYEFCYa+OSxsHKEztqBBtInmPvtOj0XMIGBBgNVHREEejB4gg93d3cuZXhhbXBsZS5vcmeCC2V4YW1wbGUuY29tggtleGFtcGxlLmVkdYILZXhhbXBsZS5uZXSCC2V4YW1wbGUub3Jngg93d3cuZXhhbXBsZS5jb22CD3d3dy5leGFtcGxlLmVkdYIPd3d3LmV4YW1wbGUubmV0MA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwgYsGA1UdHwSBgzCBgDA+oDygOoY4aHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0VExTUlNBU0hBMjU2MjAyMENBMS5jcmwwPqA8oDqGOGh0dHA6Ly9jcmw0LmRpZ2ljZXJ0LmNv">
140
+ #<struct Masscan::Banner protocol=:tcp, port=80, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:35 -0700, app_protocol=:http_server, payload="ECS (sec/97A6)">
141
+ #<struct Masscan::Banner protocol=:tcp, port=80, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:35 -0700, app_protocol=:html_title, payload="404 - Not Found">
142
+ #<struct Masscan::Banner protocol=:tcp, port=80, ip=#<IPAddr: IPv4:93.184.216.34/255.255.255.255>, timestamp=2021-08-26 16:07:35 -0700, app_protocol=:http, payload="HTTP/1.0 404 Not Found\r\nContent-Type: text/html\r\nDate: Thu, 26 Aug 2021 23:07:35 GMT\r\nServer: ECS (sec/97A6)\r\nContent-Length: 345\r\nConnection: close\r\n\r">
143
+ ```
144
+
145
+ ## Requirements
146
+
147
+ * [Ruby] >= 3.0.0
148
+ * [masscan] >= 1.0.0
149
+ * [ruby-masscan] ~> 0.1
150
+ * [ronin-core] ~> 0.2
151
+ * [ronin-db] ~> 0.2
152
+
153
+ ## Install
154
+
155
+ ```shell
156
+ $ gem install ronin-masscan
157
+ ```
158
+
159
+ ### Gemfile
160
+
161
+ ```ruby
162
+ gem 'ronin-masscan', '~> 0.1'
163
+ ```
164
+
165
+ ### gemspec
166
+
167
+ ```ruby
168
+ gem.add_dependency 'ronin-masscan', '~> 0.1'
169
+ ```
170
+
171
+ ## Development
172
+
173
+ 1. [Fork It!](https://github.com/ronin-rb/ronin-masscan/fork)
174
+ 2. Clone It!
175
+ 3. `cd ronin-masscan/`
176
+ 4. `./scripts/setup`
177
+ 5. `git checkout -b my_feature`
178
+ 6. Code It!
179
+ 7. `bundle exec rake spec`
180
+ 8. `git push origin my_feature`
181
+
182
+ ## License
183
+
184
+ Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
185
+
186
+ ronin-masscan is free software: you can redistribute it and/or modify
187
+ it under the terms of the GNU Lesser General Public License as published
188
+ by the Free Software Foundation, either version 3 of the License, or
189
+ (at your option) any later version.
190
+
191
+ ronin-masscan is distributed in the hope that it will be useful,
192
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
193
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
194
+ GNU Lesser General Public License for more details.
195
+
196
+ You should have received a copy of the GNU Lesser General Public License
197
+ along with ronin-masscan. If not, see <https://www.gnu.org/licenses/>.
198
+
199
+ [Ruby]: https://www.ruby-lang.org
200
+ [masscan]: https://github.com/robertdavidgraham/masscan#readme
201
+ [ruby-masscan]: https://github.com/postmodern/ruby-masscan#readme
202
+ [ronin-support]: https://github.com/ronin-rb/ronin-support#readme
203
+ [ronin-core]: https://github.com/ronin-rb/ronin-core#readme
204
+ [ronin-db]: https://github.com/ronin-rb/ronin-db#readme
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler'
5
+ rescue LoadError => e
6
+ warn e.message
7
+ warn "Run `gem install bundler` to install Bundler"
8
+ exit(-1)
9
+ end
10
+
11
+ begin
12
+ Bundler.setup(:development)
13
+ rescue Bundler::BundlerError => e
14
+ warn e.message
15
+ warn "Run `bundle install` to install missing gems"
16
+ exit e.status_code
17
+ end
18
+
19
+ require 'rake'
20
+
21
+ require 'rubygems/tasks'
22
+ Gem::Tasks.new(sign: {checksum: true, pgp: true})
23
+
24
+ require 'rspec/core/rake_task'
25
+ RSpec::Core::RakeTask.new
26
+ task :test => :spec
27
+ task :default => :spec
28
+
29
+ require 'yard'
30
+ YARD::Rake::YardocTask.new
31
+ task :docs => :yard
32
+
33
+ require 'kramdown/man/task'
34
+ Kramdown::Man::Task.new
35
+
36
+ require 'command_kit/completion/task'
37
+ CommandKit::Completion::Task.new(
38
+ class_file: 'ronin/masscan/cli',
39
+ class_name: 'Ronin::Masscan::CLI',
40
+ output_file: 'data/completions/ronin-masscan'
41
+ )
42
+
43
+ task :setup => %w[man command_kit:completion]
data/bin/ronin-masscan ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # ronin-masscan - A Ruby library and CLI for working with masscan.
5
+ #
6
+ # Copyright (c) 2023 Hal Brodigan (postmodern.mod3@gmail)
7
+ #
8
+ # ronin-masscan is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published
10
+ # by the Free Software Foundation, either version 3 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # ronin-masscan is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with ronin-masscan. If not, see <https://www.gnu.org/licenses/>.
20
+ #
21
+
22
+ root = File.expand_path(File.join(__dir__,'..'))
23
+ if File.file?(File.join(root,'Gemfile.lock'))
24
+ Dir.chdir(root) do
25
+ require 'bundler/setup'
26
+ rescue LoadError => e
27
+ warn e.message
28
+ warn "Run `gem install bundler` to install Bundler"
29
+ exit(-1)
30
+ end
31
+ end
32
+
33
+ require 'ronin/masscan/cli'
34
+ Ronin::Masscan::CLI.start
@@ -0,0 +1,83 @@
1
+ # ronin-masscan completion -*- shell-script -*-
2
+
3
+ # This bash completions script was generated by
4
+ # completely (https://github.com/dannyben/completely)
5
+ # Modifying it manually is not recommended
6
+
7
+ _ronin-masscan_completions_filter() {
8
+ local words="$1"
9
+ local cur=${COMP_WORDS[COMP_CWORD]}
10
+ local result=()
11
+
12
+ if [[ "${cur:0:1}" == "-" ]]; then
13
+ echo "$words"
14
+
15
+ else
16
+ for word in $words; do
17
+ [[ "${word:0:1}" != "-" ]] && result+=("$word")
18
+ done
19
+
20
+ echo "${result[*]}"
21
+
22
+ fi
23
+ }
24
+
25
+ _ronin-masscan_completions() {
26
+ local cur=${COMP_WORDS[COMP_CWORD]}
27
+ local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
28
+ local compline="${compwords[*]}"
29
+
30
+ case "$compline" in
31
+ 'new'*'--output-file')
32
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -- "$cur" )
33
+ ;;
34
+
35
+ 'scan'*'--output')
36
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -- "$cur" )
37
+ ;;
38
+
39
+ 'completion'*)
40
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_ronin-masscan_completions_filter "--print --install --uninstall")" -- "$cur" )
41
+ ;;
42
+
43
+ 'convert'*)
44
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "$(_ronin-masscan_completions_filter "--input-format -I --format -F")" -- "$cur" )
45
+ ;;
46
+
47
+ 'scan'*'-o')
48
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -- "$cur" )
49
+ ;;
50
+
51
+ 'import'*)
52
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "$(_ronin-masscan_completions_filter "--db --db-uri --db-file --format -F")" -- "$cur" )
53
+ ;;
54
+
55
+ 'print'*)
56
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_ronin-masscan_completions_filter "--protocol -P --ip --ip-range --ports -p --with-app-protocol --with-payload --with-payload-regex")" -- "$cur" )
57
+ ;;
58
+
59
+ 'dump'*)
60
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_ronin-masscan_completions_filter "--print-ips --print-hosts --print-ip-ports --print-host-ports --print-uris --protocol -P --ip --ip-range --ports -p --with-app-protocol --with-payload --with-payload-regex")" -- "$cur" )
61
+ ;;
62
+
63
+ 'grep'*)
64
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_ronin-masscan_completions_filter "--protocol -P --ip --ip-range --ports -p --with-app-protocol --with-payload --with-payload-regex")" -- "$cur" )
65
+ ;;
66
+
67
+ 'scan'*)
68
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_ronin-masscan_completions_filter "--db --db-uri --db-file --sudo --output -o --output-format -F --import")" -- "$cur" )
69
+ ;;
70
+
71
+ 'new'*)
72
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_ronin-masscan_completions_filter "--parser --scanner --printing --import --output-file --ports -p --ips")" -- "$cur" )
73
+ ;;
74
+
75
+ *)
76
+ while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_ronin-masscan_completions_filter "--version -V help completion convert dump grep import new print scan")" -- "$cur" )
77
+ ;;
78
+
79
+ esac
80
+ } &&
81
+ complete -F _ronin-masscan_completions ronin-masscan
82
+
83
+ # ex: filetype=sh