summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar steering72532026-07-16 15:42:01 -0600
committerGravatar steering72532026-07-16 15:42:01 -0600
commit6c9350e48ff04d7ae8582374fb4e3439b50162d5 (patch)
tree0a9feeb2576001ed007fc935fb6db2284c2c37e6
parentadd a noscript to the upload prompt (diff)
downloadhostfiles-6c9350e48ff04d7ae8582374fb4e3439b50162d5.tar.gz
hostfiles-6c9350e48ff04d7ae8582374fb4e3439b50162d5.tar.bz2
hostfiles-6c9350e48ff04d7ae8582374fb4e3439b50162d5.zip
block application/x-www-form-urlencoded
-rw-r--r--upload.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/upload.php b/upload.php
index 991cde7..352fdf8 100644
--- a/upload.php
+++ b/upload.php
@@ -13,7 +13,14 @@ if ($_SERVER['REQUEST_METHOD'] != 'POST' && $_SERVER['REQUEST_METHOD'] != 'PUT')
}
$c_t = strtolower($_SERVER['HTTP_CONTENT_TYPE'] ?? '');
-if ($c_t == 'multipart/form-data' || 0 === strpos($c_t, 'multipart/form-data;')) {
+if ($c_t == 'application/x-www-form-urlencoded') {
+ header('Status: 415 Unsupported Media Type');
+ header('Content-Type: text/plain');
+ echo "You seem like a really dumb bot that doesn't check the enctype of the form before spraying common vulnerabilities.\n";
+ echo "Content-Type: application/x-www-form-urlencoded is not supported.\n";
+ send_notification("[hostfil.es] $_SERVER[REMOTE_ADDR] tried to $_SERVER[REQUEST_METHOD] $c_t");
+ exit;
+} elseif ($c_t == 'multipart/form-data' || 0 === strpos($c_t, 'multipart/form-data;')) {
$FILES = remap_files();
if (!isset($FILES['file'])) {
die_error("You need to upload the file within the field name 'file[]' (or 'file' if there's only one) if you want to use multipart/form-data.", '406 Not Acceptable');