DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Nebuflood - Messing With Nebuad

06.27.2008
| 440 views |
  • submit to reddit
        nebuflood.rb 0.1

nebuad, a new ad targetting system isntalling its hardware in isp's, creates profiles by tracking what pages users of an ip address visit.  nebuflood.rb pulls random url's (one on each line) from nebuflood.dat and simulates a visit, complete with cookies--just to mess with the profiling system.

#!/usr/bin/ruby

require 'rubygems'
require 'curb'

MINUTES   = 5	# Randomly visit sites between 0 and X minutes
DATAFILE  = "nebuflood.dat" # A database of every possible page to be visited
                            # with a different URL on every line
siteArray = Array.new

easy = Curl::Easy.new
easy.enable_cookies = TRUE
easy.cookiejar = "cookies.txt"	# Choose what file to store cookies
easy.headers["User-Agent"] = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0) Gecko/2008061600 SUSE/3.0-1.2 Firefox/3.0"

# loadDatabase: Load sites database from dataFile into siteArray
def loadDatabase( siteArray, dataFile )
  if File.readable?( dataFile )
    dataFile = File.new( dataFile, "r" )
    while !dataFile.eof do
      siteArray.insert( 0, dataFile.gets.chop )
    end
    dataFile.close
  end
end

# visitSite: Download the random site siteURL
def visitSite ( siteURL, easy )  
  easy.url = siteURL
  easy.perform
  if !easy.body_str.empty?
    puts "Downloaded " + siteURL
  end
end

# !@#$ with NebuAD
loadDatabase( siteArray, DATAFILE )
if siteArray.empty?
  puts "Cannot load database."
else
  puts "Database file loaded with " + siteArray.length.to_s + " entries."
  while ( TRUE ) do
    sleep( rand( 60 * MINUTES.to_i ) )
    visitSite( siteArray[ rand( siteArray.length ) ], easy )    
  end
end