cmc-csci040
cmc-csci040 copied to clipboard
DPRK webpages not loading
Hi,
For some reason, none of the DPRK IPs will load on my browser.
I used to be able to visit the http://kcna.kp/kp webpage and visit it via the IP address, but now it won't load. This is the same for all of the IP's that came back positive from running the wardial lab.
My friend doesn't have an issue loading the pages on their device. I am being blocked from the webpages? Or is it just a me problem? Possible fixes?
Thanks!
I'm having the same issue
My short answer is:
-
The school wifi IP address is probably blocked, and if you try from another location (e.g. plugged into a dorm room ethernet or a lab machine) then it should work.
-
This block is probably short lived (e.g. 1 hour).
-
We'll talk in more detail about what exactly is going on in class on Tuesday. I will also extend the assignment due date until (at least) Thursday so there is no need to stress out about due dates for it right now.
print(is_server_at_hostname('kcna.kp/kp')) #returns True print(is_server_at_hostname('175.45.176.71')) #returns False
That IP address comes from https://whatismyip.live/dns/kcna.kp, so I'm confused as to why there are different results. My function passes all doctests.
Tried waiting it out— doesn't seem to be a short time out. I waited multiple hours.
Ahh... now I see the problem. You'll notice that you are also not able to visit the website http://175.45.176.71/ in your web browser. The problem is that visiting this raw ip address is not valid without sending the webserver a "Host" that you want to visit.
Most likely your is_server_at_hostname code looks something like
def is_server_at_hostname(hostname):
try:
requests.get(
url='http://' + hostname,
timeout=5,
)
return True
except requests.exceptions.ConnectionError:
return False
My version looks like
def is_server_at_hostname(hostname):
try:
# if the hostname is not an IP address,
# then we set the Host header variable to 'Host'
if hostname.replace('.', '').isdigit():
headers={'Host': 'Host'}
else:
headers={}
requests.get(
url='http://' + hostname,
timeout=5,
headers=headers,
)
return True
except requests.exceptions.ConnectionError:
return False
This function is able to find a server at that ip address
$ python3 -i wardial.py
>>> is_server_at_hostname('175.45.176.71')
True
>>> is_server_at_hostname('175.45.176.1')
False
Notice that my function constructs the headers dictionary and passes it to the requests.get function. Header information is optional information that is usually provided by web browsers. (We briefly talked about the user-agent header field in class that allows us to specify which web browser we are connecting from.)
Some (but not all) websites require that this Host field should be set in order to connect to an IP address directly. This is used in certain old setups to allow multiple different domains to be served from the same IP address. The DPRK servers don't actually do anything with the information in this field, but they require it or they will not send you the website information.
There was no way for you all to have known to include this in your call to requests.get. I should have included it in the example code that we did in class.