Class: Ronin::Nmap::CLI::Commands::New Private
- Inherits:
-
Ronin::Nmap::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Nmap::CLI::Command
- Ronin::Nmap::CLI::Commands::New
- Includes:
- Core::CLI::Generator
- Defined in:
- lib/ronin/nmap/cli/commands/new.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Generates a new nmap ruby script.
Usage
ronin-nmap new [options] FILE
Options
--parser Generate a nmap XML parser script
--scanner Generate a nmap scanner script
--printing Adds additional printing of the nmap scan data
--import Also import the nmap XML scan data
--xml-file XML_FILE Sets the XML file to write to or parse
-p {PORT | [PORT1]-[PORT2]}[,...],
--ports Sets the port range to scan
--target TARGET Sets the targets to scan (Defaults: ARGV[0])
-h, --help Print help information
Arguments
FILE The path to the new nmap ruby script.
Examples
ronin-nmap new scanner.rb --ports 22,80,443,8000-9000 --target example.com
ronin-nmap new parser.rb --parser --xml-file path/to/nmap.xml --printing
Instance Attribute Summary collapse
-
#features ⇒ Hash{Symbol => Boolean}
readonly
private
Additional features.
-
#ports ⇒ Array<Integer, Range(Integer,Integer)>, ...
readonly
private
The optional ports to scan.
-
#script_type ⇒ :scanner, :parser
readonly
private
The script type.
-
#syn_scan ⇒ Boolean
readonly
private
Specifies whether to enable SYN scanning.
-
#targets ⇒ Array<String>
readonly
private
The targets to scan.
-
#xml_file ⇒ String?
readonly
private
The optioanl XML file to write to or parse.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ New
constructor
private
Initializes the
ronin-nmap new
command. -
#parse_port_range(ports) ⇒ Array<Integer, Range(Integer,Integer)>, "-"
private
Parses a port range.
-
#run(file) ⇒ Object
private
Runs the
ronin-nmap new
command.
Constructor Details
#initialize(**kwargs) ⇒ New
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the ronin-nmap new
command.
160 161 162 163 164 165 166 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 160 def initialize(**kwargs) super(**kwargs) @script_type = :scanner @targets = [] @features = {} end |
Instance Attribute Details
#features ⇒ Hash{Symbol => Boolean} (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Additional features.
152 153 154 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 152 def features @features end |
#ports ⇒ Array<Integer, Range(Integer,Integer)>, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optional ports to scan.
142 143 144 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 142 def ports @ports end |
#script_type ⇒ :scanner, :parser (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The script type.
127 128 129 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 127 def script_type @script_type end |
#syn_scan ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Specifies whether to enable SYN scanning.
137 138 139 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 137 def syn_scan @syn_scan end |
#targets ⇒ Array<String> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The targets to scan.
147 148 149 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 147 def targets @targets end |
#xml_file ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The optioanl XML file to write to or parse.
132 133 134 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 132 def xml_file @xml_file end |
Instance Method Details
#parse_port_range(ports) ⇒ Array<Integer, Range(Integer,Integer)>, "-"
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parses a port range.
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 195 def parse_port_range(ports) case ports when '-' then '-' else ports.split(',').map do |port| case port when /\A\d+-\d+\z/ start, stop = port.split('-',2) (start.to_i..stop.to_i) when /\A\d+-\z/ start = port.chomp('-') (start.to_i..) when /\A-\d+\z/ stop = port[1..] (..stop.to_i) when /\A\d+\z/ port.to_i else raise(ArgumentError,"invalid port range: #{ports.inspect}") end end end end |
#run(file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the ronin-nmap new
command.
174 175 176 177 178 179 180 181 |
# File 'lib/ronin/nmap/cli/commands/new.rb', line 174 def run(file) @directory = File.dirname(file) mkdir @directory unless File.directory?(@directory) erb "script.rb.erb", file chmod '+x', file end |