Skip to main content

Securing PHP web app directory

PHP Security
Sometimes when we access https://cool-domain.com/images/ you will see bunch of images of your website. What's wrong with that? If your website has been compromised specially you are using shared server. It's easy to run https://cool-domain.com/images/attacker.php.jpg in your browser. So, let's apply obscurity technique. It's a simple PHP script actually.

Obscurity for security

In your directory that you want to protect, create an index.php and write the code below. Open your browser and see it for yourself.

<?php
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found!');


I prefer this one compare of using .htaccess of Apache. Instead of throwing a message like "Forbidden" which is too obvious that you have something there, just use obscurity technique.

Comments

Popular posts from this blog

Basic Setup for Codeception Testing

This is how I setup my "lazy" Codeception testing environment globally. It might not that helpful but the main purpose is you will get the idea. Download Codeception Go to Codeception website and download the codecept.phar file. Or go to your terminal and wget https://codeception.com/codecept.phar Testing templates If you are doing Acceptance, REST API  and Unit Test then just run php codecept.phar bootstrap command. This will generate the tests folder and inside of it are all your folders for each particular test.    But if you are interested on one area of testing, let say for instance Unit Testing, then you may pick the 3rd command. Acceptance Testing codecept.phar init acceptance REST API Testing codecept.phar init api Unit Testing codecept.phar init unit From the templates given above. I'll be using the Unit Testing template for my simple example. You can find this in quickstart of Codeception website. Let's do the basic test. Initialize ...

Object Oriented Programming and Functional Programming in PHP

A lot of buzzes and war going on about who is best in programming paradigms  (the fancy of saying "style in programming") . If it is Object Oriented Programming or Functional Programming or should I go for OOP or FP? I don't like to be sounds clever here but I here is my opinion. Since they serve different purpose. Why should I bother myself figuring out which of them are best, if they can be friends and work hand-in-hand, right? You can't use OOP in FP because it might be overkill but you can use FP in OOP. This is how we are going to leverage the two! Stop the mentality of being "which is best". Instead, start thinking "how can I leverage it". [Draft mode]

Running Dart for Web in Windows

I know the documentation was already exist on Dart website  but most of the documentations "assumed" that you know "this" and "that". So, I'll try to solve that problem here. Let's dive-in on how to run Dart for Web in Windows platform. Install Dart-SDK using Chocolatey Head over to chocolatey  website and follow the instruction on how to install chocolatey. This amazing application is like a composer for PHP or pip for Python. Don't forget to run the terminal in Administrative mode when you don't have Powershell. I recommend this approach of installing the Dart-SDK compare the Gekorm . Get CLI tools or an IDE (or both) Install  webdev and stagehand . Your CLI buddies. C:\>pub global activate webdev C:\>pub global activate stagehand Stagehand helps you get your Dart projects set up. It is a Dart project scaffolding generator. Webdev will do build and serve for the app. The available commands for stagehand are...