Created
May 9, 2019 14:13
-
-
Save jakoch/345d66c1f76ff20527a59c133acc16ab to your computer and use it in GitHub Desktop.
Authenticate Trac (bugtracker) users against Simple Machines Forum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Authenticate Trac (bugtracker) users against Simple Machines Forum | |
# Author: Derek Anderson | |
# Date: 29-01-2008 | |
# Source: http://armyofevilrobots.com/auth_trac_against_smf | |
try: | |
from mod_python import apache | |
except: | |
pass | |
def check_smf_auth(user,passwd): | |
import _mysql, hashlib | |
db=_mysql.connect("localhost","database_sql1","pw","database_sql1") | |
db.query("select passwd from smf_members where memberName='%s'"%_mysql.escape_string(user)) | |
r=db.store_result() | |
hash=r.fetch_row()[0][0] | |
#print dir(r) | |
#print hash | |
myhash=hashlib.sha1(user.lower()+passwd).hexdigest() | |
#print myhash.... | |
if myhash==hash: | |
return True | |
else: | |
return False | |
def authenhandler(req): | |
pw = req.get_basic_auth_pw() | |
user = req.user | |
#if user == "spam" and pw == "eggs": | |
try: | |
if check_smf_auth(user,pw): | |
return apache.OK | |
else: | |
return apache.HTTP_UNAUTHORIZED | |
except: | |
return apache.HTTP_UNAUTHORIZED | |
if __name__=="__main__": | |
import sys | |
print "Console Mode" | |
print "Help: Arg1 = Name / Arg2 = PW" | |
print check_smf_auth(sys.argv[1],sys.argv[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment