#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright GNU/GPL 2009 Fitorec # # ____ _ _ .--. # | __ |(_) | | ___ ____ ___ ____ | o_o | # | | _ | ||_ _|/ _ \ / __// _ \ / __/ | :_/ | # | __ || | | || (_) || | | __/| (__ // \ \ # |_| |_| | | \___/ |_| \___/ \___( (| | ) # http://fitorec.wordpress.com /'\_ _/ # \___)=(___/ # Descripción: script que se conecta el router 2wire para ver # los hosts en que están conectados, útil para detectar intrusos import urllib2 """ Funcion encargada de conectarse al route(http://gateway.2wire.net/xslt) """ def main(): cookie_h = urllib2.HTTPCookieProcessor() opener = urllib2.build_opener(cookie_h) urllib2.install_opener(opener) ua = 'Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9.0.11) ' ua += ' Gecko/2009061118 Fedora/3.0.11-1.fc10 Firefox/3.0.11' h = {"User-Agent": ua} r = urllib2.Request("http://gateway.2wire.net/xslt", headers=h) f = urllib2.urlopen(r) htmlContent = f.read() f.close() while htmlContent.find("icon_small_pc.gif")>= 0 : htmlContent = htmlContent[htmlContent.find("icon_small_pc.gif"):] htmlContent = htmlContent[htmlContent.find('"textmono">'):] htmlContent = htmlContent[htmlContent.find(">")+1:] user = htmlContent[:htmlContent.find("")] print user return 0 if __name__ == '__main__': main()