int main(int argc, char **argv) { if (argc < 3) { printf("usage: bf3decrypt infile outfile\n", argv[0]); return 1; } mmap_buf(argv[1]); if (filebuf[0] != 0x00 && filebuf[1] != 0xD1 && filebuf[2] != 0xCE && filebuf[3] != 0x00) { printf("Invalid File!\n"); free(filebuf); return 1; } decrypt(); outputfile(argv[2]); free(filebuf); return 0; }
static void buildBuf() { char line[MAX_LINE+1]; char temp1[16],temp2[16]; FILE *fp = fopen("/proc/usg/ctrl","rt"); char *rec = NULL; int pos=-1; sgBufs.num = 0; send2Ctrl("i"); while(rec=Readline(line,fp)) { if( *rec!='v' ) continue; strncpy(sgBufs.bufs[sgBufs.num].name,rec+2,5); pos = findChar(sgBufs.bufs[sgBufs.num].name,5,']'); if( pos==-1 ) continue; sgBufs.bufs[sgBufs.num].name[pos]='\0'; rec+=(pos+2); pos = findChar(rec,strlen(rec),'x'); if( pos==-1 ) continue; sscanf(rec+pos+1,"%lx",&sgBufs.bufs[sgBufs.num].virt); rec+=pos+1; pos = findChar(rec,strlen(rec),'x'); if( pos==-1 ) continue; sscanf(rec+pos+1,"%lx",&sgBufs.bufs[sgBufs.num].bus); rec+=pos+1; pos = findChar(rec,strlen(rec),'x'); if( pos==-1 ) continue; sscanf(rec+pos+1,"%lx",&sgBufs.bufs[sgBufs.num].size); printf("v[%s]\t=0x%lx | b[%s]\t=0x%lx | size[%s]\t=0x%lx\n", sgBufs.bufs[sgBufs.num].name, sgBufs.bufs[sgBufs.num].virt, sgBufs.bufs[sgBufs.num].name, sgBufs.bufs[sgBufs.num].bus, sgBufs.bufs[sgBufs.num].name, sgBufs.bufs[sgBufs.num].size ); sprintf(line,"/proc/usg/%s",sgBufs.bufs[sgBufs.num].name); sgBufs.bufs[sgBufs.num].mem=mmap_buf(line,sgBufs.bufs[sgBufs.num].size); sgBufs.num++; } }