Page 1 of 1
SSID password recovery (Windows)
Posted: Fri Sep 06, 2024 8:55 pm
by minimy
Tell me if it work in your country please, because cmd returned string is in your own lenguage.
Code: Select all
Procedure.s CLIreturn(prg.s, comando.s)
Protected salida.s
comando = ReplaceString(comando,"'",Chr(34))
idprg= RunProgram(prg, comando, GetPathPart(prg), #PB_Program_Open|#PB_Program_Read|#PB_Program_Error|#PB_Program_Hide)
If IsProgram(idprg)
While ProgramRunning(idprg)
If AvailableProgramOutput(idprg)
salida + ReadProgramString(idprg) + #CRLF$
EndIf
error$ = ReadProgramError(idprg)
If error$ <> ""
salida + error$ + #CRLF$
EndIf
Wend
EndIf
ProcedureReturn salida
EndProcedure
Procedure.s netGetRedes()
Protected.s o, router, ll, l= CLIreturn("cmd","/c netsh wlan show profiles")
Protected n, p= FindString(l," : ")-Len(" : ")
l= ReplaceString(l,Chr(10),"")
For p=10 To CountString(l,Chr(13))-1
router= StringField(StringField(l,p,Chr(13)),2,": ")
ll= CLIreturn("cmd","/c netsh wlan show profile name="+router+" key=clear")
ll= ReplaceString(ll,Chr(10),"")
For n= 1 To CountString(ll,Chr(13))-1
If n=33
o+ router+" : "+StringField(StringField(ll,n,Chr(13)),2,": ") + Chr(13)
EndIf
Next n
Next p
l= CLIreturn("cmd","/c netsh wlan show interfaces")
For n=1 To CountString(l,Chr(13))-1
If FindString(StringField(l,n,Chr(13)),"SSID :")
ll= "NETWORK : "+StringField(StringField(l,n,Chr(13)),2,": ") + Chr(13)
EndIf
Next n
ProcedureReturn ll+o
EndProcedure
MessageRequester("REDES INFO - minimy 2024", netGetRedes(),#PB_MessageRequester_Info)
Re: SSID password recovery (Windows)
Posted: Fri Sep 06, 2024 9:17 pm
by Bisonte
German W10x64 : only returns the correct SSID... no password...
Re: SSID password recovery (Windows)
Posted: Fri Sep 06, 2024 11:08 pm
by minimy
Bisonte wrote: Fri Sep 06, 2024 9:17 pm
German W10x64 : only returns the correct SSID... no password...
With this, show all info received. In my case is 33 the line with the password. May be other in german OS.. Idk.
Run this and watch in the output debug what line is the right line.
Later uncomment, and change line 28 in PB with 'if n=33' with your number.
I hope work. And thanks for comment.
Code: Select all
Procedure.s CLIreturn(prg.s, comando.s)
Protected salida.s
comando = ReplaceString(comando,"'",Chr(34))
idprg= RunProgram(prg, comando, GetPathPart(prg), #PB_Program_Open|#PB_Program_Read|#PB_Program_Error|#PB_Program_Hide)
If IsProgram(idprg)
While ProgramRunning(idprg)
If AvailableProgramOutput(idprg)
salida + ReadProgramString(idprg) + #CRLF$
EndIf
error$ = ReadProgramError(idprg)
If error$ <> ""
salida + error$ + #CRLF$
EndIf
Wend
EndIf
ProcedureReturn salida
EndProcedure
Procedure.s netGetRedes()
Protected.s o, router, ll, l= CLIreturn("cmd","/c netsh wlan show profiles")
Protected n, p= FindString(l," : ")-Len(" : ")
l= ReplaceString(l,Chr(10),"")
For p=10 To CountString(l,Chr(13))-1
router= StringField(StringField(l,p,Chr(13)),2,": ")
ll= CLIreturn("cmd","/c netsh wlan show profile name="+router+" key=clear")
ll= ReplaceString(ll,Chr(10),"")
For n= 1 To CountString(ll,Chr(13))-1
; If n=33
Debug Str(n)+" "+StringField(ll,n,Chr(13))
; o+ router+" : "+StringField(StringField(ll,n,Chr(13)),2,": ") + Chr(13)
; EndIf
Next n
Next p
l= CLIreturn("cmd","/c netsh wlan show interfaces")
For n=1 To CountString(l,Chr(13))-1
If FindString(StringField(l,n,Chr(13)),"SSID :")
ll= "NETWORK : "+StringField(StringField(l,n,Chr(13)),2,": ") + Chr(13)
EndIf
Next n
ProcedureReturn ll+o
EndProcedure
Re: SSID password recovery (Windows)
Posted: Sat Sep 07, 2024 9:11 am
by infratec
You have to use:
Code: Select all
CLIreturn("cmd","/c netsh wlan show profile name=" + #DQUOTE$ + router + #DQUOTE$ + " key=clear")
Because a FritzBox have spaces in the name like "FRITZ!Box 7430 PF"
And yes the key is shown (german version Win10 x64).
Re: SSID password recovery (Windows)
Posted: Sat Sep 07, 2024 10:11 am
by Bisonte
with infratec's correction
it works with the version in the first post on a german W10 x64 !

Re: SSID password recovery (Windows)
Posted: Sat Sep 07, 2024 1:47 pm
by minimy
infratec wrote: Sat Sep 07, 2024 9:11 am
You have to use:
Code: Select all
CLIreturn("cmd","/c netsh wlan show profile name=" + #DQUOTE$ + router + #DQUOTE$ + " key=clear")
Because a FritzBox have spaces in the name like "FRITZ!Box 7430 PF"
And yes the key is shown (german version Win10 x64).
Thanks infratec for your help, yes, I forgot that names can contain spaces.
Re: SSID password recovery (Windows)
Posted: Sat Sep 07, 2024 2:46 pm
by ChrisR
It works well here on Windows 10 x64 except for special characters.
No problem if I add the Oem2Unicode procedure below, also, netsh can be used directly without going through cmd /c
Code: Select all
Procedure.s Oem2Unicode(OEM_in_unicode.s)
Protected Oem_in_Ascii.s, ByteLength, Unicode.s
ByteLength = Len(OEM_in_unicode) + 2
Oem_in_Ascii = Space(ByteLength)
PokeS(@Oem_in_Ascii, OEM_in_unicode, -1, #PB_Ascii)
Unicode = Space(ByteLength)
OemToChar_(@Oem_in_Ascii, @Unicode)
ProcedureReturn Unicode
EndProcedure
Procedure.s CLIreturn(prg.s, comando.s)
Protected salida.s
comando = ReplaceString(comando,"'",Chr(34))
idprg= RunProgram(prg, comando, GetPathPart(prg), #PB_Program_Open|#PB_Program_Read|#PB_Program_Error|#PB_Program_Hide)
If IsProgram(idprg)
While ProgramRunning(idprg)
If AvailableProgramOutput(idprg)
salida + Oem2Unicode(ReadProgramString(idprg, #PB_Ascii)) + #CRLF$
EndIf
error$ = ReadProgramError(idprg, #PB_Ascii)
If error$ <> ""
salida + error$ + #CRLF$
EndIf
Wend
EndIf
ProcedureReturn salida
EndProcedure
Procedure.s netGetRedes()
Protected.s o, router, ll, l= CLIreturn("netsh","wlan show profiles")
Protected n, p= FindString(l," : ")-Len(" : ")
l= ReplaceString(l,Chr(10),"")
For p=10 To CountString(l,Chr(13))-1
router= StringField(StringField(l,p,Chr(13)),2,": ")
ll= CLIreturn("netsh","wlan show profile name=" + #DQUOTE$ + router + #DQUOTE$ + " key=clear")
ll= ReplaceString(ll,Chr(10),"")
For n= 1 To CountString(ll,Chr(13))-1
If n=33
o+ router+" : "+StringField(StringField(ll,n,Chr(13)),2,": ") + Chr(13)
EndIf
Next n
Next p
l= CLIreturn("netsh","wlan show interfaces")
For n=1 To CountString(l,Chr(13))-1
If FindString(StringField(l,n,Chr(13)),"SSID :")
ll= "NETWORK : "+StringField(StringField(l,n,Chr(13)),2,": ") + Chr(13)
EndIf
Next n
ProcedureReturn ll+o
EndProcedure
MessageRequester("REDES INFO - minimy 2024", netGetRedes(),#PB_MessageRequester_Info)
Re: SSID password recovery (Windows)
Posted: Sat Sep 07, 2024 5:58 pm
by infratec
@minimy
Btw. you should avoid this:
Code: Select all
For p=10 To CountString(l,Chr(13))-1
Because the expression CountString(l,Chr(13))-1 is executed for each loop.
Much better/faster:
Code: Select all
pMax = CountString(l,Chr(13))-1
For p=10 To pMax
At least with the asm backend.
Re: SSID password recovery (Windows)
Posted: Sat Sep 07, 2024 7:14 pm
by Quin
infratec wrote: Sat Sep 07, 2024 5:58 pm
At least with the asm backend.
Interesting point, I wonder if this is still a rule when using the C backend? I always do it to be safe, but wonder if you have to?
Re: SSID password recovery (Windows)
Posted: Sat Sep 07, 2024 9:24 pm
by infratec
I did a test with the /commented option on the command line.
ASM: (I reduced the listing it to the essential parts)
Code: Select all
; For i = 0 To Len("1234")
MOV dword [v_i],0
_For1:
MOV eax,_S1
PUSH eax
CALL _PB_Len@4
CMP eax,dword [v_i]
JL _Next2
; Print(Str(i))
CALL _PB_Str@12
; Next i
_NextContinue2:
INC dword [v_i]
JNO _For1
_Next2:
C ( I reduced the listing to the essential parts)
Code: Select all
// For i = 0 To Len("1234")
v_i=0;
while(1) {
integer r1=PB_Len(_S1);
if (!(((integer)r1>=v_i))) { break; }
// Print(Str(i))
PB_Str(v_i,SYS_PopStringBasePosition());
integer r2=PB_Print(p0);
// Next i
next1:
v_i+=1;
}
In both cases the Len("1234") procedure is always executed.
I don't think that the C compiler can optimize this.
For my surprise the for loop is converted to a while loop in the C compiler.
Re: SSID password recovery (Windows)
Posted: Sat Sep 14, 2024 10:16 pm
by minimy
infratec wrote: Sat Sep 07, 2024 5:58 pm
@minimy
Btw. you should avoid this:
Code: Select all
For p=10 To CountString(l,Chr(13))-1
Because the expression CountString(l,Chr(13))-1 is executed for each loop.
Much better/faster:
Code: Select all
pMax = CountString(l,Chr(13))-1
For p=10 To pMax
At least with the asm backend.
Thanks Infratec! Good lesson.
You'll never go to bed without knowing something new
