Skip to content

Instantly share code, notes, and snippets.

@martani
Last active December 10, 2015 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martani/4471399 to your computer and use it in GitHub Desktop.
Save martani/4471399 to your computer and use it in GitHub Desktop.
Online padding oracle
//Class implements ICBCOracle
public class OnlineCBCOracle : ICBCOracle
{
public bool RequestOracle(byte[] cipher)
{
const string BASE_URL = "ORACLE_URL?er=";
string urlData = Helpers.ConvertByteArrayToHexString(cipher);
WebClient wc = new WebClient();
try
{
wc.DownloadData(BASE_URL + urlData);
}
catch (WebException e)
{
//Invalid padding
if (e.Message.Contains("403"))
return false;
//Valid padding, but wrong mac
if (e.Message.Contains("404"))
return true;
}
//Failed, the oracle is not up!
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment