I have collected some Linux commands and tricks that Red Team can use for their evil deeds. All these commands and tricks have been tested against Ubuntu 16.04 server and attackers computer is Kali Linux 2019.3.
Legal disclaimer
The methods are presented for educational purposes only. You are responsible for not using the techniques for illegal purposes.
Label meanings
[victim ip address] means add your target IP address example 127.0.0.1 [victim ip address zone] means add your target IP address zone example 10.1.1.0/24 [decoy ip address] means add a decoy address that you want to frame to be the attacker example 127.0.0.2 [domain] means add a victim domain example localhost [username] means add a username example admin [attacker domain] means add a hostile computer’s ip address example 127.0.0.3 [target folder/file] means add a target folder or file that you want to change example /home/username/newfile [source folder/file] means add a source folder or file that you want to use as reference example /bin
Scanning and denying
Nmap
Nmap is a network scanning tool.
Scan 1000 most common ports. Delay is about 1 second.
Scan all ports aggressively
Try to determine Operation system. Scan 1000 most common ports and try to determine service and version.
Scan insane fast in parallel and use decoys. In a target computer it looks like 3 different IP addresses are trying to scan it ports.
Hydra
Hydra is a brute force tool.
Brute forcing SSH account. Try to brute force 4 length password that contains only letters a and o. Delay is 1 second. Brute forcing is stopped if correct username and password is found.
Slowhttptest
Slowlori attack is opening connections to HTTP server and keeps connections open. This makes web server to be very slow or unreachable.
Open 1000 connection and send only unfinished HTTP requests. Open 200 new connections per second and keep connections open by sending GET method in every 10 second with maximum length of 24 and wait 3 seconds for response.
DOS
Take lot of TCP connections to target
Send much as possible TCP connections to target to port 21 and change source address to a decoy IP address. Flood by sending 10000 packets using SYN flag and data size is 120.
Reverse shells
Bash reverse shell
In attacker’s computer listen 51920 port using Netcat
Victim is connecting to attacker and opening reverse shell
You can also create a script that will try to open a reverse shell in every 5 minute
Reverse shell using PHP site
Install Apache and PHP to victim’s computer and create PHP file that will open a reverse shell when the page is requested by HTTP protocol.
In attacker’s computer listen 51920 port using Netcat and send HTTP request to malicious site. With HTTP request the victim’s computer will open the reverse shell
This is how you can give password using only one line example in reverse shell
Python site reverse shell and fake it to look like CUPS
Give a sudo rights to user nobody without need to give a password
Fake Python to look like CUPS, create a Python script and start a Python server
If you would NMAP victim’s computer with default options it would look like ipp(CUPS) service is running
In attacker’s computer listen 51920 port using Netcat and send HTTP request to malicious site
SSH tricks and stealing passwords
SSH listening different port using reverse shell
Add PORT 2222 end of the /etc/ssh/sshd_config
Restart SSH daemon
Now you can take SSH to port 2222
SSH Public Key Authentication
Create key pair on hostile’s computer, move public key to victim’s computer and take SSH connection to it
On victim’s computer modify sshd_config allow the root to login, change SSH to find public keys also from /etc/ssh/authorized_keys and move public key to that location.
Now you can take SSH connection without password using root (or any other user) from hostile computer
Steal SSH password using bashrc
Modify bash.bashrc so it looks like first password went wrong and you need to write it again, but actually it steals victim’s password and adds it to a file
Add these line to end of the bash.bashrc file
Sudo alias and steal sudo password
This needs permanent solution to add alias and better way to do cut
Create file that asks sudo password, runs the last command and steals the password and adds it to a file
Give execute permissions to that file and give the script to sudo alias
Now every time victim is running sudo [command] script asks password, steals the password and runs the command what victim wanted to run.
After this we can hide this alias modification by modifying the alias command
Cleaning your evil deeds
Erasing history
Remove old history
Clean session history and exit
Link history to /dev/null so history does not save anything
Clean logs
Delete all useful log files
Folder and File time modifications
Check a folder or a file creation and modification time
Change a folder or a file creation and modification time to YYYYMMDDhhmm
Change a folder or a file modification time to YYYYMMDDhhmm
Copy creation and modification time from other file or folder
List all files that has been changed in 7 days
List all folders that has been changed in 7 days
Change creation and modification time for all files that has been modified in 7 days
Change creation and modification time for all folders that has been modified in 7 days
Copy creation and modification time for all files that has been modified in 7 days. Source folder could be something like /bin
UNDER THIS DOES NOT WORK YEAT
Get SSH credentials using strace
strace with reverse shell
strace with ssh
grepping the password and username
DNS tunneling
Server to listen
Client
SPAM mail
Windows create traffic using curl
https://linux.die.net/man/1/knockd
AXFR query using tcp connection to port 53