Upload
npthanh
View
12
Download
0
Embed Size (px)
Citation preview
ASA chặn truy cập Web (Advanced Inspection HTTP)Bùi Nguyễn Hoàng LongVnPro
Dùng ASA chặn truy cập Web (Advanced Inspection HTTP)
I. Mô tả:Thực hiện inspect http với yêu cầu: không cho phép truy cập vào những trang web: nhacso.net, nghenhac.info, mp3.zing.vn, nhac.vui.vn
Thực hiện inspect icmp cho phép nhận icmp echo reply trở về mà không cần cấu hình ACL
II. Cấu hìnhASA(config)# no nat-control
Tạo giá trị regex:ASA(config)# regex URL_1 "nhacso\.net"ASA(config)# regex URL_2 "nghenhac\.info"ASA(config)# regex URL_3 "mp3\.zing\.vn"ASA(config)# regex URL_4 "nhac\.vui\.vn"
Kiểm tra regex định nghĩa hợp lệASA(config)# test regex www.nhacso.net "nhacso\.net"INFO: Regular expression match succeeded.
Cấu hình class-map để kết hợp những regex vào cùng lớpASA(config)# class-map type regex match-any URLASA(config-cmap)# match regex URL_1ASA(config-cmap)# match regex URL_2ASA(config-cmap)# match regex URL_3ASA(config-cmap)# match regex URL_4
Định nghĩa class-type inspect cho http (class-map lớp 7)ASA(config)# class-map type inspect http HTTP
Thực hiện điều kiện matchASA(config-cmap)# match request header host regex class URL
Định nghĩa policy-map type inspect cho http (policy-map lớp 7)ASA(config)# policy-map type inspect http HTTPASA(config-pmap)# class HTTP
Xác định hành động khi điều kiện so khớpASA(config-pmap-c)# reset log
Định nghĩa class-map lớp 3&4
ASA(config)# class-map HTTP_TRAFFICASA(config-cmap)# match port tcp eq 80
Định nghĩa policy-map lớp 3&4ASA(config)# policy-map HTTP_POLICYASA(config-pmap)# class HTTP_TRAFFIC
Kết hợp policy-map lớp 7 vào ASA(config-pmap-c)# inspect http HTTP
Gán policy-map lớp 3&4 lên cổng insideASA(config)# service-policy HTTP_POLICY interface inside
Thực hiện inspect icmp, để giám sát trạng thái của icmp cho phép echo reply trả về mà không cần ACLASA(config)# policy-map global_policyThực hiện inspect trong class inspection_defaultASA(config-pmap)# class inspection_defaultASA(config-pmap-c)# inspect icmp
III. Cấu hình đầy đủ
GATEWAY!hostname GATEWAY!!interface FastEthernet0/0ip address 192.168.2.2 255.255.255.0ip nat insideip virtual-reassemblyduplex autospeed auto!interface FastEthernet0/1ip address dhcpip nat outsideip virtual-reassemblyduplex autospeed auto!ip route 192.168.1.0 255.255.255.0 192.168.2.1!ip http serverno ip http secure-serverip nat inside source list 1 interface FastEthernet0/1 overload!access-list 1 permit 192.168.1.0 0.0.0.255access-list 1 permit 192.168.2.0 0.0.0.255!
ASA!hostname ASAenable password 8Ry2YjIyt7RRXU24 encrypted
names!interface Ethernet0/0nameif insidesecurity-level 100ip address 192.168.1.1 255.255.255.0!interface Ethernet0/1nameif outsidesecurity-level 0ip address 192.168.2.1 255.255.255.0!interface Ethernet0/2shutdownno nameifno security-levelno ip address!interface Ethernet0/3shutdownno nameifno security-levelno ip address!interface Management0/0shutdownno nameifno security-levelno ip addressmanagement-only!passwd 2KFQnbNIdI.2KYOU encryptedregex URL_1 "nhacso\.net"regex URL_2 "nghenhac\.info"regex URL_3 "mp3\.zing\.vn"regex URL_4 "nhac\.vui\.vn"ftp mode passiveno failovericmp unreachable rate-limit 1 burst-size 1no asdm history enablearp timeout 14400route outside 0.0.0.0 0.0.0.0 192.168.2.2 1timeout xlate 3:00:00!class-map HTTP_TRAFFICmatch port tcp eq wwwclass-map type regex match-any URLmatch regex URL_1match regex URL_2match regex URL_3match regex URL_4class-map type inspect http match-all HTTPmatch request header host regex class URLclass-map inspection_defaultmatch default-inspection-traffic
!!policy-map type inspect dns preset_dns_mapparametersmessage-length maximum 512policy-map type inspect http HTTPparametersclass HTTPreset logpolicy-map HTTP_POLICYclass HTTP_TRAFFICinspect http HTTP policy-map global_policyclass inspection_defaultinspect dns preset_dns_mapinspect ftpinspect h323 h225inspect h323 rasinspect rshinspect rtspinspect esmtpinspect sqlnetinspect skinnyinspect sunrpcinspect xdmcpinspect sipinspect netbiosinspect tftpinspect icmp !service-policy global_policy globalservice-policy HTTP_POLICY interface insideprompt hostname contextCryptochecksum:5c95986550b4487314e418bb01c2f180: end
IV. Kiểm traĐảm bảo tính năng logging được kích hoạt để cho phép hiển thị log
ASA(config)# logging onASA(config)# logging console notifications
Thực hiện truy cập web với những URL được địng nghĩa trong regex
%ASA-5-415008:HTTP - matched Class 22: HTTP in policy-map HTTP, header matched - Resetting connection from inside:192.168.1.2/1193 to outside: 123.30.51.29/80%ASA-5-304001: 192.168.1.2 Accessed URL 123.30.51.29:/
%ASA-5-415008: HTTP - matched Class 22: HTTP in policy-map HTTP, header matched - Resetting connection from inside:192.168.1.2/1199 to outside: 222.255.122.16/80%ASA-5-304001: 192.168.1.2 Accessed URL 222.255.122.16:/
Tất cả các kết nối sẽ bị reset, việc truy cập không thành công. Tuy nhiên những URL không nằng trong phần regex sẽ vẫn truy cập bình thường
Nhận echo-reply mà không ACL
ASA(config)# sh conn1 in use, 17 most usedICMP out 69.89.22.108:0 in 192.168.1.2:1024 idle 0:00:00 bytes 32
ASA(config)# sh service-policy interface inside inspect http
Interface inside:Service-policy: HTTP_POLICYClass-map: HTTP_TRAFFICInspect: http HTTP, packet 479, drop 7, reset-drop 7protocol violationspacket 0class HTTPreset log, packet 7