ppek

setRDP.v1

Apr 13th, 2025
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #!/bin/bash
  2. set -e # Exit immediately if a command exits with a non-zero status
  3.  
  4. # Define color variables
  5. RED='\e[31m'
  6. GREEN='\e[32m'
  7. YELLOW='\e[33m'
  8. BLUE='\e[34m'
  9. NC='\e[0m' # No Color
  10.  
  11. # Check for root privileges
  12. if [ "$EUID" -ne 0 ]; then
  13. echo -e "${RED}This script must be run as root. Use 'sudo' to execute it.${NC}"
  14. exit 1
  15. fi
  16.  
  17. # Function to prompt for OS selection
  18. select_os() {
  19. while true; do
  20. echo -e "${BLUE} Amboyyy :${NC}"
  21. echo -e "${YELLOW}1) Windows 10 GS DigitalOcean${NC}"
  22. echo -e "${YELLOW}2) Windows 2016${NC}"
  23. echo -e "${YELLOW}3) Windows 2012${NC}"
  24. read -p "Enter choice : " os_choice
  25. if [[ "$os_choice" =~ ^[1-3]$ ]]; then
  26. break
  27. else
  28. echo -e "${RED}Invalid selection. Please enter 1 or 2.${NC}"
  29. fi
  30. done
  31.  
  32. if [ "$os_choice" == "1" ]; then
  33. img_url='joko/win10.gz'
  34. elif [ "$os_choice" == "2" ]; then
  35. img_url='joko/win2016.gz'
  36. elif [ "$os_choice" == "3" ]; then
  37. img_url='https://www.dropbox.com/scl/fi/o4qtxtms0oi16pbaghlt6/w2012r2.gz?rlkey=d2dk9acg868b7mi0wzpfg30cx&st=jjxieok7&dl=1'
  38. fi
  39. }
  40.  
  41. # Function to prompt for password
  42. prompt_password() {
  43. default_password="Warning1@"
  44. while true; do
  45. echo -e "${GREEN}Enter RDP password (press enter for default: ${default_password}):${NC}"
  46. read -p "" user_password
  47. password=${user_password:-$default_password}
  48. break
  49.  
  50. # Password strength check
  51. # if [[ "$password" =~ ^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{8,}$ ]]; then
  52. # break
  53. # else
  54. # echo -e "${RED}Password must be at least 8 characters long and include uppercase, lowercase, and numbers.${NC}"
  55. # fi
  56. done
  57. }
  58.  
  59. # Download reinstall.sh
  60. download_reinstall_script() {
  61. echo -e "${BLUE}Downloading reinstall.sh...${NC}"
  62. if ! curl -# -O https://raw.githubusercontent.com/kripul/reinstall/main/reinstall.sh && ! wget --progress=bar:force -O reinstall.sh https://raw.githubusercontent.com/kripul/reinstall/main/reinstall.sh; then
  63. echo -e "${RED}Failed to download reinstall.sh. Exiting.${NC}"
  64. exit 1
  65. fi
  66. }
  67.  
  68. # Execute the reinstall script
  69. execute_reinstall_script() {
  70. echo -e "${GREEN}Executing reinstall script...${NC}"
  71. bash reinstall.sh dd \
  72. --rdp-port 6969 \
  73. --password "$password" \
  74. --img "$img_url"
  75. }
  76.  
  77. # Confirm reboot
  78. confirm_reboot() {
  79. read -p "Are you sure you want to reboot now? (y/n): " confirm_reboot
  80. if [[ "$confirm_reboot" == "y" || "$confirm_reboot" == "Y" ]]; then
  81. echo -e "${YELLOW}Rebooting in 5 seconds...${NC}"
  82. sleep 5
  83. reboot
  84. else
  85. echo -e "${GREEN}Reboot canceled. Exiting.${NC}"
  86. exit 0
  87. fi
  88. }
  89.  
  90. # Main script logic
  91. select_os
  92. prompt_password
  93. download_reinstall_script
  94. execute_reinstall_script
  95. confirm_reboot
Add Comment
Please, Sign In to add comment