Hi a friend of mine asked me to recover a password of a program written in clipper back in 1994. I got myself a decompiler (Valkyrie 5) and decompiled the EXE-file. I located a procedure called USERLOGIN. The problem is that i dont know how to program in clipper. I would be very thankfull if someone could edit the procedure so it won't ask for authentication anymore.
#include "common.ch"
#include "inkey.ch"
********************************
Function USERLOGON
Local Local1:= -1, Local2:= .F., Local3, Local4, Local5:= 3, ;
Local6:= 3, Local7:= 7, Local8:= 41, Local9, Local10, Local11, ;
Local12, Local13, Local14, Local15
Local3:= 1
Local9:= {}
Local13:= setcursor()
If (!netuse(diskname() + ":" + dirname() + "\" + "sinusr.dbf", ;
"users"))
Return Local1
EndIf
dbSetFilter({ || users->valid })
Local14:= box(Local5, Local6, Local7, Local8, Nil, ;
coltonum("GR+/B"))
Do While (!Local2)
Local10:= Space(12)
Local11:= Space(10)
setcursor(1)
If (!Empty(n_shellver()))
Local10:= padr(nnetwhoami(), 12)
EndIf
wininfo(Local14, #Local5, #Local6, #Local7, #Local8)
# Local5 + 1, Local6 + 5 Say "User............." Color "GR+/B"
SetPos(Row(), Col() + 1)
AAdd(Local9, __Get({ |_1| IIf(ISNIL(_1), Local10, Local10:= ;
_1) }, "cUName", "#K!", Nil, Nil):display())
# Local5 + 2, Local6 + 5 Say "Password........." Color "GR+/B"
SetPos(Row(), Col() + 1)
AAdd(Local9, __Get({ |_1| IIf(ISNIL(_1), Local11, Local11:= ;
_1) }, "cUPass", "#K!", Nil, Nil):display())
Local9[2]:reader({ |_1| gt_grpassw(_1) })
wreadmodal(Local9, 0)
Local11:= Local9[2]:cargo()
Local9:= {}
If (LastKey() == K_ESC .OR. !winisinuse(Local14))
If (winisinuse(Local14))
winclose(Local14)
EndIf
Return Local1
EndIf
Local10:= alltrim(Local10)
Local12:= {}
Locate For Local10 == alltrim(users->emri)
Do While (Found())
AAdd(Local12, users->id)
Continue
EndDo
For Local4:= 1 To Len(Local12)
If ((Local15:= upass(Local12[Local4])) != Nil)
If (alltrim(Local11) == Local15)
Local2:= .T.
Exit
EndIf
EndIf
Next
EndDo
If (users->id != Local12[Local4])
users->(dbGoTop())
Locate For Local12[Local4] == users->id
If (!Found())
msg("Fatal error in user's file !", 3)
Return -1
EndIf
EndIf
For Local4:= 1 To MaxCol()
winchgpos(0, 3)
Next
boxc(Local14)
setcursor(Local13)
If (users->in)
tone(500, 10)
Local4:= al_box("User " + Trim(users->emri) + ;
" is already IN;" + "Do You Want to Jump In ?", 2, ;
{" Yes ", " No "}, 2, "WARNING")
If (Local4 == 1)
msg("More than One User with the same Name might cause Trouble !", ;
3)
Else
Close
Return -1
EndIf
ElseIf (netrlock())
Replace users->in With .T.
Unlock
dbcommit()
Else
Close
Return -1
EndIf
Static148[1]:= users->id
Static148[2]:= alltrim(users->emri)
Static148[3]:= alltrim(users->dirpriv)
Static148[4]:= users->gjuha1
Static148[5]:= users->gjuha2
Static148[6]:= alltrim(users->emriiplote)
Local1:= Static148[1]
Close
Return Local1
* EOF
This is partially guesswork, but here's my interpretation:
Read the user's password from the console into Local9[2]:
# Local5 + 2, Local6 + 5 Say "Password........." Color "GR+/B"
...
Local9[2]:reader({ |_1| gt_grpassw(_1) })
wreadmodal(Local9, 0)
Put the password into Local11:
Local11:= Local9[2]:cargo()
Fetch all user ids into Local12 via Local10:
Locate For Local10 == alltrim(users->emri)
Do While (Found())
AAdd(Local12, users->id)
Continue
EndDo
Get each user's password into Local15, and if the password's present and matches the password in Local11, verify the user:
For Local4:= 1 To Len(Local12)
If ((Local15:= upass(Local12[Local4])) != Nil)
If (alltrim(Local11) == Local15)
Local2:= .T.
Exit
EndIf
EndIf
Next
The fix
Just remove the password check code. Not being certain about the purpose of all the rest of the code, I'd recommend leaving it alone. I've preserved the retrieval of the user's password, as maybe there's a good reason not to log in a user who has no password at all (perhaps that's how an account is disabled. The last block above could be changed to this:
For Local4:= 1 To Len(Local12)
If ((Local15:= upass(Local12[Local4])) != Nil)
Local2:= .T.
EndIf
Next
Related
I'm trying to parse a POST request using apache and mod_lua, i have something like this :
function authz_bulk_get(r, id_dash)
r:debug("BULK_DEBUG START")
if r.method == 'GET' then
for k, v in pairs(r:parseargs()) do
r:debug("BULK_DEBUG " .. k .. " " .. v)
end
elseif r.method == 'POST' then
r:debug("BULK_DEBUG TREAT POST")
local jv_content = r:requestbody()
r:debug("BULK_DEBUG REQUEST_BODY")
r:debug("BULK_DEBUG " .. jv_content)
jv_content = jv_content:gsub("%[", "")
jv_content = jv_content:gsub("%]", "")
local jv_jsonparse = json.decode(jv_content)
r:debug("BULK_DEBUG " .. jv_content)
r:debug("BULK_DEBUG " .. jv_jsonparse["type"])
r:debug("BULK_DEBUG " .. jv_jsonparse["id"])
end
r:debug("BULK_DEBUG END")
return apache2.AUTHZ_GRANTED
end
Everything seems OK in debug logs, i have all correct traces and I see requestbody and json parsing executing well but the response is {"statusCode":400,"error":"Bad Request","message":"[request body]: expected value of type [array] but got [null]"}
It looks like the request is emptied when i do r:requestbody()
Maybe I need to re-transmit the POST request after doing this processing ?
Any ideas ?
Thanks
I am trying to automate drag and drop between two File Explorers on windows OS. I could find online help to drag and drop implementation for Browsers.
But no help for drag and drop for file to another File Explorer.
Use for this the Shell.Application object. To get the selection from the explorer you can use the following function:
;===============================================================================
; Function Name....: _ActiveExplorer_GetSelected
; Description......: Creates an array with
; - Count of selected files/folder
; - Path of active Explorer window and
; - the path/es of selected file/s /folder
; Requirement(s)...: Opened Explorer window
; Return Value(s)..: Array with data, $a[0] = Count, $a[1] = Folderpath, $a[2..] = File/Foldername
; .................: ATTENTION! Last index $a[0]+1 !!
; Author(s)........: BugFix ( AutoIt#bug-fix.info )
;===============================================================================
Func _ActiveExplorer_GetSelected()
Local $oShell = ObjCreate("Shell.Application")
Local $oExplorer, $sPath, $oFolderView, $iCount = 0, $sSelectedFiles = '', $n = 2
Local $oShellWindows = $oShell.Windows
For $i = 0 To $oShellWindows.Count -1
$oExplorer = $oShellWindows($i)
$sPath = StringReplace(StringReplace(StringTrimLeft($oExplorer.LocationURL, 8), '%20', ' '), '/', '\')
If WinGetTitle('[ACTIVE]') = $sPath Then ExitLoop
Next
$oFolderView = $oExplorer.Document.SelectedItems()
$iCount = $oFolderView.Count
Local $aOut[$iCount +2]
$aOut[0] = $iCount
$aOut[1] = $sPath
If $iCount = 0 Then
Return ''
Else
For $oFolderItem In $oFolderView
$aOut[$n] = $oFolderItem.Name
$n += 1
Next
Return $aOut
EndIf
EndFunc ; ==>_ActiveExplorer_GetSelected
I'm writing an LPeg-based parser. How can I make it so a parsing error returns nil, errmsg?
I know I can use error(), but as far as I know that creates a normal error, not nil, errmsg.
The code is pretty long, but the relevant part is this:
local eof = lpeg.P(-1)
local nl = (lpeg.P "\r")^-1 * lpeg.P "\n" + lpeg.P "\\n" + eof -- \r for winblows compat
local nlnoeof = (lpeg.P "\r")^-1 * lpeg.P "\n" + lpeg.P "\\n"
local ws = lpeg.S(" \t")
local inlineComment = lpeg.P("`") * (1 - (lpeg.S("`") + nl * nl)) ^ 0 * lpeg.P("`")
local wsc = ws + inlineComment -- comments count as whitespace
local backslashEscaped
= lpeg.P("\\ ") / " " -- escaped spaces
+ lpeg.P("\\\\") / "\\" -- escaped escape character
+ lpeg.P("\\#") / "#"
+ lpeg.P("\\>") / ">"
+ lpeg.P("\\`") / "`"
+ lpeg.P("\\n") -- \\n newlines count as backslash escaped
+ lpeg.P("\\") * lpeg.P(function(_, i)
error("Unknown backslash escape at position " .. i) -- this error() is what I wanna get rid of.
end)
local Line = lpeg.C((wsc + (backslashEscaped + 1 - nl))^0) / function(x) return x end * nl * lpeg.Cp()
I want Line:match(...) to return nil, errmsg when there's an invalid escape.
LPeg itself doesn't provide specific functions to help you with error reporting. A quick fix to your problem would be to make a protected call (pcall) to match like this:
local function parse(text)
local ok, result = pcall(function () return Line:match(text) end)
if ok then
return result
else
-- `result` will contain the error thrown. If it is a string
-- Lua will add additional information to it (filename and line number).
-- If you do not want this, throw a table instead like `{ msg = "error" }`
-- and access the message using `result.msg`
return nil, result
end
end
However, this will also catch any other error, which you probably don't want. A better solution would be to use LPegLabel instead. LPegLabel is an extension of LPeg that adds support for labeled failures. Just replace require"lpeg" with require"lpeglabel" and then use lpeg.T(L) to throw labels where L is an integer from 1-255 (0 is used for regular PEG failures).
local unknown_escape = 1
local backslashEscaped = ... + lpeg.P("\\") * lpeg.T(unknown_escape)
Now Line:match(...) will return nil, label, suffix if there is a label thrown (suffix is the remaining unprocessed input, which you can use to compute for the error position via its length). With this, you can print out the appropriate error message based on the label. For more complex grammars, you would probably want a more systematic way of mapping the error labels and messages. Please check the documentation found in the readme of the LPegLabel repository to see examples of how one may do so.
LPegLabel also allows you to catch the labels in the grammar by the way (via labeled choice); this is useful for implementing things like error recovery. For more information on labeled failures and examples, please check the documentation.
Hello there everyone,
I have recently downloaded a bot for a game that I play, this bot uses Autoit to automate movements on screen, alongside Autoit I downloaded some scripts that allow me to automate in-game movements. I downloaded these scripts on my main pc and my laptop so I can run them on 2 accounts if need be. The download is exactly the same and although the bot works perfectly on my PC, it does something weird on my laptop:
The cursor seems to be able to go to places I have specificly told it to go but once it needs to imagesearch or pixelsearch it simply stops. The program doesnt stop running and will continue performing the actions that it can perform, at the right timing, however all imagesearching functions get left out.
The only major diference between the pc and laptop is that the laptop is running windows 8.
Things Iv tried by searching prior to asking here:
I have read that imagesearch.dll should be in sysWOW64 in order for it to work and I beleive I have done that by copying the DLL files and pasting them in syswow64. That did not help.
I also tried adding #requireadmin to the top of the script which did not help either.
this is happening with ALL the scripts I downloaded. They all work on pc and none work on laptop. I dont have alot of understanding with this code as I did not write it myself. However I have familirized myself with it a little as I do edit it for my personal uses on my pc and make it work very well. So I thought that it not functioning on my laptop must be some amateur mistake about windows 8 or similar.
here is an example script.
#RequireAdmin
#include <Misc.au3>
HotKeySet("{[}", "MakeLock")
HotKeySet("{z}", "Start")
HotKeySet("{ESC}", "_Exit")
HotKeySet("{x}", "Shafts")
HotKeySet("{c}", "Heads")
HotKeySet("{v}", "bsb")
$handle = WinGetHandle("Wurm Online", "")
Global $running=0
Global $shaftLoc
Global $headLoc
Global $shaft=0
Global $head=0
Global $bsb=0
Global $bsbloc
Func _Exit()
Exit
EndFunc ;==>_Exit
Func Getfrombsb()
MouseMove($bsbloc[0], $bsbloc[1], 5)
MouseDown("left")
Sleep(100)
MouseMove($shaftloc[0], $shaftloc[1], 5)
Sleep(100)
MouseUp("left")
sleep(2500)
send ("4")
sleep(250)
Send("{Enter}")
sleep(3000)
EndFunc
Func Shafts()
MsgBox(0, "", "title of items")
$shaft=1
EndFunc
Func Drop()
MouseMove($shaftloc[0], $shaftloc[1], 5)
MouseDown("left")
Sleep(250)
MouseMove($bsbloc[0], $bsbloc[1], 5)
MouseUp("left")
EndFunc
Func bsb()
MsgBox(0, "", "item in bsb")
$bsb=1
EndFunc
Func Heads()
MsgBox(0, "", "Click on what ur continuing")
$head=1
EndFunc
Func continue()
MouseMove($shaftloc[0], $shaftloc[1], 5)
MouseClick("left")
Sleep(100)
MouseMove($shaftloc[0], $shaftloc[1], 5)
MouseClick("right")
Sleep(1000)
$line = GetLine()
If IsArray($line) Then
Local $random2 = Random(200, 250, 1)
MouseMove($line[0], $line[1]+3*16-8, 5)
Sleep($random2-51)
MouseMove($line[0]+120, $line[1]+3*16-8, 5)
Sleep($random2+38)
MouseMove($line[0]+120, $line[1]+3*16-8+2*16, 5)
Sleep(500)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16, 5)
Sleep($random2+161)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16+44, 25)
Sleep($random2)
MouseClick("left")
EndIf
EndFunc
Func Start()
if $running==0 Then
$running=1
TrayTip("", "Macro started", 5)
ElseIf $running==1 Then
$running=0
TrayTip("", "Macro stopped", 5)
EndIf
EndFunc
Func GetLine()
$pos = MouseGetPos()
$samp = $pos
For $i = 0 To 48 Step 1
$samp[0] = $pos[0]+32
$samp[1] = $pos[1]+$i
$s0 = PixelGetColor($samp[0], $samp[1], $handle)
If $s0 == 0xFFFFFF Then
$s1 = PixelGetColor($samp[0]+1, $samp[1], $handle)
If $s1 == 0xFFFFFF Then
$s2 = PixelGetColor($samp[0]+2, $samp[1], $handle)
$s3 = PixelGetColor($samp[0]+3, $samp[1], $handle)
If $s2 == 0xFFFFFF AND $s3 == 0xFFFFFF Then
$line = $samp
ExitLoop
EndIf
EndIf
EndIf
$line = 0
Next
Return $line
EndFunc
While (1)
if _IsPressed("01") And $shaft==1 Then
$shaftloc = MouseGetPos()
$shaft=0
MsgBox(0, "", "shaft loc loaded")
endif
if _IsPressed("01") And $head==1 Then
$headloc = MouseGetPos()
$head=0
MsgBox(0, "", "head loc loaded")
EndIf
if _IsPressed("01") And $bsb==1 Then
$bsbloc = MouseGetPos()
$bsb=0
MsgBox(0, "", "bsb loc loaded")
EndIf
if $running==1 Then
Getfrombsb()
Local $random = Random(24000, 25000, 1)
continue()
Sleep($random)
sleep(500)
Drop()
sleep(2000)
Drop()
sleep(2000)
EndIf
Sleep(10)
WEnd
After watching exactly what it does and does not do, I can see that problem arrises with the section of code below it does everything up until; $line = GetLine()
$line = GetLine()
If IsArray($line) Then
Local $random2 = Random(200, 250, 1)
MouseMove($line[0], $line[1]+3*16-8, 5)
Sleep($random2-51)
MouseMove($line[0]+120, $line[1]+3*16-8, 5)
Sleep($random2+38)
MouseMove($line[0]+120, $line[1]+3*16-8+2*16, 5)
Sleep(500)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16, 5)
Sleep($random2+161)
MouseMove($line[0]+200, $line[1]+3*16-8+2*16+44, 25)
Sleep($random2)
MouseClick("left")
EndIf
EndFunc
Any help would be appreciated. And although I am not familiar with code that much I do know how to use stack overflow well as my brother is a .net developer. I will mark the question that helps me and upvote and such.
Kind regards.
I know what your problem is.. I think. Try turning the output of PixelGetColor() into Hex.
Also, when it outputs, it doesnt include the "0x" at the beginning of the color tag.
So, you could say:
#Include <Misc.au3> ;for the _ispressed() function
Do
Until _IsPressed("01") ;wait for click
$mouse = MouseGetPos() ;Get cursor info
$color = Hex(PixelGetColor($mouse[0], $mouse[1]), 6) Get info on the pixel under the mouse.
;Lets just say the color is white
If $color == "FFFFFF" Then
MsgBox(0, "Success", "Colors match!")
EndIf
As for the ImageSearch not working, that could be a problem with AutoHotKey's compatability with Windows 8. Because of AutoIt not having a ImageSearch function, developers use AutoHotKey's ImageSearch function, and wrap it up in an AutoIt library. That may be where the problem is cominh
I'm trying to read PDF' page size eg.height X weight. Page size can be found in
File -> Properties -> Page Size
I used the code below to fetch the property value:
$path = FileOpenDialog("Select a file to read attributes",#ScriptDir,"All (*.*)")
$prop = _GetExtProperty($path,-1)
_ArrayDisplay($prop,"Property Array")
Func _GetExtProperty($sPath, $iProp)
Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
$iExist = FileExists($sPath)
If $iExist = 0 Then
SetError(1)
Return 0
Else
$sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
$sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
$oShellApp = ObjCreate ("shell.application")
$oDir = $oShellApp.NameSpace ($sDir)
$oFile = $oDir.Parsename ($sFile)
If $iProp = -1 Then
Local $aProperty[35]
For $i = 0 To 34
$aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
Next
Return $aProperty
Else
$sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
If $sProperty = "" Then
Return 0
Else
Return $sProperty
EndIf
EndIf
EndIf
EndFunc ;==>_GetExtProperty
By using above code i managed to get file size in MB, Created date , Modified date, Location and so on, but not Page Size. Appreciated, if anyone could advice how I can get page size. Any reference, advice or sample code is highly appreciated.
Nearly the same, but maybe it helps.
#include <Array.au3>
;===============================================================================
; Function Name.....: _FileGetProperty
; Description.......: Returns a property or all properties for a file.
; Version...........: 1.0.2
; Change Date.......: 2008-07-28
; AutoIt Version....: 3.2.12.1
;
; Parameter(s)......: $S_PATH - String containing the file path to return the property from.
; $S_PROPERTY - [optional] String containing the name of the property to return. (default = "")
; Requirements(s)...: None
; Return Value(s)...: Success: Returns a string containing the property value.
; If $S_PROPERTY is empty, an two-dimensional array is returned:
; $av_array[0][0] = Number of properties.
; $av_array[1][0] = 1st property name.
; $as_array[1][1] = 1st property value.
; $av_array[n][0] = nth property name.
; $as_array[n][1] = nth property value.
; Failure: Returns 0 and sets #error to:
; 1 = The folder $S_PATH does not exist.
; 2 = The property $S_PROPERTY does not exist or the array could not be created.
; 3 = Unable to create the "Shell.Application" object $objShell.
;
; Author(s).........: - Simucal <Simucal#gmail.com>
; - Modified by: Sean Hart <autoit#hartmail.ca>
; - Modified by: teh_hahn <sPiTsHiT#gmx.de>
; Company...........: None
; URL...............: None
; Note(s)...........: None
;===============================================================================
Global $re = _FileGetProperty(#ScriptDir & '\1Tutorial - AutoItWiki1.pdf')
If #error Then MsgBox(16, 'ERROR', 'Error: ' & #error & #CRLF & '1 = The folder $S_PATH does not exist.' & #CRLF & _
'2 = The property $S_PROPERTY does not exist or the array could not be created.' & #CRLF & _
'3 = Unable to create the "Shell.Application" object $objShell.')
_ArrayDisplay($re)
Func _FileGetProperty(Const $S_PATH, Const $S_PROPERTY = "")
If Not FileExists($S_PATH) Then Return SetError(1, 0, 0)
Local Const $S_FILE = StringTrimLeft($S_PATH, StringInStr($S_PATH, "\", 0, -1))
Local Const $S_DIR = StringTrimRight($S_PATH, StringLen($S_FILE) + 1)
Local Const $objShell = ObjCreate("Shell.Application")
If #error Then Return SetError(3, 0, 0)
Local Const $objFolder = $objShell.NameSpace($S_DIR)
Local Const $objFolderItem = $objFolder.Parsename($S_FILE)
If $S_PROPERTY Then
For $i = 0 To 99
If $objFolder.GetDetailsOf($objFolder.Items, $i) = $S_PROPERTY Then Return $objFolder.GetDetailsOf($objFolderItem, $i)
Next
Return SetError(2, 0, 0)
EndIf
Local $av_ret[1][2] = [[1]]
For $i = 0 To 99
If $objFolder.GetDetailsOf($objFolder.Items, $i) Then
ReDim $av_ret[$av_ret[0][0] + 1][2]
$av_ret[$av_ret[0][0]][0] = $objFolder.GetDetailsOf($objFolder.Items, $i)
$av_ret[$av_ret[0][0]][1] = $objFolder.GetDetailsOf($objFolderItem, $i)
$av_ret[0][0] += 1
EndIf
Next
If Not $av_ret[1][0] Then Return SetError(2, 0, 0)
$av_ret[0][0] -= 1
Return $av_ret
EndFunc ;==>_FileGetProperty