source: trollforge/unsorted/old-trollforges/troll/crapflood (older)/gnaa/crapflood.py @ 605

Revision 605, 4.5 KB checked in by literalka, 16 months ago (diff)

more sorting, jesus fuck

Line 
1#!/usr/bin/python
2#simple 4chan spammer by popeye
3# HACKED BY ZION
4
5# This version on longer uses a fixed image, instead it expects
6# an image dir in the same directory it is run from.
7# Note that since i was too fucking lazy to fix the bit that gives
8# the image a random name, it is best to use JP{E,}G files, or just not care
9# it should work either way.
10
11import ClientForm, urllib2, re, time, sys, random, os
12#
13# configuration
14#
15mode = 0 #0 for random flooding, 1 for constantly bumping one thread
16board = "http://boards.4chan.org/b/" #change to whatever board you want to spam
17delay   = 30 #time between posts
18               #otherwise it will fag you for flooding
19runs    = 9999  #number of spam runs before exiting
20subject = "" #subject field, if any
21email   = "" #email field, if any
22comment = open("gnaa.txt", "r").read() #comment field, if any
23name    = "" 
24#
25# proxy setup
26
27#import socks, socket
28#socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5,"localhost", 4002)
29#socket.socket = socks.socksocket
30#
31# get list of threads
32#
33print "Config: (can be changed in the script)\nURL: " + board + "\ndelay between posts: " + str(delay) + " seconds"
34print "post subject: " + str(subject)
35print "post email: " + str(email)
36print "post name: " + str(name)
37print "post comment:\n" + str(comment)
38print "Getting a list of threads from " + board + "..."
39
40for i in range(runs):
41    threads = []
42    print "Starting spam run number " + str(i+1) + "."
43    try:
44        request = urllib2.Request(board)
45        request.add_header("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11")
46        response = urllib2.urlopen(request)
47        for line in response.readlines():
48            n = re.search(r"(\[<a href=\"res/(.*?)\">Reply<)", line)
49            if n:
50                reply = n.group(2)
51                threads.append(reply)
52        response.close()
53        print "Got " + str(len(threads)) + " threads."
54    except urllib2.HTTPError, response:
55        print response
56#
57# reply to threads
58#
59
60    if len(threads) > 0:
61        for s in threads:
62            url = board + "/res/" + s
63            if mode == 1:
64                url = board + "/res/" + threads[1]
65            print "Posting in " + str(url) + "..."
66            try:
67                request = urllib2.Request(url)
68                request.add_header("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11")
69                response = urllib2.urlopen(request)
70                forms = ClientForm.ParseResponse(response, backwards_compat=False)
71                form = forms[0]
72                form["sub"] = subject
73                form["email"] = email
74                form["com"] = comment + str(random.randrange(948234, 8952895742)) #random string
75                form["name"] = name
76                response.close()
77                image = "images/" + random.choice(os.listdir("images"))
78                if image:
79                    try:
80                        img = open(image, "r+")
81                    except IOError:
82                        print "cannot open", image
83                        sys.exit(2) 
84                    form.add_file(img, "image/jpeg", str(random.randrange(948234, 8952895742)) + ".jpg")
85                request2 = form.click()
86                request2.add_header("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11")
87                response2 = urllib2.urlopen(request2)
88                error = 0
89                for line in response2.readlines():
90                    n = re.search(r"Error: Flood detected", line)
91                    if n:
92                        print "Flood triggered"
93                        error = 1
94                        time.sleep(200)
95                        break
96                    n = re.search(r"Error:", line)
97                    if n:
98                        error = 1
99                        print "Some kind of error triggered"
100                        break
101                if error == 0:
102                    print "success."
103                response2.close()
104#                if image:#
105#                    img.write("1")#
106#                    img.close()#
107                time.sleep(delay)
108            except urllib2.HTTPError, response2:
109                print response2
110            except urllib2.HTTPError, response:
111                print response
112    else:
113        print "Error: no threads to reply to!"
114else:
115        print "Finished."
Note: See TracBrowser for help on using the repository browser.