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 2022-10-18 09:04 会飞的鱼-blog 阅读(8) 评论(0) 编辑 收藏 举报 来源
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现