Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check if WannaCry SinkHole is reachable, as per its code.
from __future__ import print_function
import ctypes
DLL_KERNEL32 = ctypes.windll.kernel32
DLL_WININET = ctypes.windll.wininet
handle_inet = DLL_WININET.InternetOpenA(None, 1, None, None, None)
response = DLL_WININET.InternetOpenUrlA(
handle_inet,
'http://iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com/',
None,
None,
0x84000000,
None)
if response:
print('SinkHole reachable')
DLL_WININET.InternetCloseHandle(response)
else:
print('SinkHole NOT reachable!!')
DLL_WININET.InternetCloseHandle(handle_inet)
@ghost

This comment has been minimized.

Show comment
Hide comment

ghost commented May 13, 2017

@thez3r0

This comment has been minimized.

Show comment
Hide comment
@thez3r0

thez3r0 commented May 13, 2017

@arehmandev

This comment has been minimized.

Show comment
Hide comment
@arehmandev

arehmandev May 13, 2017

Http get request to sinkhole and public ip fetch in python:

import urllib2
from urllib2 import urlopen

ipverifier = "http://ip.42.pl/raw"
publicip = urlopen(ipverifier).read()

url = "http://iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com/"

def sinkholetest(endpoint):
    try:
        urllib2.urlopen(endpoint).read()
        print "WannaCry Sinkhole was reached"
        print "Your public ip is", publicip
    except urllib.error.URLError as e:
        print "WannaCry Sinkhole not reachable"
        try:
            print "Your public ip is", publicip
        except urllib.error.URLError as e:
            print "Are you sure you're connected to the internet?"
    return

sinkholetest(url)

arehmandev commented May 13, 2017

Http get request to sinkhole and public ip fetch in python:

import urllib2
from urllib2 import urlopen

ipverifier = "http://ip.42.pl/raw"
publicip = urlopen(ipverifier).read()

url = "http://iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com/"

def sinkholetest(endpoint):
    try:
        urllib2.urlopen(endpoint).read()
        print "WannaCry Sinkhole was reached"
        print "Your public ip is", publicip
    except urllib.error.URLError as e:
        print "WannaCry Sinkhole not reachable"
        try:
            print "Your public ip is", publicip
        except urllib.error.URLError as e:
            print "Are you sure you're connected to the internet?"
    return

sinkholetest(url)
@mgc323

This comment has been minimized.

Show comment
Hide comment
@mgc323

mgc323 May 13, 2017

Slight change to the module definitions for Python 3. Hope this helps someone.

from urllib.request import urlopen
from urllib.error import URLError

url = 'http://iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com/'

def sinkholetest(endpoint):
    try:
        urlopen(endpoint).read()
        print ('WannaCry Sinkhole was reached')
    except URLError as e:
        print ('WannaCry Sinkhole not reachable')
    return

sinkholetest(url)

mgc323 commented May 13, 2017

Slight change to the module definitions for Python 3. Hope this helps someone.

from urllib.request import urlopen
from urllib.error import URLError

url = 'http://iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com/'

def sinkholetest(endpoint):
    try:
        urlopen(endpoint).read()
        print ('WannaCry Sinkhole was reached')
    except URLError as e:
        print ('WannaCry Sinkhole not reachable')
    return

sinkholetest(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment