0x02.
2. Writing a simple Program in C
: To find a security problem with the software, you need to understand how the software is written. : It is also very useful to explore different language programming to understand the differences.
: Content
-> Installing vim editor
: sudo apt-get vim
: ESC -> “:” -> w(=save)q(=quit)!(force)
: ESC -> “:” -> syntax on
: ESC -> “:” -> set number
: simple C Code interpretation
-> #include <stdio.h> //include문을 사용하여 표준I/O(입출력)기능을 추가
int main(int argc, char *argv[]){ //main이라는 입력 기능 정의, 모든 C 프로그램에는 이 기능이 있으며 시작점이다.
# The first parameter is the argc integer. It refers to the number of arguments.
# The second parameter refers to a list.(argument vector)
printf(”Knock, knock, Neo\n”);
}
: ESC -> “:” -> wq
: gcc “-Wall” Options -> Options to alert for all ambiguous coding.
: Additional the simple Code
-> “return 0;”
: Let's add a little more functionality.
-> #include <stdio.h>
int main(int argc, char *argv[]){
if(argc==2){
printf(”Knock, knock, %s\n”, argv[1]);
} else{
fprintf(stderr, “Usage: %s <name>\n”, argv[0]);
return 1;
}
return 0;
}
-> command-line: ~$ ./matrix argument1 argument2
in-c: argv[0] argv[1] argv[2] …
-> PATH environment variable
: env
: env | grep PATH
: echo $PATH
: whereis <Directory>
-> variables on the command-line
: Move to the last line of "vim".
-> complie a C program with “gcc”
: gcc “Filename.c” -o “Save_Filename”
: Tips. Let's change the options when we start the terminal.
-> vim .bashrc # “.bashrc” meaing : Files that are set to be applied at Linux boot time and applied when running.
-> “Shift+G” -
-> “i” OR “o” (=insert content)
-> export PATH=$PATH:/home/liveoverflow
matrix $USER
-> ESC -> “:” -> wq
-> It can be easier if you use “echo” instead of “C” compilation.
-> vi vimrc - "vim" Editor Settings
-> $ vi ~/.vimrc
-> # Syntax Highlighting
if has(“syntax”)
syntax on
Endif
-> # Automatic Indent Settings
set autoindent
set cindent
-> # line number display
Set number
-> ESC -> “:” -> wq
* “env” command(환경변수)
: PATH
* “.bashrc” file
: Load whenever you open a new terminal window while already logged in.
-> The file used when the terminal is started.Buffers or arrays are ready to simpleinteger variables.
-> “Shift + G”
-> Insert
-> export PATH=$PATH:/home/rnrf
matrix $USER
(OR) -> /home/rnrf/matrix $USER