Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 64 lines (57 sloc) 2.62 KB
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# A notifier leech invaders internet.
# Copyright (c) 2011, Nycholas de Oliveira e Oliveira <nycholas@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the Nycholas de Oliveira e Oliveira nor the names of
# its contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import re
import base64
import urllib2
# DI-524
URL = 'http://192.168.0.1/wlcl.htm'
USERNAME = 'admin'
PASSWORD = ''
AUTHORIZATION = base64.encodestring('%s:%s' % (USERNAME, PASSWORD))[:-1]
REGEX_TEMPLATE = r'<tr><td>(?P<datetime>.+?)</td><td>(?P<netmask>\w{2}-\w{2}-\w{2}-\w{2}-\w{2}-\w{2})</td></tr>'
"""request = urllib2.Request(URL)
request.add_header('Authorization', 'Basic %s' % AUTHORIZATION)
handle = urllib2.urlopen(request)
content = handle.read()
"""
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, URL, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
pagehandle = urllib2.urlopen(URL)
content = pagehandle.read()
pattern = re.compile(REGEX_TEMPLATE, re.IGNORECASE)
groups = pattern.groupindex #sorted(groups, key=groups.__getitem__)
searches = re.findall(pattern, content)
print groups
print searches
print ' + FOUND %d LEECH INVADERS!' % len(searches)
Jump to Line
Something went wrong with that request. Please try again.