Information Security/Malware

Making Generate Yara rules

2013. 1. 18. 16:25

1. About

분명 공격하는 기법은 비슷한데, 소스코드가 조금씩 다르다면? 이를 yara의 패턴탐지 기법으로 분류를 하고자 한다면? 설정한 사람이 '아차'하며 놓친부분이 존재한다면? 작은 실수를 줄이기 위해서는 명확한 알고리즘과 그에 맞는 프로그래밍 혹은 도구들을 사용하는 것이 좋다고 생각한다. 다음 소개할 툴은 O(ND) 알고리즘과 google-diff-match-patch를 이용하여 Yara rule를 출력해 주는 프로그램이다.

2. Features

  • 커맨드 라인을 통해 주어진 디렉토리의 모든 파일들을 읽음
  • 읽은 파일들끼리 비교하여 분석, 일치하는 블록을 기억
  • 적어도 최소 5바이트 크기의 샘플의 70%정도 일치하는 경우에만 비교하여 일치한 블록들을 저장
  • 유사한 블록들은 인쇄할 수 있음

3. Usage

테스트는 Gongda exploit 코드를 비교 분석하였다.


./autorule/tester.py gongda_test/gongda/

CFileDiffer: Diffing a total of 15 file(s)
CFileDiffer: Diffing file 1 out of 15
CFileDiffer: Diffing file 2 out of 15
CFileDiffer: Diffing file 3 out of 15
CFileDiffer: Diffing file 4 out of 15
CFileDiffer: Diffing file 5 out of 15
CFileDiffer: Diffing file 6 out of 15
CFileDiffer: Diffing file 7 out of 15
CFileDiffer: Diffing file 8 out of 15
CFileDiffer: Diffing file 9 out of 15
CFileDiffer: Diffing file 10 out of 15
CFileDiffer: Diffing file 11 out of 15
CFileDiffer: Diffing file 12 out of 15
CFileDiffer: Diffing file 13 out of 15
CFileDiffer: Diffing file 14 out of 15
CFileDiffer: Diffing file 15 out of 15
rule test : test
{
  strings:
    $a = "<script type=\"text/javascript\" src=\"swfobject.js\"></script>\\r\\n<script src=jpg.js></script>\\r\\n<script type=\"text/javascript\">\\r\\nvar "
    $b = ");\\r\\n}\\r\\n</script>\\r\\n"
    $c = "&logo=1\" charset=\"gb2312\"></script>"
    $d = "></script>"
    $e = "</script>\\r\\n"
    $f = "6);\\r\\n}\\r\\n</script>\\r\\n"
    $g = "<script "
    $h = "&logo=1\" charset=\"gb2312\"></script>\\r\\n"

  condition:
    ($c) or                             // Matches a total of 11 file(s) out of 15
    ($f and $h) or                      // Matches a total of 5 file(s) out of 15
    ($a and $b and $d and $e and $g)    // Matches a total of 15 file(s) out of 15 
}

4. Strength

  • Yara rules에 맞는 문장으로 출력
  • condition에서 탐지 수준을 결정할 수 있음

5. Weakness

아래의 예제에서 보는 것과 같이 test를 도출해 내고자 하지만, 글자를 비교하는 것이 아닌 그림 처럼 비교하기 때문에 아쉬운 점이 존재함.

(notepad++에서 plugin의 compare기능과 비슷함)

위와 같은 이유로 파이썬으로 자동화 하기 어려움

(취약점 코드에서만 테스트 하고, 악성코드에서는 어떻게 적용 될지는 테스트 하지 못함)


cat ~/autorule/test/test01
test 0303232
cat ~/autorule/test/test02
123323 test
./autorule/tester.py test/
CFileDiffer: Diffing a total of 2 file(s)
CFileDiffer: Diffing file 1 out of 2
CFileDiffer: Diffing file 2 out of 2
rule test : test
{
 strings:

 condition:
}

6. Reference

  • UNINTENDED RESULTS OR MAYBE NOT
  • You can download 'tester.py' tool here.
반응형
저작자표시 비영리 동일조건 (새창열림)

'Information Security > Malware' 카테고리의 다른 글

Javascript Compressor  (0) 2013.02.07
Redkit Exploit Tool : Redkit Landing Page에 관한 정보  (10) 2013.02.03
Deformed of Gondad Exploit Obfuscation  (2) 2013.01.18
Exploit ToolKit  (0) 2012.08.27
Exploit Reference Website  (0) 2012.07.16
'Information Security/Malware' 카테고리의 다른 글
  • Redkit Exploit Tool : Redkit Landing Page에 관한 정보
  • Deformed of Gondad Exploit Obfuscation
  • Exploit ToolKit
  • Exploit Reference Website
hakawati
hakawati
Research Engineer

블로그 메뉴

  • 홈
  • 방명록
  • 블로그 관리
hakawati
Hakawati Security Lab
hakawati
전체
오늘
어제

공지사항

  • About Me
  • Hakawati Lab (252)
    • Notice (7)
      • Main (4)
      • Sub Notice (1)
      • Tips (2)
    • Information Technology (58)
      • System Architecture (2)
      • Programming (20)
      • Operation System (16)
      • Machine Learning (5)
      • Bigdata (2)
      • File Format (7)
      • Network (2)
      • Cloud (3)
      • Domain (1)
    • Information Security (183)
      • Security Information (36)
      • CTI & Threat Hunting (1)
      • Digital Forensics (1)
      • Licenses (2)
      • Malware (40)
      • OpenSource (53)
      • Incident Response (1)
      • Seminar (8)
      • Cryptography (2)
      • Books (11)
      • Vulnerability (4)
      • Web Hacking (8)
      • Wargame (10)
      • Abuse & Fraud (6)
    • Life Hacking (3)
      • Term Idea (0)
      • Books (3)
      • Travels (0)
      • Activities (0)
      • Workout (0)

인기 글

태그

  • 도메인
  • CWE
  • cloud
  • NIST
  • 서브도메인
  • WWW
  • 줄리엣
  • cloudflare
  • EC2
  • instance
  • Amazon
  • Macie
  • sub-domain
  • security
  • domain
  • AWS
  • juliet

최근 댓글

최근 글

hELLO · Designed By 정상우.
hakawati
Making Generate Yara rules
상단으로

티스토리툴바

개인정보

  • 티스토리 홈
  • 포럼
  • 로그인

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.