简体   繁体   English

Titanium Web代理无法加载图像

[英]Titanium web proxy cant load images

I am working on a pen testing app written in c# and I am making use of Titanium proxy. 我正在使用C#编写笔测试应用程序,并且正在使用Titanium代理。 I have been able to get html, css, js and other content types working. 我已经能够使html,css,js和其他内容类型正常工作。 I am unable to get images to show though. 我无法显示图像。 Is there some secret to this? 这有什么秘密吗?

The example code on the github for titanium has an if that only allows text/html through. 钛上github上的示例代码有一个if,仅允许text / html通过。 Here is the code from the site, which I just added some else ifs to. 这是该站点中的代码,我刚刚在其中添加了一些其他代码。

if (e.WebSession.Request.Method == "GET" || e.WebSession.Request.Method == "POST")
        {
            if (e.WebSession.Response.ResponseStatusCode == "200")
            {
                if (e.WebSession.Response.ContentType!=null && e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html"))
                {
                    byte[] bodyBytes = await e.GetResponseBody();
                    await e.SetResponseBody(bodyBytes);

                    string body = await e.GetResponseBodyAsString();
                    await e.SetResponseBodyString(body);
                }
            }
        }

I tried just adding an else, with the exact same code as the body of the above, to catch everything else but images never seem to load in the site although all CSS, JS and HTML seem to work fine. 我尝试仅添加其他代码,使用与上述代码完全相同的代码来捕获其他所有内容,但是图像似乎从未加载到站点中,尽管所有CSS,JS和HTML似乎都可以正常工作。

Here is the link to Titanium web proxy github's page. 这是Titanium Web代理github页面的链接。 https://github.com/justcoding121/Titanium-Web-Proxy https://github.com/justcoding121/Titanium-Web-Proxy

e.WebSession.Response.ContentType.Trim().ToLower().Contains("text/html")

Images have differant content-type. 图像具有不同的内容类型。 You should remove above check and then use appropriate content-type. 您应该删除上面的检查,然后使用适当的内容类型。 After that read the bytes and save it as an image using the format specified in content-type header. 之后,读取字节,并使用content-type标头中指定的格式将其另存为图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM