Hi,
I have made a script to use kixtart2010 it creates a tokenized script for runas from anb software.
Because the password is pretokenized if sould be secure.
any sugestion to make it better is welkom.
Code:
;Script to make runas from anb software secure using KiX2010_450b1a.
;The script creates a new script with the runas settings and pretokenize it.
;Settings can be saved in inifile.
;runas102.exe http://www.anbsoftware.co.uk/netadmin/runas/
;KiX2010_450b1a http://www.adminscripteditor.com/downloads.asp
Break on
$program = ""
$profile = ""
$env = ""
$netonly = ""
$s = ""
$w = ""
CLS
? "Command line For EXE: " Gets $program
$prog = Split($program,"\")
$n = -1
For Each $part in $prog
$n = $n + 1
Next
$Name = Split($prog[$n],".")
$IniFileName = @SCRIPTDIR + "\" + $Name[0] + ".ini"
$FileSize = GetFileSize ($program)
$FileTime = GetFileTime ($program)
$Fileversion = GetFileVersion ($program,)
If Exist($IniFileName)
$profile = ReadProfileString($IniFileName,"programsettings","profile")
$env = ReadProfileString($IniFileName,"programsettings","env")
$netonly = ReadProfileString($IniFileName,"programsettings","netonly")
$s = ReadProfileString($IniFileName,"programsettings","s")
$w = ReadProfileString($IniFileName,"programsettings","w")
$user = ReadProfileString($IniFileName,"usersettings","User")
$pass= ReadProfileString($IniFileName,"usersettings","pass")
$IFileSize = ReadProfileString($IniFileName,"filesettings","filesize")
$IFileTime = ReadProfileString($IniFileName,"filesettings","filetime")
$IFileVersion = ReadProfileString($IniFileName,"filesettings","fileversion")
EndIf
If Not $user = ""
CLS
? "<UserName> should be in form of USER@@DOMAIN Or DOMAIN\USER = " $user " Change User = Y/N : " Gets $Key
If $key = Y
CLS
? "<UserName> should be in form of USER@@DOMAIN Or DOMAIN\USER : " Gets $user
EndIf
Else
CLS
? "<UserName> should be in form of USER@@DOMAIN Or DOMAIN\USER : " Gets $user
EndIf
If Not $pass = ""
CLS
? "<Password> should be the Password of the user = " $pass " Change password Y/N : " Gets $key
If $key = Y
CLS
? "<Password> should be the Password of the user : " Gets $pass
EndIf
Else
CLS
? "<Password> should be the Password of the user : " Gets $pass
EndIf
If Not $profile = ""
CLS
? "If the user's profile needs to be loaded.Default = " $profile " Change = Y/N :" Gets $key
If $key = Y
If $profile = Y
$profile = N
Else
$profile = Y
EndIf
EndIf
Else
Do
CLS
? "If the user's profile needs to be loaded.Default Y/N : " Gets $profile
Until $profile = Y Or $profile = N
EndIf
If Not $env = ""
CLS
? "To use current environment instead of user's = " $env " Change = Y/N :" Gets $key
If $key = Y
If $env = Y
$env = N
Else
$env = Y
EndIf
EndIf
Else
Do
CLS
? "To use current environment instead of user's Y/N : " Gets $env
Until $env = Y Or $env = N
EndIf
If Not $netonly = ""
CLS
? "Use if the credentials specified are for remote access only = " $netonly " Change = Y/N :" Gets $key
If $key = Y
If $netonly = Y
$netonly = N
Else
$netonly = Y
EndIf
EndIf
Else
Do
CLS
? "Use if the credentials specified are for remote access only Y/N : " Gets $netonly
Until $netonly = Y Or $netonly = N
EndIf
If Not $s = ""
CLS
? "Run this program silently with no prompts or displays = " $s " Change = Y/N :" Gets $key
If $key = Y
If $s = Y
$s = N
Else
$s = Y
EndIf
EndIf
Else
Do
CLS
? "Run this program silently with no prompts or displays Y/N : " Gets $s
Until $s = Y Or $s = N
EndIf
If Not $w = ""
CLS
? "Wait for program to finish = " $w " Change = Y/N :" Gets $key
If $key = Y
If $w = Y
$w = N
Else
$w = Y
EndIf
EndIf
Else
Do
CLS
? "Wait for program to finish Y/N : " Gets $w
Until $w = Y Or $w = N
EndIf
$settings = ""
$runas = ""
$options = ""
If $profile = Y
$options = $options + " /profile"
EndIf
If $env = Y
$options = $options + " /env"
EndIf
If $netonly = Y
$options = $options + " /netonly"
EndIf
If $s = Y
$options = $options + " /s"
EndIf
If $w = Y
$options = $options + " /w"
EndIf
$settings = "run '%%comspec%% /c'" + " + '" + '"' + @SCRIPTDIR + "\runas102.exe" + '"' + "'" + " + " + "'" + $options + " /user:" + $user + " /pass:" + $pass + "' " + "+" + ' " ' + $program + '"'
$x = Open(1,@SCRIPTDIR + "\" + $Name[0]+ ".kix",5)
$x = WriteLine (1,"$$program = " + '"' + "$program" + '"' + @CRLF)
$x = WriteLine (1,"$$FileSize = GetFileSize ($$program)" + @CRLF)
$x = WriteLine (1,"$$FileTime = GetFileTime ($$program)" + @CRLF)
$x = WriteLine (1,"$$Fileversion = GetFileVersion ($$program,)" + @CRLF)
$x = WriteLine (1,"$$IFileSize = " + '"' + "$IFileSize" + '"' + @CRLF)
$x = WriteLine (1,"$$IFileTime = " + '"' + "$IFileTime" + '"' + @CRLF)
$x = WriteLine (1,"$$IFileVersion = " + '"' + "$IFileVersion" + '"' + @CRLF)
$x = WriteLine (1,"$$fc = " + '""' + @CRLF)
$x = WriteLine (1,"If $$FileSize = $$IFileSize" + @CRLF + "$$fc = 0" + @CRLF + "Else" + @CRLF + "$$fc = 1" + @CRLF + "Endif"+ @CRLF )
$x = WriteLine (1,"If $$FileTime = $$IFileTime And $$fc = 0" + @CRLF + "$$fc = 0" + @CRLF + "Else" + @CRLF + "$$fc = 1" + @CRLF + "Endif" + @CRLF)
$x = WriteLine (1,"If $$FileVersion = $$IFileVersion And $$fc = 0" + @CRLF + "$$fc = 0" + @CRLF + "Else" + @CRLF + "$$fc = 1" + @CRLF + "Endif" + @CRLF)
$x = WriteLine (1,"If $$fc = 1" + @CRLF + "$$x = MessageBox(" + '"' + "The fileSize Time Version is not the same" + '"' + "," + '"' + "File" + '"' + ", 16)" + @CRLF + "Exit" + @CRLF + "endif" + @CRLF)
$x = WriteLine (1,$settings)
$x = Close(1)
Shell @SCRIPTDIR + "\wkix32.exe " + @SCRIPTDIR + "\" + $Name[0]+ ".kix /t"
Del @SCRIPTDIR + "\" + $Name[0]+ ".kix"
CLS
? ":Save settings Y/N : " Gets $sv
If $sv = y
$x = WriteProfileString($IniFileName,"programsettings","profile",$profile)
$x = WriteProfileString($IniFileName,"programsettings","env",$env)
$x = WriteProfileString($IniFileName,"programsettings","netonly",$netonly)
$x = WriteProfileString($IniFileName,"programsettings","s",$s)
$x = WriteProfileString($IniFileName,"programsettings","w",$w)
$x = WriteProfileString($IniFileName,"usersettings","User",$user)
$x = WriteProfileString($IniFileName,"usersettings","pass",$pass)
$x = WriteProfileString($IniFileName,"programsettings","program",$program)
$x = WriteProfileString($IniFileName,"filesettings","filesize",$FileSize)
$x = WriteProfileString($IniFileName,"filesettings","filetime",$filetime)
$x = WriteProfileString($IniFileName,"filesettings","fileversion",$fileversion)
EndIf