Python SMS bot

Questions about programming languages and debugging
Post Reply
User avatar
FaoX
suck-o-fied!
suck-o-fied!
Posts: 76
Joined: 07 Sep 2007, 16:00
16
Contact:

Python SMS bot

Post by FaoX »

Hey guys, working on another python project and I've run into a bump. My idea is to make a bot on my computer then when run will connect to a google account which I have set up for it. It will then listen to any messages sent to it and if you send it the correct message it will record your current address you sent from and consider you an authorized user. Well I did get that to work using xmppy but the problem is that my end goal was to piggyback on googles free texting system so that I could send commands to my home pc from my phone. For a number of tasks such as turning on a temporary ftp server to show a friend a file or shutting down my pc if say a storm or something was in the area. Well google apparently doesn't send those received texts to its jabber part and because of this I believe I may have to start over, but I'm not sure where to go from here to gain access to it. Any help would be appreciated. Though I'm pretty sure I will need to start over here's my current bare bones code.

http://code.suck-o.com/42420" onclick="window.open(this.href);return false;" onclick="window.open(this.href);return false;
\"The OS is detected as NetBSD (it will even run on your toaster).\"

User avatar
DNR
Digital Mercenary
Digital Mercenary
Posts: 6114
Joined: 24 Feb 2006, 17:00
18
Location: Michigan USA
Contact:

Re: Python SMS bot

Post by DNR »

VERY nice.
I would just look into other sms services besides google.

I like to see the suck-o bot team work this.. :-k
What else do you have?

DNR
-
He gives wisdom to the wise and knowledge to the discerning. He reveals deep and hidden things; he knows what lies in Darkness, and Light dwells with him.

User avatar
FaoX
suck-o-fied!
suck-o-fied!
Posts: 76
Joined: 07 Sep 2007, 16:00
16
Contact:

Re: Python SMS bot

Post by FaoX »

Well I have some simple mechanics worked out for shutdown, and still tinkering with a python ftp server. But I don't want to push forward with its commands till I find a solution to the sms problem. When looking around all I can find are services that either put adds into your texts (wich would be problematic for sending and recieving IO. Or its a charged service. As far as I'm aware google is the only service that offers free sms. If anyone knows otherwise please let me know.

Ps. First time I've had my code complimented, caused a nerdgasm. Thank you for that. haha
\"The OS is detected as NetBSD (it will even run on your toaster).\"

User avatar
FaoX
suck-o-fied!
suck-o-fied!
Posts: 76
Joined: 07 Sep 2007, 16:00
16
Contact:

Re: Python SMS bot

Post by FaoX »

UPDATE: Found that google has a python API for using their google voice, wich includes their sms and phone calls, working with that now to find a minimal framework to use. So far its actually pretty simple. Ive already gotten into to in and send text messages to my phone. Now once I work out the receiving section and get the code to parse it and detect whether its a valid input should be a breeze. My only worry is after retrieval how much useless data I may have to remove before passing it on.

Here is the api if anyone else would like to tinker with it.
http://code.google.com/p/pygooglevoice/" onclick="window.open(this.href);return false;

though connection issues is a problem there is a fix, use these files instead.
https://code.google.com/r/bwpayne-pygoo ... -auth-fix/" onclick="window.open(this.href);return false;
\"The OS is detected as NetBSD (it will even run on your toaster).\"

User avatar
DNR
Digital Mercenary
Digital Mercenary
Posts: 6114
Joined: 24 Feb 2006, 17:00
18
Location: Michigan USA
Contact:

Re: Python SMS bot

Post by DNR »

well I went off a side track and looked at hardware to replace the SMS services offered by internet hosts.

one idea is just to use a peer to peer or RAS hardware like routers and modems. Instead of using the internet to communicate with your computer - you use your phone. In this case you would set up a GSM device - either a modem with a SIM card just like a cellphone or broadband modem - so now your desktop PC is just a oversized 'smartphone'. With a 'cellco' address instead of a IP, you send SMS messages via another phone.

Then another idea is to check on some of the other protocols - SMPP, Radio Interface Layer (microsoft!), to find ways to connect hardware (radio transceiver) to the PC and use wireless or RF to control the PC.

A wireless card with a hi-gain antenna is not too cost prohibitive.

I just try to find ways to:
1. use free, open source services
2. use a system that is not dedicated to pay service, ie - ISP.

Anyways - back to work
The big letdown after a nerdgasm is the need to top what you did, there is always a better way to do it.

DNR
-
He gives wisdom to the wise and knowledge to the discerning. He reveals deep and hidden things; he knows what lies in Darkness, and Light dwells with him.

User avatar
FaoX
suck-o-fied!
suck-o-fied!
Posts: 76
Joined: 07 Sep 2007, 16:00
16
Contact:

Re: Python SMS bot

Post by FaoX »

Well I've been tinkering and searching for a few days now and although the example code for the GoogleVoice API works and retrieves all of the text messages the bots account receives I know little to nothing about BeautifulSoup. Because of this I've yet to figure out how to extract only the data I need from it. I need only the newest message and its sender.

This is what the example code prints out.

{u'text': u'Test1', u'from': u'ProfessorBubbles:', 'id': u'65877d981d18fc3bd6785d0d330c9b8ed8a3fa62', u'time': u'1:17 AM'}
{u'text': u'test2', u'from': u'Me:', 'id': u'65877d981d18fc3bd6785d0d330c9b8ed8a3fa62', u'time': u'1:17 AM'}
{u'text': u'test3', u'from': u'Me:', 'id': u'65877d981d18fc3bd6785d0d330c9b8ed8a3fa62', u'time': u'1:37 AM'}

And here is the example code if anyone can point me in the right direction to research or give me an example on how to extract what I need I would be very thankfull.

http://code.suck-o.com/42421" onclick="window.open(this.href);return false;" onclick="window.open(this.href);return false;
\"The OS is detected as NetBSD (it will even run on your toaster).\"

User avatar
FaoX
suck-o-fied!
suck-o-fied!
Posts: 76
Joined: 07 Sep 2007, 16:00
16
Contact:

Re: Python SMS bot

Post by FaoX »

Alright still chugging along. Was able to cleanup the output using a dictionary to replace anything I don't need. Now a new question was given to me by a friend. Could my app unlock my computer? In the scenario I'm out somewhere and say a friend is at my house and needs to use my computer. In this scenario I trust them to have access but its locked, and instead of giving them my password could I (with my bot) unlock the computer? I know there is a way of locking via the command line "rundll32.exe user32.dll, LockWorkStation".
But I can't seem to find anyway of internally unlocking it. The OS in question is windows 7.
\"The OS is detected as NetBSD (it will even run on your toaster).\"

User avatar
DNR
Digital Mercenary
Digital Mercenary
Posts: 6114
Joined: 24 Feb 2006, 17:00
18
Location: Michigan USA
Contact:

Re: Python SMS bot

Post by DNR »

just a quick look here, bit busy.

I thought your idea would go like so:

1. person wants access to your FTP directory (so he needs user/pass - and it assigns privileges to the user)
2. you wake your computer, it was offline.
3. now computer is awake, person can log on to your port 21 FTP
Person can only access areas you assign to the user - never root.

I liked the idea that the computer is offline, in sleep or hibernation - you cannot hack into a computer that is offline. You have to send the SMS to awake the HTTP/FTP connection. The SMS push could happen on a router as well, the idea is the SMS is the first key to unlocking your 'server' to the rest of the WAN.

DNR
-
He gives wisdom to the wise and knowledge to the discerning. He reveals deep and hidden things; he knows what lies in Darkness, and Light dwells with him.

User avatar
FaoX
suck-o-fied!
suck-o-fied!
Posts: 76
Joined: 07 Sep 2007, 16:00
16
Contact:

Re: Python SMS bot

Post by FaoX »

No instead of it being asleep, the http/ftp server just isnt running, which you can't hack a server that Isn't running. The bot also being technically a client itself connecting to google means that would have to either spoof my phone number or hack my google account to gain access to the bot. I have a working project now I'm just working out what commands I want it to use etc. Here is my working bot.

http://code.suck-o.com/42422^_^
\"The OS is detected as NetBSD (it will even run on your toaster).\"

User avatar
DNR
Digital Mercenary
Digital Mercenary
Posts: 6114
Joined: 24 Feb 2006, 17:00
18
Location: Michigan USA
Contact:

Re: Python SMS bot

Post by DNR »

that is good, I was too quick to write 'sleep or hibernate', it is the better idea to awake the web services than to awake the machine itself from 'sleep or hibernation' (we all know how well 'sleep' reloads drivers when the machine is told to awake, not very well)

I do like how the code makes the machine independent or flexible - I suppose you could have called libs like smtplib (is there a SMSlib?) and make direct contact with a remote SMS server. by not coding in remote server IPs, it allows your machine to still receive communication while remote servers are down or time out.

It works for you, thats the best start in coding. I do like your style of writing, some people write code so messy and convoluted I want to shoot the person.

DNR
-
He gives wisdom to the wise and knowledge to the discerning. He reveals deep and hidden things; he knows what lies in Darkness, and Light dwells with him.

Post Reply