Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import re
- from socket import *
- import sys
- class phpBB2:
- def __init__(self, host, path):
- self.host=host
- self.path=path
- def login(self, user, passwd):
- self.user=user
- self.passwd=passwd
- user="username="+user
- passwd="password="+passwd
- log="login=Log+In"
- string=user+"&"+passwd+"&"+log
- request="POST "+self.path+"/login.php HTTP /1.1\r\nHost: "+self.host+"\r\nConnection: Close\r\nContent-Length: "+str(len(string))+"\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n"+string
- sock=socket(AF_INET, SOCK_STREAM)
- sock.connect((self.host,80))
- sock.send(request)
- r=""
- t="-"
- while(t!=""):
- t=sock.recv(1024)
- r+=t
- reg=re.compile("phpbb2mysql_data=(.+?);")
- match=reg.findall(r)
- self.cookie_sql_data="phpbb2mysql_data="+match[1]+";"
- reg=re.compile("phpbb2mysql_sid=(.+?);")
- match=reg.findall(r)
- self.cookie_sql_sid="phpbb2mysql_sid="+match[1]+";"
- self.sid=match[1]
- sock.close()
- def get_forum_id(self,forum):
- sock=socket(AF_INET, SOCK_STREAM)
- sock.connect((self.host,80))
- req="GET "+self.path+"/index.php HTTP /1.1\r\nHost: "+self.host+"\r\nConnection: Close\r\nCookie: "+self.cookie_sql_data+self.cookie_sql_sid+"\r\n\r\n"
- sock.send(req)
- r=""
- t="-"
- while(t!=""):
- t=sock.recv(1024)
- r+=t
- sock.close()
- reg=re.compile('\<a href="viewforum\.php\?f=(.+?)" class="forumlink"\>'+forum+'\</a\>')
- match=reg.findall(r)
- return match[0]
- def post(self,forum,subj,message):
- message=message.replace(" ","+")
- sock=socket(AF_INET, SOCK_STREAM)
- sock.connect((self.host,80))
- post="subject="+subj+"&addbbcode18=%23444444&addbbcode20=12&helpbox=Codice%3A+%5Bcode%5Dcodice%5B%2Fcode%5D++%28alt%2Bc%29&message="+message+"&topictype=0&poll_title=&add_poll_option_text=&poll_length=&mode=newtopic&sid="+self.sid+"&f="+self.get_forum_id(forum)+"&post=Invia"
- req="POST "+self.path+"/posting.php HTTP /1.1\r\nHost: "+self.host+"\r\nConnection: Close\r\nCookie: "+self.cookie_sql_data+self.cookie_sql_sid+"\r\nContent-Length: "+str(len(post))+"\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n"+post
- sock.send(req)
- sock.close()
- def log_out(self):
- req="GET "+self.path+"/login.php?logout=true&sid="+self.sid+" HTTP/1.1\r\nHost: "+self.host+"\r\nConnection: Close\r\nCookie: "+self.cookie_sql_data+self.cookie_sql_sid+"\r\n\r\n"
- sock=socket(AF_INET, SOCK_STREAM)
- sock.connect((self.host,80))
- sock.send(req)
- sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement