不知道大家是否还记得之前的红包游戏。
这一次新年, 我又做了个简单的红包。
这一次, 需要玩家连接到一个ssh, 然后根据提示进行操作:
给出的提示就是: 输入正确的红包口令(支付宝的口令红包, 6位), 你就可以得到正确的红包口令。
比如:
另外还提供了源代码:
#include "hb.h" // HB_KEY is defined in this file.
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
struct hb_info
{
char key[7], hb_key[7];
};
bool my_cmp(const char *a, const char *b)
{
for (int i = 0; i < 6; ++i)
{
if (a[i] != b[i])
return false;
}
return true;
}
void debug_print(const char *a)
{
for (int i = 0; i < 6; ++i)
{
printf("%x ", a[i]);
}
printf("\n");
}
int main()
{
struct hb_info info;
strcpy(info.hb_key, HB_KEY);
printf("Please enter the key: ");
scanf("%s", info.key);
usleep(500 * 1000);
if (my_cmp(info.key, info.hb_key))
{
printf("correct, hb_key is %s.\n", HB_KEY);
}
else
{
printf("sorry.\n");
}
return 0;
}
容易看出其中的缓冲区溢出漏洞(没有检查长度), 于是输入11111111111111即可获得正确的红包密码。
iceboy说, 可能可以获取shell。




发表评论