devsodoku
Goto Top

Batch Wlan Passwort auslesen mit findstr

Guten Tag,
ich habe ein Problem mit meinem Batch Programm und zwar habe ich mir einen Zufalls Generator mit Batch geschrieben das nebenbei einen Log für die Zufällig ausgewählte Kombination aus Zahlen und Buchstaben, Benutzer Information, Wlan Name und was leider nicht funktioniert das Passwort abspeichert. Kann mir da jemand helfen? Hab mir einen großteil des codes bei verschiedenen Plattformen wie zb. Administrator.de zusammen gesucht und dann meine eigenen Wünche ergänzt.

Der Code:
@echo off & setlocal


for /f "tokens=1* delims=:" %%i in (  
  'netsh wlan show interfaces ^| findstr /rxc:"[ ]* SSID [ ]*: ..*"'  
) do for /f "tokens=*" %%k in ("%%j") do set "SSID=%%k"  

for /f "tokens=1* delims=:" %%i in (  
  'netsh Wlan show Profile %SSID% key=clear ^| findstr /rxc:"[ ]* Schlüsselinhalt [ ]*: ..*"'  
) do for /f "tokens=*" %%k in ("%%j") do set "Schlüsselinhalt=%%k"  

pause

echo %SSID%
echo %Schlüsselinhalt%

:loop
set "Zeichen=BCDEGHIJKMNOPRSTUVWXYZabcdefghijklmnopqrstvwxyz!123456789"  


set G=%temp%\GetRandomText.vbs
>%G% echo R="%Zeichen%":L=Len(R):For i=1 To WScript.Arguments(0):Randomize:T=T^&Mid(Z,Int(Rnd*L+1),1):Next:WScript.Echo T  


for /f %%i in ('cscript //nologo %G% 32') do set "RandomText=%%i"  

echo %RandomText%

echo Benutzer=%username% >> C:\Ordner\ZLog.txt

echo Computer=%computername% >> C:\Ordner\ZLog.txt

echo Wlan Name=%SSID% >> C:\Ordner\ZLog.txt

echo Wlan Passwort=%Schlüsselinhalt% >> C:\Ordner\ZLog.txt

echo Zufall=%ZText% >> C:\Ordner\ZLog.txt

echo Datum=%date% >> C:\Ordner\ZLog.txt

echo Zeit=%time% >> C:\Ordner\ZLog.txt

echo Zufall=%ZText% >> C:\Ordner\OnlyRandomLogs.txt

echo - - - - - - - - - - - - - - - >> C:\Ordner\ZLog.txt

echo - - - - - - - - - - - - - - - >> C:\Ordner\OnlyRandomLogs.txt

goto loop

exit



Danke im Vorraus,
DevSodoku
screenshot (5)

Content-Key: 387245

Url: https://administrator.de/contentid/387245

Printed on: April 27, 2024 at 10:04 o'clock

Member: em-pie
em-pie Sep 21, 2018 at 20:24:13 (UTC)
Goto Top
Moin,

Du wirst „irgendwo“ eine leere Variable haben, sodass du dann dein
Echo %variable% ein Echo ist.

Baue in die ganzen Echos mal statischen Text ein, zB.
Echo 223 %variable1%
Echo 4711 %variable2%


Dann weißt du, an welcher Stelle er hängt.

Gruß
em-pie
Member: DevSodoku
DevSodoku Sep 22, 2018 at 06:08:45 (UTC)
Goto Top
Danke für deine schnelle Antwort ich denke auch das die Variable aus irgendeinem grund nicht gefüllt ist hab es gerade probiert und das kamm dabei raus:
Die SSID
21

Leider hat mir das aber jetzt nicht weiter geholfen ich versuche es jetzt noch mal in dem ich in die Variable einen von mir geschriebenen Text setzte.

Nochmals Danke,
DevSodoku
Mitglied: 137289
Solution 137289 Sep 22, 2018 updated at 09:04:16 (UTC)
Goto Top
Hi,
da fehlen ein paar Escapes, probier das:
@echo off &setlocal
for /f "tokens=2 delims=:" %%a in ('netsh wlan show interfaces ^| findstr /rc:"Profil *:"') do for /f "tokens=1*" %%b in ("%%a") do set "PROFIL=%%b"  
for /f tokens^=2^ delims^=^" %%a in ('netsh wlan show profile "%PROFIL%" key^=clear ^| findstr /lic:"SSID-Name"') do set "SSID=%%a"  
for /f "tokens=2 delims=:" %%a in ('netsh wlan show profile "%PROFIL%" key^=clear ^| findstr /i inhalt') do for /f "tokens=*" %%b in ("%%a") do set "PASSWORD=%%b"  
echo Aktuelles WLAN Profil: %PROFIL%
echo SSID: %SSID%
echo KEY: %PASSWORD%

Gruß speedlink
Member: DevSodoku
DevSodoku Sep 22, 2018 at 15:09:09 (UTC)
Goto Top
Ich danke dir speedlink für deine schnelle Antwort und du hast mein Problem damit gelöst.
Könntest du mir erklären wie die Escapes funktionieren und wie ich sie richtig benutze bin nicht wirklich gut in der Programmierung von Batches.

Und nochmal Danke,
DevSodoku
Mitglied: 137289
137289 Sep 22, 2018 at 16:01:32 (UTC)
Goto Top