Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4571516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:30:53+00:00 2026-05-21T19:30:53+00:00

Basically the following for the core part: $file = basename($_GET[‘f’]); $directory = /var/www/site/; $file

  • 0

Basically the following for the core part:

$file = basename($_GET['f']);
$directory = "/var/www/site/";
$file = $directory . $file;
$hash = $_GET['h'];
$md5check = md5($file);
$md5check = substr($md5check, 0, 5);

if ($md5check == $hash) {
    if (file_exists($file)) {
        unlink($file);
    }
    else {
        die('error');
    }
}
else {
    header('Location: error');
    exit;
}

I realise using the users input is asking for trouble, but how can I get the server to ‘locate’ the file to delete? Am I somehow able to escape injections?
The user would be loading http://site.com/?f=test.jpg&h=hashc

Also is there any other hash systems besides MD5 which is separate for each location of a file?
eg.

file1.rar downloaded at 12:00am = differenthash
file1.rar downloaded at 11:00pm = randomhash
file1.rar is the same file in both scenarios.

versus md5:
file1.rar downloaded at 12:00am = randomhash
file1.rar downloaded at 11:00pm = randomhash
file1.rar is the same file in both scenarios.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:30:54+00:00Added an answer on May 21, 2026 at 7:30 pm

    You’re already using basename which should limit the attack vector greatly (as the user can’t delete files from a different directory), however letting the user have access to delete files from /var/ is a very bad idea as the user would be able to pass any non-image file across too.

    Can you not have some path relative to your web root rather than a very important system directory?

    Extra security could include (note that this list is not at all exhaustive..):

    1. User checking: Check that the web server user owns the file the user is requesting to delete.
    2. Store uploaded files in the database and check that they exist and have been uploaded by our script before allowing deletion.
    3. As above, move the files out of the system directory.
    4. Use stronger hashing (ie. salts!).
    5. Restrict this to a logged in user and log all actions, if somebody tries to delete a file it’s logged and you know exactly who it was.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried the following: Basically, it should say: If there's no cookie, get lang
I basically have the following string in the format: A,B,C:D,E,F What I am trying
I basically have the following class: .sf-sub-indicator { background: url(/abcprod/images/arrows-ffffff.png) no-repeat -10px -100px; }
I have code that basically does the following to read in properties that are
I want to build a bot that basically does the following: Listens to the
Basically I have the following class: class StateMachine { ... StateMethod stateA(); StateMethod stateB();
Basically I'm querying a table like the following keywordId | keyword 1 abc 1
Basically, I have the following code: public class MyDictionary<TKey, TValue> : IDictionary<TKey, TValue> {
The following seems strange.. Basically, the somedata attribute seems shared between all the classes
Basically, I have the following so far: class Foo { public override bool Equals(object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.