tcpdump란?
tcpdump는 리눅스/유닉스 OS에서 네트워크 패킷을 캡처하고 분석하는 도구입니다.
tcpdump 기본 옵션
| 옵션 | 설명 |
|---|---|
| -t | 타임스탬프를 출력하지 않음 |
| -tt | Unix Epoch(1970-01-01 00:00:00 UTC 기준) 형식의 타임스탬프 출력 |
| -ttt | 이전 패킷과의 시간 차이(Delta Time) 출력 |
| -tttt | 사람이 읽기 쉬운 날짜와 시각 출력 |
| -r (file_name) | PCAP 파일 읽기 |
| -w (file_name) | 캡처한 패킷을 PCAP 파일로 저장 |
| -i (interface) | 캡처할 네트워크 인터페이스 지정 (예: enp0s3) |
| -n | 주소를 이름으로 변환하지 않고 숫자로 출력 |
| -nn | 주소와 포트 번호를 모두 숫자로 출력 |
| -v | 자세한 정보 출력 |
| -vv | 더 자세한 정보 출력 |
| —count | 패킷을 출력하지 않고 필터와 일치한 패킷 수 출력 |
| -c (count) | 지정한 개수의 패킷을 수신하면 종료 |
| -A | 패킷 페이로드를 ASCII로 출력 |
| 논리식 | 기호 |
|---|---|
| or | || |
| and | && |
| not | ! |
PCAP 파일 생성
sudo tcpdump -i enp0s3 -n -w ~/Desktop/02_Network_Security/01_tcpdump/capture.pcapPCAP 파일 읽기
tcpdump -n -r ~/Desktop/02_Network_Security/01_tcpdump/capture.pcaptcpdump -r capture.pcap
tcpdump -r capture.pcap --countChallenge 문제 풀이
문제 01. How many total packets are in the tcpdump_challenge.pcap packet capture?
tcpdump -r [file_name] --count- 1344 packets
문제 02. How many ICMP packets are in the tcpdump_challenge.pcap packet capture?
tcpdump -r [file_name] -nn icmp --count- 132 packets
문제 03. What is the ASN of the destination IP address that the endpoint was pinging?
tcpdump -r [file_name] -nn 'icmp[icmptype] = icmp-echo'목적지 IP 주소를 확인한 뒤 Hurricane Electric BGP Toolkit에서 ASN을 조회한다.
- AS13335
문제 04. How many HTTP POST requests were made in the packet capture?
tcpdump -A -r [file_name] -nn 'tcp port 80' | grep -c 'POST'- 1
문제 05. Look for any credentials within the payloads of any HTTP packets, what is the password you uncover?
tcpdump -A -r [file_name] -nn 'tcp port 80' | grep -i -A 8 -E 'username|password'- password
문제 06. Aside from HTTP on port 80, what is the other most frequent well-known destination port number?
tcpdump -tt -nn -r [file_name] tcp \
| awk '{print $5}' \
| cut -d "." -f 5 \
| tr -d ":" \
| sort | uniq -c | sort -nr- TCP/21 (FTP)
문제 07. What set of valid credentials did the endpoint use to access the file sharing server? (Format username:password)
tcpdump -A -r [file_name] -nn 'tcp port 21' | grep -E 'USER|PASS'- demo:password
문제 08. What is the name of the file that was retrieved from the file sharing server?
tcpdump -A -r [file_name] -nn 'tcp port 21' | grep -E 'RETR|STOR'- readme.txt
문제 09. Based on the unique User-Agent string found within the HTTP requests, what is the name of the related malware the endpoint might be infected with?
tcpdump -A -r [file_name] -nn 'tcp port 80' | grep -i -A 20 'User-Agent'Tesla User-Agent를 인터넷에 검색하면 Lumma Info Stealer라는 악성코드와 연결되어 있다는 것을 알 수 있다.
- Lumma Info Stealer
문제 10. In defanged format, what was the full URL that the endpoint tried to connect to using the user agent identified above?
tcpdump -A -r [file_name] -nn 'tcp port 80' | grep -i -A 20 'User-Agent: Tesla'- hxxp://t[.]me/+zz0192lskaaa
문제 11. What is the full title of the YouTube video that the user requested?
tcpdump -A -r [file_name] -nn 'tcp port 80' | grep -i -A 20 'youtube'- Rick Astley - Never Gonna Give You Up (Official Music Video)