Page 1 of 1 1
Topic Options
#193624 - 2009-04-29 05:34 AM Problem with Alt Characters
Pr0ph3t Offline
Just in Town

Registered: 2007-01-05
Posts: 4
I am writing a script using Kix 4.60 to remotely gather incident response data for forensic analysis. When the user runs the script, they are prompted for local admin credentials on the target machine. The admin accounts in my environment are required to include alt characters in the password. It appears as though Kix is incorrectly interpreting the alt characters. For example, in the sample code below, if I enter a password of "abc123ê" where ê = <alt>136, Kix will show the value of $Pwd as "abc123^". Consequently, authentication fails due to invalid password. Anyone know how to accurately capture and pass alt characters? Is there a better way to do this via WMI?

Any assistance is greatly appreciated.

 Code:
BREAK ON
CLS

DIM $Targ, $WSN, $UID, $Pwd

; Get IP Address of Target
$Targ = "192.168.1.1"  ; In the real script I prompt for this and $WSN

; Get Workstation Name
$WSN = "XPLaptop"

; Get Credentials
?? "Enter the UserID of the Admin account" + @CRLF + "you wish to use for this operation: " Gets $UID
?? "Enter the Admin account password: " Gets $Pwd

?? "User ID: " + $UID ;$UID and $Pwd are only displayed for trouble shooting
?? "Password: " + $Pwd

; Get network info - This is an example of the type of command that I want to execute.  Psexec.exe is a tool 
; that allows me to run the command remotely.
;SHELL '%WINDIR%\SYSTEM32\cmd /C D:\IR\psexec.exe \\' + $Targ + ' -u ' + $WSN + '\' + $UID + ' -p ' + $Pwd + ' ipconfig /all'

EXIT
_________________________
"There is no spoon..."

Top
#193626 - 2009-04-29 11:23 AM Re: Problem with Alt Characters [Re: Pr0ph3t]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
It's in the variable OK, it just isn't displaying very well.

Try setting ASCII on. See the following test script:
 Code:
Break ON
$=SetOption("ASCII","ON")

Function DecodePass($PASS)
	Dim $i
	For $i=1 To Len($PASS)
		"	'"+SubStr($Pass,$i,1)+"' = "+Asc(SubStr($PASS,$i))+@CRLF
	Next
EndFunction

Dim $Pass

"Enter Password: " GetS $PASS
While $PASS
	"Password is:"+@CRLF
	DecodePass($PASS)
	@CRLF+"Enter Password: " GetS $PASS
Loop

Top
#193630 - 2009-04-29 04:07 PM Re: Problem with Alt Characters [Re: Richard H.]
Pr0ph3t Offline
Just in Town

Registered: 2007-01-05
Posts: 4
Richard H. - Thanks for the information; setting ASCII-ON fixed the problem with storing Alt characters. However, now I appear to be having an issue with shell.

When I open a command prompt and manually run the following command it runs fine:
 Code:
D:\IR\psexec.exe \\192.168.1.1 -u XPLaptop\Admin -p abc123ê ipconfig /all'

But if I try to run the same command in a script using shell, then it fails authentication:
 Code:
BREAK ON
CLS
$=SetOption("ASCII","ON")
DIM $Targ, $UID, $Pwd

$Targ = "192.168.1.1"
$UID = "XPLaptop\Admin" 
$Pwd = "abc123ê"

SHELL '%WINDIR%\SYSTEM32\cmd /C D:\IR\psexec.exe \\' + $Targ + ' -u ' + $UID + ' -p ' + $Pwd + ' ipconfig /all'

EXIT

Any ideas? Am I doing something wrong in my Shell syntax?

Thanks again for the help.
_________________________
"There is no spoon..."

Top
#193631 - 2009-04-29 04:18 PM Re: Problem with Alt Characters [Re: Pr0ph3t]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Adding

? @serror

after your shell line may give you some direction.
_________________________
(... better days ahead)

Top
#193634 - 2009-04-29 05:09 PM Re: Problem with Alt Characters [Re: Allen]
Pr0ph3t Offline
Just in Town

Registered: 2007-01-05
Posts: 4
Thanks for the response.

The error that I am getting is:
"Login Failure: unknown user name or bad password"

I have verified that the user name and password that I am passing in the script are identical to those that I am using when I run the command manually.
_________________________
"There is no spoon..."

Top
#193639 - 2009-04-30 09:02 AM Re: Problem with Alt Characters [Re: Pr0ph3t]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Print the password to the screen, it may not be passing what you think.

$Pwd = "abc123ê"
$Pwd ?


Or try using the CHR() code to send the special character

$Pwd = "abc123"+CHR(321) ; you need to check this value I just typed something in
_________________________
Today is the tomorrow you worried about yesterday.

Top
#193640 - 2009-04-30 09:32 AM Re: Problem with Alt Characters [Re: Gargoyle]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Try the command in the simplest form you can, for example:
 Code:
BREAK ON
$=SetOption("ASCII","ON")

SHELL 'D:\IR\psexec.exe \\192.168.1.1 -u XPLaptop\Admin -p abc123'+Chr(136)+' ipconfig /all'

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, 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.07 seconds in which 0.038 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