안녕하세요

손예진@Google의 이미지

phase_2:
0x0000000000400f49 <+0>: push %rbp
0x0000000000400f4a <+1>: push %rbx
0x0000000000400f4b <+2>: sub $0x38,%rsp
0x0000000000400f4f <+6>: mov %fs:0x28,%rax
0x0000000000400f58 <+15>: mov %rax,0x28(%rsp)
0x0000000000400f5d <+20>: xor %eax,%eax
0x0000000000400f5f <+22>: mov %rsp,%rsi
0x0000000000400f62 <+25>: callq 0x4016bc
0x0000000000400f67 <+30>: cmpl $0x0,(%rsp)
0x0000000000400f6b <+34>: jg 0x400f72
0x0000000000400f6d <+36>: callq 0x401686
0x0000000000400f72 <+41>: lea 0x4(%rsp),%rbp
0x0000000000400f77 <+46>: mov $0x1,%ebx
0x0000000000400f7c <+51>: jmp 0x400fa0
0x0000000000400f7e <+53>: add %edx,%edx
0x0000000000400f80 <+55>: add $0x1,%eax
0x0000000000400f83 <+58>: cmp %ebx,%eax
0x0000000000400f85 <+60>: jne 0x400f7e
0x0000000000400f87 <+62>: add -0x4(%rbp),%edx
0x0000000000400f8a <+65>: cmp %edx,0x0(%rbp)
0x0000000000400f8d <+68>: je 0x400f94
0x0000000000400f8f <+70>: callq 0x401686
0x0000000000400f94 <+75>: add $0x1,%ebx
0x0000000000400f97 <+78>: add $0x4,%rbp
0x0000000000400f9b <+82>: cmp $0x7,%ebx
0x0000000000400f9e <+85>: je 0x400fb0
0x0000000000400fa0 <+87>: mov $0x1,%edx
0x0000000000400fa5 <+92>: mov $0x0,%eax
0x0000000000400faa <+97>: test %ebx,%ebx
0x0000000000400fac <+99>: jg 0x400f7e
0x0000000000400fae <+101>: jmp 0x400f87
0x0000000000400fb0 <+103>: mov 0x28(%rsp),%rax
---Type to continue, or q to quit---r
0x0000000000400fb5 <+108>: xor %fs:0x28,%rax
0x0000000000400fbe <+117>: je 0x400fc5
0x0000000000400fc0 <+119>: callq 0x400b90 <__stack_chk_fail@plt>
0x0000000000400fc5 <+124>: add $0x38,%rsp
0x0000000000400fc9 <+128>: pop %rbx
0x0000000000400fca <+129>: pop %rbp
0x0000000000400fcb <+130>: retq

read_number:
0x00000000004016bc <+0>: sub $0x10,%rsp
0x00000000004016c0 <+4>: mov %rsi,%rdx
0x00000000004016c3 <+7>: lea 0x4(%rsi),%rcx
0x00000000004016c7 <+11>: lea 0x18(%rsi),%rax
0x00000000004016cb <+15>: push %rax
0x00000000004016cc <+16>: lea 0x14(%rsi),%rax
0x00000000004016d0 <+20>: push %rax
0x00000000004016d1 <+21>: lea 0x10(%rsi),%rax
0x00000000004016d5 <+25>: push %rax
0x00000000004016d6 <+26>: lea 0xc(%rsi),%r9
0x00000000004016da <+30>: lea 0x8(%rsi),%r8
0x00000000004016de <+34>: mov $0x402961,%esi
0x00000000004016e3 <+39>: mov $0x0,%eax
0x00000000004016e8 <+44>: callq 0x400c40 <__isoc99_sscanf@plt>
0x00000000004016ed <+49>: add $0x20,%rsp
0x00000000004016f1 <+53>: cmp $0x6,%eax
0x00000000004016f4 <+56>: jg 0x4016fb
0x00000000004016f6 <+58>: callq 0x401686
0x00000000004016fb <+63>: add $0x8,%rsp
0x00000000004016ff <+67>: retq

read_number은 7자리 숫자있는거 확인하는거 맞죠??
위에 phase_2해석이 어렵습니다 ㅠ 짧은건 할 수 있는데 저렇게 긴건 처음이라ㅠ
알려주시면 감사하겠습니다..

Stephen Kyoungwon Kim@Google의 이미지

제가 단언컨대 가장 크게 도움을 받은 책이 Computer Systems: Programmer's Perspective였습니다. 이거, 그 과목 들을 때 나왔던 바이너리 분석하거나 크랙킹 하는 과제 같군요.

어셈블리와 C가 어떻게 다른지 높은 추상 수준에서 이해하고, C를 어셈블리로 어떻게 옮길 것이냐가 관건입니다. 일례로 C에는 function call이 있지만, 어셈블리에는 call instruction밖에 없습니다. call instruction은 단순히 PC를 옮겨서 코드의 다른 부분을 실행하는 거라서 얼핏 보기엔 GOTO랑 별 큰 차이가 없죠.

만약 질문하신 분이 어셈블리 프로그래머로서 C의 함수를 어셈블리로 손으로 번역한다면 어떻게 하시겠습니까? 그 책에 그 설명이 잘 되어 있습니다. 이 과제는 그 설명을 먼저 이해하고 코드를 읽으면서 확인해 보는 건데, 설명을 이해하고도 아직 이 과제가 어렵다면, 먼저 아주 간단한 함수 들을 C로 짜서 -g -O0 -S로 컴파일 하신 다음에 어셈블리 코드를 들여다 보세요.

마찬가지로 C에는 있지만 어셈블리에는 없는 게 여럿 있습니다. 변수.. C는 무한개의 변수를 허용하지만 어셈블리는 그렇지 않죠. 이 문제는 어떻게 할까요? C는 배열이나 구조체가 있지만 어셈블리에도 있나요?

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.