Skip to content

Instantly share code, notes, and snippets.

@voodoologic
Last active September 29, 2015 03:34
Show Gist options
  • Save voodoologic/6c46f72cf4abf2bf199c to your computer and use it in GitHub Desktop.
Save voodoologic/6c46f72cf4abf2bf199c to your computer and use it in GitHub Desktop.
ruby get all ducky payloads
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