How many security holes

Learn about Security for code and servers. Learn how to secure your site and your code. Learn about hacking prevention, finding and identifying exploits, and recognising vulnerabilities. Plus, Weekly Security tips and Tutorials.
Forum rules
Post questions related to security, analyse and learn about vulnerabilities and exploits within code to protect yourself against hackers.

How many security holes

Postby topdown » 26 Jul 2009, 23:41

Found an interesting one..
How many security holes do you see in this script (including variations), Count them up :grin:
Spoiler:
Code: Select all
    <?php
    $ip 
= $_SERVER['REMOTE_ADDR'];
    if(!empty($_SESSION['loggedin']) && !empty($_SESSION['username'])) // START THE IF LOGGED IN
    { // START THE IF LOGGED IN
       
       $user_sess 
= $_SESSION['username'];

       $user_4_forum = mysql_query("SELECT * FROM users WHERE username='".$user_sess."'") or die ("Error in query".mysql_error());
          if (mysql_num_rows($user_4_forum) > 0)
             {
                while($row = mysql_fetch_array($user_4_forum))
                   {
                      $steamid = $row["steamid"];
                      $rank = $row["rank"];      
                      $password 
= $row["password"];
                      $username = $row["username"];
                   }
             }
             
       
// START RANK RECOGNIZATION   QUERYS
       if ($rank == 6)
       {
          $query = "(58, 0, 12, '', 0, '".$ip."', 1248375799, '".$username."', '".$username."', '".$password."', 1248375799, 0, 'you@yourdomain.com', 34944741818, '', 0, 1248375799, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 0.00, 0, 'D M d, Y g:i a', 1, 0, 'FF0000', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 895, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'a00683416e0a8d25');";
       }
       if ($rank == 5)
       {
          $query = "(57, 0, 11, '', 0, '".$ip."', 1248375776, '".$username."', '".$username."', '".$password."', 1248375776, 0, 'you@yourdomain.com', 34944741818, '', 0, 1248375776, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 0.00, 0, 'D M d, Y g:i a', 1, 0, '0000FF', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 895, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '6e100d66ba0779ce'),";
       }
       if ($rank == 4)
       {
          $query = "(56, 0, 9, '', 0, '".$ip."', 1248375758, '".$username."', '".$username."', '".$password."', 1248375758, 0, 'you@yourdomain.com', 34944741818, '', 0, 1248375758, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 0.00, 0, 'D M d, Y g:i a', 1, 0, '00CC00', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 895, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'e0e84cf08572428f'),";
       }
       if ($rank == 3)
       {
          $query = "(55, 0, 10, '', 0, '".$ip."', 1248375739, '".$username."', '".$username."', '".$password."', 1248375739, 0, 'you@yourdomain.com', 34944741818, '', 0, 1248375739, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 0.00, 0, 'D M d, Y g:i a', 1, 0, '#60C', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 895, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'bd432b76a414888f'),";
       }
       if ($rank == 2)
       {
          $query = "(54, 0, 8, '', 0, '".$ip."', 1248375720, '".$username."', '".$username."', '".$password."', 1248375720, 0, 'you@yourdomain.com', 34944741818, '', 0, 1248375720, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 0.00, 0, 'D M d, Y g:i a', 1, 0, '#F60', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 895, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'ea4c9f7344cd20fc'),";
       }
       if ($rank == 1)
       {
          $query = "(53, 0, 7, '', 0, '".$ip."', 1248375700, '".$username."', '".$username."', '".$password."', 1248375700, 0, 'you@yourdomain.com', 34944741818, '', 0, 1248375700, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'en', 0.00, 0, 'D M d, Y g:i a', 1, 0, '', 0, 0, 0, 0, -3, 0, 0, 't', 'd', 0, 't', 'a', 0, 1, 0, 1, 1, 1, 1, 895, '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '18418bd053f0a783')";
       }   
       
// END RANK RECOGNIZATION QUERYS
       
       $checkusername 
= mysql_query("SELECT * FROM phpbb_users WHERE username = '".$user_sess."'");
          if(mysql_num_rows($checkusername) == 1)
          {
             echo "You already exist on the forum";
          }
          else
          
{   // START IF USER DOESNT EXIST ON FORUM
             //echo '<a href="'.$_SERVER['PHP_SELF'].'">Click here to activate your account on the forum</a>';
             
             if
(isset($_POST['submit']))
             { // START IF POST FOR FORUM ACTIVATION
                   $query_insert = "INSERT INTO `phpbb_users` (`user_id`, `user_type`, `group_id`, `user_permissions`, `user_perm_from`, `user_ip`, `user_regdate`, `username`, `username_clean`, `user_password`, `user_passchg`, `user_pass_convert`, `user_email`, `user_email_hash`, `user_birthday`, `user_lastvisit`, `user_lastmark`, `user_lastpost_time`, `user_lastpage`, `user_last_confirm_key`, `user_last_search`, `user_warnings`, `user_last_warning`, `user_login_attempts`, `user_inactive_reason`, `user_inactive_time`, `user_posts`, `user_lang`, `user_timezone`, `user_dst`, `user_dateformat`, `user_style`, `user_rank`, `user_colour`, `user_new_privmsg`, `user_unread_privmsg`, `user_last_privmsg`, `user_message_rules`, `user_full_folder`, `user_emailtime`, `user_topic_show_days`, `user_topic_sortby_type`, `user_topic_sortby_dir`, `user_post_show_days`, `user_post_sortby_type`, `user_post_sortby_dir`, `user_notify`, `user_notify_pm`, `user_notify_type`, `user_allow_pm`, `user_allow_viewonline`, `user_allow_viewemail`, `user_allow_massemail`, `user_options`, `user_avatar`, `user_avatar_type`, `user_avatar_width`, `user_avatar_height`, `user_sig`, `user_sig_bbcode_uid`, `user_sig_bbcode_bitfield`, `user_from`, `user_icq`, `user_aim`, `user_yim`, `user_msnm`, `user_jabber`, `user_website`, `user_occ`, `user_interests`, `user_actkey`, `user_newpasswd`, `user_form_salt`) VALUES";
             
                   
                mysql_query
("".$query_insert." ".$query."") or die(mysql_error());
                echo "Account Activated!";
             } // END IF POST FOR FORUM ACTIVATION
             else
             
{ // START IF NO SUBMIT
             ?>
                   <form action="<?php echo $PHP_SELF;?>" method="post" enctype="multipart/form-data" name="activate">
                       <input name="submit" type="submit" value="Click to activate your forum account">
                    </form>
             <?php
             
} // END IF NO SUBMIT
          } // END IF USER DOESNT EXIST ON FORUM
       


    
} // END IF IS LOGGED IN
    else // START IF IS NOT LOGGED IN
    { // START IF IS NOT LOGGED IN
       echo "You have to login to activate an account!";
    } // END IF IS NOT LOGGED IN
    ?>
Image
Valid Webs Web Development My Mods SVN phpBB Development Wiki
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 2608
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 8


Re: How many security holes

Postby Erik Frèrejean » 28 Jul 2009, 08:38

:shock: :shock: Thats horrid :shock: :shock:
Image Proud member of the phpBB support team
Image STG Support team member | Image STG Moderator team member
Image
User avatar
Erik Frèrejean    
phpBB Team Member
phpBB Team Member
 
Posts: 1023
Joined: 03 Dec 2007, 00:49
Location: USERS_TABLE
Favorite Team: phpBB teams
Gender: Male
phpBB Knowledge: 9

Re: How many security holes

Postby Obsidian » 28 Jul 2009, 10:21

That is BEGGING to be hacked. :lol:
- I will not die, I'll wait here for you... -
User avatar
Obsidian    
Supporter
Supporter
 
Posts: 2049
Joined: 04 Mar 2008, 23:35
Gender: Male
phpBB Knowledge: 8

Re: How many security holes

Postby chaoskreator » 29 Jul 2009, 18:04

Wow. Just... wow. :shock:
User avatar
chaoskreator    
Commander
Commander
 
Posts: 708
Joined: 02 Feb 2009, 22:05
Location: NC
Gender: Male
phpBB Knowledge: 7

Re: How many security holes

Postby WyriHaximus » 09 Aug 2009, 09:10

Obsidian wrote:That is BEGGING to be hacked. :lol:

Besides that the only serious leak I could find was $PHP_SELF and maybe some minor issues if the data in the $_SESSION varriable isn't properly checked. Aside from that the code is just horrible :banghead:
Image
User avatar
WyriHaximus    
Cadet I
Cadet I
 
Posts: 17
Joined: 28 Jul 2009, 04:46
Gender: Male
phpBB Knowledge: 9

Re: How many security holes

Postby Obsidian » 09 Aug 2009, 18:35

What about if it's on PHP4? register_globals anyone?
- I will not die, I'll wait here for you... -
User avatar
Obsidian    
Supporter
Supporter
 
Posts: 2049
Joined: 04 Mar 2008, 23:35
Gender: Male
phpBB Knowledge: 8

Re: How many security holes

Postby Jaymie1989 » 12 Aug 2009, 19:41

:blink: :blush: I dont see anything wrong with it. :cray:
My MOD Queue - My Tutorials
phpBB Wiki Im the Highest poster on the Support group, That is not apart of the STG Team, Source Here
Jaymie1989    
Supporter
Supporter
 
Posts: 1289
Joined: 30 Sep 2007, 15:51
Location: Some where in phpbb_users table
Favorite Team: Liverpool FC
Gender: Male
phpBB Knowledge: 5

Re: How many security holes

Postby topdown » 12 Aug 2009, 20:29

Jaymie1989 wrote::blink: :blush: I dont see anything wrong with it. :cray:


Lets just say, that if there was a script out there to show 101 ways a script could be hacked, this would be close to being that script.... ;)
Image
Valid Webs Web Development My Mods SVN phpBB Development Wiki
Do not PM me for Support unless I give permission in a post......PM's only help one, posts help everyone !
User avatar
topdown    
STG Styles Leader
STG Styles Leader
 
Posts: 2608
Joined: 01 Oct 2007, 22:56
Location: Handyman's harddrive
Favorite Team: STG Teams
Gender: Male
phpBB Knowledge: 8

Re: How many security holes

Postby Jaymie1989 » 12 Aug 2009, 20:30

:shock: I wont be using that lol.

I need to learn php
My MOD Queue - My Tutorials
phpBB Wiki Im the Highest poster on the Support group, That is not apart of the STG Team, Source Here
Jaymie1989    
Supporter
Supporter
 
Posts: 1289
Joined: 30 Sep 2007, 15:51
Location: Some where in phpbb_users table
Favorite Team: Liverpool FC
Gender: Male
phpBB Knowledge: 5

Re: How many security holes

Postby WyriHaximus » 13 Aug 2009, 06:41

topdown wrote:
Jaymie1989 wrote::blink: :blush: I dont see anything wrong with it. :cray:


Lets just say, that if there was a script out there to show 101 ways a script could be hacked, this would be close to being that script.... ;)

Yup, the way it's written their could slip in a bug very easy...
Image
User avatar
WyriHaximus    
Cadet I
Cadet I
 
Posts: 17
Joined: 28 Jul 2009, 04:46
Gender: Male
phpBB Knowledge: 9

Next

Return to Security Class

Who is online

Users browsing this forum: ccBot [Bot] and 3 guests