elezzark
04-27-2013, 06:12 PM
#!/usr/bin/python
import os, sys
import urllib, urllib2, cookielib
import re
import time
# RUBYCALABER POSTING BOT SHIT
# MODIFY AS YOU WILL
# login shit
RC_USERNAME = "hiroshima"
RC_PASSWORD = "gay4dp"
class SimpleVBPoster:
def __init__( self, url, username, password ):
self.url = url
self.username = username
self.password = password
self.user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
self.referer = self.url
self.cj = cookielib.CookieJar()
# login
self.do_login()
def do_login(self):
print( "Logging into "+self.username )
self.do_request( self.url+"/forum.php" ) # set some cookies here that allow us to open login.php
self.referer = self.url+"/forum.php"
# create login values
login_data = {
'vb_login_username': self.username,
'vb_login_password': self.password,
's': '',
'securitytoken': 'guest',
'do': 'login'
}
result = self.do_request_post( self.url+"/login.php?do=login", login_data )
if 'Thank you for logging in' in result:
print "successfully logged in, continuing.."
self.loggedin = 1
else:
print "failed to login. wrong username or password"
self.loggedin = 0
# debug
#f = open( 'result.txt', 'w' )
#f.write(result)
#f.close()
def post_in_thread(self, thread_id, post_content):
thread_id = str(thread_id)
# this would require modification in a board that used tid=
thread = self.url+"showthread.php?"+thread_id
thread = self.do_request(thread)
# gotta snag the security token now
match=re.compile('<input type="hidden" name="securitytoken" value="(.+?)"').findall(thread)
security_token = match[0]
# and some other crap..
match=re.compile('<input type="hidden" name="p" value="(.+?)"').findall(thread)
p = match[0] # im not entirely sure what this does but it's a hidden value in the form.
match=re.compile('<input type="hidden" name="loggedinuser" value="(.+?)"').findall(thread)
loggedinuser = match[0] # im not entirely sure what this does but it's a hidden value in the form.
# now create the values..
values = {
'securitytoken': security_token,
'message': post_content,
'wysiwyg': '0',
'signature': '1',
'fromquickreply': '1',
's': '',
'do': 'postreply',
't': thread_id,
'p': p,
'specifiedpost': '0',
'parseurl' : '1',
'loggedinuser': loggedinuser
}
# create the new reply URL
post_url = self.url+"newreply.php?do=postreply&t="+thread_id
result = self.do_request_post( post_url, values )
f = open( 'result.txt', 'w' )
f.write(result)
f.close()
print "Posted!"
# simple GET request
def do_request(self, url):
req = urllib2.Request(url)
req.add_header( "User-Agent", self.user_agent ) # set our user agent
req.add_header( "Referer", self.referer )
# create the cookie thing
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
response = opener.open(req)
result = response.read()
return result
# same ala post
def do_request_post(self, url, values):
req = urllib2.Request(url, urllib.urlencode(values))
req.add_header( "User-Agent", self.user_agent ) # set our user agent
req.add_header( "Referer", self.referer )
# create the cookie thing
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
response = opener.open(req)
result = response.read()
return result
if __name__ == "__main__":
poster = SimpleVBPoster( "http://rubycalaber.com/forums/", RC_USERNAME, RC_PASSWORD )
if poster.loggedin:
i = 0
while 1:
print "posting.. "+str(i)
poster.post_in_thread( 154540, "im gonna keep posting in this thread you can join me if you would like post "+str(i)+" in a row." )
time.sleep( 20 )
i=i+1
edit:fixed for rubycalaber
import os, sys
import urllib, urllib2, cookielib
import re
import time
# RUBYCALABER POSTING BOT SHIT
# MODIFY AS YOU WILL
# login shit
RC_USERNAME = "hiroshima"
RC_PASSWORD = "gay4dp"
class SimpleVBPoster:
def __init__( self, url, username, password ):
self.url = url
self.username = username
self.password = password
self.user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
self.referer = self.url
self.cj = cookielib.CookieJar()
# login
self.do_login()
def do_login(self):
print( "Logging into "+self.username )
self.do_request( self.url+"/forum.php" ) # set some cookies here that allow us to open login.php
self.referer = self.url+"/forum.php"
# create login values
login_data = {
'vb_login_username': self.username,
'vb_login_password': self.password,
's': '',
'securitytoken': 'guest',
'do': 'login'
}
result = self.do_request_post( self.url+"/login.php?do=login", login_data )
if 'Thank you for logging in' in result:
print "successfully logged in, continuing.."
self.loggedin = 1
else:
print "failed to login. wrong username or password"
self.loggedin = 0
# debug
#f = open( 'result.txt', 'w' )
#f.write(result)
#f.close()
def post_in_thread(self, thread_id, post_content):
thread_id = str(thread_id)
# this would require modification in a board that used tid=
thread = self.url+"showthread.php?"+thread_id
thread = self.do_request(thread)
# gotta snag the security token now
match=re.compile('<input type="hidden" name="securitytoken" value="(.+?)"').findall(thread)
security_token = match[0]
# and some other crap..
match=re.compile('<input type="hidden" name="p" value="(.+?)"').findall(thread)
p = match[0] # im not entirely sure what this does but it's a hidden value in the form.
match=re.compile('<input type="hidden" name="loggedinuser" value="(.+?)"').findall(thread)
loggedinuser = match[0] # im not entirely sure what this does but it's a hidden value in the form.
# now create the values..
values = {
'securitytoken': security_token,
'message': post_content,
'wysiwyg': '0',
'signature': '1',
'fromquickreply': '1',
's': '',
'do': 'postreply',
't': thread_id,
'p': p,
'specifiedpost': '0',
'parseurl' : '1',
'loggedinuser': loggedinuser
}
# create the new reply URL
post_url = self.url+"newreply.php?do=postreply&t="+thread_id
result = self.do_request_post( post_url, values )
f = open( 'result.txt', 'w' )
f.write(result)
f.close()
print "Posted!"
# simple GET request
def do_request(self, url):
req = urllib2.Request(url)
req.add_header( "User-Agent", self.user_agent ) # set our user agent
req.add_header( "Referer", self.referer )
# create the cookie thing
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
response = opener.open(req)
result = response.read()
return result
# same ala post
def do_request_post(self, url, values):
req = urllib2.Request(url, urllib.urlencode(values))
req.add_header( "User-Agent", self.user_agent ) # set our user agent
req.add_header( "Referer", self.referer )
# create the cookie thing
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
response = opener.open(req)
result = response.read()
return result
if __name__ == "__main__":
poster = SimpleVBPoster( "http://rubycalaber.com/forums/", RC_USERNAME, RC_PASSWORD )
if poster.loggedin:
i = 0
while 1:
print "posting.. "+str(i)
poster.post_in_thread( 154540, "im gonna keep posting in this thread you can join me if you would like post "+str(i)+" in a row." )
time.sleep( 20 )
i=i+1
edit:fixed for rubycalaber