Results 1 to 7 of 7

Thread: Security issue for Socialengine and img tag

  1. #1
    Administrator GumSlone's Avatar
    Join Date
    Mar 2005
    Location
    Mars, GumCity
    Posts
    1,495
    Thanks
    125
    Thanked 573 Times in 201 Posts
    Blog Entries
    2
    Rep Power
    10

    Default Security issue for Socialengine and img tag

    Please disable the image tag (img) for comments in your admin cp, cause adding comment with an image like this:
    PHP Code:
    <img src="./user_logout.php"/> 
    will automatically logout all users who access the comment page.
    Advertise your mobile site for FREE with [Only registered and activated users can see links. Click Here To Register...]

    [Only registered and activated users can see links. Click Here To Register...]


  2. #2
    Super Moderator subzero's Avatar
    Join Date
    Mar 2006
    Location
    Your Screen.
    Posts
    3,971
    Thanks
    442
    Thanked 379 Times in 180 Posts
    Blog Entries
    7
    Rep Power
    0

    Default

    awsome now i can use this idea lmao
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    Visit: [Only registered and activated users can see links. Click Here To Register...]
    _______
    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...
    _______
    Info & Tips
    php.net
    w3schools.com

  3. #3
    Senior Member CreativityKills's Avatar
    Join Date
    May 2009
    Location
    Lagos
    Posts
    844
    Thanks
    0
    Thanked 106 Times in 62 Posts
    Rep Power
    4

    Default

    Read my CSRF thread. I cud actually do more.

  4. #4
    Moderator Anshul's Avatar
    Join Date
    Jun 2007
    Location
    India
    Posts
    296
    Thanks
    5
    Thanked 19 Times in 15 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by subzero [Only registered and activated users can see links. Click Here To Register...]
    awsome now i can use this idea lmao
    lmao

  5. #5
    Administrator GumSlone's Avatar
    Join Date
    Mar 2005
    Location
    Mars, GumCity
    Posts
    1,495
    Thanks
    125
    Thanked 573 Times in 201 Posts
    Blog Entries
    2
    Rep Power
    10

    Default

    ok, here is a solution, using regex failed for me, so i have added bbcodes.

    into include/class_comment.php
    before:
    PHP Code:
    }

    ?> 
    add this:
    PHP Code:
    function bbcode_format ($str) {  
        
    #$str = htmlentities($str);  
      
        
    $simple_search = array(  
                    
    //added line break  
                    
    '/\[br\]/is',  
                    
    '/\[b\](.*?)\[\/b\]/is',  
                    
    '/\[i\](.*?)\[\/i\]/is',  
                    
    '/\[u\](.*?)\[\/u\]/is',  
                    
    #'/\[url\=(.*?)\](.*?)\[\/url\]/is',  
                    
    '/\[url\](.*?)\[\/url\]/is',  
                    
    '/\[align\=(left|center|right)\](.*?)\[\/align\]/is',  
                    
    '/\[img\](.*?)\[\/img\]/is',  
                    
    '/\[mail\=(.*?)\](.*?)\[\/mail\]/is',  
                    
    '/\[mail\](.*?)\[\/mail\]/is',  
                    
    '/\[font\=(.*?)\](.*?)\[\/font\]/is',  
                    
    '/\[size\=(.*?)\](.*?)\[\/size\]/is',  
                    
    '/\[color\=(.*?)\](.*?)\[\/color\]/is',  
                      
    //added textarea for code presentation  
                   
    '/\[codearea\](.*?)\[\/codearea\]/is',  
                     
    //added pre class for code presentation  
                  
    '/\[code\](.*?)\[\/code\]/is',  
                    
    //added paragraph  
                  
    '/\[p\](.*?)\[\/p\]/is',  
                    );  
      
        
    $simple_replace = array(  
                    
    //added line break  
                   
    '<br />',  
                    
    '<strong>$1</strong>',  
                    
    '<em>$1</em>',  
                    
    '<u>$1</u>',  
                    
    // added nofollow to prevent spam  
                    #'<a href="$1" rel="nofollow" title="$2 - $1">$2</a>',  
                    
    '<a href="$1" rel="nofollow" title="$1">$1</a>',  
                    
    '<div style="text-align: $1;">$2</div>',  
                    
    //added alt attribute for validation  
                    
    '<img src="image_check.php?src=$1" alt="" />',  
                    
    '<a href="mailto:$1">$2</a>',  
                    
    '<a href="mailto:$1">$1</a>',  
                    
    '<span style="font-family: $1;">$2</span>',  
                    
    '<span style="font-size: $1;">$2</span>',  
                    
    '<span style="color: $1;">$2</span>',  
                    
    //added textarea for code presentation  
                    
    '<textarea class="code_container" rows="30" cols="70">$1</textarea>',  
                    
    //added pre class for code presentation  
                    
    '<pre class="code">$1</pre>',  
                    
    //added paragraph  
                    
    '<p>$1</p>',  
                    );  
      
        
    // Do simple BBCode's  
        
    $str preg_replace ($simple_search$simple_replace$str);  
      
        
    // Do <blockquote> BBCode  
        
    $str $this->bbcode_quote ($str);  
      
        return 
    $str;  
    }  
      
      
      
    function 
    bbcode_quote ($str) {  
        
    //added div and class for quotes  
        
    $open '<blockquote><div class="quote">';  
        
    $close '</div></blockquote>';  
      
        
    // How often is the open tag?  
        
    preg_match_all ('/\[quote\]/i'$str$matches);  
        
    $opentags count($matches['0']);  
      
        
    // How often is the close tag?  
        
    preg_match_all ('/\[\/quote\]/i'$str$matches);  
        
    $closetags count($matches['0']);  
      
        
    // Check how many tags have been unclosed  
        // And add the unclosing tag at the end of the message  
        
    $unclosed $opentags $closetags;  
        for (
    $i 0$i $unclosed$i++) {  
            
    $str .= '</div></blockquote>';  
        }  
      
        
    // Do replacement  
        
    $str str_replace ('[' 'quote]'$open$str);  
        
    $str str_replace ('[/' 'quote]'$close$str);  
      
        return 
    $str;  


    now find function comment_list($start, $limit)

    and find inside it this line:
    PHP Code:
    'comment_body' => $comment_info[$this->comment_type.'comment_body'], 
    replace the line width:
    PHP Code:
    'comment_body' => $this->bbcode_format($comment_info[$this->comment_type.'comment_body']), 
    next step create in the main directory of your site a file image_check.php
    and paste into the file this code:
    PHP Code:
    <?

    $image_info 
    getimagesize($_GET['src']);
    if(
    $image_info['mime'] == 'image/gif'||$image_info['mime'] == 'image/jpeg'||$image_info['mime']=='image/png')
    {
      
    header ('HTTP/1.1 301 Moved Permanently');
      
    header ('Location: '.$_GET['src']);
    }
    else 
    {
      
    header ('HTTP/1.1 301 Moved Permanently');
      
    header ('Location: ./wattermark.png');
    }
    ?>
    last step:
    create a png image with your site logo, rename it to wattermark.png and upload it into the main directory of your SE site.

    Done, now you can use image bbcodes without problems
    Advertise your mobile site for FREE with [Only registered and activated users can see links. Click Here To Register...]

    [Only registered and activated users can see links. Click Here To Register...]


  6. #6
    Junior Member
    Join Date
    May 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    thanks man that looked good .
    i m going to try and let u know if any more problems are there
    thanks

  7. #7
    Administrator GumSlone's Avatar
    Join Date
    Mar 2005
    Location
    Mars, GumCity
    Posts
    1,495
    Thanks
    125
    Thanked 573 Times in 201 Posts
    Blog Entries
    2
    Rep Power
    10

    Default

    Quote Originally Posted by man101 [Only registered and activated users can see links. Click Here To Register...]
    thanks man that looked good .
    i m going to try and let u know if any more problems are there
    thanks
    it has been fixed in the latest versions of SE
    Advertise your mobile site for FREE with [Only registered and activated users can see links. Click Here To Register...]

    [Only registered and activated users can see links. Click Here To Register...]


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19