syg2.4.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!/bin/bash
  2. #---------------------------------------------------------------#
  3. # RU: Пожелания и правки присылайте на hash.null @acetone #
  4. # EN: Send wishes and corrections to the hash.null @acetone #
  5. # #
  6. # SimpleYggGen v2.4, acetone, 2020. Russia. #
  7. #---------------------------------------------------------------#
  8. #-----------------КОНФИГУРАЦИЯ / CONFIGURATION------------------#
  9. # Set Yggdrasil binary path:
  10. # for Linux:
  11. YGGBIN=/usr/bin/yggdrasil
  12. # for Windows (running that script with MSYS2 (msys2.org):
  13. #YGGBIN="/c/Program Files/Yggdrasil/yggdrasil.exe"
  14. #
  15. # To enable non-special names uncomment that line:
  16. #nonspecial=true
  17. #
  18. # To enable system testing uncomment that line:
  19. runtest=true
  20. #
  21. #------------------------КОНЕЦ / END----------------------------#
  22. #---------------------------------------------------------------#
  23. #--ЛЮБЫЕ ИЗМЕНЕНИЯ В КОДЕ НИЖЕ ВЫ ДЕЛАЕТЕ НА СВОЙ СТРАХ И РИСК--#
  24. #-----ANY CHANGES IN THE CODE BELOW YOU DO AT YOUR OWN RISK-----#
  25. #---------------------------------------------------------------#
  26. test () {
  27. timestart=$(date '+%s')
  28. for (( c=1; c<101; c++ )); do
  29. tempconf=$("$YGGBIN" -genconf)
  30. EncryptionPublicKey=$(echo $tempconf | grep -w -o -E "EncryptionPublicKey: [0-9a-f]{64}")
  31. if [[ $c = 102 ]]; then
  32. echo '' > /dev/null
  33. fi
  34. echo -n -e "\e[36m Analyzing $c%\e[0m" \\r
  35. done
  36. timestop=$(date '+%s')
  37. final=$(($timestop-$timestart))
  38. if [[ "$final" -le "1" ]]; then
  39. color="\e[36m"
  40. elif [[ "$final" -le "2" ]]; then
  41. color="\e[32m"
  42. elif [[ "$final" -le "3" ]]; then
  43. color="\e[33m"
  44. else
  45. color="\e[31m"
  46. fi
  47. echo -n -e "$color Testing taken $final second(s)\e[0m\n\n"
  48. }
  49. log () {
  50. echo -e "Yggdrasil addresses list\\n$(date '+%Y-%m-%d %H:%M:%S')"\\n > ./syg.log
  51. if ( ls ./sygX* 2> /dev/null | grep 2 &> /dev/null ); then
  52. ls ./sygX* 2> /dev/null | tr -d syg | tr _ : | tr -d X >> ./syg.log 2> /dev/null
  53. echo '' >> ./syg.log
  54. liness=$(wc ./syg.log -l | cut -f1 -d' ' 2> /dev/null);
  55. tail -n $(($liness-2)) ./syg.log 2> /dev/null
  56. echo -e "\e[32m Names saved to syg.log\e[0m\n"
  57. else
  58. echo -e "\e[31m sygX* file not exist\e[0m\n"
  59. main
  60. exit 0
  61. fi
  62. }
  63. tars () {
  64. log
  65. tar -cf ./syg$(date '+%Y%m%d_%H%M').tar ./sygX* syg.log 2> /dev/null
  66. echo -e "\e[32m All addresses archived\e[0m\n"
  67. }
  68. intro () {
  69. clear
  70. echo -e "\e[38m"' '
  71. echo -e " ▒▒▒▒▒▒ ▒ ▒ ▒▒▒▒▒▒"
  72. sleep 0.05
  73. echo -e " ▒ ▒ ▒ ▒"
  74. sleep 0.05
  75. echo -e " ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒ ▒▒▒"
  76. sleep 0.05
  77. echo -e " ▒ ▒ ▒ ▒"
  78. sleep 0.05
  79. echo -e " ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒\e[0m"
  80. echo -e "\e[38m\n © SimpleYggGen v2.4\n acetone, 2020\e[0m\n"
  81. }
  82. main () {
  83. circle=0
  84. randomfortune=0
  85. sleep 0.03
  86. echo -e -n ' Target'"$color » \e[0m"
  87. read userinput
  88. if [[ $userinput = '' ]]; then
  89. target=::
  90. elif [[ $userinput == [lL][oO][gG] ]]; then
  91. log
  92. sleep 0.3
  93. main
  94. elif [[ $userinput == [tT][aA][rR] ]]; then
  95. tars
  96. sleep 0.3
  97. main
  98. elif [[ $userinput == [tT][aA][rR][dD][eE][lL] ]]; then
  99. tars
  100. rm -r ./sygX* 2> /dev/null
  101. echo -e "\e[33m Original files deleted\e[0m\n"
  102. sleep 0.3
  103. main
  104. elif [[ $userinput == *[g-zG-Zа-яА-Я\;\+\&\#\~\_\%\=\/]* ]]; then
  105. sleep 0.03
  106. echo -e " \e[31mIncorrect input\e[0m" \\n
  107. sleep 0.03
  108. main
  109. else
  110. target=$userinput
  111. fi
  112. if [[ $nonspecial == "true" ]]; then
  113. dirname=$(echo $target | tr \* S | tr \| I | tr : C | tr ^ U | tr $ D | tr - M | tr [ L | tr ] J | tr . T)
  114. else
  115. dirname=$target
  116. fi
  117. clear
  118. echo -e \\n" [$color$target\e[0m] $(date '+%Y.%m.%d %H:%M:%S')\n"
  119. tput civis
  120. for ((;;)); do
  121. tempconf=$("$YGGBIN" -genconf)
  122. EncryptionPublicKey=$(echo $tempconf | grep -w -o -E "EncryptionPublicKey: [0-9a-f]{64}")
  123. if ( echo $EncryptionPublicKey | "$YGGBIN" -address -useconf | grep -i -E "$target" &> /dev/null ); then
  124. EncryptionPrivateKey=$(echo $tempconf | grep -w -o -E "EncryptionPrivateKey: [0-9a-f]{64}")
  125. yggsubnet=$(echo $EncryptionPublicKey | "$YGGBIN" -subnet -useconf)
  126. yggaddress=$(echo $EncryptionPublicKey | "$YGGBIN" -address -useconf)
  127. mkdir ./sygX$dirname &> /dev/null
  128. sygnamefile=$(echo $yggaddress | tr : _)
  129. echo -e "# Address: $yggaddress\n# Subnet: $yggsubnet\n\n# Change it to yggdrasil.conf\n $EncryptionPublicKey\n $EncryptionPrivateKey\n\n# SimpleYggGen v2.4 [$(date '+%Y-%m-%d %H:%M:%S')] \n# Check new version: https://cloud.disroot.org/s/TA63PBsQ6Z7dfGW" > ./sygX$dirname/$sygnamefile
  130. randomfortune=$(($randomfortune+1))
  131. fi
  132. circle=$(($circle+1))
  133. echo -n -e " \e[35m$circle/\e[0m$randomfortune \e[32m$yggaddress\e[0m " \\r
  134. done
  135. }
  136. # Start script execution
  137. intro
  138. # Run test if enabled
  139. if [[ $runtest == "true" ]]; then
  140. test
  141. else
  142. color="\e[37m"
  143. fi
  144. # Start interactive
  145. main