Skip to content

Files

Latest commit

dd27daa · Nov 1, 2020

History

History
38 lines (29 loc) · 954 Bytes

File metadata and controls

38 lines (29 loc) · 954 Bytes

CodeIntegrity

POC

function hashCode (s) {
    var hash = 0;
    if (s.length == 0) {
        return hash;
    }
    for (var i = 0; i < s.length; i++) {
        var char = s.charCodeAt(i);
        hash = ((hash<<5)-hash)+char;
        hash = hash & hash; // Convert to 32bit integer
    }
    return hash;
}

function start() {
    alert('steal cookies!');
}

function main() {
    if (hashCode(start.toString()) !== -1968638942) return;
    start();
}

main()

About

The idea here is to test the integrity of the code "on the fly" and expect the protected function's hash to not change. If it changed it means the code has changed as well, probably for research purposes, and that means the protection of the code has been compromised.

Resources