├── README.md ├── app.zip ├── images ├── 1.png ├── 2.png ├── 3.png ├── 4.png └── logo.png ├── geo-update.sh ├── rocket-banner.txt ├── block-ir-ip.sh ├── LICENSE ├── update-panel.sh ├── ssl.sh └── install.sh /README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rocket-ap/rocket-ssh/HEAD/app.zip -------------------------------------------------------------------------------- /images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rocket-ap/rocket-ssh/HEAD/images/1.png -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rocket-ap/rocket-ssh/HEAD/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rocket-ap/rocket-ssh/HEAD/images/3.png -------------------------------------------------------------------------------- /images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rocket-ap/rocket-ssh/HEAD/images/4.png -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rocket-ap/rocket-ssh/HEAD/images/logo.png -------------------------------------------------------------------------------- /geo-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Month=$(date +"%m") 3 | Year=$(date +"%Y") 4 | wget https://download.db-ip.com/free/dbip-country-lite-${Year}-${Month}.csv.gz -O /usr/share/xt_geoip/dbip-country-lite.csv.gz 5 | gunzip /usr/share/xt_geoip/dbip-country-lite.csv.gz 6 | /usr/lib/xtables-addons/xt_geoip_build -D /usr/share/xt_geoip/ -S /usr/share/xt_geoip/ 7 | rm /usr/share/xt_geoip/dbip-country-lite.csv 8 | 9 | -------------------------------------------------------------------------------- /rocket-banner.txt: -------------------------------------------------------------------------------- 1 | ██████╗ ██████╗ ██████╗██╗ ██╗███████╗████████╗ ███████╗███████╗██╗ ██╗ 2 | ██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝╚══██╔══╝ ██╔════╝██╔════╝██║ ██║ 3 | ██████╔╝██║ ██║██║ █████╔╝ █████╗ ██║ ███████╗███████╗███████║ 4 | ██╔══██╗██║ ██║██║ ██╔═██╗ ██╔══╝ ██║ ╚════██║╚════██║██╔══██║ 5 | ██║ ██║╚██████╔╝╚██████╗██║ ██╗███████╗ ██║ ███████║███████║██║ ██║ 6 | ╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝╚══════╝╚═╝ ╚═╝ -------------------------------------------------------------------------------- /block-ir-ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo apt-get update -y 4 | sudo apt-get -y upgrade 5 | sudo apt-get install curl unzip perl xtables-addons-common libtext-csv-xs-perl libmoosex-types-netaddr-ip-perl iptables-persistent -y 6 | sudo mkdir /usr/share/xt_geoip 7 | 8 | sudo wget -4 -O /usr/local/bin/geo-update.sh https://raw.githubusercontent.com/rocket-ap/rocket-ssh/master/geo-update.sh 9 | 10 | chmod 755 /usr/lib/xtables-addons/xt_geoip_build 11 | bash /usr/local/bin/geo-update.sh 12 | 13 | sudo iptables -A OUTPUT -m geoip -p tcp --destination-port 80 --dst-cc IR -j DROP 14 | sudo iptables -A OUTPUT -m geoip -p tcp --destination-port 443 --dst-cc IR -j DROP 15 | iptables-save 16 | clear 17 | echo -e "Blocked Port 80 and 443 Iran \n" 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | his is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /update-panel.sh: -------------------------------------------------------------------------------- 1 | 2 | # Set URLs and file paths 3 | repoLink="https://github.com/rocket-ap/rocket-ssh/raw/master/app.zip" 4 | 5 | originalEnvFile="/var/www/html/panel/.env" 6 | pathDir="/var/www/html" 7 | 8 | # Banner Path 9 | bannerPath="/var/www/html/panel/banner.txt" 10 | 11 | if [ ! -e "$bannerPath" ]; then 12 | touch "$bannerPath" 13 | echo "Banner file created: $bannerPath" 14 | else 15 | echo "Banner file already exists: $bannerPath" 16 | fi 17 | 18 | # Backup original .env file contents to a variable 19 | originalEnvContent=$(cat "$originalEnvFile") 20 | 21 | # Download PHP code zip file 22 | sudo wget -O /var/www/html/update.zip $repoLink 23 | 24 | # # Extract PHP code 25 | sudo unzip -o /var/www/html/update.zip -d $pathDir 26 | wait 27 | # # Restore original .env file contents 28 | echo "$originalEnvContent" > "$originalEnvFile" 29 | 30 | sudo chown -R www-data:www-data /var/www/html/panel 31 | wait 32 | chown www-data:www-data /var/www/html/panel/index.php 33 | wait 34 | sudo chown -R www-data:www-data /var/www/html/account 35 | wait 36 | chown www-data:www-data /var/www/html/account/index.php 37 | wait 38 | chown www-data:www-data /var/www/html/index.php 39 | wait 40 | sudo systemctl stop cron 41 | wait 42 | rm /tmp/call_url.lock 43 | wait 44 | pkill -f /var/www/html/cronjob.sh 45 | wait 46 | sudo systemctl start cron 47 | wait 48 | clear 49 | echo "PHP code updated and .env content restored." 50 | -------------------------------------------------------------------------------- /ssl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | 5 | getPanelPort(){ 6 | env_file="/var/www/html/panel/.env" 7 | local port_panel_value=$(grep "^PORT_PANEL=" "$env_file" | cut -d '=' -f 2-) 8 | 9 | if [ -n "$port_panel_value" ]; then 10 | echo "$port_panel_value" 11 | else 12 | echo "8081" # Default value if PORT_PANEL is not found 13 | fi 14 | } 15 | 16 | panelPort=$(getPanelPort) 17 | sslPanelPort=$((panelPort+1)) 18 | 19 | # Check if the script is run as root 20 | if [ "$EUID" -ne 0 ]; then 21 | echo "Please run as root or with sudo." 22 | exit 1 23 | fi 24 | 25 | # Check for the presence of Certbot 26 | if ! command -v certbot &> /dev/null; then 27 | echo "Certbot is not installed. Installing..." 28 | apt update 29 | apt install -y certbot 30 | fi 31 | 32 | # Get subdomain as input 33 | read -p "Enter your subdomain: " SUBDOMAIN 34 | 35 | # Stop Apache temporarily 36 | systemctl stop apache2 37 | 38 | # Obtain SSL certificate 39 | certbot certonly --standalone -d $SUBDOMAIN 40 | 41 | # Configure Apache to use the SSL certificate 42 | CONF_FILE="/etc/apache2/sites-available/default-ssl.conf" 43 | cat < $CONF_FILE 44 | 45 | 46 | ServerAdmin RockerSSH@$SUBDOMAIN 47 | ServerName $SUBDOMAIN 48 | 49 | DocumentRoot /var/www/html 50 | 51 | ErrorLog \${APACHE_LOG_DIR}/error.log 52 | CustomLog \${APACHE_LOG_DIR}/access.log combined 53 | 54 | SSLEngine on 55 | SSLCertificateFile /etc/letsencrypt/live/$SUBDOMAIN/fullchain.pem 56 | SSLCertificateKeyFile /etc/letsencrypt/live/$SUBDOMAIN/privkey.pem 57 | SSLCertificateChainFile /etc/letsencrypt/live/$SUBDOMAIN/chain.pem 58 | 59 | 60 | SSLOptions +StdEnvVars 61 | 62 | 63 | 64 | SSLOptions +StdEnvVars 65 | 66 | 67 | 68 | AllowOverride All 69 | 70 | 71 | 72 | Require all denied 73 | 74 | 75 | 76 | 77 | ServerAdmin RockerSSH@$SUBDOMAIN 78 | DocumentRoot /var/www/html/panel 79 | 80 | ServerName $SUBDOMAIN 81 | 82 | ErrorLog \${APACHE_LOG_DIR}/error.log 83 | CustomLog \${APACHE_LOG_DIR}/access.log combined 84 | 85 | SSLEngine on 86 | SSLCertificateFile /etc/letsencrypt/live/$SUBDOMAIN/fullchain.pem 87 | SSLCertificateKeyFile /etc/letsencrypt/live/$SUBDOMAIN/privkey.pem 88 | SSLCertificateChainFile /etc/letsencrypt/live/$SUBDOMAIN/chain.pem 89 | 90 | 91 | SSLOptions +StdEnvVars 92 | 93 | 94 | 95 | SSLOptions +StdEnvVars 96 | 97 | 98 | 99 | AllowOverride All 100 | 101 | 102 | 103 | EOL 104 | 105 | cat < /etc/apache2/ports.conf 106 | Listen 80 107 | Listen $panelPort 108 | 109 | Listen $sslPanelPort 110 | Listen 443 111 | 112 | 113 | Listen $sslPanelPort 114 | Listen 443 115 | 116 | EOL 117 | 118 | # Enable SSL module and the virtual host 119 | a2enmod ssl 120 | sudo a2ensite default-ssl 121 | # Restart Apache 122 | systemctl restart apache2 123 | 124 | echo "SSL certificate for $SUBDOMAIN has been configured successfully." 125 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | userInputs(){ 5 | 6 | echo -e "\n\n****** Welecome to installation of the Rocket SSH Panel ****** \n" 7 | printf "Default username is \e[33m${username}\e[0m, let it blank to use this username: " 8 | read usernameTmp 9 | 10 | if [[ -n "${usernameTmp}" ]]; then 11 | username=${usernameTmp} 12 | fi 13 | 14 | echo -e "\nPlease input Panel admin password." 15 | printf "Default password is \e[33m${password}\e[0m, let it blank to use this password: " 16 | read passwordTmp 17 | 18 | if [[ -n "${passwordTmp}" ]]; then 19 | password=${passwordTmp} 20 | fi 21 | 22 | echo -e "\nPlease input UDPGW Port ." 23 | printf "Default Port is \e[33m${udpPort}\e[0m, let it blank to use this Port: " 24 | read udpPortTmp 25 | 26 | if [[ -n "${udpPortTmp}" ]]; then 27 | udpPort=${udpPortTmp} 28 | fi 29 | 30 | echo -e "\nPlease input SSH Port ." 31 | printf "Default Port is \e[33m${sshPort}\e[0m, let it blank to use this Port: " 32 | read sshPortTmp 33 | 34 | if [[ -n "${sshPortTmp}" ]]; then 35 | sshPort=${sshPortTmp} 36 | fi 37 | 38 | echo -e "\nPlease input Panel Port ." 39 | printf "Default Port is \e[33m${panelPort}\e[0m, let it blank to use this Port: " 40 | read panelPortTmp 41 | 42 | if [[ -n "${panelPortTmp}" ]]; then 43 | panelPort=${panelPortTmp} 44 | fi 45 | } 46 | 47 | getAppVersion(){ 48 | version=$(sudo curl -Ls "https://api.github.com/repos/rocket-ap/rocket-ssh/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') 49 | echo $version; 50 | } 51 | 52 | encryptAdminPass(){ 53 | tempPass=$(php -r "echo password_hash('$password', PASSWORD_BCRYPT);"); 54 | echo $tempPass 55 | } 56 | 57 | getServerIpV4(){ 58 | ivp4Temp=$(curl -s ipv4.icanhazip.com) 59 | echo $ivp4Temp 60 | } 61 | 62 | getPanelPath(){ 63 | panelPathTmp="/var/www/html/panel" 64 | if [ -d "$panelPathTmp" ]; then 65 | rm -rf $panelPathTmp 66 | fi 67 | 68 | echo $panelPathTmp 69 | } 70 | 71 | getSshPort(){ 72 | sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config 73 | po=$(cat /etc/ssh/sshd_config | grep "^Port") 74 | port=$(echo "$po" | sed "s/Port //g") 75 | if [ -z "$port" ]; then 76 | port="22" # Set default port to 22 if $port is empty 77 | fi 78 | 79 | echo "$port" 80 | } 81 | 82 | getPanelPort(){ 83 | env_file="/var/www/html/panel/.env" 84 | local port_panel_value=$(grep "^PORT_PANEL=" "$env_file" | cut -d '=' -f 2-) 85 | 86 | if [ -n "$port_panel_value" ]; then 87 | echo "$port_panel_value" 88 | else 89 | echo "8081" # Default value if PORT_PANEL is not found 90 | fi 91 | 92 | } 93 | 94 | checkRoot() { 95 | if [ "$EUID" -ne 0 ]; then 96 | echo "Please run as root" 97 | exit 1 98 | fi 99 | } 100 | 101 | updateShhConfig(){ 102 | sed -i "s/^(\s*#?\s*Port\s+)[0-9]+/Port ${sshPort}/" /etc/ssh/sshd_config 103 | sed -E -i "s/^(\s*#?\s*Port\s+)[0-9]+/\Port ${sshPort}/" /etc/ssh/sshd_config 104 | sed -i 's/#Banner none/Banner \/root\/banner.txt/g' /etc/ssh/sshd_config 105 | sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config 106 | } 107 | 108 | installPackages(){ 109 | apt update -y 110 | phpv=$(php -v) 111 | if [[ $phpv == *"7.4"* ]]; then 112 | apt autoremove -y 113 | echo "PHP Is Installed :)" 114 | else 115 | sudo NEETRESTART_MODE=a apt-get update --yes 116 | sudo apt-get -y install software-properties-common 117 | apt-get install -y cmake && apt-get install -y screenfetch && apt-get install -y openssl 118 | sudo add-apt-repository ppa:ondrej/php -y 119 | apt-get install apache2 zip unzip net-tools curl mariadb-server -y 120 | apt-get install php php-cli php-mbstring php-dom php-pdo php-mysql -y 121 | sudo apt-get install coreutils 122 | apt install php7.4 php7.4-mysql php7.4-xml php7.4-curl cron -y 123 | fi 124 | echo "/bin/false" >> /etc/shells 125 | echo "/usr/sbin/nologin" >> /etc/shells 126 | } 127 | 128 | installSshCall(){ 129 | file=/etc/systemd/system/videocall.service 130 | if [ -e "$file" ]; then 131 | echo "SSH call is installed" 132 | else 133 | apt update -y 134 | apt install git cmake -y 135 | git clone https://github.com/ambrop72/badvpn.git /root/badvpn 136 | mkdir /root/badvpn/badvpn-build 137 | cd /root/badvpn/badvpn-build 138 | cmake .. -DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_UDPGW=1 & 139 | wait 140 | make & 141 | wait 142 | cp udpgw/badvpn-udpgw /usr/local/bin 143 | cat > /etc/systemd/system/videocall.service << ENDOFFILE 144 | [Unit] 145 | Description=UDP forwarding for badvpn-tun2socks 146 | After=nss-lookup.target 147 | 148 | [Service] 149 | ExecStart=/usr/local/bin/badvpn-udpgw --loglevel none --listen-addr 127.0.0.1:$udpPort --max-clients 999 150 | User=videocall 151 | 152 | [Install] 153 | WantedBy=multi-user.target 154 | ENDOFFILE 155 | useradd -m videocall 156 | systemctl enable videocall 157 | systemctl start videocall 158 | fi 159 | 160 | } 161 | 162 | copyPanelRepo(){ 163 | 164 | panelFolderPath="/var/www/html/panel" 165 | accountFolderPath="/var/www/html/account" 166 | 167 | if [ ! -d "$panelFolderPath" ]; then 168 | mkdir -p "$panelFolderPath" 169 | else 170 | rm -rf /var/www/html/panel 171 | fi 172 | 173 | if [ ! -d "$accountFolderPath" ]; then 174 | mkdir -p "$accountFolderPath" 175 | else 176 | rm -rf /var/www/html/account 177 | fi 178 | 179 | link=https://raw.githubusercontent.com/rocket-ap/rocket-ssh/main/app.zip 180 | 181 | if [[ -n "$link" ]]; then 182 | rm -fr /var/www/html/update.zip 183 | wait 184 | sudo wget -O /var/www/html/update.zip $link 185 | wait 186 | sudo unzip -o /var/www/html/update.zip -d /var/www/html & 187 | else 188 | echo "Error extracting the ZIP file link." 189 | exit 1 190 | fi 191 | 192 | touch /var/www/html/panel/banner.txt 193 | wait 194 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/adduser' | sudo EDITOR='tee -a' visudo & 195 | wait 196 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/userdel' | sudo EDITOR='tee -a' visudo & 197 | wait 198 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/sed' | sudo EDITOR='tee -a' visudo & 199 | wait 200 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/passwd' | sudo EDITOR='tee -a' visudo & 201 | wait 202 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/curl' | sudo EDITOR='tee -a' visudo & 203 | wait 204 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/kill' | sudo EDITOR='tee -a' visudo & 205 | wait 206 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/killall' | sudo EDITOR='tee -a' visudo & 207 | wait 208 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/lsof' | sudo EDITOR='tee -a' visudo & 209 | wait 210 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/lsof' | sudo EDITOR='tee -a' visudo & 211 | wait 212 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/sed' | sudo EDITOR='tee -a' visudo & 213 | wait 214 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/rm' | sudo EDITOR='tee -a' visudo & 215 | wait 216 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/crontab' | sudo EDITOR='tee -a' visudo & 217 | wait 218 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/mysqldump' | sudo EDITOR='tee -a' visudo & 219 | wait 220 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/pgrep' | sudo EDITOR='tee -a' visudo & 221 | wait 222 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/nethogs' | sudo EDITOR='tee -a' visudo & 223 | wait 224 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/nethogs' | sudo EDITOR='tee -a' visudo & 225 | wait 226 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/local/sbin/nethogs' | sudo EDITOR='tee -a' visudo & 227 | wait 228 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/netstat' | sudo EDITOR='tee -a' visudo & 229 | wait 230 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/systemctl restart sshd' | sudo EDITOR='tee -a' visudo & 231 | wait 232 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/systemctl reboot' | sudo EDITOR='tee -a' visudo & 233 | wait 234 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/systemctl daemon-reload' | sudo EDITOR='tee -a' visudo & 235 | wait 236 | echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/systemctl restart videocall' | sudo EDITOR='tee -a' visudo & 237 | wait 238 | sudo chown -R www-data:www-data /var/www/html/panel 239 | wait 240 | chown www-data:www-data /var/www/html/panel/index.php 241 | wait 242 | sudo chown -R www-data:www-data /var/www/html/account 243 | wait 244 | chown www-data:www-data /var/www/html/account/index.php 245 | wait 246 | 247 | sudo a2enmod rewrite 248 | wait 249 | sudo service apache2 restart 250 | wait 251 | sudo systemctl restart apache2 252 | wait 253 | sudo service apache2 restart 254 | wait 255 | sudo sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf & 256 | wait 257 | } 258 | 259 | configAppache(){ 260 | serverPort=${panelPort##*=} 261 | ##Remove the "" marks from the variable as they will not be needed 262 | serverPort=${panelPort//'"'} 263 | echo " 264 | ServerAdmin webmaster@localhost 265 | DocumentRoot /var/www/html 266 | 267 | ErrorLog ${APACHE_LOG_DIR}/error.log 268 | CustomLog ${APACHE_LOG_DIR}/access.log combined 269 | 270 | 271 | AllowOverride All 272 | 273 | 274 | Require all denied 275 | 276 | 277 | 278 | ServerAdmin webmaster@localhost 279 | DocumentRoot /var/www/html/panel 280 | 281 | ErrorLog ${APACHE_LOG_DIR}/error.log 282 | CustomLog ${APACHE_LOG_DIR}/access.log combined 283 | 284 | 285 | AllowOverride All 286 | 287 | 288 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet" > /etc/apache2/sites-available/000-default.conf 289 | wait 290 | echo "sites-available" 291 | 292 | ##Replace 'Virtual Hosts' and 'List' entries with the new port number 293 | sudo sed -i.bak 's/.*NameVirtualHost.*/NameVirtualHost *:'$serverPort'/' /etc/apache2/ports.conf 294 | echo "Listen 80 295 | Listen $serverPort 296 | 297 | Listen 443 298 | 299 | 300 | Listen 443 301 | " > /etc/apache2/ports.conf 302 | echo '#RocketSSH' > /var/www/rocketsshport 303 | sudo sed -i -e '$a\'$'\n''rocketsshport '$serverPort /var/www/rocketsshport 304 | wait 305 | 306 | ##Replace 'Virtual Hosts' and 'List' entries with the new port number 307 | sudo sed -i.bak 's/.*NameVirtualHost.*/NameVirtualHost *:'$serverPort'/' /etc/apache2/ports.conf 308 | echo "Listen 80 309 | Listen $serverPort 310 | 311 | Listen 443 312 | 313 | 314 | Listen 443 315 | " > /etc/apache2/ports.conf 316 | echo '#RocketSSH' > /var/www/rocketsshport 317 | sudo sed -i -e '$a\'$'\n''rocketsshport '$serverPort /var/www/rocketsshport 318 | wait 319 | ##Restart the apache server to use new port 320 | sudo /etc/init.d/apache2 reload 321 | sudo service apache2 restart 322 | chown www-data:www-data /var/www/html/panel/* & 323 | chown www-data:www-data /var/www/html/account/* & 324 | wait 325 | systemctl restart mariadb & 326 | wait 327 | systemctl enable mariadb & 328 | wait 329 | sudo phpenmod curl 330 | systemctl restart httpd 331 | systemctl enable httpd 332 | systemctl restart sshd 333 | sudo timedatectl set-timezone Asia/Tehran 334 | sudo systemctl restart apache2 335 | } 336 | 337 | installNethogs(){ 338 | bash <(curl -Ls $nethogsLink --ipv4) 339 | } 340 | 341 | configDatabase(){ 342 | dbName="RocketSSH" 343 | dbPrefix="cp_" 344 | appVersion=$(getAppVersion) 345 | mysql -e "create database $dbName;" & 346 | wait 347 | mysql -e "CREATE USER '${username}'@'localhost' IDENTIFIED BY '${password}';" & 348 | wait 349 | mysql -e "GRANT ALL ON *.* TO '${username}'@'localhost';" & 350 | wait 351 | 352 | # Dump and remove the old database 353 | if mysql -u root -e "USE RokcetSSH" 2>/dev/null; then 354 | # Dump and restore the old database to the new database 355 | mysqldump -u root --force RokcetSSH | mysql -u root $dbName 356 | echo "Data has been dumped from 'RokcetSSH' to '$dbName'." 357 | 358 | # Remove the old database 359 | mysql -u root -e "DROP DATABASE RokcetSSH;" 360 | echo "Old database 'RokcetSSH' has been removed." 361 | else 362 | echo "Database 'RokcetSSH' does not exist." 363 | fi 364 | 365 | sed -i "s/DB_DATABASE=rocket_ssh/DB_DATABASE=${dbName}/" /var/www/html/panel/.env 366 | sed -i "s/DB_USERNAME=root/DB_USERNAME=$username/" /var/www/html/panel/.env 367 | sed -i "s/DB_PASSWORD=/DB_PASSWORD=$password/" /var/www/html/panel/.env 368 | sed -i "s/PORT_SSH=22/PORT_SSH=$sshPort/" /var/www/html/panel/.env 369 | sed -i "s/PORT_UDP=7302/PORT_UDP=$udpPort/" /var/www/html/panel/.env 370 | sed -i "s/PORT_PANEL=8081/PORT_PANEL=$panelPort/" /var/www/html/panel/.env 371 | 372 | hashedPassword=$(php -r "echo password_hash('$password', PASSWORD_BCRYPT);") 373 | nowTime=$(php -r "echo time();") 374 | #Insert or update 375 | 376 | adminTblName=${dbPrefix}admins 377 | mysqlCmd="mysql -u'$username' -p'$password' -e 'USE $dbName; SHOW TABLES LIKE \"$adminTblName\";'" 378 | 379 | if eval "$mysqlCmd" | grep -q "$adminTblName"; then 380 | mysql -e "USE ${dbName}; UPDATE ${dbPrefix}admins SET username = '${username}' where id='1';" 381 | mysql -e "USE ${dbName}; UPDATE ${dbPrefix}admins SET password = '${hashedPassword}' where id='1';" 382 | mysql -e "USE ${dbName}; UPDATE ${dbPrefix}settings SET value = '${sshPort}' where name='ssh_port';" 383 | mysql -e "USE ${dbName}; UPDATE ${dbPrefix}settings SET value = '${udpPort}' where name='udp_port';" 384 | mysql -e "USE ${dbName}; UPDATE ${dbPrefix}settings SET value = '${appVersion}' where name='app_version';" 385 | else 386 | mysql -u ${username} --password=${password} ${dbName} < /var/www/html/panel/assets/backup/db.sql 387 | wait 388 | mysql -e "USE ${dbName}; INSERT INTO ${dbPrefix}admins (username, password, fullname, role, credit, is_active, ctime, utime) VALUES ('${username}', '${hashedPassword}', 'modir', 'admin', '0', '1', '${nowTime}','0');" 389 | mysql -e "USE ${dbName}; INSERT INTO ${dbPrefix}settings (name, value) VALUES ('ssh_port','${sshPort}');" 390 | mysql -e "USE ${dbName}; INSERT INTO ${dbPrefix}settings (name, value) VALUES ('udp_port','${udpPort}');" 391 | mysql -e "USE ${dbName}; INSERT INTO ${dbPrefix}settings (name, value) VALUES ('app_version','${appVersion}');" 392 | mysql -e "USE ${dbName}; INSERT INTO ${dbPrefix}settings (name, value) VALUES ('calc_traffic','1');" 393 | fi 394 | } 395 | 396 | configCronMaster(){ 397 | 398 | crontab -r 399 | wait 400 | 401 | cronUrl="$httpProtcol://$ipv4:$panelPort/cron/master" 402 | 403 | # Define the file path to check 404 | killFilePath="/var/www/html/kill.sh" 405 | 406 | # Check if the file exists 407 | if [ -e "$killFilePath" ]; then 408 | # Remove the file 409 | pkill -f kill.sh 410 | rm "$killFilePath" 411 | else 412 | echo "File $killFilePath does not exist." 413 | fi 414 | 415 | rm /tmp/call_url.lock 416 | 417 | cat > /var/www/html/cronjob.sh << ENDOFFILE 418 | #!/bin/bash 419 | 420 | curlUrl="tmpCurl" 421 | lockfile="/tmp/call_url.lock" 422 | 423 | # Check if the lock file exists 424 | if [ -e "\$lockfile" ]; then 425 | echo "Previous instance still running. Exiting." 426 | exit 1 427 | fi 428 | 429 | # Create the lock file 430 | touch "\$lockfile" 431 | 432 | # Function to remove the lock file 433 | cleanup() { 434 | rm -f "\$lockfile" 435 | exit 436 | } 437 | trap cleanup EXIT 438 | 439 | while true; do 440 | # Use curl to call the URL 441 | curl -s -o -v -H /dev/null \$curlUrl & 442 | sleep 5 443 | done 444 | ENDOFFILE 445 | wait 446 | chmod +x /var/www/html/cronjob.sh 447 | wait 448 | sed -i "s|curlUrl=\"tmpCurl\"|curlUrl=\"$cronUrl\"|" /var/www/html/cronjob.sh 449 | wait 450 | (crontab -l | grep . ; echo -e "* * * * * /var/www/html/cronjob.sh") | crontab - 451 | } 452 | 453 | installationInfo(){ 454 | clear 455 | echo -e "\n" 456 | bannerText=$(curl -s https://raw.githubusercontent.com/rocket-ap/rocket-ssh/master/rocket-banner.txt) 457 | printf "%s" "$bannerText" 458 | echo -e "\n" 459 | printf "Panel Link : $httpProtcol://${ipv4}:$panelPort/login" 460 | printf "\nUsername : \e[31m${username}\e[0m " 461 | printf "\nPassword : \e[31m${password}\e[0m " 462 | printf "\nSSH Port : \e[31m${sshPort}\e[0m " 463 | printf "\nUDP Port : \e[31m${udpPort}\e[0m \n\n" 464 | } 465 | 466 | runSystemServices(){ 467 | sudo systemctl restart apache2 468 | sudo systemctl restart sshd 469 | } 470 | 471 | runMigrataion(){ 472 | migrateUrl=$(echo "$httpProtcol://$ipv4:$panelPort/migrate") 473 | curl -s $migrateUrl 474 | rm /var/www/html/index.html 475 | } 476 | 477 | ipv4=$(getServerIpV4) 478 | appVersion=1.2 479 | username="admin" 480 | password="123456" 481 | udpPort=7300 482 | sshPort=$(getSshPort) 483 | panelPort=$(getPanelPort) 484 | httpProtcol="http" 485 | panelPath=$(getPanelPath) 486 | nethogsLink=https://raw.githubusercontent.com/rocket-ap/nethogs-json/master/install.sh 487 | 488 | checkRoot 489 | userInputs 490 | updateShhConfig 491 | installPackages 492 | copyPanelRepo 493 | configAppache 494 | installNethogs 495 | installSshCall 496 | configDatabase 497 | configCronMaster 498 | runSystemServices 499 | runMigrataion 500 | installationInfo 501 | --------------------------------------------------------------------------------