Page 1 of 1 1
Topic Options
#38957 - 2003-04-08 11:26 AM SU Command
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Hi Everyone

Has anyone got the hotfix for SU.exe (w2k).

Q265401_w2k_sp2_x86_en.exe

Getting errors when ruuning the SU.exe command from a Windows 2000 PC.

Thanks

Richard

Top
#38958 - 2003-04-08 02:55 PM Re: SU Command
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
With sounding stoopid, have you downloaded it from http://support.microsoft.com/default.aspx?scid=KB;en-us;q265401 ?

Is it still erroring after the hotfix has been applied ?
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#38959 - 2003-04-08 02:56 PM Re: SU Command
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Ignore that comment I see what you mean....
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#38960 - 2003-04-08 02:57 PM Re: SU Command
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Richard,

Have you had a chance to look at this?

http://www.ss64.com/nt/su.html

Specifically...
quote:

A 3rd party freeware version of SU is available here

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#38961 - 2003-04-08 02:58 PM Re: SU Command
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Ignore that comment I see what you mean....
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#38962 - 2003-04-08 02:59 PM Re: SU Command
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Ok maybe I am not reading the post corectly, the link within the post directs you to a microsoft call centre phone number.

You then need to call microsoft and pay them for the download.

Is that not how you read it ???.

Thanks

Top
#38963 - 2003-04-08 03:00 PM Re: SU Command
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Richard,

Granted, it is not M$, but maybe worthwhile..

http://bmrc.berkeley.edu/people/chaffee/winntutil.html

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#38964 - 2003-04-08 03:53 PM Re: SU Command
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Thanks

I have tried it out and it looks good, just need to try it with my scripts now.

Thanks guys for the responce.

Rich

Top
#38965 - 2003-04-08 05:05 PM Re: SU Command
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Ok that works but one problem.

When doing a SU command, it will prompt you for the password, I can't seem to script it so it don't prompt.

No there are two options.

1. Some clever person has a way of scripting this in kix so it don't prompt me for the password.

2. Some evan clever person who knows C++ modify's the code of the SU.exe so that the password is hardcoded for a username called SU-User. with a password of "SUUser12345"

Now I know this is a masive thing to ask, and a big cheek.

Thanks
Richard Farthing

The code for SU.exe is a follows:

code:
  
*/

#include <windows.h>
#include <iostream.h>
#include <winerror.h>

#define NAME_BUF_SZ 255

void ErrorHandler (LPSTR errmsg)
{
cerr << "Error: " << errmsg << ". Error Code: " << GetLastError() << endl;
}

BOOL SetUserObjectAllAccess(HANDLE hObject)
{
PSECURITY_DESCRIPTOR pSD;
SECURITY_INFORMATION si;
BOOL success;

/* Initialize a security descriptor. */

pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); /* defined in WINNT.H */
if (pSD == NULL)
{
ErrorHandler("Can't Allocate Local Memory");
return FALSE;
}

if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
{ /* defined in WINNT.H */
ErrorHandler("Can't Initialize Security Descriptor");
LocalFree ((HLOCAL) pSD);
return FALSE;
}

/* Add a NULL disc. ACL to the security descriptor. */
if (!SetSecurityDescriptorDacl(pSD,
TRUE, /* specifying a disc. ACL */
(PACL) NULL,
FALSE)) /* not a default disc. ACL */
{
ErrorHandler("Can't Set Security Descriptor DACL");
LocalFree ((HLOCAL) pSD);
return FALSE;
}

/* Add the security descriptor to the file. */
si = DACL_SECURITY_INFORMATION;
success = SetUserObjectSecurity(hObject,
&si,
pSD);

LocalFree((HLOCAL) pSD);

if ( ! success )
{
ErrorHandler("Can't Set User Object Security");
return FALSE;
}
else
{
return TRUE;
}
}

void main(int argc, char *argv[])
{
CHAR pwstr[NAME_BUF_SZ],
user[NAME_BUF_SZ],
commandLine[NAME_BUF_SZ];
STARTUPINFO startUpInfo;
PROCESS_INFORMATION procInfo;
HDESK hDesktop;
HWINSTA hWindowStation;
HANDLE hRootsid, hConsole;
DWORD err, oldConsoleMode, newConsoleMode;
OSVERSIONINFO NTversion;

// Make sure we are using the minimum OS version.
NTversion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx(&NTversion) )
{
ErrorHandler ("Unable to get OS version");
exit(1);
}

if (NTversion.dwPlatformId != VER_PLATFORM_WIN32_NT)
{
cerr << "su will run only on Windows NT." << endl;
exit(1);
}

if (NTversion.dwBuildNumber < 1057) // Commercial 3.51 release
{
cerr << "su requires at minimum NT version 3.51 build 1057." << endl;
exit(1);
}

#ifdef VERBOSE
cout << "su: NT Version " << NTversion.dwMajorVersion << "." <<
NTversion.dwMinorVersion << ", build " << NTversion.dwBuildNumber <<
endl;
#endif

// Retrieve command line parameters
switch (argc)
{
case 0: case 1:
strcpy(user, "Administrator");
strcpy(commandLine, "cmd");
break;
case 2:
strcpy(user, *++argv);
strcpy(commandLine, "cmd");
break;
default:
strcpy(user, *++argv);
strcpy(commandLine, "");
while (*++argv)
{
strcat(commandLine, *argv);
strcat(commandLine, " ");
}
break;
}

#ifdef VERBOSE
cout << "argc: " << argc << endl
<< "user: (" << user << ")" << endl
<< "cmd : (" << commandLine << ")" << endl;
#endif

// Turn off console mode echo, since we don't want clear-screen passwords
if ((hConsole = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE)
{
ErrorHandler ("Can't get handle of STDIN");
exit(1);
}

if (! GetConsoleMode(hConsole, &oldConsoleMode))
{
ErrorHandler ("Can't get current Console Mode");
exit(1);
}

newConsoleMode = oldConsoleMode & ( ~ ENABLE_ECHO_INPUT );

if (! SetConsoleMode(hConsole, newConsoleMode))
{
ErrorHandler ("Unable to turn off Echo");
exit(1);
}

// Ask for the password
cout << "Enter password: ";
cin.getline(pwstr,NAME_BUF_SZ);
// When echo is off and user hits <RETURN>, CR-LF is not echoed, so do it for him
cout << endl;
if (! SetConsoleMode(hConsole, oldConsoleMode))
{
ErrorHandler ("Unable to reset previous console mode");
exit(1);
}
CloseHandle (hConsole);

// Logon the administrator
if (!LogonUser (user,NULL,pwstr, LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, &hRootsid) )
{
err = GetLastError();
switch (err) {
case ERROR_PRIVILEGE_NOT_HELD:
cerr << "Error: you do not have the SeTcbPrivilege (act as part of OS) privilege." << endl;
break;
case ERROR_LOGON_FAILURE:
cerr << "Wrong password." << endl;
break;
case ERROR_ACCESS_DENIED:
ErrorHandler("Access is denied");
break;
default:
ErrorHandler("Unable to logon");
break;
}
exit(1);
}

// Retrieve the STARTUPINFO structure for the current process
GetStartupInfo(&startUpInfo);

// give the user access to the WindowStation and Desktop
hWindowStation = GetProcessWindowStation();
if (!SetUserObjectAllAccess(hWindowStation))
{
cerr << "Cannot set WindowStation security" ;
CloseHandle (hRootsid);
exit(1);
}
hDesktop = GetThreadDesktop(GetCurrentThreadId());
if (!SetUserObjectAllAccess(hDesktop))
{
cerr << "Cannot set Desktop security";
CloseHandle (hRootsid);
exit(1);
}

// Create the child process
if ( ! CreateProcessAsUser(hRootsid,
0, commandLine, 0, 0, FALSE,
CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP ,
0, 0, &startUpInfo, &procInfo) )
{
err = GetLastError();
switch (err) {
case ERROR_PRIVILEGE_NOT_HELD:
cerr << "Error: you do not have the SeAssignPrimary or SeIncreaseQuota Privileges." << endl;
break;
default:
ErrorHandler ("Can't create process");
break;
}
}

// Wait for the child to complete
WaitForSingleObject(procInfo.hProcess, INFINITE);
CloseHandle(hWindowStation);
CloseHandle(hDesktop);
CloseHandle(hRootsid);
exit(0);
}


Top
#38966 - 2003-04-08 05:08 PM Re: SU Command
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Richard: There have already been a lot of discussions about SU. Please read the FAQ Forum, page 2, 'Installing Applications as an Admin' and/or search this BBS for SU. A couple of solutions have already been proposed.
_________________________
There are two types of vessels, submarines and targets.

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 1321 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.539 seconds in which 0.508 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