Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #####################################
- # Strategicsec Intro to Linux #
- # By Joe McCray #
- #####################################
- ########################
- # Basic Linux Commands #
- ########################
- cd ~
- pwd
- whereis pwd
- which pwd
- sudo find / -name pwd
- /bin/pwd
- mkdir LinuxBasics
- cd LinuxBasics
- touch one two three
- ls -l t (without pressing the Enter key, press the Tab key twice. What happens?)
- h (and again without pressing the Enter key, press the Tab key twice. What happens?)
- Press the 'Up arrow key' (What happens?)
- Press 'Ctrl-A' (What happens?)
- ls
- clear (What happens?)
- echo one > one
- cat one (What happens?)
- man cat (What happens?)
- q
- cat two
- cat one > two
- cat two
- cat one two > three
- cat three
- echo four >> three
- cat three (What happens?)
- wc -l three
- man wc
- q
- cat three | grep four
- cat three | grep one
- man grep
- q
- man ps
- q
- ps
- ps aux
- ps aux | less
- Press the 'Up arrow key' (What happens?)
- Press the 'Down arrow key' (What happens?)
- q
- top
- #########
- # Files #
- #########
- cd ~
- pwd
- ls
- cd LinuxBasics
- pwd
- cd ~
- pwd
- cd LinuxBasics
- ls
- mkdir files
- cp one files/
- ls files/
- cd files/
- cp ../two .
- ls
- cp ../three .
- ls
- tar cvf files.tar *
- ls
- gzip files.tar
- ls
- rm -rf one two three
- ls
- tar -zxvf files.tar.gz
- rm -rf files.tar.gz
- sudo apt-get install -y zip unzip
- zip data *
- unzip -l data.zip
- unzip data.zip -d /tmp
- unzip -l data.zip
- ############
- # VIM Demo #
- ############
- cd ~
- sudo apt-get install -y vim
- strategicsec
- cd LinuxBasics
- mkdir vimlesson
- cd vimlesson
- vi lesson1.sh
- i (press "i" to get into INSERT mode and then paste in the lines below)
- #!/bin/bash
- echo "This is my first time using vi to create a shell script"
- echo " "
- echo " "
- echo " "
- sleep 5
- echo "Ok, now let's clear the screen"
- sleep 3
- ---------------don't put this line in your script----------------------------
- ESC (press the ESC key to get you out of INSERT mode)
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- vi lesson1.sh
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- vi lesson1.sh
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- /echo (typing "/echo" immediately after SHIFT: will search the file for the word echo).
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- vi lesson1.sh
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- 4 (typing "4" immediately after SHIFT: will take you to line number 4).
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- vi lesson1.sh
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- 4 (typing "4" immediately after SHIFT: will take you to line number 4).
- dd (typing "dd" will delete the line that you are on)
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- vi lesson1.sh
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- 4 (typing "4" immediately after SHIFT: will take you to line number 4).
- dd (typing "dd" will delete the line that you are on)
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- syntax on (typing "syntax on" immediately after SHIFT: will turn on syntax highlighting
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- set tabstop=5 (typing "set tabstop=5" immediately after SHIFT: will set your tabs to 5 spaces
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- vi ~/.vimrc
- i (press "i" to get into INSERT mode and then paste in the lines below)
- set number
- syntax on
- set tabstop=5
- ESC (press the ESC key to get you out of INSERT mode)
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- vi lesson1.sh
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- echo $MYVIMRC (typing "echo $MYVIMRC" immediately after SHIFT: will display the path to your new .vimrc file
- [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
- wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
- ###############
- # Permissions #
- ###############
- cd ~
- pwd
- ls
- cd LinuxBasics
- ls -l one
- We can determine a lot from examining the results of this command. The file "one" is owned by user "me".
- Now "me" has the right to read and write this file.
- The file is owned by the group "me". Members of the group "me" can also read and write this file.
- Everybody else can read this file
- ls -l /bin/bash
- Here we can see:
- The file "/bin/bash" is owned by user "root". The superuser has the right to read, write, and execute this file.
- The file is owned by the group "root". Members of the group "root" can also read and execute this file. Everybody else can read and execute this file
- The next command you need to know is "chmod"
- rwx rwx rwx = 111 111 111
- rw- rw- rw- = 110 110 110
- rwx --- --- = 111 000 000
- and so on...
- rwx = 111 in binary = 7
- rw- = 110 in binary = 6
- r-x = 101 in binary = 5
- r-- = 100 in binary = 4
- ls -l one
- chmod 600 one
- ls -l one
- sudo useradd testuser
- strategicsec
- sudo passwd testuser
- testuser
- testuser
- sudo chown testuser one
- strategicsec
- ls -l one
- sudo chgrp testuser one
- strategicsec
- ls -l one
- id
- su testuser
- testuser
- Here is a table of numbers that covers all the common settings. The ones beginning with "7" are used with programs (since they enable execution) and the rest are for other kinds of files.
- Value Meaning
- 777 (rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
- 755 (rwxr-xr-x) The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
- 700 (rwx------) The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
- 666 (rw-rw-rw-) All users may read and write the file.
- 644 (rw-r--r--) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
- 600 (rw-------) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
- Directory permissions
- ---------------------
- The chmod command can also be used to control the access permissions for directories. In most ways, the permissions scheme for directories works the same way as they do with files. However, the execution permission is used in a different way. It provides control for access to file listing and other things. Here are some useful settings for directories:
- Value Meaning
- 777 (rwxrwxrwx) No restrictions on permissions.
- Anybody may list files, create new files in the directory and delete files in the directory.
- Generally not a good setting.
- 755 (rwxr-xr-x) The directory owner has full access.
- All others may list the directory, but cannot create files nor delete them.
- This setting is common for directories that you wish to share with other users.
- 700 (rwx------) The directory owner has full access. Nobody else has any rights. This setting is useful for directories that only the owner may use and must be kept private from others.
- ##############################
- # Stick big and SUID exploit #
- ##############################
- Create a name myfile.txt in the file system that points to a new inode (which contains the metadata for the file and points to the blocks of data that contain its contents, i.e. the text "Hello, World!":
- $ echo 'Hello, World!' > myfile.txt
- Create a hard link my-hard-link to the file myfile.txt, which means "create a file that should point to the same inode that myfile.txt points to":
- $ ln myfile.txt my-hard-link
- Create a soft link my-soft-link to the file myfile.txt, which means "create a file that should point to the file myfile.txt":
- $ ln -s myfile.txt my-soft-link
- Look what will now happen if myfile.txt is deleted (or moved): my-hard-link still points to the same contents, and is thus unaffected, whereas my-soft-link now points to nothing. Other answers discuss the pros/cons of each.
- ####################################################
- # Privilege Escalation by Exploiting SUID Binaries #
- ####################################################
- vi test_suid.c
- ------------------------------------------------------------------
- #include<stdio.h>
- #include<stdlib.h>
- #include<unistd.h>
- int main()
- {
- char *eargs[] = {"/bin/bash", "-p"};
- printf("Executing Shell\n");
- execve("/bash/bash", eargs, NULL);
- return 0;
- }
- ------------------------------------------------------------------
- Test_suid.c is a demo exploit file can be compiled using GCC
- # gcc test_suid.c -o test_suid
- Compiling as root user to make sure file is owned by root.
- When test_suid binary is executed without SUID bit set, we still have prdarsha user permissions.
- Now lets execute test_suid binary after setting SUID bit which will escalate the privilege from notmal user to root user.
- File permissions can be set using below command (also refer Figure. File Permissions)
- # chmod u+s test_suid
- Checking the permissions of important file like passwd
- Finding all executable's which have SUID bit set
- find / -type f \( -perm -04000 -o -perm -02000 \) \-exec ls -lg {} \;
- ######################
- # Process Management #
- ######################
- top
- sudo apt-get install -y htop
- strategicsec
- htop
- ps
- ps aux
- ps -A
- ps -A | less
- ps axjf
- pstree
- pgrep bash
- pgrep init
- ps aux | grep apache
- You can list all of the signals that are possible to send with kill by typing:
- kill -l
- sudo kill -HUP pid_of_apache
- The pkill command works in almost exactly the same way as kill, but it operates on a process name instead:
- pkill -9 ping
- The above command is the equivalent of:
- kill -9 `pgrep ping`
- ##############
- # Cisco Logs #
- ##############
- wget https://s3.amazonaws.com/infosecaddictsfiles/cisco.log
- AWK Basics
- ----------
- - To quickly demonstrate the print feature in awk, we can instruct it to show only the 5th word of each line. Here we will print $5. Only the last 4 lines are being shown for brevity.
- cat cisco.log | awk '{print $5}' | tail -n 4
- - Looking at a large file would still produce a large amount of output. A more useful thing to do might be to output every entry found in “$5”, group them together, count them, then sort them from the greatest to least number of occurrences. This can be done by piping the output through “sort“, using “uniq -c” to count the like entries, then using “sort -rn” to sort it in reverse order.
- cat cisco.log | awk '{print $5}'| sort | uniq -c | sort -rn
- - While that’s sort of cool, it is obvious that we have some garbage in our output. Evidently we have a few lines that aren’t conforming to the output we expect to see in $5. We can insert grep to filter the file prior to feeding it to awk. This insures that we are at least looking at lines of text that contain “facility-level-mnemonic”.
- cat cisco.log | grep %[a-zA-Z]*-[0-9]-[a-zA-Z]* | awk '{print $5}' | sort | uniq -c | sort -rn
- - Now that the output is cleaned up a bit, it is a good time to investigate some of the entries that appear most often. One way to see all occurrences is to use grep.
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| awk '{print $10}' | sort | uniq -c | sort -rn
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10}' | sort | uniq -c | sort -rn
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10 " changed to " $14}' | sort | uniq -c | sort -rn
- ####################
- # MD5 Hashing Demo #
- ####################
- cd ~/LinuxBasics
- mkdir hashdemo
- cd hashdemo
- echo test > test.txt
- cat test.txt
- md5sum test.txt
- echo hello >> test.txt
- cat test.txt
- md5sum test.txt
- cd ..
- #################################
- # Symmetric Key Encryption Demo #
- #################################
- cd ~/LinuxBasics
- mkdir gpgdemo
- cd gpgdemo
- echo test > test.txt
- cat test.txt
- gpg -c test.txt
- password
- password
- ls | grep test
- cat test.txt
- cat test.txt.gpg
- rm -rf test.txt
- ls | grep test
- gpg -o output.txt test.txt.gpg
- cat output.txt
- #########################################################################################################################
- # Asymmetric Key Encryption Demo #
- # #
- # Configure random number generator #
- # https://www.howtoforge.com/helping-the-random-number-generator-to-gain-enough-entropy-with-rng-tools-debian-lenny #
- #########################################################################################################################
- sudo apt-get install -y rng-tools
- strategicsec
- /etc/init.d/rng-tools start
- sudo rngd -r /dev/urandom
- strategicsec
- echo hello > file1.txt
- echo goodbye > file2.txt
- echo green > file3.txt
- echo blue > file4.txt
- tar czf files.tar.gz *.txt
- gpg --gen-key
- 1
- 1024
- 0
- y
- John Doe
- john@doe.com
- --blank comment--
- O
- password
- password
- gpg --armor --output file-enc-pubkey.txt --export 'John Doe'
- cat file-enc-pubkey.txt
- gpg --armor --output file-enc-privkey.asc --export-secret-keys 'John Doe'
- cat file-enc-privkey.asc
- gpg --encrypt --recipient 'John Doe' files.tar.gz
- rm -rf files.tar.gz *.txt
- ls
- tar -zxvf files.tar.gz.gpg
- gpg --output output.tar.gz --decrypt files.tar.gz.gpg
- password
- tar -zxvf output.tar.gz
- ls
- ############################
- # Encryption using OpenSSL #
- ############################
- openssl genrsa -out private_key.pem 1024
- openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout
- echo hello > encrypt.txt
- openssl rsautl -encrypt -inkey public_key.pem -pubin -in encrypt.txt -out encrypt.dat
- cat encrypt.dat
- rm -rf encrypt.txt
- ls
- openssl rsautl -decrypt -inkey private_key.pem -in encrypt.dat -out decrypt.txt
- cat decrypt.txt
- ###############################
- # Secure File/Folder Deletion #
- ###############################
- sudo apt-get install -y secure-delete wipe
- wget https://www.sans.org/security-resources/tcpip.pdf
- file tcpip.pdf
- sudo srm tcpip.pdf
- wget https://www.sans.org/security-resources/tcpip.pdf
- shred tcpip.pdf
- wget https://www.sans.org/security-resources/tcpip.pdf
- wipe tcpip.pdf
- #################
- # IPTables Demo #
- #################
- cd ~
- - Delete Existing Rules
- ---------------------
- sudo /sbin/iptables -F
- strategicsec
- (or)
- sudo /sbin/iptables --flush
- strategicsec
- - Set Default Chain Policies
- --------------------------
- iptables -P INPUT DROP
- iptables -P FORWARD DROP
- iptables -P OUTPUT DROP
- - Delete Existing Rules
- ---------------------
- sudo /sbin/iptables -F
- strategicsec
- (or)
- sudo /sbin/iptables --flush
- strategicsec
- sudo /bin/bash
- - Block a Specific ip-address
- -----------------------------
- BLOCK_THIS_IP="1.2.3.4"
- iptables -A INPUT -s "$BLOCK_THIS_IP" -j DROP
- iptables -A INPUT -i eth0 -s "$BLOCK_THIS_IP" -j DROP
- iptables -A INPUT -i eth0 -p tcp -s "$BLOCK_THIS_IP" -j DROP
- - Allow ALL Incoming SSH
- ------------------------
- iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
- - Allow Incoming SSH only from a Sepcific Network
- -------------------------------------------------
- iptables -A INPUT -i eth0 -p tcp -s 192.168.100.0/24 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
- - Allow Incoming HTTP and HTTPS
- -------------------------------
- iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
- - Combine Multiple Rules Together using MultiPorts
- --------------------------------------------------
- iptables -A INPUT -i eth0 -p tcp -m multiport --dports 22,80,443 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp -m multiport --sports 22,80,443 -m state --state ESTABLISHED -j ACCEPT
- - Allow Outgoing SSH
- --------------------
- iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
- - Allow Outgoing SSH only to a Specific Network
- -----------------------------------------------
- The following rules allow outgoing ssh connection only to a specific network. i.e You an ssh only to 192.168.100.0/24 network from the inside.
- iptables -A OUTPUT -o eth0 -p tcp -d 192.168.100.0/24 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
- - Allow Outgoing HTTPS
- ----------------------
- The following rules allow outgoing secure web traffic. This is helpful when you want to allow internet traffic for your users. On servers, these rules are also helpful when you want to use wget to download some files from outside.
- iptables -A OUTPUT -o eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
- Load Balance Incoming Web Traffic
- ---------------------------------
- You can also load balance your incoming web traffic using iptables firewall rules.
- This uses the iptables nth extension. The following example load balances the HTTPS traffic to three different ip-address. For every 3th packet, it is load balanced to the appropriate server (using the counter 0).
- iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 0 -j DNAT --to-destination 192.168.1.101:443
- iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 1 -j DNAT --to-destination 192.168.1.102:443
- iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 2 -j DNAT --to-destination 192.168.1.103:443
- Allow Ping from Outside to Inside
- ---------------------------------
- The following rules allow outside users to be able to ping your servers.
- iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
- iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
- Allow Ping from Inside to Outside
- ---------------------------------
- The following rules allow you to ping from inside to any of the outside servers.
- iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
- iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
- Allow Loopback Access
- ---------------------
- You should allow full loopback access on your servers. i.e access using 127.0.0.1
- iptables -A INPUT -i lo -j ACCEPT
- iptables -A OUTPUT -o lo -j ACCEPT
- Allow Internal Network to External network
- ------------------------------------------
- On the firewall server where one ethernet card is connected to the external, and another ethernet card connected to the internal servers, use the following rules to allow internal network talk to external network.
- In this example, eth1 is connected to external network (internet), and eth0 is connected to internal network (For example: 192.168.1.x).
- iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
- Allow outbound DNS
- ------------------
- The following rules allow outgoing DNS connections.
- iptables -A OUTPUT -p udp -o eth0 --dport 53 -j ACCEPT
- iptables -A INPUT -p udp -i eth0 --sport 53 -j ACCEPT
- Allow Rsync From a Specific Network
- -----------------------------------
- The following rules allows rsync only from a specific network.
- iptables -A INPUT -i eth0 -p tcp -s 192.168.101.0/24 --dport 873 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 873 -m state --state ESTABLISHED -j ACCEPT
- Allow MySQL connection only from a specific network
- ---------------------------------------------------
- If you are running MySQL, typically you don’t want to allow direct connection from outside. In most cases, you might have web server running on the same server where the MySQL database runs.
- However DBA and developers might need to login directly to the MySQL from their laptop and desktop using MySQL client. In those case, you might want to allow your internal network to talk to the MySQL directly as shown below.
- iptables -A INPUT -i eth0 -p tcp -s 192.168.100.0/24 --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT
- Allow Sendmail or Postfix Traffic
- ---------------------------------
- The following rules allow mail traffic. It may be sendmail or postfix.
- iptables -A INPUT -i eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT
- Allow IMAP and IMAPS
- --------------------
- The following rules allow IMAP/IMAP2 traffic.
- iptables -A INPUT -i eth0 -p tcp --dport 143 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 143 -m state --state ESTABLISHED -j ACCEPT
- The following rules allow IMAPS traffic.
- iptables -A INPUT -i eth0 -p tcp --dport 993 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 993 -m state --state ESTABLISHED -j ACCEPT
- Allow POP3 and POP3S
- --------------------
- The following rules allow POP3 access.
- iptables -A INPUT -i eth0 -p tcp --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 110 -m state --state ESTABLISHED -j ACCEPT
- The following rules allow POP3S access.
- iptables -A INPUT -i eth0 -p tcp --dport 995 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 995 -m state --state ESTABLISHED -j ACCEPT
- Port Forwarding
- ---------------
- The following example routes all traffic that comes to the port 442 to 22. This means that the incoming ssh connection can come from both port 22 and 422.
- iptables -t nat -A PREROUTING -p tcp -d 192.168.102.37 --dport 422 -j DNAT --to 192.168.102.37:22
- If you do the above, you also need to explicitly allow incoming connection on the port 422.
- iptables -A INPUT -i eth0 -p tcp --dport 422 -m state --state NEW,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -o eth0 -p tcp --sport 422 -m state --state ESTABLISHED -j ACCEPT
- Log Dropped Packets
- -------------------
- You might also want to log all the dropped packets. These rules should be at the bottom.
- First, create a new chain called LOGGING.
- iptables -N LOGGING
- Next, make sure all the remaining incoming connections jump to the LOGGING chain as shown below.
- iptables -A INPUT -j LOGGING
- Next, log these packets by specifying a custom “log-prefix”.
- iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables Packet Dropped: " --log-level 7
- Finally, drop these packets.
- ##############################################
- # Log Analysis with Linux command-line tools #
- ##############################################
- - The following command line executables are found in the Mac as well as most Linux Distributions.
- cat – prints the content of a file in the terminal window
- grep – searches and filters based on patterns
- awk – can sort each row into fields and display only what is needed
- sed – performs find and replace functions
- sort – arranges output in an order
- uniq – compares adjacent lines and can report, filter or provide a count of duplicates
- ###############
- # Apache Logs #
- ###############
- Reference:
- http://www.the-art-of-web.com/system/logs/
- wget https://s3.amazonaws.com/SecureNinja/Python/access_log
- - You want to list all user agents ordered by the number of times they appear (descending order):
- awk -F\" '{print $6}' access_log | sort | uniq -c | sort -fr
- - Using the default separator which is any white-space (spaces or tabs) we get the following:
- awk '{print $1}' access_log # ip address (%h)
- awk '{print $2}' access_log # RFC 1413 identity (%l)
- awk '{print $3}' access_log # userid (%u)
- awk '{print $4,5}' access_log # date/time (%t)
- awk '{print $9}' access_log # status code (%>s)
- awk '{print $10}' access_log # size (%b)
- - You might notice that we've missed out some items. To get to them we need to set the delimiter to the " character which changes the way the lines are 'exploded' and allows the following:
- awk -F\" '{print $2}' access_log # request line (%r)
- awk -F\" '{print $4}' access_log # referer
- awk -F\" '{print $6}' access_log # user agent
- awk -F\" '{print $6}' access_log \
- | sed 's/(\([^;]\+; [^;]\+\)[^)]*)/(\1)/' \
- | sort | uniq -c | sort -fr
- - The next step is to start filtering the output so you can narrow down on a certain page or referer. Would you like to know which pages Google has been requesting from your site?
- awk -F\" '($6 ~ /Googlebot/){print $2}' access_log | awk '{print $2}'
- Or who's been looking at your guestbook?
- awk -F\" '($2 ~ /guestbook\.html/){print $6}' access_log
- Reference:
- https://blog.nexcess.net/2011/01/21/one-liners-for-apache-log-files/
- # top 20 URLs from the last 5000 hits
- tail -5000 ./access_log | awk '{print $7}' | sort | uniq -c | sort -rn | head -20
- tail -5000 ./access_log | awk '{freq[$7]++} END {for (x in freq) {print freq[x], x}}' | sort -rn | head -20
- # top 20 URLS excluding POST data from the last 5000 hits
- tail -5000 ./access_log | awk -F"[ ?]" '{print $7}' | sort | uniq -c | sort -rn | head -20
- tail -5000 ./access_log | awk -F"[ ?]" '{freq[$7]++} END {for (x in freq) {print freq[x], x}}' | sort -rn | head -20
- # top 20 IPs from the last 5000 hits
- tail -5000 ./access_log | awk '{print $1}' | sort | uniq -c | sort -rn | head -20
- tail -5000 ./access_log | awk '{freq[$1]++} END {for (x in freq) {print freq[x], x}}' | sort -rn | head -20
- # top 20 URLs requested from a certain ip from the last 5000 hits
- IP=1.2.3.4; tail -5000 ./access_log | grep $IP | awk '{print $7}' | sort | uniq -c | sort -rn | head -20
- IP=1.2.3.4; tail -5000 ./access_log | awk -v ip=$IP ' $1 ~ ip {freq[$7]++} END {for (x in freq) {print freq[x], x}}' | sort -rn | head -20
- # top 20 URLS requested from a certain ip excluding, excluding POST data, from the last 5000 hits
- IP=1.2.3.4; tail -5000 ./access_log | fgrep $IP | awk -F "[ ?]" '{print $7}' | sort | uniq -c | sort -rn | head -20
- IP=1.2.3.4; tail -5000 ./access_log | awk -F"[ ?]" -v ip=$IP ' $1 ~ ip {freq[$7]++} END {for (x in freq) {print freq[x], x}}' | sort -rn | head -20
- # top 20 referrers from the last 5000 hits
- tail -5000 ./access_log | awk '{print $11}' | tr -d '"' | sort | uniq -c | sort -rn | head -20
- tail -5000 ./access_log | awk '{freq[$11]++} END {for (x in freq) {print freq[x], x}}' | tr -d '"' | sort -rn | head -20
- # top 20 user agents from the last 5000 hits
- tail -5000 ./access_log | cut -d\ -f12- | sort | uniq -c | sort -rn | head -20
- # sum of data (in MB) transferred in the last 5000 hits
- tail -5000 ./access_log | awk '{sum+=$10} END {print sum/1048576}'
- ##############
- # Cisco Logs #
- ##############
- wget https://s3.amazonaws.com/StrategicSec-Files/LogAnalysis/cisco.log
- AWK Basics
- ----------
- - To quickly demonstrate the print feature in awk, we can instruct it to show only the 5th word of each line. Here we will print $5. Only the last 4 lines are being shown for brevity.
- cat cisco.log | awk '{print $5}' | tail -n 4
- - Looking at a large file would still produce a large amount of output. A more useful thing to do might be to output every entry found in “$5”, group them together, count them, then sort them from the greatest to least number of occurrences. This can be done by piping the output through “sort“, using “uniq -c” to count the like entries, then using “sort -rn” to sort it in reverse order.
- cat cisco.log | awk '{print $5}'| sort | uniq -c | sort -rn
- - While that’s sort of cool, it is obvious that we have some garbage in our output. Evidently we have a few lines that aren’t conforming to the output we expect to see in $5. We can insert grep to filter the file prior to feeding it to awk. This insures that we are at least looking at lines of text that contain “facility-level-mnemonic”.
- cat cisco.log | grep %[a-zA-Z]*-[0-9]-[a-zA-Z]* | awk '{print $5}' | sort | uniq -c | sort -rn
- - Now that the output is cleaned up a bit, it is a good time to investigate some of the entries that appear most often. One way to see all occurrences is to use grep.
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| awk '{print $10}' | sort | uniq -c | sort -rn
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10}' | sort | uniq -c | sort -rn
- cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10 " changed to " $14}' | sort | uniq -c | sort -rn
- ##############################################################
- # Intro to Bash Scripting #
- # #
- # Reference: #
- # https://www.panix.com/~elflord/unix/bash-tute.html #
- ##############################################################
- A quick guide to writing scripts using the bash shell
- A simple shell script
- A shell script is little more than a list of commands that are run in sequence. Conventionally, a shellscript should start with a line such as the following:
- #!/bin/bash
- This indicates that the script should be run in the bash shell regardless of which interactive shell the user has chosen. This is very important, since the syntax of different shells can vary greatly.
- A simple example
- Here's a very simple example of a shell script. It just runs a few simple commands
- #!/bin/bash
- echo "hello, $USER. I wish to list some files of yours"
- echo "listing files in the current directory, $PWD"
- ls # list files
- Firstly, notice the comment on line 4. In a bash script, anything following a pound sign # (besides the shell name on the first line) is treated as a comment. ie the shell ignores it. It is there for the benifit of people reading the script.
- $USER and $PWD are variables. These are standard variables defined by the bash shell itself, they needn't be defined in the script. Note that the variables are expanded when the variable name is inside double quotes. Expanded is a very appropriate word: the shell basically sees the string $USER and replaces it with the variable's value then executes the command.
- We continue the discussion on variables below ...
- Variables
- Any programming language needs variables. You define a variable as follows:
- X="hello"
- and refer to it as follows:
- $X
- More specifically, $X is used to denote the value of the variable X. Some things to take note of regarding semantics:
- bash gets unhappy if you leave a space on either side of the = sign. For example, the following gives an error message:
- X = hello
- while I have quotes in my example, they are not always necessary. where you need quotes is when your variable names include spaces. For example,
- X=hello world # error
- X="hello world" # OK
- This is because the shell essentially sees the command line as a pile of commands and command arguments seperated by spaces. foo=baris considered a command. The problem with foo = bar is the shell sees the word foo seperated by spaces and interprets it as a command. Likewise, the problem with the command X=hello world is that the shell interprets X=hello as a command, and the word "world" does not make any sense (since the assignment command doesn't take arguments).
- Single Quotes versus double quotes
- Basically, variable names are exapnded within double quotes, but not single quotes. If you do not need to refer to variables, single quotes are good to use as the results are more predictable.
- An example
- #!/bin/bash
- echo -n '$USER=' # -n option stops echo from breaking the line
- echo "$USER"
- echo "\$USER=$USER" # this does the same thing as the first two lines
- The output looks like this (assuming your username is elflord)
- $USER=elflord
- $USER=elflord
- so the double quotes still have a work around. Double quotes are more flexible, but less predictable. Given the choice between single quotes and double quotes, use single quotes.
- Using Quotes to enclose your variables
- Sometimes, it is a good idea to protect variable names in double quotes. This is usually the most important if your variables value either (a) contains spaces or (b) is the empty string. An example is as follows:
- #!/bin/bash
- X=""
- if [ -n $X ]; then # -n tests to see if the argument is non empty
- echo "the variable X is not the empty string"
- fi
- This script will give the following output:
- the variable X is not the empty string
- Why ? because the shell expands $X to the empty string. The expression [ -n ] returns true (since it is not provided with an argument). A better script would have been:
- #!/bin/bash
- X=""
- if [ -n "$X" ]; then # -n tests to see if the argument is non empty
- echo "the variable X is not the empty string"
- fi
- In this example, the expression expands to [ -n "" ] which returns false, since the string enclosed in inverted commas is clearly empty.
- Variable Expansion in action
- Just to convince you that the shell really does "expand" variables in the sense I mentioned before, here is an example:
- #!/bin/bash
- LS="ls"
- LS_FLAGS="-al"
- $LS $LS_FLAGS $HOME
- This looks a little enigmatic. What happens with the last line is that it actually executes the command
- ls -al /home/elflord
- (assuming that /home/elflord is your home directory). That is, the shell simply replaces the variables with their values, and then executes the command.
- Using Braces to Protect Your Variables
- OK. Here's a potential problem situation. Suppose you want to echo the value of the variable X, followed immediately by the letters "abc". Question: how do you do this ? Let's have a try :
- #!/bin/bash
- X=ABC
- echo "$Xabc"
- This gives no output. What went wrong ? The answer is that the shell thought that we were asking for the variable Xabc, which is uninitialised. The way to deal with this is to put braces around X to seperate it from the other characters. The following gives the desired result:
- #!/bin/bash
- X=ABC
- echo "${X}abc"
- Conditionals, if/then/elif
- Sometimes, it's necessary to check for certain conditions. Does a string have 0 length ? does the file "foo" exist, and is it a symbolic link , or a real file ? Firstly, we use the if command to run a test. The syntax is as follows:
- if condition
- then
- statement1
- statement2
- ..........
- fi
- Sometimes, you may wish to specify an alternate action when the condition fails. Here's how it's done.
- if condition
- then
- statement1
- statement2
- ..........
- else
- statement3
- fi
- alternatively, it is possible to test for another condition if the first "if" fails. Note that any number of elifs can be added.
- if condition1
- then
- statement1
- statement2
- ..........
- elif condition2
- then
- statement3
- statement4
- ........
- elif condition3
- then
- statement5
- statement6
- ........
- fi
- The statements inside the block between if/elif and the next elif or fi are executed if the corresponding condition is true. Actually, any command can go in place of the conditions, and the block will be executed if and only if the command returns an exit status of 0 (in other words, if the command exits "succesfully" ). However, in the course of this document, we will be only interested in using "test" or "[ ]" to evaluate conditions.
- The Test Command and Operators
- The command used in conditionals nearly all the time is the test command. Test returns true or false (more accurately, exits with 0 or non zero status) depending respectively on whether the test is passed or failed. It works like this:
- test operand1 operator operand2
- for some tests, there need be only one operand (operand2) The test command is typically abbreviated in this form:
- [ operand1 operator operand2 ]
- To bring this discussion back down to earth, we give a few examples:
- #!/bin/bash
- X=3
- Y=4
- empty_string=""
- if [ $X -lt $Y ] # is $X less than $Y ?
- then
- echo "\$X=${X}, which is smaller than \$Y=${Y}"
- fi
- if [ -n "$empty_string" ]; then
- echo "empty string is non_empty"
- fi
- if [ -e "${HOME}/.fvwmrc" ]; then # test to see if ~/.fvwmrc exists
- echo "you have a .fvwmrc file"
- if [ -L "${HOME}/.fvwmrc" ]; then # is it a symlink ?
- echo "it's a symbolic link
- elif [ -f "${HOME}/.fvwmrc" ]; then # is it a regular file ?
- echo "it's a regular file"
- fi
- else
- echo "you have no .fvwmrc file"
- fi
- Some pitfalls to be wary of
- The test command needs to be in the form "operand1<space>operator<space>operand2" or operator<space>operand2 , in other words you really need these spaces, since the shell considers the first block containing no spaces to be either an operator (if it begins with a '-') or an operand (if it doesn't). So for example; this
- if [ 1=2 ]; then
- echo "hello"
- fi
- gives exactly the "wrong" output (ie it echos "hello", since it sees an operand but no operator.)
- Another potential trap comes from not protecting variables in quotes. We have already given an example as to why you must wrap anything you wish to use for a -n test with quotes. However, there are a lot of good reasons for using quotes all the time, or almost all of the time. Failing to do this when you have variables expanded inside tests can result in very wierd bugs. Here's an example: For example,
- #!/bin/bash
- X="-n"
- Y=""
- if [ $X = $Y ] ; then
- echo "X=Y"
- fi
- This will give misleading output since the shell expands our expression to
- [ -n = ]
- and the string "=" has non zero length.
- A brief summary of test operators
- Here's a quick list of test operators. It's by no means comprehensive, but its likely to be all you'll need to remember (if you need anything else, you can always check the bash manpage ... )
- operator produces true if... number of operands
- -n operand non zero length 1
- -z operand has zero length 1
- -d there exists a directory whose name is operand 1
- -f there exists a file whose name is operand 1
- -eq the operands are integers and they are equal 2
- -neq the opposite of -eq 2
- = the operands are equal (as strings) 2
- != opposite of = 2
- -lt operand1 is strictly less than operand2 (both operands should be integers) 2
- -gt operand1 is strictly greater than operand2 (both operands should be integers) 2
- -ge operand1 is greater than or equal to operand2 (both operands should be integers) 2
- -le operand1 is less than or equal to operand2 (both operands should be integers) 2
- Loops
- Loops are constructions that enable one to reiterate a procedure or perform the same procedure on several different items. There are the following kinds of loops available in bash
- - for loops
- - while loops
- For loops
- The syntax for the for loops is best demonstrated by example.
- #!/bin/bash
- for X in red green blue
- do
- echo $X
- done
- The for loop iterates the loop over the space seperated items. Note that if some of the items have embedded spaces, you need to protect them with quotes. Here's an example:
- #!/bin/bash
- colour1="red"
- colour2="light blue"
- colour3="dark green"
- for X in "$colour1" $colour2" $colour3"
- do
- echo $X
- done
- Can you guess what would happen if we left out the quotes in the for statement ? This indicates that variable names should be protected with quotes unless you are pretty sure that they do not contain any spaces.
- Globbing in for loops
- The shell expands a string containing a * to all filenames that "match". A filename matches if and only if it is identical to the match string after replacing the stars * with arbitrary strings. For example, the character "*" by itself expands to a space seperated list of all files in the working directory (excluding those that start with a dot "." ) So
- echo *
- lists all the files and directories in the current directory.
- echo *.jpg
- lists all the jpeg files.
- echo ${HOME}/public_html/*.jpg
- lists all jpeg files in your public_html directory.
- As it happens, this turns out to be very useful for performing operations on the files in a directory, especially used in conjunction with a for loop. For example:
- #!/bin/bash
- for X in *.html
- do
- grep -L '<UL>' "$X"
- done
- While Loops
- While loops iterate "while" a given condition is true. An example of this:
- #!/bin/bash
- X=0
- while [ $X -le 20 ]
- do
- echo $X
- X=$((X+1))
- done
- This raises a natural question: why doesn't bash allow the C like for loops
- for (X=1,X<10; X++)
- As it happens, this is discouraged for a reason: bash is an interpreted language, and a rather slow one for that matter. For this reason, heavy iteration is discouraged.
- Command Substitution
- Command Substitution is a very handy feature of the bash shell. It enables you to take the output of a command and treat it as though it was written on the command line. For example, if you want to set the variable X to the output of a command, the way you do this is via command substitution.
- There are two means of command substitution: brace expansion and backtick expansion.
- Brace expansion workls as follows: $(commands) expands to the output of commands This permits nesting, so commands can include brace expansions
- Backtick expansion expands `commands` to the output of commands
- An example is given;:
- #!/bin/bash
- files="$(ls)"
- web_files=`ls public_html`
- echo "$files" # we need the quotes to preserve embedded newlines in $files
- echo "$web_files" # we need the quotes to preserve newlines
- X=`expr 3 \* 2 + 4` # expr evaluate arithmatic expressions. man expr for details.
- echo "$X"
- The advantage of the $() substitution method is almost self evident: it is very easy to nest. It is supported by most of the bourne shell varients (the POSIX shell or better is OK). However, the backtick substitution is slightly more readable, and is supported by even the most basic shells (any #!/bin/sh version is just fine)
- Note that if strings are not quote-protected in the above echo statement, new lines are replaced by spaces in the output.
- ##############################
- # Linux For InfoSec Homework #
- ##############################
- In order to receive your certificate of attendance you must complete the all of the quizzes on the http://linuxsurvival.com/linux-tutorial-introduction/ website.
- Submit the results via email in an MS Word document with (naming convention example: YourFirstName-YourLastName-Linux-For-InfoSec-Homework.docx)
- ##############################
- # Linux For InfoSe Challenge #
- ##############################
- In order to receive your certificate of proficiency you must complete all of the tasks covered in the Linux For InfoSec pastebin (http://pastebin.com/b5SxBRf6).
- Submit the results via email in an MS Word document with (naming convention example: YourFirstName-YourLastName-Linux-For-InfoSec-Challenge.docx)
- IMPORTANT NOTE:
- Your homework/challenge must be submitted via email to both (joe-at-strategicsec-.-com and kasheia-at-strategicsec-.-com) by Sunday October 16th at midnight EST.
- #########################################################################
- # What kind of Linux am I on and how can I find out? #
- # Great reference: #
- # https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/ #
- #########################################################################
- - What’s the distribution type? What version?
- -------------------------------------------
- cat /etc/issue
- cat /etc/*-release
- cat /etc/lsb-release # Debian based
- cat /etc/redhat-release # Redhat based
- - What’s the kernel version? Is it 64-bit?
- -------------------------------------------
- cat /proc/version
- uname -a
- uname -mrs
- rpm -q kernel
- dmesg | grep Linux
- ls /boot | grep vmlinuz-
- - What can be learnt from the environmental variables?
- ----------------------------------------------------
- cat /etc/profile
- cat /etc/bashrc
- cat ~/.bash_profile
- cat ~/.bashrc
- cat ~/.bash_logout
- env
- set
- - What services are running? Which service has which user privilege?
- ------------------------------------------------------------------
- ps aux
- ps -ef
- top
- cat /etc/services
- - Which service(s) are been running by root? Of these services, which are vulnerable - it’s worth a double check!
- ---------------------------------------------------------------------------------------------------------------
- ps aux | grep root
- ps -ef | grep root
- - What applications are installed? What version are they? Are they currently running?
- ------------------------------------------------------------------------------------
- ls -alh /usr/bin/
- ls -alh /sbin/
- dpkg -l
- rpm -qa
- ls -alh /var/cache/apt/archivesO
- ls -alh /var/cache/yum/
- - Any of the service(s) settings misconfigured? Are any (vulnerable) plugins attached?
- ------------------------------------------------------------------------------------
- cat /etc/syslog.conf
- cat /etc/chttp.conf
- cat /etc/lighttpd.conf
- cat /etc/cups/cupsd.conf
- cat /etc/inetd.conf
- cat /etc/apache2/apache2.conf
- cat /etc/my.conf
- cat /etc/httpd/conf/httpd.conf
- cat /opt/lampp/etc/httpd.conf
- ls -aRl /etc/ | awk '$1 ~ /^.*r.*/
- - What jobs are scheduled?
- ------------------------
- crontab -l
- ls -alh /var/spool/cron
- ls -al /etc/ | grep cron
- ls -al /etc/cron*
- cat /etc/cron*
- cat /etc/at.allow
- cat /etc/at.deny
- cat /etc/cron.allow
- cat /etc/cron.deny
- cat /etc/crontab
- cat /etc/anacrontab
- cat /var/spool/cron/crontabs/root
- - Any plain text usernames and/or passwords?
- ------------------------------------------
- grep -i user [filename]
- grep -i pass [filename]
- grep -C 5 "password" [filename]
- find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password" # Search for Joomla passwords
- - What NIC(s) does the system have? Is it connected to another network?
- ---------------------------------------------------------------------
- /sbin/ifconfig -a
- cat /etc/network/interfaces
- cat /etc/sysconfig/network
- - What are the network configuration settings? What can you find out about this network? DHCP server? DNS server? Gateway?
- ------------------------------------------------------------------------------------------------------------------------
- cat /etc/resolv.conf
- cat /etc/sysconfig/network
- cat /etc/networks
- iptables -L
- hostname
- dnsdomainname
- - What other users & hosts are communicating with the system?
- -----------------------------------------------------------
- lsof -i
- lsof -i :80
- grep 80 /etc/services
- netstat -antup
- netstat -antpx
- netstat -tulpn
- chkconfig --list
- chkconfig --list | grep 3:on
- last
- w
- - Whats cached? IP and/or MAC addresses
- -------------------------------------
- arp -e
- route
- /sbin/route -nee
- - Who are you? Who is logged in? Who has been logged in? Who else is there? Who can do what?
- ------------------------------------------------------------------------------------------
- id
- who
- w
- last
- cat /etc/passwd | cut -d: # List of users
- grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}' # List of super users
- awk -F: '($3 == "0") {print}' /etc/passwd # List of super users
- cat /etc/sudoers
- sudo -l
- - What sensitive files can be found?
- ----------------------------------
- cat /etc/passwd
- cat /etc/group
- cat /etc/shadow
- ls -alh /var/mail/
- - Anything “interesting” in the home directorie(s)? If it’s possible to access
- ----------------------------------------------------------------------------
- ls -ahlR /root/
- ls -ahlR /home/
- - Are there any passwords in; scripts, databases, configuration files or log files? Default paths and locations for passwords
- ---------------------------------------------------------------------------------------------------------------------------
- cat /var/apache2/config.inc
- cat /var/lib/mysql/mysql/user.MYD
- cat /root/anaconda-ks.cfg
- - What has the user being doing? Is there any password in plain text? What have they been edting?
- -----------------------------------------------------------------------------------------------
- cat ~/.bash_history
- cat ~/.nano_history
- cat ~/.atftp_history
- cat ~/.mysql_history
- cat ~/.php_history
- - What user information can be found?
- -----------------------------------
- cat ~/.bashrc
- cat ~/.profile
- cat /var/mail/root
- cat /var/spool/mail/root
- - Can private-key information be found?
- -------------------------------------
- cat ~/.ssh/authorized_keys
- cat ~/.ssh/identity.pub
- cat ~/.ssh/identity
- cat ~/.ssh/id_rsa.pub
- cat ~/.ssh/id_rsa
- cat ~/.ssh/id_dsa.pub
- cat ~/.ssh/id_dsa
- cat /etc/ssh/ssh_config
- cat /etc/ssh/sshd_config
- cat /etc/ssh/ssh_host_dsa_key.pub
- cat /etc/ssh/ssh_host_dsa_key
- cat /etc/ssh/ssh_host_rsa_key.pub
- cat /etc/ssh/ssh_host_rsa_key
- cat /etc/ssh/ssh_host_key.pub
- cat /etc/ssh/ssh_host_key
- - Any settings/files (hidden) on website? Any settings file with database information?
- ------------------------------------------------------------------------------------
- ls -alhR /var/www/
- ls -alhR /srv/www/htdocs/
- ls -alhR /usr/local/www/apache22/data/
- ls -alhR /opt/lampp/htdocs/
- ls -alhR /var/www/html/
- - Is there anything in the log file(s) (Could help with “Local File Includes”!)
- -----------------------------------------------------------------------------
- cat /etc/httpd/logs/access_log
- cat /etc/httpd/logs/access.log
- cat /etc/httpd/logs/error_log
- cat /etc/httpd/logs/error.log
- cat /var/log/apache2/access_log
- cat /var/log/apache2/access.log
- cat /var/log/apache2/error_log
- cat /var/log/apache2/error.log
- cat /var/log/apache/access_log
- cat /var/log/apache/access.log
- cat /var/log/auth.log
- cat /var/log/chttp.log
- cat /var/log/cups/error_log
- cat /var/log/dpkg.log
- cat /var/log/faillog
- cat /var/log/httpd/access_log
- cat /var/log/httpd/access.log
- cat /var/log/httpd/error_log
- cat /var/log/httpd/error.log
- cat /var/log/lastlog
- cat /var/log/lighttpd/access.log
- cat /var/log/lighttpd/error.log
- cat /var/log/lighttpd/lighttpd.access.log
- cat /var/log/lighttpd/lighttpd.error.log
- cat /var/log/messages
- cat /var/log/secure
- cat /var/log/syslog
- cat /var/log/wtmp
- cat /var/log/xferlog
- cat /var/log/yum.log
- cat /var/run/utmp
- cat /var/webmin/miniserv.log
- cat /var/www/logs/access_log
- cat /var/www/logs/access.log
- ls -alh /var/lib/dhcp3/
- ls -alh /var/log/postgresql/
- ls -alh /var/log/proftpd/
- ls -alh /var/log/samba/
- - Note: auth.log, boot, btmp, daemon.log, debug, dmesg, kern.log, mail.info, mail.log, mail.warn, messages, syslog, udev, wtmp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement