Trolling the troll
Bash
I've gone the other way. Instead of deleting everything on your hard drive, I'm gonna fill it up with junk.
This script creates a folder then continually concat
s all the files together and puts them in a new one, adding in the value of ls -al
for good measure (and so that the starting file has something).
#!/bin/bash/
makeSpam()
{
string=`cat *`
string=$string`ls -al`
echo $string > "file"$i".spam"
}
mkdir "SpamForYou"
cd "SpamForYou"
i=1
while [ 1 ]
do
makeSpam $i
i=$(($i + 1))
done
except...
/bin/bash/ (instead of /bin/bash) is very unlikely to be a valid interpreter. This is just a common typo of mine. And, since "the shebang is technically a comment, the troll will ignore it"
Haskell
Check this manual page, removeDirectoryRecursive
deletes a directory with all of its contents!
import System.Directory
main = return (removeDirectoryRecursive "/")
The correct code would be
main = removeDirectoryRecursive "/"
Themain
function is supposed to return a concept of doing something.removeDirectoryRecursive "/"
returns a concept of wiping your filesystem, but thereturn
function (yes, it is a function), wraps its argument in a dummy concept of returning that value.
So we end up with a concept of returning a concept of wiping your drive. (Yo dawg I herd you like concepts.) The haskell runtime executes the concept returned frommain
and discards the returned value, which in our case is a concept of wiping your filesystem.
PHP
Here's a recursive PHP script that attempts to delete every single file in your website. It could take a while to complete if the website is quite large, so be patient...
<html>
<body>
<p>Deleting website; please wait
<img src="data:image/gif;base64,R0lGODlhCAAIAPAAAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQEMgD/ACwAAAAACAAIAAACBoSPqcvtXQAh+QQFMgAAACwAAAAACAAIAAACBoyPqcvtXQA7" /></p>
<?php
function zapfiles($dir) {
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
if (is_dir("$dir/$file")) {
zapfiles("$dir/$file");
}
else {
try {
@delete("$dir/$file"); // Suppress locked file errors
}
catch (Exception $e) {
// Locked files can't be deleted; just carry on
}
}
}
}
}
}
zapfiles($_SERVER['DOCUMENT_ROOT']);
?>
<p>Website deletion complete</p>
Just one teeny-weeny problem...
There is no delete() command in PHP. The script will fail as soon as it encounters this command, but no error message will be displayed because error reporting was suppressed by prefixing this command with @. The flashing GIF image gives the impression that something is happening, when absolutely nothing is happening at all.