alessio-ds / BSCWhalesMonitor

BSC whales monitor and detector written in Python.
34 stars 18 forks source link

Just a Question - Blocked by CloudFlare Captcha? #1

Closed aXb0t closed 3 years ago

aXb0t commented 3 years ago

Hey @alessio-ds - this looks cool.

I was trying to test it out and was blocked by Cloudflare / 403 looks like a captcha issue I ran into.

Did you need to spoof a user agent or similar tactic to scrape the block information?

Printed out the text from the request + text at https://github.com/alessio-ds/BSCWhalesMonitor/blob/0a9a9bbc788df359592c54df3c71a4d2cb2f76cd/BSCWhales.py#L22

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>

<title>Attention Required! | Cloudflare</title>

<meta name="captcha-bypass" id="captcha-bypass" />
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]-->
<style type="text/css">body{margin:0;padding:0}</style>

<!--[if gte IE 10]><!-->
<script>
  if (!navigator.cookieEnabled) {
    window.addEventListener('DOMContentLoaded', function () {
      var cookieEl = document.getElementById('cookie-alert');
      cookieEl.style.display = 'block';
    })
  }
</script>
<!--<![endif]-->

    <script type="text/javascript">
    //<![CDATA[
    (function(){
      window._cf_chl_opt={
        cvId: "2",
        cType: "interactive",
        cNounce: "80892",
        cRay: "696810350c210a2e",
        cHash: "8677951511e0a58",
        cFPWv: "b",
        cTTimeMs: "1000",
        cLt: "n",
        cRq: {
          ru: "aHR0cHM6Ly9ic2NzY2FuLmNvbS8=",
          ra: "cHl0aG9uLXJlcXVlc3RzLzIuMjIuMA==",
          rm: "R0VU",
          d: "UwAGZJwKvxD7xfbe6GLTU6RS5p2Dq2qflpaNYrj0p8OueT+n776zkcLojcWMNm9fz8XSSDimk00GJdNeywbQIgIf062lRj10+n7JA9jssEQlFC5qmNIWrtn4J+vVD6jJMUwlXTG4HR3MkCA6PRUTRqIidJtP8d3bqkZ4s92ucJvht2oHrAayXGpZrP7B1Z9QMBlaVsIZld2JJtiBiLwVU4KIIpG80NxnPMDzKkFhg1aPDwW5RZe+qm0pnv8VkvC+4fks92Wf+RDX4PiQ+07fzlo4OGeWbqtoKU4/w+DbYbWJlI4KFy1iQ3GdgcPq63Ry6wwy3IR1PmUepnwn51XNCVgfKFLxLtFpdGlDMUvWiELsRYcn+ln0+1o1x5WDS2LazfDH1KNE7mL0KcCJuyZYfzMetkQNj1qk6M7aZfOQiF0AzhcQ+/2k4fb5TrjucPJxcB7JsEE89+5YHYZZha/+KBljFsp8UtIFzK33B4woYhCeetfeKtoo3u1R+lXWHzEFC0Cs5lbEucZge5cUa3pEoLG6qGnKdRguC0prtpOYyK1kzoYNA6SEP/Y80guWAMk7kNxjgdskBqeqyQvdkQE1+p3Lfpu8D/ZwYiL2harA0LkLPXlP8vOLDjrOy4ieKRAzpDK3C3ZNQ0TsCikEv4Ra4Dhi6U5C6nUi/FopXBrWm5OC2hlDHpKlRJQc2WmqPpq8prbdgj7GoxPgciQxIrXO/byaU19HiOWrIZh5gSayWmZlUJqGr6JNg5ILBWu6+a4A",
          t: "MTYzMjk0ODQxMS42OTYwMDA=",
          m: "D4jbew0t8k+KAOIqQ6JevVtwcKQIQndvhVIbC9VSDF8=",
          i1: "iehKTG+riAZJF/H/7vvt9g==",
          i2: "lP8Z6eKJONTSVjLiv4GtZA==",
          zh: "Qdzt30w05SSNEnt2SHcgPWWgkLJnkQjTrp30vcMIKNM=",
          uh: "JnPNhFrP9JDZz++jrWFNK99fEBZafo8DSm+TpH36hUY=",
          hh: "Vp8XgbAEBUZjzbvIYix7yiouCoI+nFD74k+vBpVmgrY=",
        }
      };
    }());
    //]]>
    </script>

<style type="text/css">
  #cf-wrapper #spinner {width:69px; margin:  auto;}
  #cf-wrapper #cf-please-wait{text-align:center}
  .attribution {margin-top: 32px;}
  .bubbles { background-color: #f58220; width:20px; height: 20px; margin:2px; border-radius:100%; display:inline-block; }
  #cf-wrapper #challenge-form { padding-top:25px; padding-bottom:25px; }
  #cf-hcaptcha-container { text-align:center;}
  #cf-hcaptcha-container iframe { display: inline-block;}
  @keyframes fader     { 0% {opacity: 0.2;} 50% {opacity: 1.0;} 100% {opacity: 0.2;} }
  #cf-wrapper #cf-bubbles { width:69px; }
  @-webkit-keyframes fader { 0% {opacity: 0.2;} 50% {opacity: 1.0;} 100% {opacity: 0.2;} }
  #cf-bubbles > .bubbles { animation: fader 1.6s infinite;}
  #cf-bubbles > .bubbles:nth-child(2) { animation-delay: .2s;}
  #cf-bubbles > .bubbles:nth-child(3) { animation-delay: .4s;}
</style>
</head>
<body>
  <div id="cf-wrapper">
    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
    <div id="cf-error-details" class="cf-error-details-wrapper">
      <div class="cf-wrapper cf-header cf-error-overview">

        <h1 data-translate="challenge_headline">One more step</h1>
        <h2 class="cf-subheadline"><span data-translate="complete_sec_check">Please complete the security check to access</span> bscscan.com</h2>

      </div>

      <div class="cf-section cf-highlight cf-captcha-container">
        <div class="cf-wrapper">
          <div class="cf-columns two">
            <div class="cf-column">

              <div class="cf-highlight-inverse cf-form-stacked">
                <form class="challenge-form interactive-form" id="challenge-form" action="/?__cf_chl_captcha_tk__=pmd_OKC34EqhDoWhejJ3jZYlV4ddWcUIv0j12CU.DVGT8b8-1632948411-0-gqNtZGzNAuWjcnBszQcR" method="POST" enctype="application/x-www-form-urlencoded">

    <div id='cf-please-wait'>
      <div id='spinner'>
        <div id="cf-bubbles">
            <div class="bubbles"></div>
            <div class="bubbles"></div>
            <div class="bubbles"></div>
        </div>
      </div>
      <p data-translate="please_wait" id="cf-spinner-please-wait">Please stand by, while we are checking your browser...</p>
      <p data-translate="redirecting" id="cf-spinner-redirecting" style="display:none">Redirecting...</p>
      </div>

  <input type="hidden" name="md" value="_wM_yjpahE1N8wrapQESOGgNH6FM9AMYMFcDMRXZjts-1632948411-0-AfUg2xORzJMSIfDXfOX61smP_q71cqo7A8pxhKni-kBSlV0z-zN7ByWLhc90Mw4YnsZNN3aZi-6jYGRiWAW7x7Vmo5mL88qOAoPpgjvgVWfBEjDSghjKxcAQ1VEmdb06XLfYEK6VMVC6ZtQwBLgNnGfxaxXG_tuGPDkSNtugvykM-DHpZUfptgWXujgwwd4Tn2xnX5CFrSg1k4PPqU9d9q8JMZm8RV8Dr9azD2Sx6qVmkEFa1--HJjHwTrYOPi_gxW-8x-WmZd_EtBO3OFf74yXl-p775E3w1ymBJqgiHUaRwr-d8YzIoKj3w8aS091DAlkNu98b80JI5J9NWivCMas4iOZ-nXP9tXxhRUa5rnmzjOHKjdo5jgfR3mzDrcryTE5zV-UoPudPMsM2Hb0XWicSQ4sJadbuvxC40_BzYS0Eu54C-GCujS9-rNaeM5UTCg7kATVSyZImdS2Y6Ntmq-I0yalCtQfKUJpsyBGnwapEAP23qs5AwHuhqcZVbWge4jOF4Rpw6CjD8oC1gnJXUi-JZy8Tz6FKl_OeUwXpCbV_5zJeFOuPVlzd2EAfJ2HHqYcS6eAQo65vgE-x0K-BXqsBAe5k-838QcA8lJDX2ITvxS-p-OqktT_FNicb1GR44rufSkGym5ywZ8IbXBIzD01wU5-ogqeTl8dwIMkQnuJk" />
  <input type="hidden" name="r" value="4rYw5F9AGsoR8xPzTCDgdKkL44LmxGyTQYRofIgsdTY-1632948411-0-AQarKiU6gIpi5BYt4PCaQHKpfnuQ2ln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oB+9R0ObCSnTe/6+jQsk66WYSg//Weg5S8tmGb2txTVO8Szjp2xYTshpRWEzpZF6tbcx8rBL8q5t3LbxDw2AG5gClUdfpKa5lw8N84pialM03kmWK8Pha4XnUG7M6USo+2ghpPGUChu2jw2c+il7/bersUZqZwA/jDc1yAZHEsxvnUTYvPiv9aU7u9t34eWsOh6nbCbROZhYJvYKvWxedckUWuwupHUkOt+S5oUw/3bH3PpYgG18p1wnJFXz4CuNhaWGul0c/+eweEGiokj/5sm8xAYaYsQ3sToIbKYsXCbuNPkgvyRxIL5V2TYcBlAQ/KNaW5qbln8EQQUGE+/Y50ghpPpIm/2bagdAEVTWRzIngQeee5CnVNLsv3qFJ4PIDAAnvOfB6tHw/994oAdxYPsj/ACiHAOaNki+p+8neiYko+AroM/WCZlrVVH1yZ/Jce2hpLU7SG47IS0kqucEHLyV6pw6QgyYkhfl3rUC+8GH8vuqO2hTxtku4uD2h7raeafQtjrNIv4w8rLSO3KIl4IDm3mGpZmkcxzx2xiJqR/L7mx3JV3ZTWAw8YvdZI4M8pmYzmqGaC+6lSGuCGziTGHJK4R3Xivb8ugzzW7Uu7GakbsRceJotoZa1Hyt3Z8=">
  <input type="hidden" name="cf_captcha_kind" value="h">
  <input type="hidden" name="vc" value="ed4960be56ff3764d0b90aa3114dbfe0">

  <noscript id="cf-captcha-bookmark" class="cf-captcha-info">
  <h1 data-translate="turn_on_js" style="color:#bd2426;">Please turn JavaScript on and reload the page.</h1>
  </noscript>
    <div id="no-cookie-warning" class="cookie-warning" data-translate="turn_on_cookies" style="display:none">
      <p data-translate="turn_on_cookies" style="color:#bd2426;">Please enable Cookies and reload the page.</p>
    </div>
  <script type="text/javascript">
  //<![CDATA[
    var a = function() {try{return !!window.addEventListener} catch(e) {return !1} },
      b = function(b, c) {a() ? document.addEventListener("DOMContentLoaded", b, c) : document.attachEvent("onreadystatechange", b)};
      b(function(){
        var cookiesEnabled=(navigator.cookieEnabled)? true : false;
        if(!cookiesEnabled){
          var q = document.getElementById('no-cookie-warning');q.style.display = 'block';
        }
      });
  //]]>
  </script>
  <div id="trk_captcha_js" style="background-image:url('/cdn-cgi/images/trace/captcha/nojs/h/transparent.gif?ray=696810350c210a2e')"></div>
</form>

  <script type="text/javascript">
    //<![CDATA[
    (function(){
        var isIE = /(MSIE|Trident\/|Edge\/)/i.test(window.navigator.userAgent);
        var trkjs = isIE ? new Image() : document.createElement('img');
        trkjs.setAttribute("src", "/cdn-cgi/images/trace/captcha/js/transparent.gif?ray=696810350c210a2e");
        trkjs.id = "trk_captcha_js";
        trkjs.setAttribute("alt", "");
        document.body.appendChild(trkjs);
        var cpo=document.createElement('script');
        cpo.type='text/javascript';
        cpo.src="/cdn-cgi/challenge-platform/h/b/orchestrate/captcha/v1?ray=696810350c210a2e";
        document.getElementsByTagName('head')[0].appendChild(cpo);
    }());
    //]]>
    </script>

              </div>
            </div>

            <div class="cf-column">
              <div class="cf-screenshot-container">

                <span class="cf-no-screenshot"></span>

              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="why_captcha_headline">Why do I have to complete a CAPTCHA?</h2>

            <p data-translate="why_captcha_detail">Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.</p>
          </div>

          <div class="cf-column">
            <h2 data-translate="resolve_captcha_headline">What can I do to prevent this in the future?</h2>

            <p data-translate="resolve_captcha_antivirus">If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.</p>

            <p data-translate="resolve_captcha_network">If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.</p>

          </div>
        </div>
      </div>

      <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">
  <p class="text-13">
    <span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">696810350c210a2e</strong></span>
    <span class="cf-footer-separator sm:hidden">&bull;</span>
    <span class="cf-footer-item sm:block sm:mb-1"><span>Your IP</span>: **withheld**</span>
    <span class="cf-footer-separator sm:hidden">&bull;</span>
    <span class="cf-footer-item sm:block sm:mb-1"><span>Performance &amp; security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing" id="brand_link" target="_blank">Cloudflare</a></span>

  </p>
</div><!-- /.error-footer -->

    </div>
  </div>

  <script type="text/javascript">
  window._cf_translation = {};

</script>

</body>
</html>
alessio-ds commented 3 years ago

Thanks a lot for telling me this! Yes, they've added a Cloudflare Captcha.

I fixxed it in my latest update: https://github.com/alessio-ds/BSCWhalesMonitor/commit/628841485baccfcdee12357ef003308dccf1fc81

Should work now! 👍🏻

aXb0t commented 3 years ago

Pulled the latest and tested on default $CAKE and DOGE, both seem to be doing what they should. :)

aXb0t commented 3 years ago

Cloudflare captcha is avoided now for token lookup