c - 对,我有这段代码,系统命令不断出现错误
问题描述
我正在尝试使用蛮力
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
while (i <= 999999 ) {
system("./lock", i);
i++;
}
printf("Error. Unable to crack file.\n");
return 0;
}
我试图将值“i”放入系统命令中,这样当我对我的文件运行它时,它就会得到 pin。但我不断收到系统命令错误,我希望它在 Linux 终端中运行。
像这样
./lock 1
./lock 2
./lock 3
etc.
但是,如果您知道一种检测它是否已被破解的方法,请同时添加。如果你可以的话。
解决方案
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 0;
while (i <= 999999 )
{
char cmd[100];
sprintf(cmd, "./lock %d", i);
if (system(cmd) == 0)
{
printf("Success with i = %d\n", i);
exit(0);
}
++i;
}
return !printf("Error. Unable to crack file.\n");
}
推荐阅读
- matlab - 我在哪里使用工具箱?
- android - 是否可以使用微调器实现 Exposed Dropdown Menus
- openai-gym - action_space 是干什么用的?
- c# - 我有 265,467 行和 500 列数据。用户应该能够使用 angular 和 c# 以 excel 格式下载这些数据
- mysql - 查询同一日期之间的数据
- node.js - 在 Angular 页面上使用不同的服务器
- python - h5py.File 函数为 mpi4py 抛出 NameError
- spring - 覆盖 Spring Data REST 中的相关链接
- sql-server - 您可以使用 JDBC 创建从 SQL Server 到 DB2 的链接服务器吗?
- java - 从使用反射获得的 RecyclerView 调用方法