cmc-csci040 icon indicating copy to clipboard operation
cmc-csci040 copied to clipboard

DPRK webpages not loading

Open m1keh0uk opened this issue 8 months ago • 4 comments

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!

m1keh0uk avatar Apr 05 '25 19:04 m1keh0uk

I'm having the same issue

charlottegjordan avatar Apr 07 '25 00:04 charlottegjordan

My short answer is:

  1. 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.

  2. This block is probably short lived (e.g. 1 hour).

  3. 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.

mikeizbicki avatar Apr 07 '25 04:04 mikeizbicki

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.

m1keh0uk avatar Apr 09 '25 02:04 m1keh0uk

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.

mikeizbicki avatar Apr 09 '25 04:04 mikeizbicki