Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/26/2012 in all areas

  1. Great story, but it needs more guns and zombies and shit.
    2 points
  2. LockFile allows you to lock a file to the current process. This is useful if you want to interact with a specific file but wish to avoid the accidental deletion by another process or worse still a user. Examples have been provided and any advice for improvements is much appreciated. UDF: #include-once ; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 ; #INDEX# ======================================================================================================================= ; Title .........: Lock_File ; AutoIt Version : v3.3.10.0 or higher ; Language ......: English ; Description ...: Lock a file to the current process only. Any attempts to interact with the file by another process will fail ; Note ..........: ; Author(s) .....: guinness ; Remarks .......: The locked file handle must be closed with the Lock_Unlock() function after use ; =============================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <WinAPI.au3> ; #GLOBAL VARIABLES# ================================================================================================= ; None ; #CURRENT# ===================================================================================================================== ; Lock_Erase: Erase the contents of a locked file ; Lock_File: Lock a file to the current process only ; Lock_Read: Read data from a locked file ; Lock_Reduce: Reduce the locked file by a certain percentage ; Lock_Write: Write data to a locked file ; Lock_Unlock: Unlock a file so other processes can interact with it ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; None ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Erase ; Description ...: Erase the contents of a locked file ; Syntax ........: Lock_Erase($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; Return values .: Success - True ; Failure - False, use _WinAPI_GetLastError() to get additional details ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Erase($hFile) _WinAPI_SetFilePointer($hFile, $FILE_BEGIN) Return _WinAPI_SetEndOfFile($hFile) EndFunc ;==>Lock_Erase ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_File ; Description ...: Lock a file to the current process only ; Syntax ........: Lock_File($sFilePath[, $bCreateNotExist = False]) ; Parameters ....: $sFilePath - Filepath of the file to lock ; $bCreateNotExist - [optional] Create the file if it doesn't exist (True) or don't create (False). Default is False ; Return values .: Success - Handle of the locked file ; Failure - Zero and sets @error to non-zero. Call _WinAPI_GetLastError() to get extended error information ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_File($sFilePath, $bCreateNotExist = False) Return _WinAPI_CreateFile($sFilePath, BitOR($CREATE_ALWAYS, (IsBool($bCreateNotExist) And $bCreateNotExist ? $CREATE_NEW : 0)), BitOR($FILE_SHARE_WRITE, $FILE_SHARE_DELETE), 0, 0, 0) ; Creation = 2, Access = 2 + 4, Sharing = 0, Attributes = 0, Security = 0 EndFunc ;==>Lock_File ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Read ; Description ...: Read data from a locked file ; Syntax ........: Lock_Read($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $iBinaryFlag - [optional] Flag value to pass to BinaryToString(). Default is $SB_UTF8. See BinaryToString() documentation for more details ; Return values .: Success - Data read from the file ; Failure - Empty string and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Read($hFile, $iBinaryFlag = $SB_UTF8) Local $iFileSize = _WinAPI_GetFileSizeEx($hFile) + 1, _ $sText = '' Local $tBuffer = DllStructCreate('byte buffer[' & $iFileSize & ']') _WinAPI_SetFilePointer($hFile, $FILE_BEGIN) _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $iFileSize, $sText) Return SetError(@error, 0, BinaryToString(DllStructGetData($tBuffer, 'buffer'), $iBinaryFlag)) EndFunc ;==>Lock_Read ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Reduce ; Description ...: Reduce the locked file by a certain percentage ; Syntax ........: Lock_Reduce($hFile, $iPercentage) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $iPercentage - A percentage value to reduce the file by ; Return values .: Success - True ; Failure - False. Use _WinAPI_GetLastError() to get additional details ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Reduce($hFile, $iPercentage) If Not IsInt($iPercentage) Then $iPercentage = Int($iPercentage) If $iPercentage > 0 And $iPercentage < 100 Then Local $iFileSize = _WinAPI_GetFileSizeEx($hFile) * ($iPercentage / 100) _WinAPI_SetFilePointer($hFile, $iFileSize) Return _WinAPI_SetEndOfFile($hFile) EndIf Return Lock_Erase($hFile) EndFunc ;==>Lock_Reduce ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Write ; Description ...: Write data to a locked file ; Syntax ........: Lock_Write($hFile, $sText) ; Parameters ....: $hFile - Handle returned by Lock_File() ; $sText - Data to be written to the locked file ; Return values .: Success - Number of bytes written to the file ; Failure - 0 and sets @error to non-zero ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Write($hFile, $sText) Local $iFileSize = _WinAPI_GetFileSizeEx($hFile), _ $iLength = StringLen($sText) Local $tBuffer = DllStructCreate('byte buffer[' & $iLength & ']') DllStructSetData($tBuffer, 'buffer', $sText) _WinAPI_SetFilePointer($hFile, $iFileSize) Local $iWritten = 0 _WinAPI_WriteFile($hFile, DllStructGetPtr($tBuffer), $iLength, $iWritten) Return SetError(@error, @extended, $iWritten) ; Number of bytes written EndFunc ;==>Lock_Write ; #FUNCTION# ==================================================================================================================== ; Name ..........: Lock_Unlock ; Description ...: Unlock a file so other applications can interact with it ; Syntax ........: Lock_Unlock($hFile) ; Parameters ....: $hFile - Handle returned by Lock_File() ; Return values .: Success - True ; Failure - False ; Author ........: guinness ; Example .......: Yes ; =============================================================================================================================== Func Lock_Unlock($hFile) Return _WinAPI_CloseHandle($hFile) EndFunc ;==>Lock_Unlock Example 1: (with LockFile) #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> ; Include the LockFile.au3 UDF #include 'LockFile.au3' ; LockFile by guinness Example_1() Func Example_1() ; Path of the locked file Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; Lock the file to this process and create it if not already done so Local $hLock = Lock_File($sFilePath, True) ; Erase the contents of the locked file Lock_Erase($hLock) ; Write random data to the locked file For $i = 1 To 5 Lock_Write($hLock, RandomText(10) & @CRLF) Next ; Read the locked file Local $sRead = Lock_Read($hLock) ; Display the contents of the locked file that was just read MsgBox($MB_SYSTEMMODAL, '', $sRead) ; Display the current file size of the locked file. For example 60 bytes MsgBox($MB_SYSTEMMODAL, '', ByteSuffix(_WinAPI_GetFileSizeEx($hLock))) ; Reduce the file size by 50% Lock_Reduce($hLock, 50) ; Display the reduced size. This will be 50% less than before. For example 30 bytes MsgBox($MB_SYSTEMMODAL, '', ByteSuffix(_WinAPI_GetFileSizeEx($hLock))) ; Delete the locked file. As this is locked the deletion will fail MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 0, as the file is currently locked).') ; Unlock the locked file Lock_Unlock($hLock) ; Delete the file as it is now unlocked MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 1, as the file is unlocked).') EndFunc ;==>Example_1 ; Convert a boolean datatype to an integer representation Func BooleanToInteger($bValue) Return $bValue ? 1 : 0 EndFunc ;==>BooleanToInteger ; Append the largest byte suffix to a value Func ByteSuffix($iBytes, $iRound = 2) ; By Spiff59 Local Const $aArray = [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB'] Local $iIndex = 0 While $iBytes > 1023 And $iIndex < UBound($aArray) $iIndex += 1 $iBytes /= 1024 WEnd Return Round($iBytes, Int($iRound)) & $aArray[$iIndex] EndFunc ;==>ByteSuffix ; Generate random text Func RandomText($iLength) Local $iRandom = 0, _ $sData = '' For $i = 1 To $iLength $iRandom = Random(55, 116, 1) $sData &= Chr($iRandom + 6 * BooleanToInteger($iRandom > 90) - 7 * BooleanToInteger($iRandom < 65)) Next Return $sData EndFunc ;==>RandomText Example 2: (without LockFile) #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <WinAPIFiles.au3> ; Traditional approach to reading and writing to a file. Due to the nature of AutoIt, the file isn't locked, thus allowing other processes to interact with the file Example_2() Func Example_2() ; Path of the locked file Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; Lock the file to this process and create it if not already done so This is writing mode Local $hLock = FileOpen($sFilePath, $FO_OVERWRITE) ; Erase the contents of the locked file FileWrite($hLock, '') ; Write random data to the locked file For $i = 1 To 5 FileWrite($hLock, RandomText(10) & @CRLF) Next ; Close the file handle and create another handle to read the file contents FileClose($hLock) $hLock = FileOpen($sFilePath, $FO_READ) ; Read the locked file Local $sRead = FileRead($hLock) ; Display the contents of the locked file that was just read MsgBox($MB_SYSTEMMODAL, '', $sRead) ; Delete the locked file. As this is not locked by AutoIt the file will be deleted MsgBox($MB_SYSTEMMODAL, '', 'Delete the locked file: ' & _ @CRLF & _ @CRLF & _ FileDelete($sFilePath) & ' (this will return 1, as the file is''t locked by AutoIt due to safety measures in place).') ; Unlock the locked file (though not really locked) FileClose($hLock) EndFunc ;==>Example_2 ; Convert a boolean datatype to an integer representation Func BooleanToInteger($bValue) Return $bValue ? 1 : 0 EndFunc ;==>BooleanToInteger ; Generate random text Func RandomText($iLength) Local $iRandom = 0, _ $sData = '' For $i = 1 To $iLength $iRandom = Random(55, 116, 1) $sData &= Chr($iRandom + 6 * BooleanToInteger($iRandom > 90) - 7 * BooleanToInteger($iRandom < 65)) Next Return $sData EndFunc ;==>RandomText All of the above has been included in a ZIP file. Previous download: 866+ LockFile.zip
    1 point
  3. Kudos, but you're taking that a bit too seriously (as far as I'm concerned and in my own opinion). The one most important thing is that your kid daughter can look at pictures and click on what she wants with confidence. Sharing that applet around can only make more little kids happier. That's what's important. Then names are just ... names: sequences of symbols. Don't bother mentionning Volta, Maxwell, Lorentz, Plank, Bohr, Heisenberg, Shockley, Intel, Microsoft, Jon and the boundless multitude of scientists, engineers, technicians and volunteers who made all this possible at any rate. We all ride an implicit pyramid of giants and humble bricks. I understand others can have a diverging opinion about the matter.
    1 point
  4. Maybe something like this would work for you? Global $WindowArray[200][2] While 1 $Pos = _CheckPlace($SubFolderID, $Place, $Space) If IsArray($Pos) Then $i = $Pos[1] - $WinData[1] + 1 $WindowCount = $WindowCount + 1 If UBound($WindowArray) Then ReDim $WindowArray[UBound($WindowArray) * 2][2] EndIf $WindowArray[$WindowCount][0] = $Pos[0] $WindowArray[$WindowCount][1] = $Pos[1] Else $i = $i + 58 EndIf WEnd ; not sure how you tell you've run out of matches in your _CheckPlace so you'll need to have someway of using ExitLoop inside the While loop. ReDim $WindowArray[$WindowCount][2] For $i = 0 To UBound($WindowArray) MsgBox(0, "", "Position of SubFolder " & $i + 1 & "in Folder X:" & $WindowArray[$i][0] & "and Y" & $WindowArray[$i][1]) NextAs the comments in the script say, I have no way of knowing how you have determined you've run out of matches, so you will need to put an ExitLoop inside the While loop so that it has some way to exit the loop. Or use a For/Next loop instead of the While loop.
    1 point
  5. Andreik

    Store a Password

    In your brain it's the best place. If you think to write the password to a file, this one can be deleted or someone curious may think to try decrypt. Maybe if you give us a context, what's the purpose of this, we can help you more.
    1 point
  6. Skitty

    Check Gmail Emails

    I'm curious, did you get anything working? because believe it or not I was trying to find a way to do this as well, the furthest I got was being able to read the atom feed but I'm still stuck at trying to read the full email, I tried using winapiex.au3 to authenticate to Google but I can't figure it out :S I'd have posted this earlier but I was too inebriated to post it and make sense. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/so #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <string.au3> Global $eReturn = _CheckMail("email", "password") Global $Emails = @extended Switch @error Case 0 Switch @extended Case True ConsoleWrite(" 0>"&$eReturn[0][0] & @CR) ConsoleWrite(" "& $Emails & " " & $eReturn[0][1] & @CR) For $x = 1 To $Emails ConsoleWrite("!>Title - " & $eReturn[$x][0] & @CR) ConsoleWrite("+>Name - " & $eReturn[$x][1] & @CR) ConsoleWrite("->Email - " & $eReturn[$x][2] & @CR) ConsoleWrite(">summary - " & $eReturn[$x][3] & @CR & @CR) Next Case Else MsgBox(64,"success!","Success! But you have no new emails :(") EndSwitch Case 1 MsgBox(0,"Error!","Couldn't get your new emails for some reason...") Case 2,3 MsgBox(0,"Error!","you need to enter an user name and password!") Case 4 MsgBox(16,"Error!","Error Getting URL Source!") Case 5 MsgBox(16,"Error!","No response?") Case 6 MsgBox(16,"Error!","Unauthorized access, possibly a wrong username or password!") EndSwitch ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CheckMail ; Description ...: Checks a Google Email for new emails. ; Syntax ........: _CheckMail($UserName, $Pswd[, $UserAgentString = ""]) ; Parameters ....: $UserName - An unknown value. ; $Pswd - An unknown value. ; $UserAgentString - [optional] An unknown value. Default is "". ; Return values .: A 2d array with email information as follows~ ; 1|Title ; 2|Name ; 3|Email ; 4|Summary ; 5|Date ; 6|Time ; ; Author ........: dantay9 ; Modified ......: THAT1ANONYMOUSDUDE ; Remarks .......: ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/111853-gmail-email-checker/page__view__findpost__p__819409 ; Example .......: Yes ; =============================================================================================================================== Func _CheckMail($UserName, $Pswd, $UserAgentString = "") If Not $UserName Then Return SetError(2,0,0) If Not $Pswd Then Return SetError(3,0,0) If $UserAgentString Then HttpSetUserAgent($UserAgentString) Local $source = InetRead("https://" & $UserName & ":" & $Pswd & "@gmail.google.com/gmail/feed/atom",1) If @error Then ConsoleWrite("!>Error Getting URL Source!" & @CR & " 404>@Error =" & @error & @CR & " 404>@Extended =" & @extended & @CR) Return SetError(4,0,0) EndIf If $source Then $source = BinaryToString($source) Else Return SetError(5,0,0) EndIf If StringLeft(StringStripWS($source, 8), 46) == "<HTML><HEAD><TITLE>Unauthorized</TITLE></HEAD>" Then Return SetError(6, 0, 0) If Not Number(StringBetween($source, "<fullcount>", "</fullcount>")) Then Return SetError(0,0,0) Local $Email = _StringBetween($source, "<entry>", "</entry>") If @error Then Return SetError(1, 0, 0) Local $Time Local $Count = UBound($Email) Local $Datum[$Count + 1][6] $Datum[0][0] = StringBetween($source, "<title>", "</title>") $Datum[0][1] = StringBetween($source, "<tagline>", "</tagline>") For $i = 0 To $Count - 1 $Datum[$i+1][0] = StringBetween($Email[$i], "<title>", "</title>") If Not $Datum[$i+1][0] Then $Datum[$i][0] = "(no subject)" $Datum[$i+1][1] = StringBetween($Email[$i], "<name>", "</name>") $Datum[$i+1][2] = StringBetween($Email[$i], "<email>", "</email>") $Datum[$i+1][3] = StringBetween($Email[$i], "<summary>", "</summary>") $Time = StringBetween($Email[$i], "<issued>", "</issued>") $Datum[$i+1][4] = DateFromTimeDate($Time) $Datum[$i+1][5] = TimeFromTimeDate($Time) Next Return SetError(0,$Count,$Datum) EndFunc Func StringBetween($Str, $S, $E) Local $B = _StringBetween($Str, $S, $E) If @error Then Return SetError(1,0,0) Return SetError(0,0,$B[0]) EndFunc ;==>StringBetween ; #FUNCTION# ==================================================================================================================== ; Name ..........: DateFromTimeDate ; Description ...: Returns email sent date. ; Syntax ........: DateFromTimeDate($String) ; Parameters ....: $String - A gmail date string ; Return values .: None ; Author ........: ??? ; Example .......: No ; =============================================================================================================================== Func DateFromTimeDate($String) Local $RegEx = StringRegExp($String, "(?<Year>d{2}|d{4})(?:-)(?<Month>d{1,2})(?:-)(?<Day>d{1,2})", 1) If IsArray($RegEx) Then Return Int($RegEx[0]) & "/" & Int($RegEx[1]) & "/" & Int($RegEx[2]) Else Return SetError(1, 0, 0) EndIf EndFunc ;==>DateFromTimeDate ; #FUNCTION# ==================================================================================================================== ; Name ..........: TimeFromTimeDate ; Description ...: Returns the email sent time. ; Syntax ........: TimeFromTimeDate($String) ; Parameters ....: $String - An unknown value. ; Return values .: None ; Author ........: ??? ; Example .......: No ; =============================================================================================================================== Func TimeFromTimeDate($String) Local $RegEx = StringRegExp($String, "(?<Hour>d{1,2})(?::)(?<Minute>d{1,2})(?::)(?<Second>d{1,2})", 1) If IsArray($RegEx) Then Return (Int($RegEx[0]) - 4) & ":" & Int($RegEx[1]) & ":" & Int($RegEx[2]) ;don't know why I have to subtract 4 Else Return SetError(1, 0, 0) EndIf EndFunc ;==>TimeFromTimeDate
    1 point
  7. Jos

    Keylogger Posts

    aahhh.. trying to make friend here ...... The simple fact is that these Keylogger type script cause a lot of virus spin offs and thus hurting the regular use of AutoIt. None of you Keylogger/game scripters have ever shown much real interest other than posting a question like "need urgent help with this script and i expect u to code it for me " and generally the wrong forum. In other words TOTAL lack of interest, so don't expect much sympathy/respect from any of the regulars..... Jon, guess this topic need to be closed soon unless you want a lengthy BS discussion as a sticky....
    1 point
×
×
  • Create New...