Last active
September 29, 2015 03:34
-
-
Save voodoologic/6c46f72cf4abf2bf199c to your computer and use it in GitHub Desktop.
ruby get all ducky payloads
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 'open-uri' | |
require 'mechanize' | |
require 'active_support/all' | |
URL = 'https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Payloads' | |
class PayloadGrabber | |
def initialize(url=URL) | |
@agent = Mechanize.new | |
@agent.get(url) | |
@links = payload_links | |
end | |
def payload_links | |
@agent.page.search('.present') | |
end | |
def make_go | |
loop_through(@links) do |page| | |
grab_payload(page) | |
end | |
end | |
def grab_payload(page) | |
title = page.search('.instapaper_title') | |
filename = title_to_filename(title) | |
puts filename | |
commands = page.search('pre').text | |
if !File.exist?(filename) | |
file = File.new(filename, 'w') | |
file << commands | |
file.close | |
end | |
end | |
def title_to_filename(title) | |
title.text.squish.tr(',', '').gsub(' ', '_').downcase | |
end | |
def loop_through(links, &block) | |
links.each do |link| | |
payload_page = @agent.click(link) | |
yield payload_page | |
end | |
end | |
end | |
PayloadGrabber.new.make_go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment