Ledensysteem fout je kan iets bekijken waar je geen rechten toe hebt

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Remco van Lent

Remco van Lent

17/12/2006 13:49:00
Quote Anchor link
Ik heb het ledensysteem phpmylogon. als ik nou niet ingelogd ben als admin. en ik ga naar admin.php dan kan ik gewoon users verwijderen.
terwijl in admin.php safe_admin.php include staat. iemand een idee. ik heb dit ook met als alleen geregistreerde en admins het mogen bekijken. dat ook al ben je niet ingelogd het toch kan zien.

safe_admin.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
###################################
##   PHPMYLOGON: A LOGIN SYSTEM  ##
##    (c) 2006 Jorik Berkepas    ##
##   Under the GNU GPL license   ##
##     [email protected]      ##
###################################

// Inlucde this file (safe_admin.php) to let a page only access by admins


include_once("config.php");
include_once("lang/lang_".$lang.".php");
include_once("connect.php");

if(isset($_SESSION['user_id'])) {
 // Login ok, set lastactive
 $sql = "UPDATE `".$db_tbl."` SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'";
 mysql_query($sql);
 if($_SESSION['user_status'] == 1) {
  // State ok, ready
 }else{
  echo $safeadmin_rights;
  exit();
 }
}
else{
 if(isset($_COOKIE['cookie_id'])) {
  $sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
  $query = mysql_query($sql);
  $row = mysql_fetch_object($query);
  $dbpass = htmlspecialchars($row->cookie_pass);
  $dbstatus = htmlspecialchars($row->state);
  if($dbpass == $_COOKIE['cookie_pass']) {
   $_SESSION['user_id'] = $_COOKIE['cookie_id'];
   $_SESSION['user_status'] = $dbstatus;
  }
else{
   setcookie("cookie_id", "", time() - 3600);
   setcookie("cookie_pass", "", time() - 3600);
   header("Location: login.php");
  }
 }
else{
  header("Location: login.php");
 }
}

?>


Safe.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
###################################
##   PHPMYLOGON: A LOGIN SYSTEM  ##
##    (c) 2006 Jorik Berkepas    ##
##   Under the GNU GPL license   ##
##     [email protected]      ##
###################################

// Inlucde this file (safe.php) to let a page only access by members/admins


include_once("config.php");
include_once("lang/lang_".$lang.".php");
include_once("connect.php");

if(isset($_SESSION['user_id'])) {
 // Login ok, update last active
 $sql = "UPDATE `".$db_tbl."` SET lastactive=NOW() WHERE id='".$_SESSION['user_id']."'";
 mysql_query($sql);
}
else{
 if(isset($_COOKIE['cookie_id'])) {
  $sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
  $query = mysql_query($sql);
  $row = mysql_fetch_object($query);
  $dbpass = htmlspecialchars($row->cookie_pass);
  $dbstatus = htmlspecialchars($row->state);
  if($dbpass == $_COOKIE['cookie_pass']) {
   $_SESSION['user_id'] = $_COOKIE['cookie_id'];
   $_SESSION['user_status'] = $dbstatus;    
  }
else{
   setcookie("cookie_id", "", time() - 3600);
   setcookie("cookie_pass", "", time() - 3600);
   header("Location: login.php");
  }
 }
else{
  header("Location: login.php");
 }
}

?>
 
PHP hulp

PHP hulp

29/04/2024 08:05:19
 
Stefan van Iwaarden

Stefan van Iwaarden

17/12/2006 14:11:00
Quote Anchor link
in dit stukje code
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
if(isset($_COOKIE['cookie_id'])) {
  $sql = "SELECT cookie_pass,state FROM `".$db_tbl."` WHERE id='".$_COOKIE['cookie_id']."'";
  $query = mysql_query($sql);
  $row = mysql_fetch_object($query);
  $dbpass = htmlspecialchars($row->cookie_pass);
  $dbstatus = htmlspecialchars($row->state);
  if($dbpass == $_COOKIE['cookie_pass']) {
   $_SESSION['user_id'] = $_COOKIE['cookie_id'];
   $_SESSION['user_status'] = $dbstatus;
  }
else{
   setcookie("cookie_id", "", time() - 3600);
   setcookie("cookie_pass", "", time() - 3600);
   header("Location: login.php");
  }
 }
else{
  header("Location: login.php");
 }

?>

moet je natuurlijk wel controleren of iemand ook daadwerkelijk admin is. Want dat doe je nog niet.
Daarnaast wil ik je heel erg aanraden, die cookies niet te gebruiken en zeker geen wachtwoorden en id's erin te zetten, je controleert ook niet of er wel geldige informatie hierin staat, dus is dit zeer sql-injection gevoelig.

Ook heb je geen or die (mysql_error()); bij de uitvoering van je query staan. En waar wijs jij de variabele $db_tbl een waarde toe?
 
Remco van Lent

Remco van Lent

17/12/2006 14:13:00
Quote Anchor link
ik heb niet zo veel verstand van php dus ik heb geen idee wat je bedoelt
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.