Beranda > Python > Python – Guest Book Spammer

Python – Guest Book Spammer

8 September 2010

#!/usr/bin/python
#original code by http://gunslingerc0de.wordpress.com/
import mechanize, cookielib, re, time, random
randstring    = [‘a’,’b’,’c’,’d’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’,
           ‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’,
           ‘1’,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’0′
          ]
header = {
          “User-Agent”: “Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3”,
          “Accept”: “text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”,
          “Accept-Language”: “en-us,en;q=0.5”,
          “Accept-Encoding”: “gzip,deflate”,
          “Accept-Charset”: “ISO-8859-1,utf-8;q=0.7,*;q=0.7”,
          “Keep-Alive”: “99999”,
          “Proxy-Connection”: “keep-alive”,
          “Content-Type”: “application/x-www-form-urlencoded”
}
ouruseragent     = [‘Mozilla/4.0 (compatible; MSIE 5.0; SunOS 5.10 sun4u; X11)’,
        ‘Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1’,
        ‘Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2pre) Gecko/20100207 Ubuntu/9.04 (jaunty) Namoroka/3.6.2pre’,
        ‘Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser;’,
        ‘Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)’,
            ‘Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1)’,
            ‘Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6)’,
            ‘Microsoft Internet Explorer/4.0b1 (Windows 95)’,
            ‘Opera/8.00 (Windows NT 5.1; U; en)’,
        ‘amaya/9.51 libwww/5.4.0’,
        ‘Mozilla/4.0 (compatible; MSIE 5.0; AOL 4.0; Windows 95; c_athome)’,
        ‘Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)’,
        ‘Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Kubuntu)’,
        ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; ZoomSpider.net bot; .NET CLR 1.1.4322)’,
        ‘Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; QihooBot 1.0 qihoobot@qihoo.net)’,
        ‘Mozilla/4.0 (compatible; MSIE 5.0; Windows ME) Opera 5.11 [en]’]

br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
# Want debugging messages ??
#br.set_debug_http(True)
#br.set_debug_redirects(True)
#br.set_debug_responses(True)
# try to cheating
br.addheaders = [(‘User-agent’, random.choice(ouruseragent))]

def main():
    ”’infinite loop”’
    while 1:
        print (“[*] Going to pemkot-malang.go.id”)
        page = br.open(“http://www.pemkot-malang.go.id/bukutamu/sella.php”)
        read = page.read()
        br.select_form(name=’book’)
        br.form[‘gb_name’] = ‘Nok nok !!!’
        br.form[‘gb_email’] = ‘oneday@gmail.com’
        br.form[‘gb_location’] = ‘http://onecoder.com’
       
      
        br.form[‘gb_comment’] = ‘NOK NOK !!’
        br.submit()
        print br.response().read()
        print (“[*] Spammed successfully…”)
        time.sleep(1)
        print (“[*] Sleeping for 60 seconds please wait”)
        time.sleep(60) # prevent blocking too, so wee need time.sleep() ;)… or we got forbidden status😉
        print (“[*] Ready to rock baby…”)

if __name__ == ‘__main__’:
    main()

Kategori:Python Tag:, ,
  1. 9 September 2010 pukul 11:48

    inspect element form yang bagus.. keep up nice work !

  2. 11 September 2010 pukul 04:02

    wehh… mas gunslinger mampir euuyy… makasih bro.. gara2 na error di nr=1 jadi searching eh dapet deh… :p

  1. No trackbacks yet.
Komentar ditutup.
%d blogger menyukai ini: