hacktricks/forensics/basic-forensic-methodology/linux-forensics.md

440 lines
24 KiB
Markdown
Raw Normal View History

# Linux Forensics
2022-04-28 16:01:33 +00:00
<figure><img src="../../.gitbook/assets/image (3) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
2022-08-31 22:35:39 +00:00
\
Tumia [**Trickest**](https://trickest.com/?utm\_campaign=hacktrics\&utm\_medium=banner\&utm\_source=hacktricks) kujenga na **kujiendesha** kwa urahisi kazi zinazotumiwa na zana za jamii **zilizoendelea zaidi** duniani.\
2024-02-11 02:13:58 +00:00
Pata Ufikiaji Leo:
2022-08-31 22:35:39 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
{% hint style="success" %}
Jifunze na fanya mazoezi ya AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Jifunze na fanya mazoezi ya GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
<details>
2022-04-28 16:01:33 +00:00
<summary>Support HackTricks</summary>
2023-12-30 10:12:47 +00:00
* Angalia [**mpango wa usajili**](https://github.com/sponsors/carlospolop)!
* **Jiunge na** 💬 [**kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuatilie** kwenye **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Shiriki mbinu za hacking kwa kuwasilisha PRs kwa** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>
{% endhint %}
2022-04-28 16:01:33 +00:00
## Mkusanyiko wa Taarifa za Awali
2020-12-25 10:22:35 +00:00
### Taarifa za Msingi
2020-12-25 10:22:35 +00:00
Kwanza kabisa, inapendekezwa kuwa na **USB** yenye **binaries na maktaba zinazojulikana vizuri** (unaweza tu kupata ubuntu na nakala za folda _/bin_, _/sbin_, _/lib,_ na _/lib64_), kisha unganisha USB, na badilisha mabadiliko ya mazingira ili kutumia hizo binaries:
2020-12-25 10:22:35 +00:00
```bash
export PATH=/mnt/usb/bin:/mnt/usb/sbin
export LD_LIBRARY_PATH=/mnt/usb/lib:/mnt/usb/lib64
```
Mara tu umepanga mfumo kutumia binaries nzuri na zinazojulikana unaweza kuanza **kuchota taarifa za msingi**:
2020-12-25 10:22:35 +00:00
```bash
2022-09-07 15:35:57 +00:00
date #Date and time (Clock may be skewed, Might be at a different timezone)
2020-12-25 10:22:35 +00:00
uname -a #OS info
2022-09-07 15:35:57 +00:00
ifconfig -a || ip a #Network interfaces (promiscuous mode?)
2020-12-25 10:22:35 +00:00
ps -ef #Running processes
netstat -anp #Proccess and ports
lsof -V #Open files
netstat -rn; route #Routing table
df; mount #Free space and mounted devices
2020-12-25 22:35:08 +00:00
free #Meam and swap space
2020-12-25 10:22:35 +00:00
w #Who is connected
2020-12-26 23:48:55 +00:00
last -Faiwx #Logins
2020-12-25 10:22:35 +00:00
lsmod #What is loaded
cat /etc/passwd #Unexpected data?
cat /etc/shadow #Unexpected data?
2020-12-25 22:35:08 +00:00
find /directory -type f -mtime -1 -print #Find modified files during the last minute in the directory
2020-12-25 10:22:35 +00:00
```
#### Taarifa za kushangaza
2020-12-25 10:22:35 +00:00
Wakati unapata taarifa za msingi unapaswa kuangalia mambo ya ajabu kama:
2020-12-25 22:25:37 +00:00
* **Mchakato wa Root** kawaida huendesha na PIDS za chini, hivyo ikiwa utapata mchakato wa root wenye PID kubwa unaweza kushuku
* Angalia **kuingia kwa watumiaji** waliojiandikisha bila shell ndani ya `/etc/passwd`
* Angalia **hash za nywila** ndani ya `/etc/shadow` kwa watumiaji bila shell
2020-12-25 22:25:37 +00:00
### Dump ya Kumbukumbu
2020-12-25 20:14:31 +00:00
Ili kupata kumbukumbu ya mfumo unaoendesha, inashauriwa kutumia [**LiME**](https://github.com/504ensicsLabs/LiME).\
Ili **kuunda** hiyo, unahitaji kutumia **kernel sawa** ambayo mashine ya mwathirika inatumia.
2020-12-25 20:14:31 +00:00
{% hint style="info" %}
Kumbuka kwamba huwezi **kufunga LiME au kitu kingine chochote** kwenye mashine ya mwathirika kwani itafanya mabadiliko kadhaa
2020-12-25 20:14:31 +00:00
{% endhint %}
Hivyo, ikiwa una toleo sawa la Ubuntu unaweza kutumia `apt-get install lime-forensics-dkms`\
Katika hali nyingine, unahitaji kupakua [**LiME**](https://github.com/504ensicsLabs/LiME) kutoka github na kuunda hiyo kwa kutumia vichwa sahihi vya kernel. Ili **kupata vichwa sahihi vya kernel** vya mashine ya mwathirika, unaweza tu **kunakili saraka** `/lib/modules/<kernel version>` kwenye mashine yako, na kisha **kuunda** LiME kwa kutumia hizo:
2020-12-25 20:14:31 +00:00
```bash
make -C /lib/modules/<kernel version>/build M=$PWD
sudo insmod lime.ko "path=/home/sansforensics/Desktop/mem_dump.bin format=lime"
```
LiME inasaidia **format** 3:
2020-12-25 20:14:31 +00:00
* Raw (sehemu zote zimeunganishwa pamoja)
* Padded (sawa na raw, lakini na sifuri katika bits za kulia)
* Lime (format inayopendekezwa yenye metadata)
2020-12-25 20:14:31 +00:00
LiME pia inaweza kutumika **kutuma dump kupitia mtandao** badala ya kuihifadhi kwenye mfumo kwa kutumia kitu kama: `path=tcp:4444`
2020-12-25 20:14:31 +00:00
### Disk Imaging
2020-12-25 21:41:10 +00:00
2024-02-11 02:13:58 +00:00
#### Kuzima
2020-12-25 22:03:49 +00:00
Kwanza kabisa, utahitaji **kuzima mfumo**. Hii si chaguo kila wakati kwani wakati mwingine mfumo utakuwa seva ya uzalishaji ambayo kampuni haiwezi kumudu kuzima.\
Kuna **njia 2** za kuzima mfumo, **kuzima kawaida** na **"kuvuta plug" kuzima**. Ya kwanza itaruhusu **mchakato kumalizika kama kawaida** na **filesystem** kuwa **synchronized**, lakini pia itaruhusu **malware** inayoweza **kuharibu ushahidi**. Njia ya "kuvuta plug" inaweza kuleta **kupoteza taarifa** (sio nyingi za taarifa zitapotea kwani tayari tumepata picha ya kumbukumbu) na **malware haitakuwa na fursa yoyote** ya kufanya chochote kuhusu hilo. Hivyo, ikiwa unahisi kuwa kuna **malware**, tekeleza tu **amri ya `sync`** kwenye mfumo na uvute plug.
2020-12-25 22:03:49 +00:00
#### Kuchukua picha ya diski
2020-12-25 22:20:35 +00:00
Ni muhimu kutambua kwamba **kabla ya kuunganisha kompyuta yako na chochote kinachohusiana na kesi**, unahitaji kuwa na uhakika kwamba itakuwa **imewekwa kama kusoma tu** ili kuepuka kubadilisha taarifa yoyote.
2020-12-25 22:03:49 +00:00
```bash
#Create a raw copy of the disk
dd if=<subject device> of=<image file> bs=512
2022-09-07 15:35:57 +00:00
#Raw copy with hashes along the way (more secure as it checks hashes while it's copying the data)
2020-12-25 22:08:05 +00:00
dcfldd if=<subject device> of=<image file> bs=512 hash=<algorithm> hashwindow=<chunk size> hashlog=<hash file>
2020-12-25 22:21:23 +00:00
dcfldd if=/dev/sdc of=/media/usb/pc.image hash=sha256 hashwindow=1M hashlog=/media/usb/pc.hashes
2020-12-25 22:03:49 +00:00
```
### Disk Image pre-analysis
2020-12-25 22:03:49 +00:00
Kuchora picha ya diski bila data zaidi.
2021-01-05 13:06:39 +00:00
```bash
2022-09-07 15:35:57 +00:00
#Find out if it's a disk image using "file" command
2024-02-11 02:13:58 +00:00
file disk.img
2021-01-05 13:06:39 +00:00
disk.img: Linux rev 1.0 ext4 filesystem data, UUID=59e7a736-9c90-4fab-ae35-1d6a28e5de27 (extents) (64bit) (large files) (huge files)
#Check which type of disk image it's
2024-02-11 02:13:58 +00:00
img_stat -t evidence.img
2021-01-05 13:06:39 +00:00
raw
#You can list supported types with
img_stat -i list
Supported image format types:
2024-02-11 02:13:58 +00:00
raw (Single or split raw file (dd))
aff (Advanced Forensic Format)
afd (AFF Multiple File)
afm (AFF with external metadata)
afflib (All AFFLIB image formats (including beta ones))
ewf (Expert Witness Format (EnCase))
2021-01-05 13:06:39 +00:00
#Data of the image
2024-02-11 02:13:58 +00:00
fsstat -i raw -f ext4 disk.img
2021-01-05 13:06:39 +00:00
FILE SYSTEM INFORMATION
--------------------------------------------
File System Type: Ext4
2024-02-11 02:13:58 +00:00
Volume Name:
2021-01-05 13:06:39 +00:00
Volume ID: 162850f203fd75afab4f1e4736a7e776
Last Written at: 2020-02-06 06:22:48 (UTC)
Last Checked at: 2020-02-06 06:15:09 (UTC)
Last Mounted at: 2020-02-06 06:15:18 (UTC)
Unmounted properly
Last mounted on: /mnt/disk0
Source OS: Linux
[...]
#ls inside the image
fls -i raw -f ext4 disk.img
d/d 11: lost+found
d/d 12: Documents
d/d 8193: folder1
d/d 8194: folder2
V/V 65537: $OrphanFiles
#ls inside folder
fls -i raw -f ext4 disk.img 12
r/r 16: secret.txt
#cat file inside image
icat -i raw -f ext4 disk.img 16
ThisisTheMasterSecret
```
<figure><img src="../../.gitbook/assets/image (3) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
2022-08-31 22:35:39 +00:00
\
Tumia [**Trickest**](https://trickest.com/?utm\_campaign=hacktrics\&utm\_medium=banner\&utm\_source=hacktricks) kujenga na **kujiendesha** kwa urahisi kazi zinazotolewa na zana za jamii **zilizoendelea zaidi** duniani.\
2024-02-11 02:13:58 +00:00
Pata Ufikiaji Leo:
2022-08-31 22:35:39 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
## Tafuta Malware inayojulikana
2020-12-23 19:52:25 +00:00
### Faili za Mfumo zilizobadilishwa
2020-12-23 19:52:25 +00:00
Linux inatoa zana za kuhakikisha uaminifu wa vipengele vya mfumo, muhimu kwa kugundua faili zinazoweza kuwa na matatizo.
2020-12-23 19:52:25 +00:00
* **Mifumo ya RedHat**: Tumia `rpm -Va` kwa ukaguzi wa kina.
* **Mifumo ya Debian**: `dpkg --verify` kwa uthibitisho wa awali, ikifuatiwa na `debsums | grep -v "OK$"` (baada ya kufunga `debsums` kwa `apt-get install debsums`) ili kubaini matatizo yoyote.
2020-12-23 19:52:25 +00:00
### Vifaa vya Kugundua Malware/Rootkit
2020-12-23 19:52:25 +00:00
Soma ukurasa ufuatao kujifunza kuhusu zana ambazo zinaweza kuwa na manufaa katika kutafuta malware:
2020-12-23 19:52:25 +00:00
{% content-ref url="malware-analysis.md" %}
[malware-analysis.md](malware-analysis.md)
{% endcontent-ref %}
2020-12-23 19:52:25 +00:00
## Tafuta programu zilizowekwa
2020-12-23 19:52:25 +00:00
Ili kutafuta kwa ufanisi programu zilizowekwa kwenye mifumo ya Debian na RedHat, fikiria kutumia kumbukumbu za mfumo na hifadhidata pamoja na ukaguzi wa mikono katika directories za kawaida.
2020-12-23 19:52:25 +00:00
* Kwa Debian, angalia _**`/var/lib/dpkg/status`**_ na _**`/var/log/dpkg.log`**_ kupata maelezo kuhusu usakinishaji wa pakiti, ukitumia `grep` kuchuja taarifa maalum.
* Watumiaji wa RedHat wanaweza kuuliza hifadhidata ya RPM kwa `rpm -qa --root=/mntpath/var/lib/rpm` ili orodhesha pakiti zilizowekwa.
2020-12-23 19:52:25 +00:00
Ili kugundua programu zilizowekwa kwa mikono au nje ya wasimamizi hawa wa pakiti, chunguza directories kama _**`/usr/local`**_, _**`/opt`**_, _**`/usr/sbin`**_, _**`/usr/bin`**_, _**`/bin`**_, na _**`/sbin`**_. Changanya orodha za directories na amri maalum za mfumo ili kubaini executable zisizohusishwa na pakiti zinazojulikana, kuboresha utafutaji wako wa programu zote zilizowekwa.
2020-12-23 19:52:25 +00:00
```bash
2024-02-07 04:05:50 +00:00
# Debian package and log details
cat /var/lib/dpkg/status | grep -E "Package:|Status:"
cat /var/log/dpkg.log | grep installed
# RedHat RPM database query
rpm -qa --root=/mntpath/var/lib/rpm
# Listing directories for manual installations
ls /usr/sbin /usr/bin /bin /sbin
# Identifying non-package executables (Debian)
2020-12-23 19:52:25 +00:00
find /sbin/ -exec dpkg -S {} \; | grep "no path found"
2024-02-07 04:05:50 +00:00
# Identifying non-package executables (RedHat)
2020-12-23 19:52:25 +00:00
find /sbin/ exec rpm -qf {} \; | grep "is not"
2024-02-07 04:05:50 +00:00
# Find exacuable files
find / -type f -executable | grep <something>
2020-12-23 19:52:25 +00:00
```
<figure><img src="../../.gitbook/assets/image (3) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
2022-08-31 22:35:39 +00:00
\
Tumia [**Trickest**](https://trickest.com/?utm\_campaign=hacktrics\&utm\_medium=banner\&utm\_source=hacktricks) kujenga na **kujiendesha kiotomatiki** kazi kwa urahisi zinazotolewa na zana za jamii **zilizoendelea zaidi** duniani.\
2024-02-11 02:13:58 +00:00
Pata Ufikiaji Leo:
2022-08-31 22:35:39 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
## Rejesha Binaries Zilizofutwa Zinazoendesha
2024-02-07 04:05:50 +00:00
Fikiria mchakato uliofanywa kutoka /tmp/exec na kisha kufutwa. Inawezekana kuutoa
2024-02-07 04:05:50 +00:00
```bash
cd /proc/3746/ #PID with the exec file deleted
head -1 maps #Get address of the file. It was 08048000-08049000
dd if=mem bs=1 skip=08048000 count=1000 of=/tmp/exec2 #Recorver it
```
## Kagua maeneo ya Autostart
2024-02-11 02:13:58 +00:00
### Kazi za Ratiba
2020-12-23 20:08:45 +00:00
```bash
cat /var/spool/cron/crontabs/* \
/var/spool/cron/atjobs \
/var/spool/anacron \
/etc/cron* \
/etc/at* \
/etc/anacrontab \
/etc/incron.d/* \
/var/spool/incron/* \
#MacOS
ls -l /usr/lib/cron/tabs/ /Library/LaunchAgents/ /Library/LaunchDaemons/ ~/Library/LaunchAgents/
```
### Services
2020-12-23 20:08:45 +00:00
Njia ambapo malware inaweza kuwekwa kama huduma:
2024-02-07 04:05:50 +00:00
* **/etc/inittab**: Inaita skripti za awali kama rc.sysinit, ikielekeza zaidi kwa skripti za kuanzisha.
* **/etc/rc.d/** na **/etc/rc.boot/**: Zina skripti za kuanzisha huduma, ya pili ikipatikana katika matoleo ya zamani ya Linux.
* **/etc/init.d/**: Inatumika katika matoleo fulani ya Linux kama Debian kwa kuhifadhi skripti za kuanzisha.
* Huduma zinaweza pia kuanzishwa kupitia **/etc/inetd.conf** au **/etc/xinetd/**, kulingana na toleo la Linux.
* **/etc/systemd/system**: Katalogi ya skripti za meneja wa mfumo na huduma.
* **/etc/systemd/system/multi-user.target.wants/**: Inashikilia viungo kwa huduma ambazo zinapaswa kuanzishwa katika kiwango cha kuendesha watumiaji wengi.
* **/usr/local/etc/rc.d/**: Kwa huduma za kawaida au za wahusika wengine.
* **\~/.config/autostart/**: Kwa programu za kuanzisha kiotomatiki maalum kwa mtumiaji, ambazo zinaweza kuwa mahali pa kuficha malware inayolenga watumiaji.
* **/lib/systemd/system/**: Faili za kitengo za kawaida za mfumo zinazotolewa na pakiti zilizowekwa.
2020-12-23 20:08:45 +00:00
### Kernel Modules
2020-12-23 22:44:17 +00:00
Moduli za kernel za Linux, mara nyingi hutumiwa na malware kama sehemu za rootkit, zinawekwa wakati wa kuanzisha mfumo. Katalogi na faili muhimu kwa moduli hizi ni pamoja na:
2020-12-23 22:44:17 +00:00
* **/lib/modules/$(uname -r)**: Inashikilia moduli za toleo la kernel linalotumika.
* **/etc/modprobe.d**: Inashikilia faili za usanidi kudhibiti upakiaji wa moduli.
* **/etc/modprobe** na **/etc/modprobe.conf**: Faili za mipangilio ya kimataifa ya moduli.
2024-02-07 04:05:50 +00:00
### Other Autostart Locations
2020-12-23 22:44:17 +00:00
Linux inatumia faili mbalimbali kwa kutekeleza programu kiotomatiki wakati wa kuingia kwa mtumiaji, ambayo inaweza kuwa na malware:
2020-12-23 22:44:17 +00:00
* **/etc/profile.d/**\*, **/etc/profile**, na **/etc/bash.bashrc**: Zinatekelezwa kwa kuingia kwa mtumiaji yeyote.
* **\~/.bashrc**, **\~/.bash\_profile**, **\~/.profile**, na **\~/.config/autostart**: Faili maalum za mtumiaji zinazotekelezwa wakati wa kuingia kwao.
* **/etc/rc.local**: Inatekelezwa baada ya huduma zote za mfumo kuanzishwa, ikionyesha mwisho wa mpito kwenda mazingira ya watumiaji wengi.
2020-12-23 22:44:17 +00:00
## Examine Logs
2020-12-23 22:44:17 +00:00
Mifumo ya Linux inafuatilia shughuli za watumiaji na matukio ya mfumo kupitia faili mbalimbali za kumbukumbu. Kumbukumbu hizi ni muhimu kwa kutambua ufikiaji usioidhinishwa, maambukizi ya malware, na matukio mengine ya usalama. Faili muhimu za kumbukumbu ni pamoja na:
2020-12-23 22:44:17 +00:00
* **/var/log/syslog** (Debian) au **/var/log/messages** (RedHat): Huhifadhi ujumbe na shughuli za mfumo mzima.
* **/var/log/auth.log** (Debian) au **/var/log/secure** (RedHat): Huhifadhi majaribio ya uthibitishaji, kuingia kwa mafanikio na yasiyofanikiwa.
* Tumia `grep -iE "session opened for|accepted password|new session|not in sudoers" /var/log/auth.log` kuchuja matukio muhimu ya uthibitishaji.
* **/var/log/boot.log**: Inashikilia ujumbe wa kuanzisha mfumo.
* **/var/log/maillog** au **/var/log/mail.log**: Huhifadhi shughuli za seva ya barua pepe, muhimu kwa kufuatilia huduma zinazohusiana na barua pepe.
* **/var/log/kern.log**: Huhifadhi ujumbe wa kernel, ikiwa ni pamoja na makosa na onyo.
* **/var/log/dmesg**: Inashikilia ujumbe wa madereva ya vifaa.
* **/var/log/faillog**: Huhifadhi majaribio ya kuingia yasiyofanikiwa, kusaidia katika uchunguzi wa uvunjaji wa usalama.
* **/var/log/cron**: Huhifadhi utekelezaji wa kazi za cron.
* **/var/log/daemon.log**: Inafuatilia shughuli za huduma za nyuma.
* **/var/log/btmp**: Huhifadhi majaribio ya kuingia yasiyofanikiwa.
* **/var/log/httpd/**: Inashikilia kumbukumbu za makosa na ufikiaji wa Apache HTTPD.
* **/var/log/mysqld.log** au **/var/log/mysql.log**: Huhifadhi shughuli za hifadhidata ya MySQL.
* **/var/log/xferlog**: Huhifadhi uhamishaji wa faili za FTP.
* **/var/log/**: Daima angalia kumbukumbu zisizotarajiwa hapa.
2020-12-23 22:44:17 +00:00
{% hint style="info" %}
Kumbukumbu za mifumo ya Linux na mifumo ya ukaguzi zinaweza kuzuiwa au kufutwa katika uvamizi au tukio la malware. Kwa sababu kumbukumbu kwenye mifumo ya Linux kwa ujumla zina taarifa muhimu zaidi kuhusu shughuli mbaya, wavamizi mara nyingi huzifuta. Hivyo, wakati wa kuchunguza faili za kumbukumbu zilizopo, ni muhimu kutafuta mapengo au kuingia zisizo za kawaida ambazo zinaweza kuwa dalili za kufutwa au kuingilia.
2020-12-23 22:44:17 +00:00
{% endhint %}
2024-02-11 02:13:58 +00:00
**Linux inahifadhi historia ya amri kwa kila mtumiaji**, iliyohifadhiwa katika:
2020-12-23 22:44:17 +00:00
* \~/.bash\_history
* \~/.zsh\_history
* \~/.zsh\_sessions/\*
* \~/.python\_history
* \~/.\*\_history
2020-12-27 00:27:13 +00:00
Zaidi ya hayo, amri ya `last -Faiwx` inatoa orodha ya kuingia kwa watumiaji. Angalia kwa kuingia zisizojulikana au zisizotarajiwa.
2020-12-27 00:27:13 +00:00
Angalia faili ambazo zinaweza kutoa rprivileges za ziada:
2020-12-27 00:27:13 +00:00
* Kagua `/etc/sudoers` kwa haki za mtumiaji zisizotarajiwa ambazo zinaweza kuwa zimetolewa.
* Kagua `/etc/sudoers.d/` kwa haki za mtumiaji zisizotarajiwa ambazo zinaweza kuwa zimetolewa.
* Chunguza `/etc/groups` ili kubaini uanachama wa vikundi au ruhusa zisizo za kawaida.
* Chunguza `/etc/passwd` ili kubaini uanachama wa vikundi au ruhusa zisizo za kawaida.
2020-12-27 00:28:02 +00:00
Baadhi ya programu pia zinaweza kuunda kumbukumbu zake:
2020-12-23 23:14:22 +00:00
* **SSH**: Chunguza _\~/.ssh/authorized\_keys_ na _\~/.ssh/known\_hosts_ kwa uhusiano wa mbali usioidhinishwa.
* **Gnome Desktop**: Angalia _\~/.recently-used.xbel_ kwa faili zilizofikiwa hivi karibuni kupitia programu za Gnome.
* **Firefox/Chrome**: Kagua historia ya kivinjari na upakuaji katika _\~/.mozilla/firefox_ au _\~/.config/google-chrome_ kwa shughuli za kushangaza.
* **VIM**: Kagua _\~/.viminfo_ kwa maelezo ya matumizi, kama vile njia za faili zilizofikiwa na historia ya utafutaji.
* **Open Office**: Angalia ufikiaji wa hati za hivi karibuni ambazo zinaweza kuashiria faili zilizovunjwa.
* **FTP/SFTP**: Kagua kumbukumbu katika _\~/.ftp\_history_ au _\~/.sftp\_history_ kwa uhamishaji wa faili ambao unaweza kuwa haujaidhinishwa.
* **MySQL**: Chunguza _\~/.mysql\_history_ kwa maswali ya MySQL yaliyotekelezwa, ambayo yanaweza kufichua shughuli zisizoidhinishwa za hifadhidata.
* **Less**: Changanua _\~/.lesshst_ kwa historia ya matumizi, ikiwa ni pamoja na faili zilizotazamwa na amri zilizotekelezwa.
* **Git**: Chunguza _\~/.gitconfig_ na mradi _.git/logs_ kwa mabadiliko ya hifadhidata.
2021-05-28 17:27:17 +00:00
### USB Logs
2021-05-28 17:27:17 +00:00
[**usbrip**](https://github.com/snovvcrash/usbrip) ni kipande kidogo cha programu kilichoandikwa kwa Python 3 safi ambacho kinachambua faili za kumbukumbu za Linux (`/var/log/syslog*` au `/var/log/messages*` kulingana na distro) kwa ajili ya kujenga meza za historia ya matukio ya USB.
2021-05-28 17:27:17 +00:00
Ni muhimu **kujua USB zote ambazo zimekuwa zikitumika** na itakuwa na manufaa zaidi ikiwa una orodha iliyoidhinishwa ya USB ili kupata "matukio ya ukiukaji" (matumizi ya USB ambazo ziko nje ya orodha hiyo).
2021-05-28 17:27:17 +00:00
### Installation
2024-02-07 04:05:50 +00:00
```bash
2021-05-28 17:27:17 +00:00
pip3 install usbrip
2022-09-07 15:35:57 +00:00
usbrip ids download #Download USB ID database
2021-05-28 17:27:17 +00:00
```
2024-02-11 02:13:58 +00:00
### Mifano
2024-02-07 04:05:50 +00:00
```bash
2021-05-28 17:27:17 +00:00
usbrip events history #Get USB history of your curent linux machine
usbrip events history --pid 0002 --vid 0e0f --user kali #Search by pid OR vid OR user
#Search for vid and/or pid
usbrip ids download #Downlaod database
usbrip ids search --pid 0002 --vid 0e0f #Search for pid AND vid
```
More examples and info inside the github: [https://github.com/snovvcrash/usbrip](https://github.com/snovvcrash/usbrip)
2024-02-07 04:05:50 +00:00
<figure><img src="../../.gitbook/assets/image (3) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
2022-08-31 22:35:39 +00:00
\
Use [**Trickest**](https://trickest.com/?utm\_campaign=hacktrics\&utm\_medium=banner\&utm\_source=hacktricks) to easily build and **automate workflows** powered by the world's **most advanced** community tools.\
Get Access Today:
2022-08-31 22:35:39 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
## Review User Accounts and Logon Activities
2024-02-07 04:05:50 +00:00
Chunguza _**/etc/passwd**_, _**/etc/shadow**_ na **logs za usalama** kwa majina yasiyo ya kawaida au akaunti zilizoundwa na au kutumika karibu na matukio yasiyoidhinishwa yanayojulikana. Pia, angalia mashambulizi ya sudo brute-force yanayowezekana.\
Zaidi ya hayo, angalia faili kama _**/etc/sudoers**_ na _**/etc/groups**_ kwa ruhusa zisizotarajiwa zilizotolewa kwa watumiaji.\
Hatimaye, tafuta akaunti zenye **hakuna nywila** au **nywila zinazoweza kukisiwa kwa urahisi**.
2024-02-07 04:05:50 +00:00
## Examine File System
2020-12-23 23:14:22 +00:00
### Analyzing File System Structures in Malware Investigation
2020-12-23 23:14:22 +00:00
Wakati wa kuchunguza matukio ya malware, muundo wa mfumo wa faili ni chanzo muhimu cha habari, ukifunua mfululizo wa matukio na maudhui ya malware. Hata hivyo, waandishi wa malware wanatengeneza mbinu za kuzuia uchambuzi huu, kama vile kubadilisha alama za muda za faili au kuepuka mfumo wa faili kwa ajili ya uhifadhi wa data.
2024-02-07 04:05:50 +00:00
Ili kupambana na mbinu hizi za anti-forensic, ni muhimu:
2024-02-07 04:05:50 +00:00
* **Fanya uchambuzi wa kina wa muda** ukitumia zana kama **Autopsy** kwa ajili ya kuonyesha mfululizo wa matukio au **Sleuth Kit's** `mactime` kwa data ya kina ya muda.
* **Chunguza scripts zisizotarajiwa** katika $PATH ya mfumo, ambazo zinaweza kujumuisha scripts za shell au PHP zinazotumiwa na washambuliaji.
* **Chunguza `/dev` kwa faili zisizo za kawaida**, kwani kawaida ina faili maalum, lakini inaweza kuwa na faili zinazohusiana na malware.
* **Tafuta faili au directories zilizofichwa** zikiwa na majina kama ".. " (dot dot space) au "..^G" (dot dot control-G), ambazo zinaweza kuficha maudhui mabaya.
* **Tambua faili za setuid root** ukitumia amri: `find / -user root -perm -04000 -print` Hii inapata faili zenye ruhusa za juu, ambazo zinaweza kutumiwa vibaya na washambuliaji.
* **Review deletion timestamps** katika jedwali la inode ili kugundua kufutwa kwa faili kwa wingi, ambayo inaweza kuashiria uwepo wa rootkits au trojans.
* **Inspect consecutive inodes** kwa faili mbaya zilizo karibu baada ya kubaini moja, kwani zinaweza kuwa zimewekwa pamoja.
* **Check common binary directories** (_/bin_, _/sbin_) kwa faili zilizobadilishwa hivi karibuni, kwani hizi zinaweza kubadilishwa na malware.
````bash
2024-02-11 02:13:58 +00:00
# List recent files in a directory:
2024-02-07 04:05:50 +00:00
ls -laR --sort=time /bin```
2024-02-11 02:13:58 +00:00
# Sort files in a directory by inode:
2024-02-07 04:05:50 +00:00
ls -lai /bin | sort -n```
````
2020-12-28 22:28:30 +00:00
{% hint style="info" %}
Kumbuka kwamba **mshambuliaji** anaweza **kubadilisha** **wakati** ili kufanya **faili kuonekana** **halali**, lakini hawezi **kubadilisha** **inode**. Ikiwa unapata kwamba **faili** inaonyesha kwamba iliumbwa na kubadilishwa kwa **wakati mmoja** na faili zingine katika folda hiyo hiyo, lakini **inode** ni **kubwa zaidi** kwa **kushtukiza**, basi **alama za wakati za faili hiyo zilibadilishwa**.
2020-12-28 22:28:30 +00:00
{% endhint %}
## Linganisha faili za toleo tofauti la mfumo wa faili
2020-12-28 22:28:30 +00:00
### Muhtasari wa Linganisho la Toleo la Mfumo wa Faili
2021-01-06 15:28:14 +00:00
Ili kulinganisha toleo la mfumo wa faili na kubaini mabadiliko, tunatumia amri rahisi za `git diff`:
2024-02-07 04:05:50 +00:00
* **Ili kupata faili mpya**, linganisha directories mbili:
2021-01-06 15:28:14 +00:00
```bash
2024-02-07 04:05:50 +00:00
git diff --no-index --diff-filter=A path/to/old_version/ path/to/new_version/
2021-01-06 15:28:14 +00:00
```
* **Kwa yaliyobadilishwa**, orodhesha mabadiliko huku ukipuuzilia mbali mistari maalum:
2021-01-06 15:28:14 +00:00
```bash
2024-02-07 04:05:50 +00:00
git diff --no-index --diff-filter=M path/to/old_version/ path/to/new_version/ | grep -E "^\+" | grep -v "Installed-Time"
2021-01-06 15:28:14 +00:00
```
* **Ili kugundua faili zilizofutwa**:
2021-01-06 15:28:14 +00:00
```bash
2024-02-07 04:05:50 +00:00
git diff --no-index --diff-filter=D path/to/old_version/ path/to/new_version/
2021-01-06 15:28:14 +00:00
```
* **Chaguzi za kuchuja** (`--diff-filter`) husaidia kupunguza mabadiliko maalum kama vile faili zilizoongezwa (`A`), kufutwa (`D`), au kubadilishwa (`M`).
* `A`: Faili zilizoongezwa
* `C`: Faili zilizokopiwa
* `D`: Faili zilizofutwa
* `M`: Faili zilizobadilishwa
* `R`: Faili zilizobadilishwa jina
* `T`: Mabadiliko ya aina (mfano, faili hadi symlink)
* `U`: Faili zisizojumuishwa
* `X`: Faili zisizojulikana
* `B`: Faili zilizovunjika
2024-02-11 02:13:58 +00:00
## Marejeleo
2020-12-23 22:44:17 +00:00
2021-10-19 00:01:07 +00:00
* [https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems\_Ch3.pdf](https://cdn.ttgtmedia.com/rms/security/Malware%20Forensics%20Field%20Guide%20for%20Linux%20Systems\_Ch3.pdf)
2020-12-23 22:44:17 +00:00
* [https://www.plesk.com/blog/featured/linux-logs-explained/](https://www.plesk.com/blog/featured/linux-logs-explained/)
2024-02-07 04:05:50 +00:00
* [https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203](https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203)
* **Kitabu: Mwongozo wa Upelelezi wa Malware kwa Mifumo ya Linux: Mwongozo wa Upelelezi wa Kidijitali**
2022-04-28 16:01:33 +00:00
{% hint style="success" %}
Jifunze & fanya mazoezi ya AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Jifunze & fanya mazoezi ya GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
<details>
2022-04-28 16:01:33 +00:00
<summary>Support HackTricks</summary>
2022-04-28 16:01:33 +00:00
* Angalia [**mpango wa usajili**](https://github.com/sponsors/carlospolop)!
* **Jiunge na** 💬 [**kikundi cha Discord**](https://discord.gg/hRep4RUj7f) au [**kikundi cha telegram**](https://t.me/peass) au **tufuatilie** kwenye **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Shiriki mbinu za udukuzi kwa kuwasilisha PRs kwa** [**HackTricks**](https://github.com/carlospolop/hacktricks) na [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repos za github.
2022-04-28 16:01:33 +00:00
</details>
{% endhint %}
2022-08-31 22:35:39 +00:00
<figure><img src="../../.gitbook/assets/image (3) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
2022-08-31 22:35:39 +00:00
\
Tumia [**Trickest**](https://trickest.com/?utm\_campaign=hacktrics\&utm\_medium=banner\&utm\_source=hacktricks) kujenga na **kujiendesha** kwa urahisi kwa kutumia zana za jamii **zilizoendelea zaidi** duniani.\
Pata Ufikiaji Leo:
2022-08-31 22:35:39 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}