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
@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 / 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
<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
#!/bin/bash
systemctl stop firewalld
systemctl disable firewalld
systemctl stop postfix
systemctl disable postfix
systemctl stop NetworkManager
systemctl disable NetworkManager
#!/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
@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
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 / get-real-ip.sh
Last active October 16, 2019 15:32
Lấy IP thực của Domain đang trỏ về sử dụng DNS của Google.
#!/bin/bash
if [ -e $1 ] && [ ! $# -eq 0 ]
then
file=$1
list=`cat $file`
for dom in $list
do
ip_real=`dig +time=5 +short $dom @8.8.8.8 | head -n1`
echo "$ip_real, $dom"
#!/bin/bash
users=`cat /tmp/malware.detect | grep "tmp" | awk -F '/' {'print $3'}`
if [ -n "$users" ]
then
for x in $users
do
pid=`pgrep -u $x`
if [ -n "$pid" ]
#!/bin/bash
# Find execute files
mal=`find /home/*/.cagefs/tmp/ -type f -maxdepth 1 -executable 2> /dev/null`
# Writing to file
if [ -z "$mal" ]
then