Skip to content

Instantly share code, notes, and snippets.

@3dd13
3dd13 / download_open_rice_contact.rb
Created October 19, 2010 08:36
OpenRice.com is a famous restaurant online directory in Hong Kong. Here is a ruby script to grep all the contact information of all shops. at this moment of time, there are around 26K records on the website. this program took ~ 15mins to finish. and
require 'rubygems'
require 'mechanize'
require 'fastercsv'
def get_all_option_values(page, attr_name)
page.search("[name=#{attr_name}]").search("option").map do |opt|
option_value = opt.attribute("value").value
[option_value, opt.text.strip.gsub(/\302\240\302\240/, '')] if option_value && option_value.length > 0
end.compact
end
@3dd13
3dd13 / ftp_client.py
Created May 19, 2010 16:43
VXRL - Defcon 2010 preparation
import ftplib
from ftplib import FTP
buffer = '\x41' * 400
try:
ftp = FTP('127.0.0.1')
ftp.login(user, password)
ftp.transfercmd("command" + buffer)
print 'xxx'
@3dd13
3dd13 / batch_concurrent_requests_by_typhoeus.rb
Created April 22, 2010 09:00
example of using Typhoeus
def main
# urls is a hash containing url to retrieve statuses of items
get_csv(urls, items) { |response, item|
item_results = CSV.parse_line(response.body)
item.setStatus(item_results[0])
}
end
def process_response(urls, items)