Skip to content

Instantly share code, notes, and snippets.

@nicdoye
Created January 4, 2017 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdoye/adffde21cac1eed46388b04fbbbbd7c8 to your computer and use it in GitHub Desktop.
Save nicdoye/adffde21cac1eed46388b04fbbbbd7c8 to your computer and use it in GitHub Desktop.
Parse GSuite DMARC Reports
#!/usr/bin/env ruby
require 'nokogiri'
require 'optparse'
require 'resolv'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: google-dmarc-parser.rb [options]"
opts.on('-f', '--file NAME', 'File name') { |v| options[:filename] = v }
end.parse!
doc = Nokogiri::XML( File.open( options[:filename] ) )
doc.xpath('//source_ip').each do |node|
begin
puts Resolv.getname node.content
rescue
puts node.content
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment