[Release] Ingamechat Php Script

01/14/2012 18:25 Mythen#16
XSS soweit nicht möglich gemacht u. den Query angepasst:
Und oben den Unnötigen Inhalt enfernt....
PHP Code:
<?php 
error_reporting
(1);
    
define("MSQL_HOST", "ip"); 
    
define("MSQL_USER", "user"); 
    
define("MSQL_PASS", "pass"); 
     
    
$connect = @mysql_connect(MSQL_HOST, MSQL_USER, MSQL_PASS);     
    if(
$connect){ 
        
$limit = 15; 
        
$sqlCmd = "SELECT `3` as 'empire',`4` as 'shout',`1` as 'msgTime' FROM log.shout_log ORDER BY msgTime DESC LIMIT ".$limit; 
        
$sqlQry = mysql_query($sqlCmd); 
        echo 
'<table><tr><th>Date</th><th>Post</th></tr>'; 
        while(
$row = mysql_fetch_object($sqlQry)){ 
            echo 
' 
                <tr> 
                    <td> 
                        '
.$row->msgTime.' 
                    </td> 
                    <td> 
            '
; 
                if(
$row->empire == 1){ 
                    echo 
'<span style="color:red;">'.htmlspecialchars($row->shout).'</span>'; 
                } elseif(
$row->empire == 2){ 
                    echo 
'<span style="color:yellow;">'.htmlspecialchars($row->shout).'</span>'; 
                } elseif(
$row->empire == 3){ 
                    echo 
'<span style="color:blue;">'.htmlspecialchars($row->shout).'</span>'; 
                } 
            echo 
' 
                    </td> 
                </tr> 
            '
; 
        } 
        echo 
'</table>'; 
    } else { 
        echo 
"Error connecting to server"; 
    } 
?>
01/14/2012 18:29 .2good4you111#17
Quote:
Originally Posted by Padrio View Post
3. Query ist falsch.
Also bei jedem so :)

Zeile 24 mit dem ersetzen:
PHP Code:
        $sqlCmd = "SELECT `3` as 'empire',`4` as 'shout',`1` as 'msgTime' FROM log.shout_log ORDER BY msgTime DESC LIMIT ".$limit; 

Danke @ Mythen

Vorsicht XSS Lücke!
Nicht nur XSS, du könntest auch eigenen PHP Code ausführen.


@TE am besten du baust noch preg_match ein...
01/14/2012 18:31 Mythen#18
Quote:
Originally Posted by .2good4you111 View Post
Nicht nur XSS, du könntest auch eigenen PHP Code ausführen.


@TE am besten du baust noch preg_match ein...
htmlspecialchars ist eine Wesentlich Bessere Funktion als preg_match........
01/14/2012 19:21 lautlosertot#19
@SoNiice' man darf nur andere forennamen posten ;)
01/14/2012 19:42 ixel4#20
Danke euch beiden hat super geklapt bekommt ihr beide thx von mir
@Jak14*-Mythen-*
@Padrio
01/15/2012 14:09 masdenqqq#21
Quote:
Originally Posted by Jak14*-Mythen-* View Post
XSS soweit nicht möglich gemacht u. den Query angepasst:
Und oben den Unnötigen Inhalt enfernt....
PHP Code:
<?php 
error_reporting
(1);
    
define("MSQL_HOST", "ip"); 
    
define("MSQL_USER", "user"); 
    
define("MSQL_PASS", "pass"); 
     
    
$connect = @mysql_connect(MSQL_HOST, MSQL_USER, MSQL_PASS);     
    if(
$connect){ 
        
$limit = 15; 
        
$sqlCmd = "SELECT `3` as 'empire',`4` as 'shout',`1` as 'msgTime' FROM log.shout_log ORDER BY msgTime DESC LIMIT ".$limit; 
        
$sqlQry = mysql_query($sqlCmd); 
        echo 
'<table><tr><th>Date</th><th>Post</th></tr>'; 
        while(
$row = mysql_fetch_object($sqlQry)){ 
            echo 
' 
                <tr> 
                    <td> 
                        '
.$row->msgTime.' 
                    </td> 
                    <td> 
            '
; 
                if(
$row->empire == 1){ 
                    echo 
'<span style="color:red;">'.htmlspecialchars($row->shout).'</span>'; 
                } elseif(
$row->empire == 2){ 
                    echo 
'<span style="color:yellow;">'.htmlspecialchars($row->shout).'</span>'; 
                } elseif(
$row->empire == 3){ 
                    echo 
'<span style="color:blue;">'.htmlspecialchars($row->shout).'</span>'; 
                } 
            echo 
' 
                    </td> 
                </tr> 
            '
; 
        } 
        echo 
'</table>'; 
    } else { 
        echo 
"Error connecting to server"; 
    } 
?>

thx corrected issue