Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
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
Tags
more
Archives
Today
Total
관리 메뉴

TH3 6R3@T H@CK

Reverse Shell 본문

Study/Penetration Test

Reverse Shell

vvh0am1 2024. 3. 20. 12:24

Bind Shell vs. Reverse Shell

 

※ Reference: https://velog.io/@security_code

 

Bind Shell

· Bind Connection: Victim에서 포트를 열고 Attacker가 Victim으로 접속하는 연결 방식

· Bind Connection의 조건

- Victim에 방화벽이 없어야 함

- 방화벽이 있다면 Victim에서 포트를 열었지만 Attack가 접속할 수 없음

 

· Bind Shell: Bind Connection을 기반으로 Victim에서 포트를 열고 뒤에서 쉘이 대기하고 있다가 Attacker가 Victim으로 접속하면 쉘이 실행되는 공격 형태

· Bind Shell의 조건

- Victim의 방화벽 비활성화

- Victim에 포트를 열고 뒤에 쉘(/bin/sh)이 대기하고 있어야 함

 

Reverse Shell

· Reverse Connection: Attacker에서 포트를 열고 Victim이 Attacker로 접속하는 연결 방식

· Reverse Connection의 조건

- Victim에 방화벽이 활성화되어 있어야 함

- 방화벽이 있다면 Victim에서 포트를 열었지만 Attacker가 접속할 수 없음 → Victim에서 Attacker로 나와야 하는 상황

 

· Reverse Shell: Reverse Connection을 기반으로 Attacker에서 포트를 열고 대기하고 있다가 Victim이 Attacker로 접속할 때 쉘을 가지고 나가면 연결 후에 Victim의 쉘이 실행되는 공격 형태

· Reverse Shell의 조건

- Victim에 방화벽이 활성화(Inbound 쪽)되어 있어도 상관없음

- Victim에 방화벽이 Outbound 쪽도 설정되어 있다면 연결이 안될 수 있음

- Victim에 방화벽이 있다면 Attacker에서 포트를 열었기 때문에 Attacker로 접속할 수 있는 상황

- Victim이 Attacker로 연결할 때 쉘(/bin/sh)을 가지고 나가야 함

 

 

 

리버스 쉘 #1

 

· Attacker (Kali Linux / 좌): netcat 도구를 통해 victim의 연결 대기 → Victim으로부터 TCP 연결

· Victim (Kali Linux / 우): 컴파일 및 실행 (실행 후 대기 상태)

· Tip: wget https://gist.github.com/0xabe-io/916cf3af33d1c0592a90로 다운받아도 됨

 

 

 

Metasploit Framework 활용하기

 

· Modules

- auxiliary: 스캐너, 퍼저, 클로러

- encoders: 페이로드 인코딩

- evasion: 안티바이러스 우회

- exploits: 익스플로잇(cve) 코드

- nops: No Operations

- payloads: 쉘 코드

- post: Post Exploitation

 

 

· msfconsole: Metasploit Framework를 사용하기 위한 Command Line Interface 제공

 

 

 

리버스 쉘 #2

 

· Metasploit Framework를 이용하여 Reverse Shell 생성

· Linux (64bit) 용 Reverse Shell 검색 & 페이로드 선택

 

· 공격자 IP, Port 설정

 

· AGENT 파일 생성: elf (리눅스 실행파일)

 

· TIP: msfvenom 명령어를 통한 AGENT 생성

 

· Reverse Shell 테스트: 공격자(Linux)

 

· Reverse Shell 테스트: 피해자(Linux)

 

 

 

리버스 쉘 #3

 

· Victim(Kali Linux): Metasploit Framework를 통해 생성된 AGENT 실행

- AGENT 기능 Reverse Shell 연결

- 임의 공격자 명령 실행

 

· Attacker(Kali Linux)

- Metasploit Framework의 기능을 이용하여 Victim과의 세션 관리

- netcat 사용 X

- 감염된 Victim에 임의 파일 다운로드/업로드 수행

 

 

 

· 공격자(Linux): msf 설정 후 대기

 

· 공격자(Linux): AGENT 생성

 

· 피해자(Linux): AGENT 실행(agent_win)

 

· 공격자(Linux) with msfconsole

 

· 공격자(Linux, msf): AGENT에 명령 보내기

 

· 피해자(Linux)

 

 

 

· TIP: Metasploit Framework 제공 명령어들

- meterpreter > help

명령어 유형 명령어(예)       설명
File System download       파일 혹은 디렉터리를 다운로드
Networking netstat       네트워크 커넥션 출력
System reboot       시스템 재부팅
User Interface screenshot       현재 데스크탑 화면 캡쳐
Webcam record_mic       기본 mic로부터 x초 동안 오디오 레코딩
Audio Output play       오디오 파일을 대상 시스템에서 재생
Elevate getsystem       시스템 권한으로 권한 상승 (가능할 경우)
Password Database hashdump       SAM 데이터베이스 파일 덤프

 

'Study > Penetration Test' 카테고리의 다른 글

Reconnaissance: Key Logger  (0) 2024.05.01
Attacking Web Pages  (0) 2024.04.17
Deployment and Expansion  (0) 2024.04.03
MSFconsole  (0) 2024.03.22
AGENT  (1) 2024.03.22