【问题标题】:Example of an asp.net application vulnerable to the Padding Oracle Attack?易受 Padding Oracle 攻击的 asp.net 应用程序示例?
【发布时间】:2011-04-28 11:36:56
【问题描述】:

谁能给我一个非常基本的 asp.net web 应用程序示例,该应用程序容易受到 padding oracle 攻击。

【问题讨论】:

  • 所有应用程序在补丁之前都容易受到攻击。特别是如果您使用 ViewState。
  • 是的,我知道,但我不熟悉 asp.net 编程...所以请你给我举个例子。使用例如视图状态
  • 您请求的目的是什么?试图入侵您的竞争对手的网站?
  • 我想在我自己的网站上试试这个漏洞...这就是为什么我要求源代码,因为我不知道如何在 asp.net 中编码

标签: asp.net padding-oracle-attack


【解决方案1】:

我知道这是一个很晚的答案,但也许有人会寻找此信息。

旧版本的 ASP.NET 容易受到 Padding Oracle 攻击。仍然可以通过一些调整来强制执行“旧”行为。我在blog 上详细描述了它们,示例代码在GitHub 上。

我们将攻击 VIEWSTATE 字段。首先,您需要禁用 ViewState 签名。为此,请确保您在 web.config 文件中有以下设置:

<appSettings>
  <add key="aspnet:UseLegacyMachineKeyEncryption" value="true" />
</appSettings>

还有一个易受 Padding Oracle Attack 攻击的示例 .ashx 文件:

<%@ WebHandler Language="C#" Class="EncryptionHandler" %>

using System;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Security;
using System.Text;

public class EncryptionHandler : IHttpHandler
{
    static readonly byte[] secret = Encoding.UTF8.GetBytes("Some text to break.");

    public void ProcessRequest(HttpContext context)
    {
        var viewState = context.Request.Form["VIEWSTATE"];

        if (viewState == null) {
            viewState = MachineKey.Encode(secret, MachineKeyProtection.Encryption);
            context.Response.ContentType = "text/html";
            context.Response.Write("<!doctype html><html><form action=\"/EncryptionHandler.ashx\" method=\"POST\">" +
                "<input type=\"hidden\" name=\"VIEWSTATE\" value=\"" + viewState + "\" />" +
                "<input type=\"submit\" value=\"Test\" /></form></html>");
            return;
        }

        var v = MachineKey.Decode(viewState, MachineKeyProtection.Encryption);
        context.Response.ContentType = "text/plain";
        if (v.SequenceEqual(secret)) {
            context.Response.Write("I know the secret");
        } else {
            context.Response.Write("Something is wrong with my secret.");
        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }
}

现在,根据 HTTP 代码(密码无效时为 HTTP 500),您可以尝试攻击该站点(如 here 所述)。

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 2010-12-19
    • 1970-01-01
    • 1970-01-01
    • 2018-11-17
    • 2016-04-18
    • 2018-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多