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

14 participants
subzero Super moderator Fellow · 3,954 posts #1

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 !!

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... _______…

frostymarvelous Senior · 266 posts #2

Don't get it. If ua is not equal to session saved ua you should login? I'm on mobile so I might be reading this wrong. But how is that supposed to work? When do you store the Md5 session? You didn't show that.

Btw that looks like the code I proposed yesterday. Just saying.

Perfection comes at a cost

I accept liberty!

subzero Super moderator Fellow · 3,954 posts #3

this makes sid go away.

Also making it harder to read from hijackers that know your cookies and id names also stops them by sending your browser as fake sid other then real sid.

its like a clone but your only know its only a trick to others thinking there sid is there info on password and login. but in fact they only going to decode

it like Opera 1059 / windows xp 64 bit

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... _______…

frostymarvelous Senior · 266 posts #4

I'm sorry I still don't get it. But its alright. Hey what happened with your project?

Perfection comes at a cost

I accept liberty!

subzero Super moderator Fellow · 3,954 posts #5

i seem to fit it in quickly so far

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... _______…

frostymarvelous Senior · 266 posts #6

I didn't hear anything.

I mean from you again concerning it.

Perfection comes at a cost

I accept liberty!

subzero Super moderator Fellow · 3,954 posts #8

its like the same with other 5 sites lol

There nothing im hiding here 😉

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... _______…

arnage Lead · 811 posts #9

Does this help somehow? I found it on php.net coments...

<?php
if (isset($_REQUEST['_SESSION'])) die("Get lost Muppet!");
?>
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
frostymarvelous Senior · 266 posts #10

I think it is checking to see if the hacker tried to pass the session var in a post it get var and then quits the function. I'm not too sure though. Cos that should be PHPSESSID instead. Well, as I said, I'm not too sure about the snippet. Pardon me if I'm wrong.

Perfection comes at a cost

I accept liberty!

arnage Lead · 811 posts #11

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 !! }

Not "sid" or "PHPSESSID", thats are the name of _SESSION.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
ori Lead · 512 posts #12

doesnt matter what u call your cookie or session vars can be phpsessid or ses or sid or hgchvbgv it really doesnt matter as long as its callled up properly in the script

subzero Super moderator Fellow · 3,954 posts #13

thats right ori lol

Mine site has cookie_monster_login_(cant say any more here)_And Here lol

Don't matter what you use as long its session being used..

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... _______…

arnage Lead · 811 posts #14

I'm just make a distinction between these two, of course and I said, is irrelevant how it is named... 😉

The question is whether this snippet helps and if placed before or after the session_start() ?

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
frostymarvelous Senior · 266 posts #15

What is it supposed to do? Thing with copying a snippet is, you don't add the preamble. That makes it weird. Post the link to the article so we check it out. And btw, you need session start before you can access session vars.

Perfection comes at a cost

I accept liberty!

arnage Lead · 811 posts #16

What to do? Isn't that a little obviously? Thats the coment from php.net, google it... Btw, thats not what i ask...

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
frostymarvelous Senior · 266 posts #17

Then what did you ask? Function won't work unless session_start() is called because it uses session vars. Can't you see that?

I know what it is meant to do, but I need to read the full thing to know if it is exactly so cos I don't know the logic behind this

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

Cos I would check to see if they match, not if they don't match unless the coder is using different logic. That's what I meant by what it is meant to do. 😛

Added after 9 minutes:

So what's it like.

Oh, the user agent I saved and the current user agent don't match so it is him, let's go ahead and log him in?

Think of the implications if a cookie is hijacked. And oh, btw I really hate what you implied in your reply, and asking me to google a post to help you?

First major security threat, what Prevents hacker from simple editing the cookie Sid value to another value and being logged in as the user with that id value?

You gotta obscure what you are doing a bit more and add some extra security checks.

Perfection comes at a cost

I accept liberty!

arnage Lead · 811 posts #18

Bro... 🙂

  1. Not function wich Subziro did, the snippet that I copy-paste from php.net:
<?php 
if (isset($_REQUEST['_SESSION'])) die("Get lost Muppet!"); 
?>
  1. The question is whether this snippet helps and if, is to be placed before or after the session_start() ?

Not session vars, the snippet. I'm not asking about function or sessions or its vars or what ever. Just 2. thing.


And I hate when someone explains me something I have not asked, ie, when I see that he did not understand the question... I hope you are not angry but really did not know what else to write, not to go into, God forbid, argument. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
frostymarvelous Senior · 266 posts #19

This will work when placed before or after session start cos it does not require a session var.

If you can give me the exact link and maybe post I Will try to refine it for you. I don't know exactly what the coder is trying to do.

Added after 2 minutes:

I know I didn't really understand that's why I asked for the link. I'm mobile so typing long stuff is annoying that's why I don't wanna do something and realise that I wasted my time.

Perfection comes at a cost

I accept liberty!

arnage Lead · 811 posts #20

You are absolutely right if you're by phone, should say right away... 😉

PHP: $_SESSION - Manual

This is that page, its the first coment but no any explanation in it.

Thanks for answer!

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

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