Exploit the possiblities

alcatel-ex.c

alcatel-ex.c
Posted Apr 2, 2003
Authored by netric, PoWeR PoRK | Site netric.org

This utility extracts files from the ramdisk image located in the Alcatel speedtouch home/pro modems. The format of these files had to be reverse engineered.

MD5 | 19e78ec0bc6ac1f32dd4e51c6b004861

alcatel-ex.c

Change Mirror Download
/*
* [ alcatel-ex.c by powerpork of netric (http://www.netric.org) ]
*
* Quick hack to extract files from the ramdisk image located in the
* alcatel speedtouch home/pro modems. The format of these files
* had to be reverse enginered and I only had 1 file to test on
* so it might be utter crap.
*
* example: ./alcatel-ex GSV7AA3.270
*
* This will recursively extract all the files packed in this
* file into the current directory.
*
* Contact: powerpork@netric.org
*
*/


#include <stdio.h>

#define STR_NOT_FOUND 0xFFFFFFFF

void * rfile(char * path, unsigned long * size);
unsigned int wfile(char * path, void * buf, unsigned int size);
unsigned int findstring(char * buffer, unsigned int bsize, char * key, int start);
int ppath(char * path);

int main(int argc, char ** argv[])
{
unsigned long * fsize;
unsigned int buf=0,c=0,ic=0,ifname=0,ifptr=0,ifsize=0;

if(!(argc>=1)){
printf("ERROR: No filename to process\n");
}

buf = (unsigned int)rfile(argv[1], fsize);
if(buf == 0){
printf("ERROR: read error\n");
exit(1);
}else{
printf("[size=%u]\n", *fsize);
}

c=0;
ic=0;
while(c != STR_NOT_FOUND){
if(c!=0){
printf("[name=%s]\n", c+buf);
ifname=(c+buf);
if(((char *)buf+c)[strlen(((char *)c+buf))-1] == 47){
c=findstring((char *)buf, *fsize, "active/", c+1);
}else{
c=findstring((char *)buf, *fsize, "we2", c);
for(c+=3;((char*)buf)[c]==0;c++){}
//printf("[stub=%s]\n", c+buf);
ifptr = (c+buf);
ic=findstring((char *)buf, *fsize, "active/", c+1);
if(ic==STR_NOT_FOUND){
ic = *fsize;
}
for(ic--;((char*)buf)[ic]==0;ic--){}
ifsize = ((ic+buf)-ifptr+1);
printf("[size=%u]\n", ifsize);
wfile(ifname, ifptr, ifsize);
}
}
c=findstring((char *)buf, *fsize, "active/", c+1);
}

//wfile("active/blaat2.txt", "blaat!", 5);

printf("END\n");
return 0;
}

void * rfile(char * path, unsigned long * size)
{
FILE * file;
unsigned int rsize=0, buf=0;
long fsize=0;

file = fopen(path, "rb");
if(file == NULL){ return 0; }

fseek(file, 0, SEEK_END);
fsize = ftell(file);
*size = fsize;
rewind(file);

buf = malloc(size);
*size = fread((void *)buf, 1, *size, file);
if(*size == 0){ return 0; }

fclose(file);
return (void *)buf;
}

unsigned int findstring(char * buffer, unsigned int bsize, char * key, int start)
{
int indexcounter=0;

for(indexcounter=start;(indexcounter<bsize);indexcounter++){
if(strncmp((((char*)buffer)+indexcounter), key, strlen(key))==0){
return indexcounter;
}
}

return STR_NOT_FOUND;
}

unsigned int wfile(char * path, void * buf, unsigned int size)
{
FILE * file;
unsigned int wsize=0;

ppath(path);

file = fopen(path, "wb");
if(file == NULL){
return 0;
}

wsize = fwrite(buf, 1, size, file);

fclose(file);
return wsize;
}

int ppath(char * path)
{
int c=0;
unsigned int pbuf=0,opbuf=0;

pbuf = malloc(strlen(path));
opbuf = pbuf;

if(pbuf == 0){
return -1;
}
strcpy(pbuf, path);

while(c!=STR_NOT_FOUND){
c=findstring(pbuf, strlen(pbuf), "/", c);
if(c!=STR_NOT_FOUND){
((char*)pbuf)[c] = 0;
mkdir((pbuf), 4095);
((char*)pbuf)[c] = 47;
c++;
}
}

free(opbuf);

return 0;
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

December 2017

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Dec 1st
    15 Files
  • 2
    Dec 2nd
    2 Files
  • 3
    Dec 3rd
    1 Files
  • 4
    Dec 4th
    15 Files
  • 5
    Dec 5th
    15 Files
  • 6
    Dec 6th
    18 Files
  • 7
    Dec 7th
    17 Files
  • 8
    Dec 8th
    15 Files
  • 9
    Dec 9th
    13 Files
  • 10
    Dec 10th
    4 Files
  • 11
    Dec 11th
    41 Files
  • 12
    Dec 12th
    44 Files
  • 13
    Dec 13th
    25 Files
  • 14
    Dec 14th
    15 Files
  • 15
    Dec 15th
    28 Files
  • 16
    Dec 16th
    0 Files
  • 17
    Dec 17th
    0 Files
  • 18
    Dec 18th
    0 Files
  • 19
    Dec 19th
    0 Files
  • 20
    Dec 20th
    0 Files
  • 21
    Dec 21st
    0 Files
  • 22
    Dec 22nd
    0 Files
  • 23
    Dec 23rd
    0 Files
  • 24
    Dec 24th
    0 Files
  • 25
    Dec 25th
    0 Files
  • 26
    Dec 26th
    0 Files
  • 27
    Dec 27th
    0 Files
  • 28
    Dec 28th
    0 Files
  • 29
    Dec 29th
    0 Files
  • 30
    Dec 30th
    0 Files
  • 31
    Dec 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2016 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close