#134716 - 2005-02-28 05:52 PM
runas_b1
|
pvds
Hey THIS is FUN
   
Registered: 2001-04-14
Posts: 201
|
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
|
|
Top
|
|
|
|
#134722 - 2005-02-28 07:54 PM
Re: runas_b1
|
pvds
Hey THIS is FUN
   
Registered: 2001-04-14
Posts: 201
|
Shawn,
I am ver dutch please what means ISH and IDK?? 
Thanks Peter
|
|
Top
|
|
|
|
#134724 - 2005-02-28 08:03 PM
Re: runas_b1
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
Quote:
Shawn,
I am ver dutch please what means ISH and IDK??
Thanks Peter
Shawn’s use of the term "ish" is a play on words.
In this context by adding the letters "ish" to "secure" you get securish, meaning kind of secure, but not very secure.
A good valid use of this term is the word Sheepish
IDK = I Don't Know
Edited by Bryce (2005-02-28 08:05 PM)
|
|
Top
|
|
|
|
#134732 - 2005-03-02 08:30 PM
Re: runas_b1
|
pvds
Hey THIS is FUN
   
Registered: 2001-04-14
Posts: 201
|
Hi,
I put the settings in a kixform and I think I am going to use it to give some programs local admin-rights in our organization still I would have al your suggestions and critics on how to make it as safe as possible.
Code:
Break On
$System = CreateObject("Kixtart.System")
$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.FontSize = 8,25
$Form.Height = 349
$Form.Left = 546
$Form.Text = "RunAs Tokenized scriptcreator"
$Form.Top = 245
$Form.Width = 393
$Button1 = $Form.Controls.ToolButton()
$Button1.FontBold = "True"
$Button1.FontSize = 8,25
$Button1.Height = 21
$Button1.Icon = 1
$Button1.Left = 345
$Button1.ToolTipText = "Find file"
$Button1.Top = 75
$Button1.Width = 23
$Button2 = $Form.Controls.Button()
$Button2.FontBold = "True"
$Button2.FontSize = 11
$Button2.Height = 23
$Button2.Left = 200
$Button2.Text = "Create KX"
$Button2.ToolTipText = "Create tokenized kix file .KX"
$Button2.Top = 285
$Button2.Width = 100
$CheckBox1 = $Form.Controls.CheckBox()
$CheckBox1.BackColor = 212,208,200
$CheckBox1.CheckAlign = 16
$CheckBox1.Checked = "True"
$CheckBox1.CheckState = 1
$CheckBox1.FontSize = 8,25
$CheckBox1.Height = 24
$CheckBox1.Left = 135
$CheckBox1.Text = ""
$CheckBox1.ToolTipText = "If the user's profile needs to be loaded.Default"
$CheckBox1.Top = 165
$CheckBox1.Width = 14
$CheckBox2 = $Form.Controls.CheckBox()
$CheckBox2.BackColor = 212,208,200
$CheckBox2.CheckAlign = 16
$CheckBox2.FontSize = 8,25
$CheckBox2.Height = 24
$CheckBox2.Left = 135
$CheckBox2.Text = ""
$CheckBox2.ToolTipText = "To use current environment instead of user's"
$CheckBox2.Top = 195
$CheckBox2.Width = 14
$CheckBox3 = $Form.Controls.CheckBox()
$CheckBox3.BackColor = 212,208,200
$CheckBox3.CheckAlign = 16
$CheckBox3.FontSize = 8,25
$CheckBox3.Height = 24
$CheckBox3.Left = 135
$CheckBox3.Text = ""
$CheckBox3.ToolTipText = "Use if the credentials specified are for remote access only"
$CheckBox3.Top = 225
$CheckBox3.Width = 14
$CheckBox4 = $Form.Controls.CheckBox()
$CheckBox4.BackColor = 212,208,200
$CheckBox4.CheckAlign = 16
$CheckBox4.Checked = "True"
$CheckBox4.CheckState = 1
$CheckBox4.FontSize = 8,25
$CheckBox4.Height = 24
$CheckBox4.Left = 135
$CheckBox4.Text = ""
$CheckBox4.ToolTipText = "Run this program silently with no prompts or displays need password."
$CheckBox4.Top = 255
$CheckBox4.Width = 14
$CheckBox5 = $Form.Controls.CheckBox()
$CheckBox5.BackColor = 212,208,200
$CheckBox5.CheckAlign = 16
$CheckBox5.FontSize = 8,25
$CheckBox5.Height = 24
$CheckBox5.Left = 135
$CheckBox5.Text = ""
$CheckBox5.ToolTipText = "Wait for program to finish"
$CheckBox5.Top = 285
$CheckBox5.Width = 14
$Label1 = $Form.Controls.Label()
$Label1.BackColor = 212,208,200
$Label1.FontBold = "True"
$Label1.FontSize = 11
$Label1.Height = 23
$Label1.Left = 15
$Label1.Text = "File to run :"
$Label1.ToolTipText = "Program command line for EXE"
$Label1.Top = 75
$Label1.Width = 100
$Label2 = $Form.Controls.Label()
$Label2.BackColor = 212,208,200
$Label2.FontBold = "True"
$Label2.FontSize = 11
$Label2.Height = 23
$Label2.Left = 15
$Label2.Text = "User name :"
$Label2.ToolTipText = " should be in form of USER@@DOMAIN Or DOMAIN\USER"
$Label2.Top = 105
$Label2.Width = 100
$Label3 = $Form.Controls.Label()
$Label3.BackColor = 212,208,200
$Label3.FontBold = "True"
$Label3.FontSize = 11
$Label3.Height = 23
$Label3.Left = 15
$Label3.Text = "Password :"
$Label3.ToolTipText = " should be the Password of the user"
$Label3.Top = 135
$Label3.Width = 100
$Label4 = $Form.Controls.Label()
$Label4.BackColor = 212,208,200
$Label4.FontBold = "True"
$Label4.FontSize = 11
$Label4.Height = 23
$Label4.Left = 15
$Label4.Text = "Profile :"
$Label4.ToolTipText = "If the user's profile needs to be loaded.Default"
$Label4.Top = 165
$Label4.Width = 100
$Label5 = $Form.Controls.Label()
$Label5.BackColor = 212,208,200
$Label5.FontBold = "True"
$Label5.FontSize = 11
$Label5.Height = 23
$Label5.Left = 15
$Label5.Text = "Enviroment :"
$Label5.ToolTipText = "To use current environment instead of user's"
$Label5.Top = 195
$Label5.Width = 100
$Label6 = $Form.Controls.Label()
$Label6.BackColor = 212,208,200
$Label6.FontBold = "True"
$Label6.FontSize = 11
$Label6.Height = 23
$Label6.Left = 15
$Label6.Text = "Net Only :"
$Label6.ToolTipText = "Use if the credentials specified are for remote access only"
$Label6.Top = 225
$Label6.Width = 100
$Label7 = $Form.Controls.Label()
$Label7.BackColor = 212,208,200
$Label7.FontBold = "True"
$Label7.FontSize = 11
$Label7.Height = 23
$Label7.Left = 15
$Label7.Text = "Run silent :"
$Label7.ToolTipText = "Run this program silently with no prompts or displays need password."
$Label7.Top = 255
$Label7.Width = 100
$Label8 = $Form.Controls.Label()
$Label8.BackColor = 212,208,200
$Label8.FontBold = "True"
$Label8.FontSize = 11
$Label8.Height = 23
$Label8.Left = 15
$Label8.Text = "Wait :"
$Label8.ToolTipText = "Wait for program to finish"
$Label8.Top = 285
$Label8.Width = 100
$Label9 = $Form.Controls.Label()
$Label9.BackColor = 212,208,200
$Label9.FontSize = 18
$Label9.Height = 42
$Label9.Left = 15
$Label9.Text = "RunAs Tokenized scriptcreator"
$Label9.Top = 15
$Label9.Width = 352
$Label10 = $Form.Controls.Label()
$Label10.BackColor = 212,208,200
$Label10.FontSize = 11
$Label10.Height = 65
$Label10.Left = 165
$Label10.Text = "Tokenized scripts are not SAFE! The file to run is recognized by file name file size file version and file time."
$Label10.Top = 165
$Label10.Width = 208
$Label11 = $Form.Controls.HyperLink()
$Label11.BackColor = 212,208,200
$Label11.FontSize = 8,25
$Label11.Height = 20
$Label11.Left = 165
$Label11.Text = "You need KiX2010_450b1a."
$Label11.Top = 239
$Label11.Value = "http://www.adminscripteditor.com/downloads.asp"
$Label11.Width = 208
$Label12 = $Form.Controls.Hyperlink()
$Label12.BackColor = 212,208,200
$Label12.FontSize = 8,25
$Label12.Height = 20
$Label12.Left = 165
$Label12.Text = "And runas102.exe."
$Label12.Top = 259
$Label12.Value = "http://www.anbsoftware.co.uk/netadmin/runas/"
$Label12.Width = 208
$TextBox1 = $Form.Controls.TextBox()
$TextBox1.AcceptsReturn = "True"
$TextBox1.AcceptsTab = "True"
$TextBox1.FontSize = 11
$TextBox1.Height = 20
$TextBox1.Left = 135
$TextBox1.Text = ""
$TextBox1.ToolTipText = "Program command line for EXE"
$TextBox1.Top = 75
$TextBox1.Width = 208
$TextBox1.OnTextChanged = "Button1_Click()"
$TextBox2 = $Form.Controls.TextBox()
$TextBox2.FontSize = 11
$TextBox2.Height = 20
$TextBox2.Left = 135
$TextBox2.Text = $user
$TextBox2.ToolTipText = " should be in form of USER@@DOMAIN Or DOMAIN\USER"
$TextBox2.Top = 105
$TextBox2.Width = 208
$TextBox3 = $Form.Controls.TextBox()
$TextBox3.FontSize = 11
$TextBox3.Height = 20
$TextBox3.Left = 135
$TextBox3.PasswordChar = "*"
$TextBox3.Text = $pass
$TextBox3.ToolTipText = " should be the Password of the user"
$TextBox3.Top = 135
$TextBox3.Width = 208
$Button1.OnClick = "Button1_Click()"
$Button2.OnClick = "Button2_Click()"
$OpenFileDialog1 = $System.OpenFileDialog()
$OpenFileDialog1.InitialDirectory = "c:\"
$OpenFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
$OpenFileDialog1.FilterIndex = 2
$OpenFileDialog1.RestoreDirectory = True
$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1
Function Button1_Click()
If Exist($TextBox1.Text) = 1
$program = $TextBox1.Text
Else
If $OpenFileDialog1.ShowDialog() = $System.DialogResult.OK
$TextBox1.Text = $OpenFileDialog1.Filename
$program = $OpenFileDialog1.Filename
EndIf
EndIf
$prog = Split($program,"\")
$n = -1
For Each $part in $prog
$n = $n + 1
Next
$Name = Split($prog[$n],".")
$IniFileName = @SCRIPTDIR + "\" + $Name[0] + ".ini"
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")
$CheckBox1.Checked = $profile
$CheckBox2.Checked = $env
$CheckBox3.Checked = $netonly
$CheckBox4.Checked = $s
$CheckBox5.Checked = $w
$TextBox2.Text = $user
$TextBox3.Text = $pass
EndIf
EndFunction
Function Button2_Click()
$profile = $CheckBox1.Checked
$env = $CheckBox2.Checked
$netonly = $CheckBox3.Checked
$s = $CheckBox4.Checked
$w = $CheckBox5.Checked
$user = $TextBox2.Text
$pass = $TextBox3.Text
$FileSize = GetFileSize ($program)
$FileTime = GetFileTime ($program)
$Fileversion = GetFileVersion ($program,)
If $Fileversion = ""
$Fileversion = "1.00.01"
EndIf
$IFileSize = $FileSize
$IFileTime = $FileTime
$IFileversion = $Fileversion
$settings = ""
$runas = ""
$options = ""
If $profile = -1
$options = $options + " /profile"
EndIf
If $env = -1
$options = $options + " /env"
EndIf
If $netonly = -1
$options = $options + " /netonly"
EndIf
If $s = -1
$options = $options + " /s"
EndIf
If $w = -1
$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,"If $$Fileversion = " + '""' + @CRLF + "$$Fileversion = 1.00.01" + @CRLF + "Endif" + @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 or FileTime or FileVersion 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"
$sv = MessageBox("Save settings to ini file? password not secured", "Save Settings", 324)
If $sv = 6
$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
Del @SCRIPTDIR + "\" + $Name[0]+ ".kix"
$Form.hide
EndFunction
Peter
|
|
Top
|
|
|
|
#134735 - 2005-03-03 07:08 PM
Re: runas_b1
|
baron164
Fresh Scripter
Registered: 2003-07-22
Posts: 12
|
Is there anyway of having the password put in automatically? for example runas /user:tag\administrator /pass:password "\\server\test.exe"
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1334 anonymous users online.
|
|
|