* Pivoting

* SSH Key 사용법

* Pivoting 2

 


 

 

0. 네트워크 설정

 

 

# 설정 참고

Wintermute Vitrual Box Setup Guide

This lab makes use of pivoting, so the VirtualBox networks need to be setup correctly. It's quick and easy with all dynamic ips.
run or Import each machine into Virtual Box ( File >> Import Applicance )

---------------------------------------------------------------------------------------------------------------------------

STRAYLIGHT (Network #1 & #2)
-This is the first machine to get root. Setup to be dual-homed/2 NIC's.
-Adapter 1 
	- Host-only Adapter
	- VirtualBox Host-Only Ethernet Adapter #1
	Advanced (we want 2 NIC's, each on a separate network)
	- Adapter Type - Intel PRO/1000 T Server 
-Adapter 2
	- Host-only Adapter
	- VirtualBox Host-Only Ethernet Adapter #2
	Advanced
	- Adapter Type - Intel PRO/1000 MT Desktop (or other adapter type different than network #1).

---------------------------------------------------------------------------------------------------------------------------

NEUROMANCER (Network #2)
-This is the final machine to get root. Setup to have 1 network. Only accessed via Straylight, using Host-Only Eth adapter #2.
-Adapter 1
	- Host-only Adapter
	- VirtualBox Host-Only Ethernet Adapter #2
	Advanced
	- Adapter Type - Intel PRO/1000 MT Desktop

---------------------------------------------------------------------------------------------------------------------------

KALI (Network #1)
- Your attacking machine should only be setup on the Host-Only adpater Straylight is on...and NAT if you choose.
- You should not be able to ping Neuromancer from your Kali box. If you can, you are cheating.
- Adapter 1
	- Host-only Adapter
	- VirtualBox Host-Only Ethernet Adapter #1

---------------------------------------------------------------------------------------------------------------------------
 

: Host-Only 네트워크 인터페이스

2개 설정 필요!

 

 

--------------------------------------------------

# 칼리 <---> StrayLight <---> Neuromancer

 

Kali는

NAT이랑 호스트 전용 어댑터 각 1개

네트워크 #1 Intel PRO/1000 T MT Desktop (192.168.10.x)

 

StrayLight 서버는

호스트 전용 어댑터 2개

네트워크 #1 Intel PRO/1000 T Server (192.168.10.x)

네트워크 #2 Intel PRO/1000 MT Desktop (172.16.10.x)

 

Neuromancer 서버는

호스트 전용 어댑터 1개

네트워크 #2 Intel PRO/1000 MT Desktop (172.16.10.x)

------------------------------------------

 

 

 

# Virtual box 설정

파일 > 호스트 네트워크 관리자

 

 

 

 

: 위와 같은 방법으로

 

B 클래스 하나 추가 생성 후

각각 네트워크 설정해 주면 됨!

 

 

 

# 접속 테스트

 

정상 확인!

 

 

 

 

 

 

1. Information Gathering

 

호스트 등록해 주고 진행!

 

 

 

- 25 SMTP user enum

 

 

 

뭔가 전송은 되는 것 같은데

아직 모름

 

 

 

- WEB ENum

80

 

 

 

: gobuster

 

 

 

 

 

- 3000

 

: 계정 정보 힌트가 주어졌고 실험해 보면

: 로그인 성공! (ntopng)

 

 

 

- Nikto 돌려보면

 

XSS 취약점이 존재하며, 확인해 보면

맞음!

 

: 별 의미는 없음

 

 

 

 

- interfaces를 바꿔가며 활성화 중인 flows를 보면

 

경로 두 군대가 확인 가능하고

gobuster로 확인 불가능했던

경로에 접근해 보면

 

 

 

: turing-bolo (php)

 

: log 파일 확인이 가능하고

 

 

 

- Directory Traversal 취약점으로 로그 파일 호출 가능!

 

: 첨에 25 smtp 공략할 때

정상 전송된 것 확인 가능!

 

 

 

 

 

2. Exploitation

 

 

- 다시 한번 25번을 공략해 이번에는

php 시스템 명령어 실행이 가능한지

테스트해 보면

 

잘 되고

 

 

- 리스너 기동 후 nc!

 

- 조회해 주면

 

침투 성공!

 

 

 

 

 

3. Privilege Escalation

 

 

- SetUID

 

/bin/screen-4.5.0?

 

 

받아서 돌리면

 

root!

 

 

 

 

 

4. Post Escalation

 

Devs,

Lady 3Jane has asked us to create a custom java app on Neuromancer's primary server to help her interact w/ the AI via a web-based GUI.
The engineering team couldn't strss enough how risky that is, opening up a Super AI to remote access on the Freeside network. It is within out internal admin network, but still, it should be off the network completely. For the sake of humanity, user access should only be allowed via the physical console...who knows what this thing can do.
Anyways, we've deployed the war file on tomcat as ordered - located here:
/struts2_2.3.15.1-showcase

It's ready for the devs to customize to her liking...I'm stating the obvious, but make sure to secure this thing.

Regards,

Bob Laugh
 

Lady 3Jane

/struts2_2.3.15.1-showcase

tomcat에 war 파일 배포!

 

 

 

- 네트워크 확인

 

 

 

 

- 추가 확인

 

ssh는 없음

 

 

 

- 대상 IP & open Ports 검색

(1) search_IP.sh
#!/bin/bash
for ip in $(seq 1 254); do
   ping -c 1 172.16.10.$ip | grep "bytes from" | cut -d " " -f 4 | cut -d ":" -f 1 &
done

(2) search_ports.sh
#!/bin/bash
for i in $(seq 1 65535); do nc -nvz -w 1 172.16.10.102 $i 2>&1; done | grep -v "refused"
 

 

 

-  정리해보면

 

 

 

 


 

 

 

5. Pivoting

 

여러 기법들이 있지만

현재 ssh 사용이 불가한 상황이라

 

socket cat(Socat)을 활용한

Port Forwarding을 시도

 

+ 공부할 겸

다른 기법들도 함께 시도해 본다.

 

 

 

(1) Socat

 

Socat은

타겟 A = Straylight (장악 완료)

타겟 B = Neuromance (장악 필요)

 

 

- 기본 socat 테스트

socat TCP-LISTEN:<<Straylight_TCP_PORT>>,fork,reuseaddr TCP:<<Neuromancer_IP_address>>:<<Neuromancer_TCP_PORT>> &

socat TCP-LISTEN:8009,fork,reuseaddr TCP:172.16.10.102:8009 &
socat TCP-LISTEN:8080,fork,reuseaddr TCP:172.16.10.102:8080 &
socat TCP-LISTEN:34483,fork,reuseaddr TCP:172.16.10.102:34483 &
 

타겟 A의 TCP 8080을 요청하면

타겟 B의 TCP 8080로 포워딩 되는 원리!

(한마디로 타겟 A가 프록시 서버!)

 

 

 

- 백그라운드로 다 요청 후

 

 

 

- 확인

 

: 잘 열렸고

 

 

- 칼리에서 nmap으로 찍어보면

 

: 정상 조회되며

 

 

- 브라우저에서 접속해 보면

 

: 정상 접속된다!

 

 


 
 
 

6. Exploitation

 

우선 첫 번째 박스에서

루팅 후 받은 힌트 경로 접속

 

 

: struts2검색

 

 

 

- 파일 업로드 테스트

 

: 붙어보면 404

 

 

 

- struts2 exploit 검색

 

 

 

- 돌려보면

 

첫 번째 시도는 반응이 없고

/bin/bash 삭제 후 기본 리스너

테스트 시 반응이 있음!

 

> 결국 exploit이 먹힌다는 이야기!

 

 

- 타겟 A에 리버스 쉘 파일 보내서

타겟 B에서 받아 실행하도록 하면 되겠다.

 

 

- 쉘 생성 후

 

: 혹시 모르니 두 개

 

 

- 받아준 뒤

 

 

 

- 파이썬 서버 & 리스너 기동

 

 

 

- exploit으로 커맨드 실행하면

 

- 잘 받아지고

 

 

 

- 실행 권한 주고 실행시키면

 

 

 

- elf 파일은 붙어졌다가 바로 해제되고

 

sh 파일로 정상 침투 성공!

 

 

 

 

 

7. Privilege Escalation

 

 

 

- 우선 ta 사용자 .bashrc에서 톰캣 경로 확인 후

 

 

tomcat-users.xml에서

: Lady3Jane pass 확인

>!Xx3JanexX!<

 

 

- 해당 사용자로 변환 시도 시

 

: 성공!

 

 

- nmap에서 ssh 포트 확인이 되었기에

ssh 로그인도

 

가능!

 

 

- sudo는 안됨

 

 

 

 

 

 

# SSH KEY 사용법

 

참고로 ta 사용자로 ssh 접속하는 경우

1) 칼리 및 접속하려는 대상(타켓 B)에 각각 ssh-key 생성

 

 

 

2) 칼리의 id_rsa.pub 복사 후

 

 

침투 서버(타켓 B)의

authorized_keys로 넣어주

 

 

 

3) 칼리의 id_rsa 키로 접속 시도하면

 

끝!

 

 


 

 

8. Pivoting - 2

 

(2) Socat reverse Port Forwarding

 

현재 Socat으로 한 방향 포워딩만 설정해 둔 상황이라

역으로 호출 시

 

당연히 닿을 수가 없는데

이럴 때 사용하는 역방향

포트 포워딩의 실습이다.

 

말이 거창했는데

사실 명령어는 동일하고

socat TCP-LISTEN:5555,fork,reuseaddr TCP:192.168.10.105:6666 &
 

그냥 설정을 반대로 하나 더

추가해 준다고 생각하면 됨!

 

타켓 B에서 타켓 A의 6666 호출 시

칼리의 6666이 반응하게 되는 구조고

 

예로

B 클래스(172~)의 타켓 B에서

C 클래스(192~)의 칼리로부터

Linpeas.sh를 받으려는 경우

 

타켓 A(172)의 6666을 호스팅 해주면

 

정상적으로 받아짐!

 

결국 중간에 중개 서버인

타켓 A를 프록시 서버로

사용하는 것!

 

 


 

 

계속 작업을 이어나간다.

 

 

- linpeas.sh

 

CVE-2021-4034

CVE-2022-2588

 

 

lxd 그룹

https://reboare.github.io/lxd/lxd-escape.html

 

 

 

 

 

 

 

 

 

 

 

728x90
반응형

'OSCP > Vulnahub' 카테고리의 다른 글

[+] VENOM  (0) 2023.01.21
[+] DigitalWorld.local : FALL (SSH id_rsa)  (0) 2023.01.21
[+] Hack Me Please  (0) 2023.01.20
[+] Hacker Kid (XXE & SSTI)  (1) 2023.01.18
[+] Typo  (0) 2023.01.18

+ Recent posts