[링크] pentest-bookmarks

보안 소식/주간 이슈 2011. 3. 18. 14:29 Posted by TEAMCR@K
모의해킹을 진행하는데 필요한 사이트들이 잘 수집되어 있습니다.

http://code.google.com/p/pentest-bookmarks/wiki/BookmarksList

Forums:
Created for forums that will help in both tool usage, syntax, attack techniques, and collection of scripts and tools. Needs some help. I don't really frequent too many underground forums but i actually find nice one-off scripts and info i can roll into my own code in these places. Would like to add more.
http://sla.ckers.org/forum/index.php
http://www.ethicalhacker.net/
http://www.backtrack-linux.org/forums/
http://www.elitehackers.info/forums/
http://www.hackthissite.org/forums/index.php
http://securityoverride.com/forum/index.php
http://www.iexploit.org/
http://bright-shadows.net/
http://www.governmentsecurity.org/forum/
http://forum.intern0t.net/

...(상세보기)를 통해 볼 수 있습니다.

이전에도 FTP 서비스를 가지고 다양한 패턴으로 취약점이 발표되었는데,

이번에는 아이폰, 아이패드 앱 중 웹 서비스에 대한 Directory Traversal 취약점들이 많이 있네요.

환경도 단순하기 때문에, 테스트 해보는 것도 좋을거 같습니다. 이 외에도 동일한 프로세스를 가지고 있는 다른 앱들도 취약점들이 있을거라 판단되네요.


Remote Exploits

PDF 악성 코드 분석 및 분석 방법 등을 정리해 놓은 URL 들입니다.
2010년을 돌아보면서 재확인 할시에 도움이 될거 같네요. 

URL 정보 : http://eternal-todo.com/blog/pdf-security-analysis-tools-2010

After one year full of security issues related to the Portable Document Format I've made a little compilation of useful links to analyses and tools:

Analysis

2010-01-04: Sophisticated, targeted malicious PDF documents exploiting CVE-2009-4324  (embedded binaries)
2010-01-07: Static analysis of malicous PDFs (Part #2) (getAnnots, arguments.callee)
2010-01-09: PDF Obfuscation (variable substitution, LuckySploit, CVE 2008-2992)
2010-01-13: Generic PDF exploit hider. embedPDF.py and goodbye AV detection
2010-01-14: PDF Obfuscation using getAnnots() (getAnnots, arguments.callee, Neosploit)
2010-02-15: Filling Adobe's heap (Javascript, ActionScript and PDF Images)
2010-02-18: Malicious PDF trick: getPageNthWord
2010-02-21: Analyzing PDF exploits with Pyew
2010-03-01: Analyzing PDF Files (getPageNthWord, getPageNumWords)
2010-04-08: JavaScript obfuscation in PDF: Sky is the limit (getAnnots,arguments.callee)
2010-04-09: Malicious PDF file analysis: zynamics style  (PDF Dissector video)
2010-04-22: Will there be new viruses exploiting /Launch vulnerability in PDF?
2010-05-18: Quickpost: More Malformed PDFs 
2010-06-08: Analysis of a Zero-day Exploit for Adobe Flash and Reader (CVE-2010-1297)
2010-06-09: A brief analysis of a malicious PDF file which exploits this week’s Flash 0-day (malware, ROP)
2010-06-21: World's Smallest PDF
2010-07-02: Exploring recent PDF exploits: A Time Killer (getPageNthWord,CVE-2008-2992,CVE-2007-5659,CVE-2009-0927,CVE-2009-4324)
2010-07-13: ReCon slides – How to really obfuscate your PDF malware
2010-07-20: PDF time bomb (CVE-2008-2992,CVE-2007-5659,CVE-2009-0927)
2010-08-04: PDF Exploit: Number of pages is the Key  (XOR, numPages,CVE-2007-5659,CVE-2009-0927,CVE-2009-4324)
2010-08-04: About the JailbreakMe PDF exploit
2010-08-12: More about the JailbreakMe PDF exploit (CVE-2010-1797)
2010-08-19: Anatomy of a PDF Exploit (AcroForm, TIFF, CVE-2010-0188)
2010-08-20: Analyzing CVE-2010-0188 exploits: The Legend of Pat Casey (Part 1)
2010-08-23: CVE-2010-1797 PDF exploit for Foxit Reader <= 4.0
2010-09-01: An approach to PDF shielding (encryption, object streams, nested PDF documents)
2010-09-13: Malicious PDF Challenges (getPageNumWords, getPageNthWord)
2010-09-17: The Rise of PDF Malware (whitepaper)
2010-09-26: Free Malicious PDF Analysis E-book
2010-10-02: Hiding PDF Exploits by embedding PDF files in streams and Flash ROP heapsprays (CVE-2010-2883)
2010-10-27: OMG WTF PDF - Julia Wolf (obfuscation, slides)
2010-10-28: CVE-2010-3654 Adobe Flash player zero day vulnerability
2010-10-28: New Adobe 0day (bug in flash player),CVE-2010-3654
2010-11-11: CVE-2010-4091 – printSeps - exploitation attempts
2010-12-03: CVE-2010-2883 with Flash JIT Spray (PDF in PDF) Event Invitation from The Heritage Foundation from spoofed Heritage address
2010-12-08: Scoring PDFs Based on Malicious Filter
2010-12-08: Released Malware Statistics and Scoring Tests
2010: A lot of analyses from Contagiodump blog

Tools

2010-05-31: PDF Dissector
2010-07-21: PDF Stream Dumper
2010-08-23: Opaf
2010-08-31: PDF Examiner (web interface)

2011년 A3 Security 워크샵 동영상

CR@K 이야기 2011. 2. 18. 17:17 Posted by TEAMCR@K
2011년 A3 Security 워크샵을 갔다 왔습니다. 이번에는 재미있는 활동은 하지 못했지만 뜻깊은 시간을 가진거 같네요.

URL 정보 : http://tools.securitytube.net/index.php?title=Open_Security_Training

Objective

We started SecurityTube.net in mid 2008 to serve as a place for sharing knowledge in computer and network security topics. The below videos created by our team over the last 2 years is the first step in that direction. Hope you like them!

Video Series

Exploit Research Megaprimer Series

  1. Exploit Research Megaprimer Part 1 Introduction by Vivek http://bit.ly/i9gIIm
  2. Exploit Research Megaprimer Part 2 Memcpy Buffer Overflow Exploitation http://bit.ly/fLmhLu
  3. Exploit Research Megaprimer Part 3 Strcpy Buffer Overflow Exploitation http://bit.ly/gx3lTU
  4. Exploit Research Megaprimer Part 4 Minishare Buffer Overflow Exploitation http://bit.ly/gufuCb
  5. Exploit Research Megaprimer Part 5 FreeSSHD Buffer Overflow http://bit.ly/eVCMB5
  6. Exploit Research Megaprimer Part 6 SEH Basics http://securitytube.net/Exploit-Research-Megaprimer-Part-6-SEH-Basics-video.aspx
  7. Exploit Research Megaprimer Part 7 Overwrite SEH http://securitytube.net/Exploit-Research-Megaprimer-Part-7-Overwrite-SEH-video.aspx
  8. Exploit Research Megaprimer Part 8 Exploiting SEH http://bit.ly/eznTUc
  9. Exploit Research Megaprimer Part 9 Guest Lecture by Andrew King http://bit.ly/dMo0QI

Assembly Language Primer for Hackers Series (Linux)

  1. Assembly Primer for Hackers (Part 1) System Organization http://www.securitytube.net/Assembly-Primer-for-Hackers-%28Part-1%29-System-Organization-video.aspx
  2. Assembly Primer for Hackers (Part 2) Virtual Memory Organization http://www.securitytube.net/Assembly-Primer-for-Hackers-%28Part-2%29-Virtual-Memory-Organization-video.aspx
  3. Assembly Primer for Hackers (Part 3) GDB Usage Primer http://www.securitytube.net/Assembly-Primer-for-Hackers-%28Part-3%29-GDB-Usage-Primer-video.aspx
  4. Assembly Primer for Hackers (Part 4) Hello World http://www.securitytube.net/Assembly-Primer-for-Hackers-%28Part-4%29-Hello-World-video.aspx
  5. Assembly Primer for Hackers (Part 5) Data Types http://www.securitytube.net/Assembly-Primer-for-Hackers-%28Part-5%29-Data-Types-video.aspx
  6. Assembly Primer for Hackers (Part 6) Moving Data http://securitytube.net/Assembly-Primer-for-Hackers-%28Part-6%29-Moving-Data-video.aspx
  7. Assembly Primer for Hackers (Part 7) Working with Strings http://securitytube.net/Assembly-Primer-for-Hackers-%28Part-7%29-Working-with-Strings-video.aspx
  8. Assembly Primer for Hackers (Part 8) Unconditional Branching http://securitytube.net/Assembly-Primer-for-Hackers-%28Part-8%29-Unconditional-Branching-video.aspx
  9. Assembly Primer for Hackers (Part 9) Conditional Branching http://securitytube.net/Assembly-Primer-for-Hackers-%28Part-9%29-Conditional-Branching-video.aspx
  10. Assembly Primer for Hackers (Part 10) Functions http://securitytube.net/Assembly-Primer-for-Hackers-%28Part-10%29-Functions-video.aspx
  11. Assembly Primer for Hackers (Part 11) Functions Stack http://www.securitytube.net/Assembly-Primer-for-Hackers-%28Part-11%29-Functions-Stack-video.aspx

Buffer Overflow Primer for Hackers Series

  1. Buffer Overflow Primer Part 1 (Smashing the Stack) http://www.securitytube.net/Buffer-Overflow-Primer-Part-1-%28Smashing-the-Stack%29-video.aspx
  2. Buffer Overflow Primer Part 2 (Writing Exit Shellcode) http://www.securitytube.net/Buffer-Overflow-Primer-Part-2-%28Writing-Exit-Shellcode%29-video.aspx
  3. Buffer Overflow Primer Part 3 (Executing Shellcode) http://www.securitytube.net/Buffer-Overflow-Primer-Part-3-%28Executing-Shellcode%29-video.aspx
  4. Buffer Overflow Primer Part 4 (Disassembling Execve) http://www.securitytube.net/Buffer-Overflow-Primer-Part-4-%28Disassembling-Execve%29-video.aspx
  5. Buffer Overflow Primer Part 5 (Shellcode for Execve) http://www.securitytube.net/Buffer-Overflow-Primer-Part-5-%28Shellcode-for-Execve%29-video.aspx
  6. Buffer Overflow Primer Part 6 (Exploiting a Program) http://www.securitytube.net/Buffer-Overflow-Primer-Part-6-%28Exploiting-a-Program%29-video.aspx
  7. Buffer Overflow Primer Part 7 (Exploiting a Program Demo) http://www.securitytube.net/Buffer-Overflow-Primer-Part-7-%28Exploiting-a-Program-Demo%29-video.aspx
  8. Buffer Overflow Primer Part 8 (Return to Libc Theory) http://www.securitytube.net/Buffer-Overflow-Primer-Part-8-%28Return-to-Libc-Theory%29-video.aspx
  9. Buffer Overflow Primer Part 9 (Return to Libc Demo) http://www.securitytube.net/Buffer-Overflow-Primer-Part-9-%28Return-to-Libc-Demo%29-video.aspx

Format String Vulnerability Series

  1. Format String Vulnerabilities Primer (Part 1 The Basics) http://www.securitytube.net/Format-String-Vulnerabilities-Primer-%28Part-1-The-Basics%29-video.aspx
  2. Format String Vulnerabilities Primer (Part 2 Understanding Format Functions) http://www.securitytube.net/Format-String-Vulnerabilities-Primer-%28Part-2-Understanding-Format-Functions%29-video.aspx
  3. Format String Vulnerabilities Primer (Part 3 Crashing the Program) http://www.securitytube.net/Format-String-Vulnerabilities-Primer-%28Part-3-Crashing-the-Program%29-video.aspx
  4. Format String Vulnerabilities Primer (Part 4 Viewing the Stack) http://www.securitytube.net/Format-String-Vulnerabilities-Primer-%28Part-4-Viewing-the-Stack%29-video.aspx

Metasploit Megaprimer Series

  1. Metasploit Megaprimer (Exploitation Basics and need for Metasploit) Part 1 Tutorial http://securitytube.net/Metasploit-Megaprimer-%28Exploitation-Basics-and-need-for-Metasploit%29-Part-1-video.aspx
  2. Metasploit Megaprimer (Getting Started with Metasploit) Part 2 Tutorial http://securitytube.net/Metasploit-Megaprimer-%28Getting-Started-with-Metasploit%29-Part-2-video.aspx
  3. Metasploit Megaprimer Part 3 (Meterpreter Basics and using Stdapi) Tutorial http://securitytube.net/Metasploit-Megaprimer-Part-3-(Meterpreter-Basics-and-using-Stdapi)-video.aspx
  4. Metasploit Megaprimer Part 4 (Meterpreter Extensions Stdapi and Priv) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-4-%28Meterpreter-Extensions-Stdapi-and-Priv%29-video.aspx
  5. Metasploit Megaprimer Part 5 (Understanding Windows Tokens and Meterpreter Incognito) Tutorial http://securitytube.net/Metasploit-Megaprimer-Part-5-%28Understanding-Windows-Tokens-and-Meterpreter-Incognito%29-video.aspx
  6. Metasploit Megaprimer Part 6 (Espia and Sniffer Extensions with Meterpreter Scripts) Tutorial http://securitytube.net/Metasploit-Megaprimer-Part-6-%28Espia-and-Sniffer-Extensions-with-Meterpreter-Scripts%29-video.aspx
  7. Metasploit Megaprimer Part 7 (Metasploit Database Integration and Automating Exploitation) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-7-%28Metasploit-Database-Integration-and-Automating-Exploitation%29-video.aspx
  8. Metasploit Megaprimer Part 8 (Post Exploitation Kung Fu) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-8-%28Post-Exploitation-Kung-Fu%29-video.aspx
  9. Metasploit Megaprimer Part 9 (Post Exploitation Privilege Escalation) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-9-%28Post-Exploitation-Privilege-Escalation%29-video.aspx
  10. Metasploit Megaprimer Part 10 (Post Exploitation Log Deletion and AV Killing) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-10-%28Post-Exploitation-Log-Deletion-and-AV-Killing%29-video.aspx
  11. Metasploit Megaprimer Part 11 (Post Exploitation and Stealing Data) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-%28Post-Exploitation-and-Stealing-Data%29-Part-11-video.aspx
  12. Metasploit Megaprimer Part 12 (Post Exploitation Backdoors and Rootkits) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-12-%28Post-Exploitation-Backdoors-and-Rootkits%29-video.aspx
  13. Metasploit Megaprimer Part 13 (Post Exploitation Pivoting and Port Forwarding) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-13-%28Post-Exploitation-Pivoting-and-Port-Forwarding%29-video.aspx
  14. Metasploit Megaprimer Part 14 (Backdooring Executables) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-14-%28Backdooring-Executables%29-video.aspx
  15. Metasploit Megaprimer Part 15 (Auxiliary Modules) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-15-%28Auxiliary-Modules%29-video.aspx
  16. Metasploit Megaprimer Part 16 (Pass the Hash Attack) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-16-%28Pass-the-Hash-Attack%29-video.aspx
  17. Metasploit Megaprimer Part 17 (Scenario Based Hacking) Tutorial http://www.securitytube.net/Metasploit-Megaprimer-Part-17-%28Scenario-Based-Hacking%29-video.aspx

Windows Assembly Language Primer

  1. Windows Assembly Language Primer Part 1 (Processor Modes) http://securitytube.net/Windows-Assembly-Language-Primer-Part-1-%28Processor-Modes%29-video.aspx
  2. Windows Assembly Language Primer for Hackers Part 2 (Protected Mode Assembly) http://securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-2-%28Protected-Mode-Assembly%29-video.aspx
  3. Windows Assembly Language Primer for Hackers Part 3 (Win32 ASM using MASM32) http://securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-3-%28Win32-ASM-using-MASM32%29-video.aspx
  4. Windows Assembly Language Primer for Hackers Part 4 (MASM Data Types) http://securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-4-%28MASM-Data-Types%29-video.aspx
  5. Windows Assembly Language Primer for Hackers Part 5 (Procedures) http://securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-5-%28Procedures%29-video.aspx
  6. Windows Assembly Language Primer for Hackers Part 6 (Macros) http://securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-6-%28Macros%29-video.aspx
  7. Windows Assembly Language Primer for Hackers Part 7 (Program Control using JMP) http://securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-7-%28Program-Control-using-JMP%29-video.aspx
  8. Windows Assembly Language Primer for Hackers Part 8 (Decision Directives) http://www.securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-8-%28Decision-Directives%29-video.aspx
  9. Windows Assembly Language Primer for Hackers Part 9 (Loops) http://www.securitytube.net/Windows-Assembly-Language-Primer-for-Hackers-Part-9-%28Loops%29-video.aspx

Scenario Based Hacking

  1. Scenario Based Hacking Part 1 (No Patches, No AV, Direct Access) http://securitytube.net/Scenario-Based-Hacking-Part-1-%28No-Patches,-No-AV,-Direct-Access%29-video.aspx
  2. Scenario Based Hacking Part 2a (No Patches, No AV, Behind NAT) http://securitytube.net/Scenario-Based-Hacking-Part-2a-%28No-Patches,-No-AV,-Behind-NAT%29-video.aspx
  3. Scenario Based Hacking Part 3 (OS Patched, No AV, Behind NAT) http://securitytube.net/Scenario-Based-Hacking-Part-3-%28OS-Patched,-No-AV,-Behind-NAT%29-video.aspx
  4. Scenario Based Hacking Part 4 (OS and Software Patched, No AV, Behind NAT) http://securitytube.net/Scenario-Based-Hacking-Part-4-%28OS-and-Software-Patched,-No-AV,-Behind-NAT%29-video.aspx

Router Hacking Series

  1. Router Hacking Part 1 (The Basics) http://securitytube.net/Router-Hacking-Part-1-%28The-Basics%29-video.aspx
  2. Router Hacking Part 2 (Service Enumeration, Fingerprinting and Default Accounts) http://securitytube.net/Router-Hacking-Part-2-(Service-Enumeration,-Fingerprinting-and-Default-Accounts)-video.aspx
  3. Router Hacking Part 3 (Bruteforcing and Dictionary Attacks with Hydra) http://securitytube.net/Router-Hacking-Part-3-(Bruteforcing-and-Dictionary-Attacks-with-Hydra)-video.aspx
  4. Router Hacking Part 4 (SNMP Attacks using SNMPCheck) http://securitytube.net/Router-Hacking-Part-4-(SNMP-Attacks-using-SNMPCheck)-video.aspx
  5. Router Hacking Part 5 (SNMP Attacks using SNMPEnum) http://securitytube.net/Router-Hacking-Part-5-(SNMP-Attacks-using-SNMPEnum)-video.aspx
  6. Router Hacking Part 6 (Dictionary Attack using Metasploit on SNMP) http://www.securitytube.net/Router-Hacking-Part-6-%28Dictionary-Attack-using-Metasploit-on-SNMP%29-video.aspx

HITB Magazine Issue 005 Released

보안 소식/주간 이슈 2011. 2. 10. 11:27 Posted by TEAMCR@K

 HITB Magazine Issue 005 Released

HITB Magazine
=============
http://magazine.hackinthebox.org/

Direct Link
===========
http://magazine.hackinthebox.org/issues/HITB-Ezine-Issue-005.pdf

A very Happy New Year and a warm welcome to Issue 05 - The first HITB Magazine release for 2011!

Just over a year has passed since Issue 001 and 2010 was definitely a great year for our humble magazine with over a 100,000 downloads of the 4 issues released which included 24 unique technical articles authored or co-authored by over 30 security experts from around the world! Since April 2010, readers have also had an opportunity to get familiar with prominent figures from the IT security industry thanks to the new "Interviews" section.

We believe our goal of giving researchers further recognition for their hard work, and to provide the security community with beneficial technical material as stated in our editorial note of Issue 001 has been successfully achieved. All this however, wouldn't have be possible without YOU - our loyal and supportive readers! It is you who provide us the most motivation to keep on pushing the boundaries and to improve on each successive issue we release, so THANK YOU!

As always, feedback of any kind is greatly appreciated so don't hesitate to drop us a line if you have any suggestions or comments. Stay tuned for Issue 006 which will be released in May 2011 in conjunction with the 2nd annual HITB Security Conference in Europe, HITB2011 - Amsterdam! See you there and in the meantime, enjoy the issue!

Warmest,

Matthew "j00ru" Jurczyk
http://twitter.com/j00ru

 

메모리 보호기법 우회 연구분석보고서 -2-


By. eloi@a3sc.co.kr
(A.K.A eloi)

jtsong@a3sc.co.kr
(A.K.A trynerr)


본 문서는 Stack Overflow 보호기법과 이를 우회하는 방법에 대하여 작성하였습니다. 해당 내용과 테스트 결과가 많은 관계로아래와 같은 주제로 3회에 걸쳐 연재하도록 하겠습니다.
 

1. 'Windows/Linux 환경에서의 Stack Overflow 보호기법'
2. 'ROP(Return Oriented Programming) Exploit'
3. 'SEH(Structed Exception Handling) Overwrite' 




ROP(Return Oriented Programming) Exploit

1. ROP(Return Oriented Programming)
ROP(Return Oriented Programming)는 취약한 프로그램 내부에 있는 기계어 코드 섹션들(Gadget)을 이용하여 BOF공격 시 특정 명령을 실행시키는 방법을 말합니다. 보통 Gadget은 함수 끝에 기술되어있는 ret 명령어를 포함, 상위 몇가지 명령어들의 집합이며 이를 이용하여 단한번의 실패없이 한번에 공격을 성공할 수 있습니다

                                                          [그림 1] Gadget #1

                                                          [그림 2] Gadget #2

이러한 ROP는 ASLR, DEP/NX, ASCII-Armor 메모리 보호기법들을 우회할 수 있기 때문에 Fedora core 13(kernel 2.6.33.3-85)에서 BOF공격이 가능합니다.

ROP는 RTL, Chaining RTL calls, GOT overwrite의 3가지 특징적인 기술을 사용합니다.

(1) RTL(Return to libc)
스택에 있는 리턴 주소를 특정 라이브러리 주소와 이에 알맞은 인자 구성을 하여 공격하는 방법을 Return-to-libc 공격이라고도 부릅니다. 특정 프로그램(/bin/sh)을 실행 하기 위하여 system(), exec*() 등과 같은 함수를 사용하여 관리자 권한의 쉘을 획득합니다.

다음은 RTL 공격 전후의 스택구조를 나타낸 그림입니다.

                                                          [그림 3] RTL 개념도

DEP/NX의 보호기법으로 인해 스택영역에 코드를 삽입하여 공격하는 고전적인 쉘코드 삽입방법은 무용지물이 되었습니다. 하지만 이러한 RTL 공격기법을 이용하여 코드 삽입 방법이 아닌 함수를 직접 호출하는 RTL 방법으로 우회할 수 있습니다.
이러한 방법은 DEP/NX + ASLR 보호 기법이 적용되면서 공격이 어렵게 됩니다. 라이브러리 로딩 순서가 바뀌거나, 부팅할 때마다 이미지 적재 위치가 바뀌게 되면 임의의 리턴 주소를 찍어 맞춰야 하기 때문에 사실상 공격이 어려워집니다.

(2) Chaining RTL calls
Chaining RTL calls 기법은 RTL 공격을 연속적으로 일어나게 스택을 구성하여 공격하는 방법을 말합니다. pop-pop-ret 과 같은 명령어를 이용하여 스택의 인자 참조 영역을 지나치고 다음 함수주소로 이동, 연속적으로 함수를 호출할 수 있습니다.

다음은 Chaining RTL calls의 구성을 나타낸 화면입니다. 아래와 같이 스택이 구성된다면 연속적인 함수 호출이 가능합니다.

                                                          [그림 4] Chaining RTL calls 개념도

(3) GOT(Global Offset Table) Overwrite
GOT Overwrite는 libc.so 내에 실제 함수 주소를 저장해 놓은 공간인 GOT에 특정 함수의 GOT 값을 변경하여 원하는 함수가 실행되게 하는 방법입니다. 예를 들어 printf 함수의 GOT값(실제 함수 주소)을 execve 함수의 주소로 변경하게 된다면 printf 함수가 수행될 때 printf가 호출되는 것이 아닌 execve함수가 호출되게 되는 것을 말합니다.

다음은 PLT에서 GOT의 흐름과 실제 함수 주소를 확인하는 화면입니다.

                                                          [그림 5] PLT, GOT 흐름도

2. ROP 시나리오
ROP 시나리오는 Stage-1과 Stage-0으로 구분됩니다. Stage-1에서는 ROP 공격을 위한 Payload가 구성되며 Stage-0에서는 Stage-1에서 구성된 Payload를 특정 스택 영역에 복사하기 위한 strcpy 함수의 Chaining RTL calls가 구성됩니다.

(1) Stage-1
Stage-1은 GOT Overwrite로 실행 함수(exec* 계열)나 getreuid함수를 호출하게 합니다. 하지만 ASLR 보호기법으로 인해 직접적인 함수 주소를 overwrite를 할 수 없기 때문에 add operation gadget을 이용하여 함수간 offset을 add operation으로 계산하여 원하는 함수가 호출되게 합니다.

다음은 execve 함수와 printf 함수의 주소 그리고 이들간에 offset값을 나타낸 화면입니다.

                                                          [그림 6] execve, printf 함수 주소

offset = execve() - printf()
execve() = printf() + offset
execve() = 0x94ee40
printf() = 0x8fad30
offset = 0x54110


다음은 Stage-1애서 GOT Overwrite를 하기위한 스택구조를 나타낸 화면입니다.

                                                          [그림 7] GOT Overwrite가 일어나는 스택구조

ecx 레지스터에 해당 offset 값을 넣어두고 add operation gadget의 명령에 맞춰 5b042464를 빼준 값을 ebp에 넣어둡니다. 해당 명령이 실행될 때에 ebp와 5b042464값이 더해지게 되어 printf함수의 주소로 바뀌게 되고 이를 ecx(offset)와 더하면서 printf 함수의 GOT 값이 execve 함수의 주소로 바뀌게 됩니다. 마지막으로 printf의 PLT값이 호출되면서 execve함수가 수행되는 방식으로 진행됩니다.

(2) Stage-0
Stage-1에서는 Stage-0에서 구성된 Payload를 실행은 되지 않지만 메모리 주소가 변하지 않는 특정 custom stack영역에 복사를 수행합니다. 여기서는 앞서 설명한 Chaining RTL calls를 이용하여 반복적으로 strcpy 함수를 호출하게 되는데 이는 부분 부분 흩어져 있는 특정 문자열들을 모아서 Stage-0 Payload에 맞게 구성해야 하기 때문입니다. 이와 같은 작업을 하는 이유는 Stage-1에서 존재하는 NULL byte(0x00) 이후의 값을 strcpy 함수로 복사할 수 없기 때문이며, 원하는 기능을 수행하기 위해서 ebp의 값을 원하는 위치에 놓이게 하기 위해서 입니다.

3. ROP Exploitation
ROP Exploit은 Fedora Core 13에서 수행하였습니다. 일반적인 BOF는 수동으로 공격을 수행하기도 하지만 ROP Exploit을 수동으로 구성하는 것은 효율적이지 않습니다. 다양한 gadget들을 모아야하며 Stage-1을 구성하기 위해 사용되는 수많은 코드들 또한 모아야 하기 때문에 오랜시간이 소비됩니다. 이 때문에 ROP는 자동화된 공격도구를 사용하게 됩니다. 앞으로의 예제는 공격코드가 구성되는 gadget과 Stage-1과 Stage-0를 쉽게 구성하기 위해 BlackHat 2010에서 소개되었던 ROPEME(ROP Exploit Made Easy)를 이용하였습니다.

다음은 BOF 취약점이 존재하는 프로그램 소스코드 입니다. strcpy함수로 인해 BOF가 일어나게 됩니다.

                                                          [그림 8] BOF 취약점이 존재하는 프로그램

다음은 ROPEME에서 제공하는 ropshell을 이용하여 해당 gadget들을 찾는 화면입니다.

                                                          [그림 9] ropshell을 이용한 gadget 검색

다음은 Stage-1이 놓이게될 custom stack 영역을 찾는 화면입니다. 주소값이 변하지 않는 .bss 영역을 지정하게 됩니다. 정확한 위치는 사용하고 있는 8byte를 지난 bss+8 영역이 됩니다.

                                                          [그림 10] custom stack이 놓이게 될 위치

gadget들과 custom stack의 위치를 찾게되면 이를 이용하여 exploit합니다. 다음은 exploit 코드 화면입니다.

                                                          [그림 11] exploit #1
                                                          [그림 12] exploit #2

exploit은 지정된 gadget들을 참조하여 stage-1과 stage-0를 구성합니다. ret의 주소를 70번 삽입하고 그 이후 stage-0를 구성하는 형태로 공격이 진행됩니다.

다음은 이를 이용하여 관리자 권한을 획득하는 화면입니다.

                                                          [그림 13] exploit #3

exploit에서 구성된 공격코드를 추출하여 분석결과 ret 이후 strcpy 함수의 Chaining RTL calls로 구성합니다. 또한 stage-0을 구성할 시에 쓰이는 문자열들은 취약한 프로그램 코드를 검색하여 수집합니다.

다음은 exploit상에서 출력되는 Stage-1과 Stage-0의 구성화면입니다.

                                                          [그림 14] Stage-1 Payload
                                                          [그림 15] Stage-0 Payload

다음은 공격코드를 추출하여 Stage-0의 strcpy의 호출과 복사 위치를 확인하는 화면입니다.

                                                          [그림 16] Stage-0의 strcpy 복사 위치 확인 #1

위와 같이 Stage-1을 구성하기위해 custom stack위치에 특정 문자열을 반복적으로 복사하는 것을 확인 할 수 있습니다.

다음은 이해를 쉽게하기 위해 실제 디비거 상에서 source위치를 확인하는 화면입니다.

                                                          [그림 17] Stage-0의 strcpy 복사 위치 확인 #2

다음은 Stage-1의 Payload 입니다. 복사되는 문자열이 Stage-1의 값이라는 것을 확인할 수 있습니다.

                                                          [그림 18] Stage-0의 strcpy 복사 위치 확인 #3

Stage-1이 일어나는 액션은 다음과 같습니다. 취약한 프로그램의 getuid함수의 GOT를 Overwrite하여 setreuid() 함수로 root권한을 상속받고 setreuid() GOT를 다시 execvp함수로 Overwrite하여 shell을 실행하는 순서로 진행합니다.

                                                          [그림 19] Stage-1의 액션 확인

위에서 설명했던 액션을 대략적으로 스택에 반영하여 확인하면 다음과 같습니다.

                                                          [그림 20] Stage-1 스택 구성도

다음은 추출한 공격코드들을 수동으로 수행하는 화면입니다.

                                                          [그림 21] 추출한 Payload로 수동공격

다음은 trace 명령으로 해당 공격코드를 삽입하여 strcpy함수를 연속적으로 호출하고 있는것을 확인하는 화면입니다. 정상함수 수행 후 BOF되어 strcpy함수를 연속적으로 호출하는 것을 확인할 수 있습니다.

                                                          [그림 22] trace 명령으로 함수 호출 확인#1

                                                          [그림 23] trace 명령으로 함수 호출 확인#2




참고 URL

1.   http://msdn.microsoft.com

2.   http://x82.inetcop.org/

3.   http://nchovy.kr/forum/5/article/377

4.   http://en.wikipedia.org/wiki/Buffer_overflow_protection

5.   http://ko.wikipedia.org/wiki/버퍼 오버플로우

6.   http://lucid7.egloos.com/

7.   http://uptx.egloos.com/

 

 

참고 문헌

1.   poc09-sotirov.pdf(POC 2009 발표자료)

2.   BHUS10_Paper_Payload_already_inside_data_reuse_for_ROP_expl.pdf

(BlackHat 2010 USA 발표자료)

3.   Linux Memory Protectiion Mechanism

4.   bh08sotirovdowd.pdf(BlackHat 2008 발표자료)

5.   BOF_공격방지_매커니즘_구현의_최신_동향.pdf

6.   http://www.shell-storm.org/papers/files/732.pdf

7.   www.phreedom.org/presentations/reverse.../reverse-engineering-ani.pdf

8.   CanSecWest2010 – SEH Overwrite, Shuichiro Suzuki

9.   Windows 구조와 원리 (OS를 관통하는 프로그래밍 원리) - 정덕영



 

메모리 보호기법 우회 연구분석보고서 -1-


By. eloi@a3sc.co.kr
(A.K.A eloi)

jtsong@a3sc.co.kr
(A.K.A trynerr)


본 문서는 Stack Overflow 보호기법과 이를 우회하는 방법에 대하여 작성하였습니다. 해당 내용과 테스트 결과가 많은 관계로아래와 같은 주제로 3회에 걸쳐 연재하도록 하겠습니다.
 

1. 'Windows/Linux 환경에서의 Stack Overflow 보호기법'
2. 'ROP(Return Oriented Programming) Exploit'
3. 'SEH(Structed Exception Handling) Overwrite' 



Window
환경에서의 메모리 보호기법

1.  Window 버전별 메모리 보호기법

Window 버젼에서 실행되고 있는 메모리 보호기법입니다. 새로운 운영체제가 출시 때마다 발전된 메모리 보호기법을 확인할 있습니다.

 

XP

sp2, sp3

2003

sp1, sp2

Vista

sp0

Vista

sp1

2008

sp0

GS

Stack Cookies

Yes

Yes

yes

yes

Yes

Variable reordering

Yes

Yes

yes

yes

yes

#pragma strict_gs_check

No

No

no

yes

yes

SafeSEH

SEH handler

validation

Yes

Yes

yes

yes

yes

SEH chain

validation

No

No

no

yes

yes

Heap protection

Safe unlinking

Yes

Yes

yes

yes

yes

Safe lookaside lists

No

No

yes

yes

yes

Heap metadata

cookies

Yes

Yes

yes

yes

yes

Heap metadata

encryption

No

No

yes

yes

yes

DEP

NX support

Yes

Yes

yes

yes

yes

Permanent DEP

No

No

no

yes

yes

OptOut mode

by default

No

Yes

no

no

yes

ASLR

PEB, TEB

Yes

Yes

yes

yes

yes

Heap

No

No

yes

yes

yes

Stack

No

No

yes

yes

yes

images

No

No

yes

yes

yes

 


2.
메모리 보호기법 설명

(1) GS

GS Window 상에서 스택을 보호하는 기법으로, Visual Studio 2003버젼 이상에서 컴파일시 기본적으로 추가 되는 옵션입니다.

다음
화면은 Visual Studio 2010 상에서 확인한 GS 옵션입니다.

[그림 1] GS 옵션 설정

 ●  Stack Cookies

GS 옵션을 적용하게 되면 코드에 스택 체크 루틴이 추가됩니다. 컴파일러는 로컬 문자열 버퍼가 있는 함수의 BOF공격을 방지하기 위하여 검사를 합니다.

 

다음 화면은 BOF 공격이 발생하여 GS cookie 공격을 탐지하는 화면입니다.

[그림 2] BOF 탐지

 

GS옵션은 함수상에 로컬 문자열 버퍼가 있는경우 컴파일러는 쿠키(ret 변조를 막기위한 메모리공간) 추가하여 Buffer Ret 사이에 위치시켜 함수의 return 주소를 보호합니다.

[그림 3] stack cookie 구조

 

예를 들어 아래와 같은 코드가 있습니다. 먼저 왼쪽은 GS옵션을 사용하지 않은 경우 BOF 발생 가능한 소스코드입니다. 하지만 GS옵션을 사용할 경우 컴파일러가 자동으로 쿠키에 대한 코드를 추가로 넣습니다. 이로 인하여 RET 주소의 변조를 확인 가능합니다. 만약에 오버플로우가 일어나면 RET 앞에 위치한 cookie 값을 변조하게 됩니다.

이때 .data 영역에 저장된 cookie RET 앞에 위치한 cookie 비교하게 됩니다.  이때 쿠키가 변조된 것으로 판명되면 Abort()해서 스택오버플로를 방지하게 됩니다.

[GS 옵션 미적용]

void a3sc(char *input)

{

char buffer[256];

strcpy(buffer, input);

}

[GS 옵션 적용]

static_cookie = rand();

 

void a3sc(char *input)

{

int cookie = random_cookie;

 

char buffer[256];

strcpy(buffer, input);

 

if (cookie != random_cookie)

    abort();

}

 

(2) SafeSEH

SEH(Structured Exception Handling) Window 상에서 예외처리를 하는 기법입니다. DLL 상에 있는 SafeSEH 에서 존재하며 H/W, S/W 상에서의 예외처리가 가능합니다. 그리고 BOF 또는 메모리에 대한 손상이 발생이나 시스템이 예기치 않게 종료되는 이벤트 발생시, 프로그램에 대한 예외처리를 해주는 역할을 담당합니다.

 

SafeSEH 에러처리 레코드를 덮어쓰는 공격을 막기위한 기법입니다. SafeSEH 옵션을 지정후, 컴파일하게되면, 링커에서 안전한 예외 처리 목록을 생성하며, 이것은 헤더에 예외처리 목록에 포함됩니다. 만약 공격자가 예외처리 레코드를 덮어쓰게 되면 프로그램은 예외를 탐지하여 프로그램을 종료하게 됩니다.

 

다음 화면은 Visual Studio 2010상에서 SafeSEH 옵션을 설정하는 화면입니다.

[그림 4] SafeSEH 옵션

 

(3)  ASLR(Address Space Layout Randomization)

ASLR 프로세스내에서 매핑되는 오브젝트에 대하여 호출 실행시 실행하는 주소를 랜덤화하는 기법입니다. ASLR 매핑된 파일들을 , 스택, PEB, TEB 위치상에서   랜덤화를 적용합니다. 공격자는 BOF 공격을 시도하더라도, 오브젝트에 대한 정확한 주소를 알지 못하므로 BOF 공격을 실패하게 됩니다.

 

다음 화면은 링커의 속성에서 ASLR 옵션을 설정하는 화면입니다.

[그림 5] ASLR 옵션

 

다음은 간단한 소스를 통하여 ASLR 기능을 확인해보았습니다.

#include <stdio.h>

 

void main()

{

    char buffer[256];

    printf("buffer address: %p\n", buffer);

}

 


다음
화면은 ASLR 옵션을 적용하지 않았을 때의 프로그램 실행화면입니다. 프로그램을 실행할 때마다 Buffer 주소가 같음을 있습니다.

[그림 6] ASLR 옵션 미적용

 

다음 화면은 ASLR 옵션을 적용하여 프로그램을 실행한 화면입니다. 위의 화면과는 다르게 프로그램을 실행할 때마다, 주소값이 달라짐을 확인 가능합니다.

[그림 7] ASLR 옵션 적용

 

(4) DEP(Data Excution Prevention)

DEP 가상 메모리의 최소 단위인 페이지에 기존에 읽고 쓰는 권한 외에 실행 권한에 대해서 체크하도록하여 메모리 공격으로부터 시스템을 보호하는 방법입니다.

기본적으로 DEP 공격자가 stack, heap, data section에서 shellcode 실행하는 것을 금지합니다. 예를들어 DEP 기능이 활성화 되어 있을 , 악의적인 코드가 실행하는 시점에서 해당 영역에서 실행권한이 없으므로 예외가 발생하여 공격을 막을 있습니다.

 

다음 화면은 Window7에서 DEP 옵션을 설정하는 화면입니다.

[그림 8] DEP 옵션



Linux 환경에서의 메모리 보호기법

1. Linux 버전별 메모리 보호기법

 

ASLR

N/X(DEP)

ASCII

Armor

main()

canary

S

H

L

S

H

L

 

 

Red Hat

Linux9.0

O

X

X

X

X

X

X

X

Fedora

8 ~ 10

O

O

X

O

O

X

O

O

Fedora

11

O

O

X

O

O

O

O

X

Fedora

12

O

O

O

O

O

O

O

X

Cent OS

4.4

O

O

X

O

O

X

O

X

Cent OS

 4.5~4.8

O

O

O

O

O

X

O

X

Cent OS

5.0~5.4

O

O

O

O

O

X

O

O

Ubuntu

6.10~ 8.04.1

O

X

O

X

X

X

X

O

Ubuntu

8.10~ 9.0.4

O

O

O

X

X

X

X

O

Ubuntu

9.10

O

O

O

O

O

X

O

X

openSUSE 11.2

O

X

O

X

X

X

X

X

Gentoo 2006.0

O

X

O

X

X

X

X

X

Gentoo 2007.0

O

X

O

X

X

X

X

O

             (S : Stack, H : Heap, L : Library)

 


2.
메모리
보호 기법

(1) ASLR(Address Space Layout Randomization)

메모리상의 공격을 방어하기 위해 주소 공간배치를 난수화 시키는 기법입니다. , 스택, , 라이브러리 등의 데이터 영역 주소등을 난수화 시킨 주소로 프로세스의 주소 공간에 배치하는것입니다. Window 에서 적용되는것과 유사한 기법이며 리눅스 커널 2.6.12이후로 적용되어있습니다

 

다음은 Fedora 13에서 현재 프로세서상에서 메모리구조를 확인하는 화면입니다.

ASLR 적용으로 인하여 메모리상에 존재하는 주소가 지속적으로 변함을 있습니다.

[그림 9] ASLR

 

(2) DEP / NX(Not Excutable)

메모리상의 보호를 위해 stack heap에서 코드가 실행되는 것을 막는 기법입니다.

공격자가 BOF 공격을 일으키면 DEP 적용된 상태에서는 실행권한이 없으므로 프로그램에 대한 예외처리후, 종료가 됩니다.

 

다음은 Fedora 13에서 현재 프로세서상에서 메모리구조를 확인하는 화면입니다.

DEP 적용으로 인하여 stack, heap, libc 영역에 실행권한이 존재하지 않음을 확인 가능합니다.

[그림 10] DEP

 

(3) ASCII-Armor

Libc 영역을 보호하기 위한 기법으로 상위주소를 \x00으로 시작하게 만드는 기법으로 공격자는 라이브러리를 호출하는 BOF 공격시, NULL 바이트가 삽입된 주소로 접근 없게됩니다.

[그림 11] ASCII-Armor

 

(4) Canary

canary Window 에서의 메모리 보호 기법인 stack cookie 같은 개념으로 Buffer RET 사이에서 스택의 BOF 모니터링하는 역할을 담당합니다. BOF 발생하면 canary 데이터의 변조로 인하여 오버플로우에 대한 경고하고 프로그램을 종료시킵니다.

 

 l  Terminator canaries

문자열 끝문자를 이용하여 canary 구성하는 방법으로 canary 값으로 NULL, CR, LF, Oxff 값의 조합이 사용됩니다. 공격자는 공격시, 종료문자로 구성된 canary 값에 접근을 없게됩니다.


l  Random canary

프로그램을 실행할 때마다 임의의 canary 값을 삽입을 합니다. 이에 따라 공격자는

Canary 값을 예측불가능하므로 공격에 어려움이 발생합니다.


l  Null canary(0x00000000)

메모리상의 공격을 막기위해 canary 값을 NULL 구성합니다. 공격자는 공격코드상에 NULL 값을 삽입할 없으므고 canary 값에 접근이 불가능합니다.


 

다음 화면은 canary 적용되지 않은 프로그램을 분석한 화면입니다.

[그림 12] Canary 미적용

 

다음 화면은 canary 적용된 프로그램을 분석한 화면입니다.  GDB 분석결과 메모리상에서 canary 대한 영역이 설정된 , buffer 구조가 설정되는 것을 확인 있습니다.

[그림 13] Canary 적용

 


참고 URL

1.   http://msdn.microsoft.com

2.   http://x82.inetcop.org/

3.   http://nchovy.kr/forum/5/article/377

4.   http://en.wikipedia.org/wiki/Buffer_overflow_protection

5.   http://ko.wikipedia.org/wiki/버퍼 오버플로우

6.   http://lucid7.egloos.com/

7.   http://uptx.egloos.com/

 

 

참고 문헌

1.   poc09-sotirov.pdf(POC 2009 발표자료)

2.   BHUS10_Paper_Payload_already_inside_data_reuse_for_ROP_expl.pdf

(BlackHat 2010 USA 발표자료)

3.   Linux Memory Protectiion Mechanism

4.   bh08sotirovdowd.pdf(BlackHat 2008 발표자료)

5.   BOF_공격방지_매커니즘_구현의_최신_동향.pdf

6.   http://www.shell-storm.org/papers/files/732.pdf

7.   www.phreedom.org/presentations/reverse.../reverse-engineering-ani.pdf

8.   CanSecWest2010 – SEH Overwrite, Shuichiro Suzuki

9.   Windows 구조와 원리 (OS를 관통하는 프로그래밍 원리) - 정덕영


OWASP TOP 10에 대해서 WebGot 등을 이용하여 테스트 환경에서 보여주고 있는 동영상들입니다.

 

URL을 통해 들어가면 더 많은 동영상을 볼 수 있습니다.

 

URL : http://www.youtube.com/view_play_list?p=04732F5EE5F80FD4

 

2011년 전후로 해서 최근 잼난 동영상들 링크입니다. 학습하는데 도움 되시기 바랍니다.

http://securitytube.net/Malware-Unpacking-in-OllyDbg-video.aspx
(Malware-Unpacking-in-OllyDbg-video)
http://vimeo.com/18645356 (XSSF - Stealing ANDROID SD Card files)
http://www.youtube.com/watch?v=q31Q-nEUqok (Thumbnail Vuln Demo by 6l4ck3y3)
http://www.blip.tv/file/4640708 (PDF Advanced Forensics Analysis)
http://vimeo.com/18821178 (Reverse Engg. Demonstration)
http://vimeo.com/6089466  (The art of Exploitation )
http://vimeo.com/6431352 (exploits internal working )
http://vimeo.com/6460509 (Antivirus Bypassing )
http://vimeo.com/6473218 (bypassing Av using metasploit )
http://vimeo.com/6757328 (Social Engg. Attacks)
http://vimeo.com/6987936 (Multilevel Attack with java applet)
http://vimeo.com/7613487 (Metasploit and Antivirus )
http://vimeo.com/8561768 (Remote buffer overflow tutorial)
http://vimeo.com/14139105 (Injecting code into a process plus bypass AV)
http://vimeo.com/14404326 (DLL Hijacking Exploits )