
DeltaRocked
Active Members-
Posts
189 -
Joined
-
Last visited
Everything posted by DeltaRocked
-
Hi All, I have been breaking my head over this : When the cell it clicked , I need to get the underlying text and Row no. but it simply doesnt happen when I click the Cell, I have to click the Header of the ListView . Where have I messed up ? Or What have I missed ? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <array.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) Local $aItems[10][2] For $iI = 0 To UBound($aItems) - 1 $aItems[$iI][0] = "Row " & $iI $aItems[$iI][1] = "Item " & $iI Next $Form1 = GUICreate("Form1", 850, 830, -1, -1) $ListView1 = GUICtrlCreateListView("Type|From ID", 13, 180, 826, 325, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_SINGLESEL, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER)) GUICtrlSetOnEvent(-1, "ListView1") _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_HEADERDRAGDROP)) GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close") _GUICtrlListView_AddArray($ListView1, $aItems) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func ListView1() ConsoleWrite('1: ' & _GUICtrlListView_GetItem($ListView1, 0) & @CRLF) ConsoleWrite('1: ' & _GUICtrlListView_GetItemText($ListView1, 0) & @CRLF) ConsoleWrite('2: ' & GUICtrlRead(GUICtrlRead($ListView1)) & @CRLF) ConsoleWrite('3: ' & _GUICtrlListView_GetSelectedIndices($ListView1,FALSE) & @CRLF) EndFunc ;==>ListView1 Func Form2Close() Exit EndFunc ;==>Form2Close Thanks and regards DR [UPDATE] Found the solution , although not elegant. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <array.au3> #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) Local $aItems[10][2] For $iI = 0 To UBound($aItems) - 1 $aItems[$iI][0] = "Row " & $iI $aItems[$iI][1] = "Item " & $iI Next $Form1 = GUICreate("Form1", 850, 830, -1, -1) $ListView1 = GUICtrlCreateListView("Type|From ID", 13, 180, 826, 325, BitOR($LVS_SINGLESEL, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER)) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_ONECLICKACTIVATE, $LVS_EX_TRACKSELECT, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_HEADERDRAGDROP)) GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close") _GUICtrlListView_AddArray($ListView1, $aItems) GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Form2Close() Exit EndFunc ;==>Form2Close Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $ListView1 If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ; No return value Case $LVN_DELETEITEM ; An item is about to be deleted $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_DELETEITEM" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ; No return value Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) ListView_HOTTRACK(DllStructGetData($tInfo, "SubItem")) ; _DebugPrint("$LVN_HOTTRACK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ ; "-->Code:" & @TAB & $iCode & @CRLF & _ ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) Return 0 ; allow the list view to perform its normal track select processing. ;Return 1 ; the item will not be selected. Case $LVN_KEYDOWN ; A key has been pressed $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam) _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _ "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags")) ; No return value Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) ;~ ConsoleWrite(">>>>>>>>>>> " & _GUICtrlListView_GetSelectedIndices($ListView1) & @CRLF) Local $aListItem = _GUICtrlListView_GetItemTextArray($ListView1, -1) ;~ ConsoleWrite(">>>>>>>>>>> " & _ArrayToString($aListItem) & @CRLF) ConsoleWrite(">>>>>>>>>>> " & $aListItem[DllStructGetData($tInfo, "SubItem") + 1] & @CRLF) ;~ _GUICtrlListView_GetItemTextString() ;~ _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ ;~ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ ;~ "-->Code:" & @TAB & $iCode & @CRLF & _ ;~ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ ;~ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ ;~ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ ;~ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ ;~ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ ;~ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ ;~ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ ;~ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ ;~ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; No return value Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; No return value Case $NM_KILLFOCUS ; The control has lost the input focus _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; No return value Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ;Return 1 ; not to allow the default processing Return 0 ; allow the default processing Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; No return value Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; No return value Case $NM_SETFOCUS ; The control has received the input focus _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ;~ ConsoleWrite( _ ;~ "!===========================================================" & @CRLF & _ ;~ "+======================================================" & @CRLF & _ ;~ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ ;~ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint Func ListView_HOTTRACK($iSubItem) Local $iHotItem = _GUICtrlListView_GetHotItem($ListView1) If $iHotItem <> -1 Then ;~ ConsoleWrite("Hot Item: " & $iHotItem & " SubItem: " & $iSubItem & @CRLF) EndIf EndFunc ;==>ListView_HOTTRACK
-
Date_Time_Convert - New version 17 Jun 23
DeltaRocked replied to Melba23's topic in AutoIt Example Scripts
Hi @Melba23 , I was having some issues with automation of Logs wherein the Date Time is either in English or in some Locale based on the configured OS. It would be great if we come to know about the Locale and then the array of Month Abbreviation in the chosen language is used/created. Would this be possible ? I have been trying to find some list or anything that would help me in getting the Abbreviations but have hit the wall. Local $German = '25 Mrz 2018' Local $English = '25 Mar 2018' ConsoleWrite(_Date_Time_Convert($German,'dd MMM yyyy','dd/MM/yyyy') & @CRLF) ;<-- Returns Empty ConsoleWrite(_Date_Time_Convert($English,'dd MMM yyyy','dd/MM/yyyy') & @CRLF) Regards DR. -
Hi, I have been trying to read a file which is being continuously written by another process. At some point, the FileReadLine reaches EOF and the Second Process appends the file . When using Filereadline and FileSetPos / FilegetPos , I am unable to go past the last FileReadLine. I have to always close the file and reopen it , set the file pointer position and then continue reading till EOF. #include <FileConstants.au3> Local $hFile, $sPos, $neof $hFile = FileOpen('abc.txt', 0) While 1 $line = FileReadLine($hFile) If (@error = -1) Then $sPos = FileGetPos($hFile) ConsoleWrite(" ---- " & $sPos & ' ---- ' & @CRLF) FileClose($hFile) $hFile = FileOpen('abc.txt', 0) FileSetPos($hFile, $sPos, $FILE_BEGIN) $neof = 1 Else $neof = 0 EndIf If ($neof = 0) Then ConsoleWrite($line & @CRLF) EndIf WEnd looping.bat rem ------------------- dir /s >> abc.txt rem ------------------- At Command Prompt : looping.bat How do I ensure that I can read the file as and when it gets updated. [UPDATE] I believe its done. but may require some fine tuning. #include <FileConstants.au3> Local $hFile, $sPos, $neof, $sFilePreviousPos_1, $sFileCurrentPos_1, $sFilePreviousPos, $error $hFile = FileOpen('abc.txt', 0) $sFileCurrentPos = FileGetPos($hFile) While 1 $line = FileReadLine($hFile) $error = @error $sFilePreviousPos = $sFileCurrentPos $sFileCurrentPos = FileGetPos($hFile) If ($error = -1) Then FileSetPos($hFile, $sFilePreviousPos, $FILE_BEGIN) $neof = 1 Else $neof = 0 EndIf If ($neof = 0) Then ConsoleWrite($line & @CRLF) EndIf WEnd Thanks in Advance.
-
Greetings Sean !!! 1: Great UDF ( Chrome Version 49.0.2623.112 m, OS: W2k3 ) Beyond this version Chrome wouldn't be updated due to W2k3. Now for the Core Issue: _ChromeEval("document.getElementsByClassName('input-search')") Output : {"text":"object"} It seems the extension will have to be modified. Any other ideas ? Regards DR
-
Hi, The concept of using Playing cards is mentioned in this link. At the end of the said article find the link to the git-hub repo hoisting the Autoit /JS/NodeJS Code. https://www.schneier.com/academic/solitaire/ An addition to Solitaire Encryption http://j.mp/SolitaireRepo Thanks and Regards DR
-
Whatever mess I had done was done ... now for the clean code. However, the Node.JS encrypted output for input strings > 16 doesnt seem to match up with that of AutoIT #include "rijndael.au3" #include <String.au3> Global $key = "1234567812345678" Global $text = "abcdabcdabcdabc" $encrypted = _StringToHex(BinaryToString(_rijndaelCipher($key, $text, 128, 0, '','0'))) ConsoleWrite("Encrypted: " & $encrypted & @CRLF) $decrypted = BinaryToString(_rijndaelInvCipher($key, _HexToString($encrypted), 128, 0, '','0')) ConsoleWrite("Decrypted: " & $decrypted & @CRLF) OutPut AutoIT : Encrypted: 63B029D7F7134F055C3309F99CE09215 Decrypted: abcdabcdabcdabc Node.JS : var crypto = require('crypto'); aesEncryptString('abcdabcdabcdabc', '1234567812345678', crypto); function aesEncryptString(input1, key1, crypto) { var CIPHER_METHOD = "aes-128-cbc"; var KEY_LENGTH = 16; var AES_BLOCK_SIZE = 16; var AES_PAD_STARTER = new Array(16).join('\0'); var key = new Buffer(key1.substring(0, KEY_LENGTH),'ascii'); var iv = new Buffer(16); iv.fill(0); var input = new Buffer(input1,'ascii'); var aesCipher = crypto.createCipheriv(CIPHER_METHOD, key, iv); var plainText = input; var padLength = 0; if ((input.length % AES_BLOCK_SIZE) === 0) { padLength = 0; } else { padLength = AES_BLOCK_SIZE - (input.length % AES_BLOCK_SIZE); } var output; aesCipher.setAutoPadding(false); console.error('InputLength : '+input.length,'MOD: ' + input.length % AES_BLOCK_SIZE,'padLength: '+padLength); input += AES_PAD_STARTER.substr(0, padLength); console.error('InputLength : '+input.length,'Input : '+ input); output = aesCipher.update(input, 'utf8', 'hex') + aesCipher.final('hex'); console.error('IV : ' , iv); console.error('Key : ' , key); console.error('Plaintext : ' , plainText); console.error('Ciphertext : ' , output.toUpperCase()); var DaesCipher = crypto.createDecipheriv(CIPHER_METHOD, key, iv); DaesCipher.setAutoPadding(false); output = DaesCipher.update(output, 'hex', 'ascii') + DaesCipher.final(); console.error('Decrypted : ',stripchars(output,'\0')); console.error('---------------_____-------------------'); } function stripchars(string, chars) { return string.replace(new RegExp('['+chars+']','g'), ''); } OUTPUT of NODE.JS: InputLength : 15 MOD: 15 padLength: 1 InputLength : 16 Input : abcdabcdabcdabc //terminated by null IV : <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> Key : <Buffer 31 32 33 34 35 36 37 38 31 32 33 34 35 36 37 38> Plaintext : <Buffer 61 62 63 64 61 62 63 64 61 62 63 64 61 62 63> Ciphertext : 63B029D7F7134F055C3309F99CE09215 Decrypted : abcdabcdabcdabc Now for the Erroneous Output. Autoit Output : StringLen : 17 Encrypted: D374CCD51195D5AFE33537E909A331E7D477B6BA4A582E3C68B43C42064F6218 Decrypted: abcdabcdabcdabcde Node.JS InputLength : 17 MOD: 1 padLength: 15 InputLength : 32 Input : abcdabcdabcdabcde IV : <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> Key : <Buffer 31 32 33 34 35 36 37 38 31 32 33 34 35 36 37 38> Plaintext : <Buffer 61 62 63 64 61 62 63 64 61 62 63 64 61 62 63 64 65> Ciphertext : D374CCD51195D5AFE33537E909A331E7127F4D3EA6A5C8200A49E7DA9ACAB758 Decrypted : abcdabcdabcdabcde
-
Hi Everyone, I have been breaking my head over this NodeJS / AutoIT AES Encryption Decryption. String encrypted by AutoIT needs to be decrypted by NodeJS using AES. However there seems to be some issue the way NodeJS has implemented AES. AutoIT Code: #include "aes.au3" $line1 = 'Test' $Key = "YoYo" $Mode = "CBC" $IV = "0000000000000000" $ret = _AesEncrypt($Key, $line1, $Mode, $IV) $a = _AesDecrypt($Key, $ret, $Mode) ConsoleWrite('Tobe: '&$line1 & @CRLF & "Encrypted: "&$ret & @CRLF &"Decrypted: " & BinaryToString($a) & @CRLF) Encrypted: 0x3030303095E8819AAA0BD7A94E88DA291B62EE52 Decrypted: Test NodeJS Code: var crypto = require('crypto'); var iv = new Buffer('0000000000000000'); var encrypt = function(data, key) { var decodeKey = crypto.createHash('sha256').update(key, 'binary').digest(); var cipher = crypto.createCipheriv('aes-256-cbc', decodeKey, iv); return cipher.update(data, 'binary', 'hex') + cipher.final('hex'); }; var decrypt = function(data, key) { var encodeKey = crypto.createHash('sha256').update(key, 'binary').digest(); var cipher = crypto.createDecipheriv('aes-256-cbc', encodeKey, iv); return cipher.update(data, 'hex', 'binary') + cipher.final('binary'); }; var data = 'Test'; var key = 'YoYo'; var cipher = encrypt(data, key); var decipher = decrypt(cipher, key); console.log('Encrypted: ',cipher); console.log('Decrypted: ',decipher); Encrypted: 221335caa771fea2a15d7ec303e4bb2d Decrypted: Test Am just unable to understand , what I should be doing in this regard, so as get the same encrypted string on both the platforms. Regards Deltarocked
-
This post has been updated :
-
There is one more request : During my testing , I was working on a local server ie. 127.0.0.1 and wanted to look into the headers , but since the LAN IP is tapped , I wassnt able to look into the https headers from the local machine and had to utilise another resource. 1: Would it be possible to tap into 127.0.0.1 rgds
-
Hi, Presently I am working on a script to load test a webservice created using Node.JS . However, I am unable to speed up the processing. The following code is a work-around , but I would like to increase its over-all performance. Hints , appreciated. Since, 1: InetGet provides a non-blocking method / ASYNC , it is being used . 2: Writing the results to the file using Little-Endian - as it is the fastest and requires least amount of code conversion. #include <Array.au3> Global Const $HTTPREQUEST_PROXYSETTING_DIRECT = 1 Global Const $HTTP_STATUS_OK = 200 Global $URL Global $count, $SecondCount Global $MaintainCount[100] Global $sFileData, $hFile FileDelete('consolidated.txt') $hFile = FileOpen('consolidated.txt', 34) For $i = 0 To 99 Step 1 $MaintainCount[$i] = 0 Next AdlibRegister('WriteToFile', 2000) ;~ AdlibRegister('Chk_Array', 150) $URL = 'http://192.168.1.14/getdata/default.aspx?adrm=TINGTONG&adrh=SomeDynamicValue' ;SomeDynamicValue is read from a txt file and that logic is not included. Presently using a static value. $count = 0 $SecondCount = 0 $begin = TimerInit() While 1 If $MaintainCount[$count] <> 0 Then If InetGetInfo($MaintainCount[$count], 2) Then ;~ AdlibUnRegister('Chk_Array') InetClose($MaintainCount[$count]) $fileContents = FileRead(@ScriptDir & '\1\' & $count & '.txt') ; FileDelete(@ScriptDir & '\1\' & $count & '.txt') $sFileData &= @HOUR & @MIN & @SEC & '|' & $fileContents & @CR $MaintainCount[$count] = 0 Call('geturl', $count) ConsoleWrite('IF : ' & $count & ' : ' & $SecondCount & @CRLF) ;~ AdlibRegister('Chk_Array', 150) EndIf Else Call('geturl', $count) ConsoleWrite('Else : ' & $count & ' : ' & $SecondCount & @CRLF) EndIf $count += 1 If $count = 100 Then $count = 0 Chk_Array() EndIf If $SecondCount == 1000 Then ExitLoop ;~ Sleep(10) WEnd AdlibUnRegister('WriteToFile') ConsoleWrite('Completed: ' & TimerDiff($begin) / 1000 & @CRLF) Local $FinalCounter = 0 While 1 For $i = 0 To 99 Step 1 If $MaintainCount[$i] <> 0 Then If InetGetInfo($MaintainCount[$i], 2) Then InetClose($MaintainCount[$i]) $fileContents = FileRead(@ScriptDir & '\1\' & $i & '.txt') ; FileDelete(@ScriptDir & '\1\' & $i & '.txt') $sFileData &= @HOUR & @MIN & @SEC & '|' & $fileContents & @CR $MaintainCount[$i] = 0 ConsoleWrite('Final : ' & $i & ' : ' & $FinalCounter & @CRLF) $FinalCounter += 1 EndIf EndIf Next If $FinalCounter == 99 Then FileWrite($hFile, $sFileData) ExitLoop EndIf WEnd ConsoleWrite('Finally Completed: ' & TimerDiff($begin) / 1000 & @CRLF) Func Chk_Array() ;~ AdlibUnRegister('Chk_Array') For $i = 0 To 99 Step 1 If $MaintainCount[$i] <> 0 Then If InetGetInfo($MaintainCount[$i], 2) Then InetClose($MaintainCount[$i]) $fileContents = FileRead(@ScriptDir & '\1\' & $i & '.txt') $sFileData &= @HOUR & @MIN & @SEC & '|' & $fileContents & @CR $MaintainCount[$i] = 0 ConsoleWrite('Adlib : ' & $i & ' : ' & $SecondCount & @CRLF) EndIf EndIf Next ;~ AdlibRegister('Chk_Array', 150) EndFunc ;==>Chk_Array Func WriteToFile() If StringInStr($sFileData, @CR, 2, 100) <> 0 Then FileWrite($hFile, $sFileData) $sFileData = '' EndIf EndFunc ;==>WriteToFile Func geturl($counter) $sdata = InetGet($URL, @ScriptDir & '\1\' & $counter & '.txt', 8, 1) $MaintainCount[$counter] = $sdata $SecondCount += 1 EndFunc ;==>geturl Is there any alternative for InetGet ? So that instead of writing it into the file, it will store the results into the buffer , that way , Disk I/O wont play a spoilsport ? A bit of the Past : The initial script completed 4 requests per second, now its around 8 requests per second. Regards [Final Update] Since there has been no reply to this thread, I presume this to be the present final solution.
-
Hi Wakillon, Downloaded the latest version and now it works as per the documentation. thanks. Regards
-
Hi , Downloaded and installed WinPcap , getting the list of NICs in the dropdown list . When I click on start and then via a browser trying to browse --- nothing shows up on the Application console. Are there any pre-requisites ? Rgds
-
ProDLLer: Unknown code running? Befriend or Kill!
DeltaRocked replied to Manko's topic in AutoIt Example Scripts
Hi Manko, this is about Prodller + windows 7. I am using purge.exe (for flushing the FileSystem Cache) along with Prodller on Win7. and I am getting the error : However, before using ShellExecute / Run , if I use the function "prodstop()" then purge.exe works perfectly well. Note: I am not facing any issues with the below code when executed on WinXP (32 bit). #include <Date.au3> #include <Process.au3> #include "Services.au3" #include <security.au3> Global $hColdBoot = 0 Local $PID OnAutoItExitRegister("ex") FileInstall('purge.exe', @WindowsDir & '\purge.exe', 1) prodservice() prodstart() ShellExecute(@WindowsDir & '\purge.exe','', @WindowsDir,'open' ,@SW_HIDE) Sleep(1000) ex() Func ex() prodstop() DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", 0, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) _Service_Stop("skeleton") _Service_Delete("skeleton") EndFunc ;==>ex Func prodstart_remote($PID_Local) DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", 0, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", 1, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", $PID_Local, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) EndFunc ;==>prodstart_remote Func prodstop() DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", 0, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) EndFunc ;==>prodstop Func prodstart() DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", 1, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", @AutoItPID, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) EndFunc ;==>prodstart Func prodservice() DllCall("ntdll.dll", "int", "RtlAdjustPrivilege", "int", 20, "int", 1, "int", 0, "int*", 0) ; Get SeDebugPrivilege FileInstall("skeleton.sys", @TempDir & "\skeleton.sys", 1) If FileExists(@TempDir & "\skeleton.sys") Then Local $fault = "", $x = 0, $drvpath = @TempDir & "\" While 1 If Not My_Service_Create("skeleton", "Skeleton Driver", $drvpath & "skeleton.sys", $SERVICE_KERNEL_DRIVER, $SERVICE_DEMAND_START, $SERVICE_ERROR_IGNORE, 0) Then $fault = @LF & $x & " My_Service_Create: @error=" & @error EndIf If Not _Service_Start("skeleton") Then $fault &= @LF & $x & " _Service_Start: @error=" & @error If @error = 3 Then If $x < 2 Then _Service_Stop("skeleton") _Service_Delete("skeleton") FileInstall("skeleton.sys", @TempDir & "\skeleton.sys", 1) $drvpath = @TempDir & "\" $x += 1 ContinueLoop EndIf EndIf EndIf _Service_Delete("skeleton") $hColdBoot = DllCall("kernel32.dll", "int", "CreateFile", "str", "\\.\skeleton", "dword", 0xc0000000, _ "dword", 0, "dword", 0, "dword", 3, "dword", 0, "dword", 0) If $hColdBoot[0] = 0 Or $hColdBoot[0] = -1 Then Local $ret = _Service_QueryStatus("skeleton") If @error Or $ret[1] = $SERVICE_STOPPED Then If $x < 3 Then If $x = 0 Then ; No action. A second try sometimes fixes it... ElseIf $x = 1 Then _Service_Delete("skeleton") ElseIf $x = 2 Then _Service_Delete("skeleton") Else RegDelete("HKLM\SYSTEM\ControlSet001\Services\Skeleton") RegDelete("HKLM\SYSTEM\ControlSet002\Services\Skeleton") RegDelete("HKLM\SYSTEM\ControlSet003\Services\Skeleton") RegDelete("HKLM\SYSTEM\CurrentControlSet\Services\Skeleton") EndIf $x += 1 ContinueLoop EndIf MsgBox(0, "Form1", "Couldn't start sys so I can not aquire DRIVER handle!" & $fault) Exit Else MsgBox(0, "Form1", "sys is running but I can not aquire DRIVER handle!" & $fault) Exit EndIf Else $hColdBoot = $hColdBoot[0] ExitLoop EndIf WEnd Else MsgBox(0, "Form1", "File does not exist: sys") Exit EndIf DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot, "dword", 0x00226110, _ "int*", 1, "dword", 4, "int*", 0, "dword", 0, "dword*", 0, "ptr", 0) EndFunc ;==>prodservice Func My_Service_Create($sServiceName, _ $sDisplayName, _ $sBinaryPath, _ $nServiceType = 0x00000010, _ $nStartType = 0x00000002, _ $nErrorType = 0x00000001, _ $nDesiredAccess = 0x000f01ff) Local $hAdvapi32 Local $hKernel32 Local $arRet Local $hSC Local $lError = -1 $hAdvapi32 = DllOpen("advapi32.dll") If $hAdvapi32 = -1 Then Return 0 $hKernel32 = DllOpen("kernel32.dll") If $hKernel32 = -1 Then Return 0 $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _ "str", ".", _ "str", "ServicesActive", _ "long", $SC_MANAGER_ALL_ACCESS) If $arRet[0] = 0 Then $arRet = DllCall($hKernel32, "long", "GetLastError") $lError = $arRet[0] Else $hSC = $arRet[0] $arRet = DllCall($hAdvapi32, "long", "OpenService", _ "long", $hSC, _ "str", $sServiceName, _ "long", $SERVICE_INTERROGATE) If $arRet[0] = 0 Then $arRet = DllCall($hAdvapi32, "long", "CreateService", _ "long", $hSC, _ "str", $sServiceName, _ "str", $sDisplayName, _ "long", $nDesiredAccess, _ "long", $nServiceType, _ "long", $nStartType, _ "long", $nErrorType, _ "str", $sBinaryPath, _ "int", 0, _ "ptr", 0, _ "int", 0, _ "int", 0, _ "int", 0) If $arRet[0] = 0 Then $arRet = DllCall($hKernel32, "long", "GetLastError") $lError = $arRet[0] Else DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0]) EndIf Else DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0]) EndIf DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC) EndIf DllClose($hAdvapi32) DllClose($hKernel32) If $lError <> -1 Then SetError($lError) Return 0 EndIf Return 1 EndFunc ;==>My_Service_Create Thanks again. regards -
Hi water, blat is the last option, however for testing purpose I cannot play around with the live prod. hence first the test server and then on to prod server. whatever be the outcome will revert back. Regards
-
Dealing with JSON response to Twitter API
DeltaRocked replied to meisandy's topic in AutoIt General Help and Support
Hi , I have verified the modified twitter udf as explained in the below mentioned posts and it works as per the Twitter API V1.1 . If there anything else you would want in this UDF ? Regards -
Hi water, will give this a try on a fresh server. cant take chances with live production . will revert back. regards
-
Hi Water, Thanks for the input. upon further investigation, MS2008 server with MS Exchange requires MAPI/CDO libraries / MS Outlook to be installed. I have asked my support staff to do the needful at the client's place and will revert back in next 48 hours. Hopefully this should resolve the issue. The Link: http://theessentialexchange.com/blogs/michael/archive/2008/06/05/mapi-cdo-for-windows-server-2008-and-windows-vista.aspx However the MAPI/CDO download link mentioned in the article is broken. Regards Deltarocked.
-
Hi , I have tried doing as suggested in the above transcripts and from other threads in this forum ie. compile the exe for x64, however I am getting the following error: OS: 64Bit Windows Server 2008 Std. with Exchange server. CDO version :CDOEX While using the 32Bit compiled exe I am getting 8002801D Any ideas?
-
Powerful HTTP Server in Pure AutoIt
DeltaRocked replied to jvanegmond's topic in AutoIt Example Scripts
Added: Multiple web-hosting #cs Resources: Internet Assigned Number Authority - all Content-Types: http://www.iana.org/assignments/media-types/ World Wide Web Consortium - An overview of the HTTP protocol: http://www.w3.org/Protocols/ Credits: Manadar for starting on the webserver. Alek for adding POST and some fixes Creator for providing the "application/octet-stream" MIME type. #ce #include <Misc.au3> ; Only used for _Iif #include <Array.au3> ; // OPTIONS HERE // Local $sRootDir = @ScriptDir & "\" ; The absolute path to the root directory of the server. Local $sIP = @IPAddress1 ; ip address as defined by AutoIt Local $iPort = 80 ; the listening port Local $sServerAddress = "http://" & $sIP & ":" & $iPort & "/" Local $iMaxUsers = 15 ; Maximum number of users who can simultaneously get/post Local $sServerName = "ManadarX/1.1 (" & @OSVersion & ") AutoIt " & @AutoItVersion ; // END OF OPTIONS // Local $aSocket[$iMaxUsers] ; Creates an array to store all the possible users Local $sBuffer[$iMaxUsers] ; All these users have buffers when sending/receiving, so we need a place to store those Local $sDomain = '' ;which domain has been requested by the client For $x = 0 To UBound($aSocket) - 1 ; Fills the entire socket array with -1 integers, so that the server knows they are empty. $aSocket[$x] = -1 Next TCPStartup() ; AutoIt needs to initialize the TCP functions $iMainSocket = TCPListen($sIP, $iPort) ;create main listening socket If @error Then ; if you fail creating a socket, exit the application MsgBox(0x20, "AutoIt Webserver", "Unable to create a socket on port " & $iPort & ".") ; notifies the user that the HTTP server will not run Exit ; if your server is part of a GUI that has nothing to do with the server, you'll need to remove the Exit keyword and notify the user that the HTTP server will not work. EndIf ConsoleWrite("Server created on " & $sServerAddress & @CRLF) ; If you're in SciTE, While 1 $iNewSocket = TCPAccept($iMainSocket) ; Tries to accept incoming connections If $iNewSocket >= 0 Then ; Verifies that there actually is an incoming connection For $x = 0 To UBound($aSocket) - 1 ; Attempts to store the incoming connection If $aSocket[$x] = -1 Then $aSocket[$x] = $iNewSocket ;store the new socket ExitLoop EndIf Next EndIf For $x = 0 To UBound($aSocket) - 1 ; A big loop to receive data from everyone connected If $aSocket[$x] = -1 Then ContinueLoop ; if the socket is empty, it will continue to the next iteration, doing nothing $sNewData = TCPRecv($aSocket[$x], 1024) ; Receives a whole lot of data if possible ;~ ConsoleWrite($sNewData & @CRLF) If @error Then ; Client has disconnected $aSocket[$x] = -1 ; Socket is freed so that a new user may join ContinueLoop ; Go to the next iteration of the loop, not really needed but looks oh so good ElseIf $sNewData Then ; data received $sBuffer[$x] &= $sNewData ;store it in the buffer If StringInStr(StringStripCR($sBuffer[$x]), @LF & @LF) Then ; if the request has ended .. $sFirstLine = StringLeft($sBuffer[$x], StringInStr($sBuffer[$x], @LF)) ; helps to get the type of the request $sRequestType = StringLeft($sFirstLine, StringInStr($sFirstLine, " ") - 1) ; gets the type of the request If $sRequestType = "GET" Then ; user wants to download a file or whatever .. $sRequest = StringTrimRight(StringTrimLeft($sFirstLine, 4), 11) ; let's see what file he actually wants If StringInStr(StringReplace($sRequest, "\", "/"), "/.") Then ; Disallow any attempts to go back a folder _HTTP_SendFileNotFoundError($aSocket[$x]) ; sends back an error Else If $sRequest = "/" Then ; user has requested the root $sRequest = "/index.html" ; instead of root we'll give him the index page EndIf $sRequest = StringReplace($sRequest, "/", "\") ; convert HTTP slashes to windows slashes, not really required because windows accepts both $sDomain = StringRegExp($sNewData, '(?i)host:(.*)', 3) ; extract the fqdn from the client request $sRootDir &= IniRead('hosts.ini', 'hosts', StringStripWS($sDomain[0], 3), 'www') ; construct the path ConsoleWrite('$sRootDir ' & $sRootDir & @CRLF) If FileExists($sRootDir & $sRequest) Then ; makes sure the file that the user wants exists $sFileType = StringRight($sRequest, 4) ; determines the file type, so that we may choose what mine type to use ConsoleWrite($sRootDir & $sRequest & @CRLF) Switch $sFileType Case "html", ".htm" ; in case of normal HTML files _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/html") Case ".css" ; in case of style sheets _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "text/css") Case ".jpg", "jpeg" ; for common images _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/jpeg") Case ".png" ; another common image format _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "image/png") Case Else ; this is for .exe, .zip, or anything else that is not supported is downloaded to the client using a application/octet-stream _HTTP_SendFile($aSocket[$x], $sRootDir & $sRequest, "application/octet-stream") EndSwitch Else _HTTP_SendFileNotFoundError($aSocket[$x]) ; File does not exist, so we'll send back an error.. EndIf EndIf ElseIf $sRequestType = "POST" Then ; user has come to us with data, we need to parse that data and based on that do something special $aPOST = _HTTP_GetPost($sBuffer[$x]) ; parses the post data $sComment = _HTTP_POST("wintext", $aPOST) ; Like PHPs _POST, but it requires the second parameter to be the return value from _Get_Post _HTTP_ConvertString($sComment) ; Needs to convert the POST HTTP string into a normal string ConsoleWrite($sComment) $sDomain = StringRegExp($sNewData, '(?i)host:(.*)', 3) $sRootDir &= IniRead('hosts.ini', 'hosts', StringStripWS($sDomain[0], 3), 'www') ConsoleWrite('$sRootDir ' & $sRootDir & @CRLF) $data = FileRead($sRootDir & "\template.html") $data = StringReplace($data, "<?au3 Replace me ?>", $sComment) $h = FileOpen($sRootDir & "\index.html", 2) FileWrite($h, $data) FileClose($h) $h = FileOpen($sRootDir & "\clean.html", 2) FileWrite($h, $sComment) FileClose($h) _HTTP_SendFile($aSocket[$x], $sRootDir & "\index.html", "text/html") ; Sends back the new file we just created EndIf $sBuffer[$x] = "" ; clears the buffer because we just used to buffer and did some actions based on them $aSocket[$x] = -1 ; the socket is automatically closed so we reset the socket so that we may accept new clients EndIf EndIf $sRootDir = @ScriptDir & "\" ; since this is one huge loop where one socket is handled at a time , we have to reinitialise the path Next Sleep(10) WEnd Func _HTTP_ConvertString(ByRef $sInput) ; converts any characters like %20 into space 8) $sInput = StringReplace($sInput, '+', ' ') StringReplace($sInput, '%', '') For $t = 0 To @extended $Find_Char = StringLeft(StringTrimLeft($sInput, StringInStr($sInput, '%')), 2) $sInput = StringReplace($sInput, '%' & $Find_Char, Chr(Dec($Find_Char))) Next EndFunc ;==>_HTTP_ConvertString Func _HTTP_SendHTML($hSocket, $sHTML, $sReply = "200 OK") ; sends HTML data on X socket _HTTP_SendData($hSocket, Binary($sHTML), "text/html", $sReply) EndFunc ;==>_HTTP_SendHTML Func _HTTP_SendFile($hSocket, $sFileLoc, $sMimeType, $sReply = "200 OK") ; Sends a file back to the client on X socket, with X mime-type Local $hFile, $sImgBuffer, $sPacket, $a ConsoleWrite("Sending " & $sFileLoc & @CRLF) $hFile = FileOpen($sFileLoc, 16) $bFileData = FileRead($hFile) FileClose($hFile) _HTTP_SendData($hSocket, $bFileData, $sMimeType, $sReply) EndFunc ;==>_HTTP_SendFile Func _HTTP_SendData($hSocket, $bData, $sMimeType, $sReply = "200 OK") $sPacket = Binary("HTTP/1.1 " & $sReply & @CRLF & _ "Server: " & $sServerName & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Lenght: " & BinaryLen($bData) & @CRLF & _ "Content-Type: " & $sMimeType & @CRLF & _ @CRLF) TCPSend($hSocket, $sPacket) ; Send start of packet While BinaryLen($bData) ; Send data in chunks (most code by Larry) $a = TCPSend($hSocket, $bData) ; TCPSend returns the number of bytes sent $bData = BinaryMid($bData, $a + 1, BinaryLen($bData) - $a) WEnd $sPacket = Binary(@CRLF & @CRLF) ; Finish the packet TCPSend($hSocket, $sPacket) TCPCloseSocket($hSocket) EndFunc ;==>_HTTP_SendData Func _HTTP_SendFileNotFoundError($hSocket) ; Sends back a basic 404 error Local $s404Loc = $sRootDir & "\404.html" If (FileExists($s404Loc)) Then _HTTP_SendFile($hSocket, $s404Loc, "text/html") Else _HTTP_SendHTML($hSocket, "404 Error: " & @CRLF & @CRLF & "The file you requested could not be found.") EndIf EndFunc ;==>_HTTP_SendFileNotFoundError Func _HTTP_GetPost($s_Buffer) ; parses incoming POST data Local $sTempPost, $sLen, $sPostData, $sTemp ; Get the lenght of the data in the POST $sTempPost = StringTrimLeft($s_Buffer, StringInStr($s_Buffer, "Content-Length:")) $sLen = StringTrimLeft($sTempPost, StringInStr($sTempPost, ": ")) ; Create the base struck $sPostData = StringSplit(StringRight($s_Buffer, $sLen), "&") Local $sReturn[$sPostData[0] + 1][2] For $t = 1 To $sPostData[0] $sTemp = StringSplit($sPostData[$t], "=") If $sTemp[0] >= 2 Then $sReturn[$t][0] = $sTemp[1] $sReturn[$t][1] = $sTemp[2] EndIf Next Return $sReturn EndFunc ;==>_HTTP_GetPost Func _HTTP_Post($sName, $sArray) ; Returns a POST variable like a associative array. For $i = 1 To UBound($sArray) - 1 If $sArray[$i][0] = $sName Then Return $sArray[$i][1] EndIf Next Return "" EndFunc ;==>_HTTP_Post The Hosts.ini - which is needed to define the domain-name and its associated path wrt @ScriptDir. ie. all the hosted domain folders should reside in the @ScriptDir path [Hosts] yoyo.com=yoyo www.yoyo.com=yoyo subdomain.yoyo.com=sub_yoyo gogo.co.uk=gogo Directory Structure Directory of D:\webserver_011\Post_Server <DIR> gogo <DIR> sub_yoyo <DIR> www <DIR> yoyo hosts.ini server.au3 In order to successfully test this , you will have to modify the hosts file or add records for these domains in your DNS server. eg. 192.168.93.145 localhost yoyo.com www.yoyo.com subdomain.yoyo.com gogo.co.uk Re: Anti-DDOS -- some things are still remaining. -
Powerful HTTP Server in Pure AutoIt
DeltaRocked replied to jvanegmond's topic in AutoIt Example Scripts
Hi Trancexx, System is Windows 2003 Server --> thats the testing platform and its not a production server. Am using both the Apache and Manadar's http server for testing , but one at a time. Source-Code : will share it as soon as its finished (like all my other source-codes which you will find in this forum ) PS: I have also implemented multiple web-site hoisting using Manadar's code To Do this : Grab the HTTP response received from the Client ie. Browser "Host:" is the FQDN requested by the client. hence essentially, you need to create an array of domains currently hosted on the server and then modify the $sRootdir within the loop to correspond with the requested FQDN and its associated path on the file system. So small modification will allow you to host multiple domains on a single server Anti-DDOS Method in a gist: Before using TcpRecv to receive the HTTP content, grab the IP using SocketToIP() (picked up from TCPRecv eg) store the IP and kick in the DDOS Module. In Apache, after the headers are received the DDOS kicks into action. Over here we simply do this task at time of Socket creation. After TCPRecv receive we validate the headers - if found incorrect -- simply close the socket and proceed ahead. This way you are skipping a lot of code processing and saving time. The ideology is similar to manner in which we handle exceptions. Secondly, how we perceive a DDOS attack differs from person to person. This above method doesn't stop DNS R-DDOS (reflective DDOS) as the ports are different and services running on these ports are different. Any other questions / queries , please ask. regards DeltaRocked -
Powerful HTTP Server in Pure AutoIt
DeltaRocked replied to jvanegmond's topic in AutoIt Example Scripts
Hi trancexx, the code hasn't been uploaded yet - integration of essentials are still remaining eg. IP blocking. Content Verification and Request Validation completed. Previous Post was an informative one. Re: Apache: it crashes , hangs up the system , it just cannot handle and this for me is a system mess. Presently testing Apache with mod_evasive module enabled and with correct configuration. NOTE: 1: LOIC Config : 1000 threads with Full Throttle enabled. 2: System Specs: Pentium Dual core with 4 GB Physical RAM Regards Deltarocked -
Powerful HTTP Server in Pure AutoIt
DeltaRocked replied to jvanegmond's topic in AutoIt Example Scripts
Hi Manadar, FYI I have taken the liberty of modifying the source and added anti-ddos module, this one is for a personal project. For Anti-DDOS Module it still under development , moreover initial tests were conducted using LOIC with satisfactory results. Regards Deltarocked. [EDIT] Note: Apache crashed within 2 seconds and messed up my system too -
Hi MeiSandy, Will verify the modified UDF and revert back. rgds Deltarocked. [uPDATE] Replied to this query in post id