ronin-nmap 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 +15 -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 +42 -0
  12. data/README.md +238 -0
  13. data/Rakefile +43 -0
  14. data/bin/ronin-nmap +32 -0
  15. data/data/completions/ronin-nmap +79 -0
  16. data/data/templates/script.rb.erb +58 -0
  17. data/gemspec.yml +42 -0
  18. data/lib/ronin/nmap/cli/command.rb +40 -0
  19. data/lib/ronin/nmap/cli/commands/completion.rb +61 -0
  20. data/lib/ronin/nmap/cli/commands/convert.rb +108 -0
  21. data/lib/ronin/nmap/cli/commands/dump.rb +293 -0
  22. data/lib/ronin/nmap/cli/commands/grep.rb +378 -0
  23. data/lib/ronin/nmap/cli/commands/import.rb +79 -0
  24. data/lib/ronin/nmap/cli/commands/new.rb +226 -0
  25. data/lib/ronin/nmap/cli/commands/print.rb +133 -0
  26. data/lib/ronin/nmap/cli/commands/scan.rb +233 -0
  27. data/lib/ronin/nmap/cli/filtering_options.rb +355 -0
  28. data/lib/ronin/nmap/cli/importable.rb +68 -0
  29. data/lib/ronin/nmap/cli/port_list.rb +102 -0
  30. data/lib/ronin/nmap/cli.rb +50 -0
  31. data/lib/ronin/nmap/converter.rb +114 -0
  32. data/lib/ronin/nmap/converters/csv.rb +162 -0
  33. data/lib/ronin/nmap/converters/json.rb +562 -0
  34. data/lib/ronin/nmap/converters.rb +54 -0
  35. data/lib/ronin/nmap/exceptions.rb +47 -0
  36. data/lib/ronin/nmap/importer.rb +369 -0
  37. data/lib/ronin/nmap/root.rb +28 -0
  38. data/lib/ronin/nmap/version.rb +26 -0
  39. data/lib/ronin/nmap.rb +223 -0
  40. data/man/ronin-nmap-completion.1 +76 -0
  41. data/man/ronin-nmap-completion.1.md +78 -0
  42. data/man/ronin-nmap-convert.1 +33 -0
  43. data/man/ronin-nmap-convert.1.md +36 -0
  44. data/man/ronin-nmap-dump.1 +141 -0
  45. data/man/ronin-nmap-dump.1.md +119 -0
  46. data/man/ronin-nmap-grep.1 +33 -0
  47. data/man/ronin-nmap-grep.1.md +36 -0
  48. data/man/ronin-nmap-import.1 +52 -0
  49. data/man/ronin-nmap-import.1.md +57 -0
  50. data/man/ronin-nmap-new.1 +81 -0
  51. data/man/ronin-nmap-new.1.md +73 -0
  52. data/man/ronin-nmap-print.1 +61 -0
  53. data/man/ronin-nmap-print.1.md +63 -0
  54. data/man/ronin-nmap-scan.1 +86 -0
  55. data/man/ronin-nmap-scan.1.md +84 -0
  56. data/man/ronin-nmap.1 +58 -0
  57. data/man/ronin-nmap.1.md +57 -0
  58. data/ronin-nmap.gemspec +62 -0
  59. data/scripts/setup +161 -0
  60. metadata +168 -0
@@ -0,0 +1,57 @@
1
+ # ronin-nmap 1 "2024-01-01" Ronin Nmap "User Manuals"
2
+
3
+ ## NAME
4
+
5
+ ronin-nmap - A CLI for working with nmap
6
+
7
+ ## SYNOPSIS
8
+
9
+ `ronin-nmap` [*options*] [*COMMAND* [...]]
10
+
11
+ ## DESCRIPTION
12
+
13
+ `ronin-nmap` provides various commands for automating `nmap`, parsing
14
+ XML output files, and importing scan data into the database.
15
+
16
+ Runs a `ronin-nmap` *COMMAND*.
17
+
18
+ ## ARGUMENTS
19
+
20
+ *COMMAND*
21
+ : The `ronin-nmap` command to execute.
22
+
23
+ ## OPTIONS
24
+
25
+ `-h`, `--help`
26
+ : Print help information
27
+
28
+ ## COMMANDS
29
+
30
+ *completion*
31
+ : Manages the shell completion rules for `ronin-nmap`.
32
+
33
+ *convert*
34
+ : Converts an nmap XML file to JSON or CSV.
35
+
36
+ *dump*
37
+ : Dumps the targets from an nmap XML file.
38
+
39
+ *import*
40
+ : Imports an nmap XML file into ronin-db.
41
+
42
+ *new*
43
+ : Generates a new nmap Ruby script.
44
+
45
+ *print*
46
+ : Prints the scanned hosts from nmap XML file(s).
47
+
48
+ *scan*
49
+ : Runs nmap and outputs data as JSON or CSV or imports into the database.
50
+
51
+ ## AUTHOR
52
+
53
+ Postmodern <postmodern.mod3@gmail.com>
54
+
55
+ ## SEE ALSO
56
+
57
+ [ronin-nmap-completion](ronin-nmap-completion.1.md) [ronin-nmap-convert](ronin-nmap-convert.1.md) [ronin-nmap-dump](ronin-nmap-dump.1.md) [ronin-nmap-import](ronin-nmap-import.1.md) [ronin-nmap-new](ronin-nmap-new.1.md) [ronin-nmap-scan](ronin-nmap-scan.1.md)
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
7
+
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
+
13
+ require 'ronin/nmap/version'
14
+ Ronin::Nmap::VERSION
15
+ end
16
+
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
23
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
24
+
25
+ glob = ->(patterns) { gem.files & Dir[*patterns] }
26
+
27
+ gem.files = `git ls-files`.split($/)
28
+ gem.files = glob[gemspec['files']] if gemspec['files']
29
+ gem.files += Array(gemspec['generated_files'])
30
+ # exclude test files from the packages gem
31
+ gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
32
+
33
+ gem.executables = gemspec.fetch('executables') do
34
+ glob['bin/*'].map { |path| File.basename(path) }
35
+ end
36
+
37
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
38
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
39
+
40
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
41
+ %w[ext lib].select { |dir| File.directory?(dir) }
42
+ })
43
+
44
+ gem.requirements = gemspec['requirements']
45
+ gem.required_ruby_version = gemspec['required_ruby_version']
46
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
47
+ gem.post_install_message = gemspec['post_install_message']
48
+
49
+ split = ->(string) { string.split(/,\s*/) }
50
+
51
+ if gemspec['dependencies']
52
+ gemspec['dependencies'].each do |name,versions|
53
+ gem.add_dependency(name,split[versions])
54
+ end
55
+ end
56
+
57
+ if gemspec['development_dependencies']
58
+ gemspec['development_dependencies'].each do |name,versions|
59
+ gem.add_development_dependency(name,split[versions])
60
+ end
61
+ end
62
+ end
data/scripts/setup ADDED
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env bash
2
+
3
+ #
4
+ # Prints a log message.
5
+ #
6
+ function log()
7
+ {
8
+ if [[ -t 1 ]]; then
9
+ echo -e "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m$1\x1b[0m"
10
+ else
11
+ echo ">>> $1"
12
+ fi
13
+ }
14
+
15
+ #
16
+ # Prints a warn message.
17
+ #
18
+ function warn()
19
+ {
20
+ if [[ -t 1 ]]; then
21
+ echo -e "\x1b[1m\x1b[33m***\x1b[0m \x1b[1m$1\x1b[0m" >&2
22
+ else
23
+ echo "*** $1" >&2
24
+ fi
25
+ }
26
+
27
+ #
28
+ # Prints an error message.
29
+ #
30
+ function error()
31
+ {
32
+ if [[ -t 1 ]]; then
33
+ echo -e "\x1b[1m\x1b[31m!!!\x1b[0m \x1b[1m$1\x1b[0m" >&2
34
+ else
35
+ echo "!!! $1" >&2
36
+ fi
37
+ }
38
+
39
+ #
40
+ # Prints an error message and exists with -1.
41
+ #
42
+ function fail()
43
+ {
44
+ error "$@"
45
+ exit -1
46
+ }
47
+
48
+ #
49
+ # Sets os_platform and os_arch.
50
+ #
51
+ function detect_os()
52
+ {
53
+ os_platform="$(uname -s)"
54
+ os_arch="$(uname -m)"
55
+ }
56
+
57
+ #
58
+ # Auto-detect the package manager.
59
+ #
60
+ function detect_package_manager()
61
+ {
62
+ case "$os_platform" in
63
+ Linux)
64
+ if [[ -f /etc/redhat-release ]]; then
65
+ if command -v dnf >/dev/null; then
66
+ package_manager="dnf"
67
+ elif command -v yum >/dev/null; then
68
+ package_manager="yum"
69
+ fi
70
+ elif [[ -f /etc/debian_version ]]; then
71
+ if command -v apt-get >/dev/null; then
72
+ package_manager="apt"
73
+ fi
74
+ elif [[ -f /etc/SuSE-release ]]; then
75
+ if command -v zypper >/dev/null; then
76
+ package_manager="zypper"
77
+ fi
78
+ elif [[ -f /etc/arch-release ]]; then
79
+ if command -v pacman >/dev/null; then
80
+ package_manager="pacman"
81
+ fi
82
+ elif [[ -f /etc/os-release ]]; then
83
+ if command -v pacman >/dev/null; then
84
+ package_manager="pacman"
85
+ elif command -v zypper >/dev/null; then
86
+ package_manager="zypper"
87
+ fi
88
+ elif [[ "$HOME" == *"com.termux"* ]]; then
89
+ package_manager="termux"
90
+ fi
91
+ ;;
92
+ Darwin)
93
+ if command -v brew >/dev/null; then
94
+ package_manager="brew"
95
+ elif command -v port >/dev/null; then
96
+ package_manager="port"
97
+ fi
98
+ ;;
99
+ *BSD)
100
+ if command -v pkg >/dev/null; then
101
+ package_manager="pkg"
102
+ fi
103
+ ;;
104
+ esac
105
+ }
106
+
107
+ #
108
+ # Detects the system.
109
+ #
110
+ function detect_system()
111
+ {
112
+ detect_os
113
+ detect_package_manager
114
+ }
115
+
116
+ #
117
+ # Installs a list of package names using the detected package manager.
118
+ #
119
+ function install_packages()
120
+ {
121
+ case "$package_manager" in
122
+ apt) $sudo apt-get install -y "$@" || return $? ;;
123
+ dnf|yum)$sudo $package_manager install -y "$@" || return $? ;;
124
+ port) $sudo port install "$@" || return $? ;;
125
+ pkg) $sudo pkg install -y "$@" || return $? ;;
126
+ brew)
127
+ local brew_owner="$(/usr/bin/stat -f %Su "$(command -v brew)")"
128
+ sudo -u "$brew_owner" brew install "$@" ||
129
+ sudo -u "$brew_owner" brew upgrade "$@" || return $?
130
+ ;;
131
+ pacman)
132
+ local missing_pkgs=($(pacman -T "$@"))
133
+
134
+ if (( ${#missing_pkgs[@]} > 0 )); then
135
+ $sudo pacman -Sy --noconfirm "${missing_pkgs[@]}" || return $?
136
+ fi
137
+ ;;
138
+ zypper) $sudo zypper -n in -l $* || return $? ;;
139
+ termux) pkg install -y "$@" || return $? ;;
140
+ "") warn "Could not determine Package Manager. Proceeding anyway." ;;
141
+ esac
142
+ }
143
+
144
+ if ! command -v nmap >/dev/null; then
145
+ detect_system
146
+
147
+ log "Installing nmap ..."
148
+ install_packages nmap || warn "Could not install nmap. Proceeding anyways ..."
149
+ fi
150
+
151
+ # default to installing gems into vendor/bundle
152
+ if [[ ! -f .bundle/config ]]; then
153
+ bundle config set --local path vendor/bundle >/dev/null || \
154
+ fail "Failed to run 'bundle config'"
155
+ fi
156
+
157
+ log "Installing gems ..."
158
+ bundle install || fail "Failed to run 'bundle install'!"
159
+
160
+ log "Setting up the project ..."
161
+ bundle exec rake setup || "Failed to run 'rake setup'!"
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ronin-nmap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Postmodern
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-06-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-nmap
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ronin-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0.rc1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0.rc1
41
+ - !ruby/object:Gem::Dependency
42
+ name: ronin-db
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.0.rc1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.0.rc1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ description: |
70
+ ronin-nmap is a Ruby library for working with nmap. ronin-nmap can parse
71
+ nmap XML, convert nmap XML into JSON or CSV, or import nmap XML into the
72
+ ronin-db database.
73
+ email: postmodern.mod3@gmail.com
74
+ executables:
75
+ - ronin-nmap
76
+ extensions: []
77
+ extra_rdoc_files:
78
+ - COPYING.txt
79
+ - ChangeLog.md
80
+ - README.md
81
+ files:
82
+ - ".document"
83
+ - ".github/workflows/ruby.yml"
84
+ - ".gitignore"
85
+ - ".rspec"
86
+ - ".rubocop.yml"
87
+ - ".ruby-version"
88
+ - ".yardopts"
89
+ - COPYING.txt
90
+ - ChangeLog.md
91
+ - Gemfile
92
+ - README.md
93
+ - Rakefile
94
+ - bin/ronin-nmap
95
+ - data/completions/ronin-nmap
96
+ - data/templates/script.rb.erb
97
+ - gemspec.yml
98
+ - lib/ronin/nmap.rb
99
+ - lib/ronin/nmap/cli.rb
100
+ - lib/ronin/nmap/cli/command.rb
101
+ - lib/ronin/nmap/cli/commands/completion.rb
102
+ - lib/ronin/nmap/cli/commands/convert.rb
103
+ - lib/ronin/nmap/cli/commands/dump.rb
104
+ - lib/ronin/nmap/cli/commands/grep.rb
105
+ - lib/ronin/nmap/cli/commands/import.rb
106
+ - lib/ronin/nmap/cli/commands/new.rb
107
+ - lib/ronin/nmap/cli/commands/print.rb
108
+ - lib/ronin/nmap/cli/commands/scan.rb
109
+ - lib/ronin/nmap/cli/filtering_options.rb
110
+ - lib/ronin/nmap/cli/importable.rb
111
+ - lib/ronin/nmap/cli/port_list.rb
112
+ - lib/ronin/nmap/converter.rb
113
+ - lib/ronin/nmap/converters.rb
114
+ - lib/ronin/nmap/converters/csv.rb
115
+ - lib/ronin/nmap/converters/json.rb
116
+ - lib/ronin/nmap/exceptions.rb
117
+ - lib/ronin/nmap/importer.rb
118
+ - lib/ronin/nmap/root.rb
119
+ - lib/ronin/nmap/version.rb
120
+ - man/ronin-nmap-completion.1
121
+ - man/ronin-nmap-completion.1.md
122
+ - man/ronin-nmap-convert.1
123
+ - man/ronin-nmap-convert.1.md
124
+ - man/ronin-nmap-dump.1
125
+ - man/ronin-nmap-dump.1.md
126
+ - man/ronin-nmap-grep.1
127
+ - man/ronin-nmap-grep.1.md
128
+ - man/ronin-nmap-import.1
129
+ - man/ronin-nmap-import.1.md
130
+ - man/ronin-nmap-new.1
131
+ - man/ronin-nmap-new.1.md
132
+ - man/ronin-nmap-print.1
133
+ - man/ronin-nmap-print.1.md
134
+ - man/ronin-nmap-scan.1
135
+ - man/ronin-nmap-scan.1.md
136
+ - man/ronin-nmap.1
137
+ - man/ronin-nmap.1.md
138
+ - ronin-nmap.gemspec
139
+ - scripts/setup
140
+ homepage: https://ronin-rb.dev/
141
+ licenses:
142
+ - LGPL-3.0
143
+ metadata:
144
+ documentation_uri: https://ronin-rb.dev/docs/ronin-nmap
145
+ source_code_uri: https://github.com/ronin-rb/ronin-nmap
146
+ bug_tracker_uri: https://github.com/ronin-rb/ronin-nmap/issues
147
+ changelog_uri: https://github.com/ronin-rb/ronin-nmap/blob/main/ChangeLog.md
148
+ rubygems_mfa_required: 'true'
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 3.0.0
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubygems_version: 3.3.27
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: A Ruby library and CLI for working with nmap.
168
+ test_files: []