initial commit via gitinitshit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
[ "root" != "$USER" ] && exec sudo $0 "$@"
|
||||
#usage sudo sh add_site_apache2.sh 192.168.1.1 example.com
|
||||
#note: the web server will go down for the duration this script is running
|
||||
#set needed A records to domain DNS before beginning
|
||||
#bind IP desired before beginning
|
||||
|
||||
IP=$1
|
||||
DOMAIN=$2
|
||||
|
||||
#stop apache
|
||||
systemctl stop apache2
|
||||
|
||||
#cert get interface
|
||||
certbot certonly
|
||||
|
||||
mkdir /var/www/$DOMAIN
|
||||
echo "<h1>its live</h1>" > /var/www/$DOMAIN/index.html
|
||||
|
||||
#make and place config file
|
||||
cat << EOF | echo > /etc/apache2/sites-available/{$DOMAIN}.config
|
||||
<VirtualHost {$IP}:443>
|
||||
DocumentRoot /var/www/{$DOMAIN}
|
||||
ServerName $DOMAIN
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/letsencrypt/live/{$DOMAIN}/fullchain.pem
|
||||
SSLCertificateKeyFile /etc/letsencrypt/live/{$DOMAIN}/privkey.pem
|
||||
SSLProtocol all -SSLv2 -SSLv3
|
||||
SSLHonorCipherOrder on
|
||||
SSLCipherSuite "HIGH:!aNULL:!MD5:!3DES:!CAMELLIA:!AES128"
|
||||
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost {$IP}:80>
|
||||
ServerName $DOMAIN
|
||||
Redirect permanent / https://{$DOMAIN}/
|
||||
</VirtualHost>
|
||||
EOF
|
||||
|
||||
a2ensite $DOMAIN
|
||||
sh fix_permissions.sh
|
||||
systemctl start apache2
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# usage:
|
||||
# add_user_ssh.sh "$USER" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP2D+9oYQlTnu1zeVi2gHfTKE7+DDWiu1EibXNwB9g72 princesspi@proton.me"
|
||||
|
||||
[ "root" != "$USER" ] && exec sudo $0 "$@"
|
||||
KEY="$2"
|
||||
mkdir /home/$1/.ssh
|
||||
echo $KEY >> /home/$1/.ssh/authorized_keys
|
||||
chmod 700 /home/$1/.ssh
|
||||
chmod 600 /home/$1/.ssh/authorized_keys
|
||||
chown -R $1:$1 /home/$1/.ssh
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
[ "root" != "$USER" ] && exec sudo $0 "$@"
|
||||
LOCK=/var/lock/backups.lock
|
||||
if [ ! -f $LOCK ]; then
|
||||
echo "lock" > $LOCK
|
||||
rsync -rzvvb --backup-dir=_old_ --suffix=$(date+_%F-%T) --update --times -e ssh /home/ <username>@<server>:~/backups/home
|
||||
rm -f $LOCK
|
||||
fi
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
# usage
|
||||
# binwalk.sh filename [default/opcodes/basicextract/compressionextract/opcodeextract
|
||||
set -e
|
||||
filename="$2"
|
||||
unix_seconds=$(date +%s)
|
||||
dir="binwalk-exracted-$filename-$unix_seconds"
|
||||
log="binwalk-log-$filename-$unix_seconds.txt"
|
||||
|
||||
basic="Bf"
|
||||
basicextract="Bef"
|
||||
compressionextract="BeMXZCf"
|
||||
opcodecompressextract="ABeMXZCf"
|
||||
opcodeextract="ABeCf"
|
||||
opcode="ABf"
|
||||
|
||||
basic_cmd="--signature"
|
||||
basicextract_cmd="--signature --extract --directory=$dir"
|
||||
compressionextract_cmd="--signature --extract --matryoshka --deflate --lzma --directory=$dir"
|
||||
opcodecompressextract_cmd="--opcodes --signature --extract --matryoshka --deflate -lzma --directory=$dir"
|
||||
opcodeextract_cmd="--opcodes --signature --extract --directory=$dir"
|
||||
opcode_cmd="--opcodes --signature"
|
||||
|
||||
usage_string="Usage:\n\tbinwalk.sh <option> <file>\n\t\tb/d/basic/default\n\t\to/op/opcode/opcodes\n\t\tbe/eb/basicextract/extractbasic\n\t\tce/ec/compressionextract/extractcompression\n\t\tope/oce/oec/opcodecompressionextract\n\t\toe/eo/opcodeextract/extractopcode"
|
||||
|
||||
if [ "$1" == "o" -o "$1" == "opcode" -o "$1" == "opcodes" -o "$1" == "op" ]; then
|
||||
tag="$opcode"
|
||||
cmd="$opcode_cmd"
|
||||
elif [ "$1" == "d" -o "$1" == "default" -o "$1" == "b" -o "$1" == "basic" ]; then
|
||||
tag="$basic"
|
||||
cmd="$basic_cmd"
|
||||
elif [ "$1" == "be" -o "$1" == "basicextract" -o "$1" == "eb" -o "$1" == "extractbasic" ]; then
|
||||
tag="$basicextract"
|
||||
cmd="$basicextract_cmd"
|
||||
elif [ "$1" == "ce" -o "$1" == "compressionextract" -o "$1" == "ec" -o "$1" == "extractcompression" ]; then
|
||||
tag="$compressionextract"
|
||||
cmd="$compressionextract_cmd"
|
||||
elif [ "$1" == "oce" -o "$1" == "opcodecompressionextract" -o "$1" == "eoc" -o "$1" == "oec" ]; then
|
||||
tag="$opcodecompressextract"
|
||||
cmd="$opcodecompressextract_cmd"
|
||||
elif [ "$1" == "oe" -o "$1" == "opcodeextract" -o "$1" == "eo" -o "$1" == "extractopcode" ]; then
|
||||
tag="$opcodeextract_cmd"
|
||||
cmd="$opcodeextract_cmd"
|
||||
else
|
||||
echo -e "$usage_string"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo -e $cmd
|
||||
|
||||
if [ -z $2 ]; then
|
||||
echo -e "$usage_string"
|
||||
exit
|
||||
fi
|
||||
|
||||
to_run="binwalk $cmd --log=$log"
|
||||
eval($to_run)
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
echo "Enter Discord Webhook URL"
|
||||
read url
|
||||
echo "Enter Tag to Notify"
|
||||
read tag
|
||||
sudo bash -c "echo '$url' > /usr/share/customscripts/webhook.txt"
|
||||
sudo bash -c "echo '$tag' > /usr/share/customscripts/tag.txt"
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Showing Wifi Interfaces:"
|
||||
iwconfig
|
||||
echo "Please Enter Wifi Interface:"
|
||||
read interface
|
||||
else
|
||||
interface="$1"
|
||||
fi
|
||||
|
||||
echo "Scanning Wifi Networks"
|
||||
nmcli dev wifi list
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
echo "Please Enter SSID"
|
||||
read ssid
|
||||
else
|
||||
ssid="$2"
|
||||
fi
|
||||
|
||||
if [ -z "$3" ]; then
|
||||
echo "Please Enter Password"
|
||||
read password
|
||||
else
|
||||
password="$2"
|
||||
fi
|
||||
|
||||
echo -e "\n\nConnect to $ssid with password $password on interface $interface \n\n"
|
||||
pause
|
||||
|
||||
echo "Running ./fix-wifi.sh"
|
||||
sudo bash ./fix-wifi.sh $interface
|
||||
|
||||
echo "Rescanning"
|
||||
nmcli dev wifi rescan
|
||||
|
||||
echo "Connecting to $ssid"
|
||||
nmcli device wifi connect $ssid password $password ifname $interface # --rescan yes
|
||||
|
||||
echo -e "\nnyaa mrrp done~ :D\n"
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
#Crowdsec Install and config
|
||||
curl -s https://packagecloud.io/install/repositories/crowdsec/crowdsec/script.deb.sh | sudo bash
|
||||
apt -y install crowdsec
|
||||
truncate -s 0 /var/log/crowdsec.log
|
||||
#configure bouncers as needed here https://hub.crowdsec.net/browse/#bouncers
|
||||
apt -y install crowdsec-firewall-bouncer-iptables
|
||||
cscli collections install crowdsecurity/base-http-scenarios
|
||||
cscli bouncers add php-bouncer
|
||||
systemctl reload crowdsec
|
||||
#cscli bouncers add <nginx-bouncer php-bouncer wordpress-bouncer cloudflare-bouncer> #as needed
|
||||
# SAVE API KEY, THEY ARE UNRECOVERABLE
|
||||
#for wordpress: install crowdsec plugin in admin panel
|
||||
# SAVE API KEY FROM INSTALL
|
||||
# add API key
|
||||
# LAPIU URL: http://localhost:8080
|
||||
#for cpanel
|
||||
#cscli scenarios install crowdsecurity/cpanel-bf
|
||||
|
||||
#unban an IP
|
||||
#cscli decisions list
|
||||
#cscli decisions delete --id <id number from list>
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" -o -z "$2" ]; then
|
||||
echo -e "usage:\n\tbash find_bytes.sh <path> <bytes string>\n\t\tex. bash find_bytes.sh /path/to/dir \"\\\x20\\\x20\""
|
||||
exit
|
||||
fi
|
||||
|
||||
# took a fuckton of experimentation to figure out da escapes lmfao
|
||||
double_bytes="$2" # rename it
|
||||
path=$1 # rename it
|
||||
|
||||
# format ddmmyyyy-HHMM-SS
|
||||
log="./recursive-binwalk-$(date +"%d%m%Y-%H%M-%S").txt" # make da log name
|
||||
|
||||
# watch your escapes here. some needs escape, redundant escape, or no escape
|
||||
find "$path" -type f -exec /bin/bash -c "cmd=\"binwalk --log=$log --raw=$double_bytes {}\"; echo -e \"\n\n==\nfile: {}\nlog: $log\ncommand: \$(printf \\\"%q\\\" \$cmd)\" | tee -a $log; exec \$cmd" \;
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Showing Wifi Interfaces:"
|
||||
iwconfig
|
||||
echo "Please Enter Wifi Interface:"
|
||||
read wifi_device
|
||||
echo "Selected ${wifi_device}"
|
||||
else
|
||||
wifi_device="$1"
|
||||
fi
|
||||
|
||||
# wifi_device=$1
|
||||
|
||||
echo 'Starting NetworkManager.service'
|
||||
sudo systemctl restart NetworkManager
|
||||
|
||||
echo 'Restarting wpa_supplicant'
|
||||
sudo systemctl restart wpa_supplicant
|
||||
|
||||
echo 'Disconnecting from wifi'
|
||||
sudo nmcli d disconnect $wifi_device
|
||||
|
||||
echo 'Deleting all wifi saved networks'
|
||||
nmcli connection show | sudo awk '{system("nmcli connection delete " $1)}'
|
||||
|
||||
echo 'Bringing down interface'
|
||||
sudo ifconfig $wifi_device down
|
||||
|
||||
echo 'Bringing back up interface'
|
||||
sudo ifconfig $wifi_device up
|
||||
|
||||
echo 'Reloading network manager'
|
||||
sudo nmcli g reload
|
||||
|
||||
echo 'Turning off network manager'
|
||||
sudo nmcli n off
|
||||
|
||||
echo 'Turning on network manager'
|
||||
sudo nmcli n on
|
||||
|
||||
echo 'Changing interface mode to managed'
|
||||
sudo iwconfig $wifi_device mode managed
|
||||
|
||||
echo 'Restarting networking stack'
|
||||
sudo systemctl restart networking
|
||||
|
||||
iwconfig
|
||||
|
||||
echo -e "\nDone~ ^w^\n"
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
[ "root" != "$USER" ] && exec sudo $0 "$@"
|
||||
chown -R www-data:www-data /var/www/*
|
||||
find /var/www/* -type d -exec chmod g=rwx "{}" \;
|
||||
find /var/www/* -type f -exec chmod g=rw "{}" \;
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -e # die on any error
|
||||
|
||||
# get current directory name without the path
|
||||
reponame=${PWD##*/}
|
||||
|
||||
# init to main branch (github default)
|
||||
git init -b main
|
||||
git add .
|
||||
git commit -m "initial commit via gitinitshit"
|
||||
|
||||
# use github cli to create repo with the dir name
|
||||
gh repo create "$thisdirname" --public --source=. --remote=upstream --push
|
||||
|
||||
# print git link and url
|
||||
git remote -v | sed -n -e 1p | awk '{print "\ngit link:", $2; gsub(".git", "", $2); print "repo url:", $2, "\n"}'
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -e # fail on error
|
||||
|
||||
if [ -f './version.txt' ]; then
|
||||
message=$(cat './version.txt')
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
message=$(date +%s)
|
||||
else
|
||||
message="$*"
|
||||
fi
|
||||
fi
|
||||
|
||||
git add .
|
||||
git commit -m "$message"
|
||||
git push
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
# sync a local git repo with a remote one over ssh
|
||||
# usage: gitsync <remote_host> <remote_dir>
|
||||
# defaults pi3 and /var/www/html/Media-Viewer
|
||||
|
||||
# handle defaultz
|
||||
handle_args () {
|
||||
if [ -z $1 ]; then
|
||||
remote_host='pi3'
|
||||
else
|
||||
remote_host="$1"
|
||||
fi
|
||||
|
||||
if [ -z $2 ]; then
|
||||
remote_dir='/var/www/html/Media-Viewer'
|
||||
else
|
||||
remote_dir="$2"
|
||||
fi
|
||||
}
|
||||
|
||||
syncstatus () {
|
||||
# view local and remote status before proceeding
|
||||
echo -e "\nLOCAL status\n"
|
||||
git status
|
||||
|
||||
echo -e "\nREMOTE status\n"
|
||||
ssh $remote_host "/bin/bash -c git -C $remote_dir status"
|
||||
}
|
||||
|
||||
gitsync () {
|
||||
# todo: param and defaults these up
|
||||
# todo: format this properly as multiline
|
||||
$remote_cmd = "echo -e \"\nREMOTE pull $remote_dir\n\"; git -C $remote_dir pull; echo -e \"\nREMOTE adding on $remote_dir\n\"; git -C $remote_dir add .; echo -e \"\nREMOTE commit $remote_dir\n\"; git -C $remote_dir commit -m \"autosync $(date +%s)\"; echo -e \"\nREMOTE push $remote_dir\n\"; git -C $remote_dir push; echo -e \"\nREMOTE status $remote_dir\n\"; git -C $remote_dir status;"
|
||||
|
||||
echo -e "\nLOCAL pulling\n"
|
||||
git pull
|
||||
|
||||
echo -e "\nLOCAL adding, comitting and pushing\n"
|
||||
git add .
|
||||
git commit -m "autosync $(date +%s)"
|
||||
git push
|
||||
|
||||
echo -e "\nLOCAL status\n"
|
||||
git status
|
||||
|
||||
# run da REMOTE shiz
|
||||
echo -e "\nREMOTE running sync\n"
|
||||
ssh $remote_host "/bin/bash -c \"$remote_cmd\""
|
||||
|
||||
echo -e "\nLOCAL status\n"
|
||||
git status
|
||||
}
|
||||
|
||||
handle_args
|
||||
syncstatus
|
||||
gitsync
|
||||
syncstatus
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# from https://askubuntu.com/questions/3299/how-to-run-cron-job-when-network-is-up
|
||||
# usage in cron
|
||||
## @reboot bash /usr/share/customscripts/ifnet "/usr/share/customscripts/webhook bootup" 2>> /var/log/cron.error.log
|
||||
function check_online
|
||||
{
|
||||
netcat -z -w 5 discord.com 80 && echo 1 || echo 0
|
||||
}
|
||||
|
||||
# Initial check to see if we are online
|
||||
IS_ONLINE=$(check_online)
|
||||
# How many times we should check if we're online - this prevents infinite looping
|
||||
MAX_CHECKS=10
|
||||
# Initial starting value for checks
|
||||
CHECKS=0
|
||||
|
||||
echo "running! IS_ONLINE: $IS_ONLINE"
|
||||
|
||||
# Loop while we're not online.
|
||||
while [[ $IS_ONLINE -eq 0 ]]; do
|
||||
sleep 10;
|
||||
echo "is_online: $IS_ONLINE loop $CHECKS"
|
||||
IS_ONLINE=check_online
|
||||
|
||||
CHECKS=$(($CHECKS + 1))
|
||||
if [ $CHECKS -gt $MAX_CHECKS ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $IS_ONLINE -eq 0 ]]; then
|
||||
# We never were able to get online. Kill script.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bash $1 2>> /var/log/cron.error.log
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
# set -e # make sure da silly thing dont continue when there be errorZ
|
||||
|
||||
gitRepo='https://gitlab.com/princesspi/general-scripts-and-system-ssssssetup.git'
|
||||
tmpDir='/tmp/customscripts'
|
||||
finalDir='/usr/share/customscripts'
|
||||
|
||||
echo "Updating software lists"
|
||||
sudo apt update
|
||||
|
||||
echo "Installan my packages"
|
||||
sudo apt install gh net-tools htop btop iptraf iotop screen byobu wget python3 python3-pip python3-virtualenv python3-setuptools thefuck nginx wget lynx neovim nmap -y
|
||||
|
||||
echo "Using Shell $SHELL"
|
||||
|
||||
# ta get da right usermayhaps
|
||||
if [[ -z $SUDO_USER ]]; then
|
||||
echo "Using User $USER"
|
||||
username="$USER"
|
||||
else
|
||||
echo "Using User $SUDO_USER"
|
||||
username="$SUDO_USER"
|
||||
fi
|
||||
|
||||
# figure oot da sehell
|
||||
if [[ "$SHELL" =~ bash$ ]]; then
|
||||
rcfile="/home/$username/.bashrc"
|
||||
elif [[ "$SHELL" =~ zsh$ ]]; then
|
||||
rcfile="/home/$username/.zshrc"
|
||||
else
|
||||
echo -e "Die: Unsupported Shell";
|
||||
exit
|
||||
fi
|
||||
|
||||
# clean up any existing install
|
||||
if [[ -d "$tmpDir" ]]; then
|
||||
echo "Cleaning Up Existing $tmpDir"
|
||||
rm -rf "$tmpDir"
|
||||
fi
|
||||
|
||||
if [[ -d "$finalDir" ]]; then
|
||||
echo "Cleaning Up Existing $finalDir"
|
||||
rm -rf "$finalDir"
|
||||
fi
|
||||
|
||||
echo "Cloning Repo $gitRepo"
|
||||
git clone $gitRepo $tmpDir --single-branch --depth 1
|
||||
|
||||
echo "Placing in $finalDir"
|
||||
mv "$tmpDir/customscripts" "$finalDir"
|
||||
|
||||
echo "Changing ownership of $finalDir to $username:$username recursively"
|
||||
chown -R $username:$username "$finalDir"
|
||||
|
||||
echo "Setting perms of $finalDir and contents to 775"
|
||||
chmod -R 775 "$finalDir"
|
||||
|
||||
grep -q $finalDir $rcfile
|
||||
pathgrep=$?
|
||||
|
||||
if [ $pathgrep -eq 0 ]; then
|
||||
echo "$finalDir Already in \$PATH Skipping"
|
||||
else
|
||||
echo "Adding $finalDir to $username's \$PATH by Appending to $rcfile"
|
||||
echo -e "\n\n# automatically added by customscripts installer\nexport PATH=\"\$PATH:$finalDir\"" >> "$rcfile"
|
||||
fi
|
||||
|
||||
# configure webhook
|
||||
# echo "Enter Discord Webhook URL"
|
||||
# read url
|
||||
# echo "Enter Tag to Notify"
|
||||
# read tag
|
||||
# sudo bash -c "echo '$url' > /usr/share/customscripts/webhook.txt"
|
||||
# sudo bash -c "echo '$tag' > /usr/share/customscripts/tag.txt"
|
||||
|
||||
echo -e "\n\nDone! Restart shell:\n\texec \$SHELL\n\n"
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
< passes.txt parallel --block 10M -C 5 --pipe grep --count --max-count=1 --fixed-strings $1
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
# usage
|
||||
# bash watch.sh /path/t/dir processname logfile
|
||||
set -e
|
||||
|
||||
if [ -z $1 ]; then
|
||||
dir='.'
|
||||
else
|
||||
dir=$1
|
||||
fi
|
||||
|
||||
if [ -z $2 ]; then
|
||||
process_name='none'
|
||||
else
|
||||
process_name=$2
|
||||
fi
|
||||
|
||||
if [ ! -f $3 ]; then
|
||||
log_name=/dev/null
|
||||
else
|
||||
log_name=$3
|
||||
fi
|
||||
|
||||
# uptime
|
||||
uptime_dirty=$(uptime | awk '{print $3,$4}')
|
||||
uptime_cleaned=${uptime_dirty:0:-1}
|
||||
|
||||
# date and time (default date command)
|
||||
# ex. Sat May 17 11:36:04 PM MDT 2025
|
||||
date_time=$(date)
|
||||
|
||||
echo -e "Uptime: $uptime_cleaned\t\tTime: $date_time\n"
|
||||
|
||||
# list filenames ordered by size large to small
|
||||
list_files=$(ls -lAhS $dir | awk '{print $9}')
|
||||
eval "list_files_names=($list_files)"
|
||||
# echo -e "\nda names\n${list_files_names[1]}\n\n"
|
||||
|
||||
# size (human) ordered by size large to small
|
||||
list_human=$(ls -lAhS $dir | awk '{print $5}')
|
||||
eval "list_files_human=($list_human)"
|
||||
# echo -e "\nda humans\n${list_files_human[1]}\n\n"
|
||||
|
||||
# size (bytes) ordered by size large to small
|
||||
list_bytes=$(du -d 1 $dir/* | awk '{print $1}' | sort -r -n)
|
||||
eval "list_files_bytes=($list_bytes)"
|
||||
# echo -e "\nda bytes\n${list_files_bytes[1]}\n\n"
|
||||
|
||||
echo -e "Size (h)\tBytes\tName"
|
||||
|
||||
count=0
|
||||
for name in ${list_files_names[@]}; do
|
||||
echo -e "${list_files_human[$count]}\t\t${list_files_bytes[$count]} \t$name"
|
||||
count=$(($count + 1))
|
||||
done
|
||||
|
||||
# pid
|
||||
list_processes_pid=$(ps aux | grep $process_name | awk '{print $2}')
|
||||
eval "list_processes_pid=($list_processes_pid)"
|
||||
# echo -e "\nda pids\n${list_processes_pid[1]}\n\n"
|
||||
|
||||
# %CPU usage
|
||||
list_processes_cpu=$(ps aux | grep $process_name | awk '{print $3}')
|
||||
eval "list_processes_cpu=($list_processes_cpu)"
|
||||
# echo -e "\nda cpu%\n${list_processes_cpu[1]}\n\n"
|
||||
|
||||
# %MEMORY usage
|
||||
list_processes_mem=$(ps aux | grep $process_name | awk '{print $4}')
|
||||
eval "list_processes_mem=($list_processes_mem)"
|
||||
# echo -e "\nda mem%\n${list_processes_mem[1]}\n\n"
|
||||
|
||||
# process names
|
||||
list_processes_name=$(ps aux | grep $process_name | awk '{print $12,$13,$14,$15,$16,$17,$18}' | sed 's/\s/_/g')
|
||||
eval "list_processes_name=($list_processes_name)"
|
||||
# echo -e "\nda name\n${list_processes_name[1]}\n\n"
|
||||
|
||||
echo -e "\nPID\t\t%MEM\t%CPU\tNAME"
|
||||
count=0
|
||||
for name in ${list_processes_name[@]}; do
|
||||
echo -e "${list_processes_pid[$count]}\t\t${list_processes_mem[$count]}%\t${list_processes_cpu[$count]}%\t$name"
|
||||
count=$(($count + 1))
|
||||
done
|
||||
|
||||
echo -e "\n$log_name"
|
||||
tail -10 $log_name
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
if [ -z $1 ]; then
|
||||
echo -e "Usage:\n\tmonitor_pid \"MESSAGE\""
|
||||
exit
|
||||
fi
|
||||
|
||||
pid=$1
|
||||
|
||||
clear
|
||||
echo -e "\nMonitoring for process PID $pid to end"
|
||||
|
||||
# get da webhook tag
|
||||
tag=$(cat /usr/share/customscripts/tag.txt)
|
||||
|
||||
# infinite loop
|
||||
while [ 1 -eq 1 ]; do
|
||||
# check for da pid
|
||||
ps -q $pid > /dev/null
|
||||
ret=$?
|
||||
|
||||
# check if the process exists via retcode of the ps -q $pid
|
||||
if [ $ret -ne 0 ]; then
|
||||
webhook "Process $pid Ended at $(date)! \n\t$tag"
|
||||
echo "Process $pid Ended at $(date)! \n\t$tag"
|
||||
exit
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
done
|
||||
@@ -0,0 +1,25 @@
|
||||
# run automatic installer
|
||||
curl -fsSL https://pyenv.run | bash
|
||||
|
||||
# append relevant bits to ~/.zshrc
|
||||
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
|
||||
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
|
||||
echo 'eval "$(pyenv init - zsh)"' >> ~/.zshrc
|
||||
|
||||
# restart shell
|
||||
exec "$SHELL"
|
||||
|
||||
pyenv install # CUSTOM STUFFS
|
||||
# pico SDK https://github.com/raspberrypi/pico-sdk
|
||||
export PICO_SDK_PATH='/home/kali/pico-sdk'
|
||||
|
||||
# esp-install-custom https://github.com/PrincessPi3/esp-install-custom
|
||||
alias get_idf='. /home/princesspi/esp/esp-idf/export.sh'
|
||||
alias run_esp_reinstall='git -C /home/princesspi/esp/esp-install-custom pull;echo -e "\nOld Version:";tail -1 /home/pri>alias esp_monitor='tail -n 75 -f /home/princesspi/esp/install.log'
|
||||
alias esp_logs='less /home/princesspi/esp/version-data.log;less /home/princesspi/esp/install.log'
|
||||
export ESPIDF_INSTALLDIR="/home/princesspi/esp"
|
||||
|
||||
# pyenv https://github.com/pyenv/pyenv
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
eval "$(pyenv init - zsh)"
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
set -e # fail on error
|
||||
|
||||
# default to scan pwd if arg 1 is empty
|
||||
if [ -z $1 ]; then
|
||||
scan_path="$PWD"
|
||||
else
|
||||
scan_path="$1"
|
||||
fi
|
||||
|
||||
# configure dir structure
|
||||
analysis_dir="recursive-analysis" # top level
|
||||
file_dir="$analysis_dir/file"
|
||||
strings_dir="$analysis_dir/strings"
|
||||
sha256sum_dir="$analysis_dir/sha256sum"
|
||||
binwalk_dir="$analysis_dir/binwalk"
|
||||
|
||||
# make the directory structure if absent or fail without error
|
||||
mkdir -p "$file_dir" "$strings_dir" "$sha256sum_dir" "$binwalk_dir"
|
||||
|
||||
# log paths
|
||||
timestamp=$(date +"%Y%m%d-%H%M-%S-%Z") # format YYYYmmdd-HHMM-SS-TZ
|
||||
log_main="./recursive-log.txt"
|
||||
log_binwalk="$binwalk_dir/recursive-binwalk-$timestamp.txt"
|
||||
log_file="$file_dir/recursive-file-$timestamp.txt"
|
||||
log_strings="$strings_dir/recursive-strings-hex-offsets-$timestamp.txt"
|
||||
log_sha256sum="$sha256sum_dir/recursive-sha256sum-$timestamp.txt"
|
||||
|
||||
# full command except filename
|
||||
pre_cmd_binwalk="binwalk"
|
||||
pre_cmd_file="file"
|
||||
strings_len=8
|
||||
pre_cmd_strings="strings --bytes=$strings_len --print-file-name --radix=x"
|
||||
pre_cmd_sha256sum="sha256sum"
|
||||
|
||||
echo -e "\nRunning Princess Pi's Recursive Analysis on $scan_path at $timestamp\n\tMaster log: $log_main\n"
|
||||
|
||||
# do da scanssss
|
||||
## binwalk
|
||||
echo "Recursive binwalk! Saving to $log_binwalk . . ."
|
||||
find "$scan_path" -type f \
|
||||
-not -path "*/.git/*" \
|
||||
-not -path "*/__pycache__/*" \
|
||||
-not -path "*/recursive-analysis/*" \
|
||||
-exec /bin/bash -c "cmd=\"$pre_cmd_binwalk {}\" && echo -e \"File: {}\nCommand: \$cmd\nTimestamp: $timestamp\" >> $log_binwalk && exec \$cmd >> $log_binwalk" \; # watch your escapes here
|
||||
|
||||
## file
|
||||
echo "Recursive file! Saving to $log_file . . ."
|
||||
find "$scan_path" -type f \
|
||||
-not -path "*/.git/*" \
|
||||
-not -path "*/__pycache__/*" \
|
||||
-not -path "*/recursive-analysis/*" \
|
||||
-exec $pre_cmd_file {} >> $log_file \;
|
||||
|
||||
## strings
|
||||
echo "Recursive strings! Saving to $log_strings . . ."
|
||||
find "$scan_path" -type f \
|
||||
-not -path "*/.git/*" \
|
||||
-not -path "*/__pycache__/*" \
|
||||
-not -path "*/recursive-analysis/*" \
|
||||
-exec $pre_cmd_strings {} >> $log_strings \;
|
||||
|
||||
## sha256sum
|
||||
echo "Recursive sha256sum! Saving to $log_sha256sum . . ."
|
||||
find "$scan_path" -type f \
|
||||
-not -path "*/.git/*" \
|
||||
-not -path "*/__pycache__/*" \
|
||||
-not -path "*/recursive-analysis/*" \
|
||||
-exec $pre_cmd_sha256sum {} >> $log_sha256sum \;
|
||||
|
||||
# log to master log
|
||||
echo -e "$timestamp:\n\tscan path: $scan_path\n\tbinwalk:\n\t\tlog: $log_binwalk\n\t\tcmd: $pre_cmd_sha256sum {}\n\tfile:\n\t\tlog: $log_file\n\t\tcmd: $pre_cmd_file {}\n\tstrings:\n\t\tlog: $log_strings\n\t\tcmd: $pre_cmd_strings {}\n\tsha256sum:\n\t\tlog: $log_sha256sum\n\t\tcmd: $pre_cmd_sha256sum {}\n" >> $log_main
|
||||
|
||||
echo -e "\nDone! :3"
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# helper to show status of git repos on both local and a remote host
|
||||
# usage: syncstatus <remote_host> <remote_directiory>
|
||||
# defaults pi3 and /var/www/html/Media-Viewer
|
||||
|
||||
# handle defaultz
|
||||
handle_args () {
|
||||
if [ -z $1 ]; then
|
||||
remote_host='pi3'
|
||||
else
|
||||
remote_host="$1"
|
||||
fi
|
||||
|
||||
if [ -z $2 ]; then
|
||||
remote_dir='/var/www/html/Media-Viewer'
|
||||
else
|
||||
remote_dir="$2"
|
||||
fi
|
||||
}
|
||||
|
||||
syncstatus () {
|
||||
# view local and remote status before proceeding
|
||||
echo -e "\nLOCAL status\n"
|
||||
git status
|
||||
|
||||
echo -e "\nREMOTE status\n"
|
||||
ssh $remote_host "/bin/bash -c \"git -C '$remote_dir' status\""
|
||||
}
|
||||
|
||||
handle_args
|
||||
syncstatus
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
git add .
|
||||
git commit -m "waypoint"
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# usage in cron
|
||||
## @reboot bash /usr/share/customscripts/ifnet "/usr/share/customscripts/webhook bootup" 2>> /var/log/cron.error.log
|
||||
# discord_webhook="https://discord.com/api/webhooks/yourwebhook"
|
||||
discord_webhook=$(cat /usr/share/customscripts/webhook.txt)
|
||||
ipaddr=$(hostname -I | grep -E -o "10.0.0.[0-9]{1,3}" | tail -1)
|
||||
date=$(date "+%d/%m/%Y %H:%M:%S %Z (%s)")
|
||||
# to tag role run \@rolename and copy the code that is like <@something>
|
||||
# tag="<@tag>"
|
||||
tag=$(cat /usr/share/customscripts/tag.txt)
|
||||
hostname=$(hostname)
|
||||
bootup_string="bootrred on $date\n\tip addr: $ipaddr\n\t$tag\n\n"
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
content='Default Ping!'
|
||||
elif [[ "$1" == "bootup" ]]; then
|
||||
content="$bootup_string"
|
||||
else
|
||||
content="$1"
|
||||
fi
|
||||
|
||||
post_data() {
|
||||
cat <<EOF
|
||||
{
|
||||
"username":"$hostname",
|
||||
"content":"$content"
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
curl -H "Content-Type: application/json" -X POST -d "$(post_data)" "$discord_webhook"
|
||||
@@ -0,0 +1,3 @@
|
||||
sudo airmon-ng check kill
|
||||
sudo airmon-ng start wlan1
|
||||
sudo airodump-ng wlan1mon
|
||||
@@ -0,0 +1,7 @@
|
||||
port=$(grep '^port=33' /etc/xrdp/xrdp.ini | sed 's/port=//')
|
||||
ip=$(ip addr | grep 'inet 10.\|inet 192.168.' | awk '{print $2}' | sed 's/\/24//')
|
||||
|
||||
sudo /etc/xrdp/startwm.sh
|
||||
sudo systemctl restart xrdp
|
||||
echo "connect on $ip:$port"
|
||||
|
||||
Reference in New Issue
Block a user