Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Last active December 23, 2018 11:24
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 JavaScript-Packer/d82363449e055a5f0507 to your computer and use it in GitHub Desktop.
Save JavaScript-Packer/d82363449e055a5f0507 to your computer and use it in GitHub Desktop.
Turned/reversed the unpacker for WHAK compression algorithm and made it into a HTML entities encoder - http://www.whak.ca/packer/JavaScript.htm
var W,H,A,K;
H ="& < > " 
 '"[$="split"](" ");
A ="&<>\"\n'";W='<script>alert("www.WHAK.com");<\/script>';
K =0;for(K in A)W=W[$](A[K]).join(H[K]);alert(W);
@JavaScript-Packer
Copy link
Author

var W,H,A,K;
H='Some <textarea id="test">www.WHAK.com</textarea>, more Text&Text';
K=[
    [/&/g,"&amp;"],
    [/</g,"&lt;"],
    [/>/g,"&gt;"],
    [/"/g,"&#34;"]
];
for(W in K)H=H.replace(K[W][0],K[W][1]);
alert(H);

@JavaScript-Packer
Copy link
Author

Here is is as a functional function...

function HTML( W,H,A,K ){
    H = '&amp; &lt; &gt; &#34; &#10; &#39;'.split(' ');
    A = '&<>"\x0A\''.split('');
    K =  0; for(K in A)W=W.split(A[K]).join(H[K]);return W
}alert(HTML('<script>alert("www.WHAK.com");<\/script>'));

@JavaScript-Packer
Copy link
Author

Minified

function HTM(W,H,A,K){H="&amp; &lt; &gt; &#34; &#10; &#39;"[x='split'](" ");A="&<>\"\n'"[x]("");K=0;for(K in A)W=W[x](A[K]).join(H[K]);return W}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment