从实现testcookie-nginx-module的网站生成cookie [英] Generating cookie from website that implements testcookie-nginx-module

查看:622
本文介绍了从实现testcookie-nginx-module的网站生成cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是此答案的后续问题:链接



基于这个答案,我可以绕过 testcookie-nginx-module的安全检查 byethost hosting。



问题是我使用的cookie是从网络浏览器复制的。我需要从我的网站上获取 COOKIE ,使用我的android设备,这样我就可以使用它在byethost服务器上发出请求。



Byethost提供了一个 __ test cookie来检查现有会话上请求的有效性,如果它似乎是我访问服务器的唯一方式是是一个有效的浏览器,如何告诉服务器,我是一个Android设备有效的浏览器?所以我可以将cookie提供给Web浏览器。

解决方案

我遇到了同样的问题,首先我使用WebView访问该页面并获取cookie,使用它来绕过testcookie-nginx-module的安全检查。

pre $ WebView myWebView = new WebView(这个);
myWebView.getSettings()。setJavaScriptEnabled(true);
myWebView.loadUrl(my_page_here);

字符串cookies = CookieManager.getInstance()。getCookie(my_page_here);
System.out.println(cookies);
myWebView.destroy();

然后为了与Volley一起使用,我创建了一个CustomRequest extends StringRequest并覆盖getHeaders,如下所示:

  @Override 
public Map< String,String> getHeaders()抛出AuthFailureError {
Map< String,String> params = new HashMap< String,String>();
params.put(User-Agent,Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36(KHTML,如Gecko)Chrome / 42.0.2311.135 Safari / 537.36 Edge / 12.10240);
params.put(Cookie,cookies +; expires = Fri,1-Jan-38 06:55:55 GMT; path = /);
params.put(Content-Type,application / x-www-form-urlencoded);
返回参数;
}

就是这样,您还有其他解决方案吗?如果不是,你可以检查:D


This is a follow question on this answer: Link Here

Based on that answer I am able to bypass the security check of testcookie-nginx-module used by byethost hosting.

The problem is that the cookies I used are copied from a web browser. I need to get the COOKIE from my website, using my android device so that I can use it to make request on byethost server.

Byethost provides a __test cookie to check for validity of a request on an existing session, if it seems that the only way for me to access to server is to be a "valid browser", How to tell the server that I am valid browser from an android device? So that I can have the cookie given to the web browsers.

解决方案

I met the same problem and first I used WebView to access the page and get the cookies, use that to bypass the security check of testcookie-nginx-module

    WebView myWebView = new WebView(this);
    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.loadUrl("my_page_here");

    String cookies = CookieManager.getInstance().getCookie("my_page_here");
    System.out.println(cookies);
    myWebView.destroy();

Then to use with Volley, i created a CustomRequest extends StringRequest and override getHeaders like this:

@Override
public Map<String, String> getHeaders() throws AuthFailureError {
    Map<String, String> params = new HashMap<String, String>();
    params.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240 ");
    params.put("Cookie", cookies+"; expires=Fri, 1-Jan-38 06:55:55 GMT; path=/");
    params.put("Content-Type", "application/x-www-form-urlencoded");
    return params;
}

And that's all, do you have any other solution yet? if not you could check this :D

这篇关于从实现testcookie-nginx-module的网站生成cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆