Linux Server Forensics. Before Starting The Linux Server - by Saniye Nur - Medium
Linux Server Forensics. Before Starting The Linux Server - by Saniye Nur - Medium
Here we will try to see potential web attacks by making inferences from both
analysis in Linux and related web design.
The most important attack surface on the server is probably the web service;
fortunately, the Apache access log keeps a history of all requests sent to the
web server and includes:
1- source address
2- response code and length
3- user agent
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 1/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
The /var/log directory is always the first place I look when reviewing. For the
subject I mentioned above, I go directly under the apache logs.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 2/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
Access logs of course draw attention and I check. There is a lot of data, I
need to do some customization.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 3/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 4/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 5/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
Now the interface of the web is as follows. For example, here I can easily
find which directory will allow the user to upload files.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 6/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
If I look at the GET and POST requests in the access logs, I can see the IP
addresses. Along with the response codes.
Among these requests, I can go to every directory that attracts my attention,
or I can look at it from the terminal. One of the points that caught my
attention was the security.md file under resources/development/2021/docs/
and when I opened it and looked at it,
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 7/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 8/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
1- cron
2- services/systemd
3- bashrc
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 9/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
4- Kernel modules
5- SSH keys
You know their locations by heart because you are constantly struggling, but
you don’t always have to know them by heart, of course, and you can find the
path and directory in linux with the locate command directly.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 10/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
64
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 11/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 12/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
As I said, you can tamper with the directory you want as much as you want.
The reason why I always say this is because linux systems are managed as
command line (there are customized ones), anomalies on the system cannot
be understood as easily as in Windows.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 13/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
The root2 user also catches my attention and I’m starting to look at the
following locations, which are one of the few places in linux where account
information is kept.
1- /etc/passwd — contains the names of most of the accounts on the system.
It should only have read privileges and do not contain password hashes.
2- /etc/shadow — contains names but must also contain password hashes.
Must have strict permissions.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 14/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
There could also be more data in /etc/passwd, my goal is to find root2 I said
with grep just get the root2 hash and now I’m going to use hash-identifier to
find out what hash it is.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 15/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 16/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
We cracked it with the john tool and found the second root account.
Now we are in the apache log analysis. The log files are smaller this time, we
can say that the attacker is a little cunning.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 17/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
Now let’s look at the apache access logs on the following server again and
you will understand what I mean.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 18/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
I’m still looking for IP 192.168.56,206 because this absurd HTTP request
confused me. “\x16\x03” 400 0 “-” “-” indicates nmap.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 19/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
If there are any backdoors, SSH keys will show me that, it’s another excellent
way to protect access, so additions to the authorized_keys file might be
worth looking into.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 20/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 21/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
Right guess.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 22/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
systemd services also keep logs in the log system; these logs are kept in
binary format and must be read by a utility like Journalctl. This binary
format comes with some advantages; however, each journal is capable of
self-verification and is more difficult to change.
3. Optional description
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 23/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
OS Version Information
cat /etc/os-relase
User Accounts
Group Information
cat /etc/group
Login Information
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 24/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
Hostname:
cat /etc/hostname
TimeZone
cat /etc/timezone
Network Configuration
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 25/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
netstat -natp
ps aux
DNS Information
cat /etc/hosts
cat /etc/resolv.conf
Started Services
ls /etc/init.d/
Syslog
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 26/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
Auth Log
We have touched on the linux forensics side superficially. In the next article,
we will look at Linux Forensic in depth.
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 27/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 28/29
17/1/23, 08:03 Linux Server Forensics. Before starting the Linux Server… | by Saniye Nur | Medium
https://snynr.medium.com/linux-server-forensics-d23ab0a20127 29/29