@@ -27,17 +27,18 @@ def check_once(url):
2727 try :
2828 headers = {
2929 'User-Agent' :
30- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
30+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit'
31+ '/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
3132 }
32- response = requests .get (url , headers = headers )
33+ response = requests .get (url , headers = headers , timeout = 5 )
3334 except requests .exceptions .ConnectionError :
3435 return False , - 1
3536 return response .ok , response .status_code
3637
3738
3839def check (url ):
3940 # We try for 5 times, with 3 seconds interval.
40- try_count = 5
41+ try_count = 1
4142 try_interval = 3
4243 for i in range (try_count ):
4344 ok , status_code = check_once (url )
@@ -51,37 +52,70 @@ def test_url():
5152 # Need to rewrite this so it generates a single, unique list of URLs,
5253 # removes any which are to be ignored, and then checks them. Would be
5354 # much cleaner.
54-
55+
5556 ignore_urls = [
56- "https://wpscan.com/" , # Cloudflare doesn't like GitHub checking it
57- "http://www.w3.org/TR/html4/loose.dtd" , # Don't need to check the DTD
58- "https://www.vmware.com/" , # Throwing a 403 for some reason, but can't see it going anywhere
59- "https://twitter.com/digininja" , # Twitter doesn't like GitHub checking it
60- "https://www.cgisecurity.com/xss-faq.html" , # Throwing a 403 for some reason, but can't see it going anywhere
61- "https://www.cgisecurity.com/csrf-faq.html" , # Throwing a 403 for some reason, but can't see it going anywhere
57+ "https://wpscan.com/" ,
58+ # Cloudflare doesn't like GitHub checking it
59+
60+ "http://www.w3.org/TR/html4/loose.dtd" ,
61+ # Don't need to check the DTD
62+
63+ # "https://twitter.com/digininja",
64+ # Twitter doesn't like GitHub checking it
65+
66+ "https://www.cgisecurity.com/xss-faq.html" ,
67+ # Timeout
68+
69+ "https://www.cgisecurity.com/csrf-faq.html"
70+ # Timeout
6271 ]
72+
73+ expected_codes = {
74+ "https://www.vmware.com/" : 403 ,
75+ "https://www.virtualbox.org/" : 402 ,
76+
77+ "https://github.com/digininja/DVWA/blob/master/README.md"
78+ "#vendor-files" : 429 ,
79+
80+ "https://github.com/digininja/DVWA/blob/master/README.md"
81+ "#apache-modules" : 429 ,
82+
83+ "https://hacks.mozilla.org/2020/08/"
84+ "changes-to-samesite-cookie-behavior/" : 403 ,
85+
86+ "https://blog.mozilla.org/security/2014/10/04/"
87+ "csp-for-the-web-we-have/" : 403 ,
88+
89+ "https://medium.com/@masjadaan/"
90+ "oracle-padding-attack-a61369993c86" : 403 ,
91+
92+ "https://www.golinuxcloud.com/brute-force-attack-web-forms" : 403 ,
93+ }
94+
6395 all_urls = []
6496 broken_urls = []
6597 for php_file in get_php_files ():
6698 for url in get_urls (php_file ):
6799 all_urls .append (url )
68-
100+
69101 # This removes any duplicates
70102 dedup_urls = list (dict .fromkeys (all_urls ))
71103
72104 for url in dedup_urls :
73- if not url in ignore_urls :
105+ if url not in ignore_urls :
74106 # print("checking %s" % url)
75107 ok , status_code = check (url )
76- if not ok :
77- # The php_file variable is now broken as it was set in a previous loop
108+ if not ok and status_code != expected_codes .get (url ):
109+ # The php_file variable is now broken
110+ # as it was set in a previous loop
78111 # and doesn't come across into this one.
79112
80- #print("failed to access %s from file %s with code %d" % (url, php_file, status_code))
113+ # print("failed to access %s from file %s with code
114+ # %d" % (url, php_file, status_code))
81115 # broken_urls.append((php_file, url, status_code))
82116 broken_urls .append ((url , status_code ))
83117
84- #for php_file, url, status_code in broken_urls:
118+ # for php_file, url, status_code in broken_urls:
85119 # print("%s\t%s\t%d" % (php_file, url, status_code))
86120
87121 for url , status_code in broken_urls :
0 commit comments