I want to login to the local modem but the return value is just "Waiting..."

78 Views Asked by At

I want to login and see the wifi devices connected to the modem but the return value is just "Waiting..." I can't set the cookie because it skips the login screen fast. Do I have to wait for additional time or is there another way I can wait until I get the information I want?

string url = "http://192.168.1.1/login.cgi";
                Uri address = new Uri(url);
                var postData = new List<KeyValuePair<string, string>>
                {
                    new KeyValuePair<string, string>("UserName", "admin"),
                    new KeyValuePair<string, string>("PassWord", "aGNzNTQzNio%3D")
                };
                HttpContent content = new FormUrlEncodedContent(postData);
                var handler = new HttpClientHandler
                {
                    UseCookies = true,
                    UseDefaultCredentials = false
                };
                var client = new HttpClient(handler)
                {
                    BaseAddress = address,
                    Timeout = TimeSpan.FromSeconds(30)
                };
                HttpResponseMessage response = await client.PostAsync(url, content);
                System.Threading.Thread.Sleep(10000);
                response.EnsureSuccessStatusCode();
                string body = await response.Content.ReadAsStringAsync();
`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1">
        <meta content="no-cache" http-equiv="Pragma" />
        <title>Waiting...</title>
        <script type="text/javascript">
            var pageName = '/';
            top.location.replace(pageName);
        </script>
    </head>
    <body></body>
</html>`

I see ajax page in developer tools (http://192.168.1.1/asp/GetRandCount.asp)

result always unique eg: fb1d2129bc3b7a3ebf28877fc6e69baa1d3a2847caf7e4c3

Total XHR Output is:

{
  "log": {
    "version": "1.2",
    "creator": {
      "name": "WebInspector",
      "version": "537.36"
    },
    "pages": [],
    "entries": [
      {
        "_initiator": {
          "type": "script",
          "stack": {
            "callFrames": [
              {
                "functionName": "send",
                "scriptId": "17",
                "url": "http://192.168.1.1/resource/common/jquery.min.js?202203162138140159067425",
                "lineNumber": 1,
                "columnNumber": 82612
              },
              {
                "functionName": "ajax",
                "scriptId": "17",
                "url": "http://192.168.1.1/resource/common/jquery.min.js?202203162138140159067425",
                "lineNumber": 1,
                "columnNumber": 78222
              },
              {
                "functionName": "LoginSubmit",
                "scriptId": "18",
                "url": "http://192.168.1.1/",
                "lineNumber": 458,
                "columnNumber": 2
              },
              {
                "functionName": "onclick",
                "scriptId": "47",
                "url": "http://192.168.1.1/",
                "lineNumber": 1326,
                "columnNumber": 206
              }
            ]
          }
        },
        "_priority": "VeryHigh",
        "_resourceType": "xhr",
        "cache": {},
        "connection": "94621",
        "request": {
          "method": "POST",
          "url": ".",
          "httpVersion": "HTTP/1.1",
          "headers": [
            {
              "name": "Accept",
              "value": "*/*"
            },
            {
              "name": "Accept-Encoding",
              "value": "gzip, deflate"
            },
            {
              "name": "Accept-Language",
              "value": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7"
            },
            {
              "name": "Connection",
              "value": "keep-alive"
            },
            {
              "name": "Content-Length",
              "value": "0"
            },
            {
              "name": "Cookie",
              "value": "Cookie=sid=7a2fdeb886ed7ad2e8d82fb03ae9146090c19ed33cfea5326487c6b4bdaece9c:Language:turkish:id=1"
            },
            {
              "name": "Host",
              "value": "192.168.1.1"
            },
            {
              "name": "Origin",
              "value": "http://192.168.1.1"
            },
            {
              "name": "Referer",
              "value": "http://192.168.1.1/"
            },
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"
            },
            {
              "name": "X-Requested-With",
              "value": "XMLHttpRequest"
            }
          ],
          "queryString": [],
          "cookies": [
            {
              "name": "Cookie",
              "value": "sid=7a2fdeb886ed7ad2e8d82fb03ae9146090c19ed33cfea5326487c6b4bdaece9c:Language:turkish:id=1",
              "path": "/",
              "domain": "192.168.1.1",
              "expires": "1969-12-31T23:59:59.000Z",
              "httpOnly": true,
              "secure": false
            }
          ],
          "headersSize": 542,
          "bodySize": 0
        },
        "response": {
          "status": 200,
          "statusText": "OK",
          "httpVersion": "HTTP/1.1",
          "headers": [
            {
              "name": "Cache-control",
              "value": "no-cache, no-store, max-age=0"
            },
            {
              "name": "Connection",
              "value": "Keep-Alive"
            },
            {
              "name": "Content-Security-Policy",
              "value": "default-src 'self' 'unsafe-inline' 'unsafe-eval'"
            },
            {
              "name": "Content-Type",
              "value": "text/html; charset=UTF-8"
            },
            {
              "name": "Pragma",
              "value": "no-cache"
            },
            {
              "name": "Transfer-Encoding",
              "value": "chunked"
            },
            {
              "name": "X-Frame-Options",
              "value": "SAMEORIGIN"
            },
            {
              "name": "X-XSS-Protection",
              "value": "1; mode=block"
            }
          ],
          "cookies": [],
          "content": {
            "size": 51,
            "mimeType": "text/html",
            "compression": -11
          },
          "redirectURL": "",
          "headersSize": 304,
          "bodySize": 62,
          "_transferSize": 366,
          "_error": null
        },
        "serverIPAddress": "192.168.1.1",
        "startedDateTime": "2023-03-20T16:30:38.369Z",
        "time": 79.48799995938316,
        "timings": {
          "blocked": 3.359999981995672,
          "dns": -1,
          "ssl": -1,
          "connect": -1,
          "send": 0.21999999999999997,
          "wait": 72.94899997246638,
          "receive": 2.9590000049211085,
          "_blocked_queueing": 2.267999981995672
        }
      },
      {
        "_initiator": {
          "type": "other"
        },
        "_priority": "VeryHigh",
        "_resourceType": "document",
        "cache": {},
        "connection": "94621",
        "request": {
          "method": "POST",
          "url": "http://192.168.1.1/login.cgi",
          "httpVersion": "HTTP/1.1",
          "headers": [
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
            },
            {
              "name": "Accept-Encoding",
              "value": "gzip, deflate"
            },
            {
              "name": "Accept-Language",
              "value": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7"
            },
            {
              "name": "Cache-Control",
              "value": "max-age=0"
            },
            {
              "name": "Connection",
              "value": "keep-alive"
            },
            {
              "name": "Content-Length",
              "value": "117"
            },
            {
              "name": "Content-Type",
              "value": "application/x-www-form-urlencoded"
            },
            {
              "name": "Cookie",
              "value": "Cookie=sid=7a2fdeb886ed7ad2e8d82fb03ae9146090c19ed33cfea5326487c6b4bdaece9c:Language:turkish:id=1"
            },
            {
              "name": "Host",
              "value": "192.168.1.1"
            },
            {
              "name": "Origin",
              "value": "http://192.168.1.1"
            },
            {
              "name": "Referer",
              "value": "http://192.168.1.1/"
            },
            {
              "name": "Upgrade-Insecure-Requests",
              "value": "1"
            },
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36"
            }
          ],
          "queryString": [],
          "cookies": [
            {
              "name": "Cookie",
              "value": "sid=7a2fdeb886ed7ad2e8d82fb03ae9146090c19ed33cfea5326487c6b4bdaece9c:Language:turkish:id=1",
              "path": "/",
              "domain": "192.168.1.1",
              "expires": "1969-12-31T23:59:59.000Z",
              "httpOnly": true,
              "secure": false
            }
          ],
          "headersSize": 736,
          "bodySize": 117,
          "postData": {
            "mimeType": "application/x-www-form-urlencoded",
            "text": "UserName=admin&PassWord=aGNzNTQzNio%3D&Language=turkish&x.X_HW_Token=2ee81f23402d9dedb018a978c775ea4944a35b229d3b1221",
            "params": [
              {
                "name": "UserName",
                "value": "admin"
              },
              {
                "name": "PassWord",
                "value": "aGNzNTQzNio%3D"
              },
              {
                "name": "Language",
                "value": "turkish"
              },
              {
                "name": "x.X_HW_Token",
                "value": "2ee81f23402d9dedb018a978c775ea4944a35b229d3b1221"
              }
            ]
          }
        },
        "response": {
          "status": 200,
          "statusText": "OK",
          "httpVersion": "HTTP/1.1",
          "headers": [
            {
              "name": "Cache-control",
              "value": "no-cache, no-store, max-age=0"
            },
            {
              "name": "Connection",
              "value": "Keep-Alive"
            },
            {
              "name": "Content-Security-Policy",
              "value": "default-src 'self' 'unsafe-inline' 'unsafe-eval'"
            },
            {
              "name": "Content-Type",
              "value": "text/html; charset=UTF-8"
            },
            {
              "name": "Pragma",
              "value": "no-cache"
            },
            {
              "name": "Set-cookie",
              "value": "Cookie=sid=3ef92539df7b3e209b1c229285c5007549b2c4eec5f68dd1234ac49ca0fe6e14:Language:turkish:id=1;path=/;HttpOnly"
            },
            {
              "name": "Transfer-Encoding",
              "value": "chunked"
            },
            {
              "name": "X-Frame-Options",
              "value": "SAMEORIGIN"
            },
            {
              "name": "X-XSS-Protection",
              "value": "1; mode=block"
            }
          ],
          "cookies": [
            {
              "name": "Cookie",
              "value": "sid=3ef92539df7b3e209b1c229285c5007549b2c4eec5f68dd1234ac49ca0fe6e14:Language:turkish:id=1",
              "path": "/",
              "domain": "192.168.1.1",
              "expires": null,
              "httpOnly": true,
              "secure": false
            }
          ],
          "content": {
            "size": 610,
            "mimeType": "text/html",
            "compression": -12
          },
          "redirectURL": "",
          "headersSize": 430,
          "bodySize": 622,
          "_transferSize": 1052,
          "_error": null
        },
        "serverIPAddress": "192.168.1.1",
        "startedDateTime": "2023-03-20T16:30:38.465Z",
        "time": 2899.5390000054613,
        "timings": {
          "blocked": 8.06600000488013,
          "dns": -1,
          "ssl": -1,
          "connect": -1,
          "send": 0.6430000000000007,
          "wait": 2889.0549999890327,
          "receive": 1.7750000115484,
          "_blocked_queueing": 2.6150000048801303
        }
      }
    ]
  }
}
0

There are 0 best solutions below