Hi,
Du lässt ein 32 Bit auf 64 Bit laufen.
s. helpfile AutoIT
Hy cool, das habe ich total übersehen da ich meistens auch 32 bit Maschienen arbeite, wenn ich das script im 32 bitmodus laufen lasse geht es. Danke!!!
Beiträge von Tigger1975
-
-
Alles anzeigen
Funktioniert doch!
Hier noch mal in einer Funktion:
Spoiler anzeigen
[autoit]ConsoleWrite(_RegexMatches('\d+', 'ABC123DEF') & @CRLF)
[/autoit] [autoit][/autoit] [autoit]Func _RegexMatches($sPattern, $sString)
[/autoit]
Local $sCode = 'Function RegexMatches(sPattern, sString)' & _
@LF & ' Dim oRegEx, oMatch, oMatches, RetStr' & _ ; Create variables.
@LF & ' Set oRegEx = New RegExp' & _ ; Create regular expression.
@LF & ' oRegEx.Pattern = sPattern' & _ ; Set pattern.
@LF & ' oRegEx.IgnoreCase = True' & _ ; Set case sensitivity.
@LF & ' oRegEx.Global = True' & _ ; Set Global option.
@LF & ' Set oMatches = oRegEx.Execute(sString)' & _ ; Execute the search test.
@LF & ' For Each oMatch in oMatches' & _
@LF & ' RetStr = RetStr & "Match found at position "' & _
@LF & ' RetStr = RetStr & oMatch.FirstIndex & vbCRLF' & _
@LF & ' RetStr = RetStr & "Match Value is "' & _
@LF & ' RetStr = RetStr & oMatch.Value & "." & vbCRLF & vbCRLF' & _
@LF & ' Next' & _
@LF & ' RegexMatches = RetStr' & _
@LF & 'End Function' & @LF
Local $Vbs = ObjCreate('ScriptControl')
$Vbs.Language = 'VBScript'
$Vbs.AddCode($sCode)
$sRET = $Vbs.Run('RegexMatches', $sPattern, $sString)
Return $sRet
EndFuncHm... meine Fehlermeldung:
Spoiler anzeigen
>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Rollout\Desktop\wsctest.au3" /autoit3dir "C:\Program Files (x86)\AutoIt3" /UserParams
+>10:06:07 Starting AutoIt3Wrapper v.2.0.0.1 Environment(Language:0409 Keyboard:00000407 OS:WIN_2008/Service Pack 2 CPU:X64 OS:X64)
>Running AU3Check (1.54.14.0) from:C:\Program Files (x86)\AutoIt3
+>10:06:07 AU3Check ended.rc:0
>Running:(3.3.0.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\Rollout\Desktop\wsctest.au3"
C:\Users\Rollout\Desktop\wsctest.au3 (20) : ==> Variable must be of type "Object".:
$Vbs.Language = 'VBScript'
$Vbs^ ERROR
->10:06:07 AutoIT3.exe ended.rc:1
+>10:06:08 AutoIt3Wrapper Finished
>Exit code: 1 Time: 1.346 -
fehlt da nicht irgendwie
[autoit]GuiCtrlCreateObj
[/autoit]Wiso meinst du das?? ist doch kein Gui Element alles was ich mache hat nicht uns soll auch nichts mit einer Gui zu tun haben.
Laut Anleitungen im Inet soll das so gehen:
Spoiler anzeigen
[autoit]Global $Vbs, $sCode, $sRET
[/autoit] [autoit][/autoit] [autoit]$sCode = 'Function RegexMatches(sPattern, sString)' & _
[/autoit] [autoit][/autoit] [autoit]
@LF & ' Dim oRegEx, oMatch, oMatches, RetStr' & _ ; Create variables.
@LF & ' Set oRegEx = New RegExp' & _ ; Create regular expression.
@LF & ' oRegEx.Pattern = sPattern' & _ ; Set pattern.
@LF & ' oRegEx.IgnoreCase = True' & _ ; Set case sensitivity.
@LF & ' oRegEx.Global = True' & _ ; Set Global option.
@LF & ' Set oMatches = oRegEx.Execute(sString)' & _ ; Execute the search test.
@LF & ' For Each oMatch in oMatches' & _
@LF & ' RetStr = RetStr & "Match found at position "' & _
@LF & ' RetStr = RetStr & oMatch.FirstIndex & vbCRLF' & _
@LF & ' RetStr = RetStr & "Match Value is "' & _
@LF & ' RetStr = RetStr & oMatch.Value & "." & vbCRLF & vbCRLF' & _
@LF & ' Next' & _
@LF & ' RegexMatches = RetStr' & _
@LF & 'End Function' & _
@LF$Vbs = ObjCreate('ScriptControl')
[/autoit] [autoit][/autoit] [autoit]
If @error Then
MsgBox(16, 'Error', 'Error creating MSScriptControl.ScriptControl')
Exit
EndIf$Vbs.Language = 'VBScript'
[/autoit] [autoit][/autoit] [autoit]$Vbs.AddCode($sCode)
[/autoit] [autoit][/autoit] [autoit]$sRET = $Vbs.Run('RegexMatches', '\d+', 'ABC123DEF')
[/autoit] [autoit][/autoit] [autoit]
Funktioniert bei mir Aber nicht.ConsoleWrite("$sRET = " & $sRET & @LF)
[/autoit] -
[autoit]
$SC = ObjCreate("MSScriptControl.ScriptControl")
[/autoit]
if IsObj($SC) Then
$SC.Language = "VBScript"
Else
_log("Error","Scriptcontrole Objekt konnte nicht initialisiert werden")
EndIfum mit
$sc.addcode($code)
dann den VBscriptcode ausführen zu lassen.
Für Lösungsvorschläge bin ich dankbar
P.S. $SC = ObjCreate('ScriptControl') habe ich schon versucht geht leider nicht.

-
Manchmal ist der Verweis darauf, dass man ein Problem nicht weiter verfolgen sollte, genauso wertvoll, wie Lösungswege. Und das trifft bei der Thematik halt zu: Finger weg!
Mit dieser Aussage trittst du vielen von uns freiwilligen Helfern gewaltig auf die Füße.
Wir bemühen uns und suchen selbst aus teilweise recht hilflos gestammelten Problembeschreibungen noch Aussagen heraus, um dem Fragenden Hilfe zu leisten. Das außerdem in einer beachtlich kurzen Reaktionszeit!Naja Klar ist es Manch mal besser von einer Sache die Finger zu lassen, dass hatte ich auch nicht gemeint, sondern Suchte Er ja einen Lösungsansatz wie man Dateien richtig von der Platte putzten könnte. Nach etwas warte zeit kommt dann 1. Durch die Steuerung das Dateisystems geht sein Lösungsansatz nicht. das ist auch richtig und gut. 2. Kommt die aussage die AU3 die er verendet ist Sch.... und er solle davon die Finger lassen, was ich mir Gewünscht hätte wäre schau mal hier .... oder Versuchsmal hiermit..... u.s.w.
Ich bin mir bewusst das das Ihr einen Guten Job macht. Mir ist tatsächlich auch mal geholfen worden. Aber NUR die aussage Geht nicht oder Sch... .au3 Hilft doch nicht wenn man Selbst, und so ist es bei mir, Stundenlang vor einem Problem hängt und mit zich Lösungsansätzen nicht weiter kommt. Man will doch Vielleicht nur eine Idee, nicht die Lösung.
Aber, wobei ich die Jedenfalls voll recht gebe ist das manche hier meinen es gäbe bei euch Glaskugeln und Wundermaschinen.
So ... zu guter Letzt möchte ich mich
1. dafür Entschuldigen das ich eine Grundsatz Diskussion ausgelöst habe, das war nicht meine Absicht.
2. Möchte ich mich Entschuldigen wenn ich Jemandem auf die Füße getreten habe auch dies war nicht wirklich meine Absicht.P.S. Immerhin gab es dann doch noch einen Lösungsversuch. Mehr wollte ich doch Gar nicht erreichen.
Guss und Kuss
Jetzt sind wir hoffentlich alle wieder Freunde. -
Also hier mal ein Beispiel wie man sich an der Fritz!Box Anmelden kann.
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit]
#include <http.au3>
#include <MD5.au3>$host = "fritz.box"
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit]
$Fritzpass = "Password"
$Challenge=StringRegExp(_INetGetSource("http://" & $host & "/cgi-bin/webcm?getpage=../html/login_sid.xml"),"<Challenge>(.*)</Challenge>",1)
$Challenge=$Challenge[0]
$CPSTR=$Challenge & "-" & $Fritzpass
$MD5 = StringLower(StringReplace(_MD5(StringToBinary($CPSTR, 2)),"0x",""))
$RESPONSE = $Challenge & "-" & $MD5
$POSTDATA="login:command/response=" & $RESPONSE & "&getpage=../html/de/menus/menu2.html"
$httpsocet = _HTTPConnect($host)
$RC = _HTTPPost($host, "http://" & $host & "/cgi-bin/webcm", $httpsocet,$POSTDATA)
sleep(1000)
$RC = _HTTPRead($httpsocet,0)
$SID = StringRegExp($RC,'[nNaAmMeE]+="[sSiIdD]+"\s*[vVaAlLuUeE]+\s*=\s*"(.*)"\s+',1)
$SID = $SID[0]
if $SID == "" Then
$ErrorMessage = StringRegExp($RC,'errorMessage">(.*)<',1)
$ErrorMessage = $ErrorMessage[0]
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ErrorMessage = ' & $ErrorMessage & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
EndIf
$RC = _HTTPPost($host, "http://" & $host & "/cgi-bin/webcm?sid=" & $SID & " &getpage=../html/de/menus/menu2.html&errorpage=../html/de/menus/menu2.html&var:pagename=foncalls&var:errorpagename=foncalls&var:menu=home&var:pagemaster=&var:activtype=pppoe&var:tabInetstat=0&var:weckernr=&logger:settings/filter=2", $httpsocet)
sleep(2000)
$CallList=_INetGetSource("http://" & $host & "/cgi-bin/webcm?sid=" & $SID & "&getpage=../html/de/FRITZ!Box_Anrufliste.csv")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $CallList = ' & $CallList & @crlf & '>Error code: ' & @error & @crlf) ;### Debug ConsoleAls nächste die beiden Include Files http.au3
Spoiler anzeigen
[autoit]; ===================================================================
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
; HTTP UDF's
; v0.5
;
; By: Greg "Overload" Laabs
; Last Updated: 07-22-06
; Tested with AutoIt Version 3.1.1.131
; Extra requirements: Nothing!
;
; A set of functions that allow you to download webpages and submit
; POST requests.
;
; Main functions:
; _HTTPConnect - Connects to a webserver
; _HTTPGet - Submits a GET request to a webserver
; _HTTPPost - Submits a POST request to a webserver
; _HTTPRead - Reads the response from a webserver
; ===================================================================TCPStartup()
[/autoit] [autoit][/autoit] [autoit]Global $_HTTPUserAgent = "AutoItScript/"&@AutoItVersion
[/autoit] [autoit][/autoit] [autoit]
Global $_HTTPLastSocket = -1
Global $_HTTPRecvTimeout = 30000; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPSetUserAgent($Program, $Version)
;
; Sets the User-Agent that will be sent with all future _HTTP
; functions. If this is never called, the user agent is set to
; AutoItScript/[YourAutoItVersion]
; Parameters:
; $Program - IN - The name of the program
; $Version - IN - The version number of the program
; Returns:
; None
; ===================================================================
Func _HTTPSetUserAgent($Program, $Version)
$_HTTPUserAgent = $Program&"/"&$Version
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPConnect($host, [$port])
;
; Opens a connection to $host on the port you supply (or 80 if you don't supply a port. Returns the socket of the connection.
; Parameters:
; $host - IN - The hostname you want to connect to. This should be in the format "www.google.com" or "localhost"
; $port - OPTIONAL IN - The port to connect on. 80 is default.
; Returns:
; The socket of the connection.
; Remarks:
; Possible @errors:
; 1 - Unable to open socket - @extended is set to Windows API WSAGetLasterror return
; ===================================================================
Func _HTTPConnect($host, $port = 80)
Dim $ip = TCPNameToIP ( $host )
Dim $socket = TCPConnect ( $ip, 80 )If ($socket == -1) Then
[/autoit] [autoit][/autoit] [autoit]
SetError(1, @error)
Return -1
EndIf
$_HTTPLastSocket = $socket
SetError(0)
Return $socket
EndFunc; Possible @errors:
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
; 1 - No socket
Func _HTTPClose($socket = -1)
If $socket == -1 Then
If $_HTTPLastSocket == -1 Then
SetError(1)
Return 0
EndIf
$socket = $_HTTPLastSocket
EndIf
TCPCloseSocket($socket)
SetError(0)
Return 1
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPGet($host, $page, [$socket])
;
; Executes a GET request on an open socket.
; Parameters:
; $host - IN - The hostname you want to get the page from. This should be in the format "www.google.com" or "localhost"
; $page - IN - The the file you want to get. This should always start with a slash. Examples: "/somepage.php" or "/somedirectory/somefile.zip"
; $socket - OPTIONAL IN - The socket opened by _HTTPConnect. If this is not supplied, the last socket opened with _HTTPConnect will be used.
; Returns:
; The number of bytes sent in the request.
; Remarks:
; Possible @errors:
; 1 - No socket supplied and no current socket exists
; 2 - Error sending to socket. Check @extended for Windows API WSAGetError return
; ===================================================================
Func _HTTPGet($host, $page, $socket = -1)
Dim $command
If $socket == -1 Then
If $_HTTPLastSocket == -1 Then
SetError(1)
Return
EndIf
$socket = $_HTTPLastSocket
EndIf
$command = "GET "&$page&" HTTP/1.1"&@CRLF
$command &= "Host: " &$host&@CRLF
$command &= "User-Agent: "&$_HTTPUserAgent&@CRLF
$command &= "Connection: close"&@CRLF
$command &= ""&@CRLF
Dim $bytessent = TCPSend($socket, $command)
If $bytessent == 0 Then
SetExtended(@error)
SetError(2)
return 0
EndIf
SetError(0)
Return $bytessent
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPPost($host, $page, [$socket])
;
; Executes a POST request on an open socket.
; Parameters:
; $host - IN - The hostname you want to get the page from. This should be in the format "www.google.com" or "localhost"
; $page - IN - The the file you want to get. This should always start with a slash. Examples: "/" or "/somedirectory/submitform.php"
; $socket - OPTIONAL IN - The socket opened by _HTTPConnect. If this is not supplied, the last socket opened with _HTTPConnect will be used.
; $data - OPTIONAL IN - The data to send in the post request. This should first be run through _HTTPEncodeString()
; Returns:
; The number of bytes sent in the request.
; Remarks:
; Possible @errors:
; 1 - No socket supplied and no current socket exists
; 2 - Error sending to socket. Check @extended for Windows API WSAGetError return
; ===================================================================
Func _HTTPPost($host, $page, $socket = -1, $data = "")
Dim $command
If $socket == -1 Then
If $_HTTPLastSocket == -1 Then
SetError(1)
Return
EndIf
$socket = $_HTTPLastSocket
EndIf
Dim $datasize = StringLen($data)
$command = "POST "&$page&" HTTP/1.1"&@CRLF
$command &= "Host: " &$host&@CRLF
$command &= "User-Agent: "&$_HTTPUserAgent&@CRLF
$command &= "Connection: close"&@CRLF
$command &= "Content-Type: application/x-www-form-urlencoded"&@CRLF
$command &= "Content-Length: "&$datasize&@CRLF
$command &= ""&@CRLF
$command &= $data&@CRLF
Dim $bytessent = TCPSend($socket, $command)
If $bytessent == 0 Then
SetExtended(@error)
SetError(2)
return 0
EndIf
SetError(0)
Return $bytessent
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPRead([$socket], [$flag])
;
; Retrieves data from an open socket. This should only be called after _HTTPGet or _HTTPPost is called.
; Parameters:
; $socket - OPTIONAL IN - The socket you want to receive data from. If this is not supplied, the last socket opened with _HTTPConnect will be used.
; $flag - OPTIONAL IN - Determines how the data will be returned. See Remarks.
; Returns:
; See "Flags" in remarks, below.
; Remarks:
; Possible @errors:
; 1 - No socket
; 3 - Timeout reached before any data came through the socket
; 4 - Some data came through, but not all of it. Return value is the number of bytes received.
; 5 - Unable to parse HTTP Response from server. Return value is the HTTP Response line
; 6 - Unexpected header data returned. Return value is the line that caused the error
; 7 - Invalid flag
; 8 - Unable to parse chunk size. Return value is the line that caused the error
; Flags:
; 0 - Return value is the body of the page (default)
; 1 - Return value is an array:
; [0] = HTTP Return Code
; [1] = HTTP Return Reason (human readable return code like "OK" or "Forbidden"
; [2] = HTTP Version
; [3] = Two dimensional array with the headers. Each item has:
; [0] = Header name
; [1] = Header value
; [4] = The body of the page
; ===================================================================
Func _HTTPRead($socket = -1, $flag = 0)
If $socket == -1 Then
If $_HTTPLastSocket == -1 Then
SetError(1)
Return
EndIf
$socket = $_HTTPLastSocket
EndIf
Dim $timer = TimerInit()
Dim $performancetimer = TimerInit()
Dim $downloadtime = 0
Dim $headers[1][2] ; An Array of the headers found
Dim $numheaders = 0 ; The number of headers found
Dim $body = "" ; The body of the message
Dim $HTTPVersion ; The HTTP version of the server (almost always 1.1)
Dim $HTTPResponseCode ; The HTTP response code like 200, or 404
Dim $HTTPResponseReason ; The human-readable response reason, like "OK" or "Not Found"
Dim $bytesreceived = 0 ; The total number of bytes received
Dim $data = "" ; The entire raw message gets put in here.
Dim $chunked = 0 ; Set to 1 if we get the "Transfer-Encoding: chunked" header.
Dim $chunksize = 0 ; The size of the current chunk we are processing.
Dim $chunkprocessed = 0 ; The amount of data we have processed on the current chunk.
Dim $contentlength ; The size of the body, if NOT using chunked transfer mode.
Dim $part = 0 ; Refers to what part of the data we're currently parsing:
; 0 - Nothing parsed, so HTTP response should come next
; 1 - Currently parsing headers
; 2 - Currently waiting for the next chunk size - this is skipped if the transfer-encoding is not chunked
; 3 - Currently waiting for or parsing body data
; 4 - Currently parsing footers
;While 1
Sleep(10)
Dim $recv = TCPRecv($socket,16)
If @error <> 0 Then
;ConsoleWrite("Server closed connection")
;@error appears to be -1 after the server closes the connection. A good way to tell that we're finished, because we always send
;the "Connection: close" header to the server.
; !!! This is no longer used because we can now tell that we're done by checking the content-length header or properly handling
; chunked data.
EndIf
While $recv <> ""
;If $recv <> "" Then
$bytesreceived = $bytesreceived + StringLen($recv)
$timer = TimerInit()
$data &= $recv
;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $data = ' & $data & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;ConsoleWrite("Bytes downloaded: "&$bytesreceived&@CRLF)
;EndIf
$recv = TCPRecv($socket,2048)
WEnd
Dim $split = StringSplit($data,@CRLF,1)
$data = ""
Dim $i
For $i=1 To $split[0]
If $i=$split[0] Then
If $part < 2 OR $chunked = 1 Then
; This is tricky. The last line we've received might be truncated, so we only want to process it under special cases.
; Non chunked data doesn't always send a CRLF at the end so there's no way to tell if this is truly the last line without parsing it.
; However, we don't want to parse it if it's only a partial header or something.
; The solution: We will only process this last line if we're at the body section and the transfer-encoding is NOT chunked.
$data = $split[$i]
ExitLoop
EndIf
EndIf
Dim $newpart = $part
Switch $part
Case 0 ; Nothing parsed, so HTTP response should come next
If $split[$i] <> "" Then
Dim $regex = StringRegExp($split[$i],"^HTTP/([0-9.]+) ([0-9]+) ([a-zA-Z0-9 ]+)$",3)
If @error <> 0 Then
SetError(5)
Return $split[$i]
Else
$HTTPVersion = $regex[0]
$HTTPResponseCode = $regex[1]
$HTTPResponseReason = $regex[2]
If $HTTPResponseCode <> 100 Then
$newpart = 1
EndIf
EndIf
EndIf
Case 1, 4 ; Currently parsing headers or footers
;If the line is blank, then we're done with headers and the body is next
If $split[$i] == "" Then
If $part = 1 Then
If $chunked Then
$newpart = 2
Else
$newpart = 3
EndIf
ElseIf $part = 4 Then
; If $part is 4 then we're processing footers, so we're all done now.
ExitLoop 2
EndIf
Else ;The line wasn't blank
;Check to see if the line begins with whitespace. If it does, it's actually
;a continuation of the previous header
Dim $regex = StringRegExp($split[$i], "^[ \t]+([^ \t].*)$", 3)
If @error <> 1 Then
If $numheaders == 0 Then
SetError(6)
Return $split[$i]
EndIf
$headers[$numheaders-1][1] &= $regex[0]
Else;The line didn't start with a space
Dim $regex = StringRegExp($split[$i],"^([^ :]+):[ \t]*(.*)$",3)
If @error <> 1 Then
;This is a new header, so add it to the array
$numheaders = $numheaders + 1
ReDim $headers[$numheaders][2]
$headers[$numheaders-1][0] = $regex[0]
$headers[$numheaders-1][1] = $regex[1]
; There are a couple headers we need to know about. We'll process them here.
If $regex[0] = "Transfer-Encoding" AND $regex[1] = "chunked" Then
$chunked = 1
ElseIf $regex[0] = "Content-Length" Then
$contentlength = Int($regex[1])
EndIf
Else
SetError(6)
Return $split[$i]
EndIf
EndIf
EndIf
Case 2 ; Awaiting chunk size
$regex = StringRegExp($split[$i],"^([0-9a-f]+);?.*$",3)
If @error <> 0 Then
SetError(8)
Return $split[$i]
EndIf
$chunksize = $regex[0]
$chunksize = Dec($chunksize)
$chunkprocessed = 0
If $chunksize == 0 Then
$newpart = 4
Else
$newpart = 3
EndIf
Case 3 ; Awaiting body data
$body &= $split[$i]
$chunkprocessed = $chunkprocessed + StringLen($split[$i])
If $chunked Then
If $chunkprocessed >= $chunksize Then
$newpart = 2
Else
$body &= @CRLF
$chunkprocessed = $chunkprocessed + 2; We add 2 for the CRLF we stipped off.
EndIf
Else
If not $chunkprocessed >= $contentlength Then
If $i < $split[0] Then
; Only add a CRLF if this is not the last line received.
$body &= @CRLF
$chunkprocessed = $chunkprocessed + 2; We add 2 for the CRLF we stipped off.
EndIf
EndIf
EndIf
Case Else
; This should never happen
EndSwitch
$part = $newpart
Next
If $bytesreceived == 0 AND TimerDiff($timer) > $_HTTPRecvTimeout Then
SetError(3)
Return 0
ElseIf $bytesreceived > 0 AND TimerDiff($timer) > $_HTTPRecvTimeout Then
ConsoleWrite($body)
SetError(4)
Return $bytesreceived
EndIf
;WEnd
$downloadtime = TimerDiff($performancetimer)
;ConsoleWrite("Performance: Download time: "&$downloadtime&@CRLF)
Switch $flag
Case 0
SetError(0)
Return $body
Case 1
Dim $return[5]
$return[0] = $HTTPResponseCode
$return[1] = $HTTPResponseReason
$return[2] = $HTTPVersion
$return[3] = $headers
$return[4] = $body
SetError(0)
Return $return
Case Else
SetError(7)
Return 0
EndSwitch
EndFunc; ===================================================================
[/autoit]
; _HTTPEncodeString($string)
;
; Encodes a string so it can safely be transmitted via HTTP
; Parameters:
; $string - IN - The string to encode
; Returns:
; A valid encoded string that can be used as GET or POST variables.
; ===================================================================
Func _HTTPEncodeString($string)
Local Const $aURIValidChars[256] = _
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, _
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Local $sEncoded = ""
For $i = 1 To StringLen($string)
Local $c = StringMid($string, $i, 1)
If $c = " " Then $c = "+"
If Number($aURIValidChars[Asc($c) ]) Then
$sEncoded &= $c
Else
$sEncoded &= StringFormat("%%X", Asc($c))
EndIf
Next
Return $sEncoded
EndFunc ;==>_WebComposeURLUnd die MD5 Includedatei mit Freundlicher Unterstützung von Xenobiologist
Spoiler anzeigen
[autoit]Func _MD5($Data)
[/autoit] [autoit][/autoit] [autoit]
Local $_MD5CodeBuffer
Local $_MD5Opcode = '0xC85800005356576A006A006A008D45A850E8280000006A00FF750CFF75088D45A850E8440000006A006A008D45A850FF7510E8710700005F5E5BC9C210005589E58B4D0831C0894114894110C70101234567C7410489ABCDEFC74108FEDCBA98C7410C765432105DC21000C80C0000538B5D088B4310C1E80383E03F8945F88B4510C1E0030143103943107303FF43148B4510C1E81D0143146A40582B45F88945F4394510724550FF750C8B45F88D44031850E8A00700008D43185053E84E0000008B45F48945FC8B45FC83C03F39451076138B450C0345FC5053E8300000008345FC40EBE28365F800EB048365FC008B45102B45FC508B450C0345FC508B45F88D44031850E84D0700005BC9C21000C84000005356576A40FF750C8D45C050E8330700008B45088B088B50048B70088B780C89D021F089D3F7D321FB09D801C1034DC081C178A46AD7C1C10701D189C821D089CBF7D321F309D801C7037DC481C756B7C7E8C1C70C01CF89F821C889FBF7D321D309D801C60375C881C6DB702024C1C61101FE89F021F889F3F7D321CB09D801C20355CC81C2EECEBDC1C1C21601F289D021F089D3F7D321FB09D801C1034DD081C1AF0F7CF5C1C10701D189C821D089CBF7D321F309D801C7037DD481C72AC68747C1C70C01CF89F821C889FBF7D321D309D801C60375D881C6134630A8C1C61101FE89F021F889F3F7D321CB09D801C20355DC81C2019546FDC1C21601F289D021F089D3F7D321FB09D801C1034DE081C1D8988069C1C10701D189C821D089CBF7D321F309D801C7037DE481C7AFF7448BC1C70C01CF89F821C889FBF7D321D309D801C60375E881C6B15BFFFFC1C61101FE89F021F889F3F7D321CB09D801C20355EC81C2BED75C89C1C21601F289D021F089D3F7D321FB09D801C1034DF081C12211906BC1C10701D189C821D089CBF7D321F309D801C7037DF481C7937198FDC1C70C01CF89F821C889FBF7D321D309D801C60375F881C68E4379A6C1C61101FE89F021F889F3F7D321CB09D801C20355FC81C22108B449C1C21601F289D021F889FBF7D321F309D801C1034DC481C162251EF6C1C10501D189C821F089F3F7D321D309D801C7037DD881C740B340C0C1C70901CF89F821D089D3F7D321CB09D801C60375EC81C6515A5E26C1C60E01FE89F021C889CBF7D321FB09D801C20355C081C2AAC7B6E9C1C21401F289D021F889FBF7D321F309D801C1034DD481C15D102FD6C1C10501D189C821F089F3F7D321D309D801C7037DE881C753144402C1C70901CF89F821D089D3F7D321CB09D801C60375FC81C681E6A1D8C1C60E01FE89F021C889CBF7D321FB09D801C20355D081C2C8FBD3E7C1C21401F289D021F889FBF7D321F309D801C1034DE481C1E6CDE121C1C10501D189C821F089F3F7D321D309D801C7037D'
$_MD5Opcode &= 'F881C7D60737C3C1C70901CF89F821D089D3F7D321CB09D801C60375CC81C6870DD5F4C1C60E01FE89F021C889CBF7D321FB09D801C20355E081C2ED145A45C1C21401F289D021F889FBF7D321F309D801C1034DF481C105E9E3A9C1C10501D189C821F089F3F7D321D309D801C7037DC881C7F8A3EFFCC1C70901CF89F821D089D3F7D321CB09D801C60375DC81C6D9026F67C1C60E01FE89F021C889CBF7D321FB09D801C20355F081C28A4C2A8DC1C21401F289D031F031F801C1034DD481C14239FAFFC1C10401D189C831D031F001C7037DE081C781F67187C1C70B01CF89F831C831D001C60375EC81C622619D6DC1C61001FE89F031F831C801C20355F881C20C38E5FDC1C21701F289D031F031F801C1034DC481C144EABEA4C1C10401D189C831D031F001C7037DD081C7A9CFDE4BC1C70B01CF89F831C831D001C60375DC81C6604BBBF6C1C61001FE89F031F831C801C20355E881C270BCBFBEC1C21701F289D031F031F801C1034DF481C1C67E9B28C1C10401D189C831D031F001C7037DC081C7FA27A1EAC1C70B01CF89F831C831D001C60375CC81C68530EFD4C1C61001FE89F031F831C801C20355D881C2051D8804C1C21701F289D031F031F801C1034DE481C139D0D4D9C1C10401D189C831D031F001C7037DF081C7E599DBE6C1C70B01CF89F831C831D001C60375FC81C6F87CA21FC1C61001FE89F031F831C801C20355C881C26556ACC4C1C21701F289F8F7D009D031F001C1034DC081C1442229F4C1C10601D189F0F7D009C831D001C7037DDC81C797FF2A43C1C70A01CF89D0F7D009F831C801C60375F881C6A72394ABC1C60F01FE89C8F7D009F031F801C20355D481C239A093FCC1C21501F289F8F7D009D031F001C1034DF081C1C3595B65C1C10601D189F0F7D009C831D001C7037DCC81C792CC0C8FC1C70A01CF89D0F7D009F831C801C60375E881C67DF4EFFFC1C60F01FE89C8F7D009F031F801C20355C481C2D15D8485C1C21501F289F8F7D009D031F001C1034DE081C14F7EA86FC1C10601D189F0F7D009C831D001C7037DFC81C7E0E62CFEC1C70A01CF89D0F7D009F831C801C60375D881C6144301A3C1C60F01FE89C8F7D009F031F801C20355F481C2A111084EC1C21501F289F8F7D009D031F001C1034DD081C1827E53F7C1C10601D189F0F7D009C831D001C7037DEC81C735F23ABDC1C70A01CF89D0F7D009F831C801C60375C881C6BBD2D72AC1C60F01FE89C8F7D009F031F801C20355E481C291D386EBC1C21501F28B4508010801500401700801780C5F5E5BC9C20800C814000053E840000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008F45EC8B5D0C6A088D4310508D'
$_MD5Opcode &= '45F850E8510000008B4310C1E80383E03F8945F483F838730B6A38582B45F48945F0EB096A78582B45F48945F0FF75F0FF75ECFF750CE831F8FFFF6A088D45F850FF750CE823F8FFFF6A1053FF7508E8050000005BC9C210005589E55156578B7D088B750C8B4D10FCF3A45F5E595DC20C00'
Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($_MD5Opcode) & "]")
DllStructSetData($CodeBuffer, 1, $_MD5Opcode)Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]")
[/autoit] [autoit][/autoit] [autoit]
DllStructSetData($Input, 1, $Data)Local $Digest = DllStructCreate("byte[16]")
[/autoit] [autoit][/autoit] [autoit]DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
[/autoit] [autoit][/autoit] [autoit]
"ptr", DllStructGetPtr($Input), _
"int", BinaryLen($Data), _
"ptr", DllStructGetPtr($Digest), _
"int", 0)Local $Ret = DllStructGetData($Digest, 1)
[/autoit] [autoit][/autoit] [autoit][/autoit]
$Input = 0
$Digest = 0
$CodeBuffer = 0
Return $Ret
EndFunc ;==>_MD5So nun hoffe ich natürlich das hier viele nützliche Tools für dei Fritz!Box raus kommen.

-
Danke Super das hat Funktioniert, ich musste zwar noch das 0x abschneiden und ein stringLower drüber schicken aber es geht ich bekomme jetzt eine SID das war es worum es ging.
Das Fertig Skript kommt mal als UDF hier rein. -
Hallo Schnuffel,
Ok du hast die das Ding angeschaut und sagt das ist wahrscheinlich misst, gut damit kann man leben aber das eigentlich Problem bleibt doch.
Wäre es nicht sinnfoll einen Lösungsansatz zu liefern ode villeicht die AU3 zu fixen?
Mit deiner Aussagt ist das Thema beendet ohne gelöst zu sein.ich selbst merke immer wieder das hier im Forum oft so verfahren wird, das finde ich schade denn das ist ja ein Hilfe und kein Philosophie Forum.
-
Der Fall wird durch eine Fehlende Konvertierung nicht Korrekt bearbeitet.
Um die Konvertierung geht es hier
Dies Müsste Irgendwie in Autoit nach gebaut werden.
-
Hallo, ich habe hier eine Zeile,
`echo -n 53855f40-testpass | iconv -f ISO8859-1 -t UTF-16LE | md5sum -b`
die unter Linux Folgendes Liefert
963d7d2ff477b5a9b332e2f5938472e0
Ohne die Convertierung kommt:eab1e005f474e90f2d66a95d0943df01
in Autoit ist das Ergebenis:
eab1e005f474e90f2d66a95d0943df01
dort Fehlt mir ja die Convertierung.
Ich habe da mal mit dem UDF von Progandy rum gespielt: https://autoit.de/index.php?page=Thread&threadID=11350
hat aber leider keinen Erfolggebracht.
-
Ich bekomme von einen Webserver eine Chanange und habe eine Passwort zusammen mus das convertiert werden danach md5 gehashed.
-
Hallo, hat einer eine Idee wie das zu lösen sein kann?
String von ISO8859-1 nach UTF-16LE Convertieren
-
Hallo, ich habe im Inet Folgendes SH Script gefunden und würde dieses gerne in Autoit Realisieren.
[autoit][/autoit][autoit][/autoit][autoit]Spoiler anzeigen
#!/bin/sh
# Challenge abholen
ChallengeXML=`wget -O - "http://fritz.box/cgi-bin/webcm?getpage=../html/login_sid.xml" 2>/dev/null| grep Challenge`
Challenge=`echo $ChallengeXML | awk '{match($0,/>[^<>]+</); print substr($0,RSTART+1,RLENGTH-2)}'`Passwd="xxxxx"
# login aufbauen und hashen
CPSTR="$Challenge-$Passwd"
MD5=`echo -n $CPSTR | iconv -f ISO8859-1 -t UTF-16LE | md5sum -b | awk '{print substr($0,1,32)}'`
RESPONSE="$Challenge-$MD5"
POSTDATA="login:command/response=$RESPONSE&getpage=../html/de/menus/menu2.html"# login senden und SID herausfischen
SID=`wget -O - --post-data="$POSTDATA" "http://fritz.box/cgi-bin/webcm" 2>/dev/null| grep "name=\"sid\"" | head -1 | awk '{match($0,/value="[^"]+"/); print substr($0,RSTART+7,RLENGTH-8)}'`# refresh der daten auslösen
wget -O /dev/null "http://fritz.box//cgi-bin/webcm?sid=$SID&getpage=../html/de/menus/menu2.html&errorpage=../html/de/menus/menu2.html&var:pagename=foncalls&var:errorpagename=foncalls&var:menu=home&var:pagemaster=&var:activtype=pppoe&var:tabInetstat=0&var:weckernr=&logger:settings/filter=2"# CSV runterladen
wget -O ../fb_anrufliste.csv "http://fritz.box/cgi-bin/webcm?sid=$SID&getpage=../html/de/FRITZ!Box_Anrufliste.csv" 2>/dev/null#include <http.au3>
[/autoit][autoit][/autoit][autoit][/autoit][autoit]
#include <MD5.au3>$host = "fritz.box"
[/autoit][autoit][/autoit][autoit]
$Fritzpass = "XXXXXXXXX"
$Challenge=StringRegExp(_INetGetSource("http://fritz.box/cgi-bin/webcm?getpage=../html/login_sid.xml"),"<Challenge>(.*)</Challenge>",1)
$Challenge=$Challenge[0]
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Challenge = ' & $Challenge & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$CPSTR=$Challenge & "-" & $Fritzpass
$MD5 = md5($CPSTR)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $MD5 = ' & $MD5 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$RESPONSE = $Challenge & "-" & $MD5
$POSTDATA="login:command/response=" & $RESPONSE & "&getpage=../html/de/menus/menu2.html"
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $POSTDATA = ' & $POSTDATA & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$httpsocet = _HTTPConnect($host)
$RC = _HTTPPost($host, "http://" & $host & "/cgi-bin/webcm", $httpsocet,$POSTDATA)
sleep(1000)
$RC = _HTTPRead($httpsocet,0)
$SID = StringRegExp($RC,'[nNaAmMeE]+="[sSiIdD]+"\s*[vVaAlLuUeE]+\s*=\s*"(.*)"\s+',1)
$SID = $SID[0]
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $SID = ' & $SID & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$ErrorMessage = StringRegExp($RC,'errorMessage">(.*)<',1)
$ErrorMessage = $ErrorMessage[0]
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ErrorMessage = ' & $ErrorMessage & @crlf & '>Error code: ' & @error & @crlf) ;### Debug ConsoleConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $RC = ' & $RC & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
[/autoit]Nur leider bekomme ich immer nur Passwort Falsch ich denke irgendwas hab ich mit dem MD5 hash falsch gemacht.
Kann mir einer Helfen?Edit: ich glaube ich habe es gefunden ich brauche eine Convertierung von ISO8859-1 UTF-16LE damit sollte es funktionieren wie kann ich den String in Autoit auf die Entsprechenden Formate Convertirern?
unter Linux get es mit "iconv -f ISO8859-1 -t UTF-16LE"http.au3
Spoiler anzeigen
[autoit]; ===================================================================
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
; HTTP UDF's
; v0.5
;
; By: Greg "Overload" Laabs
; Last Updated: 07-22-06
; Tested with AutoIt Version 3.1.1.131
; Extra requirements: Nothing!
;
; A set of functions that allow you to download webpages and submit
; POST requests.
;
; Main functions:
; _HTTPConnect - Connects to a webserver
; _HTTPGet - Submits a GET request to a webserver
; _HTTPPost - Submits a POST request to a webserver
; _HTTPRead - Reads the response from a webserver
; ===================================================================TCPStartup()
[/autoit] [autoit][/autoit] [autoit]Global $_HTTPUserAgent = "AutoItScript/"&@AutoItVersion
[/autoit] [autoit][/autoit] [autoit]
Global $_HTTPLastSocket = -1
Global $_HTTPRecvTimeout = 30000; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPSetUserAgent($Program, $Version)
;
; Sets the User-Agent that will be sent with all future _HTTP
; functions. If this is never called, the user agent is set to
; AutoItScript/[YourAutoItVersion]
; Parameters:
;$Program - IN - The name of the program
;$Version - IN - The version number of the program
; Returns:
;None
; ===================================================================
Func _HTTPSetUserAgent($Program, $Version)
$_HTTPUserAgent = $Program&"/"&$Version
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPConnect($host, [$port])
;
; Opens a connection to $host on the port you supply (or 80 if you don't supply a port. Returns the socket of the connection.
; Parameters:
;$host - IN - The hostname you want to connect to. This should be in the format "www.google.com" or "localhost"
;$port - OPTIONAL IN - The port to connect on. 80 is default.
; Returns:
;The socket of the connection.
; Remarks:
; Possible @errors:
; 1 - Unable to open socket - @extended is set to Windows API WSAGetLasterror return
; ===================================================================
Func _HTTPConnect($host, $port = 80)
Dim $ip = TCPNameToIP ( $host )
Dim $socket = TCPConnect ( $ip, 80 )If ($socket == -1) Then
[/autoit] [autoit][/autoit] [autoit]
SetError(1, @error)
Return -1
EndIf$_HTTPLastSocket = $socket
[/autoit] [autoit][/autoit] [autoit]
SetError(0)
Return $socket
EndFunc; Possible @errors:
[/autoit] [autoit][/autoit] [autoit]
; 1 - No socket
Func _HTTPClose($socket = -1)
If $socket == -1 Then
If $_HTTPLastSocket == -1 Then
SetError(1)
Return 0
EndIf
$socket = $_HTTPLastSocket
EndIf
TCPCloseSocket($socket)SetError(0)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Return 1
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPGet($host, $page, [$socket])
;
; Executes a GET request on an open socket.
; Parameters:
;$host - IN - The hostname you want to get the page from. This should be in the format "www.google.com" or "localhost"
;$page - IN - The the file you want to get. This should always start with a slash. Examples: "/somepage.php" or "/somedirectory/somefile.zip"
;$socket - OPTIONAL IN - The socket opened by _HTTPConnect. If this is not supplied, the last socket opened with _HTTPConnect will be used.
; Returns:
;The number of bytes sent in the request.
; Remarks:
; Possible @errors:
; 1 - No socket supplied and no current socket exists
; 2 - Error sending to socket. Check @extended for Windows API WSAGetError return
; ===================================================================
Func _HTTPGet($host, $page, $socket = -1)
Dim $commandIf $socket == -1 Then
[/autoit] [autoit][/autoit] [autoit]
If $_HTTPLastSocket == -1 Then
SetError(1)
Return
EndIf
$socket = $_HTTPLastSocket
EndIf$command = "GET "&$page&" HTTP/1.1"&@CRLF
[/autoit] [autoit][/autoit] [autoit]
$command &= "Host: " &$host&@CRLF
$command &= "User-Agent: "&$_HTTPUserAgent&@CRLF
$command &= "Connection: close"&@CRLF
$command &= ""&@CRLFDim $bytessent = TCPSend($socket, $command)
[/autoit] [autoit][/autoit] [autoit]If $bytessent == 0 Then
[/autoit] [autoit][/autoit] [autoit]
SetExtended(@error)
SetError(2)
return 0
EndIfSetError(0)
[/autoit] [autoit][/autoit] [autoit]
Return $bytessent
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPPost($host, $page, [$socket])
;
; Executes a POST request on an open socket.
; Parameters:
;$host - IN - The hostname you want to get the page from. This should be in the format "www.google.com" or "localhost"
;$page - IN - The the file you want to get. This should always start with a slash. Examples: "/" or "/somedirectory/submitform.php"
;$socket - OPTIONAL IN - The socket opened by _HTTPConnect. If this is not supplied, the last socket opened with _HTTPConnect will be used.
;$data - OPTIONAL IN - The data to send in the post request. This should first be run through _HTTPEncodeString()
; Returns:
;The number of bytes sent in the request.
; Remarks:
; Possible @errors:
; 1 - No socket supplied and no current socket exists
; 2 - Error sending to socket. Check @extended for Windows API WSAGetError return
; ===================================================================
Func _HTTPPost($host, $page, $socket = -1, $data = "")
Dim $commandIf $socket == -1 Then
[/autoit] [autoit][/autoit] [autoit]
If $_HTTPLastSocket == -1 Then
SetError(1)
Return
EndIf
$socket = $_HTTPLastSocket
EndIfDim $datasize = StringLen($data)
[/autoit] [autoit][/autoit] [autoit]$command = "POST "&$page&" HTTP/1.1"&@CRLF
[/autoit] [autoit][/autoit] [autoit]
$command &= "Host: " &$host&@CRLF
$command &= "User-Agent: "&$_HTTPUserAgent&@CRLF
$command &= "Connection: close"&@CRLF
$command &= "Content-Type: application/x-www-form-urlencoded"&@CRLF
$command &= "Content-Length: "&$datasize&@CRLF
$command &= ""&@CRLF
$command &= $data&@CRLFDim $bytessent = TCPSend($socket, $command)
[/autoit] [autoit][/autoit] [autoit]If $bytessent == 0 Then
[/autoit] [autoit][/autoit] [autoit]
SetExtended(@error)
SetError(2)
return 0
EndIfSetError(0)
[/autoit] [autoit][/autoit] [autoit]
Return $bytessent
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPRead([$socket], [$flag])
;
; Retrieves data from an open socket. This should only be called after _HTTPGet or _HTTPPost is called.
; Parameters:
;$socket - OPTIONAL IN - The socket you want to receive data from. If this is not supplied, the last socket opened with _HTTPConnect will be used.
;$flag - OPTIONAL IN - Determines how the data will be returned. See Remarks.
; Returns:
;See "Flags" in remarks, below.
; Remarks:
; Possible @errors:
; 1 - No socket
; 3 - Timeout reached before any data came through the socket
; 4 - Some data came through, but not all of it. Return value is the number of bytes received.
; 5 - Unable to parse HTTP Response from server. Return value is the HTTP Response line
; 6 - Unexpected header data returned. Return value is the line that caused the error
; 7 - Invalid flag
; 8 - Unable to parse chunk size. Return value is the line that caused the error
; Flags:
; 0 - Return value is the body of the page (default)
; 1 - Return value is an array:
; [0] = HTTP Return Code
; [1] = HTTP Return Reason (human readable return code like "OK" or "Forbidden"
; [2] = HTTP Version
; [3] = Two dimensional array with the headers. Each item has:
; [0] = Header name
; [1] = Header value
; [4] = The body of the page
; ===================================================================
Func _HTTPRead($socket = -1, $flag = 0)
If $socket == -1 Then
If $_HTTPLastSocket == -1 Then
SetError(1)
Return
EndIf
$socket = $_HTTPLastSocket
EndIfDim $timer = TimerInit()
[/autoit] [autoit][/autoit] [autoit]
Dim $performancetimer = TimerInit()
Dim $downloadtime = 0Dim $headers[1][2] ; An Array of the headers found
[/autoit] [autoit][/autoit] [autoit]
Dim $numheaders = 0 ; The number of headers found
Dim $body = "" ; The body of the message
Dim $HTTPVersion ; The HTTP version of the server (almost always 1.1)
Dim $HTTPResponseCode ; The HTTP response code like 200, or 404
Dim $HTTPResponseReason ; The human-readable response reason, like "OK" or "Not Found"
Dim $bytesreceived = 0 ; The total number of bytes received
Dim $data = "" ; The entire raw message gets put in here.
Dim $chunked = 0 ; Set to 1 if we get the "Transfer-Encoding: chunked" header.
Dim $chunksize = 0 ; The size of the current chunk we are processing.
Dim $chunkprocessed = 0 ; The amount of data we have processed on the current chunk.
Dim $contentlength ; The size of the body, if NOT using chunked transfer mode.
Dim $part = 0 ; Refers to what part of the data we're currently parsing:
; 0 - Nothing parsed, so HTTP response should come next
; 1 - Currently parsing headers
; 2 - Currently waiting for the next chunk size - this is skipped if the transfer-encoding is not chunked
; 3 - Currently waiting for or parsing body data
; 4 - Currently parsing footers
;While 1
Sleep(10)
Dim $recv = TCPRecv($socket,16)
If @error <> 0 Then
;ConsoleWrite("Server closed connection")
;@error appears to be -1 after the server closes the connection. A good way to tell that we're finished, because we always send
;the "Connection: close" header to the server.
; !!! This is no longer used because we can now tell that we're done by checking the content-length header or properly handling
; chunked data.
EndIfWhile $recv <> ""
[/autoit] [autoit][/autoit] [autoit]
;If $recv <> "" Then
$bytesreceived = $bytesreceived + StringLen($recv)
$timer = TimerInit()
$data &= $recv
;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $data = ' & $data & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;ConsoleWrite("Bytes downloaded: "&$bytesreceived&@CRLF)
;EndIf
$recv = TCPRecv($socket,2048)
WEndDim $split = StringSplit($data,@CRLF,1)
[/autoit] [autoit][/autoit] [autoit]
$data = ""
Dim $i
For $i=1 To $split[0]
If $i=$split[0] Then
If $part < 2 OR $chunked = 1 Then
; This is tricky. The last line we've received might be truncated, so we only want to process it under special cases.
; Non chunked data doesn't always send a CRLF at the end so there's no way to tell if this is truly the last line without parsing it.
; However, we don't want to parse it if it's only a partial header or something.
; The solution: We will only process this last line if we're at the body section and the transfer-encoding is NOT chunked.
$data = $split[$i]
ExitLoop
EndIf
EndIfDim $newpart = $part
[/autoit] [autoit][/autoit] [autoit]
Switch $part
Case 0 ; Nothing parsed, so HTTP response should come next
If $split[$i] <> "" Then
Dim $regex = StringRegExp($split[$i],"^HTTP/([0-9.]+) ([0-9]+) ([a-zA-Z0-9 ]+)$",3)
If @error <> 0 Then
SetError(5)
Return $split[$i]
Else
$HTTPVersion = $regex[0]
$HTTPResponseCode = $regex[1]
$HTTPResponseReason = $regex[2]
If $HTTPResponseCode <> 100 Then
$newpart = 1
EndIf
EndIf
EndIf
Case 1, 4 ; Currently parsing headers or footers
;If the line is blank, then we're done with headers and the body is next
If $split[$i] == "" Then
If $part = 1 Then
If $chunked Then
$newpart = 2
Else
$newpart = 3
EndIf
ElseIf $part = 4 Then
; If $part is 4 then we're processing footers, so we're all done now.
ExitLoop 2
EndIf
Else ;The line wasn't blank
;Check to see if the line begins with whitespace. If it does, it's actually
;a continuation of the previous header
Dim $regex = StringRegExp($split[$i], "^[ \t]+([^ \t].*)$", 3)
If @error <> 1 Then
If $numheaders == 0 Then
SetError(6)
Return $split[$i]
EndIf
$headers[$numheaders-1][1] &= $regex[0]
Else;The line didn't start with a space
Dim $regex = StringRegExp($split[$i],"^([^ :]+):[ \t]*(.*)$",3)
If @error <> 1 Then
;This is a new header, so add it to the array
$numheaders = $numheaders + 1
ReDim $headers[$numheaders][2]
$headers[$numheaders-1][0] = $regex[0]
$headers[$numheaders-1][1] = $regex[1]; There are a couple headers we need to know about. We'll process them here.
[/autoit] [autoit][/autoit] [autoit]
If $regex[0] = "Transfer-Encoding" AND $regex[1] = "chunked" Then
$chunked = 1
ElseIf $regex[0] = "Content-Length" Then
$contentlength = Int($regex[1])
EndIf
Else
SetError(6)
Return $split[$i]
EndIf
EndIf
EndIf
Case 2 ; Awaiting chunk size
$regex = StringRegExp($split[$i],"^([0-9a-f]+);?.*$",3)
If @error <> 0 Then
SetError(8)
Return $split[$i]
EndIf
$chunksize = $regex[0]
$chunksize = Dec($chunksize)
$chunkprocessed = 0If $chunksize == 0 Then
[/autoit] [autoit][/autoit] [autoit]
$newpart = 4
Else
$newpart = 3
EndIf
Case 3 ; Awaiting body data
$body &= $split[$i]$chunkprocessed = $chunkprocessed + StringLen($split[$i])
[/autoit] [autoit][/autoit] [autoit]If $chunked Then
[/autoit] [autoit][/autoit] [autoit]
If $chunkprocessed >= $chunksize Then
$newpart = 2
Else
$body &= @CRLF
$chunkprocessed = $chunkprocessed + 2; We add 2 for the CRLF we stipped off.
EndIf
Else
If not $chunkprocessed >= $contentlength Then
If $i < $split[0] Then
; Only add a CRLF if this is not the last line received.
$body &= @CRLF
$chunkprocessed = $chunkprocessed + 2; We add 2 for the CRLF we stipped off.
EndIf
EndIf
EndIf
Case Else
; This should never happen
EndSwitch
$part = $newpart
NextIf $bytesreceived == 0 AND TimerDiff($timer) > $_HTTPRecvTimeout Then
[/autoit] [autoit][/autoit] [autoit]
SetError(3)
Return 0
ElseIf $bytesreceived > 0 AND TimerDiff($timer) > $_HTTPRecvTimeout Then
ConsoleWrite($body)
SetError(4)
Return $bytesreceived
EndIf
;WEnd
$downloadtime = TimerDiff($performancetimer)
;ConsoleWrite("Performance: Download time: "&$downloadtime&@CRLF)Switch $flag
[/autoit] [autoit][/autoit] [autoit]
Case 0
SetError(0)
Return $body
Case 1
Dim $return[5]
$return[0] = $HTTPResponseCode
$return[1] = $HTTPResponseReason
$return[2] = $HTTPVersion
$return[3] = $headers
$return[4] = $body
SetError(0)
Return $return
Case Else
SetError(7)
Return 0
EndSwitch
EndFunc; ===================================================================
[/autoit] [autoit][/autoit] [autoit]
; _HTTPEncodeString($string)
;
; Encodes a string so it can safely be transmitted via HTTP
; Parameters:
;$string - IN - The string to encode
; Returns:
;A valid encoded string that can be used as GET or POST variables.
; ===================================================================
Func _HTTPEncodeString($string)
Local Const $aURIValidChars[256] = _
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, _
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]Local $sEncoded = ""
[/autoit] [autoit][/autoit] [autoit]
For $i = 1 To StringLen($string)
Local $c = StringMid($string, $i, 1)
If $c = " " Then $c = "+"
If Number($aURIValidChars[Asc($c) ]) Then
$sEncoded &= $c
Else
$sEncoded &= StringFormat("%%X", Asc($c))
EndIf
NextReturn $sEncoded
[/autoit]
EndFunc ;==>_WebComposeURLMD5.au3
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
; Converted to AutoIt script by SvenP;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; MODULE: CMD5
; FILENAME: C:\My Code\vb\md5\CMD5.cls
; AUTHOR: Phil Fresle
; CREATED: 16-Feb-2001
; COPYRIGHT:Copyright 2001 Frez Systems Limited. All Rights Reserved.
;
; DESCRIPTION:
; Derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm,
; as set out in the memo RFC1321.
;
; This class is used to generate an MD5 ;digest; or ;signature; of a string. The
; MD5 algorithm is one of the industry standard methods for generating digital
; signatures. It is generically known as a digest, digital signature, one-way
; encryption, hash or checksum algorithm. A common use for MD5 is for password
; encryption as it is one-way in nature, that does not mean that your passwords
; are not free from a dictionary attack. If you are using the
; routine for passwords, you can make it a little more secure by concatenating
; some known random characters to the password before you generate the signature
; and on Funcsequent tests, so even if a hacker knows you are using MD5 for
; your passwords, the random characters will make it harder to dictionary attack.
;
; *** CAUTION ***
; See the comment attached to the MD5 method below regarding use on systems
; with different character sets.
;
; This is 'free' software with the following restrictions:
;
; You may not redistribute this code as a 'sample'or 'demo'. However, you are free
; to use the source code in your own code, but you may not claim that you created
; the sample code. It is expressly forbidden to sell or profit from this source code
; other than by the knowledge gained or the enhanced value added by your own code.
;
; Use of this software is also done so at your own risk. The code is supplied as
; is without warranty or guarantee of any kind.
;
; Should you wish to commission some derivative work based on this code provided
; here, or any consultancy work, please do not hesitate to contact us.
;
; Web Site: http://www.frez.co.uk
; E-mail:sales@frez.co.uk
;
; MODIFICATION HISTORY:
; 1.0 16-Feb-2001
; Phil Fresle
; Initial Version
;*******************************************************************************Const $BITS_TO_A_BYTE = 8
[/autoit] [autoit][/autoit] [autoit]
Const $BYTES_TO_A_WORD = 4
Const $BITS_TO_A_WORD = $BYTES_TO_A_WORD * $BITS_TO_A_BYTEDim $m_lOnBits[31]
[/autoit] [autoit][/autoit] [autoit]
Dim $m_l2Power[31];*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; Class_Initialize (Func)
;
; DESCRIPTION:
; We will usually get quicker results by preparing arrays of bit patterns and
; powers of 2 ahead of time instead of calculating them every time, unless of
; course the methods are only ever getting called once per instantiation of the
; class.
;*******************************************************************************
Func Class_Initialize()
; Could have done this with a loop calculating each value, but simply
; assigning the values is quicker - BITS SET FROM RIGHT
$m_lOnBits[0] = 1 ; 00000000000000000000000000000001
$m_lOnBits[1] = 3 ; 00000000000000000000000000000011
$m_lOnBits[2] = 7 ; 00000000000000000000000000000111
$m_lOnBits[3] = 15 ; 00000000000000000000000000001111
$m_lOnBits[4] = 31 ; 00000000000000000000000000011111
$m_lOnBits[5] = 63 ; 00000000000000000000000000111111
$m_lOnBits[6] = 127 ; 00000000000000000000000001111111
$m_lOnBits[7] = 255 ; 00000000000000000000000011111111
$m_lOnBits[8] = 511 ; 00000000000000000000000111111111
$m_lOnBits[9] = 1023 ; 00000000000000000000001111111111
$m_lOnBits[10] = 2047 ; 00000000000000000000011111111111
$m_lOnBits[11] = 4095 ; 00000000000000000000111111111111
$m_lOnBits[12] = 8191 ; 00000000000000000001111111111111
$m_lOnBits[13] = 16383 ; 00000000000000000011111111111111
$m_lOnBits[14] = 32767 ; 00000000000000000111111111111111
$m_lOnBits[15] = 65535 ; 00000000000000001111111111111111
$m_lOnBits[16] = 131071 ; 00000000000000011111111111111111
$m_lOnBits[17] = 262143 ; 00000000000000111111111111111111
$m_lOnBits[18] = 524287 ; 00000000000001111111111111111111
$m_lOnBits[19] = 1048575 ; 00000000000011111111111111111111
$m_lOnBits[20] = 2097151 ; 00000000000111111111111111111111
$m_lOnBits[21] = 4194303 ; 00000000001111111111111111111111
$m_lOnBits[22] = 8388607 ; 00000000011111111111111111111111
$m_lOnBits[23] = 16777215; 00000000111111111111111111111111
$m_lOnBits[24] = 33554431; 00000001111111111111111111111111
$m_lOnBits[25] = 67108863; 00000011111111111111111111111111
$m_lOnBits[26] = 134217727 ; 00000111111111111111111111111111
$m_lOnBits[27] = 268435455 ; 00001111111111111111111111111111
$m_lOnBits[28] = 536870911 ; 00011111111111111111111111111111
$m_lOnBits[29] = 1073741823 ; 00111111111111111111111111111111
$m_lOnBits[30] = 2147483647 ; 01111111111111111111111111111111; Could have done this with a loop calculating each value, but simply
[/autoit] [autoit][/autoit] [autoit]
; assigning the values is quicker - POWERS OF 2
$m_l2Power[0] = 1 ; 00000000000000000000000000000001
$m_l2Power[1] = 2 ; 00000000000000000000000000000010
$m_l2Power[2] = 4 ; 00000000000000000000000000000100
$m_l2Power[3] = 8 ; 00000000000000000000000000001000
$m_l2Power[4] = 16 ; 00000000000000000000000000010000
$m_l2Power[5] = 32 ; 00000000000000000000000000100000
$m_l2Power[6] = 64 ; 00000000000000000000000001000000
$m_l2Power[7] = 128 ; 00000000000000000000000010000000
$m_l2Power[8] = 256 ; 00000000000000000000000100000000
$m_l2Power[9] = 512 ; 00000000000000000000001000000000
$m_l2Power[10] = 1024 ; 00000000000000000000010000000000
$m_l2Power[11] = 2048 ; 00000000000000000000100000000000
$m_l2Power[12] = 4096 ; 00000000000000000001000000000000
$m_l2Power[13] = 8192 ; 00000000000000000010000000000000
$m_l2Power[14] = 16384 ; 00000000000000000100000000000000
$m_l2Power[15] = 32768 ; 00000000000000001000000000000000
$m_l2Power[16] = 65536 ; 00000000000000010000000000000000
$m_l2Power[17] = 131072 ; 00000000000000100000000000000000
$m_l2Power[18] = 262144 ; 00000000000001000000000000000000
$m_l2Power[19] = 524288 ; 00000000000010000000000000000000
$m_l2Power[20] = 1048576 ; 00000000000100000000000000000000
$m_l2Power[21] = 2097152 ; 00000000001000000000000000000000
$m_l2Power[22] = 4194304 ; 00000000010000000000000000000000
$m_l2Power[23] = 8388608 ; 00000000100000000000000000000000
$m_l2Power[24] = 16777216; 00000001000000000000000000000000
$m_l2Power[25] = 33554432; 00000010000000000000000000000000
$m_l2Power[26] = 67108864; 00000100000000000000000000000000
$m_l2Power[27] = 134217728 ; 00001000000000000000000000000000
$m_l2Power[28] = 268435456 ; 00010000000000000000000000000000
$m_l2Power[29] = 536870912 ; 00100000000000000000000000000000
$m_l2Power[30] = 1073741824 ; 01000000000000000000000000000000
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; LShift (FUNCTION)
;
; PARAMETERS:
; (In) - $lValue - Long- The value to be shifted
; (In) - $iShiftBits - Integer - The number of bits to shift the value by
;
; RETURN VALUE:
; Long - The shifted long integer
;
; DESCRIPTION:
; A left shift takes all the set binary bits and moves them left, in-filling
; with zeros in the vacated bits on the right. This function is equivalent to
; the << operator in Java and C++
;*******************************************************************************
Func LShift($lValue, $iShiftBits)
; NOTE: If you can guarantee that the Shift parameter will be in the
; range 1 to 30 you can safely strip of this first nested if structure for
; speed.
;
; A shift of zero is no shift at all.
If $iShiftBits = 0 Then
Return $lValue
; A shift of 31 will result in the right most bit becoming the left most
; bit and all other bits being cleared
ElseIf $iShiftBits = 31 Then
If BitAND($lValue, 1) Then
Return 0x80000000
Else
Return 0
Endif
; A shift of less than zero or more than 31 is undefined
ElseIf $iShiftBits < 0 Or $iShiftBits > 31 Then
SetError(6)
Endif; If the left most bit that remains will end up in the negative bit
[/autoit] [autoit][/autoit] [autoit]
; position (0x80000000) we would end up with an overflow if we took the
; standard route. We need to strip the left most bit and add it back
; afterwards.
If BitAND($lValue, $m_l2Power[31 - $iShiftBits]) Then; (Value And OnBits(31 - (Shift + 1))) chops off the left most bits that
[/autoit] [autoit][/autoit] [autoit]
; we are shifting into, but also the left most bit we still want as this
; is going to end up in the negative bit marker position (0x80000000).
; After the multiplication/shift we Or the result with 0x80000000 to
; turn the negative bit on.
Return BitOR((BitAND($lValue, $m_lOnBits[31 - ($iShiftBits + 1)]) * _
$m_l2Power[$iShiftBits]) , 0x80000000)Else
[/autoit] [autoit][/autoit] [autoit]; (Value And OnBits(31-Shift)) chops off the left most bits that we are
[/autoit] [autoit][/autoit] [autoit]
; shifting into so we do not get an overflow error when we do the
; multiplication/shift
Return (BitAND($lValue, $m_lOnBits[31 - $iShiftBits]) * _
$m_l2Power[$iShiftBits])
Endif
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; RShift (FUNCTION)
;
; PARAMETERS:
; (In) - $lValue - Long- The value to be shifted
; (In) - $iShiftBits - Integer - The number of bits to shift the value by
;
; RETURN VALUE:
; Long - The shifted long integer
;
; DESCRIPTION:
; The right shift of an unsigned long integer involves shifting all the set bits
; to the right and in-filling on the left with zeros. This function is
; equivalent to the >>> operator in Java or the >> operator in C++ when used on
; an unsigned long.
;*******************************************************************************
Func RShift($lValue, $iShiftBits)Local $RShift
[/autoit] [autoit][/autoit] [autoit]; NOTE: If you can guarantee that the Shift parameter will be in the
[/autoit] [autoit][/autoit] [autoit]
; range 1 to 30 you can safely strip of this first nested if structure for
; speed.
;
; A shift of zero is no shift at all
If $iShiftBits = 0 Then
Return $lValue
; A shift of 31 will clear all bits and move the left most bit to the right
; most bit position
ElseIf $iShiftBits = 31 Then
If BitAND($lValue, 0x80000000) Then
Return 1
Else
Return 0
Endif
; A shift of less than zero or more than 31 is undefined
ElseIf $iShiftBits < 0 Or $iShiftBits > 31 Then
SetError(6)
Endif; We do not care about the top most bit or the final bit, the top most bit
[/autoit] [autoit][/autoit] [autoit]
; will be taken into account in the next stage, the final bit (whether it
; is an odd number or not) is being shifted into, so we do not give a jot
; about it
$RShift = int(BitAND($lValue, 0x7FFFFFFE) / $m_l2Power[$iShiftBits]); If the top most bit (0x80000000) was set we need to do things differently
[/autoit] [autoit][/autoit] [autoit]
; as in a normal VB signed long integer the top most bit is used to indicate
; the sign of the number, when it is set it is a negative number, so just
; deviding by a factor of 2 as above would not work.
; NOTE: (lValue And 0x80000000) is equivalent to (lValue < 0], you could
; get a very marginal speed improvement by changing the test to (lValue < 0)
If BitAND($lValue, 0x80000000) Then
; We take the value computed so far, and then add the left most negative
; bit after it has been shifted to the right the appropriate number of
; places
$RShift = int(BitOR($RShift, (0x40000000 / $m_l2Power[$iShiftBits - 1])))
EndifReturn $RShift
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit];*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; RShiftSigned (FUNCTION)
;
; PARAMETERS:
; (In) - $lValue - Long-
; (In) - $iShiftBits - Integer -
;
; RETURN VALUE:
; Long -
;
; DESCRIPTION:
; The right shift of a signed long integer involves shifting all the set bits to
; the right and in-filling on the left with the sign bit (0 if positive, 1 if
; negative. This function is equivalent to the >> operator in Java or the >>
; operator in C++ when used on a signed long integer. Not used in this class,
; but included for completeness.
;*******************************************************************************
Func RShiftSigned($lValue , $iShiftBits); NOTE: If you can guarantee that the Shift parameter will be in the
[/autoit] [autoit][/autoit] [autoit]
; range 1 to 30 you can safely strip of this first nested if structure for
; speed.
;
; A shift of zero is no shift at all
If $iShiftBits = 0 Then
Return $lValue; A shift of 31 will clear all bits if the left most bit was zero, and will
[/autoit] [autoit][/autoit] [autoit]
; set all bits if the left most bit was 1 (a negative indicator)
ElseIf $iShiftBits = 31 Then
; NOTE: (lValue And 0x80000000) is equivalent to (lValue < 0), you
; could get a very marginal speed improvement by changing the test to
; (lValue < 0)
If BitAND($lValue, 0x80000000) Then
Return -1
Else
Return 0
Endif; A shift of less than zero or more than 31 is undefined
[/autoit] [autoit][/autoit] [autoit]
ElseIf $iShiftBits < 0 Or $iShiftBits > 31 Then
SetError(6)
Endif; We get the same result by dividing by the appropriate power of 2 and
[/autoit] [autoit][/autoit] [autoit]
; rounding in the negative direction
Return Int($lValue / $m_l2Power[$iShiftBits])
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; RotateLeft (FUNCTION)
;
; PARAMETERS:
; (In) - $lValue - Long- Value to act on
; (In) - $iShiftBits - Integer - Bits to move by
;
; RETURN VALUE:
; Long - Result
;
; DESCRIPTION:
; Rotates the bits in a long integer to the left, those bits falling off the
; left edge are put back on the right edge
;*******************************************************************************
Func RotateLeft($lValue , $iShiftBits)
Return BitOR(LShift($lValue, $iShiftBits), RShift($lValue, (32 - $iShiftBits)))
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; AddUnsigned (FUNCTION)
;
; PARAMETERS:
; (In) - $lX - Long - First value
; (In) - $lY - Long - Second value
;
; RETURN VALUE:
; Long - Result
;
; DESCRIPTION:
; Adds two potentially large unsigned numbers without overflowing
;*******************************************************************************
Func AddUnsigned($lX , $lY )
$lX8 = BitAND($lX, 0x80000000)
$lY8 = BitAND($lY, 0x80000000)
$lX4 = BitAND($lX, 0x40000000)
$lY4 = BitAND($lY, 0x40000000)
$lResult = BitAND($lX, 0x3FFFFFFF) + BitAND($lY, 0x3FFFFFFF)
If BitAND($lX4, $lY4) Then
$lResult = BitXOR($lResult, 0x80000000, $lX8, $lY8)
ElseIf BitOR($lX4 , $lY4) Then
If BitAND($lResult, 0x40000000) Then
$lResult = BitXOR($lResult, 0xC0000000, $lX8, $lY8)
Else
$lResult = BitXOR($lResult, 0x40000000, $lX8, $lY8)
Endif
Else
$lResult = BitXOR($lResult, $lX8, $lY8)
Endif
Return $lResult
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; F (FUNCTION)
;
; DESCRIPTION:
; MD5's F function
;*******************************************************************************
Func F($x , $y , $z )
Return BitOR(BitAND($x, $y) , BitAND((BitNOT($x)), $z))
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; G (FUNCTION)
;
; DESCRIPTION:
; MD5's G function
;*******************************************************************************
Func G($x , $y , $z )
Return BitOR(BitAND($x, $z) , BitAND($y , (BitNOT($z))))
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; H (FUNCTION)
;
; DESCRIPTION:
; MD5's H function
;*******************************************************************************
Func H($x , $y , $z )
Return BitXOR($x , $y , $z)
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; I (FUNCTION)
;
; DESCRIPTION:
; MD5's I function
;*******************************************************************************
Func I($x , $y , $z )
Return BitXOR($y , BitOR($x , (BitNOT($z))))
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; FF (Func)
;
; DESCRIPTION:
; MD5's FF procedure
;*******************************************************************************
Func FF(ByRef $a , $b , $c , $d , $x , $s , $ac )
$a = AddUnsigned($a, AddUnsigned(AddUnsigned(F($b, $c, $d), $x), $ac))
$a = RotateLeft($a, $s)
$a = AddUnsigned($a, $b)
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; GG (Func)
;
; DESCRIPTION:
; MD5's GG procedure
;*******************************************************************************
Func GG(ByRef $a , $b , $c , $d , $x , $s , $ac )
$a = AddUnsigned($a, AddUnsigned(AddUnsigned(G($b, $c, $d), $x), $ac))
$a = RotateLeft($a, $s)
$a = AddUnsigned($a, $b)
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; HH (Func)
;
; DESCRIPTION:
; MD5's HH procedure
;*******************************************************************************
Func HH(ByRef $a , $b , $c , $d , $x , $s , $ac )
$a = AddUnsigned($a, AddUnsigned(AddUnsigned(H($b, $c, $d), $x), $ac))
$a = RotateLeft($a, $s)
$a = AddUnsigned($a, $b)
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; II (Func)
;
; DESCRIPTION:
; MD5's II procedure
;*******************************************************************************
Func II(ByRef $a , $b , $c , $d , $x , $s , $ac )
$a = AddUnsigned($a, AddUnsigned(AddUnsigned(I($b, $c, $d), $x), $ac))
$a = RotateLeft($a, $s)
$a = AddUnsigned($a, $b)
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; ConvertToWordArray (FUNCTION)
;
; PARAMETERS:
; (In/Out) - $sMessage - String - String message
;
; RETURN VALUE:
; Long() - Converted message as long array
;
; DESCRIPTION:
; Takes the string message and puts it in a long array with padding according to
; the MD5 rules.
;*******************************************************************************
Func ConvertToWordArray($sMessage )
Dim $lWordArray[1]Const $MODULUS_BITS = 512
[/autoit] [autoit][/autoit] [autoit]
Const $CONGRUENT_BITS = 448$lMessageLength = StringLen($sMessage)
[/autoit] [autoit][/autoit] [autoit]; Get padded number of words. Message needs to be congruent to 448 bits,
[/autoit] [autoit][/autoit] [autoit]
; modulo 512 bits. If it is exactly congruent to 448 bits, modulo 512 bits
; it must still have another 512 bits added. 512 bits = 64 bytes
; (or 16 * 4 byte words), 448 bits = 56 bytes. This means lMessageSize must
; be a multiple of 16 (i.e. 16 * 4 (bytes) * 8 (bits))
$lNumberOfWords = (int(($lMessageLength + _
int(($MODULUS_BITS - $CONGRUENT_BITS) / $BITS_TO_A_BYTE)) / _
int($MODULUS_BITS / $BITS_TO_A_BYTE)) + 1) * _
int($MODULUS_BITS / $BITS_TO_A_WORD)
ReDim $lWordArray[$lNumberOfWords]; Combine each block of 4 bytes (ascii code of character) into one long
[/autoit] [autoit][/autoit] [autoit]
; value and store in the message. The high-order (most significant) bit of
; each byte is listed first. However, the low-order (least significant) byte
; is given first in each word.
$lBytePosition = 0
$lByteCount = 0
Do
; Each word is 4 bytes
$lWordCount = int($lByteCount / $BYTES_TO_A_WORD)
; The bytes are put in the word from the right most edge
$lBytePosition = (Mod($lByteCount , $BYTES_TO_A_WORD)) * $BITS_TO_A_BYTE
$lWordArray[$lWordCount] = BitOR($lWordArray[$lWordCount] , _
LShift(Asc(StringMid($sMessage, $lByteCount + 1, 1)), $lBytePosition))
$lByteCount = $lByteCount + 1
Until $lByteCount >= $lMessageLength; Terminate according to MD5 rules with a 1 bit, zeros and the length in
[/autoit] [autoit][/autoit] [autoit]
; bits stored in the last two words
$lWordCount = int($lByteCount / $BYTES_TO_A_WORD)
$lBytePosition = (Mod($lByteCount , $BYTES_TO_A_WORD)) * $BITS_TO_A_BYTE; Add a terminating 1 bit, all the rest of the bits to the end of the
[/autoit] [autoit][/autoit] [autoit]
; word array will default to zero
$lWordArray[$lWordCount] = BitOR($lWordArray[$lWordCount] , _
LShift(0x80, $lBytePosition)); We put the length of the message in bits into the last two words, to get
[/autoit] [autoit][/autoit] [autoit]
; the length in bits we need to multiply by 8 (or left shift 3). This left
; shifted value is put in the first word. Any bits shifted off the left edge
; need to be put in the second word, we can work out which bits by shifting
; right the length by 29 bits.
$lWordArray[$lNumberOfWords - 2] = LShift($lMessageLength, 3)
$lWordArray[$lNumberOfWords - 1] = RShift($lMessageLength, 29)Return $lWordArray
[/autoit] [autoit][/autoit] [autoit]
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; WordToHex (FUNCTION)
;
; PARAMETERS:
; (In) - $lValue - Long - Long value to convert
;
; RETURN VALUE:
; String - Hex value to return
;
; DESCRIPTION:
; Takes a long integer and due to the bytes reverse order it extracts the
; individual bytes and converts them to hex appending them for an overall hex
; value
;*******************************************************************************
Func WordToHex($lValue)$WordToHex=""
[/autoit] [autoit][/autoit] [autoit]For $lCount = 0 To 3
[/autoit] [autoit][/autoit] [autoit]
$lByte = BitAND(RShift($lValue, $lCount * $BITS_TO_A_BYTE) , _
$m_lOnBits[$BITS_TO_A_BYTE - 1])
$WordToHex = $WordToHex & StringRight("0" & Hex($lByte,2), 2)
Next
Return $WordToHex
EndFunc;*******************************************************************************
[/autoit] [autoit][/autoit] [autoit]
; MD5 (FUNCTION)
;
; PARAMETERS:
; (In/Out) - sMessage - String - String to be digested
;
; RETURN VALUE:
; String - The MD5 digest
;
; DESCRIPTION:
; This function takes a string message and generates an MD5 digest for it.
; sMessage can be up to the VB string length limit of 2^31 (approx. 2 billion)
; characters.
;
; NOTE: Due to the way in which the string is processed the routine assumes a
; single byte character set. VB passes unicode (2-byte) character strings, the
; ConvertToWordArray function uses on the first byte for each character. This
; has been done this way for ease of use, to make the routine truely portable
; you could accept a byte array instead, it would then be up to the calling
; routine to make sure that the byte array is generated from their string in
; a manner consistent with the string type.
;*******************************************************************************
Func MD5($sMessage)Const $S11 = 7
[/autoit] [autoit][/autoit] [autoit]
Const $S12 = 12
Const $S13 = 17
Const $S14 = 22
Const $S21 = 5
Const $S22 = 9
Const $S23 = 14
Const $S24 = 20
Const $S31 = 4
Const $S32 = 11
Const $S33 = 16
Const $S34 = 23
Const $S41 = 6
Const $S42 = 10
Const $S43 = 15
Const $S44 = 21Class_Initialize()
[/autoit] [autoit][/autoit] [autoit]; Steps 1 and 2. Append padding bits and length and convert to words
[/autoit] [autoit][/autoit] [autoit]
$x = ConvertToWordArray($sMessage); Step 3. Initialise
[/autoit] [autoit][/autoit] [autoit]
$a = 0x67452301
$b = 0xEFCDAB89
$c = 0x98BADCFE
$d = 0x10325476; Step 4. Process the message in 16-word blocks
[/autoit] [autoit][/autoit] [autoit]
For $k = 0 To UBound($x)-1 Step 16
$AA = $a
$BB = $b
$CC = $c
$DD = $d; The hex number on the end of each of the following procedure calls is
[/autoit] [autoit][/autoit] [autoit]
; an element from the 64 element table constructed with
; T(i) = Int(4294967296 * Abs(Sin(i))) where i is 1 to 64.
;
; However, for speed we don't want to calculate the value every time.
FF( $a, $b, $c, $d, $x[$k + 0], $S11, 0xD76AA478 )
FF( $d, $a, $b, $c, $x[$k + 1], $S12, 0xE8C7B756 )
FF( $c, $d, $a, $b, $x[$k + 2], $S13, 0x242070DB )
FF( $b, $c, $d, $a, $x[$k + 3], $S14, 0xC1BDCEEE )
FF( $a, $b, $c, $d, $x[$k + 4], $S11, 0xF57C0FAF )
FF( $d, $a, $b, $c, $x[$k + 5], $S12, 0x4787C62A )
FF( $c, $d, $a, $b, $x[$k + 6], $S13, 0xA8304613 )
FF( $b, $c, $d, $a, $x[$k + 7], $S14, 0xFD469501 )
FF( $a, $b, $c, $d, $x[$k + 8], $S11, 0x698098D8 )
FF( $d, $a, $b, $c, $x[$k + 9], $S12, 0x8B44F7AF )
FF( $c, $d, $a, $b, $x[$k + 10], $S13, 0xFFFF5BB1)
FF( $b, $c, $d, $a, $x[$k + 11], $S14, 0x895CD7BE)
FF( $a, $b, $c, $d, $x[$k + 12], $S11, 0x6B901122)
FF( $d, $a, $b, $c, $x[$k + 13], $S12, 0xFD987193)
FF( $c, $d, $a, $b, $x[$k + 14], $S13, 0xA679438E)
FF( $b, $c, $d, $a, $x[$k + 15], $S14, 0x49B40821)GG( $a, $b, $c, $d, $x[$k + 1], $S21, 0xF61E2562 )
[/autoit] [autoit][/autoit] [autoit]
GG( $d, $a, $b, $c, $x[$k + 6], $S22, 0xC040B340 )
GG( $c, $d, $a, $b, $x[$k + 11], $S23, 0x265E5A51)
GG( $b, $c, $d, $a, $x[$k + 0], $S24, 0xE9B6C7AA )
GG( $a, $b, $c, $d, $x[$k + 5], $S21, 0xD62F105D )
GG( $d, $a, $b, $c, $x[$k + 10], $S22, 0x2441453 )
GG( $c, $d, $a, $b, $x[$k + 15], $S23, 0xD8A1E681)
GG( $b, $c, $d, $a, $x[$k + 4], $S24, 0xE7D3FBC8 )
GG( $a, $b, $c, $d, $x[$k + 9], $S21, 0x21E1CDE6 )
GG( $d, $a, $b, $c, $x[$k + 14], $S22, 0xC33707D6)
GG( $c, $d, $a, $b, $x[$k + 3], $S23, 0xF4D50D87 )
GG( $b, $c, $d, $a, $x[$k + 8], $S24, 0x455A14ED )
GG( $a, $b, $c, $d, $x[$k + 13], $S21, 0xA9E3E905)
GG( $d, $a, $b, $c, $x[$k + 2], $S22, 0xFCEFA3F8 )
GG( $c, $d, $a, $b, $x[$k + 7], $S23, 0x676F02D9 )
GG( $b, $c, $d, $a, $x[$k + 12], $S24, 0x8D2A4C8A)
HH( $a, $b, $c, $d, $x[$k + 5], $S31, 0xFFFA3942 )
HH( $d, $a, $b, $c, $x[$k + 8], $S32, 0x8771F681 )
HH( $c, $d, $a, $b, $x[$k + 11], $S33, 0x6D9D6122)
HH( $b, $c, $d, $a, $x[$k + 14], $S34, 0xFDE5380C)
HH( $a, $b, $c, $d, $x[$k + 1], $S31, 0xA4BEEA44 )
HH( $d, $a, $b, $c, $x[$k + 4], $S32, 0x4BDECFA9 )
HH( $c, $d, $a, $b, $x[$k + 7], $S33, 0xF6BB4B60 )
HH( $b, $c, $d, $a, $x[$k + 10], $S34, 0xBEBFBC70)
HH( $a, $b, $c, $d, $x[$k + 13], $S31, 0x289B7EC6)
HH( $d, $a, $b, $c, $x[$k + 0], $S32, 0xEAA127FA )
HH( $c, $d, $a, $b, $x[$k + 3], $S33, 0xD4EF3085 )
HH( $b, $c, $d, $a, $x[$k + 6], $S34, 0x4881D05 )
HH( $a, $b, $c, $d, $x[$k + 9], $S31, 0xD9D4D039 )
HH( $d, $a, $b, $c, $x[$k + 12], $S32, 0xE6DB99E5)
HH( $c, $d, $a, $b, $x[$k + 15], $S33, 0x1FA27CF8)
HH( $b, $c, $d, $a, $x[$k + 2], $S34, 0xC4AC5665 )II( $a, $b, $c, $d, $x[$k + 0], $S41, 0xF4292244 )
[/autoit] [autoit][/autoit] [autoit]
II( $d, $a, $b, $c, $x[$k + 7], $S42, 0x432AFF97 )
II( $c, $d, $a, $b, $x[$k + 14], $S43, 0xAB9423A7)
II( $b, $c, $d, $a, $x[$k + 5], $S44, 0xFC93A039 )
II( $a, $b, $c, $d, $x[$k + 12], $S41, 0x655B59C3)
II( $d, $a, $b, $c, $x[$k + 3], $S42, 0x8F0CCC92 )
II( $c, $d, $a, $b, $x[$k + 10], $S43, 0xFFEFF47D)
II( $b, $c, $d, $a, $x[$k + 1], $S44, 0x85845DD1 )
II( $a, $b, $c, $d, $x[$k + 8], $S41, 0x6FA87E4F )
II( $d, $a, $b, $c, $x[$k + 15], $S42, 0xFE2CE6E0)
II( $c, $d, $a, $b, $x[$k + 6], $S43, 0xA3014314 )
II( $b, $c, $d, $a, $x[$k + 13], $S44, 0x4E0811A1)
II( $a, $b, $c, $d, $x[$k + 4], $S41, 0xF7537E82 )
II( $d, $a, $b, $c, $x[$k + 11], $S42, 0xBD3AF235)
II( $c, $d, $a, $b, $x[$k + 2], $S43, 0x2AD7D2BB )
II( $b, $c, $d, $a, $x[$k + 9], $S44, 0xEB86D391 )$a = AddUnsigned($a, $AA)
[/autoit] [autoit][/autoit] [autoit]
$b = AddUnsigned($b, $BB)
$c = AddUnsigned($c, $CC)
$d = AddUnsigned($d, $DD)
Next; Step 5. Output the 128 bit digest
[/autoit]
Return StringLower(WordToHex($a) & WordToHex($b) & WordToHex($c) & WordToHex($d))
EndFunc -
Klingt nach nem Bot ... das ist doch nicht zulässing hier im Forum
-
Ich denke schon du must dich halt auf den Comport vom handy connecten und warten ... wenn das handy die SMS an den Internen comport übergibt (Gatway mode)
Comport über autoit Steuern.
http://www.autoitscript.com/forum/index.php?showtopic=45842 -
Bernd:
So ein Quark, als ob es was ausmachen würde ob man jetzt 10ms Verzögerung hat! Ich hatte das Thema nur übersprungen und da ich grundsätzlich nicht im MsgMode scripte hab ich einfach mal den Standart-Tipp weitergegeben! Außerdem hab ich in meiner Hilfe nix über Sleep in Verbindung mit GuiGetMsg gefunden..(Ich will auch jetzt garkeine Zitate o.ä)So und nun B2T!
Hilfe Autoit GuiGetMsg()
---- snip ----
Bemerkungen
Diese Funktion gibt die CPU automatisch wieder frei, wenn es erforderlich ist, so dass sie ruhig in Dauerschleifen benutzt werden kann, ohne die CPU vollständig auszulasten.
-----snip ---- -
Ja ich Schlisse mich an Netzwerk Traffic woher wohin Festplattten Traffic woher wohin .... usw etwas mehr infos wären toll.
-
-
Für RegEx kann ich den Regex coach empfehlen einfach mal Google fragen .... damit kann man on the fly RegEx aufbauen und testen. Ich Arbeit gerne damit auch wenn ich mir sicher bin das das PAttern Funktioniert teste ich es dennoch damit.
-
Einfacher geht's mit StringRegExp:
[autoit]
[/autoit]
#include <Date.au3>
$string = "12.05.2009 11:17"
$string = StringRegExpReplace($string, "(\d{2})\.(\d{2})\.(\d{4}) (\d{2}):(\d{2})", "$3/$2/$1 $4:$5:00")
MsgBox(0, 0, "Differenz in Stunden: " & _DateDiff("h", _NowCalc(), $string))Ja einfach und auch schneller ... aber RegEx ist immer Schwere kost wenn man damit anfängt.