제어 흐름 평탄화
controlFlowFlattening
~1.5x slower
코드 구조를 변형해 원래의 프로그램 흐름을 숨깁니다. 선형적인 코드를 switch 문 기반의 상태 머신으로 바꿔 수동 분석을 훨씬 어렵게 만듭니다.
// Before
function process() {
step1();
step2();
step3();
}
// After (flattened)
function process() {
var state = '0|1|2'.split('|'), i = 0;
while (true) {
switch (state[i++]) {
case '0': step1(); continue;
case '1': step2(); continue;
case '2': step3(); continue;
}
break;
}
}
제어 흐름 평탄화는 다른 기본 옵션은 물론 VM 난독화와도 잘 어울립니다. VM을 활성화하면 평탄화된 상태 머신이 다시 바이트코드로 변환됩니다.
