<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Автоматизация роутеров через WinHttpRequest]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=17684&amp;type=atom" />
	<updated>2023-03-13T09:03:24Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=17684</id>
		<entry>
			<title type="html"><![CDATA[AHK: Автоматизация роутеров через WinHttpRequest]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=157154#p157154" />
			<content type="html"><![CDATA[<p>TP-LINK.<br /></p><div class="codebox"><pre><code>login := &quot;login&quot;
pass := &quot;pass&quot;
link := &quot;http://192.168.0.1&quot;

WebRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
WebRequest.Open(&quot;GET&quot;, link)
WebRequest.Send()
link .= &quot;/userRpm/LoginRpm.htm?Save=Save&quot;
Authorization := &quot;Authorization=Basic &quot; b64Encode(login &quot;:&quot; MD5(pass))
WebRequest.Open(&quot;GET&quot;, link)
WebRequest.SetRequestHeader(&quot;Cookie&quot;, Authorization)
WebRequest.Send()
msgbox % WebRequest.ResponseText   ; получаем ссылку для дальнейших действий, помимо Cookie нужно будет отправлять referer



b64Encode(string)
{
    VarSetCapacity(bin, StrPut(string, &quot;UTF-8&quot;)) &amp;&amp; len := StrPut(string, &amp;bin, &quot;UTF-8&quot;) - 1 
    if !(DllCall(&quot;crypt32\CryptBinaryToString&quot;, &quot;ptr&quot;, &amp;bin, &quot;uint&quot;, len, &quot;uint&quot;, 0x1, &quot;ptr&quot;, 0, &quot;uint*&quot;, size))
        throw Exception(&quot;CryptBinaryToString failed&quot;, -1)
    VarSetCapacity(buf, size &lt;&lt; 1, 0)
    if !(DllCall(&quot;crypt32\CryptBinaryToString&quot;, &quot;ptr&quot;, &amp;bin, &quot;uint&quot;, len, &quot;uint&quot;, 0x1, &quot;ptr&quot;, &amp;buf, &quot;uint*&quot;, size))
        throw Exception(&quot;CryptBinaryToString failed&quot;, -1)
    return StrGet(&amp;buf)
}

MD5(string, case := False)    ; by SKAN | rewritten by jNizM
{
    static MD5_DIGEST_LENGTH := 16
    hModule := DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, &quot;advapi32.dll&quot;, &quot;Ptr&quot;)
    , VarSetCapacity(MD5_CTX, 104, 0), DllCall(&quot;advapi32\MD5Init&quot;, &quot;Ptr&quot;, &amp;MD5_CTX)
    , DllCall(&quot;advapi32\MD5Update&quot;, &quot;Ptr&quot;, &amp;MD5_CTX, &quot;AStr&quot;, string, &quot;UInt&quot;, StrLen(string))
    , DllCall(&quot;advapi32\MD5Final&quot;, &quot;Ptr&quot;, &amp;MD5_CTX)
    loop % MD5_DIGEST_LENGTH
        o .= Format(&quot;{:02&quot; (case ? &quot;X&quot; : &quot;x&quot;) &quot;}&quot;, NumGet(MD5_CTX, 87 + A_Index, &quot;UChar&quot;))
    return o, DllCall(&quot;FreeLibrary&quot;, &quot;Ptr&quot;, hModule)
}</code></pre></div><p><a href="http://forum.script-coding.com/viewtopic.php?id=14356">Тема для обсуждения</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-03-13T09:03:24Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=157154#p157154</id>
		</entry>
</feed>
