fuzzing theory

in #hacking5 years ago

퍼징(fuzzing)이란 무엇인가?

어플리케이션에 무작위 변수를 무차별 적으로 대입하여 시스템을 fuzz 시키는것

이를 통해 시스템의 취약점은 찾을 수 있다.

두가지의 fuzzing 방법

Mutation vs. Generation

Mutation의 경우 입력값을 순수하게 랜덤으로 돌려 무작위로 append하거나 replace 한다

Generation의 경우는 입력 값의 포맷을 이해하고 범위를 제한 해주는 대입

 |구분 | Mutation | Generation|

 |장점 | 이해 필요x  | 이해만 한다면 시간 절약 가능 |

 | 단점 | 경계값이 불 분명함 | 어려운 난이도|

따라서 상황에 따라 적절한 방법을 섞어 사용해야 할것이다(눕인 나는 mutation만..)

그렇다면 퍼징을 하는 방법은?

현재 퍼징을 할 수 있는 수 많은 파이썬 모듈들이 오픈소스로 풀려있다 따라서 깃허브를 뒤지다보면 쉽게 찾을  수 있다 

  • afl-python: enables American fuzzy lop fork server and instrumentation for pure-Python code
  • Sulley: fuzzer development and fuzz testing framework consisting of multiple extensible components
  • Peach Fuzzing Platform: extensible fuzzing framework for generation and mutation based fuzzing (v2 was written in Python)
  • antiparser: fuzz testing and fault injection API
  • TAOF, (The Art of Fuzzing) including ProxyFuzz, a man-in-the-middle non-deterministic network fuzzer
  • untidy: general purpose XML fuzzer
  • Powerfuzzer: highly automated and fully customizable web fuzzer (HTTP protocol based application fuzzer)
  • SMUDGE
  • Mistress: probe file formats on the fly and protocols with malformed data, based on pre-defined patterns
  • Fuzzbox: multi-codec media fuzzer
  • Forensic Fuzzing Tools: generate fuzzed files, fuzzed file systems, and file systems containing fuzzed files in order to test the robustness of forensics tools and examination systems
  • Windows IPC Fuzzing Tools: tools used to fuzz applications that use Windows Interprocess Communication mechanisms
  • WSBang: perform automated security testing of SOAP based web services
  • Construct: library for parsing and building of data structures (binary or textual). Define your data structures in a declarative manner
  • fuzzer.py (feliam): simple fuzzer by Felipe Andres Manzano
  • Fusil: Python library used to write fuzzing programs 

출처: https://github.com/dloss/python-pentest-tools

하지만 본격적으로 툴을 사용하기전에 간단한 코딩을 통해 원리를 파악하는 것이 더 중요하다고 생각한다

따라서 기본적인 예제를 통해 원리를 익힐 것이다

 https://www.slideshare.net/CodeEngn/2012-codeengn-conference-06-beist-everyone-has-his-or-her-own-fuzzer  

codeengn에서 발표된 fuzz에 대해 도움이 될 수 있는 자료를 찾았다

원리는 간단하지만 근본 적인 fuzz 알고리즘을 이해 시켜 줄 수 있는 예시이다

import os, sys, random

def go():
   return random.randrange(0, 0x100)
while 1:
    filesize = os.path.getsize("./fuz.bin")
    fp = open("./fuz.bin", "rb++")
    tmpoffset = random.randrange(0, filesize)
    fp.seek(tmpoffset, 0)
    fp.write("%c%c%c%c" % (go(), go(), go(), go()))#입력값 삽입
    fp.close()
    os.system("./fuz.bin")#실행

실제로 위의 10줄 짜리 코드가 크래쉬를 일으키는 것을 볼 수 있었다.

향후

Tool 을 사용하여 실제로 오류가 난 지점을 벡터로 활용해 원하는 작업을 실행하는 방법을 강구하고 실습 해볼 것

Sort:  

Hello @jej2660! This is a friendly reminder that you have 3000 Partiko Points unclaimed in your Partiko account!

Partiko is a fast and beautiful mobile app for Steem, and it’s the most popular Steem mobile app out there! Download Partiko using the link below and login using SteemConnect to claim your 3000 Partiko points! You can easily convert them into Steem token!

https://partiko.app/referral/partiko

Congratulations @jej2660! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 57610.17
ETH 3118.28
USDT 1.00
SBD 2.39