www.pudn.com > 051118mysqlup.rar > exe2bat.c


#include  
#include  
 
#define M 65279 
 
char *msg="GOOD_LUCK"; 
 
void help(void); 
char exe2bat(char *,char *); 
 
int main(int argc,char **argv) 
{ 
  if(argc==1) 
  { 
    help(); 
  } 
  exe2bat(argv[1],argv[2]); 
  return 0; 
} 
 
void help() 
{ 
  printf("\nWritten by W.Z.T <==Don't be lazy,Just go ahead==>\n\n"); 
  printf("exe2bat.exe input.exe output.bat\n"); 
  exit(0); 
} 
 
char exe2bat(char *s_f,char *t_f) 
{ 
  FILE *s_fp,*t_fp; 
  char *s_fe=s_f; 
  char *t_fe=t_f; 
  char c; 
  char ch; 
  long lenth; 
  int i=1,k=256; 
  if((s_fp=fopen(s_fe,"rb"))==NULL) 
  { 
    printf("Can't open the file %s.\n",s_fe); 
    exit(0); 
  } 
  if((t_fp=fopen(t_fe,"w+"))==NULL) 
  { 
    printf("Can't create the file %s.\n",t_fe); 
    exit(0); 
  } 
  fseek(s_fp,0,SEEK_END); 
  lenth=ftell(s_fp); 
  fseek(s_fp,0,SEEK_SET); 
  printf("%ld,%x\n",lenth,lenth); 
  if(lenth>=M) 
  { 
    printf("The exe file's lenth must be <= M-1\n"); 
    exit(0); 
  } 
  fputs("@echo e ",t_fp); 
  fprintf(t_fp,"%04x ",k); 
  while(!feof(s_fp)) 
  { 
    k++; 
    c = fgetc(s_fp); 
    if(( unsigned char ) c<= ( unsigned char )15) 
        fprintf(t_fp,"0",c); 
    fprintf(t_fp,"%x ",(unsigned char)c); 
    if(i%16==0) 
    { 
        fputs(">>sgl\n",t_fp); 
        fputs("@echo e ",t_fp); 
        fprintf(t_fp,"%04x ",k); 
    } 
    i++; 
  } 
  if(lenth%16!=0) 
    fputs(">>%tmp%\\sgl\n",t_fp); 
  fputs("@echo rcx>>sgl\n",t_fp); 
  fprintf(t_fp,"@echo %x>>sgl\n",lenth,t_fp); 
  fputs("@echo n tthacker>>sgl\n",t_fp); 
  fputs("@echo w>>sgl\n",t_fp); 
  fputs("@echo q>>sgl\n",t_fp); 
  fputs("@debugnul\n",t_fp); 
  fputs("@del sgl\n",t_fp); 
  fputs("@ren tthacker ",t_fp); 
  fprintf(t_fp,"%s>>sgl\n",s_fe); 
  fputs("@",t_fp); 
  fprintf(t_fp,"%s",s_fe); 
  fclose(s_fp); 
  fclose(t_fp); 
  puts(msg); 
  return 0; 
}