Authorization: Basic YWRtaW46YWRtaW4= 为登录的帐号密码。
使用 Base64 解密开查看内容:admin:admin
然后用软件将字典中的密码与“admin:”进行组合,然后进行 base64 加密,进行破解。
下面是加密算法:
#include
#include
#define HTTP_DATA_MAX_LEN 2048
#define MAX_CLIENT 8
typedef unsigned int size_t;
int listen_fd = -1;
int clientfd[MAX_CLIENT];
char *httpRequest;
static char userName[]="admin";
static char usrPassword[]="admin";
static char firmwareVersion[]="2.0";
static char *auth_str = NULL;
static const unsigned char base64_table[64] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
unsigned char * base64_encode(const unsigned char *src, int len,
int *out_len)
{
unsigned char *out, *pos;
const unsigned char *end, *in;
size_t olen;
int line_len;
olen = len * 4 / 3 + 4; /* 3-byte blocks to 4-byte */
olen += olen / 72; /* line feeds */
olen++; /* nul termination */
out = malloc(olen);
if (out == NULL)
return NULL;
end = src + len;
in = src;
pos = out;
line_len = 0;
while (end - in >= 3) {
*pos++ = base64_table[in[0] >> 2];
*pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
*pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
*pos++ = base64_table[in[2] & 0x3f];
in += 3;
line_len += 4;
if (line_len >= 72) {
*pos++ = '
';
line_len = 0;
}
}
if (end - in) {
*pos++ = base64_table[in[0] >> 2];
if (end - in == 1) {
*pos++ = base64_table[(in[0] & 0x03) << 4];
*pos++ = '=';
} else {
*pos++ = base64_table[((in[0] & 0x03) << 4) |
(in[1] >> 4)];
*pos++ = base64_table[(in[1] & 0x0f) << 2];
}
*pos++ = '=';
line_len += 4;
}
if (line_len)
*pos++ = '
';
*pos = '