Projects STRLCPY pentest-tools Commits c98e5238
🤬
  • ■ ■ ■ ■ ■ ■
    cloudflare-origin-ip.py
    skipped 13 lines
    14 14  import time
    15 15  import textwrap
    16 16  from functools import partial
    17  -from urlparse import urlparse
     17 +# from urlparse import urlparse
     18 +from urllib import parse
    18 19  from termcolor import colored
    19 20  from netaddr import *
    20 21  from multiprocessing.dummy import Pool
    skipped 87 lines
    108 109   t_sources = [ 'censys', 'crtsh' ]
    109 110   
    110 111  if 'censys' in t_sources:
    111  - CENSYS_API_URL = 'https://censys.io/api/v1'
     112 + CENSYS_API_URL = 'https://search.censys.io/api'
    112 113   try:
    113 114   CENSYS_UID = os.environ['CENSYS_UID']
    114 115   CENSYS_SECRET = os.environ['CENSYS_SECRET']
    skipped 6 lines
    121 122   
    122 123  # https://stackoverflow.com/questions/5619685/conversion-from-ip-string-to-integer-and-backward-in-python
    123 124  def IP2Int(ip):
    124  - o = map(int, ip.split('.'))
     125 + o = list( map(int, ip.split('.')) )
    125 126   res = (16777216 * o[0]) + (65536 * o[1]) + (256 * o[2]) + o[3]
    126 127   return res
    127 128   
    skipped 60 lines
    188 189   headers = {"Content-Type":"application/json"}
    189 190   try:
    190 191   ex = 0
    191  - r = requests.post( CENSYS_API_URL+'/search/ipv4', data=json.dumps(query), headers=headers, auth=(CENSYS_UID,CENSYS_SECRET) )
     192 + r = requests.get( CENSYS_API_URL+'/v2/hosts/search?q=deciplus.pro', headers=headers, auth=(CENSYS_UID,CENSYS_SECRET) )
    192 193   except Exception as e:
    193 194   ex = 1
    194 195   print( colored("[-] error occurred: %s" % e, 'red') )
    195 196   if ex == 0 and r.status_code == 200:
    196 197   j = r.json()
    197  - print( colored("[+] %d ips added" % len(j['results']), 'green') )
    198  - if j['status'] == 'ok' and type(j['results']) is list and len(j['results'])>0:
    199  - for i in j['results']:
     198 + print( colored("[+] %d ips added" % len(j['result']), 'green') )
     199 + if int(j['code']) == 200 and j['status'] == 'OK' and type(j['result']) is dict and len(j['result'])>0 and type(j['result']['hits']) is list and len(j['result']['hits'])>0:
     200 + for i in j['result']['hits']:
    200 201   t_ips.append( i['ip'] )
    201  - 
    202 202   
    203 203  def readIPfromFile( domain, ipsrc ):
    204 204   print( "[+] Reading datas from file: %s" % ipsrc )
    skipped 169 lines
    374 374   
    375 375  if not url.startswith( 'http' ):
    376 376   url = 'https://'+url
    377  -t_url_parse = urlparse( url )
     377 +t_url_parse = parse.urlparse( url )
     378 +# t_url_parse = urlparse( url )
    378 379  t_host_parse = tldextract.extract( t_url_parse.netloc )
    379 380  domain = host = t_host_parse.domain + '.' + t_host_parse.suffix
    380 381  if len(t_host_parse.subdomain):
    skipped 108 lines
Please wait...
Page is in error, reload to recover