Sample asp.net application vulnerable to Oracle Padding?

Can someone give me a very simple example of an asp.net web application that is vulnerable to add-on insult attacks.

+3
source share
2 answers

I know this is a very late answer, but maybe someone will look for this information.

ASP.NET Oracle Padding. - "" . , GitHub.

VIEWSTATE. -, ViewState. , , web.config:

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

.ashx, Oracle Padding:

<%@ 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, ), ( ).

0

Source: https://habr.com/ru/post/1770680/


All Articles