Linux & Security Flashcards
(148 cards)
What does writing echo do?
echo Output any text that we provide
How do you find out which user you are logged in as?
whoami Find out what user we’re currently logged in as!
How do you list contents of directory with privileges? How do you include hidden files?
ls -l
ls listing
ls -a for hidden files
How do you move in and out of a directory?
cd
cd ..
cd /dir/
How do you list the contents of a file?
cat file.txt
How do you show your current working directory?
pwd
print working directory
How do you find a specific file in among different directories?
find -name specificfile.txt
How do you find a specific TYPE of file in among different directories?
find -name *.txt
How do you find a specific entry in a long file, like an IP address in a .log file?
grep “(what you’re looking for)” (file of contents).log
grep “81.143.211.90” access.log
How do you write text into an empty file using the command line?
echo (content) > (filename)
cat (content) > (filename)
echo hey > welcome
> > to keep the contents of the file without overwriting them
What is SSH and how does it work? How does SSH authenticate users, and how does this authentication work?
Secure Shell is a network communication protocol.
SSH employs encryption to ensure that hackers cannot interpret the traffic between two connected devices.
The ssh command provides a secure encrypted connection between two hosts over an insecure network. This connection can also be used for terminal access, file transfers, and for tunneling other applications. Graphical X11 applications can also be run securely over SSH from a remote location.
AUTHENTICATION
TCP based connection, 3 way handshake.
SSH daemon must be running in order to use this protocol on both sides of the communication. I.E, listening on a port for inbound SSH connections.
SSH authenticates users by using passwords or SSH keys. SSH passwords can be easily breached.
- SSH keys are a matching set of cryptographic keys which can be used for authentication. Each set contains a public and a private key. The public key can be shared freely without concern, while the private key must be vigilantly guarded and never exposed to anyone.
- To authenticate using SSH keys, a user must have an SSH key pair on their local computer. On the remote server, the public key must be copied to a file within the user’s home directory at ~/.ssh/authorized_keys. This file contains a list of public keys, one-per-line, that are authorized to log into this account.
- When a client connects to the host, wishing to use SSH key authentication, it will inform the server of this intent and will tell the server which public key to use. The server then checks its authorized_keys file for the public key, generates a random string, and encrypts it using the public key. This encrypted message can only be decrypted with the associated private key. The server will send this encrypted message to the client to test whether they actually have the associated private key.
SIMPLER EXPLANATION
An SSH key relies upon the use of two related keys, a public key and a private key, that together create a key pair that is used as the secure access credential. The private key is secret, known only to the user, and should be encrypted and stored safely. The public key can be shared freely with any SSH server to which the user wishes to connect. These keys are normally managed by an organization’s IT team, or better yet, with the help of a trusted Certificate Authority (CA) to ensure they are stored safely.
What is ARP? How does it function (1)? How can it be abused?
ARP stands for Address Resolution Protocol. It is used to discover MAC addresses and map them to IP addresses for LAN communications.
- WHOIS? ARP request broadcast of a host asking for someone’s MAC address. This is sent to every client on the network, and then discarded if it isn’t the target IP. Target client will send out ARP frame containing their MAC address.
- Host receives a MAC address, which is stored in an ARP cache. This allows for communication among the network now that both devices know their MAC addresses.
- ARP request broadcast for 192. is sent to every device on the LAN
- each device receives the request and discards it if they are not the designated recipient, whereas the target IP will respond with their
MAC. - this MAC address is saved into the senders ARP cache, where MAC addresses are stored in relation to IP addresses for other devices on the network
operating on layer 2 of the OSI7 and TCP/IP as it deals with MAC addressing
ARP can be abused via ARP cache poisoning
- hacker will send ARP packets containing false information, impersonating the MAC address of a particular device which is the endpoint of
sensitive data (usually default gateway). - target will accept this ARP information and store it in its ARP cache, effectively having it poisoned with the hacker’s spoofed MAC address
- target will begin sending it’s data to spoofed address of the hacker
You can use bettercap ARP spoof feature which will send arbitrary ARP packets to intended victims, allowing you to impersonate any device on the LAN (default gateway being the prime target to imitate)
How do you usually install the requirements for a particular package off github?
Pip.
python3 -m pip install filename.txt
How do you quickly view the history of your commands from a terminal session?
History
How do you make a new directory?
mkdir *
How do you delete a directory? How do you remove a directory if it isn’t empty?
rmdir *
rm -r
How do you get the current system details such as OS version?
hostnamectl
Detailed
uname -a
OS version and build of machine
How do you display free memory of the system?
free -m
sounds like “free -memory”
How do you display the running processes in a system?
top
htop
sounds like “top processes”
How do you display all ports the machine is listening on?
netstat
How do you list the contents of your current working directory with permissions? How do you do this for a specific file?
ls -l filename
How do you allow a file to be ran by every user? How do you allow to read, write and execute?
chmod 777 filename
How do you allow a file to be read and written by every user but not executed?
chmod 766 filename
How do you add another user?
useradd username