Skip to content

Commit 3facc63

Browse files
committed
Update hackUtils.py
1 parent 0a43fd4 commit 3facc63

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

hackUtils.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -575,38 +575,44 @@ def getShellByFeiFeiCMS(url):
575575
except Exception, e:
576576
return "no info!"
577577

578-
def fetchIPs(value,page):
578+
def fetchCensys(value,field,page):
579579
API_URL = "https://www.censys.io/api/v1"
580580
UID = "3ac350c3-21f9-46be-aeb7-d18f832006f9" #Your API UID
581581
SECRET = "UBqUKkuUevh2pZqfO3fQalqNVDheGWuc" #Your API SECRET
582582
value = value.strip()
583+
field = field.strip()
583584
now = time.strftime('%H:%M:%S',time.localtime(time.time()))
584-
print "["+str(now)+"] [INFO] Fetching IPs from Censys..."
585+
print "["+str(now)+"] [INFO] Fetching IPs/URLs from Censys..."
585586
for i in range(1,page):
586587
data = {
587588
"query":value,
588589
"page":int(i),
589-
"fields":["ip"]
590+
"fields":[field]
590591
}
591-
res = requests.post(API_URL + "/search/ipv4", data=json.dumps(data), auth=(UID, SECRET)).text
592+
if field == "ip":
593+
res = requests.post(API_URL + "/search/ipv4", data=json.dumps(data), auth=(UID, SECRET)).text
594+
elif field == "domain":
595+
res = requests.post(API_URL + "/search/websites", data=json.dumps(data), auth=(UID, SECRET)).text
592596
try:
593597
results = json.loads(res)
594598
for result in results["results"]:
595-
ip=result["ip"]
599+
censys=result[field]
596600
mynow = time.strftime('%H:%M:%S',time.localtime(time.time()))
597-
logfile(ip,'censys.txt')
598-
print "["+str(mynow)+"] [INFO] "+ip
601+
if field == "domain":
602+
censys = "http://"+censys
603+
logfile(censys,'censys.txt')
604+
print "["+str(mynow)+"] [INFO] "+censys
599605
except Exception:
600606
mynow = time.strftime('%H:%M:%S',time.localtime(time.time()))
601607
print "["+str(mynow)+"] [WARNING] nothing found, please check API UID and SECRET!"
602608
output = os.path.dirname(os.path.realpath(__file__))+"/censys.txt"
603609
if os.path.exists(output):
604-
print "\n[INFO] Fetched IPs:"
610+
print "\n[INFO] Fetched IPs/URLs:"
605611
print "[*] Output File: "+output
606612

607613
def myhelp():
608614
print "\n+-----------------------------+"
609-
print "| hackUtils v0.0.5 |"
615+
print "| hackUtils v0.0.6 |"
610616
print "| Avfisher - avfisher.win |"
611617
print "| [email protected] |"
612618
print "+-----------------------------+\n"
@@ -615,7 +621,8 @@ def myhelp():
615621
print " -h, --help Show basic help message and exit"
616622
print " -b keyword, --baidu=keyword Fetch URLs from Baidu based on specific keyword"
617623
print " -g keyword, --google=keyword Fetch URLs from Google based on specific keyword"
618-
print " -c keyword, --censys=keyword Fetch IPs from Censys based on specific keyword"
624+
print " -i keyword, --censysip=keyword Fetch IPs from Censys based on specific keyword"
625+
print " -u keyword, --censysurl=keyword Fetch URLs from Censys based on specific keyword"
619626
print " -w keyword, --wooyun=keyword Fetch URLs from Wooyun Corps based on specific keyword"
620627
print " -j url|file, --joomla=url|file Exploit SQLi for Joomla 3.2 - 3.4"
621628
print " -r url|file, --rce=url|file Exploit Remote Code Execution for Joomla 1.5 - 3.4.5 (Password: handle)"
@@ -625,7 +632,8 @@ def myhelp():
625632
print "\nExamples:"
626633
print " hackUtils.py -b inurl:www.example.com"
627634
print " hackUtils.py -g inurl:www.example.com"
628-
print " hackUtils.py -c 1099.java-rmi"
635+
print " hackUtils.py -i 1099.java-rmi"
636+
print " hackUtils.py -u 1099.java-rmi"
629637
print " hackUtils.py -w .php?id="
630638
print " hackUtils.py -j http://www.joomla.com/"
631639
print " hackUtils.py -j urls.txt"
@@ -639,7 +647,7 @@ def myhelp():
639647

640648
def main():
641649
try:
642-
options,args = getopt.getopt(sys.argv[1:],"hb:g:c:w:j:r:f:d:e:",["help","baidu=","google=","censys=","wooyun=","joomla=","rce=","ffcms=","domain=","encrypt="])
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="])
643651
except getopt.GetoptError:
644652
print "\n[WARNING] error, to see help message of options run with '-h'"
645653
sys.exit()
@@ -651,8 +659,10 @@ def main():
651659
fetchUrls('baidu',value,50)
652660
if name in ("-g","--google"):
653661
fetchUrls('google',value,50)
654-
if name in ("-c","--censys"):
655-
fetchIPs(value,50)
662+
if name in ("-i","--censysip"):
663+
fetchCensys(value,"ip",50)
664+
if name in ("-u","--censysurl"):
665+
fetchCensys(value,"domain",50)
656666
if name in ("-w","--wooyun"):
657667
fetchUrls('wooyun',value,50)
658668
if name in ("-j","--joomla"):

0 commit comments

Comments
 (0)