Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

login to phpBB programmatically

I am trying to log in to a phpBB forum. However, I cannot figure out what is wrong with the code.

import requests

forum = "https://adblockplus.org/forum/"

headers = {'User-Agent': 'Mozilla/5.0'}
payload = {'username': 'username', 'password': 'password'}
session = requests.Session()

r = session.post(forum + "ucp.php?mode=login", headers=headers, data=payload)
sidStart = r.text.find("sid")+4
sid = r.text[sidStart:sidStart+32]
parameters = {'mode': 'login', 'sid': sid}
r = session.post(forum, params=parameters)

if "Logout" in r.text:
    print("We are in")
else:
    print(r.text)

print(r)

It just always ends up not logged in.

like image 424
anon Avatar asked Dec 21 '25 21:12

anon


1 Answers

import requests
forum = "https://adblockplus.org/forum/"

headers = {'User-Agent': 'Mozilla/5.0'}
payload = {'username': 'username', 'password': 'password', 'redirect':'index.php', 'sid':'', 'login':'Login'}
session = requests.Session()

r = session.post(forum + "ucp.php?mode=login", headers=headers, data=payload)
print(r.text)

Made some small changes like adding redirect, sid and login to payload and it seems to work. Not sure which one helped, I'll leave figuring that out up to you.

like image 97
MadRabbit Avatar answered Dec 23 '25 11:12

MadRabbit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!