Introduction
How does it work?
How to apply the patch?
How to use it?
Patch limitation (or features)
License
Files modified
ICMP is mainly used in two situations:
Note: The PatchICMP is a set of sed script, trying to do the right thing on the version (4.0 SP3, 4.1) I have tested. You may want, instead of running it, to read it and manually apply the changes, especially if you have a customize version of base.def or fwui_head.def.
: (pingstateful
:color ("dark orchid")
:type (Other)
:comments ("Stateful ICMP")
:exp ("icmp, icmp_type=ICMP_ECHO")
:prolog ("ping_stateful_eitherbound;")
:prematch ()
)
For enabling ICMP stateful error, add icmperror_stateful in
the prolog of an active service defined as other services. For example, in a firewall where the property
Apply Gateway Rules to Interface Direction matched Eitherbound,
and if you have defined the pingstateful service as explained above, use the following prologue to enable stateful
ping and ICMP stateful error messages :
ping_stateful_eitherbound; icmperror_stateful;. In your object file, it will looks like:
: (pingstateful
:color ("dark orchid")
:type (Other)
:comments ("Stateful ICMP")
:exp ("icmp, icmp_type=ICMP_ECHO")
:prolog ("ping_stateful_eitherbound; icmperror_stateful;")
:prematch ()
)
ICMP INSPECT SCRIPT
This code is under BSD license:
Copyright (c) 2000, Jean Chouanard , Xerox - PARC
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
Neither name of the Xerox-PARC nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This code is originally based of Checkpoint stateful_icmp function defined in base.def
and from the code of William D. Burns (shadow@netscape.com),
http://people.netscape.com/shadow/work/inspect/index.html
It was modify to:
- restrict ICMP request to echo-request
- restrict ICMP replies to echo-reply
- check the icmp sequence (From the code of William D. Burns)
- Delete entries from the icmp table when a match is found
to limit ICMP reply to *one* packet (From the code of William D. Burns)
- the recording of the outgoing accepted ICMP request in the ICMP connection table is
done in the CONN_RECORD macro so that only accepted request will be recorded.
- Offer to accept ICMP error code related to existing UDP TCP or ICMP connections
as an option
+ // + // The Following are use to control the ICMP Stateful code: + // ICMPSTATE: if not defined, no change are done to the existing code + // ICMPSTATEDEBUG: will print extra logs useful for debugging + // + // #define ICMPSTATE + // #define ICMPSTATEDEBUG +
+ #ifdef ICMPSTATE
+ #include "icmpstate.def"
+ #endif /* ICMPSTATE */
+
+
deffunc RECORD_CONN(rule) {
#ifdef TCP_FASTMODE_ACTIVE
(tcp, dport in tcp_fastmode_services)
or
#endif
(
(
(rule & 0xffffff00) = 0xffffff00,
set sr3 ((sr3 & 0xffff00ff)|((rule & 0x000000ff) << 8)),
set sr4 0
) or (
set sr3 (sr3 | 0x0000ff00),
set sr4 rule
),
#ifndef NO_ENCRYPTION_FEATURES
ACCEPT_CLIENT_ENCRYPTION(sr4)
or
#endif
(<conn> in connections)
or
(<rconn> in connections)
or
#ifndef NO_ENCRYPTION_FEATURES
#if ACCEPT_DECRYPT_ENABLE
(direction = 0, ACCEPT_DECRYPT(sr4))
or
(
#else
(IS_NOT_DECRYPTED(sr4),
#endif
#else
(
#endif
(tcp,
(
established, WAS_ENCRYPTED, drop
) or (
tcp_record_ok,
NOT_TCP_FASTMODE_PORT(sport,sr4) or reject,
(NEED_MORE_INSPECTION(dport),
set sr3 (sr3 | MORE_INSPECTION)) or (1),
set r_cdir 1,
set r_ckey 0,
set r_ctype CONN_TCP,
set r_cflags (sr3|SPOOF_CACHE_EMPTY),
record <conn;r_ckey,r_ctype,r_cflags@TCP_START_TIMEOUT> in connections
)
)
or
(udp,
(
WAS_ENCRYPTED, drop
) or (
ip_len >=28,
(NEED_MORE_INSPECTION(dport),
set sr3 (sr3 | MORE_INSPECTION)) or (1),
set r_cdir 1,
set r_ckey 0,
set r_ctype (CONN_UDP | _UDP_ESTABLISHED),
set r_cflags (sr3|SPOOF_CACHE_EMPTY),
UDP_RECORD(conn,r_ckey,r_ctype,r_cflags),
(
<udpconn> in connections
or
(
direction = 1 or set r_ctype CONN_UDP,
UDP_RECORD(udpconn,r_ckey,r_ctype,r_cflags)
)
)
)
)
+ #ifdef ICMPSTATE
+ or
+ (icmp,
+ (
+ WAS_ENCRYPTED, drop
+ ) or (
+ ip_len >= 32,
+ icmp_type in icmp_allow_requests,
+ record <src,dst,icmp_id,icmp_seq> in icmp_requests_connections
+ #ifdef ICMPSTATEDEBUG
+ , log icmp_recorded_form
+ #endif
+ )
+
+ )
+ #endif /* ICMPSTATE*/
or
(1)
)
)
};
+
+
+ #ifdef ICMPSTATEDEBUG
+ icmp_recorded_form = format {
+ <"DEBUG Recording ICMP proto", proto, ip_p>,
+ <"src", ipaddr, src>,
+ <"dst", ipaddr, dst>,
+ <"icmp_id", hex, icmp_id>,
+ <"icmp_seq", hex, icmp_seq>,
+ <"icmp-type", hex, [(IPHLEN):1]>,
+ <"icmp-code", hex, [(IPHLEN+1):1]>,
+ <"h_len", int, IPHLEN>,
+ <"ip_len", int, ip_len>,
+ <"ip_vers", int, ip_hl / 16>,
+ <"rule", rule, sr1>
+ };
+ icmp_denied_form = format {
+ <"DEBUG ICMP not on the table proto", proto, ip_p>,
+ <"src", ipaddr, src>,
+ <"dst", ipaddr, dst>,
+ <"icmp_id", hex, icmp_id>,
+ <"icmp_seq", hex, icmp_seq>,
+ <"icmp-type", hex, [(IPHLEN):1]>,
+ <"icmp-code", hex, [(IPHLEN+1):1]>,
+ <"h_len", int, IPHLEN>,
+ <"ip_len", int, ip_len>,
+ <"ip_vers", int, ip_hl / 16>,
+ <"rule", rule, sr1>
+ };
+ icmp_allowed_form = format {
+ <"DEBUG allowed ICMP proto", proto, ip_p>,
+ <"src", ipaddr, src>,
+ <"dst", ipaddr, dst>,
+ <"icmp_id", hex, icmp_id>,
+ <"icmp_seq", hex, icmp_seq>,
+ <"icmp-type", hex, [(IPHLEN):1]>,
+ <"icmp-code", hex, [(IPHLEN+1):1]>,
+ <"h_len", int, IPHLEN>,
+ <"ip_len", int, ip_len>,
+ <"ip_vers", int, ip_hl / 16>,
+ <"rule", rule, sr1>
+ };
+ icmp_deleted_form = format {
+ <"DEBUG Allow ICMP reply and deleted it proto", proto, ip_p>,
+ <"src", ipaddr, src>,
+ <"dst", ipaddr, dst>,
+ <"icmp_id", hex, icmp_id>,
+ <"icmp_seq", hex, icmp_seq>,
+ <"icmp-type", hex, [(IPHLEN):1]>,
+ <"icmp-code", hex, [(IPHLEN+1):1]>,
+ <"h_len", int, IPHLEN>,
+ <"ip_len", int, ip_len>,
+ <"ip_vers", int, ip_hl / 16>,
+ <"rule", rule, sr1>
+ };
+ #endif /* ICMPSTATEDEBUG */
+
$Id: icmp.html,v 1.19 2000/07/05 02:16:46 jean Exp $; Jean Chouanard, Xerox PARC