Results 1 to 10 of 18
-
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
-
23rd Aug 2010, 12:55 PM #2Member
Well session hijacking can't be done on every kind of sites , only on some custom made cms that are not very famous with vulnerabilities
-
23rd Aug 2010, 12:57 PM #3OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.comas a web developer i never use open source cms's as such, iu always create a framework where 1 edit filters threw the whole of my site.
and you would not believe the logs i get. so your wrong, there's hackers trying everyone, its only script kiddies who copy and past a vuln.Join 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
-
23rd Aug 2010, 01:00 PM #4Respected DeveloperWebsite's:
wrzc.orgI use a basic encripted one using the user agent but I don't add random inputs like you have in the last example only static ones but will now in the unlikely event they get that far.
I do really like your tuts litewarez even if I don't use them all their bookmarked in the brain for later
-
23rd Aug 2010, 01:02 PM #5OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.comhaha Mr Happy, no probs dood.
its nice to shareJoin 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
-
23rd Aug 2010, 01:07 PM #6MemberWebsite's:
porntonight.infobut where we need to add this code ?
-
23rd Aug 2010, 01:17 PM #7OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.comYou can add the code into a functions and call the functions just after session_start();
or you can just add the code after session_start() in your application.Join 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
-
23rd Aug 2010, 01:19 PM #8Member
Some good pics from a good friend to make you understand this topic :
--------------------------
--------------------------------------------
And Very nice one :
-
23rd Aug 2010, 01:19 PM #9MemberWebsite's:
porntonight.infolite bro , i need to know little more as i am noob
i have two vb forums, so which files i need to edit in that ?
-
23rd Aug 2010, 01:22 PM #10Member
LOL man dont worry about it, VB is fine ! hehehe
this is for applications made by you , lets say you are a programmer, this will help you to overcome session hijacking if you ever make an web app !
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...