暴力破解代码不是 运行

bruteforce-code is not running

我试着编写了一个小的暴力破解程序。但我无法编译它。我认为这是一个非常简单的程序代码,这就是为什么它如此困扰我以至于无法编译的原因。我搜索了解决方案,但无法找到一个富矿...

`1 #include <stdio.h>
 2 #include <string.h>
 3 char pass;
 4 strcpy(pass,"m");
 5 int pass_test(int argc, char *argv[]){
 6         char s_pass[2];
 7         argv[0] = s_pass;
 8         if (s_pass == pass){
 9                 printf("=================\n==Access gained==\n=================");
10 }               
11         else{
12                 printf("sth. went wrong");
13 }               
14 }
15 int main(){
16         char solved_pass[2];
17         char *OP_ABC;
18         int i, p, z;
19         strcpy(OP_ABC, "abcdefghijklmnopqrstuvwxyz");
20         if ((strlen(pass)) == 1){
21                 for(i=0;i < strlen(OP_ABC);i++){
22                         pass_test(OP_ABC[i]);
23 }                       
24 }
25         if (strlen(pass) == 2){
26                 for(p=0;p < strlen(OP_ABC);p++){
27                         for(z=0;z < strlen(OP_ABC);z++){
28                                 OP_ABC[p] = solved_pass[0];
29                                 OP_ABC[z] = solved_pass[1];
30                                 pass_test(solved_pass);
31 }                               
32 }               
33 }
34 }`

这是编译器所说的

bruteforce.c:4:13: error: expected ‘)’ before string constant bruteforce.c: In function ‘pass_test’: bruteforce.c:8:13: warning: comparison between pointer and integer [enabled by default] bruteforce.c: In function ‘main’: bruteforce.c:20:2: warning: passing argument 1 of ‘strlen’ makes pointer from integer without a cast [enabled by default] In file included from bruteforce.c:2:0: /usr/include/string.h:399:15: note: expected ‘const char *’ but argument is of type ‘char’ bruteforce.c:22:4: error: too few arguments to function ‘pass_test’ bruteforce.c:5:5: note: declared here bruteforce.c:25:2: warning: passing argument 1 of ‘strlen’ makes pointer from integer without a cast [enabled by default] In file included from bruteforce.c:2:0: /usr/include/string.h:399:15: note: expected ‘const char *’ but argument is of type ‘char’ bruteforce.c:30:5: warning: passing argument 1 of ‘pass_test’ makes integer from pointer without a cast [enabled by default] bruteforce.c:5:5: note: expected ‘int’ but argument is of type ‘char *’ bruteforce.c:30:5: error: too few arguments to function ‘pass_test’ bruteforce.c:5:5: note: declared here

有人可以帮我吗?

一个问题是你不能在全局范围内有语句或自由表达式。

另一个问题是 strcpy 函数需要一个 string(即 char*)作为目标,而不是单个 char .

您可以通过在一行中进行定义和初始化来解决这两个问题:

char pass = 'm';