Speedport W921V HttpWebRequest Login

  • VB.NET

Es gibt 9 Antworten in diesem Thema. Der letzte Beitrag () ist von flori5885.

    Speedport W921V HttpWebRequest Login

    Hallo ich habe folgendes Problem ich würde gerne alle 12Std meinen Router neustarten aber es scheitert schon am Login.
    Habe diesen Thread gefunden: [VB.NET] Router-Login via HttpWebRequest aber irgendwie will das nicht so ganz.
    Diesen Fehler bekomme ich dauernd

    Spoiler anzeigen
    System.Net.WebException wurde nicht behandelt.
    Message=The remote server returned an error: (404) Not Found.
    Source=System
    StackTrace:
    at System.Net.HttpWebRequest.GetResponse()
    at ConsoleApplication1.Module1.DoRequest(String url, String password, CookieContainer container) in C:\Users\Flo\AppData\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 39
    at ConsoleApplication1.Module1.Main() in C:\Users\Flo\AppData\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 10
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException:


    Mein Sourcecode:

    VB.NET-Quellcode

    1. Imports System.Net
    2. Imports System.Text
    3. Imports System.IO
    4. Module Module1
    5. Public Sub Main()
    6. Dim sURL As String = "https://speedport.ip/cgi-bin/login.cgi"
    7. Dim sPw As String = "12345678"
    8. Dim cContainer As CookieContainer
    9. Console.WriteLine(DoRequest(sURL, sPw, cContainer))
    10. Dim input As String = Console.ReadLine()
    11. End Sub
    12. Public Function DoRequest(ByVal url As String, ByVal password As String, ByVal container As CookieContainer) As String
    13. Dim reqLogin As HttpWebRequest = DirectCast(HttpWebRequest.Create("https://speedport.ip/cgi-bin/login.cgi"), HttpWebRequest)
    14. reqLogin.CookieContainer = container
    15. reqLogin.Method = "POST"
    16. reqLogin.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0"
    17. reqLogin.Referer = "https://speedport.ip/html/login/"
    18. reqLogin.KeepAlive = True
    19. reqLogin.Host = "speedport.ip"
    20. reqLogin.ContentType = "application/x-www-form-urlencoded"
    21. reqLogin.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
    22. reqLogin.Headers.Add("Accept-Language", "de-de,de;q=0.8,en-us;q=0.5,en;q=0.3")
    23. reqLogin.Headers.Add("Accept-Encoding", "gzip, deflate")
    24. Dim encoding As New ASCIIEncoding()
    25. Dim data As String = Uri.EscapeDataString("password") & "=" & Uri.EscapeDataString(password)
    26. Dim bytes As Byte() = encoding.GetBytes(data)
    27. reqLogin.ContentLength = bytes.Length
    28. Dim stream As Stream = reqLogin.GetRequestStream
    29. stream.Write(bytes, 0, bytes.Length)
    30. stream.Close()
    31. Dim resLogin As HttpWebResponse = DirectCast(reqLogin.GetResponse(), HttpWebResponse)
    32. Dim CookieHeaderValue As String = reqLogin.Headers.Get("Cookie")
    33. If CookieHeaderValue <> Nothing Then
    34. Dim aCookie As String() = CookieHeaderValue.Split("=")
    35. Dim Cookie As New Cookie
    36. Cookie.Domain = "speedport.ip"
    37. Cookie.Path = "/"
    38. Cookie.Secure = True
    39. Cookie.Name = aCookie(0)
    40. Cookie.Value = aCookie(1)
    41. container.Add(Cookie)
    42. End If
    43. Dim reqIndex As HttpWebRequest = DirectCast(HttpWebRequest.Create(url), HttpWebRequest)
    44. reqIndex.CookieContainer = container
    45. reqIndex.Method = "GET"
    46. reqIndex.Referer = "https://speedport.ip/wait_login.stm"
    47. reqIndex.KeepAlive = True
    48. reqIndex.Host = "speedport.ip"
    49. reqIndex.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
    50. Dim resIndex As HttpWebResponse = DirectCast(reqIndex.GetResponse(), HttpWebResponse)
    51. Dim sr As StreamReader = New StreamReader(resIndex.GetResponseStream())
    52. Dim output As String = sr.ReadToEnd
    53. resIndex.Close()
    54. Return output
    55. End Function
    56. End Module


    HTTP header:
    Spoiler anzeigen

    speedport.ip/data/Login.json

    POST /data/Login.json HTTP/1.1
    Host: speedport.ip
    User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0
    Accept: application/json, text/javascript, */*
    Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    X-Requested-With: XMLHttpRequest
    Referer: speedport.ip/html/login/
    Content-Length: 26
    Connection: keep-alive
    Pragma: no-cache
    Cache-Control: no-cache
    password=12345678&showpw=0
    HTTP/1.1 200 OK
    Date: Thu, 13 Feb 2014 14:55:35 GMT;
    Server: Apache
    Pragma: no-cache, no-cache
    Cache-Control: max-age=0, must-revalidate, no-cache
    Set-Cookie: aDuPtHhDTW921Vcb4b66f=ETOd2eCSmJiWlhGdG3W96m_LFp_JSn5siKcnyIlAzby7xalSkFYc; Path=/; Secure; expires=Thu, 13 Feb 2014 15:05:35 GMT;
    Connection: Keep-Alive
    Content-Type: application/javascript
    Expires: -1



    Mfg Flo
    Die korrekte URL (IP) deines Routers
    Ich Antworte nach bestem Wissen und Gewissen. Ich übernehme keine Garantie für die Richtigkeit oder Fehlerfreiheit meiner Texte.


    Ich konnte dir helfen?
    - Das ist schön :) Ich würde mich über ein "Hilfreich" freuen ^^
    Dann bekomme ich den hier:
    Spoiler anzeigen

    System.Net.ProtocolViolationException wurde nicht behandelt.
    Message=Content-Length or Chunked Encoding cannot be set for an operation that does not write data.
    Source=System
    StackTrace:
    at System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream)
    at System.Net.HttpWebRequest.GetResponse()
    at ConsoleApplication1.Module1.DoRequest(String url, String password, CookieContainer container) in C:\Users\Flo\AppData\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 39
    at ConsoleApplication1.Module1.Main() in C:\Users\Flo\AppData\Local\Temporary Projects\ConsoleApplication1\Module1.vb:line 10
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException:

    Ich verstehe das mim HttpWebRequest nicht so ganz, hab mit das tutorial schon angeguggt.
    Wer kann mir vielleicht helfen?
    Das ist der Sourcecode:

    HTML-Quellcode

    1. <!DOCTYPE html PUBLIC "../xhtml1-transitional-translate.dtd">
    2. <html xmlns="http://www.w3.org/1999/xhtml"
    3. xmlns:i18n="../">
    4. <head>
    5. <title>Speedport Konfigurationsprogramm</title>
    6. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    7. <script type="text/javascript">
    8. /* <![CDATA[ */
    9. var rootRelative = '../';
    10. var JSONSource = '../../data/Login.json';
    11. /* ]]> */
    12. </script>
    13. <link rel="stylesheet" type="text/css" href="../../css/reset-fonts-grids.css" />
    14. <link rel="stylesheet" type="text/css" href="../../css/xstyle.css" />
    15. <link rel="stylesheet" type="text/css" href="../../css/tcombox.css" />
    16. <link rel="stylesheet" type="text/css" href="../../css/branding.css" />
    17. <link rel="stylesheet" type="text/css" href="../../css/mainnav.css" />
    18. <link rel="stylesheet" type="text/css" href="../../css/subnav.css" />
    19. <link rel="stylesheet" type="text/css" href="../../css/securestatus.css" />
    20. <link rel="stylesheet" type="text/css" href="../../css/content.css" />
    21. <link rel="stylesheet" type="text/css" href="../../css/assistent.css" />
    22. <link rel="stylesheet" type="text/css" href="../../css/buttons.css" />
    23. <link rel="stylesheet" type="text/css" href="../../css/checkbox.css" />
    24. <link rel="stylesheet" type="text/css" href="../../css/overview.css" />
    25. <link rel="stylesheet" type="text/css" href="../../css/formular.css" />
    26. <link rel="stylesheet" type="text/css" href="../../css/jquery.selectbox.css" />
    27. <link rel="stylesheet" type="text/css" href="../../css/flyout.css" />
    28. <link rel="stylesheet" type="text/css" href="../../css/scrollbars.css" />
    29. <link rel="stylesheet" type="text/css" href="../../css/progressbar.css" />
    30. <link rel="stylesheet" type="text/css" href="../../css/testing.css" />
    31. <script type="text/javascript" src="../../js/jquery-1.3.2.min.js"></script>
    32. <script type="text/javascript" src="../../js/global.js"></script>
    33. <script type="text/javascript" src="../../js/external.libs.js"></script>
    34. <script type="text/javascript" src="../../js/jquery.logging.js"></script>
    35. <script type="text/javascript" src="../../js/jquery.i18n.js"></script>
    36. <script type="text/javascript" src="../../js/jquery.templateforms.js"></script>
    37. <script type="text/javascript" src="../../js/jquery-change.js"></script>
    38. <script type="text/javascript" src="../../js/jquery-addons.js"></script>
    39. <script type="text/javascript" src="../../js/jsonvariables.js"></script>
    40. <script type="text/javascript" src="../../js/pages/login.js"></script>
    41. <!--[if gt IE 8]>
    42. <link rel="stylesheet" type="text/css" href="../../css/ie9specific.css" />
    43. <![endif]-->
    44. <!--[if lte IE 8]>
    45. <link rel="stylesheet" type="text/css" href="../../css/ie8specific.css" />
    46. <![endif]-->
    47. <!--[if lte IE 6]>
    48. <link rel="stylesheet" type="text/css" href="../../css/ie6specific.css" />
    49. <![endif]-->
    50. </head>
    51. <body>
    52. <div id="container">
    53. <div id="brandingarea">
    54. <div id="brandingimage">
    55. <img id="tcomlogo" src="../../images/icons/t.gif" alt="Deutsche Telekom" />
    56. </div>
    57. <div id="brandinglinks" class="keepfont">
    58. <div id="metalinks" class="keepfont">
    59. <ul class="keepfont">
    60. <li class="keepfont"><a class="keepfont" href="#" id="scale_down" style="font-size: 0.8em;">A</a></li>
    61. <li class="keepfont"><a class="keepfont" href="#" id="scale_up" style="font-size: 1.2em;">A</a></li>
    62. <li class="keepfont"><a href="http://www.t-online.de/service/redir/aws_kc_telefonie.htm" class="keepfont" i18n:id="key_customerCenter" target="_blank">Kundencenter</a></li>
    63. <li class="keepfont"><a href="http://www.t-online.de/service/redir/aws_netzmanager.htm" class="keepfont" i18n:id="key_netManager" target="_blank">Netzmanager</a></li>
    64. <li class="keepfont" id="logoutlink"><a class="keepfont" href="#" i18n:id="logout">Logout</a></li>
    65. </ul>
    66. </div>
    67. </div>
    68. </div>
    69. <div id="navigationarea">
    70. <div class="mainnav_left" id="mn_00">
    71. <span></span>
    72. </div>
    73. <div>
    74. <a class="mainnav_middle" id="mn_01">
    75. <img src="../../images/icons/home_30x30.png"/>
    76. <span i18n:id="category_overview">Übersicht</span>
    77. </a>
    78. </div>
    79. <div>
    80. <a class="mainnav_middle" id="mn_02">
    81. <img src="../../images/icons/internet_30x30.png"/>
    82. <span i18n:id="category_internet">Internet</span>
    83. </a>
    84. </div>
    85. <div>
    86. <a class="mainnav_middle" id="mn_03">
    87. <img src="../../images/icons/phone_30x30.png"/>
    88. <span i18n:id="category_phone">Telefonie</span>
    89. </a>
    90. </div>
    91. <div>
    92. <a class="mainnav_middle" id="mn_04">
    93. <img src="../../images/icons/lan_30x30.png"/>
    94. <span i18n:id="category_lan">Heimnetzwerk</span>
    95. </a>
    96. </div>
    97. <div class="mainnav_middle" id="mn_05">
    98.  
    99. </div>
    100. <div>
    101. <a class="mainnav_right" id="mn_06">
    102. <img src="../../images/icons/settings_30x30.png"/>
    103. <span i18n:id="category_router">Einstellungen</span>
    104. </a>
    105. </div>
    106. </div>
    107. <div id="maincontentarea">
    108. <div id="assistent">
    109. <div class="form-internal">
    110. <address style="display: none;">
    111. <span class="form-action">../../data/Login.json</span>
    112. <span class="form-destination"></span>
    113. </address>
    114. <div id="contentcontainer">
    115. <div class="ccoben"> </div>
    116. <div class="ccmitte">
    117. <div id="containercontent">
    118. <div id="assistentcontent">
    119. <div>
    120. <h1 i18n:id="login_caption">Login zum Speedport Konfigurationsprogramm</h1>
    121. <div class="c1c">
    122. <span>
    123. <span i18n:id="login_content_1">Geben Sie das Gerätepasswort Ihres </span>
    124. <span id="login_device_name">Speedport</span>
    125. <span i18n:id="login_content_2"> ein.</span>
    126. </span>
    127. </div>
    128. <div class="c1c" i18n:id="login_content_3">
    129. Klicken Sie anschließend auf &bdquo;Login&rdquo;, um das Konfigurationsprogramm zu starten.
    130. </div>
    131. <div class="c1c">
    132. <div class="helpme" id="wfidgp">
    133. <a href="#" i18n:id="helpme_find_pwd">Wo finde ich das Gerätepasswort?</a>
    134. </div>
    135. </div>
    136. <div id="helpme_wfidgp" style="display: none;">
    137. <span i18n:id="helpme_find_pwd_content">Das Gerätepasswort finden Sie auf dem Typenschild auf der Rückseite Ihres Speedports, falls Sie es nicht schon selbst geändert haben.</span>
    138. <img src="../../images/visualizations/speedport_back.jpg" alt="Speedport back" style="display: block"/>
    139. </div>
    140. <div class="c1c">
    141. <div class="helpme" id="lostpw">
    142. <a href="#" i18n:id="helpme_lost_pwd">Gerätepasswort vergessen?</a>
    143. </div>
    144. </div>
    145. <div id="helpme_lostpw" i18n:id="helpme_lost_pwd_content" style="display: none;">
    146. Wenn Sie ein geändertes Gerätepasswort vergessen haben, können Sie den Speedport in die Werkseinstellungen zurücksetzen. Alle bisherigen Einstellungen gehen dabei verloren!
    147. Drücken Sie hierzu mit einem dünnen Gegenstand in die kleine, mit &lt;Reset&gt; bezeichnete Öffnung auf der Rückseite des Speedports für ca. 5 Sekunden.
    148. Verwenden Sie dann das voreingestellte Gerätepasswort, das auf dem Typenschild auf der Rückseite des Speedports aufgedruckt ist.
    149. Weitere Hinweise finden Sie in der Bedienungsanleitung zu Ihrem Speedport.
    150. </div>
    151. <div class="c1c" id="show_jshinw">
    152. <span class="warnmessage" i18n:id="login_jshinweis">
    153. Bitte aktivieren Sie Javascript in Ihrem Internet-Browser!
    154. </span>
    155. </div>
    156. <div class="c2c" style="display: none;" id="invalid_router_password">
    157. <div class="right">
    158. <span class="validationLabel" i18n:id="login_pwdhinweis">Geben Sie Ihr Gerätepasswort ein!</span>
    159. </div>
    160. </div>
    161. <div id="show_inppwd" style="display: none;">
    162. <div class="c2c">
    163. <div class="left" i18n:id="login_pwd_label">
    164. Gerätepasswort:
    165. </div>
    166. <div class="right">
    167. <input type="password" id="router_password" name="password" class="{validate:{required:true,minlength:1,maxlength:12}}"/>
    168. </div>
    169. </div>
    170. <div class="c2c" >
    171. <div class="right">
    172. <input type="checkbox"
    173. id="showpw_router_password" name="showpw"/><label
    174. for="showpw_router_password" i18n:id="display_chars">Zeichen anzeigen</label>
    175. </div>
    176. </div>
    177. </div>
    178. <div class="c1c" id="invalid_doublelogin" style="display: none;">
    179. <span class="warnmessage">
    180. <span i18n:id="error_message_doublelogin_1">Das Konfigurationsprogramm wird bereits von einem Benutzer des Computers mit der IP-Adresse</span>
    181. <span id="login_other_ip">0.0.0.0</span>
    182. <span i18n:id="error_message_doublelogin_2">verwendet. Es können nicht mehrere Computer gleichzeitig auf das Konfigurationsprogramm zugreifen.</span>
    183. </span>
    184. </div>
    185. <div class="c1c" id="invalid_login" style="display: none;">
    186. <span class="warnmessage" i18n:id="error_message_login">
    187. Login fehlgeschlagen. Sie haben ein falsches Gerätepasswort eingegeben.
    188. Bitte versuchen Sie es erneut und achten Sie auf die korrekte Schreibweise.
    189. </span>
    190. </div>
    191. <div class="c1c" id="login_locked" style="display: none;">
    192. <span class="warnmessage">
    193. <span i18n:id="login_locked_1">Der Login ist für</span>
    194. <span id="login_disabled_seconds">0</span>
    195. <span i18n:id="login_locked_2">Sekunden gesperrt.</span>
    196. </span>
    197. </div>
    198. </div>
    199. <div id="is_login_page"></div>
    200. </div>
    201. </div>
    202. <div style="clear: both;"></div>
    203. </div>
    204. <div class="ccmitte" id="footercontent">
    205. <div class="footerborder"></div>
    206. <div id="fooooter">
    207. <div class="buttongroup">
    208. <button id="loginbutton" type="submit" name="action" class="submitBtnActive" style="display: none;" i18n:id="btn_login">Login</button>
    209. </div>
    210. </div>
    211. </div>
    212. <div class="ccunten"> </div>
    213. </div>
    214. </div>
    215. </div>
    216. <script type="text/javascript">
    217. /* <![CDATA[ */
    218. (function($){
    219. $(document).ready(function() {
    220. $(".form-internal").each(function() {
    221. var theForm = $(this).templateForm({doNotCreate:true});
    222. if (theForm !== undefined) {
    223. theForm.requiredCheck(true);
    224. }
    225. });
    226. });
    227. }(jQuery));
    228. /* ]]> */
    229. </script>
    230. </div>
    231. </div>
    232. <div id="wheelpane" style="display: block; display: none; z-index: 600000;">
    233. <span class="wheel"></span>
    234. </div>
    235. <div style="display: none; z-index: 600000;">
    236. <span i18n:id="scale_down_font" id="scale_down_font">Zum Verkleinern bitte Tastenkombination Strg- benutzen.</span>
    237. <span i18n:id="scale_up_font" id="scale_up_font">Zum Vergrößern bitte Tastenkombination Strg+ benutzen.</span>
    238. </div>
    239. </body>
    240. </html>

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „flori5885“ ()