Last active
March 20, 2018 13:50
-
-
Save dfirfpi/54cae73f590be7e3b06c05436d368f79 to your computer and use it in GitHub Desktop.
Check if WannaCry SinkHole is reachable, as per its code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
I just wrote a batch version of it : https://github.com/thez3r0/Sinkholer/blob/master/sinkholer.bat
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)
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
www missing in url - https://gist.github.com/errantbot/bb4934917c01a0617287500eaf61c86b