Skip to content

Instantly share code, notes, and snippets.

@jsyeo
Created January 4, 2016 07:23
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 jsyeo/1395d0ec6119280bbf82 to your computer and use it in GitHub Desktop.
Save jsyeo/1395d0ec6119280bbf82 to your computer and use it in GitHub Desktop.
Two Inner Classes
public class Main {
public static void main(String[] args) {
a().evaluate();
}
public static Expression a() {
final Expression e = SimpleExpression.builder();
return new Expression() {
@Override
public Expression evaluate() {
return e.evaluate();
}
};
}
public static Expression b() {
final Expression e = SimpleExpression.builder();
return new Expression() {
@Override
public Expression evaluate() {
return e.evaluate();
}
};
}
}
interface Expression {
Expression evaluate();
}
class SimpleExpression implements Expression {
@Override
public Expression evaluate() {
Vuln.vulnerableMethod();
return null;
}
static SimpleExpression builder() {
return new SimpleExpression();
}
}
class Vuln {
static void vulnerableMethod() {
System.out.println("pwn");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment