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 hidden or 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) |
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
Http get request to sinkhole and public ip fetch in python: