|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Python Scanner
Hi, I would like to know how can I detect what server is using some web site?, what OS?, version? and all that kind of info. Im trying something like:
Code:
import asyncore, socket
class AsyncGet(asyncore.dispatcher):
def __init__(self, host):
asyncore.dispatcher.__init__(self)
self.host = host
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect((host,80))
self.request = 'GET /index.html HTTP/1.0\r\n\r\n'
self.outf = None
print 'Requesting server from',host
Is that correct? Last edited by Gerardoj : November 28th, 2003 at 04:14 PM. |
|
#2
|
||||
|
||||
|
Way, pretty low level thing you got going on there.. you can get quite allot of info about a webpage very easily with the urllib module..
>>> import urllib >>> urllib.urlopen('http://www.python.org/').info() <httplib.HTTPMessage instance at 0x01074558> >>> print urllib.urlopen('http://www.python.org/').info() Age: 7 Accept-Ranges: bytes Date: Fri, 28 Nov 2003 23:25:38 GMT Content-Length: 10611 Content-Type: text/html Server: Apache/1.3.26 (Unix) Last-Modified: Sat, 22 Nov 2003 18:48:15 GMT ETag: "5a7599-2973-3fbfaf6f" Via: 1.1 webcacheB10 (NetCache NetApp/5.3.1D2) >>> print urllib.urlopen('http://www.python.org/').info()['Server'] Apache/1.3.26 (Unix) >>> >>> d = dict(urllib.urlopen('http://www.python.org/').info()) >>> d {'content-length': '10611', 'via': '1.1 webcacheB10 (NetCache NetApp/5.3.1D2)', 'age': '255', 'server': 'Apache/1.3.26 (Unix)', 'last-modified': 'Sat, 22 Nov 2003 18:48:15 GMT', 'etag': '"5a7599-2973-3fbfaf6f"', 'date': 'Fri, 28 Nov 2003 23:25:38 GMT', 'content-type': 'text/html', 'accept-ranges': 'bytes'} >>> You have Server type, version and platform all in one key! What other info are you trying to get here? Mark. |
|
#3
|
||||
|
||||
|
hey thanks man, now works perfectly for me. One more question how can I know which ports are open? Thanks again
|
|
#4
|
||||
|
||||
|
as far as i know your can't.. or not with a spacific module, if you had SSH/telnet access you should connect to the server and check what ports are open from there using the telnetlib module..
My best bet would be to try and connect to each port one by one (i dont know how fast this will be) and return only the open ports.. If i think of another way i'll let you know! Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Python Scanner |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|