'How cloudflare detects my request is not from a browser?
I have a tool that loads subtitle from subscene.com, I wrote the code in vb.net, it used to work until 21th of Match 2022. The strange thing is when I open the website using google chrome, although I delete all cookies, site data, storage and etc data, there is no challenge in browser, I don't see any redirection in developer toolbar/network, but when I use WebClient it returns cloudflare challenge page in webexception response data. I simulated every page header that chrome sends, using same IP and user agent and still no luck. I have been struggling this for few days but I couldn't figure it out how cloudflare distinguishes my request that chrome request? can anybody help me? Below is the source of the asp.net generic handler HttpGet.ashx The usage is [Path]/HttpGet.ashx?url=http://subscene.com It returns html data for any website given.
<%@ WebHandler Language="VB" Class="GetHtml" %>
Imports System.IO
Imports System.Net
Public Class GetHtml : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim url As New Uri(HttpUtility.UrlDecode(context.Request.QueryString("url")))
dim wc = new WebClient()
wc.Headers.Add("Accept-Language", "en-US")
wc.Headers.Add("Accept", "*/*")
wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36")
Try
dim html=WC.DownloadString(url.AbsoluteUri)
context.Response.ContentType=wc.ResponseHeaders("Content-Type")
context.Response.Write(html)
Catch ex As WebException
Dim st As Stream = ex.Response.GetResponseStream()
Dim sr As New StreamReader(st)
Dim html = sr.ReadToEnd
st.Close()
context.Response.ContentType=ex.Response.ContentType
context.Response.Write(html)
Catch ex As Exception
Throw New Exception(ex.Message, ex)
End Try
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
