CryptoAnalysis icon indicating copy to clipboard operation
CryptoAnalysis copied to clipboard

Extend transformations when extracting variables

Open smeyer198 opened this issue 6 months ago • 0 comments

#683 added required components to extract transformed values. On a high level, new Boomerang queries are triggered to collect all required values and then corresponding operations are executed to determine the correct values. For example, consider the following statement:

KeyGenerator kg = KeyGenerator.getInstance("AES".replace("A", "D");

Boomerang transforms this statement to

varReplacer0 = "A"
varReplacer1 = "D";
s1 = "AES"
s2 = s1.replace(varReplacer0, varReplaver1)
kg = staticInvoke.<getInstance(s2)>

Since getInstace is part of a rule and depends on a constraint, the ExtractParameterAnalysis triggers a Boomerang query to extract the parameter s2. Since s2 is not a concrete value (i.e. a constant or new expression), it cannot extract the correct value directly. The transformation components extend this query by triggering new queries to compute relevant variables, performs the operation replace with the collected value, and returns the result as allocation site. In total, the following steps are done:

  • Trigger a Backward query Q(getInstace(s2), s2)
  • At s2 = s1.replace(varReplacer0, varReplaver1), trigger the queries Q(s2 = s1.replace(varReplacer0, varReplaver1), s1), Q(s2 = s1.replace(varReplacer0, varReplaver1), varReplacer0), and Q(s2 = s1.replace(varReplacer0, varReplaver1), varReplacer1).
  • With the extracted values s1, varReplacer0, and varReplacer1, perform the operation s1.replace(varReplacer0, varReplaver1), giving the result DES
  • Return the value DES as result for the original query Q(getInstace(s2), s2)

Currently, the transformations for Integer.parseInt, String.replace, String.toCharArray, String.getBytes, BigInteger.valueOf, Array.length, Hex.decode, String.toUpperCase, and String.toLowerCase are implemented.

Tasks:

  • Think of further transformations for Strings, Wrappers (e.g. Integer, Double) and other transformations like + or - for integers.
  • Implement the transformations

Obsoletes #269

smeyer198 avatar Aug 06 '24 12:08 smeyer198