Fake web server reply
In this section, you will learn how to create a fake web server signature. This is the application layer code. This section's code has no relation to the previous code. In order to get the server signature or banner grabbing, I am going to use the ID Serve tool.
Let's see the fake_webserver.py
code:
- Use the following modules in the program. The
logger1
module is used to create a log file. You will see the code oflogger1
later:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import logger1
- Look at the following piece of code carefully. The
fakewebserver
class inherits theBaseHTTPRequestHandler
class. Thesend_response
method is overriding the method of theBaseHTTPRequestHandler
class because we are sending our custom message asself.send_header('Server', "mohit
raj")
. Thelog_date_time_string
andsend_header
methods and theclient_address
instance variable are inherited from theBaseHTTPRequestHandler
class. Here I am sending themohit raj
server name...