My company's website just got hacked, and I'm now restoring the website with extra caution. The company wants the site up as soon as possible so I don't have enough time to actually re-code the software's vulnerabilities away, so I'm restoring it after doing the following:
- Disabling all input forms from the website. (Basically, for all forms that said
action = someform.php
I just renamedsomeform.php
on the server tosomeform1.php
so that nothing actually gets to the database. I will deal with PDO and protection from SQL injections later). - With no forms left, there's no
$_POST
input to take care of, but there's still$_GET
. For every page that takes in a query string, I've put a check on every$_GET['']
variable and made sure to only process it when it's numeric as it should be. eg.if(isset($_GET['page_id']) && is_numeric($_GET['page_id'])) { /* do something */ }
. The hacker seemed to have broken through using SQL injections. - With another section of the website (accessible only to company staff at the moment), I've made it a password protected folder. I know a hacker could still use anonymous FTP or get in using other ways, but I'm hoping at least to avoid SQL injections initially, so I thought the password protected folder would help. This is on top of an existing secure login.
- I'm now worried about the URL. I'm not sure how secure it is or isn't, it's a bilingual website, and this is the way it's going (this part of the code is by the previous developer and I don't really understand it):
if($_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == 'salman'){
$url =zeej_dir.curPageName().'?'.$_SERVER["QUERY_STRING"];
} else {
$url ='/'.curPageName().'?'.$_SERVER["QUERY_STRING"];
}
$change_url = "http://".$_SERVER['SERVER_NAME'].$url;
if($_SESSION['ln'] == 'en'){
echo '<img src="'.getSiteUrl().'images/arabicicon.jpg" alt="Arabic" width="15" height="15" />';
echo '<a href="'.getSiteUrl().'change_session.php?page_url='.base64_encode( $change_url ).'" class="top_frametext">Arabic</a>';
} else {
echo '<img src="'.getSiteUrl().'images/engicon.jpg" alt="English" width="15" height="15" />';
echo '<a href="'.getSiteUrl().'change_session.php?page_url='.base64_encode( $change_url ).'" class="top_frametext">English</a>';
}
And this is the code for change_session.php
:
@session_start();
$page_url = isset($_REQUEST['page_url'])?$_REQUEST['page_url']:'';
if($_SESSION['ln'] == 'en'){
$_SESSION['ln'] ='ar';
} else {
$_SESSION['ln'] ='en';
}
header("location: ".base64_decode($page_url));exit;
Are there some vulnerabilities here via the URL? Or am I reasonably secured so far?