php - Secure URL functions? -
my company's website got hacked, , i'm restoring website caution. company wants site possible don't have enough time re-code software's vulnerabilities away, i'm restoring after doing following:
- disabling input forms website. (basically, forms said
action = someform.php
renamedsomeform.php
on serversomeform1.php
nothing gets database. deal pdo , protection sql injections later). - with no forms left, there's no
$_post
input take care of, there's still$_get
. every page takes in query string, i've put check on every$_get['']
variable , made sure process when it's numeric should be. eg.if(isset($_get['page_id']) && is_numeric($_get['page_id'])) { /* */ }
. hacker seemed have broken through using sql injections. - with section of website (accessible company staff @ moment), i've made password protected folder. know hacker still use anonymous ftp or in using other ways, i'm hoping @ least avoid sql injections initially, thought password protected folder help. on top of existing secure login.
- i'm worried url. i'm not sure how secure or isn't, it's bilingual website, , way it's going (this part of code previous developer , don't 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 code 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 vulnerabilities here via url? or reasonably secured far?
one hint/note: regarding sql injection mentioned, make sure you're , everywhere using http://php.net/manual/en/pdo.prepared-statements.php
regarding changing language (in session). code seems safe since nobody inject or change something.
under line:
however, see 1 problem in url construction. uses base64_encode method make url "secure". however, can decode (since base64 encoding). long-term, may try using symetric encryption genereted key stored in user's session. way, nobody use url generated else.
anyway, changing language harmless in case. above mentioned proposal resources/operations needs secured. mean authorized person access (and not have stolen url). there are, of course, other ways how protect site. 1 practical advice.
Comments
Post a Comment