📄 unix- a hacking tutorial.sir
字号:
[123]: killed $ kill -9 122 garbage NO CARRIERAlso, you can do "kill -1 0" to kill your shell process to log yourself off.This is useful in scripts (explained later).-------------------Shell Programmin'------------------- Shell Programming is basically making a "script" file for thestandard shell, being sh, ksh, csh, or something on those lines. Itslike an MSDOS batch file, but more complex, and more Flexible.This can be useful in one aspect of hacking.First, lets get into variables. Variables obviously can be assignedvalues. These values can be string values, or numberic values.number=1 That would assign 1 to the variable named "number".string=Hi Thereorstring="Hi There" Both would assign "Hi there" to a variable. Using a variable is different though. When you wish to use a variable you must procede it with a dollar ($) sign. These variables can be used as arguments in programs. When I said that scripts are like batch files, I meant it. You can enter in any name of a program in a script file, and it will execute it. Here is a sample script.counter=1arg1="-uf"arg2="scythian"ps $arg1 $arg2echo $counter That script would translate to "ps -uf scythian" then would print "1" after that was finished. ECHO prints something on the screen whether it be numeric, or a string constant.Other Commands / Examples:read - reads someting into a variable. format : read variable . No dollar sign is needed here! If I wwanted to get someone's name, I could put:echo "What is your name?"read hisnameecho Hello $hisname What is your name? Sir Hackalot Hello Sir Hackalot Remember, read can read numeric values also.trap - This can watch for someone to use the interrupt character. (Ctrl-c) format: trap "command ; command ; command ; etc.."Example: trap "echo 'Noway!! You are not getting rid o me that easy' ; echo 'You gotta see this through!'" Now, if I hit control-c during the script after this statement was executed, I'd get: Noway!! You are not getting rid of me that easy You gotta see this through!exit : format :exit [num] This exists the shell [quits] with return code of num.-----CASE----- Case execution is like a menu choice deal. The format of the command or structure is : case variable in 1) command; command;; 2) command; command; command;; *) command;; esac Each part can have any number of commands. The last command however must have a ";;". Take this menu: echo "Please Choose:" echo "(D)irectory (L)ogoff (S)hell" read choice case $choice in D) echo "Doing Directory..."; ls -al ;; L) echo Bye; kill -1 0;; S) exit;; *) Echo "Error! Not a command";; esac The esac marks the end of a case function. It must be after the LAST command.Loops----- Ok, loops. There are two loop functins. the for loops, and the repeat. repeat looks like this: repeat something somethin1 somethin2 this would repeat a section of your script for each "something". say i did this: repeat scythian sirhack prophet I may see "scythian" then sirhack then prophet on my screen. The for loop is defined as "for variable in something do .. .. done" an example: for counter in 1 2 3 do echo $counter done That would print out 1 then 2 then 3.Using TEST----------The format: Test variable option variableThe optios are:-eq =-ne <> (not equal)-gt >-lt <-ge >=-le <=for strings its: = for equal != for not equal.If the condition is true, a zero is returned. Watch: test 3 -eq 3that would be test 3 = 3, and 0 would be returned.EXPR----This is for numeric functions. You cannot simply type inecho 4 + 5and get an answer most of the time. you must say:expr variable [or number] operator variable2 [or number]the operators are:+ add- subtract* multiply/ divide^ - power (on some systems)example : expr 4 + 5var = expr 4 + 5var would hold 9. On some systems, expr sometimes prints out a formula. I mean, 22+12 is not the same as 22 + 12. If you said expr 22+12 you would see: 22+12 If you did expr 22 + 12 you'd see: 34SYSTEM VARIABLES---------------- These are variables used by the shell, and are usually set in thesystem wide .profile [explained later].HOME - location of your home directory.PS1 - The prompt you are given. usually $ . On BSD its usually &PATH - This is the search path for programs. When you type in a programto be run, it is not in memory; it must be loaded off disk. Most commandsare not in Memory like MSDOS. If a program is on the search path, it maybe executed no matter where you are. If not, you must be in the directorywhere the program is. A path is a set of directories basically, seperated by":"'s. Here is a typical search path: :/bin:/etc:/usr/lbin:$HOME:When you tried to execute a program, Unix would look for it in /bin,/etc, /usr/lbin, and your home directory, and if its not found, an error isspewed out. It searches directories in ORDER of the path. SO if you had aprogram named "sh" in your home directory, and typed in "sh", EVEN ifyou were in your home dir, it would execute the one in /bin. So, youmust set your paths wisely. Public access Unixes do this for you, but systemsyou may encounter may have no path set.TERM - This is your terminal type. UNIX has a library of functions called"CURSES" which can take advantage of any terminal, provided the escapecodes are found. You must have your term set to something if you runscreen oriented programs. The escape codes/names of terms are foundin a file called TERMCAP. Don't worry about that. just set your termto ansi or vt100. CURSES will let you know if it cannot manipulate yourterminal emulation.-------------------The C compiler------------------- This Will be BRIEF. Why? Becuase if you want to learn C, go buy a book. I don't have time to write another text file on C, for it would be huge. Basically, most executables are programmed in C. Source code files on unix are found as filename.c . To compile one, type in "cc filename.c". Not all C programs will compile, since they may depend on other files not there, or are just modules. If you see a think called "makefile" you can usually type in just "make" at the command prompt, and something will be compiled, or be attempted to compile. When using make or CC, it would be wise to use the background operand since compiling sometimes takes for ever. IE: $ cc login.c& [1234] $ (The 1234 was the process # it got identified as)._____________________________________________________________________________---------------The FILE SYSTEM--------------- This is an instrumental part of UNIX. If you do not understand thissection, you'll never get the hang of hacking Unix, since a lot of Pranksyou can play, and things you can do to "raise your access" depend on it.First, Let's start out by talking about the directory structure. It isbasically a Hiearchy file system, meaning, it starts out at a root directoryand expands, just as MSDOS, and possibly AmigaDos.Here is a Directory Tree of sorts: (d) means directory / (root dir) | |--------------------| bin (d) usr (d) ----^-------------------- | | | sirhack(d) scythian (d) prophet (d) | src (d)Now, this particular system contains the following directories://bin/usr/usr/sirhack/usr/sirhack/src/usr/scythian/usr/prophetHopefully, you understood that part, and you should. Everything spawns fromthe root directory.o File Permissions!------------------Now, this is really the biggie. File Permissions. It is not that hard tounderstand file permissions, but I will explain them deeply anyway.OK, now you must think of user groups as well as user names. Everyonebelongs to a group. at the $ prompt, you could type in 'id' to see whatgroup you are in. Ok, groups are used to allow people access certain things,instead of just having one person controlling/having access to certain files.Remember also, that Unix looks at someone's UID to determine access, notuser name.Ok. File permissions are not really that complicated. Each file has an ownerThis OWNER is usually the one who creates the file, either by copying a fileor just by plain editing one. The program CHOWN can be used to give someoneownership of a file. Remember that the owner of a file must be the one whoruns CHOWN, since he is the only one that can change the permissions of a fileAlso, there is a group owner, which is basically the group that you were inwhen the file was created. You would use chgrp to change the group a file isin.Now, Files can have Execute permissions, read permissions, or write permission.If you have execute permission, you know that you can just type in the nameof that program at the command line, and it will execute. If you have readpermission on a file, you can obviously read the file, or do anything thatreads the file in, such as copying the file or cat[ing] it (Typing it).If you do NOT have access to read a file, you can't do anything that requiresreading in the file. This is the same respect with write permission. Now,all the permissions are arranged into 3 groups. The first is the owner'spermissions. He may have the permissions set for himself to read and executethe file, but not write to it. This would keep him from deleting it.The second group is the group permissions. Take an elongated directoryfor an example: $ ls -l runme r-xrwxr-- sirhack root 10990 March 21 runmeok. Now, "root" is the groupname this file is in. "sirhack" is the owner.Now, if the group named 'root' has access to read, write and execute, they
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -