Skip to content

Instantly share code, notes, and snippets.

@racterub
Created May 23, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save racterub/7f26968a1f4c2c2c6e14269eda41fcd9 to your computer and use it in GitHub Desktop.
Save racterub/7f26968a1f4c2c2c6e14269eda41fcd9 to your computer and use it in GitHub Desktop.
patch for EmerldBlue and doublepulse exploit
#!/usr/bin/env python
import os
import subprocess
import sys
import time
print "Initializing....."
time.sleep(5)
ruleres = []
checkres = []
def checkresult(req):
res = req.communicate()
if len(str(res)) <= 40:
print "SUCCESS"
ruleres.append('y')
else:
print "ERROR: Unknown error occurs"
ruleres.append('n')
def checkfinal():
if "n" in ruleres:
print "something went wrong, please contact author!!!"
sys.exit(0)
else:
print "All firewall rules installed "
def checkexist(req):
res = req.communicate()
if len(str(res)) >= 300:
checkres.append('y')
else:
checkres.append('n')
#Check firewall already set or not
a = subprocess.Popen('netsh advfirewall firewall show rule name="block TCP 445 in"', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkexist(a)
b = subprocess.Popen('netsh advfirewall firewall show rule name="block TCP 139 in"', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkexist(b)
c = subprocess.Popen('netsh advfirewall firewall show rule name="block UDP 445 in"', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkexist(c)
d = subprocess.Popen('netsh advfirewall firewall show rule name="block UDP 139 in"', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkexist(d)
if "y" in checkres:
print 'firewall rules already existed'
print 'Exiting......'
time.sleep(5)
sys.exit(0)
else:
print "Installing......"
time.sleep(5)
#Install firewall rules
tcpf = subprocess.Popen('netsh advfirewall firewall add rule name="block TCP 445 in" protocol=TCP dir=in localport=445 action=block', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkresult(tcpf)
udpf = subprocess.Popen('netsh advfirewall firewall add rule name="block UDP 445 in" protocol=UDP dir=in localport=445 action=block', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkresult(udpf)
tcpo = subprocess.Popen('netsh advfirewall firewall add rule name="block TCP 139 in" protocol=TCP dir=in localport=139 action=block', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkresult(tcpo)
udpo = subprocess.Popen('netsh advfirewall firewall add rule name="block UDP 139 in" protocol=UDP dir=in localport=139 action=block', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE )
checkresult(udpo)
checkfinal()
time.sleep(5)
print "Follow the website's instruction for testing SMB's exploit"
time.sleep(5)
os.system("start https://racterubspace.lionfree.net/done.html")
os.system("pause")
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment