Page 1 of 1 1
Topic Options
#76341 - 2003-08-13 01:34 AM SIDTONAME for remote system - Possible?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I want to try to use SIDTONAME against a remote computer to create a group of select statements that will allow me to try a few different passwords for the Local Administrators account that we have on different systems.

I'm not sure this can be done this method or not and I'm looking to see if anyone can confirm whether or not it can be done via this method.

In cases where the Administrator account has been renamed I'd like to use SIDTONAME to check it. This is an Administrator script, not a logon script.

code:
break on

$wksta = 'computer1'
? 'Now attaching to: '+'\\'+$wksta
SELECT
CASE LocalAdmin('\\'+$wksta)
? 'You have admin rights on '+$wksta
CASE NOT LocalAdmin('\\'+$wksta)
USE V: '\\'+$wksta+'\C$' /user:$wksta+'\Administrator' /password:'password'
; The above line works but I want to use the line below in case the account
; has been renamed.
$x = $wksta+'\'+sidtoname('S-1-5-32-500')
USE V: '\\'+$wksta+'\C$' /user:$x /password:'password'
? 'Error mapping was: '+@ERROR+' - '+@SERROR
IF @ERROR = 0
? 'You successfully mapped the C$ share as an admin - run code'
ELSE
? 'You were unable to map the C$ share as an admin - can not run code'
ENDIF
CASE 1
? 'Unable to map as an Administrator'
ENDSELECT

function LocalAdmin($wksta)
$LocalAdmin=ingroup('$wksta\'+sidtoname('S-1-5-32-544'))-1+@inwin
endfunction


Top
#76342 - 2003-08-13 01:47 AM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Can't do that DOC.

Each OS has its own SID my Administrator account can be found by sidtoname('S-1-5-21-823518204-854245398-839522115-500').

I can help with either my Win32Admin.DLL (needs augmented) or a standalone program if you want.

SidToName can not function remotely. If I use a SID from another server, I receive:
quote:
Error: 1332 No mapping between account names and security IDs was done.


[ 13. August 2003, 02:01: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76343 - 2003-08-13 02:20 AM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
oops!

Win32Admin.DLL can do this now.

http://mywebpages.comcast.net/habullock/Win32Admin.htm#Security

LocalAdminGrp(optional $Server)
Returns the name of the local BUILTIN\Administrators group on $Server.

This method is valuable when trying to locate a renamed or language localized group name. When $Server is NULL, the local computer is used. This method is valuable when trying to locate an account that has been renamed or is not 'Administrators' because of OS language localization.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76344 - 2003-08-13 02:23 AM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA

$Win32Admin = createobject("Win32Admin")
if vartypename($Win32Admin) <> "Object"
? "@serror"
endif

$Version = $Win32Admin.Version
if @error <> 0
? "@serror"
endif
? "DLL Version = " + $Version

$AdminGrp = $Win32Admin.GetLocalAdminGrp("ComputerName")
if $AdminGrp = ""
? "@serror"
endif
? "AdminGrp =" + $AdminGrp


[ 13. August 2003, 03:03: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76345 - 2003-08-13 03:02 AM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Argh! Mental confusion abounds here...


$Win32Admin = createobject("Win32Admin")
if vartypename($Win32Admin) <> "Object"
? "@serror"
endif

$Version = $Win32Admin.Version
if @error <> 0
? "@serror"
endif
? "DLL Version = " + $Version

; Method GetAdminAccount()
; Returns the name of the local BUILTIN\Administrator account.
; This method is valuable when trying to locate an account that
; has been renamed or is not 'Administrator' because of OS
; language localization.
$Account = $Win32Admin.GetAdminAccount("ComputerName");
if $Account = ""
? "@serror"
endif
? "BUILTIN\" + $Account

$Win32Admin = 0


[ 13. August 2003, 03:03: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76346 - 2003-08-13 02:14 PM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Clarification for those that have an interest in the details of the SidToName() implementation.

SidToName() does resolve remote sids to names but only those that visible via a trust relation. In other words, you can resolve accounts and groups sids of your domain or a trusted domain but not those of a member server, workstation, or untrusted domain.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76347 - 2003-08-13 08:10 PM Re: SIDTONAME for remote system - Possible?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Howard,

This code works fine if my account is in the local administrators group on the remote system, but it does not work if my membership is only through a Universal group.

code:
break on
$wksta = 'workstation1'
RemoteAdmin($wksta)

function RemoteAdmin($wksta)
$Win32Admin = createobject("Win32Admin")
$AdminGrp = $Win32Admin.GetLocalAdminGrp($wksta)
$AdminAccount = $Win32Admin.GetAdminAccount($wksta)
? 'AdminGroup is: '+$AdminGrp
? 'Admin Account is: '+$AdminAccount
? '\\'+$wksta+'\'+$AdminGrp
IF INGROUP('\\'+$wksta+'\'+$AdminGrp)
? 'You are a member of Admins group on: '+$wksta+' '+@error+' - '+@serror
ELSE
? 'You are NOT a member of Admins group on: '+$wksta+' '+@error+' - '+@serror
ENDIF
$Win32Admin = 0
endfunction


Top
#76348 - 2003-08-13 08:12 PM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Unfortunately, I do not have any Universal groups to test in my environment. This would seem to indicate a BUG in INGROUP relative to UNVERSAL group enumeration.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76349 - 2003-08-13 08:21 PM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I thought I read that INGROUP supported univeral groups [Confused]
quote:
INGROUP can be used to check for group membership of groups that exist on the domain or server where the user is logged on, or to check for group membership of groups on a specific domain or server.

When checking for a local group, INGROUP identifies that the user is indirectly a member of the group by virtue of being a member of a global group which, in turn, is a member of the local group.

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76350 - 2003-08-13 08:21 PM Re: SIDTONAME for remote system - Possible?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Doing a check for C$ gives an error instead of expected 0 success even when I have Admin rights

The following code returns an error as well if I have Admin rights.

code:
$wksta = 'workstation1'
RemoteAdmin($wksta)

Function RemoteAdmin($wksta)
DIR '\\'+$wksta+'\C$\*.'
? 'Admin check was: '+@error+' - '+@serror
EndFunction

Error returned is:
Admin check was: -1 - Error (317 / 13D) while retrieving error information for FFFFFFFF

Top
#76351 - 2003-08-13 08:33 PM Re: SIDTONAME for remote system - Possible?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Doing a LOCAL check does work for Universal groups. However, doing it remotely does not seem to work.
Top
#76352 - 2003-08-13 08:39 PM Re: SIDTONAME for remote system - Possible?
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I thought I read that INGROUP supported univeral groups [Confused]
quote:
INGROUP can be used to check for group membership of groups that exist on the domain or server where the user is logged on, or to check for group membership of groups on a specific domain or server.

When checking for a local group, INGROUP identifies that the user is indirectly a member of the group by virtue of being a member of a global group which, in turn, is a member of the local group.

Yes I thought I saw it.
quote:
Previous versions of KiXtart always queried the logonserver for the group-membership information. This provided information on both local and global groups in the logondomain. As of KiXtart 2001, KiXtart retrieves group-membership information using the security token of the current user. The benefit of the new method is that KiXtart can now support universal groups as well as nested global groups.
This issue seems like a bug to me. Ruud a little help please.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#76353 - 2003-08-13 08:57 PM Re: SIDTONAME for remote system - Possible?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Radimus gave me this code and it seems to work well so far.

code:
$wksta = 'workstation1'
? iif(RemoteAdmin($wksta),"Admin","Not Admin")

Function RemoteAdmin($wksta)
$RemoteRC=dir ('\\'+$wksta+'\'+'c$$'+'\.')
$remoteAdmin=iif(not @error,'1','0')
endfunction


Top
#76354 - 2003-08-13 09:57 PM Re: SIDTONAME for remote system - Possible?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I'd go with:

Function RemoteAdmin($computer)
$_=dir('\\'+$computer+'\admin$$')
$remoteAdmin=iif(not @error,1,0)
endfunction

It is always possible that someone had been given perms to c$, but not as likely for admin$
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#76355 - 2003-08-15 09:53 AM Re: SIDTONAME for remote system - Possible?
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
In short: InGroup supports any type of group included in the user token. This includes universal groups.

However, querying for groupmembership on a remote domain or machine does not (can not) rely on the user token, but instead directly queries the remote system. The API involved sadly does not support nested groups. The only workaround for this would be to recursively query all groups on the system, which would be much too expensive in terms of performance and network traffic.

Kind regards,

Ruud

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.128 seconds in which 0.098 seconds were spent on a total of 12 queries. Zlib compression enabled.

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