fqy131314

C++——循环的经典应用

client.cpp

#include  <iostream>

#include  <Windows.h>

#include <string>

using namespace std;

int main (void){

       string pwd;

      

       while (1) {

              cout << "Please input your password: ";

              cin >> pwd;

             

              if (pwd == "000123") {

                     break;

              } else {

                     cout << "Password error." << endl;

              }

       }

      

       cout << "login success" << endl;

       cout << "1. 注册" << endl;

       cout << "2. 管理" << endl;

       cout << "3. 查询" << endl;

       cout << "4. 删除" << endl;

       system("pause");

       return 0;

}

crack.cpp

#include <iostream>

using namespace std;

int main(void) {

         char pwd[7];

         char dict[64]; //10+26+26+1 = 63;

         char tmp[32];

         int index = 0;

        

         for (int i=0; i<10; i++) {

                  dict[index++] = '0' + i;

         }

        

         /*

         for (int i=0; i<26; i++) {

                  dict[index++] = 'a' + i;

         }

        

         for (int i=0; i<26; i++) {

                  dict[index++] = 'A' + i;

         }

        

         dict[index++] = '_';

         */

                          

         dict[index] = '\0';

         int n = index; // 字符个数

        

         for (int p1=0; p1<n; p1++) {

                  for (int p2=0; p2<n; p2++) {

                           for (int p3=0; p3<n; p3++) {

                                    for(int p4=0; p4<n; p4++) {

                                             for(int p5=0; p5<n; p5++){

                                                      for (int p6=0; p6<n; p6++) {

                                                               tmp[0] = dict[p1];

                                                               tmp[1] = dict[p2];

                                                               tmp[2] = dict[p3];

                                                               tmp[3] = dict[p4];

                                                               tmp[4] = dict[p5];

                                                               tmp[5] = dict[p6];

                                                               tmp[6] = '\0';

                                                               cout << tmp << endl;

                                                      }

                                             }

                                    }

                           }

                  }

         }

        

         return 0;

}

在控制台:

crack.exe  |  client.exe

posted on   会飞的鱼-blog  阅读(8)  评论(0编辑  收藏  举报  

相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示