⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 基于TCP-WRAP原理的系统监控的c语言实现代码
💻
📖 第 1 页 / 共 4 页
字号:
Ultrix).You can use the `tcpdchk' program to identify the most common problemsin your wrapper and inetd configuration files.  With the `tcpdmatch' program you can examine how the wrapper wouldreact to specific requests for service.  The `try-from' program tests the host and username lookup code.  Run itfrom a remote shell command (`rsh host /some/where/try-from') and itshould be able to figure out from what system it is being called.The `safe_finger' command should be used when you implement a boobytrap:  it gives better protection against nasty stuff that remote hostsmay do in response to your finger probes.The tcpd program can be used to monitor the telnet, finger, ftp, exec,rsh, rlogin, tftp, talk, comsat and other tcp or udp services that havea one-to-one mapping onto executable files.With System V.4-style systems, the tcpd program can also handle TLIservices. When TCP/IP or UDP/IP is used underneath TLI, tcpd providesthe same functions as with socket-based applications. When some otherprotocol is used underneath TLI, functionality will be limited (noclient username lookups, weird network address formats).The tcpd program can also be used for services that are marked asrpc/udp in the inetd configuration file, but not for rpc/tcp servicessuch as rexd.  You probably do not want to run rexd anyway. On mostsystems it is even less secure than a wildcard in /etc/hosts.equiv.Install the tcpd command in a suitable place. Apollo UNIX users willwant to install it under a different name because the name "tcpd" isalready taken; a suitable name would be "frontd".  File protections: the wrapper, all files used by the wrapper, and alldirectories in the path leading to those files, should be accessiblebut not writable for unprivileged users (mode 755 or mode 555). Do notinstall the wrapper set-uid.Then perform the following edits on the inetd configuration file(usually /etc/inetd.conf or /etc/inet/inetd.conf):    finger  stream  tcp     nowait  nobody  /usr/etc/in.fingerd     in.fingerd                                            ^^^^^^^^^^^^^^^^^^^becomes:    finger  stream  tcp     nowait  nobody  /usr/etc/tcpd           in.fingerd                                            ^^^^^^^^^^^^^Send a `kill -HUP' to the inetd process to make the change effective.Some IRIX inetd implementations require that you first disable thefinger service (comment out the finger service and `kill -HUP' theinetd) before you can turn on the modified version. Sending a HUPtwice seems to work just as well for IRIX 5.3, 6.0, 6.0.1 and 6.1.AIX note: you may have to execute the `inetimp' command after changingthe inetd configuration file.The example applies to SunOS 4. With other UNIX implementations thenetwork daemons live in /usr/libexec, /usr/sbin, or /etc, the networkdaemons have no "in." prefix to their names, or the username field inthe inetd configuration file may be missing.When the finger service works as expected you can perform similarchanges for other network services. Do not forget the `kill -HUP'.The miscd daemon that comes with Ultrix implements several networkservices. It decides what to do by looking at its process name. One ofthe services is systat, which is a kind of limited finger service.  Ifyou want to monitor the systat service, install the miscd wrapper in asuitable place and update the inetd configuration file:    systat  stream  tcp     nowait  /suitable/place/miscd      systatdUltrix 4.3 allows you to specify a user id under which the daemon willbe executed. This feature is not documented in the manual pages.  Thus,the example would become:    systat  stream  tcp     nowait  nobody /suitable/place/miscd    systatdOlder Ultrix systems still run all their network daemons as root.In the absence of any access-control tables, the daemon wrapperswill just maintain a record of network connections made to your system.7.3 - Daemons with arbitrary path names---------------------------------------The above tcpd examples work fine with network daemons that live in acommon directory, but sometimes that is not practical. Having softlinks all over your file system is not a clean solution, either.Instead you can specify, in the inetd configuration file, an absolutepath name for the daemon process name.  For example,    ntalk   dgram   udp     wait    root    /usr/etc/tcpd /usr/local/lib/ntalkdWhen the daemon process name is an absolute path name, tcpd ignores thevalue of the REAL_DAEMON_DIR constant, and uses the last path componentof the daemon process name for logging and for access control.7.4 - Building and testing the access control rules---------------------------------------------------In order to support access control the wrappers must be compiled withthe -DHOSTS_ACCESS option. The access control policy is given in theform of two tables (default: /etc/hosts.allow and /etc/hosts.deny).Access control is disabled when there are no access control tables, orwhen the tables are empty.If you haven't used the wrappers before I recommend that you first runthem a couple of days without any access control restrictions. Thelogfile records should give you an idea of the process names and of thehost names that you will have to build into your access control rules.The syntax of the access control rules is documented in the filehosts_access.5, which is in `nroff -man' format. This is a lengthydocument, and no-one expects you to read it right away from beginningto end.  Instead, after reading the introductory section, skip to theexamples at the end so that you get a general idea of the language.Then you can appreciate the detailed reference sections near thebeginning of the document.The examples in the hosts_access.5 document (`nroff -man' format) showtwo specific types of access control policy:  1) mostly closed (onlypermitting access from a limited number of systems) and 2) mostly open(permitting access from everyone except a limited number of troublemakers). You will have to choose what model suits your situation best.Implementing a mixed policy should not be overly difficult either.Optional extensions to the access control language are described in thehosts_options.5 document (`nroff -man' format).The `tcpdchk' program examines all rules in your access control filesand reports any problems it can find. `tcpdchk -v' writes to standardoutput a pretty-printed list of all rules. `tcpdchk -d' examines thehosts.access and hosts.allow files in the current directory. Thisprogram is described in the tcpdchk.8 document (`nroff -man' format).The `tcpdmatch' command can be used to try out your local accesscontrol files.  The command syntax is:    tcpdmatch process_name hostname (e.g.: tcpdmatch in.tftpd localhost)    tcpdmatch process_name address  (e.g.: tcpdmatch in.tftpd 127.0.0.1)This way you can simulate what decisions will be made, and what actionswill be taken, when hosts connect to your own system. The program isdescribed in the tcpdmatch.8 document (`nroff -man' format).Note 1: `tcpdmatch -d' will look for hosts.{allow,deny} tables in thecurrent working directory. This is useful for testing new rules withoutbothering your users.Note 2: you cannot use the `tcpdmatch' command to simulate what happenswhen the local system connects to other hosts.In order to find out what process name to use, just use the service andwatch the process name that shows up in the logfile.  Alternatively,you can look up the name from the inetd configuration file. Coming backto the tftp example in the tutorial section above:    tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpbootThis entry causes the inetd to run the wrapper program (tcpd) with aprocess name `in.tftpd'.  This is the name that the wrapper will usewhen scanning the access control tables. Therefore, `in.tftpd' is theprocess name that should be given to the `tcpdmatch' command. On yoursystem the actual inetd.conf entry may differ (tftpd instead ofin.tftpd, and no `root' field), but you get the idea.When you specify a host name, the `tcpdmatch' program will use both thehost name and address. This way you can simulate the most common casewhere the wrappers know both the host address and the host name.  The`tcpdmatch' program will iterate over all addresses that it can findfor the given host name.When you specify a host address instead of a host name, the `tcpdmatch'program will pretend that the host name is unknown, so that you cansimulate what happens when the wrapper is unable to look up the clienthost name.7.5 - Other applications------------------------The access control routines can easily be integrated with otherprograms.  The hosts_access.3 manual page (`nroff -man' format)describes the external interface of the libwrap.a library.The tcpd program can even be used to control access to the mailservice.  This can be useful when you suspect that someone is tryingout some obscure sendmail bug, or when a remote site is misconfiguredand keeps hammering your mail daemon.In that case, sendmail should not be run as a stand-alone networklistener, but it should be registered in the inetd configuration file.For example:    smtp    stream  tcp     nowait  root    /usr/etc/tcpd /usr/lib/sendmail -bsYou will still need to run one sendmail background process to handlequeued-up outgoing mail. A command like:    /usr/lib/sendmail -q15m(no `-bd' flag) should take care of that. You cannot really preventpeople from posting forged mail this way, because there are manyunprotected smtp daemons on the network.8 - Acknowledgements--------------------Many people contributed to the evolution of the programs, by askinginspiring questions, by suggesting features or bugfixes, or bysubmitting source code.  Nevertheless, all mistakes and bugs in thewrappers are my own.Thanks to Brendan Kehoe (cs.widener.edu), Heimir Sverrisson (hafro.is)and Dan Bernstein (kramden.acf.nyu.edu) for feedback on an earlyrelease of this product.  The host name/address check was suggested byJohn Kimball (src.honeywell.com).  Apollo's UNIX environment has somepeculiar quirks: Willem-Jan Withagen (eb.ele.tue.nl), PieterSchoenmakers (es.ele.tue.nl) and Charles S. Fuller (wccs.psc.edu)provided assistance.  Hal R.  Brand (addvax.llnl.gov) told me how toget the client IP address in case of datagram-oriented services, andsuggested the optional shell command feature.  Shabbir Safdar(mentor.cc.purdue.edu) provided a first version of a much-needed manualpage.  Granville Boman Goza, IV (sei.cmu.edu) suggested to use theclient IP address even when the host name is available.  Casper H.S.Dik (fwi.uva.nl) provided additional insight into DNS spoofingtechniques.  The bogus daemon feature was inspired by code from AndrewMacpherson (BNR Europe Ltd).  Steve Bellovin (research.att.com)confirmed some of my suspicions about the darker sides of TCP/IPinsecurity. Risks of automated fingers were pointed out by Borja Marcos(we.lc.ehu.es). Brad Plecs (jhuspo.ca.jhu.edu) was kind enough to trymy early TLI code and to work out how DG/UX differs from Solaris.John P.  Rouillard (cs.umb.edu) deserves special mention for hispersistent, but constructive, nagging about wrong or missing things,and for trying out and discussing embryonic code or ideas.Last but not least, Howard Chu (hanauma.jpl.nasa.gov), Darren Reed(coombs.anu.edu.au), Icarus Sparry (gdr.bath.ac.uk), Scott Schwartz(cs.psu.edu), John A. Kunze (violet.berkeley.edu), Daniel Len Schales(engr.latech.edu), Chris Turbeville (cse.uta.edu), Paul Kranenburg(cs.few.eur.nl), Marc Boucher (cam.org), Dave Mitchell(dcs.shef.ac.uk), Andrew Maffei, Adrian van Bloois, Rop Gonggrijp, JohnC. Wingenbach, Everett F. Batey  and many, many others provided fixes,code fragments, or ideas for improvements.        Wietse Venema (wietse@wzv.win.tue.nl)        Department of Mathematics and Computing Science        Eindhoven University of Technology        P.O. Box 513        5600 MB Eindhoven        The Netherlands	Currently visiting IBM T.J. Watson Research, Hawthorne NY, USA.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -