Commit dab1e98e authored by Arturo Borrero Gonzalez's avatar Arturo Borrero Gonzalez
Browse files

New upstream version 1.8.1

parent f1f129da
/nfnl_osf
/nfnl_osf.8
/nfbpf_compile
......@@ -6,8 +6,10 @@ AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include \
sbin_PROGRAMS =
pkgdata_DATA =
man_MANS =
if HAVE_LIBNFNETLINK
man_MANS += nfnl_osf.8
sbin_PROGRAMS += nfnl_osf
pkgdata_DATA += pf.os
......@@ -23,3 +25,5 @@ if ENABLE_SYNCONF
sbin_PROGRAMS += nfsynproxy
nfsynproxy_LDADD = -lpcap
endif
CLEANFILES = nfnl_osf.8
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
......@@ -18,7 +18,17 @@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
......@@ -81,13 +91,12 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
sbin_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3)
@HAVE_LIBNFNETLINK_TRUE@am__append_1 = nfnl_osf
@HAVE_LIBNFNETLINK_TRUE@am__append_2 = pf.os
@ENABLE_BPFC_TRUE@am__append_3 = nfbpf_compile
@ENABLE_SYNCONF_TRUE@am__append_4 = nfsynproxy
@HAVE_LIBNFNETLINK_TRUE@am__append_1 = nfnl_osf.8
@HAVE_LIBNFNETLINK_TRUE@am__append_2 = nfnl_osf
@HAVE_LIBNFNETLINK_TRUE@am__append_3 = pf.os
@ENABLE_BPFC_TRUE@am__append_4 = nfbpf_compile
@ENABLE_SYNCONF_TRUE@am__append_5 = nfsynproxy
subdir = utils
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/build-aux/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
......@@ -95,14 +104,16 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_linker_flags.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_FILES = nfnl_osf.8
CONFIG_CLEAN_VPATH_FILES =
@HAVE_LIBNFNETLINK_TRUE@am__EXEEXT_1 = nfnl_osf$(EXEEXT)
@ENABLE_BPFC_TRUE@am__EXEEXT_2 = nfbpf_compile$(EXEEXT)
@ENABLE_SYNCONF_TRUE@am__EXEEXT_3 = nfsynproxy$(EXEEXT)
am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(pkgdatadir)"
am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)" \
"$(DESTDIR)$(pkgdatadir)"
PROGRAMS = $(sbin_PROGRAMS)
nfbpf_compile_SOURCES = nfbpf_compile.c
nfbpf_compile_OBJECTS = nfbpf_compile.$(OBJEXT)
......@@ -186,6 +197,9 @@ am__uninstall_files_from_dir = { \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man8dir = $(mandir)/man8
NROFF = nroff
MANS = $(man_MANS)
DATA = $(pkgdata_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
......@@ -206,6 +220,8 @@ am__define_uniq_tagged_files = \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/nfnl_osf.8.in \
$(top_srcdir)/build-aux/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
pkgdatadir = @pkgdatadir@
ACLOCAL = @ACLOCAL@
......@@ -250,6 +266,7 @@ LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
......@@ -347,6 +364,7 @@ program_transform_name = @program_transform_name@
psdir = @psdir@
regular_CFLAGS = @regular_CFLAGS@
regular_CPPFLAGS = @regular_CPPFLAGS@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
......@@ -360,10 +378,12 @@ AM_CFLAGS = ${regular_CFLAGS}
AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_builddir}/include \
-I${top_srcdir}/include ${libnfnetlink_CFLAGS}
pkgdata_DATA = $(am__append_2)
pkgdata_DATA = $(am__append_3)
man_MANS = $(am__append_1)
@HAVE_LIBNFNETLINK_TRUE@nfnl_osf_LDADD = ${libnfnetlink_LIBS}
@ENABLE_BPFC_TRUE@nfbpf_compile_LDADD = -lpcap
@ENABLE_SYNCONF_TRUE@nfsynproxy_LDADD = -lpcap
CLEANFILES = nfnl_osf.8
all: all-am
.SUFFIXES:
......@@ -380,7 +400,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu utils/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu utils/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
......@@ -398,6 +417,8 @@ $(top_srcdir)/configure: $(am__configure_deps)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
nfnl_osf.8: $(top_builddir)/config.status $(srcdir)/nfnl_osf.8.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
install-sbinPROGRAMS: $(sbin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \
......@@ -496,6 +517,49 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
install-man8: $(man_MANS)
@$(NORMAL_INSTALL)
@list1=''; \
list2='$(man_MANS)'; \
test -n "$(man8dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.8[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
done; }
uninstall-man8:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man8dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.8[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir)
install-pkgdataDATA: $(pkgdata_DATA)
@$(NORMAL_INSTALL)
@list='$(pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \
......@@ -602,9 +666,9 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(DATA)
all-am: Makefile $(PROGRAMS) $(MANS) $(DATA)
installdirs:
for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(pkgdatadir)"; do \
for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(pkgdatadir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
......@@ -629,6 +693,7 @@ install-strip:
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
......@@ -660,7 +725,7 @@ info: info-am
info-am:
install-data-am: install-pkgdataDATA
install-data-am: install-man install-pkgdataDATA
install-dvi: install-dvi-am
......@@ -676,7 +741,7 @@ install-info: install-info-am
install-info-am:
install-man:
install-man: install-man8
install-pdf: install-pdf-am
......@@ -706,7 +771,10 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-pkgdataDATA uninstall-sbinPROGRAMS
uninstall-am: uninstall-man uninstall-pkgdataDATA \
uninstall-sbinPROGRAMS
uninstall-man: uninstall-man8
.MAKE: install-am install-strip
......@@ -717,14 +785,16 @@ uninstall-am: uninstall-pkgdataDATA uninstall-sbinPROGRAMS
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-pkgdataDATA install-ps install-ps-am \
install-info-am install-man install-man8 install-pdf \
install-pdf-am install-pkgdataDATA install-ps install-ps-am \
install-sbinPROGRAMS install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-pkgdataDATA \
uninstall-sbinPROGRAMS
tags tags-am uninstall uninstall-am uninstall-man \
uninstall-man8 uninstall-pkgdataDATA uninstall-sbinPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
......
.TH NFNL_OSF 8 "" "@PACKAGE_STRING@" "@PACKAGE_STRING@"
.SH NAME
nfnl_osf \- OS fingerprint loader utility
.SH SYNOPSIS
.ad l
.in +8
.ti -8
.B nfnl_osf
.BI -f " fingerprints"
[
.B -d
]
.SH DESCRIPTION
The
.B nfnl_osf
utility allows to load a set of operating system signatures into the kernel for
later matching against using iptables'
.B osf
match.
.SH OPTIONS
.TP
.BI -f " fingerprints"
Read signatures from file
.IR fingerprints .
.TP
.B -d
Instead of adding the signatures from
.I fingerprints
into the kernel, remove them.
.SH EXIT STATUS
Exit status is 0 if command succeeded, otherwise a negative return code
indicates the type of error which happened:
.TP
.B -1
Illegal arguments passed, fingerprints file not readable or failure in netlink
communication.
.TP
.B -ENOENT
Fingerprints file not specified.
.TP
.B -EINVAL
Netlink handle initialization failed or fingerprints file format invalid.
.SH FILES
An up to date set of operating system signatures can be downloaded from
http://www.openbsd.org/cgi-bin/cvsweb/src/etc/pf.os .
.SH SEE ALSO
The description of
.B osf
match in
.BR iptables-extensions (8)
contains further information about the topic as well as example
.B nfnl_osf
invocations.
......@@ -141,7 +141,7 @@ static char *xt_osf_strchr(char *ptr, char c)
if (tmp)
*tmp = '\0';
while (tmp && tmp + 1 && isspace(*(tmp + 1)))
while (tmp && isspace(*(tmp + 1)))
tmp++;
return tmp;
......@@ -157,7 +157,6 @@ static void xt_osf_parse_opt(struct xt_osf_opt *opt, __u16 *optnum, char *obuf,
i = 0;
while (ptr != NULL && i < olen && *ptr != 0) {
val = 0;
op = 0;
wc = OSF_WSS_PLAIN;
switch (obuf[i]) {
case 'N':
......@@ -344,7 +343,7 @@ static int osf_load_line(char *buffer, int len, int del)
pend = xt_osf_strchr(pbeg, OSFPDEL);
if (pend) {
*pend = '\0';
cnt = snprintf(obuf, sizeof(obuf), "%s,", pbeg);
snprintf(obuf, sizeof(obuf), "%s,", pbeg);
pbeg = pend + 1;
}
......@@ -352,25 +351,23 @@ static int osf_load_line(char *buffer, int len, int del)
if (pend) {
*pend = '\0';
if (pbeg[0] == '@' || pbeg[0] == '*')
cnt = snprintf(f.genre, sizeof(f.genre), "%s", pbeg + 1);
snprintf(f.genre, sizeof(f.genre), "%s", pbeg + 1);
else
cnt = snprintf(f.genre, sizeof(f.genre), "%s", pbeg);
snprintf(f.genre, sizeof(f.genre), "%s", pbeg);
pbeg = pend + 1;
}
pend = xt_osf_strchr(pbeg, OSFPDEL);
if (pend) {
*pend = '\0';
cnt = snprintf(f.version, sizeof(f.version), "%s", pbeg);
snprintf(f.version, sizeof(f.version), "%s", pbeg);
pbeg = pend + 1;
}
pend = xt_osf_strchr(pbeg, OSFPDEL);
if (pend) {
*pend = '\0';
cnt =
snprintf(f.subtype, sizeof(f.subtype), "%s", pbeg);
pbeg = pend + 1;
snprintf(f.subtype, sizeof(f.subtype), "%s", pbeg);
}
xt_osf_parse_opt(f.opt, &f.opt_num, obuf, sizeof(obuf));
......@@ -384,7 +381,7 @@ static int osf_load_line(char *buffer, int len, int del)
nfnl_addattr_l(nmh, sizeof(buf), OSF_ATTR_FINGER, &f, sizeof(struct xt_osf_user_finger));
return nfnl_talk(nfnlh, nmh, 0, 0, NULL, NULL, NULL);
return nfnl_query(nfnlh, nmh);
}
static int osf_load_entries(char *path, int del)
......@@ -438,7 +435,7 @@ int main(int argc, char *argv[])
break;
default:
fprintf(stderr,
"Usage: %s -f fingerprints -d <del rules> -h\n",
"Usage: %s -f fingerprints [-d]\n",
argv[0]);
return -1;
}
......
......@@ -6,6 +6,7 @@
* published by the Free Software Foundation.
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
......
# $FreeBSD: head/etc/pf.os 258865 2013-12-03 04:32:02Z eadler $
# $OpenBSD: pf.os,v 1.26 2012/08/03 12:25:16 jsg Exp $
# $OpenBSD: pf.os,v 1.27 2016/09/03 17:08:57 sthen Exp $
# passive OS fingerprinting
# -------------------------
#
......@@ -315,6 +315,9 @@ S22:64:1:52:M*,N,N,S,N,W0: Linux:2.2:ts:Linux 2.2 w/o timestamps
16384:64:1:64:M*,N,N,S,N,W3,N,N,T: OpenBSD:4.9::OpenBSD 4.9
16384:64:0:64:M*,N,N,S,N,W3,N,N,T: OpenBSD:4.9:no-df:OpenBSD 4.9 (scrub no-df)
16384:64:1:64:M*,N,N,S,N,W6,N,N,T: OpenBSD:6.1::OpenBSD 6.1
16384:64:0:64:M*,N,N,S,N,W6,N,N,T: OpenBSD:6.1:no-df:OpenBSD 6.1 (scrub no-df)
# ----------------- DragonFly BSD -----------------
57344:64:1:60:M*,N,W0,N,N,T: DragonFly:1.0:A:DragonFly 1.0A
......
#!/usr/bin/env python3
# encoding: utf-8
import os
import sys
import shlex
import argparse
from subprocess import Popen, PIPE
keywords = ("iptables-translate", "ip6tables-translate", "ebtables-translate")
if sys.stdout.isatty():
colors = {"magenta": "\033[95m", "green": "\033[92m", "yellow": "\033[93m",
"red": "\033[91m", "end": "\033[0m"}
else:
colors = {"magenta": "", "green": "", "yellow": "", "red": "", "end": ""}
def magenta(string):
return colors["magenta"] + string + colors["end"]
def red(string):
return colors["red"] + string + colors["end"]
def yellow(string):
return colors["yellow"] + string + colors["end"]
def green(string):
return colors["green"] + string + colors["end"]
def run_test(name, payload):
test_passed = True
tests = passed = failed = errors = 0
result = []
for line in payload:
if line.startswith(keywords):
tests += 1
process = Popen([ os.path.abspath(os.path.curdir) + "/iptables/xtables-nft-multi" ] + shlex.split(line), stdout=PIPE, stderr=PIPE)
(output, error) = process.communicate()
if process.returncode == 0:
translation = output.decode("utf-8").rstrip(" \n")
expected = next(payload).rstrip(" \n")
if translation != expected:
test_passed = False
failed += 1
result.append(name + ": " + red("Fail"))
result.append(magenta("src: ") + line.rstrip(" \n"))
result.append(magenta("exp: ") + expected)
result.append(magenta("res: ") + translation + "\n")
test_passed = False
else:
passed += 1
else:
test_passed = False
errors += 1
result.append(name + ": " + red("Error: ") + "iptables-translate failure")
result.append(error.decode("utf-8"))
if (passed == tests) and not args.test:
print(name + ": " + green("OK"))
if not test_passed:
print("\n".join(result))
if args.test:
print("1 test file, %d tests, %d tests passed, %d tests failed, %d errors" % (tests, passed, failed, errors))
else:
return tests, passed, failed, errors
def load_test_files():
test_files = total_tests = total_passed = total_error = total_failed = 0
for test in sorted(os.listdir("extensions")):
if test.endswith(".txlate"):
with open("extensions/" + test, "r") as payload:
tests, passed, failed, errors = run_test(test, payload)
test_files += 1
total_tests += tests
total_passed += passed
total_failed += failed
total_error += errors
print("%d test files, %d tests, %d tests passed, %d tests failed, %d errors" % (test_files, total_tests, total_passed, total_failed, total_error))
def main():
os.putenv("XTABLES_LIBDIR", os.path.abspath("extensions"))
os.putenv("PATH", "%s/iptables:%s" % (os.path.abspath(os.path.curdir), os.getenv("PATH")))
if args.test:
if not args.test.endswith(".txlate"):
args.test += ".txlate"
try:
with open(args.test, "r") as payload:
run_test(args.test, payload)
except IOError:
print(red("Error: ") + "test file does not exist")
else:
load_test_files()
parser = argparse.ArgumentParser()
parser.add_argument("test", nargs="?", help="run only the specified test file")
args = parser.parse_args()
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment