From a06b0312ad162a992c4312308946bfbfb7c93e29 Mon Sep 17 00:00:00 2001 From: getimiskon Date: Mon, 13 Feb 2023 17:42:17 +0200 Subject: [PATCH] Added code for filename randomization --- http/sakisafe.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/http/sakisafe.pl b/http/sakisafe.pl index 0900a48..e0ef3d1 100755 --- a/http/sakisafe.pl +++ b/http/sakisafe.pl @@ -21,9 +21,11 @@ $openbsd = 1 if $^O eq "openbsd"; pledge("stdio cpath rpath wpath inet flock fattr") if $openbsd; my $MAX_SIZE = 1024 * 1024 * 100; - my @BANNED = qw(); # Add banned IP addresses here +my $RANDOMIZE_FILENAME = 1; + my $dirname; +my $filename = ""; my $host; mkdir "f"; @@ -58,7 +60,12 @@ sub handle_file { # Generate random string for the directory my @chars = ( '0' .. '9', 'a' .. 'Z' ); $dirname .= $chars[ rand @chars ] for 1 .. 5; - my $filename = $filedata->filename; + if ( $RANDOMIZE_FILENAME eq 1 ) { + $filename .= $chars [ rand @chars ] for 1 .. 5; + # TODO: add extension at the end of the filename, fix the multiplication of the chars every time the code runs + } else { + $filename = $filedata->filename; + } carp(color("bold yellow"), "sakisafe warning: could not create directory: $ERRNO", color("reset")) unless mkdir( "f/" . $dirname ); $filename .= ".txt" if $filename eq "-"; @@ -123,7 +130,7 @@ __DATA__

sakisafe

-

shitless file upload, pastebin and url shorter

+

shitless file upload, pastebin and url shortener

USAGE

POST a file: