Identify OS on remote host

For nmap to even make a guess, nmap needs to find at least 1 open and 1 closed port on a remote host. Using the previous scan results, let us find out more about the host 192.168.0.115: # nmap -O -sV 192.168.0.115 Output: Starting Nmap 7.80 ( https://nmap.org ) at 2020-10-02 12:21 CEST Nmap scan…

Clear Linux Cache

1. Clear PageCache only. # sync; echo 1 > /proc/sys/vm/drop_caches 2. Clear dentries and inodes. # sync; echo 2 > /proc/sys/vm/drop_caches 3. Clear PageCache, dentries and inodes. # sync; echo 3 > /proc/sys/vm/drop_caches nJoy 😉

Show all cronjobs for all users

This is a simple script to get all cronjbs for all users on a system for someone in $(cut -f1 -d: /etc/passwd); do echo $someone; crontab -u $someone -l ; done nJoy 😉  

Create windows 10 boot disk on almost any linux host

Mount the ISO: sudo mount -t udf -o loop,ro,unhide /path/to/file.iso /mnt Insert the USB drive. Run fdisk and specify the device name of the USB drive; for example: sudo fdisk /dev/sdc Delete any existing partition table and create a new one. Create a new partition of at least 4.5 GB. Mark it bootable and set…

Backup and Restore Elastic search

While elastic search is usually run as a cluster, for the sake of this tutorial I am showing the _snapshot and _restore tools.   mkdir /mnt/backups/my_backup chmod 777 -R /mnt/backups/ Must available on all nodes. curl -XPUT 'http://localhost:9200/_snapshot/my_backup' -d '{ "type": "fs", "settings": { "location": "/mnt/backups/my_backup", "compress": true } }' [root@centos-base mnt]# curl -XGET 'http://localhost:9200/_snapshot/my_backup?pretty'…

fstab entry for sshfs

Sample entry root@192.168.168.100:/mnt/streamstorage53/stage.k/ura/web /opt/kaltura/web fuse.sshfs _netdev,auto 0 0   nJoy 😉  

Auto-blacklist iptables

Gather a list of ips which fail logins and drop from firewall for the future lastb | awk '{ FS == "[ \t]+" ; print $3; }' | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'| grep -v "192.168." | sort | uniq | xargs -n 1 -I {} iptables -A INPUT -s {} -j DROP if you want to…

Replacing a piece of XML with awk

This script searches for an initial tag and and closing one and replaces the content. # !/bin/bash awk ‘ BEGIN {pr = 1;one = 0} /<Name>OPENING<\/Name>/ {pr = 0;} { if (pr) print } { if (!pr && !one) {print (“\t\t <Name>OPENING</Name> \n \t\t\t <Value>false</Value> \n \t\t<Type>STOPHERE</Type> \n ” ); one =1 ;}} /<Type>STOPHERE<\/Type>/ {pr…