• Source/destination port: Snort supports three dif-
ferent fields for the number of source/destination
ports. Iptables makes use of --sport value and
--dport value options. In this case there is not
a direct correspondence, but we adopted a trick.
Iptables allows the definition of the port num-
bers, like Snort. Additionally, Iptables lets to de-
fine an interval, separating the extremes with a
colon. For defining any port (corresponding to
any in Snort), the user must omit the port num-
ber in Iptables. Iptables allows to exclude a spe-
cific port number, as well as Snort, but for indicat-
ing a set of port numbers, Iptables requires the -m
multiport module before the commands for the
specification of the port numbers;
• Operator: there is not a correspondence for
the Snort’s direction tag in Iptables, where the
same information is represented by the concept of
chain. In the case of s2ipt, a custom chain is cre-
ated, which is referred to by the Iptables engine,
as discussed later in the paper.
Once the header is translated into a Snort rule,
the algorithm examines the options, analyzing them
singularly, trying to accomplish the translation. Even
if not all the Snort options can be translated in Ipta-
bles rules as they are not supported, the most common
ones can be mapped.
All the Snort options that s2ipt can translate into
the Iptables format are listed along with the adopted
assumptions and strategies:
• Content: allows to find a specific byte sequence
within a payload, applying the Boyer-Moore algo-
rithm. The Iptables extension that performing the
”string-matching” can be selected with the com-
mand -m string -string "string" -- algo
bm, where string is the string to search within the
payload. Snort allows the search of hexadecimal
value that can be accomplished with Iptables op-
tion -m string --hex-string;
• Uricontent: allows to handle data codified in
URLs, transferred on HTTP. S2ipt manages this
option as well as the previous one;
• Offset: searches for a content within the payload
starting from an offset location. Iptables allows
the same option with the command --from;
• Depth: forces that the packet matching does not
overcome a certain number of bytes after the pay-
load. In Iptables this option is specified through
the command --to followed by the number of de-
sired bytes. This and the following option can be
present in more than an instance within a Snort
rule. This is not allowed by Iptables, with the
additional constraint tha the number of bytes in-
dicated by --from be smaller than that indicated
by --to. In such case, 2s2ipt sums the values of
the depth (--to) fields, considering the minimum
value of the offset (--from) field;
• TTL: allows to match a packet relying on the TTL
value within the IP header. Both Snort and Ipt-
ables allow to specify a value of TTL smaller or
greater than, and equals to a certain number;
• Tos: indicates the bit within the Type of Service
field in the IP header. This option is supported
by Iptables with the command -m tos --tos
value;
• Flow: this Snort option allows to define a spe-
cific state of a connection: for instance the combi-
nation of from
client and established lets to an-
alyze only the packets on the client side of a
TCP connection after the three-way handshake
was completed. Iptables lets to filter the state
of a TCP connection with -m state --stat
CONNECTION STATE command. Differently from
Snort, Iptables allows to check only five states
(INVALID, ESTABLISHED, NEW, RELATED
and UNTRACKED). For this reason we made the
decision to consider in s2ipt only the Snort rules
referring to the ESTABLISHED;
• Ip proto: resctricts the scope of rule on the basis
of the protocol field of the IP header.Iptables lets
to specify the same option with the command -p
followed by the type of the desired protocol;
• Pcre: stands for Perl Compatible Regular Expres-
sion and lets Snort to apply regular expressions
of high complexity. Since Iptables does not sup-
port any kind of regular expression, for this option
the algorithm must use mainly the best-effort ap-
proach. s2ipt is able to translate only a little subset
of all the possibile variants of Snort’s pcre. The al-
gorithm can translate only those rules whose pcre
option contains constant values, as it begins the
aforementioned content. Another case that allows
the transaltion in Iptables rule is represented by
static patterns defined by numeric values.
The complete algorithm of translation includes
four main phases:
• Pre-processing: the tool carries out a preliminary
evaluation of the rules for excluding those that can
not be translated because of a missing correspon-
dence between the Snort and the Iptables sintax.
The remaining rules are gathered in two sets: one
contains the part concerning the header and the
other contains the part concerning the option;
SECRYPT 2017 - 14th International Conference on Security and Cryptography
464