Created
March 12, 2015 21:00
-
-
Save carolineartz/db9285ae3a1d998cdf7b to your computer and use it in GitHub Desktop.
ruby script for submitting uris to easysol.net/explorer for dmarc preparedness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'open-uri' | |
require "net/http" | |
require 'csv' | |
require 'nokogiri' | |
require 'mechanize' | |
CSV.foreach("urls.csv") do |line| | |
agent = Mechanize.new | |
agent.set_proxy('10.0.1.12', '9396') #this is for logging/debugging http requests | |
dmarc_explorer = 'http://www.easysol.net/resources/dmarc-explorer' | |
page = agent.get(dmarc_explorer) | |
script_body = page.search("script")[24] #this is the text of the script with the generated easy_control value for the current load | |
easy_control = script_body.to_s.gsub(/(.+)(value=\")(.+)(">.+)/mx, "\\3") #extracted value for the easy_control | |
params = {'txt_domain' => URI.parse(line[0]).host, 'easy_control' => easy_control} | |
agent.post(dmarc_explorer, params) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment