Last active
August 29, 2015 14:20
-
-
Save nolageek/7a3cea90dfe85284470d to your computer and use it in GitHub Desktop.
bbslink client for daydream bbs
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/env python | |
## Original code by Sampsa Laine, B4BBS (2:250/7), http://sampsa.com/b4bbs | |
## Usage Example (get door codes after joining bbslink.net): | |
## Command line format: /home/bbs/python/dd-bbslink.py %N <door code> | |
## | |
## DOOR_COMMAND.. LORD | |
## DOOR_TYPE..... 6 | |
## DOOR_SECURITY. 200 | |
## DOOR_EXECUTE.. /home/bbs/python/dd-bbslink.py %N LORD | |
## DOOR_CONFS1... XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
## DOOR_CONFS2... XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
## DOOR_PASSWD... - | |
## | |
## User configurable bits start here / FIXME config file? | |
host = "games.bbslink.net" # Server address, usually 'games.bbslink.net' | |
## request access from bbslink.net | |
syscode = "xxxxx" # Your system code (username) | |
authcode = "xxxxxxxxxx"; # Your system's authorisation code | |
schemecode = "xxxxxxxxxx"; # Scheme code | |
## User configurable bits end here | |
## DO NOT EDIT BELOW THIS LINE | |
version = "0.02" | |
import md5 | |
import random | |
import string | |
import httplib | |
import os | |
import sys | |
import dd | |
if (dd.initdoor(sys.argv[1])==0): | |
print "Ugh. Run me from DD\n" | |
sys.exit(-1) | |
else: | |
## Calculates a hex MD5 digest of given string s | |
def getMD5Hash(s): | |
m = md5.new() | |
m.update(s) | |
rv = m.hexdigest() | |
return rv | |
## get door code from args | |
print len(sys.argv) | |
if not len(sys.argv) == 4: | |
print "BORK! Usage: doorclient.py <doorcode>" | |
exit(42) | |
## print welcome message | |
os.system("clear") | |
dd.sendstring("BBS InterLink - doorclient.py " + version + "\n -=- Courtesy of Sampsa Laine, B4BBS (2:250/7), http://sampsa.com/b4bbs -=- \n") | |
dd.sendstring("-=- Modified for DayDream by nolageek -=-\n") | |
dd.pause() | |
## getting our variables and the door name. | |
doorcode = sys.argv[2] | |
usernumber = dd.getvar(dd.USER_ACCOUNT_ID) | |
screenrows = dd.getvar(dd.USER_SCREENLENGTH) | |
scripttype = "Python (DayDream)" | |
scriptver = version | |
## generate xkey | |
xkey = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(6)).lower() | |
## get token | |
h1 = httplib.HTTPConnection(host) | |
h1.request("GET", "/token.php?key=" + xkey) | |
r1 = h1.getresponse() | |
token = r1.read() | |
token = str(token).strip() | |
## authorize | |
headers = { | |
"X-User": usernumber, | |
"X-System": syscode, | |
"X-Auth": getMD5Hash(authcode + token), | |
"X-Code": getMD5Hash(schemecode + token), | |
"X-Rows": screenrows, | |
"X-Key": xkey, | |
"X-Door": doorcode, | |
"X-Token": token, | |
"X-Type": scripttype, | |
"X-Version": scriptver | |
} | |
h2 = httplib.HTTPConnection(host) | |
h2.request("GET","/auth.php?key=" + xkey,"",headers) | |
r2 = h2.getresponse() | |
status = r2.read() | |
status = str(status).strip() | |
if status == "complete": | |
os.system("telnet -K -8 " + host) | |
else: | |
dd.sendstring("An error occurred when contacting the door server:") | |
dd.sendstring("[" + status + "]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment