knocker-0.7.1/0000777000175000001440000000000007473306520006722 5knocker-0.7.1/Makefile.in0000644000175000001440000002551607473306517010722 # Makefile.in generated automatically by automake 1.4-p5 from Makefile.am # Copyright (C) 1994, 1995-8, 1999, 2001 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. # Makefile.am file for knocker # Edited by Gabriele Giorgetti # This file is processed by automake SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ LIBS = @LIBS@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ SUBDIRS = src docs DIST_SUBDIRS = $(SUBDIRS) # All the rest of the distributed files EXTRA_DIST = AUTHORS BUGS COPYING INSTALL README README.Win32 TO-DO autogen.sh src-indent.sh ChangeLog knocker.ico DevCPP4_Project.zip ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ Makefile.am Makefile.in NEWS acconfig.h aclocal.m4 config.h.in \ configure configure.in install-sh missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status $(ACLOCAL_M4): configure.in cd $(srcdir) && $(ACLOCAL) config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) config.h: stamp-h @if test ! -f $@; then \ rm -f stamp-h; \ $(MAKE) stamp-h; \ else :; fi stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES= CONFIG_HEADERS=config.h \ $(SHELL) ./config.status @echo timestamp > stamp-h 2> /dev/null $(srcdir)/config.h.in: $(srcdir)/stamp-h.in @if test ! -f $@; then \ rm -f $(srcdir)/stamp-h.in; \ $(MAKE) $(srcdir)/stamp-h.in; \ else :; fi $(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h cd $(top_srcdir) && $(AUTOHEADER) @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null mostlyclean-hdr: clean-hdr: distclean-hdr: -rm -f config.h maintainer-clean-hdr: # 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. @SET_MAKE@ all-recursive install-data-recursive install-exec-recursive \ installdirs-recursive install-recursive uninstall-recursive \ check-recursive installcheck-recursive info-recursive dvi-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ 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; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $(MAKEFLAGS); amf=$$2; \ dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ test "$$subdir" != "." || dot_seen=yes; \ done; \ test "$$dot_seen" = "no" && 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; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(PACKAGE)-$(VERSION) top_distdir = $(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 -rm -rf $(distdir) GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz mkdir $(distdir)/=build mkdir $(distdir)/=inst dc_install_base=`cd $(distdir)/=inst && pwd`; \ cd $(distdir)/=build \ && ../configure --srcdir=.. --prefix=$$dc_install_base \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) dist -rm -rf $(distdir) @banner="$(distdir).tar.gz is ready for distribution"; \ dashes=`echo "$$banner" | sed s/./=/g`; \ echo "$$dashes"; \ echo "$$banner"; \ echo "$$dashes" dist: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) dist-all: distdir -chmod -R a+r $(distdir) GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) -rm -rf $(distdir) distdir: $(DISTFILES) -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done for subdir in $(DIST_SUBDIRS); do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ chmod 777 $(distdir)/$$subdir; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ || exit 1; \ fi; \ done info-am: info: info-recursive dvi-am: dvi: dvi-recursive check-am: all-am check: check-recursive installcheck-am: installcheck: installcheck-recursive all-recursive-am: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive install-exec-am: install-exec: install-exec-recursive install-data-am: install-data: install-data-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-recursive uninstall-am: uninstall: uninstall-recursive all-am: Makefile config.h all-redirect: all-recursive-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive installdirs-am: mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-recursive clean-am: clean-hdr clean-tags clean-generic mostlyclean-am clean: clean-recursive distclean-am: distclean-hdr distclean-tags distclean-generic clean-am distclean: distclean-recursive -rm -f config.status maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-recursive -rm -f config.status .PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ install-data-recursive uninstall-data-recursive install-exec-recursive \ uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ all-recursive check-recursive installcheck-recursive info-recursive \ dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ install-exec-am install-exec install-data-am install-data install-am \ install uninstall-am uninstall all-redirect all-am all installdirs-am \ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # 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: knocker-0.7.1/README0000644000175000001440000000462607473300030007514 -- $Id: README file for knocker version 0.7.1 - released on 24 May 2002 ------------------------------------------------------------------------------- t h e k n o c k e r p r o j e c t http://knocker.sourceforge.net Knocker is a simple and easy to use TCP security port scanner written in C using which is able to analyze hosts and all of the different services started on them. This is the Linux console version of knocker, other versions of knocker can be found at http://knocker.sourceforge.net knocker is released under the GNU General Public License (GPL). If you have comments or suggestions, you are welcome to mail me, and please report any bugs: Gabriele Giorgetti -- Gabriele Giorgetti ______________________________ --=| QUICK START GUIDE TO KNOCKER |=------------------------------- ------------------------------ -[ How to build and install knocker ]- -------------------------------- 1. Unpack the package: tar -zxvf knocker-X.X.X.tar.gz 2. cd knocker-X.X.X 3. type: ./configure 4. make 5. (Become root if you want to install knocker system wide) type: make install -[ You want to start to pollute hosts logfile scanning'em but you don't have a clue ? :) ]- -------------------------------------------------------------- 1. If you have installed knocker with make install you should be able to execute it just by typing: knocker otherwise cd into the src directory under the unpacked source tree and type: ./knocker or better: knocker --help 2. Now to perform a simple port scan to a host (let's use your host as target...) type: knocker --host localhost 3. Let's say you have to perform a long scan and you want the program to run in background so you can continue your work... just type: knocker --host thehost --start-port 1 --end-port 4000 --quiet & or in a shorter form: knocker -H thehost -SP 1 -EP 4000 -q & you won't see any output this way... just do: cat ./knocker_scan.log to see the scan results. Or if you want to log to a particular file: knocker -H thehost -l logfile.txt If you want to scan only one port: knocker -H thehost --port 21 Hope that's enought.... ChEeRs....... Gabriele Giorgetti, knocker-0.7.1/stamp-h.in0000644000175000001440000000000007473305253010527 knocker-0.7.1/AUTHORS0000644000175000001440000000005307432561273007707 Gabriele Giorgetti knocker-0.7.1/COPYING0000644000175000001440000004311007321734435007672 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 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) year 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. knocker-0.7.1/ChangeLog0000644000175000001440000002034607473300016010407 -- $Id: ChangeLog file for knocker version 0.7.1 - released on 24 May 2002 ------------------------------------------------------------------------------- 24 May 2002 - Modified knocker_led.c and knocker_led.h to let knocker build on non-linux OS as well. (if linux/kd.h include is found NO_LED will be defined). 19 May 2002 - A --configure option was added. If knocker is executed with this option it will ask a few questions so the user can configure it to its need. It is currently possible to choose if or not to use colors, and actually choose what color to use for a particular output. These settings are stored int the ~/.knocker/knocker.conf file and can be manually changed by the user. - Fixed the wrong results output in the logfile. The total number of scanned ports was reported as the total of the found open ports. 18 May 2002 - Unit knocker_conf was added. The code in this module will handle all the stuffs relative to the kncoker's configuration file. This file (knocker.conf) is automatically created everytime knocker is executed and it can't find its .conf in the user ~/.knocker subdirectory. 13 May 2002 - --no-fency (-nf for short) option added. This switch tells knocker to show the output in a "polite" way. All the lines and stuffs shown in the default mode, will not be displayed using this option. - Function knocker_term_set_color modified no to alter the console background color. This makes knocker to work properly under X11 terminals. It doesn't screw up colors anymore. (Works with transparent background terminals too). 25 April 2002 - Unit knocker_led added. The code in this unit will handle the keyboard leds. The idea is to get the leds blinking while portscanning ... The code is there and it works, but it is not active yet. 7 April 2002 - --last-host option added. This gets the last host name that was scanned. 28 March 2002 - Added the --last-scan option. This option tells knocker to perform again the last port scan. - The unit knocker_user was added. In this module goes all the code that has to do with user relative functions and the knocker user dir.(ex ~/.knocker) 26 March 2002 - Changed the --quiet-mode option in --quiet and the corrispondent short option -qm in -q 9 March 2002 - Fixed a serious bug that was preventing knocker to scan a number of ports greater than 1023, all ports scanned after 1023 ports already scanned were reported as CLOSED ! (Basically I was not closing the socket in the knocker_core_portscan_tcp_connnect (...) function, so that after 1023 open sockets the system was unable to open more of them). - Fixed another bug that was causing knocker to segfault before exiting if a hostname couldn't be resolved. Thanks to Emmanuel Seyman for having reported these bugs. 8 March 2002 - Changed the --enable-logfile option in --logfile. This option now requires a file name to be specified. Ex: knocker -H thehost --logfile log.txt - Added code to manage the list of services (generated from the /etc/services file) in the unit knocker_services to get the correct service name under Win32 platfroms. The getservbyport function in the Winsock lib seems not to work correctly. - Added the --win32-frontend option and the relative code to work with the knocker win32 frontend. 1 March 2002 - Added Win32 Winsock code to work natively on Windows platforms. Knocker can now be builded natively on Win32 platforms. - Added code to handle colored output under Win32 platforms in the unit knocker_term. (using conio.h). - Added a function (knocker_term_reset) to *Fix* the bug that caused knocker not to reset to the console default colors at exit. - Added a function (knocker_term_clear) to clear the screen when knocker is started. - Added a DevC++4 project file to build knocker under Win32s platforms using the IDE/Compiler available at www.bloodshed.net Information on how to build knocker with this IDE can be found in the file README.Win32 - knocker.ico file added in the source distribution. 23 February 2002: - Fixed the segmentation fault that was caused by starting knocker without the --host or -H option. Now the program exits properly and prints an error message to inform the user. - Unit knocker_timer added. This module handles timing stuffs. - The elapsed time is now counted in milliseconds rather than in seconds. - If a wrong option is given as a knocker command line argument, the error message now prints its name. Ex: knocker --hast localhost knocker: invalid argument given: '--hast' 17 February 2002: - Knocker's output style & colors changed. I like it, but you might not, if that's the case, please, let me know. - Elapsed time since the begin of the port scan is now shown in the results. - Module knocker_output added. All the boring fprintf(...) stuffs are now in this unit. This makes the main knocker unit a bit cleaner. - Code to output debug messages was added. 15 February 2002: - Big portions of code rewritten from scratch. - The TCP connect port scan code has been improved. The scan should be faster now. (In the old code the host name was resolved for each port to be scanned!) Damn it. - knocker_core totally redesigned (and rewritten) to be more flexible and versatile. Plans are to make it available as a library/DLL . 13 February 2002: - Fixed a bug in the version 0.5.1 that made impossible to scan a host starting knocker in the default mode Ex: knocker --host thehost This caused knocker to quit without performing the port scan. - Added header file definitions to prevent multiple file inclusion. 09 February 2002: - An option to perform a portscan on a single port was added. The option is --port or -P - threads code removed (since it was quite buggie) Threads support will be redesigned and reimplemented in the future. - Fixed the total scanned ports result counting bug: knocker was not displaying the correct number of the scanned ports. Ex: for a scan from port 1 to port 1000 it was displaying 998 as total resoult insted of 1000. That's now fixed. Thanks to Cristian Ionescu-Idbohrn for reporting that. - Fixed the bug that caused knocker to segfault when the log file couldn't be open. The program now quits gracefully telling the user what's going on. - Compilation is now done with the following flags -Wall -ansi -pedantic - Module terminal.c renamed to knocker_term.c 06 January 2002: - Added the following options: 1. --quiet-mode With this option the program can be started in background so that no output to the console is generated and the scan's results are written to a log file. (knocker_scan.log) Ex: knocker --host 192.168.0.1 --quiet-mode & 2. --enable-logfile This option logs the scan results to a file (knocker_scan.log) Console output is not disabled by this option. 3. --no-threads If you experience problems running knocker with threads just pass this option. Ex: knocker --host 192.168.0.1 --no-threads - Added modules knocker_log.c, knocker_log.h to support the new file logging functions. 27 July 2001: - Added colored output ! - Code to print colored output done. - Added a "--no-colors" option to disabled colored output - Man page updated with new the new option about colors. 26 July 2001: - Begun to add the code to print colored output. 20 July 2001: - Now knocker uses threads (linux pthreads) in the portscan loop. - The port scan process can now be cancelled by pressing the "c" key. - The number of total ports scanned is now correctly shown even if the scan is cancelled. - configure.in modified to use threads. - Three functions added to support the use of threads. 16 July 2001: - Now knocker attempts to resolve an host IP address before the port scan is started. It aborts the scan if the host IP can't be resolved. 15 July 2001: - Added a function in knocker_core.c to resolve hosts IP addresses. 08 July 2001: - Initial release. -- Gabriele Giorgetti knocker-0.7.1/INSTALL0000644000175000001440000001722707321734437007704 Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. knocker-0.7.1/Makefile.am0000644000175000001440000000121607471770741010702 # Makefile.am file for knocker # Edited by Gabriele Giorgetti # This file is processed by automake ## Any directories that are built and installed should go here. SUBDIRS = src docs ## Any directories to be a part of the distribution should be listed ## here, as well as have a Makefile generated at the end of configure.in DIST_SUBDIRS = $(SUBDIRS) # All the rest of the distributed files EXTRA_DIST = \ AUTHORS \ BUGS \ COPYING \ INSTALL \ README \ README.Win32 \ TO-DO \ autogen.sh \ src-indent.sh \ ChangeLog \ knocker.ico \ DevCPP4_Project.zip knocker-0.7.1/NEWS0000644000175000001440000000653007473300020007326 -- $Id: NEWS file for knocker version 0.7.1 released on 24 May 2002 ------------------------------------------------------------------------------- Most important changes in new releases and NEWS are in this file. A detailed list of changes can be found in the ChangeLog file. knocker-0.7.1 (24 May 2002): - Fixes a problem in the 0.7.0 version that was causing knocker not to build on non-Linux OS (FreeBSD, OpenBSD, HP-UX, and so on). knocker-0.7.0 (19 May 2002): - A new option to display the program output in a "no-fency" mode was added, and also the possibility to configure knocker with the also new --configure option was added. - The colored output code has been improved and it is not causing the background color to change anymore if knocker is executed in a X11 terminal. The text is now correctly displayed on transparent background terminals too. - Two new options were added, these are --last-scan, to perform again the last port scan, and --last-host, which puts the last scanned host as target. knocker-0.6.6 (9 March 2002): - Fixed a serious bug that was preventing knocker to scan a number of ports greater than 1023. - Fixed another bug that was causing knocker to segfault before exiting if a hostname couldn't be resolved. knocker-0.6.5 (8 March 2002): - knocker is now displaying service names correctly on Win32 platforms. - Added Win32 Winsock code to make knocker work and build natively on Win32 platforms. - Code added to work with a contributed knocker Windows frontend. - Console/terminal colors are now restored to default under Win32 platforms. - Elapsed time is now in milliseconds rather than seconds. - Fixed a bug that caused knocker to segfault if a host was not specified after the --host option. knocker-0.6.0 (17 February 2002): - Changed the knocker's output style & colors. - Big portions of code rewritten from scratch. - TCP connect port scan code has been improved, the port scan should be faster now. - Elapsed time since the port scan started is now shown in the results. knocker-0.5.2 (13 February 2002): - Fixed an important bug that prevented knocker version 0.5.1 to perform the port scan, if started in the default mode. knocker-0.5.1 (11 February 2002): - Added an option to perform a portscan on a single port. - Threads code removed. Knocker is no longer using threads. - Two important bugs fixed. (see ChangeLog for detailed infos). knocker-0.5.0 (06 January 2002): - Added an option to run the program in background and log results to a file. - Options added to log port scan results to a file. - Added an options to disable the use threads. knocker-0.4.0 (27 July 2001): - Added colored output ! - Now knocker is able to print its output using colors. - A option to disable colors ha been added: "--no-colors" knocker-0.3.0 (20 July 2001): - Now knocker uses threads (linux pthreads) in the portscan loop. - The port scan process can now be cancelled by pressing the "c" key. knocker-0.2.0 (16 July 2001): - Now knocker attempts to resolve an host IP address before the port scan is started. It aborts the scan if the host IP can't be resolved. - Added a function in knocker_core.c to resolve hosts IP addresses. knocker-0.1.0 (8 July 2001): - Initial release. -- Gabriele Giorgetti knocker-0.7.1/acconfig.h0000644000175000001440000000007107326025315010553 #undef HAVE_PTHREAD_CANCEL #undef PACKAGE #undef VERSION knocker-0.7.1/aclocal.m40000644000175000001440000001554107473305252010505 dnl aclocal.m4 generated automatically by aclocal 1.4-p5 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. # Do all the work for Automake. 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. # serial 1 dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) AC_DEFUN([AM_INIT_AUTOMAKE], [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) VERSION=[$2] AC_SUBST(VERSION) dnl test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi ifelse([$3],, AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) AC_REQUIRE([AM_SANITY_CHECK]) AC_REQUIRE([AC_ARG_PROGRAM]) dnl FIXME This is truly gross. missing_dir=`cd $ac_aux_dir && pwd` AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_REQUIRE([AC_PROG_MAKE_SET])]) # # Check to make sure that the build environment is sane. # AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftestfile # 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 conftestfile 2> /dev/null` if test "[$]*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "[$]*" != "X $srcdir/configure conftestfile" \ && test "[$]*" != "X conftestfile $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" = conftestfile ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi rm -f conftest* AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. AC_DEFUN([AM_MISSING_PROG], [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if ($2 --version) < /dev/null > /dev/null 2>&1; then $1=$2 AC_MSG_RESULT(found) else $1="$3/missing $2" AC_MSG_RESULT(missing) fi AC_SUBST($1)]) # Like AC_CONFIG_HEADER, but automatically create stamp file. AC_DEFUN([AM_CONFIG_HEADER], [AC_PREREQ([2.12]) AC_CONFIG_HEADER([$1]) dnl When config.status generates a header, we must update the stamp-h file. dnl This file resides in the same directory as the config header dnl that is generated. We must strip everything past the first ":", dnl and everything past the last "/". AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, <>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, <>; do case " <<$>>CONFIG_HEADERS " in *" <<$>>am_file "*<<)>> echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx ;; esac am_indx=`expr "<<$>>am_indx" + 1` done<<>>dnl>>) changequote([,]))]) # serial 1 # @defmac AC_PROG_CC_STDC # @maindex PROG_CC_STDC # @ovindex CC # If the C compiler in not in ANSI C mode by default, try to add an option # to output variable @code{CC} to make it so. This macro tries various # options that select ANSI C on some system or another. It considers the # compiler to be in ANSI C mode if it handles function prototypes correctly. # # If you use this macro, you should check after calling it whether the C # compiler has been set to accept ANSI C; if not, the shell variable # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source # code in ANSI C, you can make an un-ANSIfied copy of it by using the # program @code{ansi2knr}, which comes with Ghostscript. # @end defmac AC_DEFUN([AM_PROG_CC_STDC], [AC_REQUIRE([AC_PROG_CC]) AC_BEFORE([$0], [AC_C_INLINE]) AC_BEFORE([$0], [AC_C_CONST]) dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require dnl a magic option to avoid problems with ANSI preprocessor commands dnl like #elif. dnl FIXME: can't do this because then AC_AIX won't work due to a dnl circular dependency. dnl AC_BEFORE([$0], [AC_PROG_CPP]) AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) AC_CACHE_VAL(am_cv_prog_cc_stdc, [am_cv_prog_cc_stdc=no ac_save_CC="$CC" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" AC_TRY_COMPILE( [#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; } 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; ], [ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ], [am_cv_prog_cc_stdc="$ac_arg"; break]) done CC="$ac_save_CC" ]) if test -z "$am_cv_prog_cc_stdc"; then AC_MSG_RESULT([none needed]) else AC_MSG_RESULT($am_cv_prog_cc_stdc) fi case "x$am_cv_prog_cc_stdc" in x|xno) ;; *) CC="$CC $am_cv_prog_cc_stdc" ;; esac ]) knocker-0.7.1/config.h.in0000644000175000001440000000313107473305252010660 /* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if you have the gettimeofday function. */ #undef HAVE_GETTIMEOFDAY /* Define if you have the nanosleep function. */ #undef HAVE_NANOSLEEP /* Define if you have the pause function. */ #undef HAVE_PAUSE /* Define if you have the usleep function. */ #undef HAVE_USLEEP /* Define if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define if you have the header file. */ #undef HAVE_ERRNO_H /* Define if you have the header file. */ #undef HAVE_FCNTL_H /* Define if you have the header file. */ #undef HAVE_LINUX_KD_H /* Define if you have the header file. */ #undef HAVE_NETDB_H /* Define if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define if you have the header file. */ #undef HAVE_SIGNAL_H /* Define if you have the header file. */ #undef HAVE_STRING_H /* Define if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define if you have the header file. */ #undef HAVE_SYS_WAIT_H /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Name of package */ #undef PACKAGE /* Version number of package */ #undef VERSION knocker-0.7.1/configure0000755000175000001440000016075107473305254010562 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= 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=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -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 ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$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" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$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) # 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 << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --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 EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$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" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) 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) 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" ;; -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 ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=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" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=src/knocker_core.h # 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 its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. 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 if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi 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 fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # 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 # 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" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:556: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/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 if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" 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. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&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_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 echo "configure:609: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile # 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 conftestfile 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftestfile` fi if test "$*" != "X $srcdir/configure conftestfile" \ && test "$*" != "X conftestfile $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". { echo "configure: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" 1>&2; exit 1; } fi test "$2" = conftestfile ) then # Ok. : else { echo "configure: error: newly created file is older than distributed files! Check your system clock" 1>&2; exit 1; } fi rm -f conftest* echo "$ac_t""yes" 1>&6 if test "$program_transform_name" = s,x,x,; then program_transform_name= else # Double any \ or $. echo might interpret backslashes. cat <<\EOF_SED > conftestsed s,\\,\\\\,g; s,\$,$$,g EOF_SED program_transform_name="`echo $program_transform_name|sed -f conftestsed`" rm -f conftestsed fi 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" # sed with no file args requires a program. test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 echo "configure:666: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftestmake fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$ac_t""yes" 1>&6 SET_MAKE= else echo "$ac_t""no" 1>&6 SET_MAKE="MAKE=${MAKE-make}" fi PACKAGE=knocker VERSION=0.7.1 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } fi cat >> confdefs.h <> confdefs.h <&6 echo "configure:712: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (aclocal --version) < /dev/null > /dev/null 2>&1; then ACLOCAL=aclocal echo "$ac_t""found" 1>&6 else ACLOCAL="$missing_dir/missing aclocal" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 echo "configure:725: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoconf --version) < /dev/null > /dev/null 2>&1; then AUTOCONF=autoconf echo "$ac_t""found" 1>&6 else AUTOCONF="$missing_dir/missing autoconf" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 echo "configure:738: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (automake --version) < /dev/null > /dev/null 2>&1; then AUTOMAKE=automake echo "$ac_t""found" 1>&6 else AUTOMAKE="$missing_dir/missing automake" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 echo "configure:751: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (autoheader --version) < /dev/null > /dev/null 2>&1; then AUTOHEADER=autoheader echo "$ac_t""found" 1>&6 else AUTOHEADER="$missing_dir/missing autoheader" echo "$ac_t""missing" 1>&6 fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 echo "configure:764: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. if (makeinfo --version) < /dev/null > /dev/null 2>&1; then MAKEINFO=makeinfo echo "$ac_t""found" 1>&6 else MAKEINFO="$missing_dir/missing makeinfo" echo "$ac_t""missing" 1>&6 fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:784: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 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 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:814: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_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 $# -gt 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 set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:865: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:897: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 908 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:939: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:944: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:972: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&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 echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 echo "configure:1007: checking for ${CC-cc} option to accept ANSI C" >&5 if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else am_cv_prog_cc_stdc=no ac_save_CC="$CC" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" cat > conftest.$ac_ext < #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; } 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; } EOF if { (eval echo configure:1060: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_prog_cc_stdc="$ac_arg"; break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done CC="$ac_save_CC" fi if test -z "$am_cv_prog_cc_stdc"; then echo "$ac_t""none needed" 1>&6 else echo "$ac_t""$am_cv_prog_cc_stdc" 1>&6 fi case "x$am_cv_prog_cc_stdc" in x|xno) ;; *) CC="$CC $am_cv_prog_cc_stdc" ;; esac # 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 # 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" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:1095: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/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 if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" 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. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&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_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' #AC_CANONICAL_HOST echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:1150: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1171: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1188: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1205: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 echo "configure:1230: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1243: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else rm -rf conftest* 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 > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else rm -rf conftest* 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 > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #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)) exit(2); exit (0); } EOF if { (eval echo configure:1310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_header_stdc=no fi rm -fr conftest* fi fi fi echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi for ac_hdr in \ string.h \ errno.h \ signal.h \ netdb.h \ netinet/in.h \ arpa/inet.h \ sys/socket.h \ sys/types.h \ sys/wait.h \ sys/time.h \ unistd.h \ fcntl.h \ sys/ioctl.h \ linux/kd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1353: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1363: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done if test "x$GCC" = "xyes" ; then # -ansi -pedantic removed to test nanosleep and other non ansi functions CFLAGS="$CFLAGS -Wall" fi for ac_func in gettimeofday pause usleep nanosleep do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1400: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* 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_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done trap '' 1 2 15 cat > confcache <<\EOF # 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. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # 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. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo " Makefile docs/Makefile src/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@PACKAGE@%$PACKAGE%g s%@VERSION@%$VERSION%g s%@ACLOCAL@%$ACLOCAL%g s%@AUTOCONF@%$AUTOCONF%g s%@AUTOMAKE@%$AUTOMAKE%g s%@AUTOHEADER@%$AUTOHEADER%g s%@MAKEINFO@%$MAKEINFO%g s%@SET_MAKE@%$SET_MAKE%g s%@CC@%$CC%g s%@CPP@%$CPP%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #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. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 knocker-0.7.1/configure.in0000644000175000001440000000173007473301424011146 dnl configure.in file for knocker dnl Edit by Gabriele Giorgetti dnl to be processed with autoconf AC_INIT(src/knocker_core.h) AM_INIT_AUTOMAKE(knocker, 0.7.1) AM_CONFIG_HEADER(config.h) AC_PROG_CC AM_PROG_CC_STDC AC_PROG_INSTALL #AC_CANONICAL_HOST dnl Check for standard C headers AC_HEADER_STDC dnl Check for extra required headers AC_CHECK_HEADERS( \ string.h \ errno.h \ signal.h \ netdb.h \ netinet/in.h \ arpa/inet.h \ sys/socket.h \ sys/types.h \ sys/wait.h \ sys/time.h \ unistd.h \ fcntl.h \ sys/ioctl.h \ linux/kd.h ) dnl Use -Wall -ansi -pedantic if we have gcc. if test "x$GCC" = "xyes" ; then # -ansi -pedantic removed to test nanosleep and other non ansi functions CFLAGS="$CFLAGS -Wall" fi dnl Check for library functions AC_CHECK_FUNCS(gettimeofday pause usleep nanosleep) AC_SUBST(LIBS) AC_OUTPUT([ Makefile docs/Makefile src/Makefile ]) knocker-0.7.1/install-sh0000755000175000001440000001273607321734473010657 #!/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 knocker-0.7.1/missing0000755000175000001440000001421307321734476010245 #! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997 Free Software Foundation, Inc. # Franc,ois 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. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi 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 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 lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing - GNU libit 0.0" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`configure.in'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`configure.in'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`configure.in'. 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.in` 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) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. 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 ;; 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 ;; makeinfo) 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 ;; *) 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 knocker-0.7.1/mkinstalldirs0000755000175000001440000000132707321734476011456 #! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.1.1.1 2001/07/08 01:37:02 ggdev Exp $ errstatus=0 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 fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here knocker-0.7.1/BUGS0000644000175000001440000000121207473300024007306 -- $Id: BUGS file for knocker version 0.7.1 released on 24 May 2002 ------------------------------------------------------------------------------- Please report any bugs, or comments to: Gabriele Giorgetti Don't forget to visit http://knocker.sourceforge.net for more informations on the knocker project. List of known bugs: Well, the same old story: if you find one, please, report it :-) You can report bugs by visiting: http://knocker.sourceforge.net/development.php and following the BUGS link on the page. Or just by sending an e-mail to me. -- Gabriele Giorgetti knocker-0.7.1/README.Win320000644000175000001440000000147207471770741010433 t h e k n o c k e r p r o j e c t http://knocker.sourceforge.net HOW TO BUILD KNOCKER FROM SOURCE CODE ON WIN32 PLATFORMS ________________________________________________________ Knocker has been tested and succesfully compiled with the following compilers for Window9x/NT/2000: - MinGW available at http://www.mingw.org - Cygwin available at http://www.cygnus.com - DevC++4 IDE/Compiler available at http://www.bloodshed.net [ Building knocker source using the DevC++ 4 IDE ] ...ZzzzZZzzzzZzzZz... argh... ehm... Oh Crap ! 4:54am I'd better stop with that and go straight to bed. PS: If you really need help or informations on how to build knocker under Win32 please contact me. knocker-0.7.1/TO-DO0000644000175000001440000000147707473300034007406 -- $Id: TO-DO file for knocker version 0.7.1 - released on 24 May 2002 ------------------------------------------------------------------------------- Wish list for new future knocker versions: - Implement Stealth Scan - Improve the tcp connect scan by making it non blocking and scanning in parallel mode. - Optimize the knocker Win32 Winsock code to be faster than the slow crap it is now. - Improve the --port option to accept a list of ports, like : --port 22-100-1024-2025 - Add an option to scan a list of hosts from a file. - Add an interactive mode - Banner grabbing. - Add a configuration file to deny/allow the use of knocker by normal users and also set color preferences. - Other cool things not listed yet... -- Gabriele Giorgetti knocker-0.7.1/autogen.sh0000755000175000001440000000234707432561273010650 #!/bin/sh # autogen.sh script for knocker # Edited by Gabriele Giorgetti # DIE=0 (autoconf --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`autoconf' installed to." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 } (automake --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`automake' installed." echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" echo "(or a newer version if it is available)" 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 "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz" echo "(or a newer version if it is available)" DIE=1 } if test "$DIE" -eq 1; then exit 1 fi aclocal \ && echo "Running autoheader..." \ && autoheader \ && echo "Running automake --gnu --add-missing ..." \ && automake --gnu --add-missing \ && echo "Running autoconf ..." \ && autoconf knocker-0.7.1/src-indent.sh0000644000175000001440000000112407472004402011227 #!/bin/sh SECONDS=10 echo echo Warning, you are about to change source code indentation ! echo executing in $SECONDS seconds, press ctrl + c to abort. for (( i=0 ; $i <= (SECONDS=$SECONDS-1) ; i=$i+1 )) do sleep 1 echo -n ". " done echo indent --indent-level2 --line-length140 --comment-line-length140 \ --no-blank-lines-after-declarations --no-blank-lines-after-procedures \ --dont-break-function-decl-args --dont-break-procedure-type \ -nut --space-after-if src/*.c # -nut = --no-tabs ( but --not-tabs is not working -nut does work ) echo Source code indentation complete. knocker-0.7.1/knocker.ico0000644000175000001440000000137607442475055011003  è( @€€€€€€€€€€ÀÀÀ€€€ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿðÿÿÿÿðÿÿðÿÿÿÿÿÿÿðÿÿÿÿÿ𪪪ªÿÿÿ ªªªªªªªªÿÿÿÿÿÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿðÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÀxÿÀpÿÀpÿÀ`?ÿÀ@?ÿÀÿÀÿÿÀÿÿÀÿÿÀÿÿÀÿÿÀÿÀ@?ÿÀ`ÿàð?ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿknocker-0.7.1/DevCPP4_Project.zip0000644000175000001440000000341007442475055012221 PKOnÚ(âczbbã conio.oUOlÛTÿl§«—…¥Ò Ú–128E[©BJÓe ­¦Yà2)M'q0vä8]{˜Ø$BEʼn ¨WGà´¨ ½U»pàR1†¢uª(S„BË÷žíg§!bŸôìß÷ûþ¾ï½8oq¹7ð"E.f)‹x²….ŸàÛ Øú)\€¹X.ke}~".-}hÅæ+ø¹‰~éÆƒÚ£ãw“=‰Ú ªO¡B¬Û'—­Ó„âªÁ»ÉnŽPGWPç«£¨Sÿvw9Ù•jíÝÒ_ D¨Ñ’(n¬7cþõå u&ó47>÷œàÍ¡ÁÈ“ÜÍdO ßNn†o§ï…¿]“J‘!!ÌWâJ\ç!UÇ6Ö£• ¬Ðº˜¬ÛLŠRñ´9þcg[Û|ã1ºÉA }⨭Ñj${4¢'y΋h¦{ÍmðöóÝÃÖÐ=`ÍÓëcô½S—x Õ%Ž‚?ê’@A§.܉ŒRý׺dƒ­º$v–8ÒS3-Ö‡;_zJЙ/öΗòØu3"ï=§ûá³Òw.bí±ú`#¾¢N­ÃRç'{ÛµsÏp†;æ ›£½[LðÞ´ÈdÎÿhOÓó ‡NÛ¶ýnÝo"C.¡F€‰WiWí]„µÖ³µ#O“˜ÙÎêþþ>íęӯ‹=2BòHÍ {ÒsÆËùîE@Vë b~¯­íÙ#ð#Î*„¯¿›É1ûPÇí3í‘D‰’1@‡’È ;þq¶0 ¶¼‰ë9\ãÆç Š>bÜg@¿.ˆ¾gÜ:>OR´ƒÏgp‚?ñyšra¼‡QŠ"œkr®õ2çfy‡s3ßgÜ¢ç)ñ>§±ÇŠ2t†¡+¼[#Å»5tÆU÷9ïÖXåíoæ8ÜaY~fˆ\t”¡—7öuÁí¹À8“q?0®èŠbyUSÀ–½}€'ºjÄdè÷CÍÑŠDŽ 0QÆD€|}JFÖLÅÐ`Îõ¡LE6¡ècÊU ¿ÿ[SP,¹¨€È¹ ‘WqMö1 \Ý>æmòàYU¯hª®œ÷,%cé9Þu ׇžÏuUÏס.ø}ò¸¾î‹ZÀÕñESY‚«B?³)–±¸-Ö³ÿŸ”ŒOàÈé)ð‹ÿ_”§>"ÿ?¨@}\¨ÜrÞ¼³>û¤=æ Ÿ¿Í|3Àü8ÀÜ`ü=ØÌ‰æµ>Æ>÷¬iëöy™ªnåÁcRQ剌l¼_Æ‹œ‹A&“)èUFddd*˜©jV ÓZ*+41™´ªç TÊezãñz¨dŠj¡¸ æ´Ÿ¬e™6šÏÊïL£ªçl]64Ã$Õ.ÌÌ&/ÎΤ¯œ'Zbjú²«]T¬”•»”Õsš2)Åš6ôŠ¡)Ó´›7°ø$õsø”l*Šž¨æó ³^P5Í1ÏT-¼²Ó8”¬l)æT|âÌ`Vɨ¨–jè$Ö³]Å–§p3ê|ÕRúMïÒNË€PK&¡i,ê'„w4x knocker.dev•’QkÂ0…ßùû ­ZƒÏÓ # This file is processed by automake SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ LIBS = @LIBS@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ bin_PROGRAMS = knocker knocker_SOURCES = knocker_main.c knocker_core.c knocker_core.h knocker_args.c knocker_args.h knocker_user.c knocker_user.h knocker_conf.c knocker_conf.h knocker_output.c knocker_output.h knocker_log.c knocker_log.h knocker_term.c knocker_term.h knocker_time.c knocker_time.h knocker_services.c knocker_services.h knocker_led.c knocker_led.h mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ knocker_OBJECTS = knocker_main.o knocker_core.o knocker_args.o \ knocker_user.o knocker_conf.o knocker_output.o knocker_log.o \ knocker_term.o knocker_time.o knocker_services.o knocker_led.o knocker_LDADD = $(LDADD) knocker_DEPENDENCIES = knocker_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best SOURCES = $(knocker_SOURCES) OBJECTS = $(knocker_OBJECTS) all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status mostlyclean-binPROGRAMS: clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) distclean-binPROGRAMS: maintainer-clean-binPROGRAMS: install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) list='$(bin_PROGRAMS)'; for p in $$list; do \ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done .c.o: $(COMPILE) -c $< .s.o: $(COMPILE) -c $< .S.o: $(COMPILE) -c $< mostlyclean-compile: -rm -f *.o core *.core clean-compile: distclean-compile: -rm -f *.tab.c maintainer-clean-compile: knocker: $(knocker_OBJECTS) $(knocker_DEPENDENCIES) @rm -f knocker $(LINK) $(knocker_LDFLAGS) $(knocker_OBJECTS) $(knocker_LDADD) $(LIBS) tags: TAGS ID: $(HEADERS) $(SOURCES) $(LISP) list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ here=`pwd` && cd $(srcdir) \ && mkid -f$$here/ID $$unique $(LISP) TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ awk ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) mostlyclean-tags: clean-tags: distclean-tags: -rm -f TAGS ID maintainer-clean-tags: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = src distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done knocker_args.o: knocker_args.c knocker_core.h ../config.h knocker_args.h \ knocker_user.h knocker_conf.h knocker_log.h knocker_conf.o: knocker_conf.c knocker_core.h ../config.h knocker_args.h \ knocker_term.h knocker_user.h knocker_conf.h knocker_core.o: knocker_core.c ../config.h knocker_core.h \ knocker_services.h knocker_led.o: knocker_led.c knocker_led.h ../config.h knocker_log.o: knocker_log.c knocker_core.h ../config.h knocker_log.h \ knocker_args.h knocker_user.h knocker_time.h knocker_main.o: knocker_main.c ../config.h knocker_log.h \ knocker_output.h knocker_term.h knocker_args.h knocker_user.h \ knocker_conf.h knocker_core.h knocker_time.h knocker_led.h \ knocker_services.h knocker_output.o: knocker_output.c knocker_core.h ../config.h \ knocker_output.h knocker_conf.h knocker_args.h knocker_term.h \ knocker_user.h knocker_time.h knocker_services.o: knocker_services.c knocker_services.h ../config.h \ knocker_core.h knocker_term.o: knocker_term.c ../config.h knocker_core.h knocker_term.h \ knocker_args.h knocker_time.o: knocker_time.c knocker_time.h ../config.h knocker_user.o: knocker_user.c knocker_core.h ../config.h knocker_args.h \ knocker_user.h info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-binPROGRAMS install-exec: install-exec-am install-data-am: install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-binPROGRAMS uninstall: uninstall-am all-am: Makefile $(PROGRAMS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \ mostlyclean-am clean: clean-am distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-compile distclean-compile clean-compile \ maintainer-clean-compile tags mostlyclean-tags distclean-tags \ clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ all-redirect all-am all installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean # 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: knocker-0.7.1/src/Makefile.am0000644000175000001440000000114307472001275011456 # Makefile.am file for knocker # Edited by Gabriele Giorgetti # This file is processed by automake bin_PROGRAMS = knocker knocker_SOURCES = \ knocker_main.c \ knocker_core.c \ knocker_core.h \ knocker_args.c \ knocker_args.h \ knocker_user.c \ knocker_user.h \ knocker_conf.c \ knocker_conf.h \ knocker_output.c \ knocker_output.h \ knocker_log.c \ knocker_log.h \ knocker_term.c \ knocker_term.h \ knocker_time.c \ knocker_time.h \ knocker_services.c \ knocker_services.h \ knocker_led.c \ knocker_led.h knocker-0.7.1/src/knocker_main.c0000644000175000001440000002431407473301127012233 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include "knocker_log.h" #include "knocker_output.h" #include "knocker_term.h" #include "knocker_args.h" #include "knocker_user.h" #include "knocker_conf.h" #include "knocker_core.h" #include "knocker_time.h" #include "knocker_led.h" #include "knocker_services.h" #include int total_open_ports = 0; int total_scanned_ports = 0; double elapsed_time; knocker_core_portscan_data_t pscan_data; /* ============================================================================ ============================================================================ */ static void init (int argc, char *argv[]) { knocker_core_init (); if (init_knocker_core_services_db () < 0) { fprintf (stderr, "%s: Error allocating services strings memory. Fatal.\n", PACKAGE); exit (EXIT_FAILURE); } knocker_user_init (&knocker_user); knocker_args_init (&knocker_args, FALSE, FALSE, TRUE); knocker_args_parse (&knocker_args, argc, argv); if (knocker_conf_parse () < 0) /* write a default conf file for the user if it is not already there. */ knocker_conf_write_default (); knocker_core_init_portscan_data (&pscan_data); if (knocker_args.fency) knocker_term_clear (); knocker_output_open (); knocker_term_fprintf (stdout, "\n"); /* open and initialize log file if needed */ if (knocker_log_open (knocker_args.lfname) < 0) { fprintf (stderr, "%s: error, couldn't open the log file (%s)\n", PACKAGE, KNOCKER_LOG_FILE); fprintf (stderr, "(You might not have write permission on the current directory.)\n"); fprintf (stderr, "Knocker portscan aborted.\n"); knocker_args_free (&knocker_args); knocker_core_free_portscan_data (&pscan_data); knocker_core_quit (); exit (EXIT_FAILURE); } } /* ============================================================================ ============================================================================ */ static void quit (void) { knocker_log_close (); knocker_args_free (&knocker_args); knocker_user_free (&knocker_user); knocker_core_free_portscan_data (&pscan_data); free_knocker_core_services_db (); #ifdef __WIN32__ if ((knocker_args.win32_frontend) && (!knocker_args.quiet)) { system ("PAUSE"); } #endif /* knocker_led_reset(); Not ready for leds Yet */ knocker_term_reset (); knocker_core_quit (); } /* ============================================================================ ============================================================================ */ static void resolve (void) { if (knocker_core_resolve_host (&pscan_data, knocker_args.hname) == NULL) { knocker_output_resolve_error (knocker_args.hname); knocker_log_resolve_error (knocker_args.hname); quit (); exit (EXIT_FAILURE); } knocker_core_get_hostname (&pscan_data); knocker_core_get_hostip (&pscan_data); knocker_output_host_info (knocker_core_last_hostname, knocker_core_last_hostip); knocker_log_host_info (knocker_core_last_hostname, knocker_core_last_hostip); } /* ============================================================================ ============================================================================ */ static void portscan (void) { knocker_term_fflush (stdout); if (knocker_args.port != 0) { knocker_output_ports_info (knocker_args.port, knocker_args.port); knocker_log_ports_info (knocker_args.port, knocker_args.port); knocker_user_write_lastscan (&knocker_user, &knocker_args); knocker_time_start_timer (); if (knocker_core_portscan_tcp_connnect (&pscan_data, knocker_args.port) == PORT_OPEN) { #ifdef __WIN32__ #else knocker_core_get_service (knocker_args.port, PROTO_TCP); #endif knocker_output_open_port (knocker_args.port, knocker_core_last_service); knocker_log_open_port (knocker_args.port, knocker_core_last_service); } elapsed_time = knocker_time_get_ticks (); total_scanned_ports = 1; return; } else if ((knocker_args.sport == 0) && (knocker_args.eport == 0)) { int port; knocker_args.sport = 1; knocker_args.eport = KNOCKER_DEFAULT_PORT_RANGE; knocker_output_ports_info (knocker_args.sport, knocker_args.eport); knocker_log_ports_info (knocker_args.sport, knocker_args.eport); knocker_user_write_lastscan (&knocker_user, &knocker_args); knocker_time_start_timer (); for (port = knocker_args.sport; port <= knocker_args.eport; port++) { if (knocker_core_portscan_tcp_connnect (&pscan_data, port) == PORT_OPEN) { total_open_ports++; #ifdef __WIN32__ knocker_core_services_db_get_service (port, PROTO_TCP); #else if (knocker_core_get_service (port, PROTO_TCP) == NULL) { knocker_core_services_db_get_service (port, PROTO_TCP); } #endif knocker_term_fflush (stdout); knocker_output_open_port (port, knocker_core_last_service); knocker_log_open_port (port, knocker_core_last_service); } } elapsed_time = knocker_time_get_ticks (); total_scanned_ports = port; return; } knocker_output_ports_info (knocker_args.sport, knocker_args.eport); knocker_log_ports_info (knocker_args.sport, knocker_args.eport); if ((knocker_args.sport == knocker_args.eport) && (knocker_args.sport != 0) && (knocker_args.eport != 0)) { int port = knocker_args.sport; knocker_user_write_lastscan (&knocker_user, &knocker_args); knocker_time_start_timer (); if (knocker_core_portscan_tcp_connnect (&pscan_data, port) == PORT_OPEN) { #ifdef __WIN32__ knocker_core_services_db_get_service (port, PROTO_TCP); #else if (knocker_core_get_service (port, PROTO_TCP) == NULL) { knocker_core_services_db_get_service (port, PROTO_TCP); } #endif knocker_output_open_port (port, knocker_core_last_service); knocker_log_open_port (port, knocker_core_last_service); } elapsed_time = knocker_time_get_ticks (); total_scanned_ports = 1; return; } else if (knocker_args.sport > knocker_args.eport) { int port = 0; /* avaoid unitialization warning */ knocker_user_write_lastscan (&knocker_user, &knocker_args); knocker_time_start_timer (); for (port = knocker_args.sport; port >= knocker_args.eport; port--) { if (knocker_core_portscan_tcp_connnect (&pscan_data, port) == PORT_OPEN) { total_open_ports++; #ifdef __WIN32__ knocker_core_services_db_get_service (port, PROTO_TCP); #else if (knocker_core_get_service (port, PROTO_TCP) == NULL) { knocker_core_services_db_get_service (port, PROTO_TCP); } #endif knocker_output_open_port (port, knocker_core_last_service); knocker_log_open_port (port, knocker_core_last_service); } } elapsed_time = knocker_time_get_ticks (); total_scanned_ports = knocker_args.sport - port; return; } else { int port; knocker_user_write_lastscan (&knocker_user, &knocker_args); knocker_time_start_timer (); for (port = knocker_args.sport; port <= knocker_args.eport; port++) { /* Not ready yet for these stuffs knocker_led_sequence(); usleep(10000); / usleep is deprecated, use nanosleep instead knocker_time_delay(10); */ if (knocker_core_portscan_tcp_connnect (&pscan_data, port) == PORT_OPEN) { total_open_ports++; #ifdef __WIN32__ knocker_core_services_db_get_service (port, PROTO_TCP); #else if (knocker_core_get_service (port, PROTO_TCP) == NULL) { knocker_core_services_db_get_service (port, PROTO_TCP); } #endif knocker_output_open_port (port, knocker_core_last_service); knocker_log_open_port (port, knocker_core_last_service); } } elapsed_time = knocker_time_get_ticks (); total_scanned_ports = port - knocker_args.sport; return; } return /* it should be never reached */ ; } /* ============================================================================ ============================================================================ */ static void results (void) { char timestr[80]; elapsed_time = elapsed_time / 1000; sprintf (timestr, "%.2f", elapsed_time); knocker_output_results (knocker_core_last_hostname, knocker_core_last_hostip, total_scanned_ports, total_open_ports, timestr); knocker_log_results (knocker_core_last_hostname, knocker_core_last_hostip, total_scanned_ports, total_open_ports, timestr); } /* ============================================================================ ============================================================================ */ int main (int argc, char *argv[]) { init (argc, argv); atexit (quit); resolve (); portscan (); results (); return (EXIT_SUCCESS); } knocker-0.7.1/src/knocker_core.c0000644000175000001440000005164607473301073012247 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include "knocker_core.h" #include "knocker_services.h" static int knocker_core_init_port_data (knocker_core_port_t * port); static void knocker_core_free_port_data (knocker_core_port_t * port); static int knocker_core_init_socket_data (knocker_core_socket_t * sock); static void knocker_core_free_socket_data (knocker_core_socket_t * sock); static int knocker_core_open_socket (knocker_core_socket_t * sock, int protocol); static void knocker_core_close_socket (knocker_core_socket_t * sock); static int knocker_core_init_host_data (knocker_core_host_t * host); static void knocker_core_free_host_data (knocker_core_host_t * host); static int knocker_core_gethostbyname (knocker_core_host_t * hinfo, const char *hostname); static int knocker_core_getservbyport (char *service, unsigned int port, int protocol); static char *knocker_core_get_host_name_string (knocker_core_host_t * hinfo); static char *knocker_core_get_host_ip_string (knocker_core_host_t * hinfo); static int knocker_core_set_host_name_string (knocker_core_host_t * hinfo, const char *hostname); static int knocker_core_set_host_ip_string (knocker_core_host_t * hinfo, const char *hostip); static void knocker_core_free_host_name_string (knocker_core_host_t * hinfo); static void knocker_core_free_host_ip_string (knocker_core_host_t * hinfo); /* ============================================================================ ============================================================================ */ int knocker_core_init (void) { #ifdef __WIN32_WINSOCK2__ WORD winsock_version = MAKEWORD (2, 0); #elif defined __WIN32__ WORD winsock_version = MAKEWORD (1, 1); #endif #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_init() called.\n"); #endif #ifdef __WIN32__ /* Start up the dreaded Winsock */ if (WSAStartup (winsock_version, &knocker_core_wsadata) != 0) return -1; #endif /* __WIN32__ */ knocker_core_last_hostip = NULL; /* string of the last resolved host ip address */ knocker_core_last_hostname = NULL; /* string of the last used host name */ knocker_core_last_service = NULL; /* string of the last service */ return 0; } /* ============================================================================ ============================================================================ */ void knocker_core_quit (void) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_quit() called.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: knocker_core_last_hostip is: %s, memory must be deallocated... ", knocker_core_last_hostip); #endif if (knocker_core_last_hostip != NULL) free (knocker_core_last_hostip); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: knocker_core_last_hostname is: %s, memory must be deallocated... ", knocker_core_last_hostname); #endif if (knocker_core_last_hostname != NULL) free (knocker_core_last_hostname); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: knocker_core_last_service is: %s, memory must be deallocated... ", knocker_core_last_service); #endif if (knocker_core_last_service != NULL) free (knocker_core_last_service); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef __WIN32__ /* Shut Winsock back down */ WSACleanup (); #endif /* __WIN32__ */ } /* ============================================================================ ============================================================================ */ int knocker_core_init_portscan_data (knocker_core_portscan_data_t * data) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_init_portscan_data(...) called.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: initializing socket data with a call to knocker_core_init_socket_data()... "); #endif knocker_core_init_socket_data (&data->socket); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: initializing port data with a call to knocker_core_init_port_data()... "); #endif knocker_core_init_port_data (data->port); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: initializing host data with a call to knocker_core_init_host_data()... "); #endif knocker_core_init_host_data (&data->host); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif return 0; } /* ============================================================================ ============================================================================ */ void knocker_core_free_portscan_data (knocker_core_portscan_data_t * data) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_free_portscan_data(...) called\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: deallocating scoket data with a call to knocker_core_free_socket_data()... "); #endif knocker_core_free_socket_data (&data->socket); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: deallocating port data with a call to knocker_core_free_port_data()... "); #endif knocker_core_free_port_data (data->port); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: deallocating host data with a call to knocker_core_free_host_data()... "); #endif knocker_core_free_host_data (&data->host); #ifdef DEBUG fprintf (stderr, "done.\n"); #endif } /* ============================================================================ ============================================================================ */ char *knocker_core_get_hostname (knocker_core_portscan_data_t * data) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_get_hostname (...) called\n"); #endif if (knocker_core_last_hostname == NULL) { knocker_core_last_hostname = malloc (1 + strlen (knocker_core_get_host_name_string (&data->host))); } else { knocker_core_last_hostname = realloc (knocker_core_last_hostname, 1 + strlen (knocker_core_get_host_name_string (&data->host))); } #ifdef DEBUG fprintf (stderr, "debug: allocated %d bytes for knocker_core_last_hostname\n", 1 + strlen (knocker_core_get_host_name_string (&data->host))); fprintf (stderr, "debug: calling knocker_core_get_host_name_string to get the hostname...\n"); fprintf (stderr, "debug: knocker_core_get_host_name_string returned \"%s\" (%d bytes)\n", knocker_core_get_host_name_string (&data->host), strlen (knocker_core_get_host_name_string (&data->host))); #endif return (strcpy (knocker_core_last_hostname, knocker_core_get_host_name_string (&data->host))); } /* ============================================================================ ============================================================================ */ char *knocker_core_get_hostip (knocker_core_portscan_data_t * data) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_get_hostip (...) called\n"); #endif if (knocker_core_last_hostip == NULL) { knocker_core_last_hostip = malloc (1 + strlen (knocker_core_get_host_ip_string (&data->host))); } else { knocker_core_last_hostip = realloc (knocker_core_last_hostip, 1 + strlen (knocker_core_get_host_ip_string (&data->host))); } #ifdef DEBUG fprintf (stderr, "debug: allocated %d bytes for knocker_core_last_hostip\n", 1 + strlen (knocker_core_get_host_ip_string (&data->host))); fprintf (stderr, "debug: calling knocker_core_get_host_ip_string to get the host ip...\n"); fprintf (stderr, "debug: knocker_core_get_host_ip_string returned \"%s\" (%d bytes)\n", knocker_core_get_host_ip_string (&data->host), strlen (knocker_core_get_host_ip_string (&data->host))); #endif return (strcpy (knocker_core_last_hostip, knocker_core_get_host_ip_string (&data->host))); } /* ============================================================================ ============================================================================ */ char *knocker_core_get_service (unsigned int port, int protocol) { int slenght; /* string lenght */ char tmpstr[200]; /* That must be enought for a service name :-) */ /* I must be paranoid */ #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_get_service (...) called\n"); fprintf (stderr, "debug: arguments passed port: %d, protocol: %d\n", port, protocol); fprintf (stderr, "debug: checking if passed protocol type is OK... "); #endif if (protocol != PROTO_TCP) { #ifdef DEBUG fprintf (stderr, " it is not TCP... \n"); #endif if (protocol != PROTO_UDP) { #ifdef DEBUG fprintf (stderr, "nor UDP, returning NULL !!\n"); #endif return NULL; } } #ifdef DEBUG fprintf (stderr, "Yes.\n"); #endif /* this functions returns the number of copied chars in tmpstr, if it is successfull, else -1 */ slenght = knocker_core_getservbyport (tmpstr, port, protocol); #ifdef DEBUG fprintf (stderr, "debug: %d bytes to be allocated for knocker_core_last_service\n", slenght + 1); fprintf (stderr, "debug: returned service by knocker_core_getservbyport is \"%s\", (%d bytes)\n", tmpstr, strlen (tmpstr)); #endif if (slenght == -1) { if (knocker_core_last_service == NULL) { knocker_core_last_service = malloc (strlen ("unknown") + 1); strcpy (knocker_core_last_service, "unknown"); } else { knocker_core_last_service = realloc (knocker_core_last_service, strlen ("unknown") + 1); strcpy (knocker_core_last_service, "unknown"); } return NULL; } if (knocker_core_last_service == NULL) { knocker_core_last_service = malloc (slenght + 1); } else { knocker_core_last_service = realloc (knocker_core_last_service, slenght + 1); } return (strcpy (knocker_core_last_service, tmpstr)); } /* ============================================================================ ============================================================================ */ int knocker_core_validate_port_number (unsigned int port) { if (port < 1) return FALSE; if (port > KNOCKER_MAX_PORT_NUMBER) return FALSE; return TRUE; } /* ============================================================================ ============================================================================ */ int knocker_core_portscan_tcp_connnect (knocker_core_portscan_data_t * data, unsigned int port) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_portscan_tcp_connnect (...) called\n"); fprintf (stderr, "debug: connecting to port: %d\n", port); #endif if (knocker_core_open_socket (&data->socket, PROTO_TCP) == KNOCKER_SOCKET_ERROR) { #ifdef DEBUG fprintf (stderr, "debug: socket error, couldn't connect.\n"); #endif return -1; } data->host.sockaddr_in.sin_family = AF_INET; data->host.sockaddr_in.sin_port = htons (port); data->host.sockaddr_in.sin_addr = *((struct in_addr *) data->host.info->h_addr); memset (&(data->host.sockaddr_in.sin_zero), 0, 8); if (!connect (data->socket.fd, (struct sockaddr *) &data->host.sockaddr_in, sizeof (struct sockaddr))) /* here the port is open */ { knocker_core_close_socket (&data->socket); #ifdef DEBUG fprintf (stderr, "debug: connected to port: %d, port is open\n", port); #endif return PORT_OPEN; } #ifdef DEBUG fprintf (stderr, "debug: port: %d is closed\n", port); #endif /* the socket must be closed even if the remote port is closed */ knocker_core_close_socket (&data->socket); return (PORT_CLOSED); } /* ============================================================================ ============================================================================ */ char *knocker_core_resolve_host (knocker_core_portscan_data_t * data, const char *hostname) { if (knocker_core_gethostbyname (&data->host, hostname) == -1) return NULL; else return (data->host.ip); } /* ============================================================================ ============================================================================ */ static int knocker_core_init_host_data (knocker_core_host_t * host) { knocker_core_set_host_name_string (host, NULL); knocker_core_set_host_ip_string (host, NULL); return 0; } /* ============================================================================ ============================================================================ */ static void knocker_core_free_host_data (knocker_core_host_t * host) { knocker_core_free_host_name_string (host); knocker_core_free_host_ip_string (host); } /* ============================================================================ ============================================================================ */ static int knocker_core_init_port_data (knocker_core_port_t * port) { int i; for (i = 0; i < KNOCKER_MAX_PORT_NUMBER; i++) { port[i].number = 0; port[i].status = PORT_NONE; port[i].protocol = PROTO_NONE; port[i].service = NULL; } return 0; } /* ============================================================================ ============================================================================ */ static void knocker_core_free_port_data (knocker_core_port_t * port) { int i; for (i = 0; i < KNOCKER_MAX_PORT_NUMBER; i++) { port[i].number = 0; port[i].status = PORT_NONE; port[i].protocol = PROTO_NONE; if (port[i].service != NULL) { free (port[i].service); } } } /* ============================================================================ ============================================================================ */ static int knocker_core_init_socket_data (knocker_core_socket_t * sock) { if (sock->active == TRUE) knocker_core_close_socket (sock); sock->protocol = PROTO_NONE; sock->active = FALSE; return 0; } /* ============================================================================ ============================================================================ */ static void knocker_core_free_socket_data (knocker_core_socket_t * sock) { knocker_core_init_socket_data (sock); } /* ============================================================================ ============================================================================ */ static int knocker_core_open_socket (knocker_core_socket_t * sock, int protocol) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_open_socket (...) called.\n"); #endif if (protocol == PROTO_TCP) { if ((sock->fd = socket (AF_INET, SOCK_STREAM, 0)) == KNOCKER_SOCKET_ERROR) { #ifdef DEBUG fprintf (stderr, "debug: couldn't open the socket: "); perror ("socket"); #endif return -1; } } else if (protocol == PROTO_UDP) { if ((sock->fd = socket (AF_INET, SOCK_DGRAM, 0)) == KNOCKER_SOCKET_ERROR) { #ifdef DEBUG fprintf (stderr, "debug: couldn't open the socket: "); perror ("socket"); #endif return -1; } } else return -1; sock->protocol = protocol; sock->active = TRUE; #ifdef DEBUG fprintf (stderr, "debug: socket open succesfully."); #endif return 0; } /* ============================================================================ ============================================================================ */ static void knocker_core_close_socket (knocker_core_socket_t * sock) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_core_close_socket (...) called.\n"); #endif if (sock->active == FALSE) return; #ifdef __WIN32__ closesocket (sock->fd); #else close (sock->fd); #endif sock->active = FALSE; sock->protocol = PROTO_NONE; #ifdef DEBUG fprintf (stderr, "debug: socket closed.\n"); #endif } /* ============================================================================ ============================================================================ */ static int knocker_core_gethostbyname (knocker_core_host_t * hinfo, const char *hostname) { if ((hinfo->info = gethostbyname (hostname)) == NULL) return -1; knocker_core_set_host_name_string (hinfo, hostname); knocker_core_set_host_ip_string (hinfo, inet_ntoa (*(struct in_addr *) *hinfo->info->h_addr_list)); return 0; } /* ============================================================================ ============================================================================ */ static int knocker_core_getservbyport (char *service, unsigned int port, int protocol) { struct servent *service_st; if (protocol == PROTO_TCP) { service_st = getservbyport (htons (port), "tcp"); } else if (protocol == PROTO_UDP) { service_st = getservbyport (htons (port), "udp"); } else return -1; if (!service_st) { /*strcpy (service, "unknown"); */ service = NULL; return -1; } else { strcpy (service, service_st->s_name); } return (strlen (service_st->s_name)); } /* ============================================================================ ============================================================================ */ static int knocker_core_set_host_name_string (knocker_core_host_t * hinfo, const char *hostname) { if (hostname == NULL) { hinfo->name = NULL; return 0; } /* If the hostname in the hinfo structure is NULL we copy the passed hostname there. */ if (hinfo->name == NULL) { hinfo->name = malloc (strlen (hostname) + 1); strcpy (hinfo->name, hostname); } else /* if the hinfo->name is used already */ { /* if the hostname in the hinfo structure is not the same as the passed hostname, we just update it. */ if (strcmp (hinfo->name, hostname)) { hinfo->name = realloc (hinfo->name, strlen (hostname) + 1); strcpy (hinfo->name, hostname); } } return 0; } /* ============================================================================ ============================================================================ */ static int knocker_core_set_host_ip_string (knocker_core_host_t * hinfo, const char *hostip) { if (hostip == NULL) { hinfo->ip = NULL; return 0; } /* If the hostname in the hinfo structure is NULL we copy the passed hostip there. */ if (hinfo->ip == NULL) { hinfo->ip = malloc (strlen (hostip) + 1); strcpy (hinfo->ip, hostip); } else /* if the hinfo->ip is used already */ { /* if the hostname in the hinfo structure is not the same as the passed hostip, we just update it. */ if (strcmp (hinfo->ip, hostip)) { hinfo->ip = realloc (hinfo->ip, strlen (hostip) + 1); strcpy (hinfo->ip, hostip); } } return 0; } /* ============================================================================ ============================================================================ */ static char *knocker_core_get_host_name_string (knocker_core_host_t * hinfo) { return (hinfo->name); } /* ============================================================================ ============================================================================ */ static char *knocker_core_get_host_ip_string (knocker_core_host_t * hinfo) { return (hinfo->ip); } /* ============================================================================ ============================================================================ */ static void knocker_core_free_host_name_string (knocker_core_host_t * hinfo) { if (hinfo->name != NULL) { free (hinfo->name); knocker_core_set_host_name_string (hinfo, NULL); } } /* ============================================================================ ============================================================================ */ static void knocker_core_free_host_ip_string (knocker_core_host_t * hinfo) { if (hinfo->ip != NULL) { free (hinfo->ip); knocker_core_set_host_ip_string (hinfo, NULL); } } knocker-0.7.1/src/knocker_core.h0000644000175000001440000001750507473301075012252 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_CORE_H_ #define _KNOCKER_CORE_H_ #ifdef HAVE_CONFIG_H # include #endif #ifndef PACKAGE #define PACKAGE "knocker" #endif #ifndef VERSION #define VERSION _KNOCKER_CORE_VERSION_ #endif #include #include #include #ifdef __WIN32__ /* Use Winsock Version 1.1 */ /* To be linked with -lwsock32 */ #include #include #elif defined __WIN32_WINSOCK2__ /* Use Winsock Version 2.0 */ /* To be linked with -lws2_32 */ #define __WIN32__ #include #include #else #include #include #include #include #include #include #include #endif /* __WIN32__ */ /* If in trouble .... :-) */ /* #define DEBUG */ /* and run knocker in quiet mode to se debug output only */ #ifndef _KNOCKER_CORE_VERSION_ #define _KNOCKER_CORE_VERSION_ "0.7.1" #endif #ifndef _KNOCKER_CORE_RELEASE_DATE_ #define _KNOCKER_CORE_RELEASE_DATE_ "24 May 2002" #endif #ifndef _KNOCKER_CORE_HOMEPAGE_ #define _KNOCKER_CORE_HOMEPAGE_ "http://knocker.sourceforge.net" #endif #ifndef _KNOCKER_CORE_AUTHOR_ #define _KNOCKER_CORE_AUTHOR_ "Gabriele Giorgetti" #endif #ifndef _KNOCKER_CORE_AUTHOR_EMAIL_ #define _KNOCKER_CORE_AUTHOR_EMAIL_ "" #endif #define KNOCKER_DEFAULT_PORT_RANGE 1024 /* by default scan from 1 to 1024 */ #define KNOCKER_MAX_PORT_NUMBER 65535 /* max allowed port number */ #ifndef FALSE enum { FALSE, TRUE }; #endif #ifndef EXIT_FAILURE enum { EXIT_SUCCESS, EXIT_FAILURE }; #endif enum { PORT_NONE, PORT_CLOSED, PORT_OPEN }; enum { PROTO_NONE, PROTO_UDP, PROTO_TCP }; #ifdef __WIN32__ #define KNOCKER_SOCKET_ERROR INVALID_SOCKET #else #define KNOCKER_SOCKET_ERROR -1 /* in UNIX socket errors are returned with -1 */ #endif /* __WIN32__ */ typedef struct { #ifdef __WIN32__ SOCKET fd; /* Winsocket socket */ #else int fd; /* socket file descriptor */ #endif /* __WIN32__ */ int active; /* if socket is connected or not, TRUE or FALSE */ int protocol; /* protocol PROTO_NONE, PROTO_UDP, PROTO_TCP */ } knocker_core_socket_t; typedef struct { unsigned int number; /* port number */ char *service; /* associated service name */ int status; /* port status, PORT_NONE PORT_OPEN or PORT_CLOSED */ int protocol; /* protocol PROTO_NONE, PROTO_UDP, PROTO_TCP */ } knocker_core_port_t; /* typedef struct { char *servname; char *servinfo; } knocker_core_services_db_t; */ typedef struct { struct hostent *info; /* hostent structure */ struct sockaddr_in sockaddr_in; /* sockaddr_in structure */ char *name; /* hostname string */ char *ip; /* host IP address string */ } knocker_core_host_t; typedef struct { knocker_core_socket_t socket; knocker_core_port_t port[KNOCKER_MAX_PORT_NUMBER]; knocker_core_host_t host; } knocker_core_portscan_data_t; #ifdef __WIN32__ WSADATA knocker_core_wsadata; #endif /* __WIN32__ */ #define knocker_socket_t knocker_core_socket_t #define knocker_port_t knocker_core_port_t #define knocker_host_t knocker_core_host_t #define knocker_portscan_data_t knocker_core_portscan_data_t static const char knocker_core_version[] = _KNOCKER_CORE_VERSION_; static const char knocker_core_release_date[] = _KNOCKER_CORE_RELEASE_DATE_; static const char knocker_core_homepage[] = _KNOCKER_CORE_HOMEPAGE_; static const char knocker_core_author[] = _KNOCKER_CORE_AUTHOR_; static const char knocker_core_author_email[] = _KNOCKER_CORE_AUTHOR_EMAIL_; /* allocated and deallocated within knocker_core_init, knocker_core_quit */ char *knocker_core_last_hostip; /* string of the last resolved host ip address */ char *knocker_core_last_hostname; /* string of the last used host name */ char *knocker_core_last_service; /* string of the last service */ int knocker_core_init ( void ); void knocker_core_quit ( void ); int knocker_core_portscan_tcp_connnect (knocker_core_portscan_data_t *data, unsigned int port); /* Initialize the knocker_core_portscan_data_t structure data */ int knocker_core_init_portscan_data (knocker_core_portscan_data_t *data); /* Frees the the knocker_core_portscan_data_t structure data */ void knocker_core_free_portscan_data (knocker_core_portscan_data_t *data); /* Returns FALSE if port is > than KNOCKER_MAX_PORT_NUMBER and < 1 */ int knocker_core_validate_port_number (unsigned int port); /* returns host ip address on success, NULL on failure */ char *knocker_core_resolve_host (knocker_core_portscan_data_t *data, const char *hostname); /* return the hostname string from the structure */ char *knocker_core_get_hostname (knocker_core_portscan_data_t *data); /* return the host ip string from the structure */ char *knocker_core_get_hostip (knocker_core_portscan_data_t *data); /* return the service name string using getservbyport */ char *knocker_core_get_service (unsigned int port, int protocol); /* Functions used internally ---- ------------------------------------------------------------------------------------------ static int knocker_core_init_port_data (knocker_core_port_t *port); static void knocker_core_free_port_data (knocker_core_port_t *port); static int knocker_core_init_socket_data (knocker_core_socket_t *sock); static void knocker_core_free_socket_data (knocker_core_socket_t *sock); static int knocker_core_open_socket (knocker_core_socket_t *sock, int protocol); static void knocker_core_close_socket (knocker_core_socket_t *sock); static int knocker_core_init_host_data (knocker_core_host_t *host); static void knocker_core_free_host_data (knocker_core_host_t *host); static int knocker_core_gethostbyname (knocker_core_host_t *hinfo, const char *hostname); static int knocker_core_getservbyport (char *service, unsigned int port, int protocol); static char *knocker_core_get_host_name_string (knocker_core_host_t *hinfo); static char *knocker_core_get_host_ip_string (knocker_core_host_t *hinfo); static int knocker_core_set_host_name_string (knocker_core_host_t *hinfo, const char *hostname); static int knocker_core_set_host_ip_string (knocker_core_host_t *hinfo, const char *hostip); static void knocker_core_free_host_name_string (knocker_core_host_t *hinfo); static void knocker_core_free_host_ip_string (knocker_core_host_t *hinfo); ----- ------------------------- --------------------------------------------------------------- */ #endif /* _KNOCKER_CORE_H_ */ knocker-0.7.1/src/knocker_args.c0000644000175000001440000003577707473301051012256 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #include "knocker_core.h" #include "knocker_args.h" #include "knocker_user.h" #include "knocker_conf.h" #include "knocker_log.h" /* used internally by knocker_args_parse */ static void knocker_args_validate (knocker_args_t * args, int argc, char *argv[]); static int _have_last_host = 0; /* tells if we've got the host with the --last-host option */ /* ============================================================================ ============================================================================ */ static void print_version_info (void) { #ifdef __WIN32__ fprintf (stdout, "%s %s-Win32 (%s)\n", PACKAGE, VERSION, knocker_core_release_date); #else fprintf (stdout, "%s %s (%s)\n", PACKAGE, VERSION, knocker_core_release_date); #endif } /* ============================================================================ ============================================================================ */ static void print_help_info (void) { #ifdef __WIN32__ fprintf (stdout, "%s, the net portscanner. Version %s-Win32 (%s)\n", PACKAGE, VERSION, knocker_core_release_date); #else fprintf (stdout, "%s, the net portscanner. Version %s (%s)\n", PACKAGE, VERSION, knocker_core_release_date); #endif fprintf (stdout, "\n"); fprintf (stdout, "Usage: %s %s [OPTIONS]\n", PACKAGE, HOST_LONG_OPT); fprintf (stdout, "\n"); fprintf (stdout, "Example: %s %s 192.168.0.1 %s 1 %s 1024\n", PACKAGE, HOST_SHORT_OPT, START_PORT_SHORT_OPT, END_PORT_SHORT_OPT); fprintf (stdout, "\n"); fprintf (stdout, "Required options:\n"); fprintf (stdout, " %s, %s host name or numeric Internet address\n", HOST_SHORT_OPT, HOST_LONG_OPT); fprintf (stdout, " or\n"); fprintf (stdout, " %s get the last scanned host name\n", LAST_HOST_LONG_OPT); fprintf (stdout, "\n"); fprintf (stdout, "Common options (if SP is specified you must also give EP):\n"); fprintf (stdout, " %s, %s single port number (for one port scans only)\n", SINGLE_PORT_SHORT_OPT, SINGLE_PORT_LONG_OPT); fprintf (stdout, " %s, %s port number to begin the scan from\n", START_PORT_SHORT_OPT, START_PORT_LONG_OPT); fprintf (stdout, " %s, %s port number to end the scan at\n", END_PORT_SHORT_OPT, END_PORT_LONG_OPT); fprintf (stdout, "\n"); fprintf (stdout, " %s performs again the last port scan\n", LAST_SCAN_LONG_OPT); fprintf (stdout, "\n"); fprintf (stdout, "Extra options:\n"); fprintf (stdout, " %s, %s quiet mode (no console output, logs to file)\n", QUIET_MODE_SHORT_OPT, QUIET_MODE_LONG_OPT); fprintf (stdout, " %s, %s log scan results to the specified file\n", ENABLE_LOGFILE_SHORT_OPT, ENABLE_LOGFILE_LONG_OPT); fprintf (stdout, " %s, %s disable fency output\n", NO_FENCY_SHORT_OPT, NO_FENCY_LONG_OPT); fprintf (stdout, " %s, %s disable colored output\n", NO_COLORS_SHORT_OPT, NO_COLORS_LONG_OPT); fprintf (stdout, "\n"); fprintf (stdout, " %s let you configure %s\n", CONFIGURE_LONG_OPT, PACKAGE); fprintf (stdout, "\n"); fprintf (stdout, "Info options:\n"); fprintf (stdout, " %s, %s display this help and exit\n", HELP_SHORT_OPT, HELP_LONG_OPT); fprintf (stdout, " %s, %s output version information and exit\n", VERSION_SHORT_OPT, VERSION_LONG_OPT); fprintf (stdout, "\n"); fprintf (stdout, "SEE THE MAN PAGE FOR MORE DESCRIPTIONS, AND EXAMPLES\n"); fprintf (stdout, "Report bugs to %s.\n", knocker_core_author_email); } /* ============================================================================ ============================================================================ */ int knocker_args_init (knocker_args_t * args, int logfile, int quiet, int colors) { args->hname = NULL; args->hip = NULL; args->lfname = NULL; args->port = 0; args->sport = 0; args->eport = 0; args->logfile = logfile; args->quiet = quiet; args->colors = colors; args->fency = TRUE; /* true by default */ return 0; } /* ============================================================================ ============================================================================ */ void knocker_args_free (knocker_args_t * args) { if (args->hname != NULL) free (args->hname); if (args->lfname != NULL) free (args->lfname); if (args->hip != NULL) free (args->hip); } /* ============================================================================ ============================================================================ */ /* int knocker_args_argument (knocker_args_t *args, unsigned short argument) { } */ /* ============================================================================ ============================================================================ */ int knocker_args_parse (knocker_args_t * args, int argc, char *argv[]) { int i; if (argv[1] == NULL) { fprintf (stderr, "%s: no arguments given\n", PACKAGE); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); exit (EXIT_FAILURE); } for (i = 1; i <= argc - 1; i++) { if ((!strcmp (argv[i], VERSION_SHORT_OPT)) || (!strcmp (argv[i], VERSION_LONG_OPT))) { print_version_info (); exit (EXIT_SUCCESS); } else if ((!strcmp (argv[i], HELP_SHORT_OPT)) || (!strcmp (argv[i], HELP_LONG_OPT))) { print_help_info (); exit (EXIT_SUCCESS); } else if (!strcmp (argv[i], CONFIGURE_LONG_OPT)) { knocker_conf_configure (); exit (EXIT_SUCCESS); } else if (!strcmp (argv[i], LAST_SCAN_LONG_OPT)) { /* attempts to read all arguments from the last performed port scan */ if (knocker_user_read_lastscan (&knocker_user, args) < 0) { fprintf (stderr, "%s: couldn't find any last port scan record.\n", PACKAGE); fprintf (stderr, "This could be because you haven't performed a port scan yet.\n"); knocker_args_free (args); exit (EXIT_FAILURE); } return (0); /* we should have all arguments here */ } else if ((!strcmp (argv[i], NO_FENCY_SHORT_OPT)) || (!strcmp (argv[i], NO_FENCY_LONG_OPT))) { /* Disable fency output */ args->fency = FALSE; } else if ((!strcmp (argv[i], NO_COLORS_SHORT_OPT)) || (!strcmp (argv[i], NO_COLORS_LONG_OPT))) { /* Disable colored output */ args->colors = FALSE; } else if ((!strcmp (argv[i], ENABLE_LOGFILE_SHORT_OPT)) || (!strcmp (argv[i], ENABLE_LOGFILE_LONG_OPT))) { if (++i == argc) { fprintf (stderr, "%s: error, no logfile given\n", PACKAGE); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } /* allocate space and set the logfile string arg */ args->lfname = realloc (args->lfname, strlen (argv[i]) + 1); strcpy (args->lfname, argv[i]); /* log scan results to file */ args->logfile = TRUE; } else if ((!strcmp (argv[i], QUIET_MODE_SHORT_OPT)) || (!strcmp (argv[i], QUIET_MODE_LONG_OPT))) { /* Enable quiet mode, disable stdout output, and log result to file */ args->quiet = TRUE; args->colors = FALSE; args->logfile = TRUE; } else if (!strcmp (argv[i], LAST_HOST_LONG_OPT)) { /* attempts to read the last host argument from the last performed port scan */ if (knocker_user_read_lasthost (&knocker_user, args) < 0) { fprintf (stderr, "%s: couldn't find any 'lasthost' record.\n", PACKAGE); fprintf (stderr, "This could be because you haven't performed a port scan yet.\n"); knocker_args_free (args); exit (EXIT_FAILURE); } _have_last_host = 1; /* Got the hostname, set this to 1 so other functions'll know that we have a host */ } else if ((!strcmp (argv[i], HOST_SHORT_OPT)) || (!strcmp (argv[i], HOST_LONG_OPT))) { if (!_have_last_host) /* If we haven't got the host to scan yet we check and get it if the user has passed it */ { if (++i == argc) { fprintf (stderr, "%s: error, no host to scan given\n", PACKAGE); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } /* allocate space and set the hostname string arg */ args->hname = realloc (args->hname, strlen (argv[i]) + 1); strcpy (args->hname, argv[i]); } } else if ((!strcmp (argv[i], SINGLE_PORT_SHORT_OPT)) || (!strcmp (argv[i], SINGLE_PORT_LONG_OPT))) { if (++i == argc) { fprintf (stderr, "%s: error, no port number given\n", PACKAGE); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } /* set the single port number for the one-port-only-scan */ args->port = atoi (argv[i]); if (!knocker_core_validate_port_number (args->port)) { fprintf (stderr, "%s: error, invalid port number `%d' given\n", PACKAGE, args->port); knocker_args_free (args); exit (EXIT_FAILURE); } } else if ((!strcmp (argv[i], START_PORT_SHORT_OPT)) || (!strcmp (argv[i], START_PORT_LONG_OPT))) { if (++i == argc) { fprintf (stderr, "%s: error, no port number, where to start the scan from, given\n", PACKAGE); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } /* set the start port number */ args->sport = atoi (argv[i]); if (!knocker_core_validate_port_number (args->sport)) { fprintf (stderr, "%s: error, invalid start port number `%d' given\n", PACKAGE, args->sport); knocker_args_free (args); exit (EXIT_FAILURE); } } else if ((!strcmp (argv[i], END_PORT_SHORT_OPT)) || (!strcmp (argv[i], END_PORT_LONG_OPT))) { if (++i == argc) { fprintf (stderr, "%s: error, no port number, where to scan to, given\n", PACKAGE); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } /* set the end port number */ args->eport = atoi (argv[i]); if (!knocker_core_validate_port_number (args->eport)) { fprintf (stderr, "%s: error, invalid end port number `%d' given\n", PACKAGE, args->eport); knocker_args_free (args); exit (EXIT_FAILURE); } } else if ((!strcmp (argv[i], WIN32_FRONTEND_SHORT_OPT)) || (!strcmp (argv[i], WIN32_FRONTEND_LONG_OPT))) { /* Disable colored output */ args->win32_frontend = TRUE; } else { fprintf (stderr, "%s: invalid argument given: '%s'\n", PACKAGE, argv[i]); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } } /* end of for loop */ knocker_args_validate (args, argc, argv); return 0; } /* ============================================================================ ============================================================================ */ static void knocker_args_validate (knocker_args_t * args, int argc, char *argv[]) { int we_havegot_host = 0; int we_havegot_sp = 0; int we_havegot_ep = 0; int i; for (i = 1; i <= argc - 1; i++) { if ((!strcmp (argv[i], HOST_SHORT_OPT)) || (!strcmp (argv[i], HOST_LONG_OPT)) || (!strcmp (argv[i], LAST_HOST_LONG_OPT))) { we_havegot_host = 1; _have_last_host = 0; /* reset the _have_last_host variable */ } if ((!strcmp (argv[i], START_PORT_SHORT_OPT)) || (!strcmp (argv[i], START_PORT_LONG_OPT))) we_havegot_sp = 1; if ((!strcmp (argv[i], END_PORT_SHORT_OPT)) || (!strcmp (argv[i], END_PORT_LONG_OPT))) we_havegot_ep = 1; } if (!we_havegot_host) /* if HOST_SHORT_OPT or HOST_LONG_OPT is not the args */ { fprintf (stderr, "%s: error, no host to scan given\n", PACKAGE); fprintf (stderr, "You must provide a host to scan with 'the %s ' or '%s ' option.\n", HOST_LONG_OPT, HOST_SHORT_OPT); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } if ((we_havegot_sp) && (!we_havegot_ep)) { fprintf (stderr, "%s: error, start port number given but no end port number. \n", PACKAGE); fprintf (stderr, "You must provide both a port number where to start the scan from and end\n"); fprintf (stderr, "the scan to: %s %s \n", START_PORT_LONG_OPT, END_PORT_LONG_OPT); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } if ((!we_havegot_sp) && (we_havegot_ep)) { fprintf (stderr, "%s: error, end port number given but no start port number. \n", PACKAGE); fprintf (stderr, "You must provide both a port number where to start the scan from and end\n"); fprintf (stderr, "the scan to: %s %s \n", START_PORT_LONG_OPT, END_PORT_LONG_OPT); fprintf (stderr, "Try `%s %s' for more information.\n", PACKAGE, HELP_LONG_OPT); knocker_args_free (args); exit (EXIT_FAILURE); } } knocker-0.7.1/src/knocker_args.h0000644000175000001440000000735007473301053012247 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_ARGS_H_ #define _KNOCKER_ARGS_H_ /* COMMAND LINE ARGUMENTS DEFINITION */ /* ********************************** */ /* host to scan */ #define HOST_SHORT_OPT "-H" #define HOST_LONG_OPT "--host" /* host to scan, got with lasthost */ #define LAST_HOST_LONG_OPT "--last-host" /* single port number */ #define SINGLE_PORT_SHORT_OPT "-P" #define SINGLE_PORT_LONG_OPT "--port" /* port number to start with */ #define START_PORT_SHORT_OPT "-SP" #define START_PORT_LONG_OPT "--start-port" /* port number to scan to */ #define END_PORT_SHORT_OPT "-EP" #define END_PORT_LONG_OPT "--end-port" /* Log scan results to file */ #define ENABLE_LOGFILE_SHORT_OPT "-lf" #define ENABLE_LOGFILE_LONG_OPT "--logfile" /* disable output to stdout, disable threads */ #define QUIET_MODE_SHORT_OPT "-q" #define QUIET_MODE_LONG_OPT "--quiet" /* option to disable fency cool out put */ #define NO_FENCY_SHORT_OPT "-nf" #define NO_FENCY_LONG_OPT "--no-fency" /* option to disable colored out put */ #define NO_COLORS_SHORT_OPT "-nc" #define NO_COLORS_LONG_OPT "--no-colors" /* option --last-scan, reperforms the last port scan */ #define LAST_SCAN_LONG_OPT "--last-scan" /* option --configure, let the usere configure knocker */ #define CONFIGURE_LONG_OPT "--configure" #define WIN32_FRONTEND_SHORT_OPT "--win32-frontend" #define WIN32_FRONTEND_LONG_OPT "--win32-frontend" #define HELP_SHORT_OPT "-h" #define HELP_LONG_OPT "--help" #define VERSION_SHORT_OPT "-v" #define VERSION_LONG_OPT "--version" /* ********************************** */ typedef struct { char *hname; /* hostname string */ char *hip; /* host IP string */ char *lfname; /* logfile name */ unsigned int port; /* Single port number, -P */ unsigned int sport; /* Start port number, -SP */ unsigned int eport; /* End port number, -EP */ int logfile; /* log to file TRUE,FALSE */ int quiet; /* quiet mode TRUE,FALSE */ int colors; /* no colors, TRUE,FALSE */ int fency; /* fency output, TRUE, FALSE */ int win32_frontend; } knocker_args_t; knocker_args_t knocker_args; /* command line arguments structure */ /* Initialize a knocker_args_t type of structure */ int knocker_args_init (knocker_args_t *args, int logfile, int quiet, int colors); /* Free a previously initialized knocker_args_t type of strucutre */ void knocker_args_free (knocker_args_t *args); /* Parse passed arguments, fills a previously initialized knocker_args_t type of structure, and hanndles some options like --version, and --help. */ int knocker_args_parse (knocker_args_t *args, int argc, char *argv[]); /* This tells knocker (returning TRUE or FALSE) if an option is enabled or not. */ /* int knocker_args_argument (knocker_args_t *args, unsigned short argument); */ #endif /* _KNOCKER_ARGS_H_ */ knocker-0.7.1/src/knocker_user.c0000644000175000001440000002353107473301203012260 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #ifdef __WIN32__ #else #include #include #include #include #include #endif /* __WIN32__ */ #include "knocker_core.h" #include "knocker_args.h" #include "knocker_user.h" #define KNOCKER_USER_DIR PACKAGE #define KNOCKER_LASTSCAN_FILE "lastscan" #define KNOCKER_TOKEN "|" static int _dir_exists (const char *path); static int _dir_create (const char *path); static int _file_exists (const char *path); static int _file_readline (FILE * fp, char *line, int maxlen); /* ============================================================================ ============================================================================ */ int knocker_user_init (knocker_user_t * user) { #ifdef DEBUG fprintf (stderr, "debug: function knocker_user_init() called.\n"); #endif if (knocker_user_get_username () != NULL) { if (user->name != NULL) user->name = realloc (user->name, strlen (knocker_user_get_username ()) + 1); else user->name = malloc (strlen (knocker_user_get_username ()) + 1); } user->name = knocker_user_get_username (); if (user->dir != NULL) user->dir = realloc (user->dir, strlen (knocker_user_get_userhome ()) + strlen (KNOCKER_USER_DIR) + 3); else user->dir = malloc (strlen (knocker_user_get_userhome ()) + strlen (KNOCKER_USER_DIR) + 3); strcpy (user->dir, knocker_user_get_userhome ()); strcat (user->dir, "/."); strcat (user->dir, KNOCKER_USER_DIR); if (!_dir_exists (user->dir)) { _dir_create (user->dir); } if (knocker_user_is_root) user->super = 1; else user->super = 0; #ifdef DEBUG fprintf (stderr, "debug: username is: %s\n", user->name); #endif return 0; } /* ============================================================================ ============================================================================ */ void knocker_user_free (knocker_user_t * user) { /* This causes Segmentation Fault ... if ( user->name != NULL) free(user->name); */ if (user->dir != NULL) free (user->dir); user->super = 0; } /* ============================================================================ ============================================================================ */ int knocker_user_write_lastscan (knocker_user_t * user, knocker_args_t * args) { char *lscanfile; FILE *fp; if (args->hname == NULL) return -1; if (args->port == 0) { if ((args->sport == 0) && (args->eport == 0)) return -1; } lscanfile = malloc (strlen (user->dir) + strlen (KNOCKER_LASTSCAN_FILE) + 2); sprintf (lscanfile, "%s/%s", user->dir, KNOCKER_LASTSCAN_FILE); if ((fp = fopen (lscanfile, "w")) == NULL) { /* couldn't create file */ free (lscanfile); return -1; } free (lscanfile); fprintf (fp, "%s%s", args->hname, KNOCKER_TOKEN); fprintf (fp, "%d%s", args->port, KNOCKER_TOKEN); fprintf (fp, "%d%s", args->sport, KNOCKER_TOKEN); fprintf (fp, "%d%s", args->eport, KNOCKER_TOKEN); fprintf (fp, "%d%s", args->logfile, KNOCKER_TOKEN); if (args->logfile) fprintf (fp, "%s%s", args->lfname, KNOCKER_TOKEN); else fprintf (fp, "null%s", KNOCKER_TOKEN); fprintf (fp, "%d%s", args->quiet, KNOCKER_TOKEN); fprintf (fp, "%d%s", args->colors, KNOCKER_TOKEN); fprintf (fp, "\n"); fclose (fp); return 0; } /* ============================================================================ ============================================================================ */ int knocker_user_read_lastscan (knocker_user_t * user, knocker_args_t * args) { char *lscanfile; char line[255]; char *buffer[255]; int i = 0; FILE *fp; lscanfile = malloc (strlen (user->dir) + strlen (KNOCKER_LASTSCAN_FILE) + 2); sprintf (lscanfile, "%s/%s", user->dir, KNOCKER_LASTSCAN_FILE); if (_file_exists (lscanfile)) { } if ((fp = fopen (lscanfile, "r")) == NULL) { /* couldn't open file */ free (lscanfile); return -1; } free (lscanfile); if (_file_readline (fp, line, 255) < 0) { /* something wrong happened */ return -1; } /* get the argument using strtok on the line */ buffer[i++] = strtok (line, KNOCKER_TOKEN); /* get the first */ while ((buffer[i++] = strtok (NULL, KNOCKER_TOKEN))); /* and then the others */ /* allocate space and set the hostname string arg */ args->hname = realloc (args->hname, strlen (buffer[0]) + 1); strcpy (args->hname, buffer[0]); args->port = atoi (buffer[1]); args->sport = atoi (buffer[2]); args->eport = atoi (buffer[3]); args->logfile = atoi (buffer[4]); if (args->logfile) { /* allocate space and set the logfile string arg */ args->lfname = realloc (args->lfname, strlen (buffer[5]) + 1); strcpy (args->lfname, buffer[5]); } args->quiet = atoi (buffer[6]); args->colors = atoi (buffer[7]); /* printf("0, args->hname: %s\n", buffer[0]); printf("1, args->port: %s\n", buffer[1]); printf("2, args->sport: %s\n", buffer[2]); printf("3, args->eport: %s\n", buffer[3]); printf("4, args->logfile: %s\n", buffer[4]); printf("5, args->lfname: %s\n", buffer[5]); printf("6, args->quiet: %s\n", buffer[6]); printf("7, args->colors: %s\n", buffer[7]); */ fclose (fp); return 0; } /* ============================================================================ ============================================================================ */ int knocker_user_read_lasthost (knocker_user_t * user, knocker_args_t * args) { char *lscanfile; char line[255]; char *buffer[255]; int i = 0; FILE *fp; lscanfile = malloc (strlen (user->dir) + strlen (KNOCKER_LASTSCAN_FILE) + 2); sprintf (lscanfile, "%s/%s", user->dir, KNOCKER_LASTSCAN_FILE); if (_file_exists (lscanfile)) { } if ((fp = fopen (lscanfile, "r")) == NULL) { /* couldn't open file */ free (lscanfile); return -1; } free (lscanfile); if (_file_readline (fp, line, 255) < 0) { /* something wrong happened */ return -1; } /* get the argument using strtok on the line */ buffer[i++] = strtok (line, KNOCKER_TOKEN); /* get the first, the host */ /* allocate space and set the hostname string arg */ args->hname = realloc (args->hname, strlen (buffer[0]) + 1); strcpy (args->hname, buffer[0]); fclose (fp); return 0; } /* ============================================================================ ============================================================================ */ int knocker_user_is_root (void) { #ifdef __WIN32__ return (1); #else if (getuid () == 0) /* user is root */ return 1; #endif /* __WIN32__ */ return 0; } /* ============================================================================ ============================================================================ */ char *knocker_user_get_username (void) { #ifdef __WIN32__ return (NULL); #else if (getenv ("USER") != NULL) /* the USER variable is not present in some */ return (getenv ("USER")); /* Linux distribution. LOGNAME should be there. */ else if (getenv ("LOGNAME") != NULL) return (getenv ("LOGNAME")); else return (NULL); #endif /* __WIN32__ */ } /* ============================================================================ ============================================================================ */ char *knocker_user_get_userhome (void) { #ifdef __WIN32__ return (NULL); #else return (getenv ("HOME")); #endif /* __WIN32__ */ } /* ---- internally used functions -------------- */ static int _dir_create (const char *path) { #ifdef __WIN32__ return (0); #else /* first let's check if the directory exists already */ if (_dir_exists (path)) return 0; /* directory exist, no need to create it again */ /* 0700 Allow only the user to read, write, and execute */ if (mkdir (path, 0700) != 0) return -1; /* couldn't create dir */ #endif /* __WIN32__ */ return 0; } static int _dir_exists (const char *path) { #ifdef __WIN32__ #else struct stat dirstat; if (stat (path, &dirstat) != 0) { /* couln't access to directory */ return 0; } if (S_ISDIR (dirstat.st_mode)) { /* directory exist and "it's a directory" */ return 1; } #endif /* __WIN32__ */ return 0; } static int _file_exists (const char *path) { #ifdef __WIN32__ #else struct stat filestat; if (stat (path, &filestat) != 0) { /* coulnd't access to file */ return 0; } if (S_ISREG (filestat.st_mode)) { /* file exist and "it's a regular file" */ return 1; } #endif /* __WIN32__ */ return 0; } static int _file_readline (FILE * fp, char *line, int maxlen) { int i = 0; int c; while (i < maxlen) { c = fgetc (fp); if (c == EOF) { line[i] = '\0'; return (EOF); } if (c == '\n') break; line[i] = c; i++; } line[i] = '\0'; return (i); } knocker-0.7.1/src/knocker_user.h0000644000175000001440000000317007473301204012263 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_USER_H_ #define _KNOCKER_USER_H_ typedef struct { char *name; /* user name */ char *dir; /* knocker dir under the user home ex: /home/user/.knocker */ int super; /* user is root or not */ } knocker_user_t; knocker_user_t knocker_user; int knocker_user_is_root ( void ); char *knocker_user_get_username ( void ); char *knocker_user_get_userhome ( void ); int knocker_user_init (knocker_user_t *user); void knocker_user_free (knocker_user_t *user); int knocker_user_read_lastscan (knocker_user_t *user, knocker_args_t *args); int knocker_user_write_lastscan (knocker_user_t *user, knocker_args_t *args); int knocker_user_read_lasthost (knocker_user_t *user, knocker_args_t *args); #endif /* _KNOCKER_USER_H_ */ knocker-0.7.1/src/knocker_conf.c0000644000175000001440000005064307473301065012241 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #include #include #include #include "knocker_core.h" #include "knocker_args.h" #include "knocker_term.h" #include "knocker_user.h" #include "knocker_conf.h" /* ============================================================================ ============================================================================ */ static int _isblank (int c) { if (c == '\t') return 0; if (c == ' ') return 0; return 1; } /* ============================================================================ ============================================================================ */ static int _isno (char *answer) { if (!strcmp (answer, "N")) return 1; else if (!strcmp (answer, "NO")) return 1; else if (!strcmp (answer, "n")) return 1; else if (!strcmp (answer, "no")) return 1; return 0; } /* ============================================================================ ============================================================================ */ static int _isyes (char *answer) { if (!strcmp (answer, "Y")) { return 1; } else if (!strcmp (answer, "YES")) { return 1; } else if (!strcmp (answer, "y")) { return 1; } else if (!strcmp (answer, "yes")) { return 1; } else return 0; return 0; } /* ============================================================================ ============================================================================ */ static char *_get_answer (char *answer) { char *tmp = malloc (KNOCKER_CONF_MAX_LEN); /* Looks like I have problems using fgets */ /* if ( fgets(tmp, KNOCKER_CONF_MAX_LEN, stdin) == NULL) { free(tmp); return NULL; } */ /* Let's go for the good old scanf */ fscanf (stdin, "%s", tmp); if (answer == NULL) answer = malloc (strlen (tmp) + 1); else answer = realloc (answer, strlen (tmp) + 1); strcpy (answer, tmp); free (tmp); return answer; } /* ============================================================================ ============================================================================ */ static int _iscommented (char *line, char comment) { int first_char = 0; int i = 0; if (line[0] == comment) return 1; while (i < strlen (line)) { if (line[i] == '\0') return 0; if (_isblank (line[i]) && !first_char) i++; if (line[i] != comment && !first_char) return 0; if ((line[i] == comment) && !first_char) return 1; else if ((line[i] != comment) && !first_char) return 0; i++; } return 0; } /* ============================================================================ ============================================================================ */ static int _isvalid (char *line, char token) { /* Check for the KNOCKER_OPTION_TOKEN char */ if (strchr (line, token) == NULL) return 0; return 1; } /* ============================================================================ ============================================================================ */ static int _fgetline (FILE * fp, char *line, int maxlen) { int i = 0; int c; while (i < maxlen) { c = fgetc (fp); if (c == EOF) { line[i] = '\0'; return (EOF); } if (c == '\n') break; line[i] = c; i++; } line[i] = '\0'; return (i); } /* ============================================================================ ============================================================================ */ static int _getoptval (char *line, char *opt, char *value) { char *tmpp = malloc (strlen (line)); char *p = malloc (strlen (line)); /* Check if the option is present in the line */ tmpp = strstr (line, opt); if (tmpp == NULL) return 0; /* nope */ tmpp = tmpp + strlen (opt); if (!_isblank (*tmpp) || *tmpp != KNOCKER_OPTION_TOKEN) { free (tmpp); return 0; } /* Check for the KNOCKER_OPTION_TOKEN char */ p = strchr (line, KNOCKER_OPTION_TOKEN); p++; value = realloc (value, strlen (p) + 1); strcpy (value, p); /* free(p); this cause knocker to segfault */ /* well I have to know why... */ return 1; } /* ============================================================================ ============================================================================ */ int _get_color_by_opt (char *opt_value) { int color; if (!strcmp (opt_value, "black")) color = COLOR_BLACK; else if (!strcmp (opt_value, "red")) color = COLOR_RED; else if (!strcmp (opt_value, "green")) color = COLOR_GREEN; else if (!strcmp (opt_value, "yellow")) color = COLOR_YELLOW; else if (!strcmp (opt_value, "blue")) color = COLOR_BLUE; else if (!strcmp (opt_value, "magenta")) color = COLOR_MAGENTA; else if (!strcmp (opt_value, "cyan")) color = COLOR_CYAN; else if (!strcmp (opt_value, "white")) color = COLOR_WHITE; else color = -1; /* not a valid color */ return color; } /* ============================================================================ ============================================================================ */ int _get_color_attrib_by_opt (char *opt_value) { int attrib; if (!strcmp (opt_value, "normal")) attrib = ATTRIB_RESET; else if (!strcmp (opt_value, "bright")) attrib = ATTRIB_BRIGHT; else if (!strcmp (opt_value, "underline")) attrib = ATTRIB_UNDERLINE; else if (!strcmp (opt_value, "blink")) attrib = ATTRIB_BLINK; else if (!strcmp (opt_value, "reverse")) attrib = ATTRIB_REVERSE; else attrib = -1; /* not a valid attrib */ return attrib; } void _set_color_conf (char *opt_value, int n, int attr) { if ((n == 1) && (!attr)) { /* KNOCKER_COLOR_1 */ KNOCKER_COLOR_1 = _get_color_by_opt (opt_value); if (KNOCKER_COLOR_1 == -1) KNOCKER_COLOR_1 = KNOCKER_DEFAULT_COLOR_1; } else if ((n == 1) && (attr)) { /* KNOCKER_COLOR_1_ATTR */ KNOCKER_COLOR_1_ATTR = _get_color_attrib_by_opt (opt_value); if (KNOCKER_COLOR_1_ATTR == -1) KNOCKER_COLOR_1_ATTR = KNOCKER_DEFAULT_COLOR_1_ATTR; } else if ((n == 2) && (!attr)) { /* KNOCKER_COLOR_2 */ KNOCKER_COLOR_2 = _get_color_by_opt (opt_value); if (KNOCKER_COLOR_2 == -1) KNOCKER_COLOR_2 = KNOCKER_DEFAULT_COLOR_2; } else if ((n == 2) && (attr)) { /* KNOCKER_COLOR_2_ATTR */ KNOCKER_COLOR_2_ATTR = _get_color_attrib_by_opt (opt_value); if (KNOCKER_COLOR_2_ATTR == -1) KNOCKER_COLOR_2_ATTR = KNOCKER_DEFAULT_COLOR_2_ATTR; } } /* ============================================================================ ============================================================================ */ void knocker_conf_set_default (void) { KNOCKER_COLOR_1 = KNOCKER_DEFAULT_COLOR_1; KNOCKER_COLOR_1_ATTR = KNOCKER_DEFAULT_COLOR_1_ATTR; KNOCKER_COLOR_2 = KNOCKER_DEFAULT_COLOR_2; KNOCKER_COLOR_2_ATTR = KNOCKER_DEFAULT_COLOR_2_ATTR; } /* ============================================================================ ============================================================================ */ int knocker_conf_parse (void) { FILE *fp; char *conf_file = NULL; char *linebuff = NULL; char *opt_value = NULL; conf_file = malloc (strlen (knocker_user.dir) + strlen ("/") + strlen (KNOCKER_CONFIG_FILE) + 1); strcpy (conf_file, knocker_user.dir); strcat (conf_file, "/"); strcat (conf_file, KNOCKER_CONFIG_FILE); if ((fp = fopen (conf_file, "r")) == NULL) { /* fprintf (stderr, "couldn't read config file %s\n", conf_file); */ free (conf_file); knocker_conf_set_default (); /* run with the default configuration */ return -1; } linebuff = malloc (KNOCKER_CONF_MAX_LEN); opt_value = malloc (KNOCKER_CONF_MAX_LEN); while (!feof (fp)) { if (_fgetline (fp, linebuff, KNOCKER_CONF_MAX_LEN) == EOF) { break; } if (!_iscommented (linebuff, KNOCKER_COMMENT_CHAR)) { if (_isvalid (linebuff, KNOCKER_OPTION_TOKEN)) { if (_getoptval (linebuff, KNOCKER_CONF_OPT_USE_COLORS, opt_value)) { if (_isno (opt_value)) knocker_args.colors = 0; else if (_isyes (opt_value)) knocker_args.colors = 1; else knocker_args.colors = 1; /* unless is a no colors are enabled */ } else if (_getoptval (linebuff, KNOCKER_CONF_OPT_COLOR_1, opt_value)) { _set_color_conf (opt_value, 1, 0); } else if (_getoptval (linebuff, KNOCKER_CONF_OPT_COLOR_2, opt_value)) { _set_color_conf (opt_value, 2, 0); } else if (_getoptval (linebuff, KNOCKER_CONF_OPT_COLOR_1_ATTR, opt_value)) { _set_color_conf (opt_value, 1, 1); } else if (_getoptval (linebuff, KNOCKER_CONF_OPT_COLOR_2_ATTR, opt_value)) { _set_color_conf (opt_value, 2, 1); } } } } /* end of while(!foef(fp)) */ fclose (fp); free (conf_file); free (linebuff); free (opt_value); return 0; } /* ============================================================================ ============================================================================ */ int knocker_conf_write_default (void) { FILE *fp; char *conf_file = NULL; conf_file = malloc (strlen (knocker_user.dir) + strlen ("/") + strlen (KNOCKER_CONFIG_FILE) + 1); strcpy (conf_file, knocker_user.dir); strcat (conf_file, "/"); strcat (conf_file, KNOCKER_CONFIG_FILE); if ((fp = fopen (conf_file, "w")) == NULL) { /* printf (stderr, "couldn't write config file %s\n", conf_file); */ knocker_conf_set_default (); /* run with the default configuration */ free (conf_file); return -1; } fprintf (fp, "%c Config file for %s. Copyright (C) 2001-2002 %s\n", KNOCKER_COMMENT_CHAR, PACKAGE, _KNOCKER_CORE_AUTHOR_); fprintf (fp, "%c %s %s\n", KNOCKER_COMMENT_CHAR, _KNOCKER_CORE_AUTHOR_EMAIL_, _KNOCKER_CORE_HOMEPAGE_); fprintf (fp, "\n"); fprintf (fp, "%c Edit as you need.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "\n"); fprintf (fp, "%c TO USE COLORS OR NOT TO USE COLORS ?\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c If you say no here, colors won't be used, otherwise yes\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%s%cyes\n", KNOCKER_CONF_OPT_USE_COLORS, KNOCKER_OPTION_TOKEN); fprintf (fp, "\n"); fprintf (fp, "%c COLORS AND COLORS ATTRIBUTES:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c These are for the %s colored output, you can choose what colors\n", KNOCKER_COMMENT_CHAR, PACKAGE); fprintf (fp, "%c are to be used.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c Valid values for COLOR are:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c black, red, green, yellow, blue, magenta, cyan, white.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c Valid ATTRIBS are:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c normal, bright, underline, blink, reverse\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%s%cgreen\n", KNOCKER_CONF_OPT_COLOR_1, KNOCKER_OPTION_TOKEN); fprintf (fp, "%s%cnormal\n", KNOCKER_CONF_OPT_COLOR_1_ATTR, KNOCKER_OPTION_TOKEN); fprintf (fp, "\n"); fprintf (fp, "%s%cwhite\n", KNOCKER_CONF_OPT_COLOR_2, KNOCKER_OPTION_TOKEN); fprintf (fp, "%s%cbright\n", KNOCKER_CONF_OPT_COLOR_2_ATTR, KNOCKER_OPTION_TOKEN); fprintf (fp, "\n"); free (conf_file); fclose (fp); return 0; } /* ============================================================================ ============================================================================ */ int knocker_conf_write (int use_colors, char *color1, char *color2, char *color1_attr, char *color2_attr) { FILE *fp; char *conf_file = NULL; conf_file = malloc (strlen (knocker_user.dir) + strlen ("/") + strlen (KNOCKER_CONFIG_FILE) + 1); strcpy (conf_file, knocker_user.dir); strcat (conf_file, "/"); strcat (conf_file, KNOCKER_CONFIG_FILE); if ((fp = fopen (conf_file, "w")) == NULL) { /* printf (stderr, "couldn't write config file %s\n", conf_file); */ /* knocker_conf_set_default (); not needed here since this function is only called by --configure */ /* we will just exit after that */ fprintf (stderr, "\n%s: error, couldn't write configuration file: %s\n", PACKAGE, conf_file); free (conf_file); return -1; } fprintf (stdout, "\nWriting configuration file... "); fprintf (fp, "%c Config file for %s. Copyright (C) 2001-2002 %s\n", KNOCKER_COMMENT_CHAR, PACKAGE, _KNOCKER_CORE_AUTHOR_); fprintf (fp, "%c %s %s\n", KNOCKER_COMMENT_CHAR, _KNOCKER_CORE_AUTHOR_EMAIL_, _KNOCKER_CORE_HOMEPAGE_); fprintf (fp, "\n"); fprintf (fp, "%c Edit as you need.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "\n"); fprintf (fp, "%c TO USE COLORS OR NOT TO USE COLORS ?\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c If you say no here, colors won't be used, otherwise yes\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); if (use_colors) fprintf (fp, "%s%cyes\n", KNOCKER_CONF_OPT_USE_COLORS, KNOCKER_OPTION_TOKEN); else fprintf (fp, "%s%cno\n", KNOCKER_CONF_OPT_USE_COLORS, KNOCKER_OPTION_TOKEN); if (color1 != NULL && color2 != NULL && color1_attr != NULL && color2_attr != NULL) { fprintf (fp, "\n"); fprintf (fp, "%c COLORS AND COLORS ATTRIBUTES:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c These are for the %s colored output, you can choose what colors\n", KNOCKER_COMMENT_CHAR, PACKAGE); fprintf (fp, "%c are to be used.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c Valid values for COLOR are:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c black, red, green, yellow, blue, magenta, cyan, white.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c Valid ATTRIBS are:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c normal, bright, underline, blink, reverse\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%s%c%s\n", KNOCKER_CONF_OPT_COLOR_1, KNOCKER_OPTION_TOKEN, color1); fprintf (fp, "%s%c%s\n", KNOCKER_CONF_OPT_COLOR_1_ATTR, KNOCKER_OPTION_TOKEN, color1_attr); fprintf (fp, "\n"); fprintf (fp, "%s%c%s\n", KNOCKER_CONF_OPT_COLOR_2, KNOCKER_OPTION_TOKEN, color2); fprintf (fp, "%s%c%s\n", KNOCKER_CONF_OPT_COLOR_2_ATTR, KNOCKER_OPTION_TOKEN, color2_attr); fprintf (fp, "\n"); } else { fprintf (fp, "\n"); fprintf (fp, "%c COLORS AND COLORS ATTRIBUTES:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c These are for the %s colored output, you can choose what colors\n", KNOCKER_COMMENT_CHAR, PACKAGE); fprintf (fp, "%c are to be used.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c Valid values for COLOR are:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c black, red, green, yellow, blue, magenta, cyan, white.\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c Valid ATTRIBS are:\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c normal, bright, underline, blink, reverse\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%c\n", KNOCKER_COMMENT_CHAR); fprintf (fp, "%s%cgreen\n", KNOCKER_CONF_OPT_COLOR_1, KNOCKER_OPTION_TOKEN); fprintf (fp, "%s%cnormal\n", KNOCKER_CONF_OPT_COLOR_1_ATTR, KNOCKER_OPTION_TOKEN); fprintf (fp, "\n"); fprintf (fp, "%s%cwhite\n", KNOCKER_CONF_OPT_COLOR_2, KNOCKER_OPTION_TOKEN); fprintf (fp, "%s%cbright\n", KNOCKER_CONF_OPT_COLOR_2_ATTR, KNOCKER_OPTION_TOKEN); fprintf (fp, "\n"); } fprintf (stdout, "done.\n"); fprintf (stdout, "Configuration written to: %s\n", conf_file); fprintf (stdout, "You can also edit this file manually.\n"); fprintf (stdout, "\n"); free (conf_file); fclose (fp); return 0; } /* ============================================================================ ============================================================================ */ void knocker_conf_configure (void) { char *buff = NULL; int use_colors = 1; /* default is yes */ char *color1 = NULL; char *color2 = NULL; char *color1_attr = NULL; char *color2_attr = NULL; fprintf (stdout, "\n"); fprintf (stdout, "Welcome to the %s configuration !\n", PACKAGE); fprintf (stdout, "\n"); fprintf (stdout, "%s is able to output text using colors,\n", PACKAGE); fprintf (stdout, "do you want me te enable colors ?\n"); fprintf (stdout, "[Y/n]: "); while (1) { buff = _get_answer (buff); if (_isyes (buff)) { use_colors = 1; break; } else if (_isno (buff)) { use_colors = 0; knocker_conf_write (use_colors, color1, color2, color1_attr, color2_attr); return; } else fprintf (stdout, "[Y/n]: "); } fprintf (stdout, "\n"); fprintf (stdout, "It is also possible to change the default colors settings,\n"); fprintf (stdout, "do you want to change the default colors ?\n"); fprintf (stdout, "[y/N]: "); while (1) { buff = _get_answer (buff); if (_isyes (buff)) { fprintf (stdout, "\n"); fprintf (stdout, "Normal text:\n"); fprintf (stdout, "Choose the color you want to use for normal text:\n"); fprintf (stdout, "[black/red/green/yellow/blue/magenta/cyan/white]: "); color1 = malloc (strlen (_get_answer (buff) + 1)); strcpy (color1, buff); fprintf (stdout, "\n"); fprintf (stdout, "Choose the color attribute you want to use for normal text:\n"); fprintf (stdout, "[normal/bright/underline/blink/reverse]: "); color1_attr = malloc (strlen (_get_answer (buff) + 1)); strcpy (color1_attr, buff); fprintf (stdout, "\n"); fprintf (stdout, "Highlighted text:\n"); fprintf (stdout, "Choose the color you want to use for highlighted text:\n"); fprintf (stdout, "[black/red/green/yellow/blue/magenta/cyan/white]: "); color2 = malloc (strlen (_get_answer (buff) + 1)); strcpy (color2, buff); fprintf (stdout, "\n"); fprintf (stdout, "Choose the color attribute you want to use for normal text:\n"); fprintf (stdout, "[normal/bright/underline/blink/reverse]: "); color2_attr = malloc (strlen (_get_answer (buff) + 1)); strcpy (color2_attr, buff); knocker_conf_write (use_colors, color1, color2, color1_attr, color2_attr); free (color1); free (color2); free (color1_attr); free (color2_attr); return; } else if (_isno (buff)) { use_colors = 0; break; } else fprintf (stdout, "[Y/n]: "); } return; } knocker-0.7.1/src/knocker_conf.h0000644000175000001440000000413407473301064012237 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_CONF_H_ #define _KNOCKER_CONF_H_ #define KNOCKER_CONFIG_FILE "knocker.conf" #define KNOCKER_CONF_MAX_LEN 255 /* max line lenght in the conf file */ #define KNOCKER_COMMENT_CHAR '#' /* conf file comment char */ #define KNOCKER_OPTION_TOKEN '=' /* conf file option/value separetor */ /* Default color definition for knocker */ #define KNOCKER_DEFAULT_COLOR_1 COLOR_GREEN #define KNOCKER_DEFAULT_COLOR_2 COLOR_WHITE #define KNOCKER_DEFAULT_COLOR_1_ATTR ATTRIB_RESET #define KNOCKER_DEFAULT_COLOR_2_ATTR ATTRIB_BRIGHT /* Options found in the config file */ #define KNOCKER_CONF_OPT_USE_COLORS "USE_COLORS" #define KNOCKER_CONF_OPT_COLOR_1 "COLOR_1" #define KNOCKER_CONF_OPT_COLOR_2 "COLOR_2" #define KNOCKER_CONF_OPT_COLOR_1_ATTR "COLOR_1_ATTR" #define KNOCKER_CONF_OPT_COLOR_2_ATTR "COLOR_2_ATTR" /* The actual values variable */ /* these values are read from the conf file */ /* by the knocker_conf_parse function */ int KNOCKER_USER_COLOR; int KNOCKER_COLOR_1; int KNOCKER_COLOR_2; int KNOCKER_COLOR_1_ATTR; int KNOCKER_COLOR_2_ATTR; void knocker_conf_configure ( void ); int knocker_conf_parse ( void ); int knocker_conf_write_default ( void ); #endif /* _KNOCKER_CONF_H_ */ knocker-0.7.1/src/knocker_output.c0000644000175000001440000003342007473301137012646 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #include "knocker_core.h" #include "knocker_output.h" #include "knocker_conf.h" #include "knocker_args.h" #include "knocker_term.h" #include "knocker_user.h" #include "knocker_time.h" const char knocker_header[12][90] = { "+-----------------------------------------------------------------------------+\n", "|--=|", " k n o c k e r ", "--", " t h e ", "--", " n e t ", "--", " p o r t s c a n n e r ", "|=-=[ ", VERSION, " ]=-|\n" }; char *knocker_time; /* ============================================================================ ============================================================================ */ int knocker_output_open (void) { time_t timenow; if (!knocker_args.fency) return 0; time (&timenow); knocker_time = ctime (&timenow); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); /* print the colored header */ knocker_term_color_fprintf (knocker_output_fp, knocker_header[0], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[1], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[2], KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[3], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[4], KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[5], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[6], KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[7], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[8], KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[9], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[10], KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[11], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_header[0], KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); if (knocker_user.name != NULL) { knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " - ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "started by user ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_user.name, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " on ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_time, KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } else { knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " - ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "started on ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, knocker_time, KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } fflush (knocker_output_fp); return 0; } /* ============================================================================ ============================================================================ */ void knocker_output_host_info (const char *hostname_str, const char *hostip_str) { if (knocker_args.fency) { knocker_term_color_fprintf (knocker_output_fp, " - ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "hostname to scan: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostname_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " - ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "resolved host ip: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostip_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } else { knocker_term_color_fprintf (knocker_output_fp, "Host: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostname_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " resolved: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostip_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } fflush (knocker_output_fp); } /* ============================================================================ ============================================================================ */ void knocker_output_resolve_error (char *hostname_str) { if (knocker_args.fency) { knocker_term_color_fprintf (knocker_output_fp, " - ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "failed to resolve given hostname/IP: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostname_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " - Aborting\n\n\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } else { knocker_term_color_fprintf (knocker_output_fp, "Failed to resolve hostname/IP: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostname_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } fflush (knocker_output_fp); } /* ============================================================================ ============================================================================ */ void knocker_output_ports_info (int sp, int ep) { if (!knocker_args.fency) { knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); return; } knocker_term_color_fprintf (knocker_output_fp, " - - scan from port: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_intfprintf (knocker_output_fp, sp, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n - - - scan to port: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_intfprintf (knocker_output_fp, ep, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n - - - - scan type: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "tcp connect", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n\n+=- - - - - - - - - - - - - - - - - - - - - - - - - - - - - ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " s c a n n i n g ", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " -\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); fflush (knocker_output_fp); } /* ============================================================================ ============================================================================ */ void knocker_output_open_port (int port, char *service_str) { if (knocker_args.fency) { knocker_term_color_fprintf (knocker_output_fp, " -=[ ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_intfprintf (knocker_output_fp, port, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "/", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "tcp", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, ", ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, service_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " ]=-", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " * ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "OPEN", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " *\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } else { knocker_term_color_intfprintf (knocker_output_fp, port, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "/", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "tcp", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, ", ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, service_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, ", ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, "open", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } fflush (knocker_output_fp); } /* ============================================================================ ============================================================================ */ void knocker_output_results (char *hostname_str, char *hostname_ip, int tot_ps, int open_ps, char *secs) { if (knocker_args.fency) { knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "+=- - - - - - - - - - - - - - - - - - - - - - - - - - - - ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " c o m p l e t e d ", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " -\n\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " - scanned host name: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostname_str, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " IP: ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, hostname_ip, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "\n\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " - found ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_intfprintf (knocker_output_fp, open_ps, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " open ports in a total of ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_intfprintf (knocker_output_fp, tot_ps, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " ports scanned.\n\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, " - port scan completed in ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, secs, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " seconds.\n\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } else { knocker_term_color_fprintf (knocker_output_fp, "\n", KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, "Found ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_intfprintf (knocker_output_fp, open_ps, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " open ports in a total of ", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_intfprintf (knocker_output_fp, tot_ps, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " ports scanned (", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); knocker_term_color_fprintf (knocker_output_fp, secs, KNOCKER_COLOR_2, KNOCKER_COLOR_2_ATTR); knocker_term_color_fprintf (knocker_output_fp, " secs).\n\n", KNOCKER_COLOR_1, KNOCKER_COLOR_1_ATTR); } fflush (knocker_output_fp); } knocker-0.7.1/src/knocker_output.h0000644000175000001440000000303607473301141012646 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_OUTPUT_H_ #define _KNOCKER_OUTPUT_H_ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #define KNOCKER_OUTPUT_FP stdout #define knocker_output_fp KNOCKER_OUTPUT_FP int knocker_output_open ( void ); void knocker_output_host_info (const char *hostname_str, const char *hostip_str); void knocker_output_resolve_error (char *hostname_str); void knocker_output_ports_info (int sp, int ep); void knocker_output_open_port (int port, char *service_str); void knocker_output_results (char *hostname_str, char *hostname_ip, int tot_ps, int open_ps,char *secs); #endif /* _KNOCKER_OUTPUT_H_ */ knocker-0.7.1/src/knocker_log.c0000644000175000001440000001410307473301115012060 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #include "knocker_core.h" #include "knocker_log.h" #include "knocker_args.h" #include "knocker_user.h" #include "knocker_time.h" const char knocker_log_header[] = "+-----------------------------------------------------------------------------+\n|--=| k n o c k e r -- t h e -- n e t -- p o r t s c a n n e r |=-=[logfile]=-|\n+-----------------------------------------------------------------------------+\n"; char *knocker_time; /* ============================================================================ ============================================================================ */ int knocker_log_open (const char *filename) { time_t timenow; /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return 0; if (filename == NULL) knocker_log_fp = fopen (KNOCKER_LOG_FILE, "a"); else knocker_log_fp = fopen (filename, "a"); if (knocker_log_fp == NULL) return -1; time (&timenow); knocker_time = ctime (&timenow); fprintf (knocker_log_fp, "%s", knocker_log_header); if (knocker_user.name != NULL) fprintf (knocker_log_fp, " - %s started by user %s on %s\n", PACKAGE, knocker_user.name, knocker_time); else fprintf (knocker_log_fp, " - %s started on %s\n", PACKAGE, knocker_time); /* fprintf(knocker_log_fp, "\n"); */ fflush (knocker_log_fp); return 0; } /* ============================================================================ ============================================================================ */ void knocker_log_host_info (char *hostname_str, char *hostip_str) { /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return; fprintf (knocker_log_fp, " - hostname to scan: %s\n", hostname_str); fprintf (knocker_log_fp, " - resolved host ip: %s\n", hostip_str); fflush (knocker_log_fp); } /* ============================================================================ ============================================================================ */ void knocker_log_resolve_error (char *hostname_str) { /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return; fprintf (knocker_log_fp, " - ERROR: failed to resolve hostname: %s\n", hostname_str); fprintf (knocker_log_fp, " - Aborting.\n"); fprintf (knocker_log_fp, "\n\n"); fclose (knocker_log_fp); } /* ============================================================================ ============================================================================ */ void knocker_log_ports_info (int sp, int ep) { /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return; fprintf (knocker_log_fp, " - - scan from port: %d\n", sp); fprintf (knocker_log_fp, " - - - scan to port: %d\n", ep); fprintf (knocker_log_fp, " - - - - scan type: tcp connect\n"); fprintf (knocker_log_fp, "+=- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - s c a n n i n g -\n"); fprintf (knocker_log_fp, "\n"); fflush (knocker_log_fp); } /* ============================================================================ ============================================================================ */ void knocker_log_open_port (int port, char *service_str) { /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return; fprintf (knocker_log_fp, " -=[ %d/tcp, %s ]=- * OPEN *\n", port, service_str); fflush (knocker_log_fp); } /* ============================================================================ ============================================================================ */ void knocker_log_results (char *hostname_str, char *hostip_str, int tot_ps, int open_ps, char *secs) { /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return; fprintf (knocker_log_fp, "\n"); fprintf (knocker_log_fp, "+=- - - - - - - - - - - - - - - - - - - - - - - - - - - - c o m p l e t e d -\n\n"); fprintf (knocker_log_fp, " - scanned host name: %s ", hostname_str); fprintf (knocker_log_fp, "IP: %s\n\n", hostip_str); fprintf (knocker_log_fp, " - found %d open ports in a totoal of %d ports scanned.\n\n", open_ps, tot_ps); fprintf (knocker_log_fp, " - port scan completed in %s seconds.\n\n", secs); fflush (knocker_log_fp); } /* ============================================================================ ============================================================================ */ void knocker_log_cancelled (void) { /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return; fprintf (knocker_log_fp, "- * port scan cancelled by user * -\n"); fflush (knocker_log_fp); } /* ============================================================================ ============================================================================ */ void knocker_log_close (void) { /* if logging to file is FALSE */ if (knocker_args.logfile == FALSE) return; /* If a previous knocker_log_open () function call failed, we must not write to the file, since it hasn't been open */ if (knocker_log_fp == NULL) return; fprintf (knocker_log_fp, "- -- - - - = http://knocker.sourceforge.net - bugs to - \n"); fprintf (knocker_log_fp, "\n\n\n\n"); fclose (knocker_log_fp); } knocker-0.7.1/src/knocker_log.h0000644000175000001440000000307507473301116012074 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_LOG_H_ #define _KNOCKER_LOG_H_ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #define KNOCKER_LOG_FILE "knocker_scan.log" FILE *knocker_log_fp; int knocker_log_open (const char *filename); void knocker_log_host_info (char *hostname_str, char *hostip_str); void knocker_log_resolve_error (char *hostname_str); void knocker_log_ports_info (int sp, int ep); void knocker_log_open_port (int port, char *service_str); void knocker_log_results (char *hostname_str, char *hostip_str, int tot_ps, int open_ps, char *secs); void knocker_log_cancelled (void); void knocker_log_close (void); #endif /* _KNOCKER_LOG_H_ */ knocker-0.7.1/src/knocker_term.c0000644000175000001440000001625007473301162012255 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include "knocker_core.h" #include "knocker_term.h" #include "knocker_args.h" /* ============================================================================ ============================================================================ */ void knocker_term_clear (void) { if (knocker_args.quiet == FALSE) { #ifdef __WIN32__ clrscr (); /* clear the screen using clrscr() from conio.h */ #else system ("clear"); /* this should work on the most of the UNIX and UNIX-like */ #endif /* __WIN32__ */ } } /* ============================================================================ ============================================================================ */ void knocker_term_set_default_color (void) { if (!knocker_args.quiet) { if (knocker_args.colors == TRUE) { #ifdef __WIN32__ /* in win32 the default fg color is LIGHTGRAY */ knocker_term_set_color (LIGHTGRAY, COLOR_NONE, ATTRIB_RESET); #else knocker_term_set_color (COLOR_WHITE, COLOR_NONE, ATTRIB_RESET); #endif } } return; } /* ============================================================================ ============================================================================ */ void knocker_term_reset (void) { knocker_term_set_default_color (); /* Something must be printed to actually reset the terminal to the defaults */ #ifdef __WIN32__ /* in win32 the default fg color is LIGHTGRAY */ /* cprintf ( " " ); */ #else /* fprintf ( stdout, " " ); */ #endif return; } /* ============================================================================ ============================================================================ */ void knocker_term_set_color (int fg, int bg, int attrib) { if (knocker_args.quiet == FALSE) { char cmd_str[13]; if (knocker_args.colors == TRUE) { if ((bg == COLOR_NONE) && (fg != COLOR_NONE)) { #ifdef __WIN32__ textcolor (fg); #else /* this one doesn't change the background current color */ sprintf (cmd_str, "%c[%d;%dm", 0x1B, attrib, fg + 30); #endif } else if ((bg != COLOR_NONE) && (fg == COLOR_NONE)) { #ifdef __WIN32__ textbackground (bg); #else /* this one doesn't change the foreground current color */ sprintf (cmd_str, "%c[%d;%dm", 0x1B, attrib, bg + 40); #endif } else if ((bg == COLOR_NONE) && (fg == COLOR_NONE)) { #ifndef __WIN32__ /* this one doesn't change the background color and the foreground color neither */ sprintf (cmd_str, "%c[%dm", 0x1B, attrib); #endif } else { #ifdef __WIN32__ textcolor (fg); textbackground (bg); #else sprintf (cmd_str, "%c[%d;%d;%dm", 0x1B, attrib, fg + 30, bg + 40); #endif } fprintf (stdout, "%s", cmd_str); } } return; } /* ============================================================================ ============================================================================ */ void knocker_term_fflush (FILE * fd) { if (knocker_args.quiet == FALSE) { fflush (fd); } } /* ============================================================================ ============================================================================ */ void knocker_term_printf (const char *buffer) { if (knocker_args.quiet == FALSE) { printf ("%s", buffer); } return; } /* ============================================================================ ============================================================================ */ void knocker_term_fprintf (FILE * fd, const char *buffer) { if (knocker_args.quiet == FALSE) { fprintf (fd, "%s", buffer); } return; } /* ============================================================================ ============================================================================ */ void knocker_term_color_printf (const char *buffer, int color, int attrib) { if (knocker_args.quiet == FALSE) { knocker_term_set_color (color, COLOR_NONE, attrib); #ifdef __WIN32__ cprintf ("%s", buffer); #else printf ("%s", buffer); #endif knocker_term_set_default_color (); } return; } /* ============================================================================ ============================================================================ */ void knocker_term_color_fprintf (FILE * fd, const char *buffer, int color, int attrib) { if (knocker_args.quiet == FALSE) { knocker_term_set_color (color, COLOR_NONE, attrib); #ifdef __WIN32__ cprintf ("%s", buffer); #else fprintf (fd, "%s", buffer); #endif knocker_term_set_default_color (); } return; } /* ============================================================================ ============================================================================ */ void knocker_term_color_intprintf (const int i, int color, int attrib) { if (knocker_args.quiet == FALSE) { knocker_term_set_color (color, COLOR_NONE, attrib); #ifdef __WIN32__ cprintf ("%d", i); #else printf ("%d", i); #endif knocker_term_set_default_color (); } return; } /* ============================================================================ ============================================================================ */ void knocker_term_color_intfprintf (FILE * fd, const int i, int color, int attrib) { if (knocker_args.quiet == FALSE) { knocker_term_set_color (color, COLOR_NONE, attrib); #ifdef __WIN32__ cprintf ("%d", i); #else fprintf (fd, "%d", i); #endif knocker_term_set_default_color (); } return; } /* * function: restore_terminal - restore normal screen mode. * algorithm: uses the 'stty' command to restore normal screen mode. * serves as a cleanup function for the user input thread. * input: none. * output: none. */ /* void restore_terminal (void) { restore_terminal: before 'stty -raw echo' system ("stty -raw echo"); restore_terminal: after 'stty -raw echo' } */ knocker-0.7.1/src/knocker_term.h0000644000175000001440000000444707473301163012270 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_TERM_H_ #define _KNOCKER_TERM_H_ #ifdef HAVE_CONFIG_H # include #endif #include #ifdef __WIN32__ #include #define COLOR_BLACK BLACK #define COLOR_BLUE BLUE #define COLOR_GREEN GREEN #define COLOR_CYAN CYAN #define COLOR_RED RED #define COLOR_MAGENTA MAGENTA #define COLOR_WHITE WHITE #define COLOR_YELLOW YELLOW #else enum { COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE }; #endif /* __WIN_32__ */ #define COLOR_NONE -2002 /* just to be sure it doesn't conflict with other colors */ enum { ATTRIB_RESET, ATTRIB_BRIGHT, ATTRIB_DIM, ATTRIB_UNDERLINE, ATTRIB_BLINK, ATTRIB_REVERSE, ATTRIB_HIDDEN }; void knocker_term_clear ( void ); void knocker_term_set_color (int fg, int bg, int attrib); void knocker_term_set_default_color (void); void knocker_term_reset (void); void knocker_term_fflush (FILE *fd); void knocker_term_printf (const char *buffer); void knocker_term_fprintf (FILE * fd, const char *buffer); void knocker_term_color_printf (const char *buffer, int color, int attrib); void knocker_term_color_fprintf (FILE * fd, const char *buffer, int color, int attrib); void knocker_term_color_intprintf (const int i, int color, int attrib); void knocker_term_color_intfprintf (FILE * fd, const int i, int color, int attrib); #endif /* _KNOCKER_TERM_H_ */ knocker-0.7.1/src/knocker_time.c0000644000175000001440000000565607473301174012257 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #include #include #include "knocker_time.h" #ifdef __WIN32__ #include #else #include #include #include #endif /* __WIN32__ */ #ifdef __WIN32__ static unsigned long timer_start; #else static struct timeval timer_start; #endif void knocker_time_start_timer (void) { #ifdef __WIN32__ timer_start = GetTickCount (); #else /* Set first ticks value */ gettimeofday (&timer_start, NULL); #endif } double knocker_time_get_ticks (void) { double ticks; #ifdef __WIN32__ double timer_now; na timer_now = GetTickCount (); ticks = ((timer_now - timer_start)); #else struct timeval timer_now; gettimeofday (&timer_now, NULL); ticks = (timer_now.tv_sec - timer_start.tv_sec) * 1000 + (timer_now.tv_usec - timer_start.tv_usec) / 1000; #endif return (ticks); } void knocker_time_delay (unsigned long ms) { #ifdef __WIN32__ #else /* #if defined (HAVE_PAUSE) && defined (HAVE_NANOSLEEP) */ /* # ifdef HAVE_NANOSLEEP --------------------- UNTESTED !!!!!!! -------------------------- struct timespec rqtp; unsigned long pause; pause = pause; rqtp.tv_sec = (time_t) pause / 1000; rqtp.tv_nsec = (long) (pause % 1000) * 1000000; (void) nanosleep (&rqtp, NULL); */ #ifdef HAVE_USLEEP #else double before, now; before = knocker_time_get_ticks (); now = before; #ifdef DEBUG fprintf (stderr, "debug: function knocker_time_delay() called.\n"); fprintf (stderr, "debug: timer is now = %f (it should be 0)\n", now); fprintf (stderr, "debug: delaying for %f milliseconds...", ms); #endif /* Very bad do nothing delay loop */ do { now = knocker_time_get_ticks (); if (now > before + ms) break; /* just to make sure we don't get stuck in this loop */ /* if the test now <= before + ms fails */ } while (now <= before + ms); #endif #ifdef DEBUG fprintf (stderr, " done.\n"); fprintf (stderr, "debug: timer is now = %f \n", now); #endif #endif /* ifdef __WIN32__ */ } knocker-0.7.1/src/knocker_time.h0000644000175000001440000000223507473301173012251 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_TIME_H_ #define _KNOCKER_TIME_H_ #ifdef HAVE_CONFIG_H # include #endif #include void knocker_time_start_timer (void); double knocker_time_get_ticks (void); void knocker_time_delay (unsigned long ms); #endif /* _KNOCKER_TIME_H_ */ knocker-0.7.1/src/knocker_services.c0000644000175000001440000007011607473301153013132 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #include #include #include #include "knocker_services.h" #include "knocker_core.h" /* this following list of services has been automatically generated from /etc/services */ int init_knocker_core_services_db (void) { #ifdef DEBUG int n_of_services = 0; int i = 0; #endif /* if it has been already initialized we do anything */ if (knocker_core_services_db_init) return 0; knocker_core_services_db_init = 0; #ifdef DEBUG fprintf (stderr, "debug: function init_knocker_core_services_db (...) called.\n"); #endif #ifdef DEBUG fprintf (stderr, "debug: allocating memory to store service strings... "); #endif knocker_core_services_db[1] = malloc (6 + 1); strcpy (knocker_core_services_db[1], "tcpmux"); if (knocker_core_services_db[1] == NULL) return -1; knocker_core_services_db[7] = malloc (4 + 1); strcpy (knocker_core_services_db[7], "echo"); if (knocker_core_services_db[7] == NULL) return -1; knocker_core_services_db[9] = malloc (7 + 1); strcpy (knocker_core_services_db[9], "discard"); if (knocker_core_services_db[9] == NULL) return -1; knocker_core_services_db[11] = malloc (6 + 1); strcpy (knocker_core_services_db[11], "systat"); if (knocker_core_services_db[11] == NULL) return -1; knocker_core_services_db[13] = malloc (7 + 1); strcpy (knocker_core_services_db[13], "daytime"); if (knocker_core_services_db[13] == NULL) return -1; knocker_core_services_db[15] = malloc (7 + 1); strcpy (knocker_core_services_db[15], "netstat"); if (knocker_core_services_db[15] == NULL) return -1; knocker_core_services_db[17] = malloc (4 + 1); strcpy (knocker_core_services_db[17], "qotd"); if (knocker_core_services_db[17] == NULL) return -1; knocker_core_services_db[18] = malloc (3 + 1); strcpy (knocker_core_services_db[18], "msp"); if (knocker_core_services_db[18] == NULL) return -1; knocker_core_services_db[19] = malloc (7 + 1); strcpy (knocker_core_services_db[19], "chargen"); if (knocker_core_services_db[19] == NULL) return -1; knocker_core_services_db[20] = malloc (8 + 1); strcpy (knocker_core_services_db[20], "ftp-data"); if (knocker_core_services_db[20] == NULL) return -1; knocker_core_services_db[21] = malloc (3 + 1); strcpy (knocker_core_services_db[21], "ftp"); if (knocker_core_services_db[21] == NULL) return -1; knocker_core_services_db[22] = malloc (3 + 1); strcpy (knocker_core_services_db[22], "ssh"); if (knocker_core_services_db[22] == NULL) return -1; knocker_core_services_db[23] = malloc (6 + 1); strcpy (knocker_core_services_db[23], "telnet"); if (knocker_core_services_db[23] == NULL) return -1; knocker_core_services_db[25] = malloc (4 + 1); strcpy (knocker_core_services_db[25], "smtp"); if (knocker_core_services_db[25] == NULL) return -1; knocker_core_services_db[37] = malloc (4 + 1); strcpy (knocker_core_services_db[37], "time"); if (knocker_core_services_db[37] == NULL) return -1; knocker_core_services_db[39] = malloc (3 + 1); strcpy (knocker_core_services_db[39], "rlp"); if (knocker_core_services_db[39] == NULL) return -1; knocker_core_services_db[42] = malloc (10 + 1); strcpy (knocker_core_services_db[42], "nameserver"); if (knocker_core_services_db[42] == NULL) return -1; knocker_core_services_db[43] = malloc (5 + 1); strcpy (knocker_core_services_db[43], "whois"); if (knocker_core_services_db[43] == NULL) return -1; knocker_core_services_db[50] = malloc (10 + 1); strcpy (knocker_core_services_db[50], "re-mail-ck"); if (knocker_core_services_db[50] == NULL) return -1; knocker_core_services_db[53] = malloc (6 + 1); strcpy (knocker_core_services_db[53], "domain"); if (knocker_core_services_db[53] == NULL) return -1; knocker_core_services_db[57] = malloc (3 + 1); strcpy (knocker_core_services_db[57], "mtp"); if (knocker_core_services_db[57] == NULL) return -1; knocker_core_services_db[67] = malloc (6 + 1); strcpy (knocker_core_services_db[67], "bootps"); if (knocker_core_services_db[67] == NULL) return -1; knocker_core_services_db[68] = malloc (6 + 1); strcpy (knocker_core_services_db[68], "bootpc"); if (knocker_core_services_db[68] == NULL) return -1; knocker_core_services_db[69] = malloc (4 + 1); strcpy (knocker_core_services_db[69], "tftp"); if (knocker_core_services_db[69] == NULL) return -1; knocker_core_services_db[70] = malloc (6 + 1); strcpy (knocker_core_services_db[70], "gopher"); if (knocker_core_services_db[70] == NULL) return -1; knocker_core_services_db[77] = malloc (3 + 1); strcpy (knocker_core_services_db[77], "rje"); if (knocker_core_services_db[77] == NULL) return -1; knocker_core_services_db[79] = malloc (6 + 1); strcpy (knocker_core_services_db[79], "finger"); if (knocker_core_services_db[79] == NULL) return -1; knocker_core_services_db[80] = malloc (3 + 1); strcpy (knocker_core_services_db[80], "www"); if (knocker_core_services_db[80] == NULL) return -1; knocker_core_services_db[87] = malloc (4 + 1); strcpy (knocker_core_services_db[87], "link"); if (knocker_core_services_db[87] == NULL) return -1; knocker_core_services_db[88] = malloc (8 + 1); strcpy (knocker_core_services_db[88], "kerberos"); if (knocker_core_services_db[88] == NULL) return -1; knocker_core_services_db[95] = malloc (6 + 1); strcpy (knocker_core_services_db[95], "supdup"); if (knocker_core_services_db[95] == NULL) return -1; knocker_core_services_db[98] = malloc (9 + 1); strcpy (knocker_core_services_db[98], "linuxconf"); if (knocker_core_services_db[98] == NULL) return -1; knocker_core_services_db[101] = malloc (9 + 1); strcpy (knocker_core_services_db[101], "hostnames"); if (knocker_core_services_db[101] == NULL) return -1; knocker_core_services_db[102] = malloc (8 + 1); strcpy (knocker_core_services_db[102], "iso-tsap"); if (knocker_core_services_db[102] == NULL) return -1; knocker_core_services_db[105] = malloc (8 + 1); strcpy (knocker_core_services_db[105], "csnet-ns"); if (knocker_core_services_db[105] == NULL) return -1; knocker_core_services_db[107] = malloc (7 + 1); strcpy (knocker_core_services_db[107], "rtelnet"); if (knocker_core_services_db[107] == NULL) return -1; knocker_core_services_db[109] = malloc (4 + 1); strcpy (knocker_core_services_db[109], "pop2"); if (knocker_core_services_db[109] == NULL) return -1; knocker_core_services_db[110] = malloc (4 + 1); strcpy (knocker_core_services_db[110], "pop3"); if (knocker_core_services_db[110] == NULL) return -1; knocker_core_services_db[111] = malloc (6 + 1); strcpy (knocker_core_services_db[111], "sunrpc"); if (knocker_core_services_db[111] == NULL) return -1; knocker_core_services_db[113] = malloc (4 + 1); strcpy (knocker_core_services_db[113], "auth"); if (knocker_core_services_db[113] == NULL) return -1; knocker_core_services_db[115] = malloc (4 + 1); strcpy (knocker_core_services_db[115], "sftp"); if (knocker_core_services_db[115] == NULL) return -1; knocker_core_services_db[117] = malloc (9 + 1); strcpy (knocker_core_services_db[117], "uucp-path"); if (knocker_core_services_db[117] == NULL) return -1; knocker_core_services_db[119] = malloc (4 + 1); strcpy (knocker_core_services_db[119], "nntp"); if (knocker_core_services_db[119] == NULL) return -1; knocker_core_services_db[123] = malloc (3 + 1); strcpy (knocker_core_services_db[123], "ntp"); if (knocker_core_services_db[123] == NULL) return -1; knocker_core_services_db[129] = malloc (6 + 1); strcpy (knocker_core_services_db[129], "pwdgen"); if (knocker_core_services_db[129] == NULL) return -1; knocker_core_services_db[137] = malloc (10 + 1); strcpy (knocker_core_services_db[137], "netbios-ns"); if (knocker_core_services_db[137] == NULL) return -1; knocker_core_services_db[138] = malloc (11 + 1); strcpy (knocker_core_services_db[138], "netbios-dgm"); if (knocker_core_services_db[138] == NULL) return -1; knocker_core_services_db[139] = malloc (11 + 1); strcpy (knocker_core_services_db[139], "netbios-ssn"); if (knocker_core_services_db[139] == NULL) return -1; knocker_core_services_db[143] = malloc (5 + 1); strcpy (knocker_core_services_db[143], "imap2"); if (knocker_core_services_db[143] == NULL) return -1; knocker_core_services_db[161] = malloc (4 + 1); strcpy (knocker_core_services_db[161], "snmp"); if (knocker_core_services_db[161] == NULL) return -1; knocker_core_services_db[162] = malloc (9 + 1); strcpy (knocker_core_services_db[162], "snmp-trap"); if (knocker_core_services_db[162] == NULL) return -1; knocker_core_services_db[163] = malloc (8 + 1); strcpy (knocker_core_services_db[163], "cmip-man"); if (knocker_core_services_db[163] == NULL) return -1; knocker_core_services_db[164] = malloc (10 + 1); strcpy (knocker_core_services_db[164], "cmip-agent"); if (knocker_core_services_db[164] == NULL) return -1; knocker_core_services_db[174] = malloc (5 + 1); strcpy (knocker_core_services_db[174], "mailq"); if (knocker_core_services_db[174] == NULL) return -1; knocker_core_services_db[177] = malloc (5 + 1); strcpy (knocker_core_services_db[177], "xdmcp"); if (knocker_core_services_db[177] == NULL) return -1; knocker_core_services_db[178] = malloc (8 + 1); strcpy (knocker_core_services_db[178], "nextstep"); if (knocker_core_services_db[178] == NULL) return -1; knocker_core_services_db[179] = malloc (3 + 1); strcpy (knocker_core_services_db[179], "bgp"); if (knocker_core_services_db[179] == NULL) return -1; knocker_core_services_db[191] = malloc (8 + 1); strcpy (knocker_core_services_db[191], "prospero"); if (knocker_core_services_db[191] == NULL) return -1; knocker_core_services_db[194] = malloc (3 + 1); strcpy (knocker_core_services_db[194], "irc"); if (knocker_core_services_db[194] == NULL) return -1; knocker_core_services_db[199] = malloc (4 + 1); strcpy (knocker_core_services_db[199], "smux"); if (knocker_core_services_db[199] == NULL) return -1; knocker_core_services_db[201] = malloc (7 + 1); strcpy (knocker_core_services_db[201], "at-rtmp"); if (knocker_core_services_db[201] == NULL) return -1; knocker_core_services_db[202] = malloc (6 + 1); strcpy (knocker_core_services_db[202], "at-nbp"); if (knocker_core_services_db[202] == NULL) return -1; knocker_core_services_db[204] = malloc (7 + 1); strcpy (knocker_core_services_db[204], "at-echo"); if (knocker_core_services_db[204] == NULL) return -1; knocker_core_services_db[206] = malloc (6 + 1); strcpy (knocker_core_services_db[206], "at-zis"); if (knocker_core_services_db[206] == NULL) return -1; knocker_core_services_db[209] = malloc (4 + 1); strcpy (knocker_core_services_db[209], "qmtp"); if (knocker_core_services_db[209] == NULL) return -1; knocker_core_services_db[210] = malloc (5 + 1); strcpy (knocker_core_services_db[210], "z3950"); if (knocker_core_services_db[210] == NULL) return -1; knocker_core_services_db[213] = malloc (3 + 1); strcpy (knocker_core_services_db[213], "ipx"); if (knocker_core_services_db[213] == NULL) return -1; knocker_core_services_db[220] = malloc (5 + 1); strcpy (knocker_core_services_db[220], "imap3"); if (knocker_core_services_db[220] == NULL) return -1; knocker_core_services_db[369] = malloc (11 + 1); strcpy (knocker_core_services_db[369], "rpc2portmap"); if (knocker_core_services_db[369] == NULL) return -1; knocker_core_services_db[370] = malloc (9 + 1); strcpy (knocker_core_services_db[370], "codaauth2"); if (knocker_core_services_db[370] == NULL) return -1; knocker_core_services_db[372] = malloc (9 + 1); strcpy (knocker_core_services_db[372], "ulistserv"); if (knocker_core_services_db[372] == NULL) return -1; knocker_core_services_db[389] = malloc (4 + 1); strcpy (knocker_core_services_db[389], "ldap"); if (knocker_core_services_db[389] == NULL) return -1; knocker_core_services_db[443] = malloc (5 + 1); strcpy (knocker_core_services_db[443], "https"); if (knocker_core_services_db[443] == NULL) return -1; knocker_core_services_db[444] = malloc (4 + 1); strcpy (knocker_core_services_db[444], "snpp"); if (knocker_core_services_db[444] == NULL) return -1; knocker_core_services_db[487] = malloc (4 + 1); strcpy (knocker_core_services_db[487], "saft"); if (knocker_core_services_db[487] == NULL) return -1; knocker_core_services_db[610] = malloc (10 + 1); strcpy (knocker_core_services_db[610], "npmp-local"); if (knocker_core_services_db[610] == NULL) return -1; knocker_core_services_db[611] = malloc (8 + 1); strcpy (knocker_core_services_db[611], "npmp-gui"); if (knocker_core_services_db[611] == NULL) return -1; knocker_core_services_db[612] = malloc (8 + 1); strcpy (knocker_core_services_db[612], "hmmp-ind"); if (knocker_core_services_db[612] == NULL) return -1; knocker_core_services_db[631] = malloc (3 + 1); strcpy (knocker_core_services_db[631], "ipp"); if (knocker_core_services_db[631] == NULL) return -1; knocker_core_services_db[512] = malloc (4 + 1); strcpy (knocker_core_services_db[512], "exec"); if (knocker_core_services_db[512] == NULL) return -1; knocker_core_services_db[513] = malloc (5 + 1); strcpy (knocker_core_services_db[513], "login"); if (knocker_core_services_db[513] == NULL) return -1; knocker_core_services_db[514] = malloc (5 + 1); strcpy (knocker_core_services_db[514], "shell"); if (knocker_core_services_db[514] == NULL) return -1; knocker_core_services_db[515] = malloc (7 + 1); strcpy (knocker_core_services_db[515], "printer"); if (knocker_core_services_db[515] == NULL) return -1; knocker_core_services_db[517] = malloc (4 + 1); strcpy (knocker_core_services_db[517], "talk"); if (knocker_core_services_db[517] == NULL) return -1; knocker_core_services_db[518] = malloc (5 + 1); strcpy (knocker_core_services_db[518], "ntalk"); if (knocker_core_services_db[518] == NULL) return -1; knocker_core_services_db[520] = malloc (5 + 1); strcpy (knocker_core_services_db[520], "route"); if (knocker_core_services_db[520] == NULL) return -1; knocker_core_services_db[525] = malloc (5 + 1); strcpy (knocker_core_services_db[525], "timed"); if (knocker_core_services_db[525] == NULL) return -1; knocker_core_services_db[526] = malloc (5 + 1); strcpy (knocker_core_services_db[526], "tempo"); if (knocker_core_services_db[526] == NULL) return -1; knocker_core_services_db[530] = malloc (7 + 1); strcpy (knocker_core_services_db[530], "courier"); if (knocker_core_services_db[530] == NULL) return -1; knocker_core_services_db[531] = malloc (10 + 1); strcpy (knocker_core_services_db[531], "conference"); if (knocker_core_services_db[531] == NULL) return -1; knocker_core_services_db[532] = malloc (7 + 1); strcpy (knocker_core_services_db[532], "netnews"); if (knocker_core_services_db[532] == NULL) return -1; knocker_core_services_db[533] = malloc (7 + 1); strcpy (knocker_core_services_db[533], "netwall"); if (knocker_core_services_db[533] == NULL) return -1; knocker_core_services_db[538] = malloc (6 + 1); strcpy (knocker_core_services_db[538], "gdomap"); if (knocker_core_services_db[538] == NULL) return -1; knocker_core_services_db[540] = malloc (4 + 1); strcpy (knocker_core_services_db[540], "uucp"); if (knocker_core_services_db[540] == NULL) return -1; knocker_core_services_db[548] = malloc (10 + 1); strcpy (knocker_core_services_db[548], "afpovertcp"); if (knocker_core_services_db[548] == NULL) return -1; knocker_core_services_db[556] = malloc (8 + 1); strcpy (knocker_core_services_db[556], "remotefs"); if (knocker_core_services_db[556] == NULL) return -1; knocker_core_services_db[543] = malloc (6 + 1); strcpy (knocker_core_services_db[543], "klogin"); if (knocker_core_services_db[543] == NULL) return -1; knocker_core_services_db[544] = malloc (6 + 1); strcpy (knocker_core_services_db[544], "kshell"); if (knocker_core_services_db[544] == NULL) return -1; knocker_core_services_db[563] = malloc (5 + 1); strcpy (knocker_core_services_db[563], "nntps"); if (knocker_core_services_db[563] == NULL) return -1; knocker_core_services_db[636] = malloc (5 + 1); strcpy (knocker_core_services_db[636], "ldaps"); if (knocker_core_services_db[636] == NULL) return -1; knocker_core_services_db[655] = malloc (4 + 1); strcpy (knocker_core_services_db[655], "tinc"); if (knocker_core_services_db[655] == NULL) return -1; knocker_core_services_db[749] = malloc (12 + 1); strcpy (knocker_core_services_db[749], "kerberos-adm"); if (knocker_core_services_db[749] == NULL) return -1; knocker_core_services_db[765] = malloc (7 + 1); strcpy (knocker_core_services_db[765], "webster"); if (knocker_core_services_db[765] == NULL) return -1; knocker_core_services_db[873] = malloc (5 + 1); strcpy (knocker_core_services_db[873], "rsync"); if (knocker_core_services_db[873] == NULL) return -1; knocker_core_services_db[989] = malloc (9 + 1); strcpy (knocker_core_services_db[989], "ftps-data"); if (knocker_core_services_db[989] == NULL) return -1; knocker_core_services_db[990] = malloc (4 + 1); strcpy (knocker_core_services_db[990], "ftps"); if (knocker_core_services_db[990] == NULL) return -1; knocker_core_services_db[992] = malloc (7 + 1); strcpy (knocker_core_services_db[992], "telnets"); if (knocker_core_services_db[992] == NULL) return -1; knocker_core_services_db[993] = malloc (5 + 1); strcpy (knocker_core_services_db[993], "imaps"); if (knocker_core_services_db[993] == NULL) return -1; knocker_core_services_db[994] = malloc (4 + 1); strcpy (knocker_core_services_db[994], "ircs"); if (knocker_core_services_db[994] == NULL) return -1; knocker_core_services_db[995] = malloc (5 + 1); strcpy (knocker_core_services_db[995], "pop3s"); if (knocker_core_services_db[995] == NULL) return -1; knocker_core_services_db[1080] = malloc (5 + 1); strcpy (knocker_core_services_db[1080], "socks"); if (knocker_core_services_db[1080] == NULL) return -1; knocker_core_services_db[1352] = malloc (9 + 1); strcpy (knocker_core_services_db[1352], "lotusnote"); if (knocker_core_services_db[1352] == NULL) return -1; knocker_core_services_db[1524] = malloc (10 + 1); strcpy (knocker_core_services_db[1524], "ingreslock"); if (knocker_core_services_db[1524] == NULL) return -1; knocker_core_services_db[1525] = malloc (11 + 1); strcpy (knocker_core_services_db[1525], "prospero-np"); if (knocker_core_services_db[1525] == NULL) return -1; knocker_core_services_db[1645] = malloc (11 + 1); strcpy (knocker_core_services_db[1645], "datametrics"); if (knocker_core_services_db[1645] == NULL) return -1; knocker_core_services_db[1646] = malloc (11 + 1); strcpy (knocker_core_services_db[1646], "sa-msg-port"); if (knocker_core_services_db[1646] == NULL) return -1; knocker_core_services_db[1812] = malloc (6 + 1); strcpy (knocker_core_services_db[1812], "radius"); if (knocker_core_services_db[1812] == NULL) return -1; knocker_core_services_db[1813] = malloc (11 + 1); strcpy (knocker_core_services_db[1813], "radius-acct"); if (knocker_core_services_db[1813] == NULL) return -1; knocker_core_services_db[2101] = malloc (10 + 1); strcpy (knocker_core_services_db[2101], "rtcm-sc104"); if (knocker_core_services_db[2101] == NULL) return -1; knocker_core_services_db[2401] = malloc (10 + 1); strcpy (knocker_core_services_db[2401], "cvspserver"); if (knocker_core_services_db[2401] == NULL) return -1; knocker_core_services_db[2430] = malloc (5 + 1); strcpy (knocker_core_services_db[2430], "venus"); if (knocker_core_services_db[2430] == NULL) return -1; knocker_core_services_db[2431] = malloc (8 + 1); strcpy (knocker_core_services_db[2431], "venus-se"); if (knocker_core_services_db[2431] == NULL) return -1; knocker_core_services_db[2432] = malloc (7 + 1); strcpy (knocker_core_services_db[2432], "codasrv"); if (knocker_core_services_db[2432] == NULL) return -1; knocker_core_services_db[2433] = malloc (10 + 1); strcpy (knocker_core_services_db[2433], "codasrv-se"); if (knocker_core_services_db[2433] == NULL) return -1; knocker_core_services_db[2583] = malloc (3 + 1); strcpy (knocker_core_services_db[2583], "mon"); if (knocker_core_services_db[2583] == NULL) return -1; knocker_core_services_db[2628] = malloc (4 + 1); strcpy (knocker_core_services_db[2628], "dict"); if (knocker_core_services_db[2628] == NULL) return -1; knocker_core_services_db[3050] = malloc (6 + 1); strcpy (knocker_core_services_db[3050], "gds_db"); if (knocker_core_services_db[3050] == NULL) return -1; knocker_core_services_db[3130] = malloc (5 + 1); strcpy (knocker_core_services_db[3130], "icpv2"); if (knocker_core_services_db[3130] == NULL) return -1; knocker_core_services_db[3306] = malloc (5 + 1); strcpy (knocker_core_services_db[3306], "mysql"); if (knocker_core_services_db[3306] == NULL) return -1; knocker_core_services_db[5002] = malloc (3 + 1); strcpy (knocker_core_services_db[5002], "rfe"); if (knocker_core_services_db[5002] == NULL) return -1; knocker_core_services_db[5308] = malloc (8 + 1); strcpy (knocker_core_services_db[5308], "cfengine"); if (knocker_core_services_db[5308] == NULL) return -1; knocker_core_services_db[6000] = malloc (3 + 1); strcpy (knocker_core_services_db[6000], "x11"); if (knocker_core_services_db[6000] == NULL) return -1; knocker_core_services_db[6001] = malloc (5 + 1); strcpy (knocker_core_services_db[6001], "x11-1"); if (knocker_core_services_db[6001] == NULL) return -1; knocker_core_services_db[6002] = malloc (5 + 1); strcpy (knocker_core_services_db[6002], "x11-2"); if (knocker_core_services_db[6002] == NULL) return -1; knocker_core_services_db[6003] = malloc (5 + 1); strcpy (knocker_core_services_db[6003], "x11-3"); if (knocker_core_services_db[6003] == NULL) return -1; knocker_core_services_db[6004] = malloc (5 + 1); strcpy (knocker_core_services_db[6004], "x11-4"); if (knocker_core_services_db[6004] == NULL) return -1; knocker_core_services_db[6005] = malloc (5 + 1); strcpy (knocker_core_services_db[6005], "x11-5"); if (knocker_core_services_db[6005] == NULL) return -1; knocker_core_services_db[6006] = malloc (5 + 1); strcpy (knocker_core_services_db[6006], "x11-6"); if (knocker_core_services_db[6006] == NULL) return -1; knocker_core_services_db[6007] = malloc (5 + 1); strcpy (knocker_core_services_db[6007], "x11-7"); if (knocker_core_services_db[6007] == NULL) return -1; knocker_core_services_db[7000] = malloc (15 + 1); strcpy (knocker_core_services_db[7000], "afs3-fileserver"); if (knocker_core_services_db[7000] == NULL) return -1; knocker_core_services_db[7001] = malloc (13 + 1); strcpy (knocker_core_services_db[7001], "afs3-callback"); if (knocker_core_services_db[7001] == NULL) return -1; knocker_core_services_db[7002] = malloc (13 + 1); strcpy (knocker_core_services_db[7002], "afs3-prserver"); if (knocker_core_services_db[7002] == NULL) return -1; knocker_core_services_db[7003] = malloc (13 + 1); strcpy (knocker_core_services_db[7003], "afs3-vlserver"); if (knocker_core_services_db[7003] == NULL) return -1; knocker_core_services_db[7004] = malloc (13 + 1); strcpy (knocker_core_services_db[7004], "afs3-kaserver"); if (knocker_core_services_db[7004] == NULL) return -1; knocker_core_services_db[7005] = malloc (11 + 1); strcpy (knocker_core_services_db[7005], "afs3-volser"); if (knocker_core_services_db[7005] == NULL) return -1; knocker_core_services_db[7006] = malloc (11 + 1); strcpy (knocker_core_services_db[7006], "afs3-errors"); if (knocker_core_services_db[7006] == NULL) return -1; knocker_core_services_db[7007] = malloc (8 + 1); strcpy (knocker_core_services_db[7007], "afs3-bos"); if (knocker_core_services_db[7007] == NULL) return -1; knocker_core_services_db[7008] = malloc (11 + 1); strcpy (knocker_core_services_db[7008], "afs3-update"); if (knocker_core_services_db[7008] == NULL) return -1; knocker_core_services_db[7009] = malloc (11 + 1); strcpy (knocker_core_services_db[7009], "afs3-rmtsys"); if (knocker_core_services_db[7009] == NULL) return -1; knocker_core_services_db[7100] = malloc (12 + 1); strcpy (knocker_core_services_db[7100], "font-service"); if (knocker_core_services_db[7100] == NULL) return -1; knocker_core_services_db[22273] = malloc (4 + 1); strcpy (knocker_core_services_db[22273], "wnn6"); if (knocker_core_services_db[22273] == NULL) return -1; knocker_core_services_db_init = 1; /* Initialization complete */ #ifdef DEBUG fprintf (stderr, "done.\n"); #endif #ifdef DEBUG for (i = 0; i < SERVICES_DB_TOTAL_SERVICES; i++) { if (knocker_core_services_db[i] != NULL) n_of_services++; } fprintf (stderr, "debug: succesfully stored %d service strings.\n", n_of_services); #endif return 0; } void free_knocker_core_services_db (void) { int i; /* if it hasn't been initialized yet we don't free anything */ if (!knocker_core_services_db_init) return; for (i = 0; i < SERVICES_DB_TOTAL_SERVICES; i++) { if (knocker_core_services_db[i] != NULL) free (knocker_core_services_db[i]); } knocker_core_services_db_init = 0; /* deinitialized state */ } /* ============================================================================ ============================================================================ */ char *knocker_core_services_db_get_service (unsigned int port, int protocol) { int slenght; /* string lenght */ if (!knocker_core_services_db_init) { /* if the services string list is not initialized */ return NULL; } if (protocol != PROTO_TCP) { if (protocol != PROTO_UDP) { return NULL; } } /* this functions returns the number of copied chars in tmpstr, if it is successfull, else -1 */ if (knocker_core_services_db[port] != NULL) slenght = strlen (knocker_core_services_db[port]); else slenght = -1; if (slenght == -1) { if (knocker_core_last_service == NULL) { knocker_core_last_service = malloc (strlen ("unknown") + 1); strcpy (knocker_core_last_service, "unknown"); } else { knocker_core_last_service = realloc (knocker_core_last_service, strlen ("unknown") + 1); strcpy (knocker_core_last_service, "unknown"); } return NULL; } if (knocker_core_last_service == NULL) { knocker_core_last_service = malloc (slenght + 1); } else { knocker_core_last_service = realloc (knocker_core_last_service, slenght + 1); } return (strcpy (knocker_core_last_service, knocker_core_services_db[port])); } knocker-0.7.1/src/knocker_services.h0000644000175000001440000000255207473301152013135 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_SERVICES_H_ #define _KNOCKER_SERVICES_H_ #ifdef HAVE_CONFIG_H # include #endif #define SERVICES_DB_TOTAL_SERVICES 30000 /* was erroneously 231 */ int knocker_core_services_db_init; char *knocker_core_services_db[SERVICES_DB_TOTAL_SERVICES]; int init_knocker_core_services_db ( void ); void free_knocker_core_services_db ( void ); char *knocker_core_services_db_get_service (unsigned int port, int protocol); #endif /* _KNOCKER_SERVICES_H_ */ knocker-0.7.1/src/knocker_led.c0000644000175000001440000001536607473301105012056 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 */ #include #include #include #include "knocker_led.h" #ifdef __WIN32__ #elif defined NO_LED #else #include #include #include #include #include #include #endif /* __WIN32__ */ /* Led values are in the linux/kd.h include */ #define LED_VALUE_NUM LED_NUM #define LED_VALUE_CAP LED_CAP #define LED_VALUE_SCR LED_SCR #ifndef NO_LED static int initialized = 0; #endif /* ============================================================================ ============================================================================ */ static int knocker_led_init (knocker_led_t * knocker_leds) { #ifndef NO_LED ioctl (0, KDSETLED, 0xff); knocker_leds->num = 0; knocker_leds->caps = 0; knocker_leds->scroll = 0; knocker_leds->sequence = 0; initialized = 1; #endif return 0; } /* ============================================================================ ============================================================================ */ static void knocker_led_quit (knocker_led_t * knocker_leds) { #ifndef NO_LED if (!initialized) return; knocker_leds->num = 0; knocker_leds->caps = 0; knocker_leds->scroll = 0; knocker_leds->sequence = 0; initialized = 0; #endif return; } /* ============================================================================ ============================================================================ */ void knocker_led_turn_on (int led) { #ifndef NO_LED char state; if (!initialized) knocker_led_init (&knocker_led_status); ioctl (0, KDGETLED, &state); if (led == KNOCKER_LED_NUMLOCK) { if (!knocker_led_status.num) { ioctl (0, KDSETLED, LED_VALUE_NUM); knocker_led_status.num = 1; } } else if (led == KNOCKER_LED_CAPSLOCK) { if (!knocker_led_status.caps) { ioctl (0, KDSETLED, LED_VALUE_CAP); knocker_led_status.caps = 1; } } else if (led == KNOCKER_LED_SCROLLOCK) { if (!knocker_led_status.scroll) { ioctl (0, KDSETLED, LED_VALUE_SCR); knocker_led_status.scroll = 1; } } #endif return; } /* ============================================================================ ============================================================================ */ void knocker_led_turn_off (int led) { #ifndef NO_LED char state; if (!initialized) return; ioctl (0, KDGETLED, &state); if (led == KNOCKER_LED_NUMLOCK) { if (knocker_led_status.num) { ioctl (0, KDSETLED, state & ~LED_VALUE_NUM); /*ioctl (0, KDSETLED, 0xff); */ knocker_led_status.num = 0; } } else if (led == KNOCKER_LED_CAPSLOCK) { if (knocker_led_status.caps) { ioctl (0, KDSETLED, state & ~LED_VALUE_CAP); /* ioctl (0, KDSETLED, 0xff); */ knocker_led_status.caps = 0; } } else if (led == KNOCKER_LED_SCROLLOCK) { if (knocker_led_status.scroll) { ioctl (0, KDSETLED, state & ~LED_VALUE_SCR); /* ioctl (0, KDSETLED, 0xff); */ knocker_led_status.scroll = 0; } } #endif return; } /* ============================================================================ ============================================================================ */ void knocker_led_turn_on_all (void) { #ifndef NO_LED if (!initialized) knocker_led_init (&knocker_led_status); ioctl (0, KDSETLED, LED_VALUE_SCR | LED_VALUE_NUM | LED_VALUE_CAP); knocker_led_status.num = 1; knocker_led_status.caps = 1; knocker_led_status.scroll = 1; #endif return; } /* ============================================================================ ============================================================================ */ void knocker_led_turn_off_all (void) { #ifndef NO_LED char state; if (!initialized) return; ioctl (0, KDGETLED, &state); ioctl (0, KDSETLED, state & ~(LED_VALUE_SCR | LED_VALUE_NUM | LED_VALUE_CAP)); knocker_led_status.num = 0; knocker_led_status.caps = 0; knocker_led_status.scroll = 0; #endif return; } /* ============================================================================ ============================================================================ */ void knocker_led_sequence (void) { #ifndef NO_LED if (ledt > led_delay) ledt = 0; if (ledt < 0) ledt = 0; ledt++; if (ledt != led_delay) return; if (knocker_led_status.sequence == 0) { /* no leds were on before */ /* turn on the first one */ knocker_led_turn_on (KNOCKER_LED_NUMLOCK); knocker_led_status.sequence = 1; return; } else if (knocker_led_status.sequence == 1) { /* NumLock was on before */ /* turn it off */ knocker_led_turn_off (KNOCKER_LED_NUMLOCK); knocker_led_turn_on (KNOCKER_LED_CAPSLOCK); knocker_led_status.sequence = 2; return; } else if (knocker_led_status.sequence == 2) { /* CapsLock was on before */ /* turn it off */ knocker_led_turn_off (KNOCKER_LED_CAPSLOCK); knocker_led_turn_on (KNOCKER_LED_SCROLLOCK); knocker_led_status.sequence = 3; return; } else if (knocker_led_status.sequence == 3) { /* ScrolLock was on before */ /* turn it off */ knocker_led_turn_off (KNOCKER_LED_SCROLLOCK); knocker_led_turn_on (KNOCKER_LED_NUMLOCK); knocker_led_status.sequence = 1; return; } #endif return; } /* ============================================================================ ============================================================================ */ void knocker_led_reset (void) { #ifndef NO_LED if (initialized) knocker_led_quit (&knocker_led_status); ioctl (0, KDSETLED, 0xff); #endif return; } knocker-0.7.1/src/knocker_led.h0000644000175000001440000000371007473301104012050 /* knocker version 0.7.1 * Release date: 24 May 2002 * * Project homepage: http://knocker.sourceforge.net * * Copyright 2001,2002 Gabriele Giorgetti * * * 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 _KNOCKER_LED_H_ #define _KNOCKER_LED_H_ #ifdef HAVE_CONFIG_H #include /* If we have config.h and NO_LED has not been defined */ /* we check for the include needed by the led functions */ /* if a include is missing, led are disabled. */ #ifndef NO_LED #ifndef HAVE_FCNTL_H #define NO_LED #endif #ifndef HAVE_SYS_IOCTL_H #define NO_LED #endif #ifndef HAVE_LINUX_KD_H #define NO_LED #endif #endif /* ifndef NO_LED */ #endif /* ifdef HAVE_CONFIG_H */ #ifdef __WIN32__ /* no led yet under WIN32 */ #define NO_LED #endif enum { KNOCKER_LED_NUMLOCK, KNOCKER_LED_CAPSLOCK, KNOCKER_LED_SCROLLOCK }; typedef struct { int num; int caps; int scroll; int sequence; /* used in knocker_led_sequence() only */ } knocker_led_t; knocker_led_t knocker_led_status; void knocker_led_turn_on (int led); void knocker_led_turn_off (int led); void knocker_led_turn_on_all ( void ); void knocker_led_turn_off_all ( void ); void knocker_led_sequence ( void ); void knocker_led_reset ( void ); #define led_delay 1 int ledt; #endif /* _KNOCKER_LED_H_ */ knocker-0.7.1/docs/0000777000175000001440000000000007473306521007653 5knocker-0.7.1/docs/Makefile.in0000644000175000001440000001310407473306521011633 # Makefile.in generated automatically by automake 1.4-p5 from Makefile.am # Copyright (C) 1994, 1995-8, 1999, 2001 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. # Makefile.am file for knocker # Edited by Gabriele Giorgetti # This file is processed by automake # No subdirs # SUBDIRS = SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include DESTDIR = pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : CC = @CC@ LIBS = @LIBS@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ man_MANS = knocker.1 EXTRA_DIST = $(man_MANS) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = man1dir = $(mandir)/man1 MANS = $(man_MANS) NROFF = nroff DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps docs/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status install-man1: $(mkinstalldirs) $(DESTDIR)$(man1dir) @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ done uninstall-man1: @list='$(man1_MANS)'; \ l2='$(man_MANS)'; for i in $$l2; do \ case "$$i" in \ *.1*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ rm -f $(DESTDIR)$(man1dir)/$$inst; \ done install-man: $(MANS) @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-man1 uninstall-man: @$(NORMAL_UNINSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-man1 tags: TAGS TAGS: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = docs distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ || cp -p $$d/$$file $(distdir)/$$file || :; \ fi; \ done info-am: info: info-am dvi-am: dvi: dvi-am check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am install-exec-am: install-exec: install-exec-am install-data-am: install-man install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am uninstall-am: uninstall-man uninstall: uninstall-am all-am: Makefile $(MANS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(mandir)/man1 mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: mostlyclean-am: mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-generic mostlyclean-am clean: clean-am distclean-am: distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am .PHONY: install-man1 uninstall-man1 install-man uninstall-man tags \ distdir info-am info dvi-am dvi check check-am installcheck-am \ installcheck install-exec-am install-exec install-data-am install-data \ install-am install uninstall-am uninstall all-redirect all-am all \ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # 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: knocker-0.7.1/docs/Makefile.am0000644000175000001440000000032207432561273011622 # Makefile.am file for knocker # Edited by Gabriele Giorgetti # This file is processed by automake # No subdirs # SUBDIRS = man_MANS = \ knocker.1 EXTRA_DIST = $(man_MANS) knocker-0.7.1/docs/knocker.10000644000175000001440000000461107473301274011307 .\" knocker man page .\" Process this file with: groff -man -Tascii .\" man page originally written by Gabriele Giorgetti .TH KNOCKER 1 "MAY 24, 2002" .SH NAME knocker \- An easy to use network security port scanner .SH SYNOPSIS .B \fBknocker\fR --host [\fIOPTION\fR] .SH DESCRIPTION .B knocker is a simple and easy to use TCP security port scanner written in C using pthreads which is able to analyze hosts and all of the different services started on them. .SH OPTIONS .TP \fB\-H\fr, \fB\-\-host\fR host name or numeric Internet address to scan .TP \fB\-P\fr, \fB\-\-port\fR port number to scan (single port scan only) .TP \fB\-SP\fr, \fB\-\-start-port\fR port number to begin the scan from .TP \fB\-EP\fr, \fB\-\-end-port\fR port number to end the scan at .TP \fB\-\-last-host\fR uses the last scanned host as target .TP \fB\-\-last-scan\fR performs again the last port scan .TP \fB\-q\fr, \fB\-\-quiet\fR disable console output and logs to file. .TP \fB\-lf\fr, \fB\-\-logfile \fR log the results to a specified file. .TP \fB\-nf\fr, \fB\-\-no-fency\fR disable fency output .TP \fB\-nc\fr, \fB\-\-no-colors\fR disable colored output .TP \fB\-\-configure\fR let the user configure knocker .TP \fB\-h\fR, \fB\-\-help\fR display this help and exit .TP \fB\-v\fR, \fB\-\-version\fR output version information and exit .SH EXAMPLES .LP To run this program the standard way type: .LP knocker --host 192.168.0.1 .LP If you want to specify a port range to scan: .LP knocker --host thehost --start-port 1 --end-port 2600 .LP or .LP knocker -H thehost -SP 1 -EP 2600 .LP To scan a single port: .LP knocker -H thehost --port 21 .LP To run this program not using colors (if your terminal does not support colors): .LP knocker --host 192.168.0.1 --no-colors .LP To run this program run in background and have the results written in a log file: .LP knocker --host 192.168.0.1 --quiet & .LP .LP .SH AVAILABILTY The latest version of this program can be found at http://knocker.sourceforge.net .SH BUGS See the BUGS file in the knocker source package for a list of known bugs. Report bugs to .SH AUTHOR knocker is written by Gabriele Giorgetti .SH COPYRIGHT Copyright \(co 2001,2002 Gabriele Giorgetti .br This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.