diff --git a/src/markdown-pages/books/linux-basics-for-hackers.md b/src/markdown-pages/books/linux-basics-for-hackers.md new file mode 100644 index 000000000..4110da77b --- /dev/null +++ b/src/markdown-pages/books/linux-basics-for-hackers.md @@ -0,0 +1,705 @@ +--- +title: Linux Basics for Hackers +date: 2026-08-17 +tags: + - hacking + - linux + - book +--- + +https://www.amazon.com/Linux-Basics-Hackers-Networking-Scripting/dp/1593278551 + +## Finding + +```bash +locate aircrack-ng +whereis aircrack-ng +which aircrack-ng +find -type f -name apache2 +find / -type f -name apache2 +find /etc -type f -name apache2.\* + +ps aux +``` + +## Snort + +```bash +apt-get install snort +cat /etc/snort/snort.conf + +nl # show file with numbered lines + +tail -n+507 /etc/snort/snort.conf | head -n 6 +``` + +## Network + +```bash +ifconfig +iwconfig + +ifconfig eth0 192.168.181.115 # sets ip +ifconfig eth0 192.168.181.115 netmask 255.255.0.0 broadcast # change mask and gateway + +ifconfig eth0 down +ifconfig eth0 hw ether 00:11:22:33:44:55 +ifconfig eth0 up + +dig hackers-arise.com ns +dig hackers-arise.com mx + +vi /etc/resolv.conf +``` + +### DHCP + +Linux has `dhcpd` running in the background that assigns IP addresses to machines. It has logs, great for forensics. + +```bash +dhclient eth0 # new IP +``` + +## Installing and Removing + +`apt` or `apt-get`. `apt` may be preferred but `apt-get` has more function + +`apt-cache search ` search for app + +`apt-get install ` installs the app + +`apt-get remove snort` removes app + +`apt-get purge ` clears config files + +`apt autoremove snort` removes deps + +`apt-get update` updates packages + +`apt-get upgrade` installs updates + +Apt will search repositories from `sources.list`. + +`vi /etc/apt/sources.list` + +`apt-get install synaptic` and Gdebi are GUI instlal tools, no longer included by default in kali. + +## Permissions + +```bash +chown bob /tmp/bobsfile # grant ownership of file +chgrp security new IDS # change group +chmod 774 # changes permissions for owner, group, all +``` + +Decimal Notation + +Uses octal, 0-7 + +| Binary | Octal | rwx | +| ------ | ----- | ---- | +| 000 | 0 | --- | +| 001 | 1 | --x | +| 010 | 2 | -w- | +| 011 | 3 | -wx- | +| 100 | 4 | r-- | +| 101 | 5 | r-x | +| 111 | 7 | rwx | +UGO syntax + +`u` for user, `g` for group, `o` for others +`-` removes +`+` adds +`=` sets + +Can be comma separated + +More Secure Default + +`666` is default for files +`777` is default for directories + +umask is a three-digit ocatal for three permissions digits, but it is subtracted. + +Kali base: + +`666 - 022 = 644` +`777 - 022 = 755` + +### Temporary Root Permissions + +SUID: temp root + +To set SUID, enter a 4 before regular permissions. e.g. `4644` + +SGID: temp for group + +To set SGID, enter a 2 before regular permissions. e.g. 2644 + +Sticky bit: legacy, let's a user delete or rename files in a directory + +### Special Permissions + +Privilege escalation via SUID. + +```bash +find / -user root -perm -4000 # files with SUID for root + +``` + +## Processes + +`ps` view processes + +`ps aux` view all processes for all users + +`msfconsole` start metasploit + +`top` find greedy processes + +Nice sets priority, low number is taken first. + +`niceĀ -n -10 /bin/slowprocess` set priority when starting process + +`renice 19 6996` change priority of PID 6996 + +`kill ` kill + +| Signal Name | Number | Description | +| ----------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------- | +| SIGHUP | 1 | Hangup (HUP) signal. Stops the process and restarts with same PID | +| SIGINT | 2 | Interrupt signal. Weak kill signal that isn't guarenteed to work, but does most times. | +| SIGQUIT | 3 | Core dump. Terminates the process and saves the process information in memory and then saves in the working directory with a file named core. | +| SIGTERM | 15 | Termination (TERM) signal. Kill commands default signal. | +| SIGKILL | 9 | Absolute kill signal. Forces the process to stop by senign the process's resources to a special device, /dev/null | +| | | | +| | | | + +`killall -9 rogueprocess` killall by app name + +`