


PPC has solved the Discuz!7.1 and 7.2 remote execution vulnerability_PHP tutorial
On the afternoon of January 6th, online release based on Discuz! 7.1&7.2 vulnerabilities and related attack methods. In response to this, PHPChina urgently contacted the DZ R&D department and made relevant patches for the PHPChina official forum program in the shortest possible time to ensure the normal use and safe operation of members in the PHPChina forum. Thank you for your concern and support for PHPChina. We will always adhere to the user-oriented principle and provide you with a safer and more convenient learning and communication environment. The following is the relevant introduction:
First of all, the vulnerability was transmitted from the t00ls core group. xhming read it first, and then I read it later. What was read was code execution. At 11 on the night of January 5 At around 1 o'clock, at the request of the core group of hackers, xhming gave me a POC and I gave me an exp. They found the same problem. As of around 2 o'clock in the night, I was offline. Only a few people in the t00ls core group knew the exp I gave, but I never expected that after half a day, the exp would be everywhere, and it was indeed from the version I had yesterday.
It is not difficult to imagine the speed at which exp spreads. A and B have a good relationship, and A sends it to B; B and C are good friends, and B sends it to C... There are always people who can't bear it and leak some rumors. , so everyone got one. The most unbearable thing is that some SBs are hawking in the group; I really don’t want to say anything, when will it be your turn to hawk? People's hearts are not ancient, so if you have any in the future, you should keep it to yourself.
I told Saiy about the vulnerability in the morning, and the official DZ patch will be out soon.
Related reading: Kangsheng Chuangxiang releases Discuz!7.2 patch 20100110
Special note: The $scriptlang array that generates the vulnerability has been initialized after the plug-in is installed, so users who have installed the plug-in are not affected.
Vulnerability introduction:
Discuz! The parameters executed in eval in the showmessage function in the new versions 7.1 and 7.2 are not initialized and can be submitted arbitrarily, so that any PHP command can be executed.
Vulnerability analysis:
Let’s analyze this remote code execution vulnerability. This problem is really serious. You can directly write the shell:
1. The vulnerability comes from the showmessage function:
Copy to Clipboard
extract($GLOBALS, EXTR_SKIP);//Dangerous usage, uninitialized variables can be brought directly into the function , directly caused the problem, from www.oldjun.com
global $hookscriptmessage, $extrahead, $discuz_uid, $discuz_action, $debuginfo, $seccode, $seccodestatus, $fid, $tid, $charset, $show_message, $inajax, $_DCACHE, $advlist;
define('CACHE_FORBIDDEN', TRUE);
$hookscriptmessage = $show_message = $message;$messagehandle = 0;
$msgforward = unserialize($_DCACHE[' settings']['msgforward']);
$refreshtime = intval($msgforward['refreshtime']);
$refreshtime = empty($forwardtype) ? $refreshtime : ($refreshtime ? $refreshtime : 3 );
$msgforward['refreshtime'] = $refreshtime * 1000;
$url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) && $transsidstatus ? transsid( $url_forward) : $url_forward);
$seccodecheck = $seccodestatus & 2;
if($_DCACHE['settings']['funcsiteid'] && $_DCACHE['settings']['funckey'] && $funcstatinfo && !IS_ROBOT) {
$statlogfile = DISCUZ_ROOT.'./forumdata/funcstat.log';
if($fp = @fopen($statlogfile, 'a')) {
@flock ($fp, 2);
if(is_array($funcstatinfo)) {
$funcstatinfo = array_unique($funcstatinfo);
foreach($funcstatinfo as $funcinfo) {
fwrite($fp , funcstat_query($funcinfo, $message)."n");
}
} else {
fwrite($fp, funcstat_query($funcstatinfo, $message)."n");
}
fclose($fp);
$funcstatinfo = $GLOBALS['funcstatinfo'] = '';
}
}
if(!defined('STAT_DISABLED') && STAT_ID > 0 && !IS_ROBOT) {
write_statlog($message);
}
if($url_forward && (!empty($quickforward) || empty($inajax) && $ msgforward['quick'] && $msgforward['messages'] && @in_array($message, $msgforward['messages']))) {
updatesession();
dheader("location: ".str_replace ('&', '&', $url_forward));
}
if(!empty($infloat)) {
if($extra) {
$messagehandle = $extra;
}
$extra = '';
}
if(in_array($extra, array('HALTED', 'NOPERM'))) {
$discuz_action = 254;
} else {
$discuz_action = 255;
}
include language('messages');
$vars = explode(':', $message);// Just include:
if(count($vars) == 2 && isset($scriptlang[$vars[0]][$vars[1]])) {//Two numbers are enough, use :Split
eval("$show_message = "".str_replace('"', '"', $scriptlang[$vars[0]][$vars[1]])."";");// $scriptlang is not initialized and can be customized, from www.oldjun.com
} elseif(isset($language[$message])) {
$pre = $inajax ? 'ajax_' : '';
eval("$show_message = "".(isset($language[$pre.$message]) ? $language[$pre.$message] : $language[$message])."";");
unset($pre);
}
......
}
- Total 2 pages:
- Previous page
- 1
- 2
- Next page

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)
