How to delete a password string variable?
How to delete a password string variable?
Hello fellows,
what is the best way to completely delete a string variable that contains, for example, a decoded password that is no longer needed?
Would a sPassword = "" be enough?
Kurzer
what is the best way to completely delete a string variable that contains, for example, a decoded password that is no longer needed?
Would a sPassword = "" be enough?
Kurzer
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
"Happiness is a pet." | "Never run a changing system!"
Re: How to delete a password string variable?
If you really don't want it in memory anymore, write something about it and then reset the string with "".
I think this has been discussed here in the forum several times.
I think this has been discussed here in the forum several times.
sorry for my bad english
Re: How to delete a password string variable?
Do you mean overwriting the string?
It is described that the memory for strings is not really freed, but reused. Therefore also my question... I suspect/fear that sPassword = "" simply uses a new string memory and the password is still visible in the memory.
Code: Select all
sPassword = Space(100)
sPassword = ""
That's what I thought and searched for, but I didn't find a really meaningful result.I think this has been discussed here in the forum several times.
It is described that the memory for strings is not really freed, but reused. Therefore also my question... I suspect/fear that sPassword = "" simply uses a new string memory and the password is still visible in the memory.
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
"Happiness is a pet." | "Never run a changing system!"
Re: How to delete a password string variable?
An overwrite with sPassword = "" wouldn't help for sure:
Code: Select all
Define String.s = "Hallo World!"
Define *Buffer = @String
String = ""
ShowMemoryViewer(*Buffer, 24)
Also if you overwrite it with a string larger than the password, the new string could be stored at an other place and leave the old unchanged:0000000001EE1310 00 00 61 00 6C 00 6C 00 6F 00 20 00 57 00 6F 00 ..a.l.l.o. .W.o.
0000000001EE1320 72 00 6C 00 64 00 21 00 r.l.d.!.
Code: Select all
Define String.s = "Hallo World!"
Define *Buffer = @String
String = Space(100)
ShowMemoryViewer(*Buffer, 24)
I think you have to overwrite the password with a string with the same length0000000001D31310 48 00 61 00 6C 00 6C 00 6F 00 20 00 57 00 6F 00 H.a.l.l.o. .W.o.
0000000001D31320 72 00 6C 00 64 00 21 00 r.l.d.!.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: How to delete a password string variable?
I'm not sure whether overwriting with a string of the same length always works. I would overwrite the password with PokeS.STARGÅTE wrote:I think you have to overwrite the password with a string with the same length
Code: Select all
PokeS (@MyPassword$, Space (Len (MyPassword$)))
MyPsssword$ = ""
sorry for my bad english
Re: How to delete a password string variable?
For PB 5.71 on Windows 10 x64, this seems to work. For the other versions I haven't tested.Josh wrote:I'm not sure whether overwriting with a string of the same length always works.
Based on the code of STARGÅTE and idea of Josh
Code: Select all
Define MyPassword$ = "Hello World!"
Define *Buffer = @MyPassword$
ShowMemoryViewer(*Buffer, 24)
MessageRequester("", "Hit Enter to continue")
PokeS (@MyPassword$, Space (Len (MyPassword$)))
ShowMemoryViewer(*Buffer, 24)
Code: Select all
00000000023C0880 48 00 65 00 6C 00 6C 00 6F 00 20 00 57 00 6F 00 H.e.l.l.o. .W.o.
00000000023C0890 72 00 6C 00 64 00 21 00 r.l.d.!.
Code: Select all
00000000023C0880 20 00 20 00 20 00 20 00 20 00 20 00 20 00 20 00 . . . . . . . .
00000000023C0890 20 00 20 00 20 00 20 00 . . . .
Code: Select all
MyPassword$ = Space(Len(MyPassword$) - 1)
Re: How to delete a password string variable?
Thank you all for your input.
The version with poking into the string memeory looks very reliable to me. I'll have it that way.
Thanks a lot!
Kurzer
The version with poking into the string memeory looks very reliable to me. I'll have it that way.
Thanks a lot!
Kurzer
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
"Happiness is a pet." | "Never run a changing system!"
Re: How to delete a password string variable?
Really clear/delete a string
Code (x64):
Only fully works with PB 5.62 and earlier Versions
as Null$ is broken on all newer versions of PB!
Code (x64):
Code: Select all
Macro DeleteString(String)
EnableASM
mov rax,String
DisableASM
!test rax,rax
!jz dels_error
!dels_clear:
!mov word[rax],0x0
!add rax,0x2
!cmp word[rax],0x0
!jne dels_clear
!dels_error:
String = #Null$
EndMacro
as Null$ is broken on all newer versions of PB!
Re: How to delete a password string variable?
Thanks Mijikai,
but what a pity that it is not working in PB 5.71.
but what a pity that it is not working in PB 5.71.
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
"Happiness is a pet." | "Never run a changing system!"
Re: How to delete a password string variable?
What is wrong with Josh's PokeS()?
Works for me.
Works for me.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: How to delete a password string variable?
On newer versions this is the current work around:kurzer wrote:Thanks Mijikai,
but what a pity that it is not working in PB 5.71.
Code: Select all
String = "!_PB_NullConstant_!"
Re: How to delete a password string variable?
FillMemory could also be used as an alternative for PokeS and is probably faster.
In that case you will end up with multiple labels that have the same name.
To fix this you could use MacroExpandedCount.
Code: Select all
MyPassword.s = "MyPassword"
FillMemory(@MyPassword, StringByteLength(MyPassword))
ShowMemoryViewer(@MyPassword, 22)
This code will give problems when the macro is called multiple times.Mijikai wrote:Really clear/delete a string
Code (x64):Code: Select all
Macro DeleteString(String) EnableASM mov rax,String DisableASM !test rax,rax !jz dels_error !dels_clear: !mov word[rax],0x0 !add rax,0x2 !cmp word[rax],0x0 !jne dels_clear !dels_error: String = #Null$ EndMacro
In that case you will end up with multiple labels that have the same name.
To fix this you could use MacroExpandedCount.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: How to delete a password string variable?
It is nothing wrong, I use his Version in my code.skywalk wrote:What is wrong with Josh's PokeS()?
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2024: 56y
"Happiness is a pet." | "Never run a changing system!"
"Happiness is a pet." | "Never run a changing system!"