Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

After purchasing with us the download link will be delivered to your forum message box.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Session Hijacking?  (Read 236 times)

mentaljason

  • Basic Member
  • *
  • Reputation Power: 13
  • mentaljason has no influence.
  • Offline Offline
  • Posts: 28
  • MentalJason HURRAH
    • View Profile
    • WWW
Session Hijacking?
« on: September 16, 2010, 10:49:50 AM »
Not sure how it works, so i cant test it, but i found this script:
 
Code: [Select]
<?php

/*
  SecureSession class
  Written by Vagharshak Tozalakyan <vagh@armdex.com>
  Released under GNU Public License
*/

class SecureSession
{
    
// Include browser name in fingerprint?
    
var $check_browser true;

    
// How many numbers from IP use in fingerprint?
    
var $check_ip_blocks 0;

    
// Control word - any word you want.
    
var $secure_word 'SECURESTAFF';

    
// Regenerate session ID to prevent fixation attacks?
    
var $regenerate_id true;

    
// Call this when init session.
    
function Open()
    {
        
$_SESSION['ss_fprint'] = $this->_Fingerprint();
        
$this->_RegenerateId();
    }

    
// Call this to check session.
    
function Check()
    {
        
$this->_RegenerateId();
        return (isset(
$_SESSION['ss_fprint']) && $_SESSION['ss_fprint'] == $this->_Fingerprint());
    }

    
// Internal function. Returns MD5 from fingerprint.
    
function _Fingerprint()
    {
        
$fingerprint $this->secure_word;
        if (
$this->check_browser) {
            
$fingerprint .= $_SERVER['HTTP_USER_AGENT'];
        }
        if (
$this->check_ip_blocks) {
            
$num_blocks abs(intval($this->check_ip_blocks));
            if (
$num_blocks 4) {
                
$num_blocks 4;
            }
            
$blocks explode('.'$_SERVER['REMOTE_ADDR']);
            for (
$i 0$i $num_blocks$i++) {
                
$fingerprint .= $blocks[$i] . '.';
            }
        }
        return 
md5($fingerprint);
    }

    
// Internal function. Regenerates session ID if possible.
    
function _RegenerateId()
    {
        if (
$this->regenerate_id && function_exists('session_regenerate_id')) {
            if (
version_compare(phpversion(), '5.1.0''>=')) {
                
session_regenerate_id(true);
            } else {
                
session_regenerate_id();
            }
        }
    }
}

?>

Good or no good?
Logged
Like Mccodes? Like things to be free? try My mods forum where all of the mods are free!
 


This forum is now closed and has moved to a new location! Click here to find out why.