Zaproxy에선 Context menu, passive scan, active scan 등 모든 기능 구간에 대한 기본적인 script template 코드를 제공해주고 있고, 다른 코드 참조해서 작성하면 어렵지 않습니다.
(확장기능 만드는거보다 쉬워서 계속 스크립트 적용해서 최적화하면 Burp보다 좋다고 생각됩니다. 이런면에선 정말 강점이 두드러지는듯)
Script for information leakage(feat Regex)
코드는 Javascript 코드 기준으로 진행하겠습니다. 우선 Passive scan script의 뼈대가 되는 함수는 scan() 입니다. 해당 script가 enable 되면 scan으로 ps(zap 객체인듯?), msg(request/response 데이터), src의 인자값을 받습니다.원하는 처리 로직대로 코드 작성해주시고, ps의 raiseAlert 메소드를 통해 ZAP의 Alert 부분으로 데이터를 넘겨줄 수 있습니다.
function scan(ps, msg, src) {
url = msg.getRequestHeader().getURI().toString(); // msg에서 url 데이터 가져옴
alertRisk = 2
alertReliability = 2
alertTitle = "script 이름"
alertDesc = "취약점 내용"
alertSolution = "대응방안"
cweId = 0
wascId = 0
re = /REGEX!/g // 적용할 정규식 룰!
contenttype = msg.getResponseHeader().getHeader("Content-Type")
unwantedfiletypes = ['image/png', 'image/jpeg','image/gif','application/x-shockwave-flash'] // Media 계열들 무시
if (unwantedfiletypes.indexOf(""+contenttype) >= 0) {
//
return
}else{
body = msg.getResponseBody().toString()
if (re.test(body)) { // 정규식 테스트
re.lastIndex = 0 // After testing reset index
var your_data = []
while (comm = re.exec(body)) {
your_data.push(comm[0]);
}
ps.raiseAlert(alertRisk, alertReliability, alertTitle, alertDesc, url, '', '', your_data.toString(), alertSolution, '', cweId, wascId, msg); // Alert에 등록
// 각각 모두 Alert 페이지에 나타나는 항목들입니다.
}
}
}
이 코드를 Enable 시키면 Response 데이터에서 정규식으로 원하는 문자열이 있는 경우에 Alert 쪽으로 넘겨주게 됩니다. 우선 뼈대는 있기 떄문에 로직만 넣어주면 쉽게쉽게 원하는 기능을 만들 수 있습니다.
혹시라도 재미있는 아이디어 있다면 댓글, 메일 등 남겨주세요 :)
(이미 회사에서 여러가지 적용하고 있지만..ㅋㅋㅋ)
![]() |
HAHWULSecurity engineer, Gopher and H4cker! |
0 개의 댓글:
Post a Comment