From 415ba843c0dc66bcb84ae0fbd239b40b6818896b Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Mon, 23 May 2022 19:45:10 +0530 Subject: minor changes + added old scripts --- .scripts/bts | 2 +- .scripts/cht.sh | 12 +++++++++ .scripts/compile_ | 12 +++++++++ .scripts/shar256rec | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100755 .scripts/cht.sh create mode 100755 .scripts/compile_ create mode 100755 .scripts/shar256rec diff --git a/.scripts/bts b/.scripts/bts index 7b85aac..014444f 100755 --- a/.scripts/bts +++ b/.scripts/bts @@ -1,6 +1,6 @@ #!/bin/bash option=$(echo -e "Connect\nDisconnect\nChange profile"| dmenu -p "Do you wish to connect/disconnect or change soundprofile of your bluetooth device:") -MAC=$(echo "A1:B3:EC:B1:53:60") +MAC=$(echo "76:67:11:36:64:A2") case $option in "Connect") status=$(systemctl status bluetooth | grep Active | cut -d " " -f 7) diff --git a/.scripts/cht.sh b/.scripts/cht.sh new file mode 100755 index 0000000..2b724c0 --- /dev/null +++ b/.scripts/cht.sh @@ -0,0 +1,12 @@ +#!/bin/sh +languages=`echo "cpp c python rust golang lua typescript" | tr ' ' '\n'` +core_utils=`echo "xargs find mv sed awk" | tr ' ' '\n'` + +selected=`printf "$languages\n$core_utils" | fzf` +read -p "query: " query + +if printf $languages | grep -qs $selected; then + curl cht.sh/$selected/`echo $query | tr ' ' '+' | bat` +else + curl cht.sh/$selected~$query | bat +fi diff --git a/.scripts/compile_ b/.scripts/compile_ new file mode 100755 index 0000000..abd9b9f --- /dev/null +++ b/.scripts/compile_ @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "enter a correct .cpp file" + exit +else + file="$1" +fi +output=$(echo "$1" | cut -d "." -f1) +echo "$file" +echo "$output" +g++ -o $output $file -lstdc++ diff --git a/.scripts/shar256rec b/.scripts/shar256rec new file mode 100755 index 0000000..de39c4e --- /dev/null +++ b/.scripts/shar256rec @@ -0,0 +1,70 @@ +#!/bin/bash +#recursive sha256sum script for an entire directory + + #FUNCTIONS OR FUNCTYOU? + function s_readonly { err=$(date +%s%N); cd "$1"; mkdir $err 2> /tmp/$err; rmdir $err 2>/dev/null; echo $(cat /tmp/$err|grep -i "Read-only file system"|wc -l);shred -n 0 -uz /tmp/$err; } + function w_denied { echo $(err=$(date +%s%N); cd "$1"; mkdir $err 2> /tmp/$err; rmdir $err 2>/dev/null; cat /tmp/$err|grep -i "Permission denied"|wc -l;shred -n 0 -uz /tmp/$err); } + function r_denied { echo $(err=$(date +%s%N); cd "$1" >/dev/null 2> /tmp/$err; find . >/dev/null 2>> /tmp/$err; cat /tmp/$err|grep -i "Permission denied"|wc -l;shred -n 0 -uz /tmp/$err); } + function rando_name { rando=$(echo $(date +%s%N)|sha256sum|awk '{print $1}'); rando=${rando::$(shuf -i 30-77 -n 1)}; echo $rando;} + function ms0 { ms0=$(($(date +%s%N)/1000000)); }; function mstot { echo $(($(($(date +%s%N)/1000000))-$ms0));} + function s0 { s0=$(date +%s); }; function stot { echo $(($(date +%s)-$s0));} + s0 + + #CHECK IF A TARGET DIR WAS SPECIFIED (-t= or --target= switch) + if [ ! -z "$1" ]; then arg1="$1"; arg1_3=${arg1::3}; arg1_9=${arg1::9};fi + if [ "$arg1_3" = "-t=" -o "$arg1_9" = "--target=" ]; then + switch=$(echo $arg1|awk -F '=' '{print $1}') + switch_chr=$((${#switch}+1)) + target=${arg1:$switch_chr} + current=$(pwd) + cd "$target" + arg1="" #<- cancels the not path in the find line + else + current=$(pwd) + target=$(pwd) + fi + + echo -e "=======================================================================\ + \nsha256rec: \ + \n=======================================================================\ + \nCurrent Folder : $current \ + \nTarget Folder : $target" + + #GETS DEFAULT_USER, ASSUME'S YOU'RE USER 1000, IF 1000 DOESN'T EXIST SEARCHES 999, THEN 1001, 1002 + default_user=$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd) + if [ -z "$default_user" ]; then default_user=$(awk -v val=999 -F ":" '$3==val{print $1}' /etc/passwd); fi + if [ -z "$default_user" ]; then default_user=$(awk -v val=1001 -F ":" '$3==val{print $1}' /etc/passwd); fi + if [ -z "$default_user" ]; then default_user=$(awk -v val=1002 -F ":" '$3==val{print $1}' /etc/passwd); fi + + if [ "$(users | wc -l)" = "1" ]; then USER=$(users|awk '{print $1}'); else USER=$default_user;fi #not perfect but meh... + + #running rando_name in this very specific spot between USER detection and Permission detection, some interfers somehow with detection functions... + #the rando function placed underneath the user detection is somehow turning c=$current from the dir path to whatever rando_name puts out. + + #FIGURE OUT WHERE TO PUT HASH LIST + hash_file="000_sha256sum_recurs_${target##*/}_d_$(date +%d-%m-20%y)_t_$(date +%H.%M).txt" + if [ $(s_readonly "$current") -gt 0 -o $(w_denied "$current") -gt 0 ]; then if [ "$(whoami)" != root ]; then dest="/home/$(whoami)";echo -e "Output File : $dest/$hash_file\n\n";echo "Seems you're currently in either a Read-Only system or a root owned directory as a regular user. You can find the hash results in your home folder."; else dest="/home/$USER";echo -e "Output File : $dest/$hash_file\n\n";echo "Seems you're currently a Read-Only system. You can find the hash results in $USER's home folder.";fi; else dest="$current";echo -e "Output File : $dest/$hash_file\n\n";echo "Results will be saved here.";fi + + + + #CAN REGULAR USER ACCESS TARGET DIR? ARE ALL IT'S SUBDIRS READABLE? + if [ $(r_denied "$target") -gt 0 ]; then sudo=sudo; echo "Some folder were not read-able as a regular user. User elevation will be required.";fi + + #PERFORM RECURSIVE HASHING + command=$($sudo find . -type f -not -type l -not -path "$arg1" -not -path "$2" -not -path "$3" -not -path "$4" -not -path "$5" -not -path "$6" -not -path "$7" -not -path "$8" -not -path "$9" |grep -v "\./000_sha"|sort|awk "{print \"$sudo sha256sum \\\"\"\$0}"|awk '{print $0"\""}'|tr '\n' ';') + eval $command > "$dest/$hash_file" + + sha256sum "$dest/$hash_file" + echo "Operation Length: $(stot) Seconds." + echo -e "=======================================================================" + + + + if [ "$target" != "$current" ]; then cd "$current";fi + + + exit + #|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| + #|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| + #|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| + #|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -- cgit v1.2.3