OpenVAS Scanner
7.0.0~git
|
Go to the source code of this file.
◆ MD4_DIGEST_LENGTH
#define MD4_DIGEST_LENGTH 16 |
◆ nasl_cipher_des()
◆ nasl_get_password()
◆ nasl_get_sign()
Definition at line 246 of file nasl_crypto.c.
252 if (mac_key == NULL || buf == NULL || buflen == -1 || seq_num <= -1)
254 nasl_perror (lexic,
"Syntax : get_signature(key:<k>, buf:<b>, "
255 "buflen:<bl>, seq_number:<s>)\n");
258 uint8_t calc_md5_mac[16];
261 memcpy (buf + 18, calc_md5_mac, 8);
262 char *ret = g_malloc0 (buflen);
263 memcpy (ret, buf, buflen);
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), nasl_perror(), simple_packet_signature_ntlmssp(), TC::size, TC::str_val, and TC::x.
◆ nasl_get_smb2_sign()
Definition at line 571 of file nasl_crypto.c.
573 void *key, *buf, *signature, *ret;
581 if (!key || !buf || keylen <= 0)
583 nasl_perror (lexic,
"Syntax : get_smb2_signature(buf:<b>, key:<k>)");
588 nasl_perror (lexic,
"get_smb2_sign: Buffer length < 64");
593 memset ((
char *) buf + 48, 0, 16);
594 signature =
hmac_sha256 (key, keylen, buf, buflen);
597 ret = g_malloc0 (buflen);
598 memcpy (ret, buf, buflen);
599 memcpy ((
char *) ret + 48, signature, 16);
References alloc_typed_cell(), CONST_DATA, get_str_var_by_name(), get_var_size_by_name(), hmac_sha256(), nasl_perror(), TC::size, TC::str_val, and TC::x.
◆ nasl_hmac_dss()
◆ nasl_hmac_md2()
◆ nasl_hmac_md5()
◆ nasl_hmac_ripemd160()
◆ nasl_hmac_sha1()
◆ nasl_hmac_sha256()
Definition at line 349 of file nasl_crypto.c.
351 void *key, *data, *signature;
359 if (!key || !data || keylen <= 0 || datalen <= 0)
361 nasl_perror (lexic,
"Syntax : hmac_sha256(data:<b>, key:<k>)\n");
364 signature =
hmac_sha256 (key, keylen, data, datalen);
368 retc->
x.
str_val = (
char *) signature;
References alloc_typed_cell(), CONST_DATA, get_str_var_by_name(), get_var_size_by_name(), hmac_sha256(), nasl_perror(), TC::size, TC::str_val, and TC::x.
◆ nasl_hmac_sha384()
◆ nasl_hmac_sha512()
◆ nasl_insert_hexzeros()
Definition at line 835 of file nasl_crypto.c.
844 if (in_len < 0 || in == NULL)
846 nasl_perror (lexic,
"Syntax : insert_hexzeros(in:<i>)\n");
850 byte_len =
sizeof (
smb_ucs2_t) * (strlen ((
char *) in) + 1);
851 out = g_malloc0 (byte_len);
855 for (i = 0; i < in_len; i++)
866 byte_len = byte_len - 2;
869 retc->
size = byte_len;
References alloc_typed_cell(), CONST_DATA, get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), TC::size, TC::str_val, uchar, val, and TC::x.
◆ nasl_keyexchg()
Definition at line 725 of file nasl_crypto.c.
729 unsigned char *nt_hash =
732 if (cryptkey == NULL || session_key == NULL || nt_hash == NULL)
736 "Syntax : key_exchange(cryptkey:<c>, session_key:<s>, nt_hash:<n> )\n");
739 uint8_t new_sess_key[16];
741 uint8_t *encrypted_session_key = NULL;
743 session_key, cryptkey, nt_hash, (uint8_t *) &new_sess_key);
745 char *ret = g_malloc0 (len);
746 memcpy (ret, new_sess_key, 16);
747 memcpy (ret + 16, encrypted_session_key, 16);
References alloc_typed_cell(), CONST_DATA, get_str_var_by_name(), nasl_perror(), ntlmssp_genauth_keyexchg(), TC::size, TC::str_val, and TC::x.
◆ nasl_lm_owf_gen()
Definition at line 806 of file nasl_crypto.c.
815 if (pass_len < 0 || pass == NULL)
817 nasl_perror (lexic,
"Syntax : nt_lm_gen(password:<p>)\n");
821 bzero (pwd,
sizeof (pwd));
822 strncpy ((
char *) pwd, pass,
sizeof (pwd) - 1);
823 for (i = 0; i <
sizeof (pwd); i++)
824 pwd[i] = toupper (pwd[i]);
830 retc->
x.
str_val = g_memdup (p16, 16);
References alloc_typed_cell(), CONST_DATA, E_P16(), get_str_var_by_num(), get_var_size_by_num(), nasl_perror(), TC::size, TC::str_val, uchar, and TC::x.
◆ nasl_md2()
◆ nasl_md4()
◆ nasl_md5()
◆ nasl_nt_owf_gen()
◆ nasl_ntlm2_response()
Definition at line 652 of file nasl_crypto.c.
660 if (!cryptkey || !password || !nt_hash || hash_len < 16)
662 nasl_perror (lexic,
"Syntax : ntlm2_response(cryptkey:<c>, password:<p>, "
663 "nt_hash:<n[16]>)\n");
667 uint8_t lm_response[24];
668 uint8_t nt_response[24];
669 uint8_t session_key[16];
673 session_key, cryptkey, nt_hash);
674 int len =
sizeof (lm_response) +
sizeof (nt_response) +
sizeof (session_key);
675 char *ret = g_malloc0 (len);
676 memcpy (ret, lm_response,
sizeof (lm_response));
677 memcpy (ret +
sizeof (lm_response), nt_response,
sizeof (nt_response));
678 memcpy (ret +
sizeof (lm_response) +
sizeof (nt_response), session_key,
679 sizeof (session_key));
References alloc_typed_cell(), CONST_DATA, get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), ntlmssp_genauth_ntlm2(), TC::size, TC::str_val, and TC::x.
◆ nasl_ntlm_response()
Definition at line 687 of file nasl_crypto.c.
696 if (!cryptkey || !password || !nt_hash || hash_len < 16 || neg_flags < 0)
698 nasl_perror (lexic,
"Syntax : ntlm_response(cryptkey:<c>, password:<p>, "
699 "nt_hash:<n[16]>, neg_flags:<nf>)\n");
703 uint8_t lm_response[24];
704 uint8_t nt_response[24];
705 uint8_t session_key[16];
710 session_key, cryptkey, nt_hash, neg_flags);
712 int len =
sizeof (lm_response) +
sizeof (nt_response) +
sizeof (session_key);
713 char *ret = g_malloc0 (len);
714 memcpy (ret, lm_response,
sizeof (lm_response));
715 memcpy (ret +
sizeof (lm_response), nt_response,
sizeof (nt_response));
716 memcpy (ret +
sizeof (lm_response) +
sizeof (nt_response), session_key,
717 sizeof (session_key));
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), ntlmssp_genauth_ntlm(), TC::size, TC::str_val, and TC::x.
◆ nasl_ntlmv1_hash()
Definition at line 755 of file nasl_crypto.c.
760 unsigned char p21[21];
764 if (cryptkey == NULL || password == NULL)
766 nasl_perror (lexic,
"Syntax : ntlmv1_hash(cryptkey:<c>, passhash:<p>)\n");
773 bzero (p21,
sizeof (p21));
774 memcpy (p21, password, pass_len);
776 ret = g_malloc0 (24);
778 E_P24 (p21, cryptkey, ret);
References alloc_typed_cell(), CONST_DATA, E_P24(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), TC::size, TC::str_val, uchar, and TC::x.
◆ nasl_ntlmv2_hash()
Definition at line 963 of file nasl_crypto.c.
971 unsigned char ntlmv2_response[16];
972 unsigned char *ntlmv2_client_data = NULL;
973 unsigned char *final_response;
976 if (sc_len < 0 || server_chal == NULL || hash_len < 0 || ntlm_v2_hash == NULL
977 || client_chal_length < 0)
981 "Syntax : ntlmv2_hash(cryptkey:<c>, passhash:<p>, length:<l>)\n");
988 ntlmv2_client_data = g_malloc0 (client_chal_length);
989 for (i = 0; i < client_chal_length; i++)
990 ntlmv2_client_data[i] = rand () % 256;
992 assert (hash_len == 16);
995 client_chal_length, ntlmv2_response);
998 final_response = g_malloc0 (client_chal_length +
sizeof (ntlmv2_response));
999 memcpy (final_response, ntlmv2_response,
sizeof (ntlmv2_response));
1002 memcpy (final_response +
sizeof (ntlmv2_response), ntlmv2_client_data,
1003 client_chal_length);
1005 g_free (ntlmv2_client_data);
1008 retc->
size = client_chal_length +
sizeof (ntlmv2_response);
1009 retc->
x.
str_val = (
char *) final_response;
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), TC::size, SMBOWFencrypt_ntv2_ntlmssp(), TC::str_val, uchar, and TC::x.
◆ nasl_ntlmv2_response()
Definition at line 608 of file nasl_crypto.c.
613 unsigned char *ntlmv2_hash =
618 if (cryptkey == NULL || user == NULL || domain == NULL || ntlmv2_hash == NULL
619 || address_list == NULL || address_list_len < 0)
622 lexic,
"Syntax : ntlmv2_response(cryptkey:<c>, user:<u>, domain:<d>, "
623 "ntlmv2_hash:<n>, address_list:<a>, address_list_len:<len>)\n");
626 uint8_t lm_response[24];
627 uint8_t nt_response[16 + 28 + address_list_len];
628 uint8_t session_key[16];
629 bzero (lm_response,
sizeof (lm_response));
630 bzero (nt_response,
sizeof (nt_response));
631 bzero (session_key,
sizeof (session_key));
634 cryptkey, lm_response, nt_response, session_key,
637 int lm_response_len = 24;
638 int nt_response_len = 16 + 28 + address_list_len;
639 int len = lm_response_len + nt_response_len +
sizeof (session_key);
640 char *ret = g_malloc0 (len);
641 memcpy (ret, lm_response, lm_response_len);
642 memcpy (ret + lm_response_len, session_key,
sizeof (session_key));
643 memcpy (ret + lm_response_len +
sizeof (session_key), nt_response,
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), nasl_perror(), ntlmssp_genauth_ntlmv2(), TC::size, TC::str_val, and TC::x.
◆ nasl_ntv2_owf_gen()
Definition at line 876 of file nasl_crypto.c.
884 char *src_user, *src_domain;
888 size_t user_byte_len;
889 size_t domain_byte_len;
894 if (owf_in_len < 0 || owf_in == NULL || user_in_len < 0 || user_in == NULL
895 || domain_len < 0 || domain_in == NULL)
898 "Syntax : ntv2_owf_gen(owf:<o>, login:<l>, domain:<d>)\n");
902 assert (owf_in_len == 16);
904 user_byte_len =
sizeof (
smb_ucs2_t) * (strlen (user_in) + 1);
905 user = g_malloc0 (user_byte_len);
909 for (i = 0; i < user_in_len; i++)
911 val_user = *src_user;
912 *dst_user = val_user;
919 domain_byte_len =
sizeof (
smb_ucs2_t) * (strlen (domain_in) + 1);
920 domain = g_malloc0 (domain_byte_len);
922 src_domain = domain_in;
924 for (i = 0; i < domain_len; i++)
926 val_domain = *src_domain;
927 *dst_domain = val_domain;
938 assert (user_byte_len >= 2);
939 assert (domain_byte_len >= 2);
942 user_byte_len = user_byte_len - 2;
943 domain_byte_len = domain_byte_len - 2;
945 kr_buf = g_malloc0 (16);
949 hmac_md5_update ((
const unsigned char *) domain, domain_byte_len, &ctx);
References alloc_typed_cell(), CONST_DATA, get_str_var_by_name(), get_var_size_by_name(), hmac_md5_final(), hmac_md5_init_limK_to_64(), hmac_md5_update(), nasl_perror(), TC::size, TC::str_val, strupper_w(), uchar, and TC::x.
◆ nasl_prf_sha256()
◆ nasl_prf_sha384()
◆ nasl_ripemd160()
◆ nasl_sha()
◆ nasl_sha1()
◆ nasl_sha256()
◆ nasl_tls1_prf()
void E_P24(const uchar *p21, const uchar *c8, uchar *p24)
int get_var_size_by_name(lex_ctxt *, const char *)
static tree_cell * nasl_cipher(int algorithm, void *data, size_t dlen, void *key, size_t klen)
uint8_t * ntlmssp_genauth_keyexchg(uint8_t *session_key, char *challenge_data, unsigned char *nt_hash, uint8_t *new_sess_key)
void E_P16(uchar *p14, uchar *p16)
char * get_str_var_by_name(lex_ctxt *, const char *)
void hmac_md5_init_limK_to_64(const uchar *key, int key_len, HMACMD5Context *ctx)
The microsoft version of hmac_md5 initialisation.
void nasl_perror(lex_ctxt *lexic, char *msg,...)
void SMBOWFencrypt_ntv2_ntlmssp(const uchar kr[16], const uint8_t *srv_chal, int srv_chal_len, const uint8_t *cli_chal, int cli_chal_len, uchar resp_buf[16])
static tree_cell * nasl_hash(lex_ctxt *lexic, int algorithm)
int strupper_w(smb_ucs2_t *s)
void hmac_md5_update(const uchar *text, int text_len, HMACMD5Context *ctx)
Update hmac_md5 "inner" buffer.
long int get_int_var_by_name(lex_ctxt *, const char *, int)
char * get_str_var_by_num(lex_ctxt *, int)
void ntlmssp_genauth_ntlm2(char *password, uint8_t pass_len, uint8_t *lm_response, uint8_t *nt_response, uint8_t *session_key, char *challenge_data, unsigned char *nt_hash)
static tree_cell * nasl_gcrypt_hash(lex_ctxt *lexic, int algorithm, void *data, size_t datalen, void *key, size_t keylen)
void ntlmssp_genauth_ntlm(char *password, uint8_t pass_len, uint8_t *lm_response, uint8_t *nt_response, uint8_t *session_key, char *challenge_data, unsigned char *nt_hash, int neg_flags)
void hmac_md5_final(uchar *digest, HMACMD5Context *ctx)
Finish off hmac_md5 "inner" buffer and generate outer one.
int get_var_size_by_num(lex_ctxt *, int)
void simple_packet_signature_ntlmssp(uint8_t *mac_key, const uchar *buf, uint32 seq_number, unsigned char *calc_md5_mac)
static void * hmac_sha256(const void *key, int keylen, const void *buf, int buflen)
static tree_cell * nasl_prf(lex_ctxt *lexic, int hmac)
static tree_cell * nasl_hmac(lex_ctxt *lexic, int algorithm)
tree_cell * alloc_typed_cell(int typ)
void ntlmssp_genauth_ntlmv2(char *user, char *domain, char *address_list, int address_list_len, char *challenge_data, uint8_t *lm_response, uint8_t *nt_response, uint8_t *session_key, unsigned char *ntlmv2_hash)