BOOK THIS SPACE FOR AD
ARTICLE ADI have found myself way too many times forgetting certain commands, or how to perform specific actions related to bug hunting.
Solution: make a cheat sheet of all the useful commands.
And I figured, you may find it useful, or maybe you already know all of them by heart in which case, good for you. Either way, there are personal notes on some of the cheats which may give you insight into my way of thinking. For better or worse :)
Swap space (useful for msfconsole):
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04 — for processes getting killed, it may be due to out of memory issue, which means swap memory isn’t present, I actually used this for metasploit some time ago and then never did a reboot of my vps, and then I did which erased the swap file, and I’m not that interested in making it persistent change so just know to follow the above if/when rebooting, here’s the quicky:
You can first check if there is any swap memory enabled.
$sudo swapon -s
if it is empty, it means you don’t have any swap enabled. To add a 1GB swap:
$sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024k
$sudo mkswap /swapfile
$sudo swapon /swapfile
Add the following line to the fstab to make the swap permanent.
// not sure whether to do it yet or not for now just above
$sudo vim /etc/fstab
/swapfile none swap sw 0 0
RAM clearing (useful when things won’t start):
https://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/ —
for processes not wanting to start, it may be due to needing ram cleared, there are three ways, 1 is simple, 2 is advanced, and 3 is apparently better not to mess with just in case, here’s the quick command[as root]:
sync; echo 1 > /proc/sys/vm/drop_caches
For nginx/website/subdomain/etc.:
https://serverfault.com/questions/424452/nginx-enable-site-command
nmap and ports related:
For when I forget by any chance to start nmap or other long-running cmd inside screen, this is how to force it into a screen session:
https://twitter.com/hakluke/status/1149209144416583680
to open ports:
ufw allow 1234/tcp
Space management:
For docker (when I’m running out of space, it could be docker):
https://docs.docker.com/config/pruning/
For emptying files to save space:
echo * | xargs -n1 cp /dev/null // for ffuf outputs, massdns stuff, etc.
DNS Stuff (ssrf related, dns rebinding):
Disable and stop the systemd-resolved service:
sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved.
restarting:
systemctl restart systemd-resolved
DNS CACHE flushing:
systemd-resolve — statistics
systemd-resolve — flush-caches
For DNS Bind configuration (when I find a need to get into dns messing about again):
For tcpdump OOB DNS:
tcpdump -n port 53 --immediate-mode -l | grep "myserver.tk"
a bit better one, especially for logging so no worries with screen -r and buffer:
tcpdump -n port 53 --immediate-mode -l >> logtcp.txt & tail -f logtcp.txt | grep "myserver.tk"
ffuf related:
For ffuf output grep-ing:
cut -d',' -f2,5,6 *csv | grep ',200,' |more
For sorting by numbers (basically to help in figuring out fp-s from not fp-s with ffuf and cut):
sort -nk3 -t','
For uniq sorting where matching pairs are removed (both strings if they are same, not same as sort -u):
sort input.txt | uniq -u > output.txt
For pip3:
python3 -m pip install some_module (if pip3 install some_module isn’t working)
For bash scripting (not really vps specific, just figured makes sense to put it here):