first commit
This commit is contained in:
85
profiles/base/.local/bin/check_ip
Executable file
85
profiles/base/.local/bin/check_ip
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
set -o nounset
|
||||
|
||||
readonly SCRIPT_NAME="${0##*/}"
|
||||
|
||||
check_deps() {
|
||||
command -v "curl" >/dev/null 2>&1 || die "curl: command not found"
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: ${SCRIPT_NAME} [--family auto|4|6] [-h|--help]
|
||||
|
||||
Query an external service using curl and print:
|
||||
1) public IP address
|
||||
2) reverse DNS (PTR record)
|
||||
3) curl version
|
||||
|
||||
Options:
|
||||
--family auto|4|6 select IP protocol version (default: auto)
|
||||
-h, --help show help and exit
|
||||
EOF
|
||||
}
|
||||
|
||||
shell_quote() {
|
||||
local -r string="$1"
|
||||
printf "'%s'" "${string//'/'\\''}"
|
||||
}
|
||||
|
||||
die() {
|
||||
local -r message="$1"
|
||||
printf "%s: %b\n" "${SCRIPT_NAME}" "${message}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
invalid_option() {
|
||||
local -r option="$1"
|
||||
die "invalid option $(shell_quote "${option}")\nTry '${SCRIPT_NAME} --help' for usage."
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
family="auto"
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
-h|--help) usage; exit 0 ;;
|
||||
--family)
|
||||
( (( $# < 2 )) || [[ -z "$2" ]] ) && die "--family requires an argument (auto, 4 or 6)"
|
||||
family="$2"
|
||||
shift 2
|
||||
;;
|
||||
--family=*)
|
||||
family="${1#*=}"
|
||||
[[ -z "${family}" ]] && die "--family requires an argument (auto, 4 or 6)"
|
||||
shift
|
||||
;;
|
||||
*) invalid_option "$1" ;;
|
||||
esac
|
||||
done
|
||||
validate_args
|
||||
}
|
||||
|
||||
validate_args() {
|
||||
case "${family}" in
|
||||
auto|4|6) ;;
|
||||
*) die "invalid value for family: '${family}' (expected auto, 4 or 6)"
|
||||
esac
|
||||
}
|
||||
|
||||
show_ip() {
|
||||
local -a curl_args=()
|
||||
[[ ${family} == "4" ]] && curl_args=( "-4" )
|
||||
[[ ${family} == "6" ]] && curl_args=( "-6" )
|
||||
curl "${curl_args[@]}" "zx2c4.com/ip"
|
||||
}
|
||||
|
||||
main() {
|
||||
check_deps
|
||||
parse_args "$@"
|
||||
show_ip
|
||||
}
|
||||
|
||||
main "$@"
|
||||
138
profiles/base/.local/bin/dnsleaktest
Executable file
138
profiles/base/.local/bin/dnsleaktest
Executable file
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env bash
|
||||
#usage: ./dnsleaktest.sh [-i interface_ip|interface_name]
|
||||
#example: ./dnsleaktest.sh -i eth1
|
||||
# ./dnsleaktest.sh -i 10.0.0.2
|
||||
|
||||
RED='\033[0;31m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
api_domain='bash.ws'
|
||||
error_code=1
|
||||
|
||||
getopts "i:" opt
|
||||
interface=$OPTARG
|
||||
|
||||
function echo_bold {
|
||||
echo -e "${BOLD}${1}${NC}"
|
||||
}
|
||||
|
||||
if [ -z "$interface" ]; then
|
||||
curl_interface=""
|
||||
ping_interface=""
|
||||
else
|
||||
curl_interface="--interface ${interface}"
|
||||
ping_interface="-I ${interface}"
|
||||
echo_bold "Interface: ${interface}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
function increment_error_code {
|
||||
error_code=$((error_code + 1))
|
||||
}
|
||||
|
||||
function echo_error {
|
||||
(>&2 echo -e "${RED}${1}${NC}")
|
||||
}
|
||||
|
||||
function require_command {
|
||||
command -v $1 > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_error "Please, install \"$1\""
|
||||
exit $error_code
|
||||
fi
|
||||
increment_error_code
|
||||
}
|
||||
|
||||
function check_internet_connection {
|
||||
curl --silent --head ${curl_interface} --request GET "https://${api_domain}" | grep "200 OK" > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo_error "No internet connection."
|
||||
exit $error_code
|
||||
fi
|
||||
increment_error_code
|
||||
}
|
||||
|
||||
require_command curl
|
||||
require_command ping
|
||||
check_internet_connection
|
||||
|
||||
if command -v jq &> /dev/null; then
|
||||
jq_exists=1
|
||||
else
|
||||
jq_exists=0
|
||||
fi
|
||||
|
||||
id=$(curl ${curl_interface} --silent "https://${api_domain}/id")
|
||||
|
||||
for i in $(seq 1 10); do
|
||||
ping -c 1 ${ping_interface} "${i}.${id}.${api_domain}" > /dev/null 2>&1
|
||||
done
|
||||
|
||||
function print_servers {
|
||||
|
||||
if (( $jq_exists )); then
|
||||
|
||||
echo ${result_json} | \
|
||||
jq --monochrome-output \
|
||||
--raw-output \
|
||||
".[] | select(.type == \"${1}\") | \"\(.ip)\(if .country_name != \"\" and .country_name != false then \" [\(.country_name)\(if .asn != \"\" and .asn != false then \" \(.asn)\" else \"\" end)]\" else \"\" end)\""
|
||||
|
||||
else
|
||||
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" != *${1} ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
ip=$(echo $line | cut -d'|' -f 1)
|
||||
code=$(echo $line | cut -d'|' -f 2)
|
||||
country=$(echo $line | cut -d'|' -f 3)
|
||||
asn=$(echo $line | cut -d'|' -f 4)
|
||||
|
||||
if [ -z "${ip// }" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -z "${country// }" ]; then
|
||||
echo "$ip"
|
||||
else
|
||||
if [ -z "${asn// }" ]; then
|
||||
echo "$ip [$country]"
|
||||
else
|
||||
echo "$ip [$country, $asn]"
|
||||
fi
|
||||
fi
|
||||
done <<< "$result_txt"
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if (( $jq_exists )); then
|
||||
result_json=$(curl ${curl_interface} --silent "https://${api_domain}/dnsleak/test/${id}?json")
|
||||
else
|
||||
result_txt=$(curl ${curl_interface} --silent "https://${api_domain}/dnsleak/test/${id}?txt")
|
||||
fi
|
||||
|
||||
dns_count=$(print_servers "dns" | wc -l)
|
||||
|
||||
echo_bold "Your IP:"
|
||||
print_servers "ip"
|
||||
|
||||
echo ""
|
||||
if [ ${dns_count} -eq "0" ];then
|
||||
echo_bold "No DNS servers found"
|
||||
else
|
||||
if [ ${dns_count} -eq "1" ];then
|
||||
echo_bold "You use ${dns_count} DNS server:"
|
||||
else
|
||||
echo_bold "You use ${dns_count} DNS servers:"
|
||||
fi
|
||||
print_servers "dns"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo_bold "Conclusion:"
|
||||
print_servers "conclusion"
|
||||
|
||||
exit 0
|
||||
8
profiles/base/.local/bin/iommu_groups
Executable file
8
profiles/base/.local/bin/iommu_groups
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
shopt -s nullglob
|
||||
for g in $(find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V); do
|
||||
echo "IOMMU Group ${g##*/}:"
|
||||
for d in ${g}/devices/*; do
|
||||
echo -e "\t$(lspci -nns ${d##*/})"
|
||||
done;
|
||||
done;
|
||||
6
profiles/base/.local/bin/transfer
Executable file
6
profiles/base/.local/bin/transfer
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
transfer() (if [ $# -eq 0 ]; then printf "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>\n">&2; return 1; fi; file_name=$(basename "$1"); if [ -t 0 ]; then file="$1"; if [ ! -e "$file" ]; then echo "$file: No such file or directory">&2; return 1; fi; if [ -d "$file" ]; then cd "$file" || return 1; file_name="$file_name.zip"; set -- zip -r -q - .; else set -- cat "$file"; fi; else set -- cat; fi; url=$("$@" | curl --silent --show-error --progress-bar --upload-file "-" "https://transfer.sh/$file_name"); echo "$url"; )
|
||||
|
||||
transfer
|
||||
|
||||
Reference in New Issue
Block a user