The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Python Scanner
Discuss Python Scanner in the Python Programming forum on Dev Shed. Python Scanner Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 28th, 2003, 03:39 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
|
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.
|

November 28th, 2003, 05:35 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
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.
__________________
programming language development: www.netytan.com – Hula
|

November 28th, 2003, 05:45 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
|
hey thanks man, now works perfectly for me. One more question how can I know which ports are open? Thanks again
|

November 28th, 2003, 06:04 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|