728x90
태어나서 처음으로 핸드레이라는것을 해보았다.
우선 어셈블리 코드를 보기위해 gdb를 이용하였다.
이 코드안에 무슨 함수가 있는지 보기위해
info func
사용
main함수가 있는것을 봤으니 main함수부터 들어가보자
<main>
main함수를 보니깐 menu와 success함수도 이용하는 것을 알 수 있다.
코드의 흐름을 따라가면서 다른 함수들도 한번 보자
<menu>
<success>
코드를 완벽하게 작성하기전에 실행되면 어떻게 되는 지 한번 실행해보자
근데 이 부분이 배열을 의미하는거 같은데 뒤에 주소가 무엇을 담고있는지 어제부터 잘 모르겠었다..
그래서
x/30wx
명령어를 이용해서 주소를 까보니
이렇게 나오는데 일일히 배열안에 넣어야 할 거 같다
그럼 이제 c언어 코드로 작성해보자
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | #include <stdio.h> void menu(); void success(); void passcode(); int main() { menu(); int num; printf("Input number : "); scanf("%d",&num); if(num==1658) { success(); } else { puts("It is not...."); } } void menu() { passcode(); puts("\nI need a password to conquer the planet."); puts("so could you let me konw?"); puts("(hint: password is sum of my name)"); } void passcode() { int a = 0; int hello[50]; hello[0] = 0x00000090; hello[1] = 0x000000ca; hello[2] = 0x000000d8; hello[3] = 0x000000d8; hello[4] = 0x000000de; hello[5] = 0x00000042; hello[6] = 0x00000040; hello[7] = 0x0000009a; hello[8] = 0x000000f2; hello[9] = 0x00000040; hello[10] = 0x000000dc; hello[11] = 0x000000c2; hello[12] = 0x000000da; hello[13] = 0x000000ca; hello[14] = 0x00000040; hello[15] = 0x000000d2; hello[16] = 0x000000e6; hello[17] = 0x00000040; hello[18] = 0x0000009a; hello[19] = 0x000000ca; hello[20] = 0x000000ce; hello[21] = 0x000000c2; hello[22] = 0x000000e8; hello[23] = 0x000000e4; hello[24] = 0x000000de; hello[25] = 0x000000dc; hello[26] = 0x00000042; for(a=0; a<=26; a++) { putchar(hello[a]/2); } } void success() { puts("Thank you!!! Help us conquer the earth."); } | cs |
이제 한번 실행해보자
잘된다ㅎㅎㅎ
저 배열부분이 자동적으로 문자열을 찾아주는게 아니라 하나하나 대입해준거였다..
어제 이것때문에 힘들었는데
해결했다
친구한테 알려줘야겠다.
반응형