Print any code
Print any code even if it is obfuscated with not valid op codes and other garbage. Also it can print any custom modification of byte code instead of fall with Exception.
This commit is contained in:
@@ -128,6 +128,10 @@ public class Print extends Lua {
|
||||
}
|
||||
|
||||
static void printValue( PrintStream ps, LuaValue v ) {
|
||||
if (v == null) {
|
||||
ps.print("null");
|
||||
return;
|
||||
}
|
||||
switch ( v.type() ) {
|
||||
case LuaValue.TSTRING: printString( ps, (LuaString) v ); break;
|
||||
default: ps.print( v.tojstring() );
|
||||
@@ -136,7 +140,7 @@ public class Print extends Lua {
|
||||
}
|
||||
|
||||
static void printConstant(PrintStream ps, Prototype f, int i) {
|
||||
printValue( ps, f.k[i] );
|
||||
printValue( ps, i < f.k.length ? f.k[i] : LuaValue.valueOf("UNKNOWN_CONST_" + i) );
|
||||
}
|
||||
|
||||
static void printUpvalue(PrintStream ps, Upvaldesc u) {
|
||||
@@ -189,6 +193,9 @@ public class Print extends Lua {
|
||||
ps.print("[" + line + "] ");
|
||||
else
|
||||
ps.print("[-] ");
|
||||
if (o >= OPNAMES.length - 1) {
|
||||
ps.print("UNKNOWN_OP_" + o + " ");
|
||||
} else {
|
||||
ps.print(OPNAMES[o] + " ");
|
||||
switch (getOpMode(o)) {
|
||||
case iABC:
|
||||
@@ -220,11 +227,19 @@ public class Print extends Lua {
|
||||
case OP_GETUPVAL:
|
||||
case OP_SETUPVAL:
|
||||
ps.print(" ; ");
|
||||
if (b < f.upvalues.length) {
|
||||
printUpvalue(ps, f.upvalues[b]);
|
||||
} else {
|
||||
ps.print("UNKNOWN_UPVALUE_" + b);
|
||||
}
|
||||
break;
|
||||
case OP_GETTABUP:
|
||||
ps.print(" ; ");
|
||||
if (b < f.upvalues.length) {
|
||||
printUpvalue(ps, f.upvalues[b]);
|
||||
} else {
|
||||
ps.print("UNKNOWN_UPVALUE_" + b);
|
||||
}
|
||||
ps.print(" ");
|
||||
if (ISK(c))
|
||||
printConstant(ps, f, INDEXK(c));
|
||||
@@ -233,7 +248,11 @@ public class Print extends Lua {
|
||||
break;
|
||||
case OP_SETTABUP:
|
||||
ps.print(" ; ");
|
||||
if (a < f.upvalues.length) {
|
||||
printUpvalue(ps, f.upvalues[a]);
|
||||
} else {
|
||||
ps.print("UNKNOWN_UPVALUE_" + a);
|
||||
}
|
||||
ps.print(" ");
|
||||
if (ISK(b))
|
||||
printConstant(ps, f, INDEXK(b));
|
||||
@@ -280,7 +299,11 @@ public class Print extends Lua {
|
||||
ps.print(" ; to " + (sbx + pc + 2));
|
||||
break;
|
||||
case OP_CLOSURE:
|
||||
if (bx < f.p.length) {
|
||||
ps.print(" ; " + f.p[bx].getClass().getName());
|
||||
} else {
|
||||
ps.print(" ; UNKNOWN_PROTYPE_" + bx);
|
||||
}
|
||||
break;
|
||||
case OP_SETLIST:
|
||||
if (c == 0)
|
||||
@@ -294,6 +317,7 @@ public class Print extends Lua {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user