KyranRana / cloudflare-bypass

A new and improved PHP library which bypasses the Cloudflare IUAM page using cURL
MIT License
275 stars 97 forks source link

return new code to br encoding #115

Closed Laky-64 closed 5 years ago

Laky-64 commented 5 years ago

this is my output

HTTP/1.1 302 Moved Temporarily
--
  | Date: Fri, 03 May 2019 18:04:00 GMT
  | Content-Type: text/html
  | Content-Length: 159
  | Connection: keep-alive
  | Set-Cookie: __cfduid=d1809e099fc7555819174732dfa9f63881556906640; expires=Sat, 02-May-20 18:04:00 GMT; path=/; domain=.alta-definizione.info; HttpOnly; Secure
  | Set-Cookie: cf_clearance=5f49e7b74f2fb43896fc2b017d17fae2d14e7ec0-1556906640-1800-150; path=/; expires=Fri, 03-May-19 19:34:00 GMT; domain=.alta-definizione.info; HttpOnly
  | Location: /
  | Server: cloudflare
  | CF-RAY: 4d1427a5db8d3dab-MXP
  | X-Frame-Options: SAMEORIGIN
  |  
  | HTTP/1.1 301 Moved Permanently
  | Date: Fri, 03 May 2019 18:04:00 GMT
  | Transfer-Encoding: chunked
  | Connection: keep-alive
  | Cache-Control: max-age=3600
  | Expires: Fri, 03 May 2019 19:04:00 GMT
  | Location: https://alta-definizione.info/
  | Vary: Accept-Encoding
  | Server: cloudflare
  | CF-RAY: 4d1427a66c1d3dab-MXP
  |  
  | HTTP/2 200
  | date: Fri, 03 May 2019 18:04:00 GMT
  | content-type: text/html; charset=UTF-8
  | set-cookie: __cfduid=d69137777ae0cb128c08cd24b8d9fdba11556906640; expires=Sat, 02-May-20 18:04:00 GMT; path=/; domain=.alta-definizione.info; HttpOnly; Secure
  | vary: Accept-Encoding
  | x-powered-by: PHP/7.2.6
  | x-hyper-cache: continue - no file
  | x-cache: HIT
  | access-control-allow-origin: *
  | expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
  | server: cloudflare
  | cf-ray: 4d1427a76c263d93-MXP
  | content-encoding: br
  |  
  | ��CDT�z!��jj_�M����� <%R���6cɗd;���(� �������]�~�n����TjZ��*��̟�d�n����e���V�]J������.N���FrPc��g7�3È�,�,4��1T��E��l�a����*�QQЭF8{=�.�ǀp�wB5 �3v���,�yH�^u���R�U��`�A����5*,ˎ?��F;�  ��e�@S�'j�D����^���f��2oȌ����\�Kj�ƈ삺���Zl��� ��$w�ƾS�bI�^X��1�K�r���r�Kz''g�:��z�f
  | �\PV��~)���п�_T��O��;�e���1x�c��}&�z���.�U�2��5��1��4-BT?PL���kߌ±3�[<a���Ҳ�$�RG���D���*��,�:2��BXӊYa���@��ÐW�Fk�e\|��`��JX])f���;͂MBU���U!���B�5�ǘK\|�JM�n���(�W6��5�;!0*�l�2yk�)���)�ZS�ij?��z���GAZX��4 (��+��C]'�C���u��s�V�k)�ȏ�A�I} �*'�1���d7�H��� M�Z�����J��Z�b���  �Т�R�������@f�چ���3���e+����w�����~� ��_�!\|�`�5��H����Az�ߧ�S� ��AyB��!�:M#��+wL�� ��S�6g~2��}>έ�����M������q~�^��rH�F8l��&hl:.G���7Z�� "/n�Q��x<l�#כ�m�*`�v`*�{��:�}��u����v�+w� ts�z�����)��{�+��"z���sjI6�T��J306�w&����o�������A�-Nᢊ��)��Ԩ�b
  |    ��M�r�B��h���o��`Q��[��}���V��ߠ�/�a͕��=�k����#$c��蝼z��@�`��mL�`�4S�ѻ���Fl��l7��!w�A�)�4�[��͠��$ Ԉ?����25�`�5e+_sVA�ީO�n�Tݣ�Dz,؄�dD�H.�c��/�ߨ#��gk�[#�`���֗���Ȫ�5�yU�J*�� �+��i៾O�ʧ?�*?�,+00��=��(StYI\z6g9ql��H�b7�!�rc�5t���_��� ���^Pkk�W(����v�*I�FʺE�{!H��.Q�[�aĖ�4*UQ��>V���<��S;��6� n��օC^��Њ;�VB��x�L�H.�����,�îb�B��INk���N���b<�K�    ,�:g�읜�l@eTE����=�m�S����Ѝ\|/b'j�,ltZ�V����%9�㴼h<��;WfT��n�����;o�Λ`I�x��W�(��wބ�V~�����&�7��r>�Ʊ����~����ܮ��<�p�Ł����n���U�?�Lګg�nE�~�_/S�\�Z�E6�6���a�������.�Ț����Ȅ�~�<~�Y0��a��\��\|���9Sǻ�כ���Y\|�����6�����9L���/���H�٨}9����`�E_ط��}�\�˾8���K��t����B-���շ�v���m_��~���c6�   �f�KH�f��>D�����ew�%�4-F_��NЎ��o9A�ZN�9��J�7N��\�S�����, $�  ������q�ysǼ<E�V��]כ�KN�z��4ZK[��&\��l�4���w�.�q#��f���-%;�J�eT1:�Q�u3p�(�����VJ�,�߁,l�$�2�*����������D�xa��R���Ӗ�t�v8�k�yJ�f�,�m� ��G�����9Wu<b�^�F��Ŷ-�B�9$��J�*,/nF��$+�
  | �������=ed���yN �U���W%�E�z~�܎'�����q�_–5Uw�ؘ幮��-�1^�2��P�`����O���}�tڣ�Zo9�&�Sһ\|o�����Zn�������+��O��n�ɲ��:������bp1���21�����w�ϓ�b9&���`�
  | ����@�#[׊ �)C��"��s�[!�#O����e>�\&0Ә�W���\�F�)�e����i���l�J�ވ>>�a?�=�@�l�#�Y���?މi-2;s3Ǿc�#a�Q�M�xA-�=�5�VU� ��ORGE9)�-}�^�)R�R[c5Km�m��Y��vi��0��^^~!��:M�u�BI�Xd=Z�⌻��d]y�� ���%A/�8R�t����Y6�0aL�L�S�v+�̱:i���UL�Y�o��o�w?�뛨i���3тCɲ��x/yde�RC/=</5�^�{6�2E2��J\|㥔�S�T��0U{���hB��Q�Ⱦ�2��Q3Q�xr�b���_�P��OL�\|X���S��v�w���_��d�wۡ"x���h
  | ��U��%ii�Ru�%�7��� �N�Ǚ�A*ق£���o@�iﰣ5}�n���+��
  | ��is�ʝ}��k�E�)� vp�:9�E��0���� �l�_   $�U!��J�S'��U"���]l1�P��`6{G;�b��+�X���ԩ:�U��M�\|q�(�L*������}�=D����\�X^iod��+��=�^+5��wz�u=��J��=����E���<��_� u�E��"�7ۥ��J-�QpS�z�wpŊ�T>��0W��)Z9���"���d�E�+���R���2�E�9���ó�@J��QGMjP�%�G��(ni@��?&�2eGs��5�@�E7�bg�E�G�;s��n�$B��޴��@��>xa��7�0�.^��R��G������X�\�5�����Xn���;c�V}�qw3���X@�܃Μ4;�ڤ�\¢?볖��ߚ�D�Z�̆g&���\|޿�\|�_���GMԂIf�<���<Sw�@x~ˤ��,'uzϭ��y��*3���U\.vnR�;O�ֿ�x�[���UЍ��׎�`P����(u:`J�hm����$�Rj�&�L:�K~��7vv @:���8�c���������V4]�`�  N'��r��:&ow�=Q/"�ؓ��ӯq+Lr%�1�t�����
  | ���B���,���K���:�.�\|'痱P�E/�$�R~_�#���2�E�ഐ^A��%�^N�3�+�(�@!�iH���J-VK��gh��Ɖ�Õ\|��\
  | �1�}F.F_\�����:A�.e8}�z�T!:�ʯJ�@�ن˚���be��h�D##\ܙв�ч�W?(�&h9�����*c)��hfi(�J�`��(y�q-zX+�ޅ�PA��l4���3���u#.81�O�� �V �)� �adJ/ki�
  | ���9�D�R:2��Fؖ��F!Z $��+��W[��*����v\el�O�msqlC����{d[�r^�*;�j6�>x�X�
  | C@S�Aʵ�t0��)�D�/i(�^G++����B�Z�r\|;��y�+�nИY\x"��#�a���?d���[����jePֺШ���s+�9p�=6W��@��_� @[@�Bh9ECic�R�    ��Q���%k4���Y]1�ͮs����a͍�G���;u�p��0!��hH$��'� %TpE7c�t#�rT^qc�k%��?^cxefV6.��0dI��s��F\|4�����v���ݏ�.I��竜���[���p@N���k�f0AH�O����i��:ߠ���]m�����ܓ ��d�c���?�����ٞs��)Hw9�� &@��Q��@���I$��g*4)�T�c��\|nt�:����� S�m0_8�?t�F�y�4F<�mԱ����UQ+�z��c}�BF�MP�����X�\(���bR}TV�9��mqmµ�Erc)bUkR�    Qr�R~U�`� rQ��1&RV�m@���  7XsP+d�����>��Ud��g"��q/nC�Vh�lm�f˵�s���
  | ��S��@1s �L�L�舝��'�.����D�C�QfX�ʪ���ٛ��P���A~�����#+J��zޱ!�M(�3ۀZA���h�K�̨�'�f�;\�ԟCCQ��I٨K�O�G����B���M ��� GHy��*�&��x<��R�6i�y���� �+�-��=Д���;��m&���Q�
  | -%r��G��ig���
  | ��Z2����j�!q�]�WM?8t��h$��gJ-�Qt!/f)���TW
  | ��`G�Ɋ^�  �����D��F���pA�r���9�>R^i���Ĝ����ґ��A�m*.ߝ�+2��0+Bm"�%é⪊���>f(��L3����3VmQ���e-т'���Q�2\=�+���_����}#NIv~Y���'�[@����$�e�V��'���%�*&r����e:3�Bfin�k��ɓ��Б�)s�������J�4B��+�T`��9;�/���`*    ?]c1o�p����G�O�@�'"��voN}��Q�1CS[�,���b���    9&�8��y�@ ?�b. �P�S����1����+M��w<�
  | �/.� Fb��ȣ���XiA~Fǭ���\|��C�\|z�j�#�d�6�Z�"�Y���9d�=�u�F3��Ɏ+����}d�q� Ȋ����pv�a�;�}��>���y}y{   �w�N_^���3�f�>�Დ����� �N~�r7�$k���"�d~qS�9Pwށ#�Ĉn�=�;�o��:F�_�ez���X@x�$�c�BE�e*$�_B`�Z:� ���
  | �C#Dn[2�a�:�8��r�,���_���a��*t�*u{r�k�����-Kj<4���V�˳����+T,%<��:���;�g�.��P�d�+Q�@0�vg��]��v�P�{�A�Ia5���NL��v�,F��d�Qw����ځB�#T]�X<D����O\|5��+�������!PB����B;�$o���e,.�*��3�D�
  | ݠh!8\B��09�o΄< ���V5=��-[�m b�˺�N� �/W���bFK��=����1cSE��`����
  | #��lq���ĶG��P�B"!�d#}����z����bZ&c�2������謼<9��ڦ��*1v�����s6Y�'c��b���v�̆Pt�߆O'�F�I=����l9PS$���Y3˖�e��
  | l��NX�^�m�d"r�<3ӕH�����/<����'Ĵ��
  | Iz�,�[Cn��Ϲɻ��#� �r�_j�����\�;�O�b'.��`W��X�N�~���5:׌�����H�R�7_�] �f=A�D�S�b���$`���z+Uu��Fq�9j��%^c �~�pEі�Q-�5 N�oy �~@�N_+��+�~<�Iя��Huu�蕻>��E��L��(qLq�ߨE䏩j<���#RFSU8r�0��G�M�k��+\|}<�"H[��W�6����
  | xD�I���F-[�d�.1\|V]��T��JP�#WUI��Z̵��0�D�������f7�{��m[������ .��1g���[�o���pD�OTy�o�,{��Ń���������y�Q\lf�Kf��Kf�UKf݋���<7����'s[�*��)� ��G��Rp�+�P��6��_ž�_:�
  | �'�[p�H�1tŷ��G���^W"g���U�v��pЌ�h���o/��eQI��:���xR���+�
  | ��h�V�jr�l��,
  | �_:Q�)XCӥz�v2'U8.NfS�K =�5�O]�5A��z��G��y��^1�jn&��,��/ ey�{Z�ha�����F1�lѽ�n�WW17�:_R�B���\�#
  | N��$��������<`�\|�-��� JB�+�U0��s`�ly6�3�A��p��
  | ��C̹�g���kC!8��5���}i:`�Y[m���D �d���n���. zy�=ƅ���p8H���j�����g�;�)4�a��\+t'i��b�i���Te'.�̠��*���.Ω.r{��h��%+���>:r:�2*X^�����ք>��di�7u\|;��,�
  | ��0��zg'�6�\|�دĚ�9�D.I��t��-ʺi�d~�\|��7<8^lBe��W��ؑ������б�ps��2��d�5N��ck3r���vߪǑ5N�xSL���0Ê �%$Y�.>�bJ���b�v���2y�#C��k�,��E3�00�9�7��_�����K���Q�{���f�K��۝'�V��a)Q�}�ɿ&۵\|�\|���9$��z�D~�8�����z���%�gN  8�g/Fz)�sYP�R����Z���1%��cܡap��^L �Pn��h���L�É�q*BX�?��:�s3�������MEmȞ��!�W0�4˂�������_���vܻN��^Y5If��B1���<��D�H{���a�l\��kV�_�y֔/��� "s���de    ��@;��d�.�2��sX\D�N�n%�P���a{e]�i�g�E��wa�~{*���dĀ���y� ��ND�8�,�@�<,��euC��W,-�!���,/za6�� �Vc����EÕ~�~�H�2��[�ȷ�5@���������v�B=��}F1� o��\    �Gr���Eck8���8!�S����ڵhI7(�+�MUv �e_  ������u7&Ki�p\+ҝף���T���~�՘�W�����EG��6B�]��z�&�s�5�S������h�d��Ǖ�1\�e���p�P-\#��5����G��C̫,�X�ۛ8ϧyEh�pD��v۲}�X�ׁ�K��bZ�Ȳ��MCW#�`<�$����,���sin���+T�c��Z��$���H���w��a&QW��o�DM���    \,��M�[(�wr���^�d��  &YmXݷͰ  "����];dN@�lz;���$kU�0ra����NR�{�U/'װ"���BɁu��tw.�9�f*�s@�cuJa�\|lRw*��m��aDh�fzZu0�H[��Te莔=~    g��A+�x#r�(��Aƈ�$�MSzEl:���F6�֐�{z�� �bkl�Ğ+�*꘷���4  1��7\|h"���e��GD�(T۾3Y�K%��MXD��f1�{�L�Ai��TYgH�K_oʵ_:�J׀����M����Q�zb����~�qd7)�2ak uF_55�cQE[�[ᑴ�!K��j�jHJ��:�F�&�.9k�����´�����a$��U'Xe<$8�5!����C��   N$�8�a�B�wK   6?D�N�p9!�uCb�����     $89��"�>���������n�m� �䀚�   �&)U:�+/�Jh��ՠ�V�
  | Z�he(��@GӁ�q��4@,��. � � � � ��X���%���jPE�B�e�2��J�����8hh���N4�;��>ұ�b]1�G�Z4X���sq���+�����G��a�+R6���A��A�K�ls��N�@yl�ȵ���1�Ym1�a��!R=���tz�򋐪�����"K�t&����h��1��p�J�8���&���������~���RO҃����R�ꗲF��캓(��4�-���v@��'����n>gYV��l،�쾂Wׯ�
  | Cv�,$�
  | x�:K�����mx�j�H��+{��T;��`AzR�]��i]�mӏ)]r�\��P����ev �!�U=�6.j��fn�K����K��e�PR3^��P��,�4g������h�Y��2Fn��:.FYk$����  ��7�L��G\*^�i,�����f5��b��RN]&2>d�6�Yy�/ ]�~������*˧��i􀤝!%��Oٕi�G�vg˕**\&_����>�!J���褽���޵����bI�?�2������b����8'rnoPo�
  | {����R��G��6���2&GH %�A�CP���G=��3����T�4���L��;��ܓ��ωs
  | nԡ��E�2� ��$x ���c( �����&8�<��WAtn�P��C[;'5`�.�K}��6����0?�/P�8�������R�3>�:�� �(q7��L�b�+�,�8/m�{��e7���"�l���p�0PM�\`ה+4�S��lf�b�ƌ�X�g���ݒ,f&[��3�r�C]��?vśW���ʼ����#R�+�e����ۛA���9��ON4���G�$����I�    ru+�S~�b�TJ[�������`����əJ�5�T$�~K���D�c{����Sb��Q�s�%�b�n�olepP��\|c� Rh�cl�=�T�,
  | ���-T��$�h ����\�q�)H"}���`W��f�ު5�w�7�H]��5f��^�   dB*� �?'�� W';I"]��bh��c���0xS�JO �60v$֥*���� ��_F�ɴ��P8�s����b� ��_ٴ�nC(uz]�;Dw4�a��@��Z�p�3�V�d���&4%"'��������@���nQ�l�VP@�_�1�M;@�l�AK�Z��l bg��$N��P�t:xC� �����E����aS=��K�;K$N�/��$mV��������Ô����<xE`�v`m   =)9�o�y.tԲzX7��qS�7y4�܆l���x��H�Z���!R�F�-y�ۤPc�+�“y��V�;�Y���% ���(G�7��J����
  | KS��R��c%�F�a(���A�%UX����#����mD�\����*c�T���> u���U !3���WID�2^�W;���   1��8WdQ����\��� �����t&�*;c�\�LW�T�3t
  | ���cg��U��Q���t���$0o\6�,P)�y��:Lw���   m>>�S�?}8������/O������5\|������N�������L�j�qVrJHrH�_3l0v�����s-�    i;�f���ʸW���,�0�#�:_!�u�5L�?�FB�ݑ�`�m�T����i�@bog
  | 7.�x���3P��>��l!9�Lׯ�)]fjd�5�TX)Eiap:�-?®��"�C(^=�Ӡ�����vu��/�߁)����������P][�[�}CS�hWւ �j��-Z �%���� /.%��-H�2�{��LJ)v��^���c,Y�8����"��E�w�4/:�����Pڨ�_I��ZO��A�V$X�*(h2��Ҭ�u~e��[��X8�%���l��S������j0���g�D�6�\�=0�T���p���@o,v��I{e����d�L��+�RA X#7��C<H>�a�t<�=4
  | E�u�b�_LR�2��4��hR�֋A��� Q���D^��[��إ�)�$g�v�>�2�-h狟2�{t���.6z������E�w��8vF�A��P޵"�#������m��-�$�-ܘ[��i )�b�BG�Y��I�Υ�oa�wv�yp�����I�ls��h�< �Smۂ�~Ujo�!��yE��������%KyrO/�T˲@��t�7#-ޙT��w�%L ��<�ÀH��Y!��WT�����ӐQ��mr^w 0� +�Hq�o�ӻ��F3����=��1o�b�왧E+R�nE���z��בUY����ړ53���R5q��H
  | mc`c�@:�����El�K�;$6gaĺ�ma8 �g�@���){�bgl?���z�UM�p+*$��w3٫B�#S�Q�����U�����C�$�mɡ�Œ�a�.�� C��� Aǂ�²���\|��x�: bL�9�n}M�*��������TE�<�� �Rs[��(ܽ�װRX�JA�z�(��r4��ql?�Y]E����(������:hci�XP�<�~7b:~<K(ǝ_ �_�U�(q�@����U�:�p��F!������$Z��am�:�#a�  c��y7�Y3gd�;��d�(Jۇ�    �V��r�Z5��bj�{���x����$)X�/��r��1�:fRL&�V�W�2���v7�����*��T�4�'��+�D�L�o�����:h(.�>�" ��R��z�V{5� Ry+X��I�9f�I[�:Ŧ��m�G�gu\&ǵ���J.�k���U!D�' �
  | Ōч���m�ln���Pޗ�/��;�{pArray
  | (
  | [id] => d69137777ae0cb128c08cd24b8d9fdba11556906640
  | [clear] => 5f49e7b74f2fb43896fc2b017d17fae2d14e7ec0-1556906640-1800-150
  | [link_challenge] => http://alta-definizione.info/cdn-cgi/l/chk_jschl?s=0ed27ff893a180494c2562fc8638900c2c6dc5e4-1556906634-1800-AcBDzrQfcbCVPt3oEz8LeBrCTUxeCbRSeb3DtkVAmZJwbGlet8z2rEKLOYQKtgbNYOwhWTtIfI5luBp2INMP22%2FCidJAE5CFUB8Eys%2F3hteklq7JjktUN0vRaktCdbjYOA%3D%3D&jschl_vc=b8adf2474a9535ffd55aa98431f0a58b&pass=1556906638.97-agEyTtntrJ&jschl_answer=8.6479817841
  | )
  | <html>
  | <head><title>302 Found</title></head>
  | <body bgcolor="white">
  | <center><h1>302 Found</h1></center>
  | <hr><center>cloudflare</center>
  | </body>
  | </html>

this is code

cf.php

<?php
function rr($js_code)
    {
    $js_code = str_replace(array(
        ")+(",
        "![]",
        "!+[]",
        "[]"
    ) , array(
        ").(",
        "(!1)",
        "(!0)",
        "(0)"
    ) , $js_code);
    return $js_code;
    }

function getClearanceLink($content, $url)
    {
    sleep(4);
    preg_match_all('/name="\w+" value="(.+?)"/', $content, $matches);
    $params = array();
    list($params['s'], $params['jschl_vc'], $params['pass']) = $matches[1];
    $uri = parse_url($url);
    $host = $uri["host"];
    $result = "";
    $t1 = explode('id="cf-dn', $content);
    $t2 = explode(">", $t1[1]);
    $t3 = explode("<", $t2[1]);
    $cf = $t3[0];
    preg_match("/f\,\s?([a-zA-z0-9]+)\=\{\"([a-zA-Z0-9]+)\"\:\s?([\/!\[\]+()]+|[-*+\/]?=[\/!\[\]+()]+)/", $content, $m);
    eval("\$result=" . rr($m[3]) . ";");
    $pat = "/" . $m[1] . "\." . $m[2] . "(.*)+\;/";
    preg_match($pat, $content, $p);
    $t = explode(";", $p[0]);
    for ($k = 0; $k < count($t); $k++)
        {
        if (substr($t[$k], 0, strlen($m[1])) == $m[1])
            {
            if (strpos($t[$k], "function(p){var p") !== false)
                {
                $a1 = explode("function(p){var p", $t[$k]);
                $t[$k] = $a1[0] . $cf;
                $line = str_replace($m[1] . "." . $m[2], "\$result ", rr($t[$k])) . ";";
                eval($line);
                }
              else
            if (strpos($t[$k], "(function(p){return") !== false)
                {
                $a1 = explode("(function(p){return", $t[$k]);
                $a2 = explode('("+p+")")}', $a1[1]);
                $line = "\$index=" . rr(substr($a2[1], 0, -2)) . ";";
                eval($line);
                $line = str_replace($m[1] . "." . $m[2], "\$result ", rr($a1[0]) . " " . ord($host[$index]) . ");");
                eval($line);
                }
              else
                {
                $line = str_replace($m[1] . "." . $m[2], "\$result ", rr($t[$k])) . ";";
                eval($line);
                }
            }
        }

    $params['jschl_answer'] = round($result, 10);
    return sprintf("%s://%s/cdn-cgi/l/chk_jschl?%s", $uri['scheme'], $uri['host'], http_build_query($params));
    }

function getClearanceLink_old($content, $url)
    {
    /*
    * 1. Mimic waiting process
    */
    sleep(4);
    /*
    * 2. Extract "jschl_vc" and "pass" params
    */
    preg_match_all('/name="\w+" value="(.+?)"/', $content, $matches);
    $params = array();

    list($params['s'], $params['jschl_vc'], $params['pass']) = $matches[1];

    // Extract CF script tag portion from content.

    $cf_script_start_pos = strpos($content, 's,t,o,p,b,r,e,a,k,i,n,g,f,');
    $cf_script_end_pos = strpos($content, '</script>', $cf_script_start_pos);
    $cf_script = substr($content, $cf_script_start_pos, $cf_script_end_pos - $cf_script_start_pos);
    /*
    * 3. Extract JavaScript challenge logic
    */
    preg_match_all('/:[\/!\[\]+()]+|[-*+\/]?=[\/!\[\]+()]+/', $cf_script, $matches);

    /*
    * 4. Convert challenge logic to PHP
    */
    $php_code = "";
    foreach($matches[0] as $js_code)
        {

        // [] causes "invalid operator" errors; convert to integer equivalents

        $js_code = str_replace(array(
            ")+(",
            "![]",
            "!+[]",
            "[]"
        ) , array(
            ").(",
            "(!1)",
            "(!0)",
            "(0)"
        ) , $js_code);

        $php_code.= '$params[\'jschl_answer\']' . ($js_code[0] == ':' ? '=' . substr($js_code, 1) : $js_code) . ';';
        }

    /*
    * 5. Eval PHP and get solution
    */

    eval($php_code);

    // toFixed(10).

    $params['jschl_answer'] = round($params['jschl_answer'], 10);

    // Split url into components.

    $uri = parse_url($url);

    // Add host length to get final answer.
    // echo $uri['host'];

    $params['jschl_answer']+= strlen($uri['host']);

    /*
    * 6. Generate clearance link
    */

    // echo http_build_query($params);

    return sprintf("%s://%s/cdn-cgi/l/chk_jschl?%s", $uri['scheme'], $uri['host'], http_build_query($params));
    }
?>

cloudflare.php

<?php
header('Content-Type: text/plain');
include ("cf.php");

function bypassCloud($link) {
    $cookie = __DIR__ . "\c.txt";
    $head = array(
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Language: en-US,en;q=0.5',
        'Accept-Encoding: deflate, br',
        'Connection: keep-alive',
        'Upgrade-Insecure-Requests: 1'
    );
    $ua = $_SERVER['HTTP_USER_AGENT'];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $ua);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_HTTPGET, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch, CURLOPT_HEADER, 1);

    $h = curl_exec($ch);
    if (strpos($h, 'id="cf-dn') === false)
        $q = getClearanceLink_old($h, $link);
    else
        $q = getClearanceLink($h, $link);
    curl_setopt($ch, CURLOPT_URL, $q);
    echo curl_exec($ch);
    curl_close($ch);

    $cfuid = '_cfduid Not Found !';
    $cf_clearance = 'cf_clearance Not Found !';

    $c = file_get_contents($cookie);

    if(preg_match("/__cfduid\s+[a-z0-9\-]+/",$c,$matchs)){
        $cfuid = str_replace('_cfduid   ','',$matchs[0]);
        $cfuid = str_replace('_','',$cfuid);
        $cfuid = trim($cfuid);
    }

    if(preg_match("/cf_clearance\s+[a-z0-9\-]+/",$c,$clearance)) {
        $cf_clearance = $clearance[0];
        $cf_clearance = str_replace('cfclearance ','',$cf_clearance);
        $cf_clearance = str_replace('_','',$cf_clearance);
        $cf_clearance = trim($cf_clearance);
        $cf_clearance = str_replace('cfclearance    ','',$cf_clearance);
    }

    return [ 'id' => $cfuid, 'clear' => $cf_clearance, 'link_challenge' => $q];
}

    $target = bypassCloud('http://alta-definizione.info');
    print_r($target);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $target['link_challenge']);
    curl_setopt($ch, CURLOPT_COOKIE, '__cfduid='.$target['id'].'; cf_clearance='.$target['clear'].';');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36');
    echo curl_exec($ch);
    curl_close($ch);
vb6rocod commented 5 years ago

THIS IS NOT YOUR CODE..... Replace

'Accept-Encoding: deflate, br',

with

'Accept-Encoding: deflate',

If still return "br" add

curl_setopt($ch, CURLOPT_ENCODING, "");
Laky-64 commented 5 years ago

@vb6rocod why does it take 20 or more seconds to load? can't you improve speed?

vb6rocod commented 5 years ago

I check both links (https://alta-definizione.info/ and https://altadefinizione.cloud/) On my PC take ~ 5-6 sec, so I don't know why takes so long on your's. I suggest to use https. I also make small change in code

$link="https://altadefinizione.cloud/";
include ("cf.php");

$ua = $_SERVER['HTTP_USER_AGENT'];
$cookie = dirname($_SERVER['SCRIPT_FILENAME'])."/c.txt";   // you may change this

$head = array(
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language: en-US,en;q=0.5',
    'Connection: keep-alive',
    'Upgrade-Insecure-Requests: 1'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_HEADER, 1);
$h = curl_exec($ch);

if (strpos($h, "503 Service") !== false)
    {
    if (strpos($h, 'id="cf-dn') === false) $q = getClearanceLink_old($h, $link);
      else $q = getClearanceLink($h, $link);
    curl_setopt($ch, CURLOPT_URL, $q);
    $h = curl_exec($ch);
    curl_close($ch);
    //for check
    $c=file_get_contents($cookie);
    preg_match("/cf_clearance\s+[a-z0-9\-]+/",$c,$match);
    echo $match[0];

    }
  else
    {
    curl_close($ch);
    }
echo $h;
Laky-64 commented 5 years ago

@vb6rocod i solved, but can't you do so as it was when the old cookie is loaded and doesn't always have to re-run the connection?

before with kyranrana it worked like this ...

prinze77 commented 5 years ago

Broke again

Laky-64 commented 5 years ago

@prinze77 this is a correct code

created by vbr6 and edited by me

cloudflare.php

<?php
header('Content-Type: text/plain');
include ("cf.php");

function bypassCloud($link) {
    $cookie = __DIR__ . "/c.txt";
    $head = array(
        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Language: en-US,en;q=0.5',
        'Accept-Encoding: deflate, b, php, html, txt',
        'Connection: keep-alive',
        'Upgrade-Insecure-Requests: 1'
    );
    $ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $ua);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_HTTPGET, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch, CURLOPT_HEADER, 0);

    $h = curl_exec($ch);
    if (strpos($h, 'id="cf-dn') === false)
        $q = getClearanceLink_old($h, $link);
    else
        $q = getClearanceLink($h, $link);
    //curl_setopt($ch, CURLOPT_URL, $q);
    //$h=curl_exec($ch);
    //curl_close($ch);

    $cfuid = '_cfduid Not Found !';
    $cf_clearance = 'cf_clearance Not Found !';

    $c = file_get_contents($cookie);

    if(preg_match("/__cfduid\s+[a-z0-9\-]+/",$c,$matchs)){
        $cfuid = str_replace('_cfduid   ','',$matchs[0]);
        $cfuid = str_replace('_','',$cfuid);
        $cfuid = trim($cfuid);
    }

    if(preg_match("/cf_clearance\s+[a-z0-9\-]+/",$c,$clearance)) {
        $cf_clearance = $clearance[0];
        $cf_clearance = str_replace('cfclearance ','',$cf_clearance);
        $cf_clearance = str_replace('_','',$cf_clearance);
        $cf_clearance = trim($cf_clearance);
        $cf_clearance = str_replace('cfclearance    ','',$cf_clearance);
    }
    curl_setopt($ch, CURLOPT_URL, $q);
    curl_setopt($ch, CURLOPT_COOKIE, '__cfduid='.$cfuid.'; cf_clearance='.$cf_clearance.';');
    curl_setopt($ch,CURLOPT_ENCODING, 'br');
    echo curl_exec($ch);
    curl_close($ch);
    return [ 'id' => $cfuid, 'clear' => $cf_clearance, 'link_challenge' => $q];
}
    $target = bypassCloud($_GET['linkf']);
    //$target = bypassCloud('https://tvhub.org/');
    //print_r($target);
?>

cf.php


function rr($js_code)
    {
    $js_code = str_replace(array(
        ")+(",
        "![]",
        "!+[]",
        "[]"
    ) , array(
        ").(",
        "(!1)",
        "(!0)",
        "(0)"
    ) , $js_code);
    return $js_code;
    }

function getClearanceLink($content, $url)
    {
    sleep(4);
    preg_match_all('/name="\w+" value="(.+?)"/', $content, $matches);
    $params = array();
    list($params['s'], $params['jschl_vc'], $params['pass']) = $matches[1];
    $uri = parse_url($url);
    $host = $uri["host"];
    $result = "";
    $t1 = explode('id="cf-dn', $content);
    $t2 = explode(">", $t1[1]);
    $t3 = explode("<", $t2[1]);
    $cf = $t3[0];
    preg_match("/f\,\s?([a-zA-z0-9]+)\=\{\"([a-zA-Z0-9]+)\"\:\s?([\/!\[\]+()]+|[-*+\/]?=[\/!\[\]+()]+)/", $content, $m);
    eval("\$result=" . rr($m[3]) . ";");
    $pat = "/" . $m[1] . "\." . $m[2] . "(.*)+\;/";
    preg_match($pat, $content, $p);
    $t = explode(";", $p[0]);
    for ($k = 0; $k < count($t); $k++)
        {
        if (substr($t[$k], 0, strlen($m[1])) == $m[1])
            {
            if (strpos($t[$k], "function(p){var p") !== false)
                {
                $a1 = explode("function(p){var p", $t[$k]);
                $t[$k] = $a1[0] . $cf;
                $line = str_replace($m[1] . "." . $m[2], "\$result ", rr($t[$k])) . ";";
                eval($line);
                }
              else
            if (strpos($t[$k], "(function(p){return") !== false)
                {
                $a1 = explode("(function(p){return", $t[$k]);
                $a2 = explode('("+p+")")}', $a1[1]);
                $line = "\$index=" . rr(substr($a2[1], 0, -2)) . ";";
                eval($line);
                $line = str_replace($m[1] . "." . $m[2], "\$result ", rr($a1[0]) . " " . ord($host[$index]) . ");");
                eval($line);
                }
              else
                {
                $line = str_replace($m[1] . "." . $m[2], "\$result ", rr($t[$k])) . ";";
                eval($line);
                }
            }
        }

    $params['jschl_answer'] = round($result, 10);
    return sprintf("%s://%s/cdn-cgi/l/chk_jschl?%s", $uri['scheme'], $uri['host'], http_build_query($params));
    }

function getClearanceLink_old($content, $url)
    {
    /*
    * 1. Mimic waiting process
    */
    sleep(4);
    /*
    * 2. Extract "jschl_vc" and "pass" params
    */
    preg_match_all('/name="\w+" value="(.+?)"/', $content, $matches);
    $params = array();

    list($params['s'], $params['jschl_vc'], $params['pass']) = $matches[1];

    // Extract CF script tag portion from content.

    $cf_script_start_pos = strpos($content, 's,t,o,p,b,r,e,a,k,i,n,g,f,');
    $cf_script_end_pos = strpos($content, '</script>', $cf_script_start_pos);
    $cf_script = substr($content, $cf_script_start_pos, $cf_script_end_pos - $cf_script_start_pos);
    /*
    * 3. Extract JavaScript challenge logic
    */
    preg_match_all('/:[\/!\[\]+()]+|[-*+\/]?=[\/!\[\]+()]+/', $cf_script, $matches);

    /*
    * 4. Convert challenge logic to PHP
    */
    $php_code = "";
    foreach($matches[0] as $js_code)
        {

        // [] causes "invalid operator" errors; convert to integer equivalents

        $js_code = str_replace(array(
            ")+(",
            "![]",
            "!+[]",
            "[]"
        ) , array(
            ").(",
            "(!1)",
            "(!0)",
            "(0)"
        ) , $js_code);

        $php_code.= '$params[\'jschl_answer\']' . ($js_code[0] == ':' ? '=' . substr($js_code, 1) : $js_code) . ';';
        }

    /*
    * 5. Eval PHP and get solution
    */

    eval($php_code);

    // toFixed(10).

    $params['jschl_answer'] = round($params['jschl_answer'], 10);

    // Split url into components.

    $uri = parse_url($url);

    // Add host length to get final answer.
    // echo $uri['host'];

    $params['jschl_answer']+= strlen($uri['host']);

    /*
    * 6. Generate clearance link
    */

    // echo http_build_query($params);

    return sprintf("%s://%s/cdn-cgi/l/chk_jschl?%s", $uri['scheme'], $uri['host'], http_build_query($params));
    }
?>```
Laky-64 commented 5 years ago

i founded solution