Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/system/xbin/bash
- . /system/etc/sshd.conf
- clear
- echo "---CONFIGURE-SSH-DAEMON---"
- echo ""
- read -s -p "Enter password:" CPASS
- echo ""
- until [ "$CPASS" = "$PASS" ]; do
- read -s -p "Wrong password, try again:" CPASS
- echo ""
- done
- mount -o remount,rw /system
- echo ""
- read -s -p "Enter new password:" NEWPASS
- echo ""
- while [[ -z "$NEWPASS" ]]; do
- echo ""
- echo "Password CAN NOT be blank"
- echo ""
- read -s -p "Enter new password:" NEWPASS;
- echo ""
- done
- sed -i -e"s/^PASS=.*/PASS=$NEWPASS/" /etc/sshd.conf
- if test $? -eq 0; then
- echo 'password written'
- else
- echo 'write attempt failed!'
- fi
- echo ""
- read -p "Enter new port: " NEWPORT
- if test "$NEWPORT" = ""; then
- echo "DEFAULT PORT #2222"; sed -i -e"s/^PORT=.*/PORT=2222/" /etc/sshd.conf
- else
- sed -i -e"s/^PORT=.*/PORT=$NEWPORT/" /etc/sshd.conf
- fi
- if test $? -eq 0; then
- echo "port set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- while true
- do
- read -r -p 'Enable SSH? ' choice
- case "$choice" in
- n|N|no|No|NO) echo "SSH disabled";
- if [[ -e /system/etc/init.d/60dropbear ]]; then
- rm /etc/init.d/60dropbear
- else
- break
- fi;
- break;;
- y|Y|yes|Yes|YEs|YES|YeS|yeS|yES) echo "SSH enabled";
- if [[ ! -e /system/etc/init.d/60dropbear ]]; then
- touch /system/etc/init.d/60dropbear;
- echo "#!/system/bin/sh" >> /system/etc/init.d/60dropbear;
- echo "" >> /system/etc/init.d/60dropbear;
- echo "if [[ ! -d /data/data/br.com.bott.droidsshd ]]; then
- ln -s /system/etc/dropbear/data/br.com.bott.droidsshd /data/data/br.com.bott.droidsshd
- fi" >> /system/etc/init.d/60dropbear;
- echo "" >> /system/etc/init.d/60dropbear;
- echo "sleep 1" >> /system/etc/init.d/60dropbear;
- echo "" >> /system/etc/init.d/60dropbear;
- echo "dropbear" >> /system/etc/init.d/60dropbear;
- chmod 755 /etc/init.d/60dropbear;
- else
- break
- fi; break;;
- *) echo 'Nothing done';
- break;;
- esac
- done
- echo ""
- echo "---CONFIGURE-REVERSE-SSH---"
- echo ""
- read -p "Enter reverse listen port: " NEWREVPORT
- if test "$NEWREVPORT" = ""; then
- echo "DEFAULT IS BLANK"; sed -i -e"s/^REVPORT=.*/REVPORT=/" /etc/sshd.conf
- else
- sed -i -e"s/^REVPORT=.*/REVPORT=$NEWREVPORT/" /etc/sshd.conf
- fi
- if test $? -eq 0; then
- echo "port set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- read -p "Enter remote server: " NEWREMSERV
- if test "$NEWREMSERV" = ""; then
- echo "DEFAULT IS BLANK"; sed -i -e"s/^REMSERV=.*/REMSERV=/" /etc/sshd.conf
- else
- sed -i -e"s/^REMSERV=.*/REMSERV=$NEWREMSERV/" /etc/sshd.conf
- fi
- if test $? -eq 0; then
- echo "server set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- read -p "Enter remote serv port: " NEWREMSERVPORT
- if test "$NEWREMSERVPORT" = ""; then
- echo "DEFAULT IS 22"; sed -i -e"s/^REMSERVPORT=.*/REMSERVPORT=22/" /etc/sshd.conf
- else
- sed -i -e"s/^REMSERVPORT=.*/REMSERVPORT=$NEWREMSERVPORT/" /etc/sshd.conf
- fi
- if test $? -eq 0; then
- echo "port set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- read -p "Enter remote username: " NEWREMUSER
- if test "$NEWREMUSER" = ""; then
- echo "DEFAULT IS BLANK"; sed -i -e"s/^REMUSER=.*/REMUSER=/" /etc/sshd.conf
- else
- sed -i -e"s/^REMUSER=.*/REMUSER=$NEWREMUSER/" /etc/sshd.conf
- fi
- if test $? -eq 0; then
- echo "username set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- while true
- do
- read -r -p 'Enable reverse ssh? ' choice
- case "$choice" in
- n|N|no|No|NO) echo "Reverse SSH disabled";
- if [[ -e /system/etc/init.d/70sshtunnel ]]; then
- rm /etc/init.d/70sshtunnel
- else
- break
- fi;
- break;;
- y|Y|yes|Yes|YEs|YES|YeS|yeS|yES) echo "Reverse SSH enabled";
- if [[ ! -e /system/etc/init.d/70sshtunnel ]]; then
- touch /etc/init.d/70sshtunnel;
- echo "#!/system/xbin/bash" >> /system/etc/init.d/70sshtunnel;
- echo "" >> /system/etc/init.d/70sshtunnel;
- echo "reverse_ssh >/dev/null" >> /system/etc/init.d/70sshtunnel;
- chmod 755 /etc/init.d/70sshtunnel;
- else
- break
- fi;
- break;;
- *) echo 'Nothing done';
- break;;
- esac
- done
- echo ""
- echo "---CONFIGURE-HTTP-PROXY---"
- echo ""
- read -p "Enter socks listen port: " NEWSOCKPORT
- if test "$NEWSOCKPORT" = ""; then
- echo "DEFAULT IS BLANK"; sed -i -e"s/^SOCKSPORT=.*/SOCKSPORT=/" /etc/sshd.conf
- else
- sed -i -e"s/^SOCKSPORT=.*/SOCKSPORT=$NEWSOCKPORT/" /etc/sshd.conf
- fi
- if test $? -eq 0; then
- echo "port set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- while true
- do
- read -r -p 'Enable http tunnel? ' choice
- case "$choice" in
- n|N|no|No|NO) echo "HTTP tunnel disabled";
- if [[ -e /system/etc/init.d/80httptunnel ]]; then
- rm /etc/init.d/80httptunnel
- else
- break
- fi; break;;
- y|Y|yes|Yes|YEs|YES|YeS|yeS|yES) echo "HTTP tunnel enabled";
- if [[ ! -e /system/etc/init.d/80httptunnel ]]; then
- touch /system/etc/init.d/80httptunnel;
- echo "#!/system/xbin/bash" >> /system/etc/init.d/80httptunnel;
- echo "" >> /system/etc/init.d/80httptunnel;
- echo "http_tunnel >/dev/null" >> /system/etc/init.d/80httptunnel;
- chmod 755 /etc/init.d/80httptunnel;
- else
- break
- fi; break;;
- *) echo 'Nothing done';
- break;;
- esac
- done
- echo ""
- echo "--CONFIGURE-DDNS--"
- echo ""
- read -p "Enter username: " DDNSUSER
- if test "DDNSUSER" = ""; then
- echo "DEFAULT UNCONFIGURED"; sed -i -e"s/^--username .*/--username/" /etc/inadyn.conf
- else
- sed -i -e"s/^--username .*/--username $DDNSUSER/" /etc/inadyn.conf
- fi
- if test $? -eq 0; then
- echo "user set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- read -p "Enter password: " DDNSPASS
- if test "DDNSPASS" = ""; then
- echo "DEFAULT UNCONFIGURED"; sed -i -e"s/^--password .*/--password/" /etc/inadyn.conf
- else
- sed -i -e"s/^--password .*/--password $DDNSPASS/" /etc/inadyn.conf
- fi
- if test $? -eq 0; then
- echo "pass set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- read -p "Enter alias: " DDNSALIAS
- if test "DDNSALIAS" = ""; then
- echo "DEFAULT UNCONFIGURED"; sed -i -e"s/^--alias .*/--alias/" /etc/inadyn.conf
- else
- sed -i -e"s/^--alias .*/--alias $DDNSALIAS/" /etc/inadyn.conf
- fi
- if test $? -eq 0; then
- echo "alias set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- read -p "Enter provider: " DDNSSYSTEM
- if test "DDNSSYSTEM" = ""; then
- echo "DEFAULT UNCONFIGURED"; sed -i -e"s/^--dyndns_system .*/--dyndns_system/" /etc/inadyn.conf
- else
- sed -i -e"s/^--dyndns_system .*/--dyndns_system $DDNSSYSTEM/" /etc/inadyn.conf
- fi
- if test $? -eq 0; then
- echo "provider set"
- else
- echo "write attempt failed!"
- fi
- echo ""
- while true
- do
- read -r -p 'Enable DDNS? ' choice
- case "$choice" in
- n|N|no|No|NO) echo "DDNS disabled";
- if [[ -e /system/etc/init.d/50inadyn ]]; then
- rm /etc/init.d/50inadyn
- else
- break
- fi;
- break;;
- y|Y|yes|Yes|YEs|YES|YeS|yeS|yES) echo "DDNS enabled";
- if [[ ! -e /system/etc/init.d/50inadyn ]]; then
- touch /etc/init.d/50inadyn;
- echo "#!/system/xbin/bash" >> /system/etc/init.d/50inadyn;
- echo "" >> /system/etc/init.d/50inadyn;
- echo "inadyn >/dev/null" >> /system/etc/init.d/50inadyn;
- chmod 755 /etc/init.d/50inadyn;
- else
- break
- fi; break;;
- *) echo 'Nothing done';
- break;;
- esac
- done
- echo ""
- echo "---REMOVE-OLD-KEYS---"
- echo ""
- while true
- do
- read -r -p 'Remove old key(s)? ' choice
- case "$choice" in
- n|N|no|No|NO) echo "Keeping old key(s)";
- break;;
- y|Y|yes|Yes|YEs|YES|YeS|yeS|yES) echo "Removing old key(s)";
- rm /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_*_host_key;
- break;;
- *) echo 'Keeping old key(s)';
- break;;
- esac
- done
- echo ""
- echo "---GENERATING-RSA-KEY---"; dropbearkey -t rsa -f /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_rsa_host_key; chmod 400 /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_rsa_host_key
- echo ""
- echo "---GENERATING-DSS-KEY---"; dropbearkey -t dss -f /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_dss_host_key; chmod 400 /etc/dropbear/data/br.com.bott.droidsshd/files/etc/dropbear_dss_host_key
- echo ""
- read -p "Enter path to private key: " PRIKEYLOC
- echo ""
- echo "---CONVERTING-PRIVATE-KEY---"; mkdir /system/etc/.ssh; mkdir /sdcard/.ssh; rm /system/etc/.ssh/reverse_ssh_key; dropbearconvert openssh dropbear "$PRIKEYLOC" /system/etc/.ssh/reverse_ssh_key; chmod 400 /system/etc/.ssh/reverse_ssh_key; cp "$PRIKEYLOC" /system/etc/.ssh/openssh_key; chmod 400 /system/etc/.ssh/openssh_key
- echo ""; echo "Restarting dropbear with new settings..."
- killall dropbear
- echo ""
- dropbear
- echo ""
- echo ""; echo "Press RETURN to continue"; read return; clear
- mount -o remount,ro /system
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement