security bootcamp 2013 penetration testing (basic)

99
Lương Trung Thành| Oct 25-27, 2013 [email protected] BASIC PENETRATION TESTING

Upload: security-bootcamp

Post on 02-Jun-2015

1.640 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Security Bootcamp 2013   penetration testing (basic)

Lương Trung Thành| Oct 25-27, [email protected]

BASIC PENETRATIONTESTING

Page 2: Security Bootcamp 2013   penetration testing (basic)

Đơn vị tổ chức:

Đơn vị tài trợ:

Page 3: Security Bootcamp 2013   penetration testing (basic)

ABOUT ME

Page 4: Security Bootcamp 2013   penetration testing (basic)

MỤC ĐÍCHCung cấp khái niệm và kỹ năng cơ bản về

pentest System, Web, Application. Hướngdẫn quy trình cơ bản thực hiện pentest.Định hướng cách học và nghiên cứu kỹ năng

chuyên sâu.Chia sẻ kinh nghiệm và khó khăn thực tế.

Page 5: Security Bootcamp 2013   penetration testing (basic)

NỘI DUNGA.Tổng quan về PentestB.Giới thiệu BacktrackC.Thu thập thông tin (Information

Gathering)D.System PentestE.Website PentestF.Software Pentest

Page 6: Security Bootcamp 2013   penetration testing (basic)
Page 7: Security Bootcamp 2013   penetration testing (basic)

A. Tổng quan về PentestI. Khái niệmII.Các yêu cầuIII.Phân loạiIV.Các giai đoạn PentestPre-attackAttackPost-attack

Page 8: Security Bootcamp 2013   penetration testing (basic)

I. Khái niệmPentestration Testing (Pentest) là tiến

trình giả lập tấn công các đối tượngtrong hệ thống CNTT với mục đích tìmlỗi để kiện toàn hệ thống.Pentest khác với Vulnerability

Assessments.Pentest không thực hiện “chuyên

nghiệp” có thể dẫn đến rủi ro cho hệthống.

Page 9: Security Bootcamp 2013   penetration testing (basic)

II. Các yêu cầuVăn bản phê duyệt thực hiện pentest.Xác định, thống nhất phạm vi và mục

tiêu pentest.Thỏa thuận “Bảo hiểm trách nhiệm”.Thực hiện Service level agreements

(SLAs).

Page 10: Security Bootcamp 2013   penetration testing (basic)

III. Phân loại

Page 11: Security Bootcamp 2013   penetration testing (basic)

Black-box PentestKhông được cung cấp trước thông tin.Mô phỏng quá trình tấn công của một

hacker thực sự.Tốn thời gian và là loại kiểm tra tốn

kém.Ưu điểm:Là kiểu kiểm tra toàn diện, mang tính thực

tế cao.

Page 12: Security Bootcamp 2013   penetration testing (basic)

White-box PentestCung cấp đầy đủ thông tin.Mô phỏng quá trình kiểm tra của nhân viên

công ty.Thông thường chỉ kiểm tra một đối tượng

hoặc một kiểu tấn công cụ thể.Ưu điểm:Cho thấy nhiều lỗ hỏng và ít tốn thời gian hơnĐánh giá đầy đủ và có chiều sâu.

Page 13: Security Bootcamp 2013   penetration testing (basic)

Grey-box PentestCung cấp thông tin hạn chế.Kết hợp giữa Black-box and White-box.

Page 14: Security Bootcamp 2013   penetration testing (basic)

IV. Các giai đoạn Pentest

Page 15: Security Bootcamp 2013   penetration testing (basic)

IV. Các giai đoạn Pentest (tt)Giai đoạn Pre-AttackDo thám, thu thập, ghi nhận thông tin của hệ

thống.Các hoạt động:

• Footprinting.

• Scanning and Enumeration.

• Vulnerability Analysis.

Page 16: Security Bootcamp 2013   penetration testing (basic)

IV. Các giai đoạn Pentest (tt)Giai đoạn Pre-AttackCác thông tin thu thập được:

• Domain, email address, website, contact.• Live systems, open/filtered port, mapping

router, firewall rules.• Operating system details.• User’s information, authentication

credentials.• …

Page 17: Security Bootcamp 2013   penetration testing (basic)

IV. Các giai đoạn Pentest (tt)Giai đoạn AttackTìm và khai thác lỗi, nâng quyền và thực thi

các tác vụ kiểm soát hệ thống.Các hoạt động:

• Exploitation.• Privilege Escalation.• Maintaning Access.• Cover Track.

Page 18: Security Bootcamp 2013   penetration testing (basic)

IV. Các giai đoạn Pentest (tt)Giai đoạn Post-AttackĐây là gian đoạn phục hồi hệ thống trở về

hiện trạng ban đầu. Các hoạt động:• Xóa các rootkits, backdoor.• Dọn sạch registry.• Xóa các tool, exploited vulnerabilies.• Xóa các dịch vụ chia sẻ và các kết nối.

Page 19: Security Bootcamp 2013   penetration testing (basic)

IV. Các giai đoạn Pentest (tt)Giai đoạn Post-AttackLập báo cáo các sự cố xảy ra, các hoạt

động thực hiện trong quá trình pentest.Lập báo cáo đánh giá và đưa ra các

khuyến cáo, giải pháp khắc phục rủi ro.

Page 20: Security Bootcamp 2013   penetration testing (basic)
Page 21: Security Bootcamp 2013   penetration testing (basic)

Backtrack là gì ?Được phát triển dựa trên bản phân phối

Debian GNU/Linux với mục đích pentestvà forensic.Là sự hợp nhất công cụ của 2 bản phân

phối pentest nổi tiếng: WHAX, Auditor.Hỗ trợ Live DVD và Live USB.Tháng 3/2013, phát hành phiên bản mới

với tên gọi là Kali Linux.

Page 22: Security Bootcamp 2013   penetration testing (basic)

Các công cụ trên BacktrackĐược sắp xếp thành 12 loại:

Page 23: Security Bootcamp 2013   penetration testing (basic)

Demo Backtrack

Page 24: Security Bootcamp 2013   penetration testing (basic)

SYSTEM PENTEST

Page 25: Security Bootcamp 2013   penetration testing (basic)
Page 26: Security Bootcamp 2013   penetration testing (basic)

I. FootprintingFootprinting là kỹ thuật truy vết, thu thâp

thông tinCác thông tin: Phiên bản ứng dụng. Các dịch vụ. Sơ đồ hệ thống, mạng. Dịch vụ DNS. Các lỗi, lỗ hổng.

Page 27: Security Bootcamp 2013   penetration testing (basic)

I. Footprinting (tt)Thông tin tổ chức: Sơ đồ tổ chức công ty Địa chỉ, số điện thoại Thông tin cá nhân nhân viên …

Page 28: Security Bootcamp 2013   penetration testing (basic)

I. Footprinting (tt)Thông tin Network: Domain name Internal domain names Network blocks IP addresses TCP & UDP services …

Page 29: Security Bootcamp 2013   penetration testing (basic)

I. Footprinting (tt)Thông tin System: User and group names Sytem banners Sytem architecture Sytem names Passwords SMTP information …

Page 30: Security Bootcamp 2013   penetration testing (basic)

I. Footprinting (tt)Các kỹ thuật sử dụng:Google HackingEmail HarvestingTìm thông tin DomainDNS ReconnaissanceSMNP ReconnaissanceSao chép Website

Page 31: Security Bootcamp 2013   penetration testing (basic)

Google Hacking Tìm thư mục quản trị:

• intile:index.of.admin Tìm file log:

• filetype:log inurl:ws_ftp.log Tìm phiên bản server:

• intitle:index.of “server at” Tìm file backup web:

• intitle:index.of index.php.bak Tìm lỗi:

• intile:”Antichat Shell” “disable functions”

Page 32: Security Bootcamp 2013   penetration testing (basic)

Google Hacking (tt)

Google Hacking DatabaseWebsite

Page 33: Security Bootcamp 2013   penetration testing (basic)

Google Hacking (tt)

Google Hacking DatabaseWebsite

Page 34: Security Bootcamp 2013   penetration testing (basic)

Google Hacking Tool

Page 35: Security Bootcamp 2013   penetration testing (basic)

Email Harvesting Theharvester

Page 36: Security Bootcamp 2013   penetration testing (basic)

Tìm thông tin DomainWhois

Page 37: Security Bootcamp 2013   penetration testing (basic)

Tìm thông tin DomainWhois Thông tin thu được:

Page 38: Security Bootcamp 2013   penetration testing (basic)

Tìm thông tin Domain (tt)Whois Thực hiện reverse lookup:

Page 39: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance Nslookup Domain

checkpoint.com có địa chỉ216.200.241.66

Page 40: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt) Nslookup - MX Queries

Page 41: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt) Nslookup - NS Queries

Page 42: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt) Forward Lookup Brute Force Dùng lệnh host để kiểm tra domain www.checkpoint.com phân giải được => tồn

tại nosub.checkpoint không phân giải được =>

không tồn tại.

Page 43: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt) Forward Lookup Brute Force Tạo script để kiểm tra tự động

Page 44: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt) Forward Lookup Brute Force Thông tin thu được:

Page 45: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt) Reverse Lookup Brute Force Thông tin thu được:

Page 46: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt) DNS Zone Transfers Là quá trình database replication giữa các

DNS server. Nếu cấu hình không đúng có thể bị khai thác

thông tin.

Page 47: Security Bootcamp 2013   penetration testing (basic)

DNS Reconnaissance (tt)

DNSenum

Page 48: Security Bootcamp 2013   penetration testing (basic)

SNMP Reconnaissance

Enumerating Windows Users

Page 49: Security Bootcamp 2013   penetration testing (basic)

SMNP Reconnaissance (tt) Enumerating Running Services

Page 50: Security Bootcamp 2013   penetration testing (basic)

SNMP Reconnaissance (tt)

Enumerating Open TCP Ports snmpwalk –c public –v1 <IP address> 1

|grep tcpConnState |cut –d”.” –f6 |sort –nu Enumerating Installed Software snmpwalk -c public -v1 <IP address> 1 |grep

hrSWInstalledName

Page 51: Security Bootcamp 2013   penetration testing (basic)

SNMP Reconnaissance (tt) Công cụ kiểm tra tự động: Snmpenum Snmpcheck

Page 52: Security Bootcamp 2013   penetration testing (basic)

Microsoft NetBIOS InformationGathering

Null sessions http://en.wikipedia.org/wiki/NetBIOS http://www.securityfriday.com/Topics/winxp2.

html http://www.securityfriday.com/Topics/restricta

nonymous.html

Page 53: Security Bootcamp 2013   penetration testing (basic)

Microsoft NetBIOS InformationGathering (tt)

Scanning for the NetBIOS Service nbtscan smbserverscan

Page 54: Security Bootcamp 2013   penetration testing (basic)

Microsoft NetBIOS InformationGathering (tt)

Enumerating Username/PasswordPolicies samrdump

Page 55: Security Bootcamp 2013   penetration testing (basic)

Sao chép Website HTTrack

Page 56: Security Bootcamp 2013   penetration testing (basic)

II. ScanningScanning để xác định:Các host đang hoạt động trên hệ thống

mạng.Các ports, services đang chạy trên host.Các lỗi tìm ẩn có thể khai thác.

Page 57: Security Bootcamp 2013   penetration testing (basic)

II. Scanning (tt)Phân loại :Network Scanning.Port Scanning.Vulnerability Scanning.

Page 58: Security Bootcamp 2013   penetration testing (basic)

Network ScaningĐể kiểm tra tình trạng hoạt động của hostGửi ICMP ECHO requests đến host. Nếu host đang

hoạt động trên hệ thống mạng, sẽ trả về ICMP

ECHO reply.

Để xác định firewall có lọc gói ICMP không

Page 59: Security Bootcamp 2013   penetration testing (basic)

Network Scaning (tt) Ping Sweep Ping Sweep dùng để kiểm

tra đồng thời tình trạng hoạtđộng của nhiều host từ mộtdãy IP addreeses.

Ping Sweep gửi nhiều góiICMP ECHO requests đếnnhiều host. Nếu host nàođang hoạt động, sẽ trả vềICMP ECHO reply.

Sử dụng Ping Sweep đểthống kê các host đang hoạtđộng trên hệ thống mạng.

Page 60: Security Bootcamp 2013   penetration testing (basic)

Tree-way Handshake Client gửi gói

SYN khởi tạokết nối.

Server nhận góiSYN và gửi lạigói SYN/ACK.

Client nhận góiSYN/ACK vàgửi lại gói ACK.

Page 61: Security Bootcamp 2013   penetration testing (basic)

TCP Communication Flags

Page 62: Security Bootcamp 2013   penetration testing (basic)

Port ScanningTCP Connect/Full Open Scan

TCP Connect scan phát hiện port mở bằng cách hoàntất các bước Tree-way handshake.

TCP Connect scan thiết lập kết nối đầy đủ và ngắt kếtnối bằng cách gửi gói RST.

Page 63: Security Bootcamp 2013   penetration testing (basic)

Port Scanning (tt)

Stealth Scan (Half-open Scan)– Client gửi gói SYN (trên 1 port cụ thể)

• Nếu port mở, Server gửi trả gói SYN/ACK.• Nếu port đóng, Server gửi trả gói RST.

– Client gửi gói RST để ngắt kết nối.

Page 64: Security Bootcamp 2013   penetration testing (basic)

Port Scanning (tt)UDP ScanningKhông dựa trên cơ chế Three-way TCP

handshake.Không trả về thông điệp nếu port mở.Trả về thông điệp “ICMP port unreachable

message” nếu port đóng.

Page 65: Security Bootcamp 2013   penetration testing (basic)

OS FingerprintingOS Fingerprinting là kỹ thuật xác định

phiên bản hệ điều hành.Có 2 loại:

– Active.– Passive.

Page 66: Security Bootcamp 2013   penetration testing (basic)

OS Fingerprinting (tt) Nmap

Page 67: Security Bootcamp 2013   penetration testing (basic)

Service Fingerprinting Nmap

Page 68: Security Bootcamp 2013   penetration testing (basic)

Nmap Scripting Engine Script mở rộng, hỗ

trợ Nmap thực thitự động một số tácvụ (DNSenumeration, bruteforce, xác địnhvulnerability,…)

Đường dẫn scripttrong BT“/usr/local/share/nmap/scripts”

Page 69: Security Bootcamp 2013   penetration testing (basic)

Vulnerability ScanningVulnerability Scanning là kỹ thuật xác

định lỗi và điểm yếu.Công cụ quét:

– Nessus– Saint– OpenVAS

Page 70: Security Bootcamp 2013   penetration testing (basic)

Vulnerability Scanning (tt) OpenVAS Nessus

Page 71: Security Bootcamp 2013   penetration testing (basic)

Network MappersMaltego

Page 72: Security Bootcamp 2013   penetration testing (basic)

Network Mappers (tt)LANsurveyor

Page 73: Security Bootcamp 2013   penetration testing (basic)

Network Mappers (tt)

Page 74: Security Bootcamp 2013   penetration testing (basic)

Scanning Pentest

Page 75: Security Bootcamp 2013   penetration testing (basic)

Scanning Pentest (tt)

Page 76: Security Bootcamp 2013   penetration testing (basic)
Page 77: Security Bootcamp 2013   penetration testing (basic)

D. System PentestI. SniffingII.Passwork AttackIII.Exploit FrameworkIV.Privilege EscalationV.Maintaning AccessVI.Cover TrackVII.Transfering filesVIII.Lab

Page 78: Security Bootcamp 2013   penetration testing (basic)

I. SniffingARP poisoning

Page 79: Security Bootcamp 2013   penetration testing (basic)

I. Sniffing (tt) Ettercap

Page 80: Security Bootcamp 2013   penetration testing (basic)

II. Passwork Attack Các kỹ thuật crack password:

Page 81: Security Bootcamp 2013   penetration testing (basic)

II. Passwork Attack (tt) Phân loại: Online Password Attacks.

(Passive or Active) Offline Password Attacks. Physical Access Attacks. Memory Password Attacks. Non-Electronic Attacks.

Page 82: Security Bootcamp 2013   penetration testing (basic)

Passive Online AttacksSử dụng các công cụ bắt dữ liệu trên

đường truyền.Dữ liệu là password gửi từ client đến các

hệ thống truy cập từ xa(FTP, Mail,rlogin,…).Các kỹ thuật: MITM, Relay Attack.

Page 83: Security Bootcamp 2013   penetration testing (basic)

Active Online AttacksTạo ra một dictionary (username,

password) và cố gắng thử từngusername, password trong dictionary.Sử dụng Trojan/Spyware/Keylogger.

Page 84: Security Bootcamp 2013   penetration testing (basic)

Active Online Attacks (tt) xHydra Username List:

/pentest/web/wfuzz/wordlist/fuzzdb/wordlists-user-passwd/names/nameslist.txt

Password List:/pentest/web/wfuzz/wordlist/fuzzdb/wordlists-user-passwd/passwds/john.txt

Page 85: Security Bootcamp 2013   penetration testing (basic)

Active Online Attacks (tt)Medusa

Page 86: Security Bootcamp 2013   penetration testing (basic)

Offline Password AttacksWindows SAM Window lưu thông tin tài

khoản trong SecurityAccounts Manager(SAM) database

File SAM có thể tìmthấytại.%SYSTEMROOT%\sytem32\config.

Bản backup tại%SYSTEMROOT%\repair.

Page 87: Security Bootcamp 2013   penetration testing (basic)

Offline Password Attacks (tt)PWdump và Fgdump Window hash dumping lấy password hash trong

HKEY_LOCAL_MACHINE\Security\SAM\Domains\Account\Users

Page 88: Security Bootcamp 2013   penetration testing (basic)

Offline Password Attacks (tt)John The

Ripper JTR’s cracking

modes:• Wordlist mode• Single crack

mode• Incremental

mode• External mode

Page 89: Security Bootcamp 2013   penetration testing (basic)

III. Exploit FrameworkMetasploit

Page 90: Security Bootcamp 2013   penetration testing (basic)

III. Exploit Framwork (tt) Fast-Track

Page 91: Security Bootcamp 2013   penetration testing (basic)

III. Exploit Framework (tt) Armitage

Page 92: Security Bootcamp 2013   penetration testing (basic)

III. Exploit Framework (tt)Metasploit (Web GUI)

Page 93: Security Bootcamp 2013   penetration testing (basic)

IV. Privilege EscalationIncognito

Page 94: Security Bootcamp 2013   penetration testing (basic)

IV. Privilege Escalation (tt)Social-Engineer Toolkit (SET)

Page 95: Security Bootcamp 2013   penetration testing (basic)

V. Maintaning AccessPersistent Backdoor

Page 96: Security Bootcamp 2013   penetration testing (basic)

VI. Cover TrackExploitation script “IRB”

Page 97: Security Bootcamp 2013   penetration testing (basic)

VII. Transfering filesThe Non-interactive Shell“Không chạy chương trình Interactive trên

Remote Shell”Uploading filesTFTP (non-interactive command)FTP (interactive command)

Page 98: Security Bootcamp 2013   penetration testing (basic)

VIII. LABMục tiêu: Kioptrix Level 1Các bước thực hiện:Port Scanning, OS Fingerprinting : NmapServices Fingerprinting: Netcat, Ncat, smbclientExploit: Exploit-DBFiles transfer: TFTP, pure-ftpdPassword Cracking: JTRMetasploit

Page 99: Security Bootcamp 2013   penetration testing (basic)

Q & A