[Noisebridge-discuss] Unlocking the door via SMS

Micah Lee micahflee at gmail.com
Wed Mar 10 22:16:11 UTC 2010


On Wed, Mar 10, 2010 at 2:04 PM, Rachel McConnell <rachel at xtreme.com> wrote:
> This might be just secure enough to satisfy my twinge.  You have to have
> been there at least once to find out what the current SMS code word is.
>  Maybe it could be something that anyone can reset from the touch
> panels, or from pony?  I could go for that... might even write it.

I hard-coded "OPEN SESAME", but it would be easy for me to make a
simple web page hosted on pony (accessible from the touch panels) that
lets you update the secret and store it in a file, and use that file
to check for the right secret.

Also, in case anyone's interested, I used pygooglevoice
http://code.google.com/p/pygooglevoice/. Here's the source code:

from googlevoice import Voice
import sys
import time
import BeautifulSoup
import urllib

def extractsms(htmlsms) :
    """
    extractsms  --  extract SMS messages from BeautifulSoup tree of
Google Voice SMS HTML.

    Output is a list of dictionaries, one per message.
    """
    msgitems = []										# accum message items here
    #	Extract all conversations by searching for a DIV with an ID at top level.
    tree = BeautifulSoup.BeautifulSoup(htmlsms)			# parse HTML into tree
    conversations = tree.findAll("div",attrs={"id" : True},recursive=False)
    for conversation in conversations :
        #	For each conversation, extract each row, which is one SMS message.
        rows = conversation.findAll(attrs={"class" : "gc-message-sms-row"})
        for row in rows :								# for all rows
            #	For each row, which is one message, extract all the fields.
            msgitem = {"id" : conversation["id"]}		# tag this message
with conversation ID
            spans = row.findAll("span",attrs={"class" : True}, recursive=False)
            for span in spans :							# for all spans in row
                cl = span["class"].replace('gc-message-sms-', '')
                msgitem[cl] = ("
".join(span.findAll(text=True))).strip()	# put text in dict
            msgitems.append(msgitem)					# add msg dictionary to list
    return msgitems

# generate a hash string from a msg
def getHashstring(msg):
    return msg['text']+' '+msg['from']+' '+msg['id']+' '+msg['time']

# function to check for "open sesame" SMS, and to open the door if found
def checkForSMS():
    voice.sms()
    for msg in extractsms(voice.sms.html):
        hashString = getHashstring(msg)
        if hashString not in seenMessages:
            print 'new SMS: '+str(msg)
            if msg['text'].upper() == 'OPEN SESAME':
                # open the door
                print 'OPENING THE DOOR'
                urllib.urlopen("http://172.30.0.30/gate")
            seenMessages[hashString] = True

voice = Voice()
voice.login()

# messages that have already been looked at
seenMessages = dict()

# start by adding all the messages to seenMessages, so that we'll only
check for new messages
voice.sms()
for msg in extractsms(voice.sms.html):
    seenMessages[getHashstring(msg)] = True

while(True):
    checkForSMS()
    time.sleep(5)



More information about the Noisebridge-discuss mailing list