Skip to content

Instantly share code, notes, and snippets.

@fitorec
Created December 18, 2009 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitorec/259463 to your computer and use it in GitHub Desktop.
Save fitorec/259463 to your computer and use it in GitHub Desktop.
se conecta el router 2wire para ver los hosts en que están conectados, útil para detectar intrusos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright GNU/GPL 2009 Fitorec <chanerec@gmail.com>
#
# ____ _ _ .--.
# | __ |(_) | | ___ ____ ___ ____ | 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("</span>")]
print user
return 0
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment