Hiding Session Id

Started on the old forum in January 2009 · view the original in the archive · old links redirect here

134 replies · 11,752 views · started 17 years ago · 1 min read

TL;DR · summary of 134 replies
  • -mod_rewrite would not be effective for hiding session IDs as they still need to pass through URLs.
  • -Using dynamic variables like IP or browser information could help prevent session hijacking, but it may not be foolproof.
  • -Adding username and password to the authentication process can strengthen session security by defining both the user and their credentials.

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

38 participants
djlee Developer · 224 posts #21

ok you have username, and password , they are part of the authentication process, the session id defines those two vars, if they dont then ur using a really shit session system anyway (this is why i create my own session systems), as far as shared mobile ip's thats not a worry, ive never seen a successful session hijack using a mobile as you need some sort of webserver to route data through for a successful xss session hijack. so even without username and id in the session you will most likely be using a computer to hijack a session as why wud u use a mobile if you've got a computer . the only benefit of using a mobile is that there is a chance that the hijacked session has a user attached to it with the same ip. the chances in that occurence are slim and just to hijack a session of sum wapsite that are are common as muck i doubt anyone with the knowledge to do this even a script kiddie would give up testing stolen sessions on there own mobile when the chances in the ip being the same are slim

yes its not foolproof. but the easiest thing would just be to protect your sites from session id's being stolen in the first place, rather than trying to protect a session after its been stolen. dont over complicate authentication, this wapdesire script is already slow and buggy enough as it is. adding more processes to authentication that are not needed if you just used a few brain cells to actively protect the site in the first place is just bad design.

shad0w Developer · 119 posts #23

The easy way is to Remove sid... use user and password on each page (&user=$user&pass=$pass)...

whatmp3.name - search mp3 on mobile

shad0w Developer · 119 posts #24

The most sid are found through download... To prevent sending sid when downloading make a new file : dlfile.php where the sid is not get and from there to make a link : download file... that way the can not be send... The same thing in gallery , when downloading a photo ...

whatmp3.name - search mp3 on mobile

something else Fellow · 2,296 posts #25

QUOTE (shad0w @ Feb 7 2009, 11:17 PM) <{POST_SNAPBACK}>

The easy way is to Remove sid... use user and password on each page (&user=$user&pass=$pass)...

Thats even worse as you are now giving away username and password 😛

wolf77ar Developer · 51 posts #26

No no, no user&pass visible 😛 One simple solution to hide $sid on lavalair is:

  1. in login.php put in line 2 after:
<?php ``` session_start(); $_SESSION['sid']=$sid; ``` 2. remove sid=$sid from loginpage, the link to enter in site will be: echo"<a href=\"index.php?action=main\">[ ENTER ]</a>"; 3. In all pages: Start with index.php remove: ``` $sid = $_GET["sid"]; ``` remove sid=$sid from all links and put this in line 2: after <?php ``` session_start(); $_SESSION['sid']=$sid; ``` 4. to make secure put this ``` if (!empty($sid)) ``` from where you want to make sessions acces in your site this is for control if real start you session and to not be atack from distance ex: before if($action=="main") 5. to destroy session put this on exit: ```    unset($_SESSION['sid']);    $_SESSION = array();   // reset session array    session_destroy();     // destroy session. ``` Optionaly, you can create one cookies in login.php ``` setcookie("cooksid", $_SESSION['sid'], time()+60*60*24*100, "/"); ``` to unset cookies: ``` setcookie("cooksid", "", time()-60*60*24*100, "/"); ``` But this will be dysplay one error because the headers is already sent, and for not show put this before session_start in index.php ``` ini_set('error_reporting', 'E_ALL & ~E_NOTICE & ~E_WARNING'); ``` this will be expire after 100 days 😀 In my site work verry well, but my wap provider Orange, change IP`s after 5-10 mins, in this case session change and have to login again You have any solutions for this? :sad:

echo "<a href="http://wapcomunity.ro">[-Enter Here-]</a>";

kiss Senior · 294 posts #27

wolf77ar did you know that not all mobile browsers support cookies? 😉

www.inbuzunar.mobi -Your mobile portal pocket

valentin2br Junior · 47 posts #28
$ipout= getip();
if(detect($ipout,$ubr,$sid))
    {
mysql_query("DELETE FROM ibwf_ses WHERE uid='".getuid_sid($sid)."'");
mysql_query("DELETE FROM ibwf_online WHERE userid='".getuid_sid($sid)."'");
mysql_query("DELETE FROM action WHERE cui=''".getuid_sid($sid)."'");
echo "<img src=\"images/notok.gif\" alt=\"x\"/>    You can log on to other users!
";
$name =  mamebyip($ipout);
 $text = "Ip: $ipout tried to enter the session's $nick![br/]User suspicious: $name($ubr)";
 $sql = mysql_query("SELECT id, name FROM ibwf_users WHERE perm='4'");
while ($id = @mysql_fetch_array($sql)){
   mysql_query("INSERT INTO ibwf_private SET text='[b]suspicios alet[/b][br/]".$text."', byuid='4', touid = '".$id[0]."', timesent='".time()."'");
   }
   echo "</p>";
   echo "</card>";
   echo "</wml>";
   exit();
}
  }
else { 
mysql_query("UPDATE ibwf_users SET ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");
}

insert it and nobody can get on your session

wolf77ar Developer · 51 posts #29

Hmmm.... Yes is very good your code, but you know well that in our country the most used provider, wap Orange, changing IPs from 5-10 min. In this case the user may be our victim :sad:

You know, any time to acces main page mysql UPDATE ibwf_users and SET $uip Is work good only if remove UPDATE from index.php and SET $uip in login.php to keep the IP on the same user session.

echo "<a href="http://wapcomunity.ro">[-Enter Here-]</a>";

subzero Super moderator Fellow · 3,954 posts #30

Using ip is a nightmare...

What happens some one comes in your server same ip as yours ??

so he can login with your name lmao

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

djlee Developer · 224 posts #31

true but they'd still need a way to authenticate, just having the same ip wouldnt give someone access to a running php session. Personally since i dont code for wap i use a complex cookie system whereby using a subdomain of the site i can create virtually unsteabale cookies as the cookies are locked to the subdomain so only the system can access it, any xss code would be injected on the main domain and the browser would deny access to the cookie... simple idea, slightly complex code and probably the best unique way ive come up with for auth so far

locking to ip's is the most basic of authentication procedures, even top comercial sites from MS to google still use it as part of a larger security system so i doubt its the worst idea ever... problem is your looking for a way to suit everyone, that opens up a whole can of security issues, at what point do you draw the line and start to forfeit the odd user in order to protect the rest.

But there is a way around ip checking, allow the user to unbind there ip, if a user is in the situation where there ip changes frequently every few mins or so they can go to the profile and turn off ip checking (or make a request to staff if you make it a staff function), as long as you code in a fail safe so staff accts cant disable the ip protect you'll be fine since what use is another user account to a hacker?

Guest #32

What are the ways of hacking session id in lavalair anyway?

If its by user clicking links why dont you set up a redirection page. that strips the SID before getting sent to the other site?

valentin2br Junior · 47 posts #33

QUOTE (youngson @ Feb 16 2009, 12:14 PM) <{POST_SNAPBACK}>

What are the ways of hacking session id in lavalair anyway?

If its by user clicking links why dont you set up a redirection page. that strips the SID before getting sent to the other site?

so you can look into the session http://extremetracking.com/open;ref1?login=sharemob if you're chatting with your access and a link that will take you there and show that follows you into the session

jsyguy23 Developer · 134 posts #34

ive hidden the session id in lava and it not with mod rewright

bOrN2pwn Developer · 230 posts #35

Make a credential-checking file: call it gate.cfm. To avoid confusion in case you've just browsed another ColdFusion site, delete cfid and cftoken cookies. In case you've been inside this application earlier, delete the "pass" cookie (you'll set later) as well. Enable session management with cookies turned off and permit idle time to be three minutes.

<!--- Remove old cookies and set session parameters --->
<cfcookie name="cfid" value=0 expires=-1>
<cfcookie name="cftoken" value=0 expires=-1>
<cfcookie name="myid" value=0 expires=-1>
<cfcookie name="mytoken" value=0 expires=-1>
<cfapplication Name="HideSession"
clientmanagement="no"
sessionmanagement="yes"
setclientcookies="no"
sessiontimeout=#createTimeSpan(0,0,3,0)#>

For this demonstration, replace database logic by simply pretending that the "Frank" login was validated and that the database says Frank has AccessLevel 5. Then concatenate the Application name and session ID to form a lock name that should only block another window of this same browser, copy cftoken to a variable that doesn't have to be locked, and store the UserId and AccessLevel in a memory structure for this session.

<!--- Pretend that "Frank" login was validated
and that the "database" said Frank has AccessLevel 5 --->
<cfset form.UserId="Frank">
<cfset request.AccessLevel=5>

<!--- Copy session identifiers and store data in session memory --->
<cfset Lock="HideSession"&#session.cfid#>
<cflock name="#Lock#" timeout=30>
<cfset request.cftoken=session.cftoken>
<cfset session.User=form.UserId>
<cfset session.Access=request.AccessLevel>
</cflock>

Use list functions to build a list of elements separated by spaces, urlEncode it to make its special characters safe, and encrypt the result as you store it in a cookie named "Pass". It's a bad idea to permit spaces in UserIDs anyway; this avoids problems in case someone wants to have a comma in a UserId [groan]. The random number just adds aggravation. It doesn't do much in this demonstration, but if you rearranged the pieces before (or after) encryption, it might make the string appear even more different from attempt to attempt.

<!--- Store the UserID and session keys in an encrypted cookie --->
<cfset Temp="">
<cfset Temp=listAppend(Temp,randRange(0,9999)," ")>
<cfset Temp=listAppend(Temp,session.cfid," ")>
<cfset Temp=listAppend(Temp,request.cftoken," ")>
<cfset Temp=listAppend(Temp,form.UserId," ")>
<cfset cookie.Pass=urlEncodedFormat(encrypt(Temp,"welcome"))>

Because this is a demonstration, you need a method to help you realize what the session Id was on the first page so you can see if the session retained its integrity between pages. Build a form to help with this task.

<form name="Gate" action="menu.cfm" method="post">
Notice the session Id: <cfoutput>#session.cfid#</cfoutput><br>
<input type="hidden" name="Reference" value=<cfoutput>"#session.cfid#"</cfoutput>>
<input type="submit" name="Go" value="Done reading">
</form>

Build a Menu

This "menu", menu.cfm, merely contains the code needed to show that session memory can be accessed based on the contents of an encrypted cookie. (In real life, the available menu items would depend on AccessLevel.) Read the Pass, display it for educational purposes, and interpret it. When you interpret it, set url variables CFID and CFTOKEN based on the contents of Pass so ColdFusion will "resume" this session when you turn session management on.

<!--- Read the Pass --->
<cfparam name="cookie.Pass" default="">
<cfif not len(cookie.Pass)>
The credential is missing
</cfif>
<pre>
urlEncoded Pass:<cfoutput>#cookie.Pass#</cfoutput><br>
urlDecoded Pass:<cfoutput>#urlDecode(cookie.Pass)#</cfoutput>
</pre>
<p>

<!--- Interpret the Pass --->
<cfset Temp=decrypt(urlDecode(cookie.Pass),"welcome")>
<cfoutput>Random number is #listGetAt(Temp,1," ")#</cfoutput>
<p>
<cfset url.cfid=listGetAt(Temp,2," ")>
<cfset url.cftoken=listGetAt(Temp,3," ")>
<cfset url.UserId=listGetAt(Temp,4," ")>

Set session parameters as before, and read session memory. If for some reason the session does not contain a UserId and SessionLevel - perhaps the old session didn't restart after all - use cf try-catch combinations to avoid exposing the user to raw errors. Finally, display the desired and actual data.

<!--- Set session parameters --->
<cfapplication Name="HideSession"
clientmanagement="no"
sessionmanagement="yes"
setclientcookies="no"
sessiontimeout=#createTimeSpan(0,0,3,0)#>

<!--- Access session memory to prove the session was found --->
<cfset Lock="HideSession"&#session.cfid#>
<cflock name=Lock timeout=30>
<cftry>
<cfset request.UserId=session.User>
<cfcatch>
UserId not found<br>
<cfset request.UserId="">
</cfcatch>
</cftry>
<cftry>
<cfset request.AccessLevel=session.Access>
<cfcatch>
SessionLevel not found<br>
<cfset request.AccessLevel=0>
</cfcatch>
</cftry>
</cflock>

UserId desired: Frank<br>
UserId seen: <cfoutput>#request.UserId#</cfoutput><br>
Access Level desired: 5 <br>
AccessLevel seen: <cfoutput>#request.AccessLevel#</cfoutput><br>
Session desired: <cfoutput>#form.reference#</cfoutput><br>
Session seen: <cfoutput>#session.cfid#</cfoutput>

🙄

BakGat

class Counter {
public:
  void Count();
  int  ReadDisplay();
private:
  int  CurrentCount;
};

External image (may be gone) External image (may be gone) External image (may be gone)

Back up my hard drive? How do I put it in reverse? http://www.hackthissite.org Profile…

ori Lead · 512 posts #36

modrewrite can mide the queries but to do session on each page u can do same result in cookies and its so easy

session_name("SESSIONID");
session_start();
$act = get_var("act");
if ($act == "index") unset($_SESSION['uid']);
if (!isset($_SESSION['username'])) $_SESSION['username'] = "Guest";
if (!isset($_SESSION['ses'])) $_SESSION['ses'] = "Guest_".substr(md5(time()),0,12);

to login it changes guest to user

$GetSession = fetch_array("sesid",sessions,"LOWER(username) = LOWER('$nick')");
if(empty($GetSession))$sesid = NewSessionID($nick,$_SERVER['HTTP_USER_AGENT'],ip(),subno(ip()));
else $sesid=$GetSession;
$_SESSION['username'] = fetch_array("username",members,"LOWER(username) = LOWER('$nick')");
$_SESSION['ses'] = $sesid;
$_SESSION['uid'] = fetch_array(id,members,"LOWER(username) = LOWER('$_SESSION[username]')");

and to delete i use

delete(sessions,"LOWER(username) = LOWER('$_SESSION[username]')");
session_unset();
$_SESSION['username'] = "Guest";
$_SESSION['ses'] = NewSessionID("Guest",$_SERVER['HTTP_USER_AGENT'],ip(),subno(ip()));
synergyx2009 Developer · 86 posts #38

I dont even see how it is possible that some1 can hack ur session id. they would physically have to see ur url to steal the sid.

|Dont forget to say thanx|

mcKeny Developer · 130 posts #39

synergyx2009 wrote: I dont even see how it is possible that some1 can hack ur session id. they would physically have to see ur url to steal the sid.

REFERER -duh- or i can send a variable via Url and it excuted 🙂

R.M.C

PHP Adovocate B)

synergyx2009 Developer · 86 posts #40

yes i know that, but there would have to be a link to an external page in order for that to happen.

|Dont forget to say thanx|

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