
ML 기반 웹 애플리케이션 방화벽을 위한 유도 돌연변이 기반 퍼저
ML 기반 웹 애플리케이션 방화벽(Web Application Firewall, WAF)을 위한 가이드 변이 기반 퍼저로, AFL에서 영감을 받았으며 Andreas Zeller 등의 FuzzingBook을 기반으로 합니다.
입력된 SQL 인젝션 쿼리가 주어지면, 대상 WAF를 우회할 수 있는 의미론적으로 동일한 쿼리를 생성하려고 시도합니다. 이 도구를 사용하여 WAF-A-MoLE이 솔루션 공간을 탐색하여 대상 분류기가 놓친 위험한 "사각지대"를 찾도록 함으로써 제품의 견고성을 평가할 수 있습니다.

WAF-A-MoLE은 초기 페이로드를 받아 페이로드 **풀(Pool)**에 삽입합니다. 이 풀은 각 페이로드에 대한 WAF 신뢰도 점수로 정렬된 우선순위 큐를 관리합니다.
각 반복(iteration) 동안, 페이로드 풀의 헤드는 **퍼저(Fuzzer)**로 전달되어 사용 가능한 변이 연산자 중 하나를 무작위로 적용하여 변이(mutate)됩니다.
모든 변이 연산자는 의미론을 보존하며 SQL 언어의 높은 표현력(이 버전에서는 MySQL)을 활용합니다.
다음은 현재 버전의 WAF-A-MoLE에서 사용 가능한 변이 연산자입니다.
| 변이(Mutation) | 예제(Example) |
|---|---|
| 대소문자 변경 (Case Swapping) | admin' OR 1=1# ⇒ admin' oR 1=1# |
| 공백 대체 (Whitespace Substitution) | admin' OR 1=1# ⇒ admin'\t\rOR\n1=1# |
| 주석 삽입 (Comment Injection) | admin' OR 1=1# ⇒ admin'/**/OR 1=1# |
| 주석 재작성 (Comment Rewriting) | admin'/**/OR 1=1# ⇒ admin'/*xyz*/OR 1=1#abc |
| 정수 인코딩 (Integer Encoding) | admin' OR 1=1# ⇒ admin' OR 0x1=(SELECT 1)# |
| 연산자 교체 (Operator Swapping) | admin' OR 1=1# ⇒ admin' OR 1 LIKE 1# |
| 논리적 불변식 (Logical Invariant) | admin' OR 1=1# ⇒ admin' OR 1=1 AND 0<1# |
| 숫자 섞기 (Number Shuffling) | admin' OR 1=1# ⇒ admin' OR 2=2# |
WAF-A-MoLE은 "WAF-A-MoLE: Evading Web Application Firewalls through Adversarial Machine Learning"에서 제시된 방법론을 구현합니다. 사전 인쇄본은 arXiv에서도 찾을 수 있습니다.
인용을 원하시면 다음 (BibTeX) 참조를 사용해 주십시오:
@inproceedings{demetrio20wafamole,
title={WAF-A-MoLE: evading web application firewalls through adversarial machine learning},
author={Demetrio, Luca and Valenza, Andrea and Costa, Gabriele and Lagorio, Giovanni},
booktitle={Proceedings of the 35th Annual ACM Symposium on Applied Computing},
pages={1745--1752},
year={2020}
}
pip install -r requirements.txt
자체 WAF의 견고성을 평가하거나 일부 예제 분류기를 대상으로 WAF-A-MoLE을 시험해 볼 수 있습니다. 첫 번째 경우, Model 클래스를 확인하십시오. 커스텀 모델은 이 클래스를 구현해야 WAF-A-MoLE에서 평가할 수 있습니다. 이미 sci-kit learn 및 keras 분류기를 위한 래퍼를 제공하며, 필요에 따라 특징 추출 단계에 맞게 확장할 수 있습니다.
wafamole --help
Usage: wafamole [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
evade Launch WAF-A-MoLE against a target classifier.
wafamole evade --help
Usage: wafamole evade [OPTIONS] MODEL_PATH PAYLOAD
Launch WAF-A-MoLE against a target classifier.
Options:
-T, --model-type TEXT Type of classifier to load
-t, --timeout INTEGER Timeout when evading the model
-r, --max-rounds INTEGER Maximum number of fuzzing rounds
-s, --round-size INTEGER Fuzzing step size for each round (parallel fuzzing
steps)
--threshold FLOAT Classification threshold of the target WAF [0.5]
--random-engine TEXT Use random transformations instead of evolution
engine. Set the number of trials
--output-path TEXT Location were to save the results of the random
engine. NOT USED WITH REGULAR EVOLUTION ENGINE
--help Show this message and exit.
wafamole/models/custom/example_models에 사전 훈련된 모델 몇 개를 제공하여 재미있게 실험해 볼 수 있습니다. 사용된 분류기는 아래 표에 나와 있습니다.
| 분류기 이름(Classifier name) | 알고리즘(Algorithm) |
|---|---|
| WafBrain | 순환 신경망 (Recurrent Neural Network) |
| ML-Based-WAF | 비선형 SVM (Non-Linear SVM) |
| ML-Based-WAF | 확률적 경사 하강법 (Stochastic Gradient Descent) |
| ML-Based-WAF | AdaBoost |
| 토큰 기반 (Token-based) | 나이브 베이즈 (Naive Bayes) |
| 토큰 기반 (Token-based) | 랜덤 포레스트 (Random Forest) |
| 토큰 기반 (Token-based) | 선형 SVM (Linear SVM) |
| 토큰 기반 (Token-based) | 가우시안 SVM (Gaussian SVM) |
| SQLiGoT - 방향 비례 (Directed Proportional) | 가우시안 SVM (Gaussian SVM) |
| SQLiGoT - 방향 비비례 (Directed Unproportional) | 가우시안 SVM (Gaussian SVM) |
| SQLiGoT - 무방향 비례 (Undirected Proportional) | 가우시안 SVM (Gaussian SVM) |
| SQLiGoT - 무방향 비비례 (Undirected Unproportional) | 가우시안 SVM (Gaussian SVM) |
ML 기반 WAF 외에도, WAF-A-MoLE은 규칙 기반 WAF도 지원합니다. 특히, pymodsecurity 프로젝트를 기반으로 한 OWASP Core Rule Set (CRS)이 장착된 ModSecurity WAF용 래퍼를 제공합니다.
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 WAF-Brain 분류기를 우회합니다.
wafamole evade --model-type waf-brain wafamole/models/custom/example_models/waf-brain.h5 "admin' OR 1=1#"
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 ML-Based-WAF SVM 분류기를 우회합니다.
wafamole evade --model-type mlbasedwaf wafamole/models/custom/example_models/mlbasedwaf_svc.dump "admin' OR 1=1#"
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 ML-Based-WAF SVM 분류기를 우회합니다. SQLiV5는 Kaggle에서 가져온 데이터셋에 WAF-A-MoLE 자체에서 생성된 일련의 쿼리를 확장한 것으로, WAF-A-MoLE 쿼리가 재훈련을 통해 WAF의 견고성을 향상시킬 수 있다는 개념 증명입니다. 원본 Kaggle 데이터셋(SQLiV3)으로 훈련된 WAF를 우회하려면 mlbasedwaf_svc_sqliv3.dump를 사용하십시오.
wafamole evade --model-type mlbasedwaf wafamole/models/custom/example_models/mlbasedwaf_svc_sqliv5.dump "admin' OR 1=1#"
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 ML-Based-WAF SGD 분류기를 우회합니다.
wafamole evade --model-type mlbasedwaf wafamole/models/custom/example_models/mlbasedwaf_sgd.dump "admin' OR 1=1#"
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 ML-Based-WAF AdaBoost 분류기를 우회합니다 (다른 모델보다 시간이 오래 걸리며, 약 2~5분 정도 소요).
wafamole evade --model-type mlbasedwaf wafamole/models/custom/example_models/mlbasedwaf_ada.dump "admin' OR 1=1#"
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 토큰 기반 나이브 베이즈 분류기를 우회합니다.
wafamole evade --model-type token wafamole/models/custom/example_models/naive_bayes_trained.dump "admin' OR 1=1#"
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 토큰 기반 랜덤 포레스트 분류기를 우회합니다.
wafamole evade --model-type token wafamole/models/custom/example_models/random_forest_trained.dump "admin' OR 1=1#"
admin' OR 1=1#과 동등한 쿼리를 사용하여 사전 훈련된 토큰 기반 선형 SVM 분류기를 우회합니다.
wafamole evade --model-type token wafamole/models/custom/example_models/lin_svm_trained.dump "admin' OR 1=1#"