When it comes to competitions, several of the machines the team will be responsible for will running Linux. Often it's older versions of common of Linux distros such as Ubuntu 14.04.
There are very basic commands that will be necessary in order to navigate your machine.
ls
- Lists the contents of the current directory. To show all files, usels -al
.pwd
- Shows your current directorycd
- Changes your current directory.cd ~
,cd /
,cd /etc/
mkdir
- Makes a new directorymkdir test
,mkdir -p a/test/dir
rm
- Deletes a file (add-rf
to delete a directory)find
- Find a filelocate
- Easy way to find a filetouch
- Create an empty filetouch file.txt
cat
- Print the contents of a file tostdout
grep
- Search a file for a stringgrep 'string' file.c
ps
- Shows running processes --ps auxf
for tree structurekill
- Kill a processkill -9 $PID
who
- Show who is signed inecho
- Print tostdout
--echo 'This a test'
lsof
- See all open file descriptorstail -f
- Watch the end of a filewatch
- Run a command at specified intervals
There are a few ways to find out what distro you're on, the name of the machine, and the machine's IP address
uname -a
- Prints the kernel version and morehostname
- Prints the system hostnameifconfig
- Shows the IP addressip addr
- The new way to show IP addresscat /etc/os-release
- Shows various information about the system
There will be certain services that need to be running throughout a
competition. It will be good to know how to manage them. The tool used to
manage services on newer Linux systems is called systemctl
, part of the
systemd
suite of utilities.
stop
- Stops a servicerestart
- Restarts a servicestart
- Starts a servicestatus
- Shows whether a service is running/stopped/failedlist-unit
- Shows all services and morereboot
- Reboot the machine
Once a malicious actor has had root access on your Linux machine, that machine cannot be trusted. The right thing to do would be to start fresh and be better at prevention in the future. Unfortunately, that's not possible during a competition. Here's a few really nasty ways an attacker could mess with you.
- Adding malicious things to
/etc/crontab
. These will run at specified intervals (every minute, 5 minutes, every hour at :05, etc.) - Putting fake binaries on your
$PATH
sudo
so that anyone who runssudo
gets rootpasswd
so that you can't change passwords or passwords get logged
- malicious systemd services or timers
- modifications to
~/.*rc
files
man
-- tryman man
- linuxjourney.com (External link)
- JMU Unix Users Group
--help
flag to commandsapropos
to search for commands