Page 1 of 2 12>
Topic Options
#134716 - 2005-02-28 05:52 PM runas_b1
pvds Offline
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
#134717 - 2005-02-28 06:09 PM Re: runas_b1
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
oh my ... Peter ... you said the "secure" word ... you gunna regret that buddy. get your flame-retardant suit on my friend ...
Top
#134718 - 2005-02-28 06:56 PM Re: runas_b1
pvds Offline
Hey THIS is FUN
*****

Registered: 2001-04-14
Posts: 201
Shawn

I was afraid for this kind of reactions.
Is it possible to reverse engineer a tokenized script?

Because it was some time ago I made any kix script I decided to make something to push up my scripting skills found out I am still scripting the trial and error way but it is working.

Regards Peter

Top
#134719 - 2005-02-28 07:13 PM Re: runas_b1
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Don't get me wrong - personally myself - I'm cool with it. I would probably trust the tokenizing to obfuscate my script - hell of a site better than plain-text thats for sure -

Have tokenized scripts been reversed engineered ?

Not that I know of.

Can tokenized scripts be reversed engineered ?

Ruud said they "could" be.

Will tokenized scripts ever be reversed engineered ?

My guess, probably not - but who knows.


Top
#134720 - 2005-02-28 07:29 PM Re: runas_b1
pvds Offline
Hey THIS is FUN
*****

Registered: 2001-04-14
Posts: 201
Shawn

So you are saying that when there is a Ruud in my organisation it is not secure but for now it is at least a bit secure.
And how secure are commercial programs like TQcRunas? (and they cost money)

BTW the tokenizing part is working excellent and that is where it was all about.

Kind Regards,

Peter

Top
#134721 - 2005-02-28 07:34 PM Re: runas_b1
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
rofl, ja - don't hire anyone named "Ruud" ...

Seriously, i think you said it perfect - for now, its at least a bit secure (ish) (I said (ish) so I dont get flamed too). TCqRunas idk.

Top
#134722 - 2005-02-28 07:54 PM Re: runas_b1
pvds Offline
Hey THIS is FUN
*****

Registered: 2001-04-14
Posts: 201
Shawn,

I am ver dutch please what means ISH and IDK??

Thanks Peter

Top
#134723 - 2005-02-28 07:57 PM Re: runas_b1
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
"ish" means "almost" or "like" ... so tokenizing is "almost" like being secure

IDK is slang for "I don't know"


Top
#134724 - 2005-02-28 08:03 PM Re: runas_b1
Bryce Offline
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
#134725 - 2005-02-28 08:08 PM Re: runas_b1
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Bryce said it good - i am feeling mildly sheepish right now, ja.
Top
#134726 - 2005-02-28 08:27 PM Re: runas_b1
pvds Offline
Hey THIS is FUN
*****

Registered: 2001-04-14
Posts: 201
Shawn

The IDK thing I figured out my self

I hoped for some sugestions to make the script better I fully understand that secure is not the word better hide the password!!

for now we say hide and seek when we mean tokenized.

Kind regards

Peter

Top
#134727 - 2005-03-01 05:19 AM Re: runas_b1
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
There are better ways to run scripts under different user accounts than any of the RunAs approaches. Also, tokenization should not be relied upon to protect passwords. Without knowing your specific needs it's hard to make recommendations but both e.g. the RemoteExec() or the Task Scheduler might fit your bill.
_________________________
There are two types of vessels, submarines and targets.

Top
#134728 - 2005-03-01 12:58 PM Re: runas_b1
pvds Offline
Hey THIS is FUN
*****

Registered: 2001-04-14
Posts: 201
Jens,

Sometimes we need to start a program with elevated permissions.

Now I use for this occasions TQcRunAs but a totally kix solution is a nice to have.

Kind regards

Peter

Top
#134729 - 2005-03-02 02:23 PM Re: runas_b1
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
I understand the issues around using RunAs within scripts but I must say that it all depends on the users envirouments.

If you feel your data is not that important then use the RunAs, allways knowing that it could be hacked at some point in time.

I do use RunAs when applications are needed to run as Admin, but I tell my managers and everyone knows that this is not a fail safe action. I do as much as possible to keep it secure by changing script to EXE and then rapping it up within KiXcrypt. But I allways know that it could be hacked.

Thanks


Top
#134730 - 2005-03-02 03:29 PM Re: runas_b1
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Be very very careful about obfuscating commands this way.

You are constructing a command and passing the arguments on the command line. These are extremely easy to view. For instance, if you browse the "win32_process" WMI object you will see the options supplied on the command line, including the username and password.

A safer option is to place the values in the local environment before you call the RUNAS command.

Top
#134731 - 2005-03-02 05:07 PM Re: runas_b1
pvds Offline
Hey THIS is FUN
*****

Registered: 2001-04-14
Posts: 201
Richard

Please help put options in the local enviroment an example would be nice maby i can build it in b2 I have created an form for the options.

Peter

Top
#134732 - 2005-03-02 08:30 PM Re: runas_b1
pvds Offline
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
#134733 - 2005-03-03 09:52 AM Re: runas_b1
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Peter,

In your case it is not such a problem, as the user is typing the password in anyway. However you need to be aware that the command line values are visible to anyone with remote access via WMI to you process table.

In general you should avoid passwords as command line parameters unless you can ensure that they will not appear in the process table.

This is more of a problem when you have a password embedded in the script, and you are trying to hide it from an end-user.

I've looked at the utility you use, and it does not support the passing of values in environment variables - perhaps you could contact the authors and suggest adding it. It is a trivial coding exercise, and would enhance their product.

Top
#134734 - 2005-03-03 10:20 AM Re: runas_b1
pvds Offline
Hey THIS is FUN
*****

Registered: 2001-04-14
Posts: 201
Richard,

Thank you for the explanation.

Top
#134735 - 2005-03-03 07:08 PM Re: runas_b1
baron164 Offline
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
Page 1 of 2 12>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.118 seconds in which 0.078 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org