gwen001 / cloudflare-origin-ip

Try to find the origin IP of a webapp protected by Cloudflare.
MIT License
317 stars 64 forks source link

Response content size can be zero #10

Closed MMquant closed 11 months ago

MMquant commented 11 months ago
[+] Reading datas from file: ips
[+] 0 subdomains found, 27 ips added
[+] 27 unique ips collected
[+] Performing reference request...
Status=404, Length=0, Headers=9, Content-Type=text/plain; charset=utf-8
[+] Testing bypass...
[-] 40.126.38.21: Exceeded 30 redirects.
Traceback (most recent call last):
  File "/app/cloudflare-origin-ip.py", line 584, in <module>
    pool.map( partial(testBypass3,t_multiproc,r_reference,host), t_ips )
  File "/usr/local/lib/python3.12/multiprocessing/pool.py", line 367, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/multiprocessing/pool.py", line 774, in get
    raise self._value
  File "/usr/local/lib/python3.12/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
           ^^^^^^^^^^^^^^^^
  File "/app/cloudflare-origin-ip.py", line 458, in testBypass3
    score = responseCompare( r_reference, r )
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/cloudflare-origin-ip.py", line 490, in responseCompare
    score['dist_content'] = 100 - ( dist*100 / len(r_reference.content[0:COMPARE_FIRST_CHARS]) )
                                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: division by zero
MMquant commented 11 months ago
if len(r_reference.content[0:COMPARE_FIRST_CHARS]) != 0:
    score['dist_content'] = 100 - ( dist*100 / len(r_reference.content[0:COMPARE_FIRST_CHARS]) )

seems to fix it

gwen001 commented 11 months ago

Should be ok now, let me know.

Thank you!

MMquant commented 11 months ago

This is fixed but in the meantime I found another division by zero bug. Will create a new issue.