Results 1 to 10 of 18
Threaded View
-
23rd Aug 2010, 12:48 PM #1OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.comSession Hijacking
Heya guys,
Just going to do a little talk about Session Hijacking today...
What is Session Hijacking
Session hijacking is a way that a hacker can gain access to someone else's session and gain access to private parts of your site.
How does it work:
Session hijacking works by an external source (hacker) gets access to a cookie file from a user and then sets a cookie on his machine to fool your site to thinking that the hacker is actually the user.
Example of how a session works:
Session works in a way where your server gives out a unique id to a user's cookie, and stores a file with session data in temporary files.
from the moment you call session_start(); a cookie is sent to the browser witch is stored, lets take this example.
PHP Code:session_start();
/*
1. A check is made to get a session id from the cookie, if exists see 1.a, if not see 1b
1a. php checks to see if session_COOKIE_ID exists in /tmp and loads t he data
1b. A new session id is created and a new blank file is created called session_SID.tmp
2. The session data is loaded into $_SESSION
*/#
if(isset($_SESSION['logged_in']))
{
//Blah
}
not good
Preventing this from happening!
Theres a few ways to prevent hijacking and im going to show you them.
The first way is to check the users User-Agent, so if its another user agent then you can stop the session.
Heres an example
PHP Code:session_start();
$ua = md5($_SERVER['HTTP_USER_AGENT']);
if(isset($_SESSION['SECURITY_UA']))
{
if($ua != $_SESSION['SECURITY_UA'])
{
die('Session Hijacking Attempt');
}
}
The next way is to mix it up so to speek, so that we mix data the hacker can never get.
PHP Code:session_start();
$ua = md5($_SERVER['HTTP_USER_AGENT']."SeCrEtStRiNgAhAcKeRCaNtGet");
if(isset($_SESSION['SECURITY_UA']))
{
if($ua != $_SESSION['SECURITY_UA'])
{
die('Session Hijacking Attempt');
}
}
so this still can be improved, HOW you ask.. let me show you
PHP Code:session_start();
$newtoken = uniquid(rand(0,1000),true);
$oldtoken = $_SESSION['TOKEN'];
$ua = md5($_SERVER['HTTP_USER_AGENT'] . $newtoken);
//Update the data
$_SESSION['TOKEN'] = $newtoken;
if(isset($_SESSION['SECURITY_UA']))
{
if($oldtoken != $_SESSION['SECURITY_UA'])
{
die('Session Hijacking Attempt');
}else
{
$_SESSION['SECURITY_UA'] = $ua; //new hash
}
}
Implementing such things will practically stop Hijackers in there tracks.
NOTE:
Have you ever noticed that sites like facebook log you out if you close your browser, and reopen it, and others just dont log you out.
Think how that's handledFingerprint the browsers session.
litewarez Reviewed by litewarez on . Session Hijacking Heya guys, Just going to do a little talk about Session Hijacking today... What is Session Hijacking Session hijacking is a way that a hacker can gain access to someone else's session and gain access to private parts of your site. How does it work: Session hijacking works by an external source (hacker) gets access to a cookie file from a user and then sets a cookie on his machine to fool your site to thinking that the hacker is actually the user. Rating: 5Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
[help] Detect session on URL
By jomasaco in forum Web Development AreaReplies: 4Last Post: 28th Apr 2011, 05:20 PM -
China Web hijacking shows Net at risk
By Benign in forum News & Current EventsReplies: 4Last Post: 18th Nov 2010, 06:32 AM -
[PHP] Session's secure
By Nedim! in forum Web Development AreaReplies: 2Last Post: 12th Oct 2010, 05:43 PM -
stop image hijacking (anti-hotlinking) Lighttpd
By jessepure in forum Server ManagementReplies: 4Last Post: 16th Jan 2010, 12:19 PM -
Webcam session with To0 :P
By CyberJ37 in forum General DiscussionReplies: 40Last Post: 22nd Dec 2009, 09:20 AM
themaCreator - create posts from...
Version 3.56 released. Open older version (or...