SHARE
TWEET

Speedport W 723V (Type A) Reconnect Script

brian-ammon Apr 13th, 2012 803 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. ########################################################
  3. # recon (c) Philipp Immel 2012 April 13 Version 1.1    #
  4. ########################################################       
  5. # Description: Reconnects Speedport W 723V router
  6. # Syntax: recon
  7. # Extern: read printf echo curl grep awk sleep rm
  8. ########################################################
  9.  
  10. #----------------------
  11. # Read router password
  12. #----------------------
  13. read -s -p "Password: " PASS
  14. echo ""
  15.  
  16. #-------------------------------------
  17. # Convert password to Base64 encoding
  18. #-------------------------------------
  19. BASE64PASS=$( printf "$PASS"|base64 )
  20.  
  21. #---------------------------
  22. # Check external IP address
  23. #---------------------------
  24. echo "Fetching external IP address …"
  25. OLDIP=$( curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g' )
  26.  
  27. #----------------------------------------------
  28. # Log on to router and get a session ID cookie
  29. #----------------------------------------------
  30. echo "Logging in …"
  31. curl --location --cookie-jar "SessionID.txt" --data "Username=admin&Password=$BASE64PASS" https://speedport.ip/index/login.cgi &> /dev/null
  32.  
  33. #----------------------------------------------
  34. # Add comma to the cookie string for HTTP POST
  35. #----------------------------------------------
  36. echo "Preparing cookie …"
  37. SIDCOOKIE=$( grep "SessionID" SessionID.txt | awk '{printf "%s,%s",$6,$7}' )
  38.  
  39. #-----------------------------
  40. # Suspend internet connection
  41. #-----------------------------
  42. echo "Suspending internet connection …"
  43. curl --location --cookie "SessionID.txt" --data "x.EnabledForInternet=0" https://speedport.ip/auth/setcfg.cgi?x=InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig&cookie=$SIDCOOKIE &> /dev/null
  44.  
  45. #--------------------
  46. # Wait for 5 seconds
  47. #--------------------
  48. sleep 5
  49.  
  50. #-----------------------------
  51. # Release internet connection
  52. #-----------------------------
  53. echo "Releasing internet connection …"
  54. curl --location --cookie "SessionID.txt" --data "x.EnabledForInternet=1" https://speedport.ip/auth/setcfg.cgi?x=InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig&cookie=$SIDCOOKIE &> /dev/null
  55.  
  56. #-------------------------
  57. # Log out from the router
  58. #-------------------------
  59. echo "Logging off …"
  60. curl --location --cookie "SessionID.txt" --data "" https://speedport.ip/auth/logout.cgi?cookie=$SIDCOOKIE &> /dev/null
  61.  
  62. #---------------------------
  63. # Check external IP address
  64. #---------------------------
  65. echo "Fetching external IP address …"
  66. NEWIP=$( curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g' )
  67.  
  68. #-------------------
  69. # Check for success
  70. #-------------------
  71. if [ "$OLDIP" != "$NEWIP" ]
  72. then
  73.     echo "Reconnect has been successful. Your new IP address is:" $NEWIP
  74. else
  75.         echo "Reconnect has not been successful. Please try again. Your IP address is still:" $OLDIP
  76. fi
  77.  
  78. #--------------------
  79. # Remove cookie file
  80. #--------------------
  81. rm SessionID.txt
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top