added thing

This commit is contained in:
Lucas Kent 2022-11-18 09:28:42 -05:00 committed by GitHub
parent b6b595bf35
commit df4d81c356
7 changed files with 255 additions and 0 deletions

83
tools/corrupt/corrupt.php Normal file
View File

@ -0,0 +1,83 @@
<?php
$upfile_name = $_FILES['upfile']['name'];
$upfile_size = $_FILES['upfile']['size'];
$upfile_type = $_FILES['upfile']['type'];
$upfile = $_FILES['upfile']['tmp_name'];
// this value tells this code how many (succesful) corrupted files should be generated
// with a maximum of set retries
$nCorrupts = 10;
$nRetries = 1000;
if($upfile_size > (500 * 1024)) die("File is too big");
function jpegIsValid($filename) {
// load the file
$img = @imageCreateFromJPEG($filename);
// return 0 if the image is invalid
if(!$img) return(0);
// return 1 otherwise
return(1);
}
function scramble($content, $size) {
$sStart = 10;
$sEnd = $size-1;
$nReplacements = rand(1, 30);
for($i = 0; $i < $nReplacements; $i++) {
$PosA = rand($sStart, $sEnd);
$PosB = rand($sStart, $sEnd);
$tmp = $content[$PosA];
$content[$PosA] = $content[$PosB];
$content[$PosB] = $tmp;
}
return($content);
}
// first check if 'upfile' is set
if(empty($upfile) or empty($upfile_name)) {
die("No file to corrupt, please go back and select a JPEG image to upload.");
}
// then check if it is a JPEG file
if($upfile_type != "image/jpeg") {
die("The image does not seem to be JPEG but of type '$upfile_type', please go back and select a JPEG image to upload.");
}
// load the file and get its size
$content = file_get_contents($upfile);
$size = $upfile_size;
// now store the original one
$fd = fopen("images/$upfile_name", "w") or die("The first fopen went wrong, e-mail webmaster Ben.");
fwrite($fd, $content, $size) or die("The first fwrite went wrong, e-mail webmaster Ben.");
fclose($fd);
// check the copied image
if(!imageCreateFromJPEG("images/$upfile_name")) {
die("This JPEG is not valid, please go back and try another one.");
}
// create a folder to store the corrupted versions
@mkdir("images/$upfile_name-corrupted");
// corrupt it a few times
for($c = 0, $r = 0; $c < $nCorrupts && $r < $nRetries; $r++) {
// corrupt the file
$corrupted = scramble($content, $size);
// save it to disc
$fd = fopen("images/$upfile_name-corrupted/$c.jpg", "w") or die("The fopen went wrong, e-mail webmaster Ben.");
fwrite($fd, $corrupted, $size) or die("The fwrite went wrong, e-mail webmaster Ben.");
fclose($fd);
// count succeeded corrupts
if(jpegIsValid("images/$upfile_name-corrupted/$c.jpg")) $c++;
}
// jippie! we're done! now go to the list of images...
Header("Location: index.php");
?>

106
tools/corrupt/index.html Normal file
View File

@ -0,0 +1,106 @@
<?php $width = 500; ?>
<?php $first = 3; ?>
<HTML>
<HEAD>
<title>CORRUPT&trade;</title>
<link rel="stylesheet" href="styles.css" type="text/css">
</HEAD>
<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<center>
<TABLE ALIGN=LEFT CELLSPACING=10 BGCOLOR=#FFFFFF>
<TD colspan=2>
<!-- This part needs to stay on your page somewhere - visible -->
<p><strong>Corrupt&trade; - data corruption software 3.0</strong></p>
<p<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/80x15.png" /></a><br /><span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/InteractiveResource" property="dc:title" rel="dc:type">Corrupt</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.recyclism.com/corrupt.php" property="cc:attributionName" rel="cc:attributionURL">Corrupt by Recyclism</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.<br />Based on a work at <a xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://www.recyclism.com/corrupt/corrupt.zip" rel="dc:source">www.recyclism.com</a>.
</p>
<!-- End -->
<!-- Feel free to modify from here -->
<TR>
<TD colspan=2><IMG SRC="line.gif" WIDTH=5548 HEIGHT=5 ALT=""></TD>
</TR>
<TD colspan=2>
<BR>
<A href=upload.php><font color="#FF0000">Upload and Corrupt&trade; a JPEG file - Max 500kb</font></A>
<br>
<br>
</TD>
</p>
</TD>
<TR>
<TD colspan=2><IMG SRC="line.gif" WIDTH=5548 HEIGHT=5 ALT=""></TD>
</TR>
<TR><TD align=left><strong>3 Latest uploaded image</strong></TD><TD align=left><strong>Corrupted version</strong></TD></TR>
<?php
// open the images directory
$dir = opendir("images");
// list all files in the images directory
for($images = Array(); $file = readdir($dir);) {
// get full path
$img = "images/$file";
// skip directories
if(is_dir($img)) continue;
// store create time
$images[$img] = filectime($img);
}
// close the images directory
closedir($dir);
// sort images (backwards)
arsort($images);
// get image names
$images = array_keys($images);
// show images
for($i = 0; $i < $first && $i < count($images); $i++) {
// get filename
$fname = $images[$i];
// show the image
echo("<TR>");
echo("<TD><IMG src=\"$fname\" alt=\"$fname\" border=0 width=$width></TD>");
echo("<TD>");
echo("<TABLE border=0>");
echo("<TR>");
// open the directory containing the corrupted versions
$dir = opendir("$fname-corrupted");
// list all files in the corrupted directory
while($file = readdir($dir)) {
// skip directories in the corrupted folder
if(is_dir("$fname-corrupted/$file")) continue;
// show corrupted image
echo("<TD><IMG src=\"$fname-corrupted/$file\" alt=\"$fname ($file)\" border=0 width=$width></TD>");
}
// close table row
echo("</TR>");
echo("</TABLE>");
echo("</TD>");
echo("</TR>");
}
?>
</TABLE>
</center>
</BODY>

BIN
tools/corrupt/line.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
tools/corrupt/pattern.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 B

19
tools/corrupt/readme.txt Normal file
View File

@ -0,0 +1,19 @@
Corrupt by Corrupt by Recyclism is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at http://corrupt.recyclism.com/
I DO NOT OFFER SUPPORT TO SET UP CORRUPT on your server. I leave up to you to set up (it's nothing complicated), simply upload the corrupt folder and allow the image folder to be written.
I do not take any responsibility for vulnerability that your web server may occur by allowing php upload and I do not take any responsibility for any virus or malware you may get once you let people use it.
If you decide to host your own CORRUPT page, please make sure to keep the mentions and license details as they are in the html (see below):
<!-- This part needs to stay on your page somewhere - visible -->
<p><strong>Corrupt&trade; - data corruption software 3.0</strong></p>
<p<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/80x15.png" /></a><br /><span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/InteractiveResource" property="dc:title" rel="dc:type">Corrupt</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.recyclism.com/corrupt.php" property="cc:attributionName" rel="cc:attributionURL">Corrupt by Recyclism</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.<br />Based on a work at <a xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://www.recyclism.com/corrupt/corrupt.zip" rel="dc:source">www.recyclism.com</a>.
</p>
<!-- End -->
Feel free to update, modify and share corrupt with as many people as possible, however make sure you follow the terms and conditions sated in the license (Attribution-NonCommercial-ShareAlike 3.0 Unported)
http://creativecommons.org/licenses/by-nc-sa/3.0/
I'd also appreciate to know about CORRUPT pages out there and would like to link them from my website so feel free to send me a link to your page using this form: http://www.recyclism.com/contact.php

32
tools/corrupt/styles.css Normal file
View File

@ -0,0 +1,32 @@
body,table,td,tr,div,p,pre,h1,h2,h3,h4,ul {font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;}
body,td,div,p,pre,ul {font-size: 12px;color: #000000;}
/*BODY {background-color:#FFFFFF;}*/
BODY { background-image: url("pattern.gif") }
h1 {font-size: 12px;}
h2 {font-size: 12px;}
h3 {font-size: 12px;}
.menue {font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 12px;color: #0099FF;}
.lesen {font-size: 12px; color: #000000;}
.head {font-size: 12px; letter-spacing : 2px; color: #ffffff;}
.mhead {font-size: 12px; letter-spacing : 2px; color: #ffffff;}
.invert {color: #000000;background-color:#E0E2D4; font-weight : bold; letter-spacing : 2px; font-size: 12px}
a {font-size: 12px; text-decoration: none; font-weight : bold;}
a:link { text-decoration: none; color: #000000; }
a:visited { text-decoration: none; color: #000000; }
a:hover { text-decoration: none; color: #0099FF; }
a:active { text-decoration: none; color: #FF0000; }
.sb {scrollbar-3dlight-color:#666666;
scrollbar-arrow-color:#cc3300;
scrollbar-base-color:#ffffff;
scrollbar-darkshadow-color:#6666666;
scrollbar-face-color:#ffffff;
scrollbar-highlight-color:#ffffff;
scrollbar-shadow-color:}

15
tools/corrupt/upload.php Normal file
View File

@ -0,0 +1,15 @@
<HEAD>
<title>CORRUPT&trade;</title>
<link rel="stylesheet" href="styles.css" type="text/css">
</HEAD>
<FORM method=POST action="corrupt.php" enctype="multipart/form-data">
Corrupt an image: <INPUT type=file name=upfile size=40><INPUT type=submit name=submit value="Upload"><BR>
</FORM>
<!-- This part needs to stay on your page somewhere - visible -->
<p><strong>Corrupt&trade; - data corruption software 3.0</strong></p>
<p<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/3.0/80x15.png" /></a><br /><span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/InteractiveResource" property="dc:title" rel="dc:type">Corrupt</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.recyclism.com/corrupt.php" property="cc:attributionName" rel="cc:attributionURL">Corrupt by Recyclism</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.<br />Based on a work at <a xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://www.recyclism.com/corrupt/corrupt.zip" rel="dc:source">www.recyclism.com</a>.
</p>
<!-- End -->