News for hackers. Stuff that matters.
Re:Things to commit just before leaving your job by onion2k on Wednesday August 19, 2015 @08:36AM (#10085008)
Something I wrote to amuse the junior front end developers here:

    document.write('Error: Script not found.');
    var node = document.currentScript;
    if (node.parentNode) { node.parentNode.removeChild(node); }
Pop that in a JS file called something like jQuery.min.js and add it to an HTML page with the usual <script src="/js/jQuery.min.js"></script>. It'll run when the page loads, add the line of text to the page, and then it'll remove it's own <script> tag so there's no reference to it in the DOM (in relatively modern browsers) if you view the source. It's easy to debug by watching the network traffic, but it caused a few scratched heads for a little while.
Re:Things to commit just before leaving your job by ivank on Wednesday August 19, 2015 @09:24AM (#10085200)
'View source' shows the HTML source, not the DOM, in both Firefox and Chrome. Maybe you're thinking of the developer console, or the Firefox 'View selection source' feature?
Re:Things to commit just before leaving your job by onion2k on Wednesday August 19, 2015 @09:58AM (#10085467)
You're right, I am, but pretty much every developer will use the browser's built-in dev tools to query the source these days, so the trick worked.
Re:Things to commit just before leaving your job by thegreatpeter on Wednesday August 19, 2015 @10:27AM (#10085703)
Why wouldn't you search for 'Script not found' in the source code..?
Re:Things to commit just before leaving your job by onion2k on Wednesday August 19, 2015 @11:19AM (#10086054)
The point wasn't to leave people puzzling over it for hours. It was a bit of fun. But ... It'd be quite trivial to hide the string.

    var msg = ['E','r','r','o','r',':','S','c','r','i','p','t',' ','n','o','t',' ','f','o','u','n','d'];
    document.write(msg.join(''));
Re:Things to commit just before leaving your job by billyhoffman on Wednesday August 19, 2015 @01:15PM (#10086947)
I gave a talk at BlackHat many years ago about JS malware, and proposed obfuscating malicious JS like this:

- Treat JS code like 7-bit ASCII

- For each character, convert the bits into white space. 1= space, 0 = tab

- A = "1000001" = space tab tab tab tab tab space

- concat it all together, \n shows you are done

So you can represent JS code as just whitespace. Which means this is malicious code:

<script> //st4rt

//3nd

var html = document.body.innerHTML; var start = html.indexOf("//st" + "4rt"); var end = html.indexOf("3" + "nd"); var code = html.substring(start+12, end); eval(hydrate(code)); </script>

Re:Things to commit just before leaving your job by onion2k on Wednesday August 19, 2015 @05:09PM (#10088512)
I like that a lot. I wonder if it might be possible to use Unicode zero width space and zero width non-joiner characters.. Then there wouldn't even be any white space to see.
Re:Things to commit just before leaving your job by nullgeo on Wednesday August 19, 2015 @11:27AM (#10086115)
Base64 encode the string for added fun.
Re:Things to commit just before leaving your job by gknoy on Wednesday August 19, 2015 @11:49AM (#10086343)
... and then caesar-cipher it so that the first guess won't easily find it? :D
Re:Things to commit just before leaving your job by napperjabber on Wednesday August 19, 2015 @12:48PM (#10086762)
Add 'happy hunting' in a comment string for additional fun.
Re:Things to commit just before leaving your job by jupiterjaz on Wednesday August 19, 2015 @10:42AM (#10085811)
I'm a junior dev with just 1 year of experience and this was my immediate instinct.
Re:Things to commit just before leaving your job by mtsmithhn on Wednesday August 19, 2015 @08:44AM (#10085036)
I remember that game: Javascript hide and go seek