Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: ganondolf en 25 Septiembre 2014, 20:39 pm



Título: como poder escuchar puerto 80 mediante socket en python
Publicado por: ganondolf en 25 Septiembre 2014, 20:39 pm
alguien sabe como poder escuchar el puerto 80 mediante socket con python, ya que de manera comun, no hay resultados.

Código
  1. import socket
  2.  
  3. # create an INET, STREAMing socket
  4. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  5. # now connect to the web server on port 80 - the normal http port
  6. s.connect(("localhost", 80))
  7. # create an INET, STREAMing socket
  8. serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  9. # bind the socket to a public host, and a well-known port
  10. serversocket.bind((socket.gethostname(), 80))
  11. # become a server socket
  12. serversocket.listen(5)
  13. while True:
  14.    # accept connections from outside
  15.    (clientsocket, address) = serversocket.accept()
  16.    # now do something with the clientsocket
  17.    # in this case, we'll pretend this is a threaded server
  18.    ct = client_thread(clientsocket)
  19.    ct.run()