链接:http://www.shiyanbar.com/ctf/2020
下面是反汇编的源码:
#include <stdio.h>
#include<stdlib.h>
typedef struct list
{
int num;
char ch;
char no_use[3];
struct list *next;
} list;
list *global = NULL;
int exe(char *str)
{
int i;
int j;
int temp;
list *p_list;
int src[6];
int dst[] = {5, 2, 7, 2, 5, 6};
for (i = 0; i <= 5; ++i)
{
p_list = global;
temp = 0;
while (p_list != NULL)
{
if (p_list->ch == str[i])
{
temp = p_list->num;
break;
}
p_list = p_list->next;
}
src[i] = temp;
}
for (j = 0; j <= 5; ++j)
{
if (src[j] != dst[j])
{
return 1;
}
}
return 0;
}
int main()
{
char buf[16];
int i;
for (i = 1; i <= 10; ++i)
{
list *temp = (list *)malloc(sizeof(list));
temp->num = i;
temp->ch = i + 109;
temp->next = global;
global = temp;
}
printf("Enter the password: ");
if (!fgets(buf, 7, stdin))
{
return 0;
}
if (exe(buf))
{
puts("Incorrect password!");
}
else
{
puts("Nice!");
}
}