发新话题
打印

[原创]改进版的黑客字典

[原创]改进版的黑客字典

文章作者:sgl
信息来源:邪恶八进制信息安全团队(www.eviloctal.com

俺喜欢命令行下的东东,于是就有了这个。
复制内容到剪贴板
代码:
//-------------------------------------------------------------------------------//
//  黑客字典 v2.3 Source Code for Visual C++ 6.0                      //
//                                                     //
//    -->> Everyone free to use, modify, recompile!!!  Open it for Internet    //
//                                                     //
//  Author:   W.Z.T                                         //
//  HomePage:  [url]http://tthacker.hackvip.cn[/url]                           //
//  Publisher: [url]http://www.suse.edu.cn[/url]                              //
//  Release:  8/9/2005                                       //
//-------------------------------------------------------------------------------//
/*

黑客字典2.3,改进了穷举的算法,密码最大长度为1000,使代码长度减小,程序的执行速度加快。
同时加入了新的功能,除了完成一般黑客字典的所有功能外. 还加入了辅助功能,协助黑客更好的
设置字典。

常规字典:

01。生日字典,提供12种格式。
02。手机。电话字典。
03。穷举给定长度的数字,大小写字母之间的排列。
04。支持字定义字符模式。

辅助功能:

05。增加了无穷个字典的合并功能,合并后可去除每两个字典档中重复的密码。
06。把一个较大的文件分解成若干个小的字典档。
07。向一个文件每个密码的前面或后面增加特定的字符串,或是删除特定的字符串。
08。把每个密码的前后调换。
09。从一个文件过滤出特定字符的密码。
10。可以将指定文件中每行指定的字符前面的字符保留。
11。将一个文件中每行中指定的字符串替换成另一个字符串。
12。完成类似txt2dic程式的功能,从指定程序过滤掉给定的字符串。

FAQ:

02.当穷举时,如果有'^',需在命令行下写两便。例如:@#^^,将生成@#^之间所有的排列。
---------------------------------------------------------------------------------*/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 1000
#define Max 100
#define M 600

void help(void);
void turn(char *,char *);   /*将密码倒转*/
void grep(char *,char *,char *);  /*保留特定字符串*/
void find(char *,char *,char *);  /*查找字符函数*/
void a_file(int,char **);   /*合并文件*/
void c_file(int,char **);   /*分解文件*/
void mobi(char *,char *,char *,char *,char *);  /*生成手机密码*/
void tel(char *,char *,char *,char *);        /*电话密码*/
void create(char *,char *,char *,char *);     /*穷举密码*/
void adle(char *,char *,char *,char *);    /*文件每行加入特定的字符串*/
void acle(char *,char *,char *,char *);    /*文件每行删除特定的字符串*/
void cut(char *,char *,char *,char *);   /*保留文件每行中特定字符前面的字符串*/
void txt2dic(char *,char *,char *,char *);  /*过滤特定字符串*/
void defi(char *,char *,char *,char *);  /*将指定的字符串替换成另一字符串*/
void birth(char *,char *,char *,char *,char *,char *,char *,char *);  /*生日字典*/

char a[MAX];      /*将要穷举的字符数组*/

char line[MAX][Max];

char b[]="0123456789";

char c[]="abcdefghijklmnopqrstuvwxyz";

char d[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

char e[]="0123456789abcdefghijklmnopqrstuvwxyz";

char h[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

char g[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

char f[]="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(int argc ,char **argv)
{
    if(argc==1)
    {
      help();
    }
    if(!strcmp(argv[1],"-tt"))
    {
         txt2dic(argv[2],argv[3],argv[4],argv[5]);
    }
    if(!strcmp(argv[1],"-g"))
    {
         grep(argv[2],argv[3],argv[4]);
    }
    if(!strcmp(argv[1],"-m"))
    {
        mobi(argv[2],argv[3],argv[4],argv[5],argv[6]);
    }
    if(!strcmp(argv[1],"-t"))
    {
      tel(argv[2],argv[3],argv[4],argv[5]);
    }
    if(!strcmp(argv[1],"-b"))
    {
      birth(argv[2],argv[3],argv[4],argv[5],argv[6],argv[7],argv[8],argv[9]);
    }

   if(!strcmp(argv[1],"-d"))
   {
      create(argv[2],argv[3],argv[4],argv[5]);
   }
   if(!strcmp(argv[1],"-ac"))
   {
      adle(argv[2],argv[3],argv[4],argv[5]);
   }
   if(!strcmp(argv[1],"-ca"))
   {
      acle(argv[2],argv[3],argv[4],argv[5]);
   }
   if(!strcmp(argv[1],"-u"))
   {
      turn(argv[2],argv[3]);
   }
   if(!strcmp(argv[1],"-cc"))
   {
      cut(argv[2],argv[3],argv[4],argv[5]);
   }
   if(!strcmp(argv[1],"-v"))
   {
      defi(argv[2],argv[3],argv[4],argv[5]);
   }

   if(!strcmp(argv[1],"-a"))  /*字典文件合并*/
   {
      a_file(argc,argv);
   }
   if(!strcmp(argv[1],"-c"))   /*字典文件分割*/
   {
      c_file(argc,argv);
   }
}


void mobi(char *a,char *b,char *c,char *d,char *e)  /*手机字典生成函数*/
{
   FILE *fp;
   char *aa=a;
   char *bb=b;
   char *cc=c;
   char *dd=d;
   char *ee=e;
   char ch;
   int p,q,j;
   long m,n,i;
   long lenth=0;
   
   if((fp=fopen(aa,"w+"))==NULL)
   {
      printf("Can&#39;t open the file %s\n",aa);
      exit(0);
   }
   
   p=atoi(bb);
   q=atoi(cc);
   m=atol(dd);
   n=atol(ee);
   
   if(p>q||m>n)     /*排错处理*/
   {
      printf("error,p must <= q or m <= n please input again:\n");
      exit(0);
   }
   for(j=p;j<=q;j++)
      for(i=m;i<=n;i++)
         fprintf(fp,"%d%ld\n",j,i,fp);
   rewind(fp);
   
   while((ch=fgetc(fp))!=EOF)
   {
      if(ch==&#39;\n&#39;)
          ++lenth;
   }
   printf("done.\nthe file has %ld words in %s\n",lenth,aa);
   fclose(fp);
}


void tel(char *a,char *b,char *c,char *d)    /*电话字典生成函数*/
{
    FILE *fp;
    char *aa=a,*bb=b,*cc=c,*dd=d;
    int p,w=0;
    char ch;
    long m,n,i;
    long lenth=0;
   
    if((fp=fopen(aa,"w+"))==NULL)
    {
      printf("Can&#39;t open the file %s\n",aa);
      exit(0);
    }
    p=atoi(bb);
    m=atol(cc);
    n=atol(dd);
    if(m>=n)
    {
       printf("error.start_n must <= end_n\n");
       exit(0);
    }
    if(p>=1000)
    {
      for(i=m;i<=n;i++)
          fprintf(fp,"%d%ld\n",p,i);
    }
    else
    {
      for(i=m;i<=n;i++)
          fprintf(fp,"%d%d%ld\n",w,p,i);
    }
    rewind(fp);
    while((ch=fgetc(fp))!=EOF)
    {
      if(ch==&#39;\n&#39;)
          ++lenth;
    }
    fclose(fp);
    printf("\nDone.\nThe file has %ld hang in %s.\n",lenth,aa);
}


void birth(char *a1,char *b1,char *c1,char *d1,char *e1,char *f1,char *g1,char *h1)
{
   FILE *fp;
   char *aa=a1,*bb=b1,*cc=c1,*dd=d1,*ee=e1,*ff=f1,*gg=g1,*hh=h1;
   long int lenth=0;
   int a,b,c,d,e,f,h,m=0;
   char ch,ch1=&#39;//&#39;,ch2=&#39;:&#39;,ch3=&#39;.&#39;,ch4=&#39;-&#39;,ch5=&#39;\\&#39;;
   if((fp=fopen(bb,"w+"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n",bb);
      exit(0);
   }

   h=atoi(aa);
   a=atoi(cc);
   b=atoi(dd);
   c=atoi(ee);
   d=atoi(ff);
   e=atoi(gg);
   f=atoi(hh);

   if(a>d||b>e||c>f)
   {
      printf("error.check it again.\n");
      exit(0);
   }
   while(a<=d)
   {
      switch(h)
      {
         case 1:
            if(b<10&&c<10)
               fprintf(fp,"%d%d%d%d%d\n",a,m,b,m,c);
            if(b>=10&&c<10)
               fprintf(fp,"%d%d%d%d\n",a,b,m,c);
            if(b<10&&c>=10)
               fprintf(fp,"%d%d%d%d\n",a,m,b,c);
            if(b>=10&&c>=10)
               fprintf(fp,"%d%d%d\n",a,b,c);
            break;
         case 2:
            if(b<10&&c<10)
               fprintf(fp,"%d%c%d%d%c%d%d\n",a,ch1,m,b,ch1,m,c);
            if(b>=10&&c<10)
               fprintf(fp,"%d%c%d%c%d%d\n",a,ch1,b,ch1,m,c);
            if(b<10&&c>=10)
               fprintf(fp,"%d%c%d%d%c%d\n",a,ch1,m,b,ch1,c);
            if(b>=10&&c>=10)
               fprintf(fp,"%d%c%d%c%d\n",a,ch1,b,ch1,c);
            break;
         case 3:
            if(b<10&&c<10)
               fprintf(fp,"%d%c%d%d%c%d%d\n",a,ch2,m,b,ch2,m,c);
            if(b>=10&&c<10)
               fprintf(fp,"%d%c%d%c%d%d\n",a,ch2,b,ch2,m,c);
            if(b<10&&c>=10)
               fprintf(fp,"%d%c%d%d%c%d\n",a,ch2,m,b,ch2,c);
            if(b>=10&&c>=10)
               fprintf(fp,"%d%c%d%c%d\n",a,ch2,b,ch2,c);
            break;
         case 4:
            if(b<10&&c<10)
               fprintf(fp,"%d%c%d%d%c%d%d\n",a,ch3,m,b,ch3,m,c);
            if(b>=10&&c<10)
               fprintf(fp,"%d%c%d%c%d%d\n",a,ch3,b,ch3,m,c);
            if(b<10&&c>=10)
               fprintf(fp,"%d%c%d%d%c%d\n",a,ch3,m,b,ch3,c);
            if(b>=10&&c>=10)
               fprintf(fp,"%d%c%d%c%d\n",a,ch3,b,ch3,c);
            break;
         case 5:
            if(b<10&&c<10)
               fprintf(fp,"%d%c%d%d%c%d%d\n",a,ch4,m,b,ch4,m,c);
            if(b>=10&&c<10)
               fprintf(fp,"%d%c%d%c%d%d\n",a,ch4,b,ch4,m,c);
            if(b<10&&c>=10)
               fprintf(fp,"%d%c%d%d%c%d\n",a,ch4,m,b,ch4,c);
            if(b>=10&&c>=10)
               fprintf(fp,"%d%c%d%c%d\n",a,ch4,b,ch4,c);
            break;
         case 6:
               fprintf(fp,"%d%d%d\n",a,b,c);
               break;
         case 7:
               fprintf(fp,"%d%c%d%c%d\n",a,ch1,b,ch1,c);
               break;
         case 8:
               fprintf(fp,"%d%c%d%c%d\n",a,ch2,b,ch2,c);
               break;
         case 9:
               fprintf(fp,"%d%c%d%c%d\n",a,ch3,b,ch3,c);
               break;
         case 10:
               fprintf(fp,"%d%c%d%c%d\n",a,ch4,b,ch4,c);
               break;
         case 11:
               fprintf(fp,"%d%c%d%c%d\n",a,ch5,b,ch5,c);
               break;
         case 12:
             if(b<10&&c<10)
               fprintf(fp,"%d%c%d%d%c%d%d\n",a,ch5,m,b,ch5,m,c);
             if(b>=10&&c<10)
               fprintf(fp,"%d%c%d%c%d%d\n",a,ch5,b,ch5,m,c);
             if(b<10&&c>=10)
               fprintf(fp,"%d%c%d%d%c%d\n",a,ch5,m,b,ch5,c);
             if(b>=10&&c>=10)
               fprintf(fp,"%d%c%d%c%d\n",a,ch5,b,ch5,c);
             break;
     }
    c++;
    if(a==d)
    {
       if(b>=e&&c>f)
         break;
    }
    if(c>31)
    {
       b++;
       c=1;
       if(b>12)
       {
         a++;
         b=1;
       }
     }
   }
   rewind(fp);
   while((ch=fgetc(fp))!=EOF)
   {
     if(ch==&#39;\n&#39;)
     lenth++;
   }
   fclose(fp);
   printf("\ndone.\nThe file has %ld hang in %s\n",lenth+1,bb);

}


void a_file(int len,char **line)
{
   FILE *s_fp,*t_fp;
   int i=2;
   int flag=1;
   long int lenth=0;
   long int sum=0;
   char buffer[Max];
   char buffer1[Max];
   char ch;
   char ch1=&#39;\n&#39;;
   
   if((s_fp=fopen(line[i],"w+"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n",line[i]);
      exit(0);
   }
   if((t_fp=fopen(line[i+1],"a"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n",line[i+1]);
      exit(0);
   }
   fseek(t_fp,-1L,2);
   if((ch=fgetc(t_fp))!=&#39;\n&#39;)
   {
      printf("%c\n",ch);
      fputs("\n",t_fp);
   }
   fclose(t_fp);
   
   if((t_fp=fopen(line[i+1],"r"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n",line[i+1]);
      exit(0);
   }
   while(fgets(buffer,512,t_fp)!=NULL)
   {
      fputs(buffer,s_fp);
      ++lenth;
   }
   rewind(s_fp);
   fclose(t_fp);
   
   printf("The file %s has %ld words\n\n",line[i+1],lenth);
   printf("waiting...\n");
   for(i=4;i<len;i++)
   {
      lenth=0;
      if((t_fp=fopen(line[i],"r"))==NULL)
      {
        printf("Can&#39;t open the file %s.\n",line[i]);
        exit(0);
      }
      while(fgets(buffer,512,t_fp)!=NULL)
      {
        ++lenth;
        rewind(s_fp);
        while(fgets(buffer1,512,s_fp)!=NULL)
        {
            if(!strcmp(buffer,buffer1))
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            flag=0;
        else
           fputs(buffer,s_fp);
      }
      fputs("\n",s_fp);
      fclose(t_fp);
      printf("The file %s has %ld words.\n\n",line[i],lenth);
      printf("waiting...\n");
    }
    rewind(s_fp);
   
    while(fgets(buffer,512,s_fp)!=NULL)
        ++sum;
    fclose(s_fp);
    printf("The file %s has %ld words.\n\n",line[2],sum);
    printf("done.\n\nGood Luck:)\n");
}

void c_file(int len,char **line)
{
   FILE *s_fp,*t_fp;
   int i=2,j;
   long int  lenth=0,len1,len2,len3=0;
   char buffer[Max];
   char ch;
   
   if((s_fp=fopen(line[i],"r"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n");
      exit(0);
   }
   while((ch=fgetc(s_fp))!=EOF)
      if(ch==&#39;\n&#39;)
         lenth++;
   rewind(s_fp);
   
   len1=lenth/(len-3);
   len2=lenth%(len-3);
   for(i=3;i<len;i++)
   {
      if((t_fp=fopen(line[i],"w+"))==NULL)
      {
         printf("Can&#39;t open the file %s.\n",line[i]);
         exit(0);
      }
      for(j=len3;j<len1;j++)
      {
         fgets(buffer,512,s_fp);
         fputs(buffer,t_fp);
      }
        fclose(t_fp);
      printf("finished file %s.\n",line[i]);
      len3=len1;
      if(i==len)
      {
           len1+=len1;
         len1+=len2;
      }
      len1+=len1;
   }
}

void create(char *aa,char *bb,char *cc,char *dd)   /*穷举算法*/
{
   FILE *fp;
   char *a1=aa,*b2=bb,*c2=cc,*d2=dd,ch;
   char a2[MAX],line[MAX],up[MAX];
   int min,max,min1,max1,next,lenth;
   register int i=0,j;
   long lenth1=0;

   min=atoi(c2);
   max=atoi(d2);

   if(min>max)
   {
        printf("argv[3] must <= argv[4].\n");
        exit(0);
   }
   
   if(!strcmp(a1,"-s"))
        strcpy(a,c);
   else if(!strcmp(a1,"-b"))
        strcpy(a,d);
   else if(!strcmp(a1,"-n"))
        strcpy(a,b);
   else if(!strcmp(a1,"-sn"))
        strcpy(a,e);
   else if(!strcmp(a1,"-bn"))
        strcpy(a,h);
   else if(!strcmp(a1,"-sb"))
        strcpy(a,g);
   else if(!strcmp(a1,"-sbn"))
        strcpy(a,f);
   else
   {
        strcpy(a,a1);
   }
   if((fp=fopen(b2,"w+"))==NULL)
   {
        printf("Can&#39;t open the file.\n");
        exit(0);
   }
   puts(a);
   lenth=strlen(a);

   while(min<=max)
   {
        for(i=0;i<max;i++)
          up[i]=0;
        next=1;
        while(next)
        {
           for(i=0;i<min;i++)    /*注意密码下标*/
              line[i]=a[up[i]];
           line[i]=&#39;\0&#39;;
           fputs(line,fp); fputs("\n",fp);
           for(j=min-1;j>=0;j--)
           {
              up[j]++;        /*下标进位,穷举算法的关键*/
                  if(up[j]!=lenth)
                 break;
              else
              {
                 up[j]=0;
                 if(j==0)  next=0;
              }
           }
       }
       min++;
   }
    rewind(fp);
    while((ch=fgetc(fp))!=EOF)
    {
        if(ch==&#39;\n&#39;)
        ++lenth1;
    }
    fclose(fp);
    printf("\n");
    printf("Done.\nThe file has %ld hang in %s.\n",lenth1,bb);
}

void adle(char *aa,char *b,char *c,char *d)   /*文件每行前或后增加特定的字符串*/
{
      FILE *fp,*fp1;
      char *aaa=aa,*bb=b,*cc=c,*dd=d;
      char line1[600];
      int len,i;
      
      if((fp=fopen(cc,"r"))==NULL)
      {
         printf("Can&#39;t open the file %s\n",cc);
         exit(0);
      }
      if((fp1=fopen(dd,"w+"))==NULL)
      {
         printf("Can&#39;t open the file %s\n",dd);
         exit(0);
      }
      
      while(fgets(line1,512,fp)!=NULL)
      {
         if(!strcmp(aaa,"-a"))
         {
            fputs(bb,fp1);
            fputs(line1,fp1);
         }
         if(!strcmp(aaa,"-c"))
         {
            len=strlen(line1);
            for(i=0;i<(len-1);i++)
               fputc(line1[i],fp1);
            fputs(bb,fp1);
            fputs("\n",fp1);
         }
     }
     fclose(fp1);
     fclose(fp);
     printf("done.\n");

}



void acle(char *aa,char *c,char *d,char *e)  /*文件的每行的前或后删除特定的字符串*/
{
      FILE *fp,*fp1;
      char line1[600];
      char *aaa=aa,*cc=c,*dd=d,*ee=e;
      int len,len1,i;
      
      len=strlen(cc);
      if((fp=fopen(dd,"r"))==NULL)
      {
          printf("Can&#39;t open the file %s\n",dd);
          exit(0);
      }
      if((fp1=fopen(ee,"w+"))==NULL)
      {
          printf("Can&#39;t open the file %s\n",ee);
          exit(0);
      }
      
      while(fgets(line1,512,fp)!=NULL)
      {
          len1=strlen(line1);
          if(!strcmp(aaa,"-a"))
          {
            for(i=len;i<len1;i++)
               fputc(line1[i],fp1);
          }
          if(!strcmp(aaa,"-b"))
          {
            for(i=0;i<(len1-len-1);i++)
               fputc(line1[i],fp1);
            fputs("\n",fp1);
          }
     }
     fclose(fp);
     fclose(fp1);
     printf("done.\n");

}



void turn(char *aa,char *b)    /*将每行的密码倒转*/
{
     FILE *fp,*fp1;
     char line1[600];
     char *aaa=aa,*bb=b;
     int i,len;
     if((fp=fopen(aaa,"r"))==NULL)
     {
        printf("Can&#39;t open the file %s\n",aaa);
        exit(0);
     }
     if((fp1=fopen(bb,"w+"))==NULL)
     {
        printf("Can&#39;t open the file %s\n",bb);
        exit(0);
     }
     while(fgets(line1,512,fp)!=NULL)
     {
        len=strlen(line1);
           for(i=len-2;i>=0;i--)
        fputc(line1[i],fp1);
        fputs("\n",fp1);
     }
     fclose(fp);
     fclose(fp1);
     printf("done.\n");

}



void cut(char *aa,char *b,char *c,char *d)   /*保留文件每行中特定字符前面的字符串*/
{
    FILE *fp,*fp1;
    char line[600],ch;
    char *aaa=aa,*bb=b,*cc=c,*dd=d;
    int i,count=0,count1;
    if((fp=fopen(cc,"r"))==NULL)
    {
          printf("Can&#39;t open the file %s\n",cc);
        exit(0);
    }
    if((fp1=fopen(dd,"w+"))==NULL)
    {
          printf("Can&#39;t open the file %s\n",dd);
          exit(0);
    }
    count1=atoi(bb);        /*将字符转换成数字*/
        printf("%d\n",count1);
    while(fgets(line,512,fp)!=NULL)
      {
        count=0;
        for(i=0;i<strlen(line);i++)
        {
               if(line[i]==aaa[0])
               {

                 count++;
                }
        }
        if(count>=count1)
        {
            printf("check...\n");
            count=0;
            for(i=0;i<strlen(line);i++)
              {
                  if(line[i]==aaa[0])
                      count++;
                  if(count==count1)
                      break;
            fputc(line[i],fp1);
         }
         fputs("\n",fp1);
        }

      }
      fclose(fp);
      fclose(fp1);
      printf("done.\n");
}


void grep(char *aa,char *b,char *c)  /*保留每行中特定的字符串*/
{
      FILE *fp,*fp1;
      char line[600];
      char *aaa=aa,*bb=b,*cc=c;
      if((fp=fopen(bb,"r"))==NULL)
      {
        printf("Can&#39;t open the file %s\n",bb);
        exit(0);
      }
      if((fp1=fopen(cc,"w+"))==NULL)
      {
        printf("Can&#39;t open the file %s\n",cc);
        exit(0);
      }
      while(fgets(line,512,fp)!=NULL)
      {
        if(strstr(line,aaa)!=NULL)     /*比较要保留的字符串*/
            fputs(line,fp1);
      }
      fclose(fp);
      fclose(fp1);
      printf("done.\n");
}



void txt2dic(char *aa,char *b,char *c,char *d)  /*过滤特定的字符*/
{
      FILE *fp1,*fp2;
      long int count=0,lenth=0;
      int i,flag=0;
      char a[Max],ch;
      char *aaa=aa,*bb=b,*cc=c,*dd=d;
      if((fp1=fopen(cc,"r"))==NULL)
      {
          printf("Can&#39;t open the file %s\n",cc);
          exit(1);
      }
      if((fp2=fopen(dd,"w+"))==NULL)
      {
          printf("Can&#39;t create the file %s.\n",dd);
          exit(1);
      }
      while((ch=fgetc(fp1))!=EOF)
      {
            for(i=0;i<strlen(bb);i++)    /*开始过滤特定的字符*/
            {
               if(bb[i]==ch)
               {
                  flag=1;
                  break;
               }
            }
            if(flag==1)
            {
               flag=0;
               continue;
            }
            else
            {
             if(!strcmp(aaa,"-b"))     /*转换成大写字母*/
             {
                    if(ch>=&#39;a&#39;&&ch<=&#39;z&#39;)
                    {
                        ch-=32;
                        fputc(ch,fp2);
                        ++count;
                    }
                    else if(ch==&#39;\n&#39;)
                        fputc(&#39;\n&#39;,fp2);
                    else
                    {
                        fputc(ch,fp2);
                        ++count;
                    }
               }
               if(!strcmp(aaa,"-s"))      /*转换成小写字母*/
               {
                    if(ch>=&#39;A&#39;&&ch<=&#39;Z&#39;)
                    {
                          ch+=32;
                         fputc(ch,fp2);
                         ++count;
                    }
                    else if(ch==&#39;\n&#39;)
                          fputc(&#39;\n&#39;,fp2);
                  else
                    {
                          fputc(ch,fp2);
                          ++count;
                 }
             }
         }
      }
      rewind(fp2);
      while((ch=fgetc(fp2))!=EOF)    /*计算密码个数*/
      {
            if(ch==&#39;\n&#39;)
              ++lenth;
      }
      fclose(fp1);
      fclose(fp2);
      printf("\nThe dic has %ld hang\n",lenth);
      printf("Done.Good Luck:)\n");
}

void defi(char *a,char *b,char *c,char *d)
{
   FILE *fp,*fp1;
   char *a1=a,*b1=b;
   char *c1=c,*d1=d;
   char ch;
   char ch1=&#39;\n&#39;;
   char line[M];
   char line1[M];
   char line2[M];
   
   if((fp=fopen(c1,"a+"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n",c1);
      exit(0);
   }
   fseek(fp,0L,2);
   if((ch=fgetc(fp))==&#39;\n&#39;)
   {
      fclose(fp);
   }
   else
   {
      fputc(ch1,fp);
      fclose(fp);
   }
   if((fp=fopen(c1,"r"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n",c1);
      exit(0);
   }
   if((fp1=fopen(d1,"w+"))==NULL)
   {
      printf("Can&#39;t open the file %s.\n",d1);
      exit(0);
   }
   while(fgets(line,512,fp)!=NULL)
   {
      if(strstr(line,a1)!=NULL)
      {
        find(line,a1,b1);
        fputs(line,fp1);
      }
      else
        fputs(line,fp1);
   }
   fclose(fp);
   fclose(fp1);
   printf("done.\n");
}

void find(char *a,char *b,char *c)
{
   char *sp=a,*cp=b,*p=c;
   char temp;
   char tp[M];
   char *p1=tp;
   int i=0,l=0;
   int j,k;
   int len;
   
   while(*sp)
   {
      j=0;
      temp=*(sp+i+j);
      while(*cp&&(temp==*(cp+j)))
      {
        temp=*(sp+i+ ++j);
      }
      if(*(cp+j)==&#39;\0&#39;)
      {
        printf("%s,%d\n","found",i);
        /*#define m 8*/
        /*printf("%d\n",m);*/
        k=i;
        len=k+strlen(cp);
        l=0;
        while(len<strlen(sp))
        {
           *(p1+l)=*(sp+len);
           l++;
           len++;
        }
        *(p1+l)=&#39;\0&#39;;
        l=0;
        while(l<strlen(p))
        {
           *(sp+k)=*(p+l);
           k++;
           l++;
        }
        l=0;
        while(l<strlen(p1))
        {
           *(sp+k)=*(p1+l);
           k++;
           l++;
        }
        *(sp+k)=&#39;\0&#39;;
        break;
      }
      i++;
   }
}

void help(void)
{
      printf("\n\t             SdiC <Protype 2.3>\n\n");
      printf("   Written by W.Z.T  <Don&#39;t be lazy,Just go ahead>  [url]http://tthacker.hackvip.cn[/url]\n\n");
      printf("hackdic.exe -m c:\\pass.dic 130 137 78511315 78511319\n");
      printf("        -t c:\\pass.dic 813 3935248 3932559\n");
      printf("                  1476 8442132 8442159\n");
      printf("        -b <h> c:\\pass.dic 1985 1 2 1989 1 2 1\n");
      printf("                       85 1 2 89 1 12 1\n");
      printf("        -d -s c:\\pass.txt 3 5\n");
      printf("          -b c:\\pass.txt 3 5\n");
      printf("          -n c:\\pass.txt 3 5\n");
      printf("          -sn c:\\pass.txt 3 5\n");
      printf("          -bn c:\\pass.txt 3 5\n");
      printf("          -sbn c:\\pass.txt 3 5\n");
      printf("          -sb c:\\pass.txt 3 5\n");
      printf("          -a c:\\pass.txt 3 5 75 99\n");
      printf("          ~!@#$% c:\\pass.txt 3 5\n");
      printf("        -a a.txt 1.txt 2.txt 3.txt.....\n");
      printf("        -c c.txt 1.txt 2.txt 3.txt.....\n");
      printf("        -ac -a sgl 1.txt 2.txt.\n");
      printf("           -c sgl 1.txt 2.txt.\n");
      printf("        -ca -a sgl 1.txt 2.txt.\n");
      printf("           -b sgl 1.txt 2.txt.\n");
      printf("        -u 1.txt 2.txt.\n");
      printf("        -g wangzhitong 1.txt 2.txt\n");
      printf("        -cc \";\" 2 1.txt 2.txt\n");
      printf("        -tt -b wangzhitong 1.txt 2.txt\n");
      printf("           -s wangzhitong 1.txt 2.txt\n");
      printf("        -v tthacker wangzhitong 1.txt 2.txt\n");
      printf("\n[optin--a]: -a add file and leave the different words.\n");
      printf("        -c cut file you want.\n");
      printf("        -ac -a add letters to file in the head.\n");
      printf("           -C add letters to file at the end.\n");
      printf("        -ca -a Cut letters from the head.\n");
      printf("           -b Cut letters from the end.\n");
      printf("        -u turn back.\n");
      printf("        -g leave the letters from the text.\n");
      printf("        -cc \n");
      printf("        -tt -b change into big letters.\n");
      printf("           -s change into small letters.\n");
      printf("\n[optin--b]: h=1,19850102\th=2,1985//0//02\n");
      printf("        h=3,1985:01:02\th=4,1985.01.02\n");
      printf("        h=5,1985-01-02\th=6,198512\n");
      printf("        h=7,1985//1//2\th=8,1985:1:2\n");
      printf("        h=9,1985.1.2\th=10,1985-1-2\n");
      printf("        h=11,1985\\1\\2\th=12,1985\\01\\02\n");
      exit(0);
}

附件

hackdic.rar (19 KB)

2005-8-9 20:48, 下载次数: 560

http://tthacker.sitesled.com

TOP

有问题。。。问题大大的。。。。

不是说你的代码逻辑上有错误。。。因为我没有通读你的代码。。即使有我也没发现。。。
但是别的问题确实应该提醒你注意了。。。。
首先,单行注释最好使用“//”来,不要使用“/*”,因为有的时候你很可能就忘记了将注释闭合。刚才pc逍遥鼠问我代码为什么编译不成功。。。我仔细一看原来你在main函数开始处声明那些自定义函数的时候acle函数后面的注释符你没有闭合,所以造成了下面的代码被认为成注释了。
如下:
char acle(char *,char *,char *,char *);    /*文件每行删除特定的字符串

所以错误就一连串的出来了。。。应该是这样就对了:
char acle(char *,char *,char *,char *);    /*文件每行删除特定的字符串*/
另外给你提个醒,一些变量如果在程序中根本就没用到的话就不要去定义它。习惯不好!
另外注意你的函数定义,是否有返回值请明确定义。不要定义的时候有返回值,但函数实现上却没有返回。。。

其它的有待其他朋友发现了
俺是mika!别叫错了! 俺的QQ:794773 http://hi.baidu.com/stealthwalker/ my private area ------------------------------------------------------------ <a href=http://hi.baidu.com/stealthwalker target=_blank></a>

TOP

其实简单的说就是代码前面的那些注释,把/*改成//就可以了,我也是无意中发现
本人正在学习C++编程,大家一定要照顾我

TOP

char acle(char *,char *,char *,char *);    /*文件每行删除特定的字符串*/后面是忘记结束了,向各位道歉了.俺写程序都不加注释的,放上来的时候就简单的加了注释,没想到....

"一些变量如果在程序中根本就没用到的话就不要去定义它。习惯不好!"  这的确是我程式的毛病.

"不是说你的代码逻辑上有错误。。。因为我没有通读你的代码。。即使有我也没发现。。。"

.........这好象是废话吧
http://tthacker.sitesled.com

TOP

提示: 作者被禁止或删除 内容自动屏蔽

TOP

这段代码楼主是在TC下编译成功的?
VC下是不可能编译成功的。错误满多的。
还有很多定义的变量没用到,我不知道你定义的干什么的。
还有就是无敌说的,你的函数没什么需要返回的就定义个void类型的吧,如果需要返回函数有没有成功执行定义成int或bool也可以啊,为什么要定义成char呢?不理解。。。。。
http://hi.baidu.com/fengze

TOP

虚心接受楼上的和无敌对我代码指出的不足,只有这样,我的编程水平才可以提高。事实上,我接触编程一年有两个月了,属于初学者,代码编写上还有很大的缺陷,还请各位高手对提出宝贵的意见^_^

代码是有C-free 3.5编译的,重新修改了
http://tthacker.sitesled.com

TOP

接触编程才一年多?佩服~~看来楼主的学习接受能力很强,而且编写欲望也强。
1年多能写出你拿出来的代码真的不容易,结构也比较清晰。
http://hi.baidu.com/fengze

TOP

以后要多向EST的大哥们学习,多谢风泽大哥给小第恢复信心,俺要继续努力~
http://tthacker.sitesled.com

TOP

刚才进来看了一下,代码已经经过修改,看起来应该比上次好,我下复制下来看看。
http://hi.baidu.com/fengze

TOP

生成的字典文件实在是太大了……几十GB都不够用……

TOP

这个会不会太大了,看来我还要继续的学了,向各个大哥学习
我不是忍者,但是永不言弃是我的忍道

TOP

引用:
这里是引用第[11 楼]xhxy5212006-06-26 11:49发表的:
这个会不会太大了,看来我还要继续的学了,向各个大哥学习
每个字典生成器都有穷举算法,我这个即有常规字典的功能,又字符串处理功能,所以你可以将很大的字典档按照你的意愿修改的很小。
http://tthacker.sitesled.com

TOP

发新话题