lib/pwn/plugins/nmap_it.rb in pwn-0.4.699 vs lib/pwn/plugins/nmap_it.rb in pwn-0.4.700
- old
+ new
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require 'nmap/command'
require 'nmap/xml'
+require 'open3'
module PWN
module Plugins
# This plugin is used as an interface to nmap, the exploration tool and security / port scanner. More info on available options can be found at: https://github.com/postmodern/ruby-nmap/blob/main/lib/nmap/command.rb
module NmapIt
@@ -55,10 +56,33 @@
end
rescue StandardError => e
raise e
end
+ # Supported Method Parameters::
+ # PWN::Plugins::NmapIt.diff_xml_results(
+ # xml_a: 'required - path to nmap xml results',
+ # xml_b: 'required - path to nmap xml results',
+ # diff: 'required - path to nmap xml results diff'
+ # )
+ public_class_method def self.diff_xml_results(opts = {})
+ xml_a = opts[:xml_a].to_s.scrub.strip.chomp
+ xml_b = opts[:xml_b].to_s.scrub.strip.chomp
+ diff = opts[:diff].to_s.scrub.strip.chomp
+
+ stdout, _stderr, _status = Open3.capture3(
+ 'ndiff',
+ '--xml',
+ xml_a,
+ xml_b
+ )
+
+ File.write(diff, stdout)
+ rescue StandardError => e
+ raise e
+ end
+
# Author(s):: 0day Inc. <request.pentest@0dayinc.com>
public_class_method def self.authors
"AUTHOR(S):
0day Inc. <request.pentest@0dayinc.com>
@@ -95,9 +119,15 @@
output.each_line { |line| puts line }
end
end
end
end
+
+ #{self}.diff_xml_results(
+ xml_a: 'required - path to nmap xml results',
+ xml_b: 'required - path to nmap xml results',
+ diff: 'required - path to nmap xml results diff'
+ )
#{self}.authors
"
end
end