Information Security

[Lord Of Sql injection] golem 본문

Web Hacking/Lord Of Sql injection 풀이

[Lord Of Sql injection] golem

leeeeye321 2017. 12. 25. 02:42

[Lord Of Sql injection] golem

 

if(preg_match('/or|and|substr\(|=/i'$_GET[pw])) exit("HeHe"); 

이때까지 했던대로 ' or id='admin' and length(pw)=8 %23을 injection하여 admin 패스워드의 길이를 알아내려고 했는데 preg_match()함수에 의해 or, and, =이 차단된다.

또, ' or id='admin' and ascii(substr(pw,1,1))=54 %23로 패스워드를 한 글자씩 알아내려 했는데 substr() 함수가 차단된다.

 

우회 방법은 다음과 같다.

or -> ||

and -> &&(%26%26)

 

= -> 

like 절

http://www.w3big.com/ko/mysql/mysql-like-clause.html

 

in()

MySQL IN() function finds a match in the given arguments.

ex) expr in (value,...)

The function returns 1 if expr is equal to any of the values in the IN list, otherwise, returns 0.

 

substr() -> 

mid(해당 문자열의, 어디서부터, 몇 개)

MySQL MID() extracts a substring from a string.

 

left(해당 문자열의, 왼쪽에서부터 몇 개)

MySQL LEFT() returns a specified number of characters from the left of the string.

 

right(해당 문자열의, 오른쪽에서부터 몇 개)

MySQL RIGHT() extracts a specified number of characters from the right side of a string.

https://www.w3resource.com/mysql/string-functions

 

패스워드의 길이는 8이다.

 

=은 like로, substr()은 mid()로 대체했다.

 

 

스크립트 실행 결과, 패스워드는 위와 같다.