Skip to content

Instantly share code, notes, and snippets.

View hoangdh's full-sized avatar
🏠
Working from home

Dao Huy Hoang hoangdh

🏠
Working from home
View GitHub Profile
#!/bin/bash
ENCODER="-c:v libx264 -b:v 1.5M -preset superfast -tune zerolatency -c:a aac -ar 44100"
ENCODER2="-c:v libx264 -b:v 1.5M -pix_fmt yuv420p -c:a aac -strict experimental -b:a 192k -ac 2"
genPort() {
while
port=$(shuf -n 1 -i 49152-65535)
netstat -atun | grep -q "$port"
do
@hoangdh
hoangdh / install-SSLFree-multiDomain.sh
Last active March 7, 2020 04:52
Install SSL Free (Let's Encrypt) for Zimbra's Virtualhosts.
#!/bin/bash
### Check A record and add virtualhost to Zimbra
domains="$1"
server=$(dig +short a `hostname -f`)
flag=0
for dom in $domains
do
dom=`echo "$dom" | tr '[:upper:]' '[:lower:]'`
#!/bin/bash
if [ -n "$1" ]
then
sudo iptables -I INPUT -s $1 -j DROP -m comment --comment "Block. Reason: $2"
echo "This IP ($1) has been blocked by $2"
else
echo -e "Usage: ./$0 <ip> <reason>\nExample: ./$0 1.2.3.4 \"Bruteforce site abc.com\""
fi
#!/bin/bash
systemctl stop firewalld
systemctl disable firewalld
systemctl stop postfix
systemctl disable postfix
systemctl stop NetworkManager
systemctl disable NetworkManager
<VirtualHost *:80>
DocumentRoot "/opt/ctds"
<Directory /opt/ctds>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName nangtam.vn
ServerAlias *.nangtam.vn
ErrorLog ${APACHE_LOG_DIR}/ctds-error.log
@hoangdh
hoangdh / get-mx-record.sh
Last active May 25, 2019 02:24
Script get MX records.
#!/bin/bash
FILE="$1"
data=`cat $FILE`
filename=$(echo kq-`date +%H:%M:%S-%d.%m-%Y`.txt)
touch $filename
for x in $data
do
@hoangdh
hoangdh / auto-mount.sh
Last active March 7, 2020 04:52
Tự động mount và chuyển dữ liệu từ /home sang disk mới
#!/bin/bash
# Dinh dang mac dinh cua phan vung moi
FORMAT='ext4'
## Liet ke danh sach disk chua duoc phan vung
disks=`parted -l 2>&1 > /dev/null | awk -F ':' {'print $2'} | grep -Ev '[0-9]$|Warning|Read-only'`
## Phan vung; dinh dang disk (ext4)
for d in $disks
@hoangdh
hoangdh / add-swap.sh
Created October 29, 2018 07:06
Auto add SWAP.
#!/bin/bash
### Get current swap size
info=`free -m | grep "Swap:"`
size_cur=$(echo $info | awk {'print $2'})
echo -e "Current swap size: $size_cur"
read -p "Enter new size (Unit: MB): " size_new
@hoangdh
hoangdh / ip-to-country.sh
Last active October 30, 2018 09:59
Trace IP SYN Flood to country
#!/bin/bash
####
#
# Count IP send SYN's flag
#
####
list=`netstat -npt | grep SYN_RECV | awk {'print $5'} | cut -d':' -f1`;
for x in $list;
@hoangdh
hoangdh / download-vtvgiaitri.sh
Created November 6, 2018 14:46
Tải film từ VTV Giải trí.
#!/bin/bash
regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]'
if [ -e $1 ]
then
lists=`cat $1`
for x in $lists
do
name=`echo $x | grep -Eo '?.*?\.mp4' | awk -F '/' {'print $NF'}`
ffmpeg -i "$x" -c copy $name
done