#!/usr/local/bin/python2.4 # -*- coding: iso-8859-2 -*- # # Script: sms.eraomnix.py # Version: 1.1 # Date: 06/12/2005 # Works ONLY with python 2.4.1 # Copyright 2005 Rodion rodion7(at)o2.pl # import cookielib, string, urllib, urllib2 debug = 0 login = '' password = '' def sendsms(sender, recipient, message): baseURL='http://www.eraomnix.pl' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) request = urllib2.Request(baseURL + '/msg/user/sponsored/welcome.do') request.add_header('User-Agent', 'Opera/8.51 (Windows NT 5.0; U; en)') try: result = opener.open(request) if debug: print 'Connecting with',baseURL except IOError: print 'Connection with %s failed.' % baseURL request = urllib2.Request(baseURL + '/sso2/omnix_iframe/login.jsp') request.add_header('User-Agent', 'Opera/8.51 (Windows NT 5.0; U; en)') try: result = opener.open(request) if debug: print 'Connecting with login frame' except IOError: print 'Connection with login frame failed.' for line in result.readlines(): if '"org.apache.struts.taglib.html.TOKEN"' in line: token = line.strip().split()[-2].split('"')[1] parmdicta = {'org.apache.struts.taglib.html.TOKEN' : token, 'login' : login, 'password' : password} request = urllib2.Request(baseURL + '/sso2/authenticate.do') postdata = urllib.unquote(urllib.urlencode(parmdicta)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.51 (Windows NT 5.0; U; en)') try: result = opener.open(request) if debug: print 'Login in',baseURL except IOError: print 'Connection with %s failed.' % baseURL for line in result.readlines(): if '"org.apache.struts.taglib.html.TOKEN"' in line: token = line.strip().split()[-2].split('"')[1] parmdictb = {'org.apache.struts.taglib.html.TOKEN' : token, 'top.phoneReceiver' : recipient, 'top.text' : message, 'top.characterLimit' : '110', 'top.signature' : sender, 'send.x' : '0', 'send.y' : '0'} request = urllib2.Request(baseURL + '/msg/user/sponsored/sms.do') postdata = urllib.unquote(urllib.urlencode(parmdictb)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.51 (Windows NT 5.0; U; en)') try: result = opener.open(request) if debug: print 'Send SMS' except IOError: print 'Connection with %s failed.' % baseURL # Main if __name__ == '__main__': import sys if len(sys.argv) < 4: print 'Sposób użycia:', sys.argv[0], ' ' print 'Przykład: ', sys.argv[0], 'inspektor 600123456 bardzo być może ale żaba pozostaje żab±' sys.exit(1) sender, recipient, message = sys.argv[1], sys.argv[2], ' '.join(sys.argv[3:]) sendsms(sender, recipient, message)