我正在尝试向目标linux计算机发送一个snmptrap,并且它正在接收该陷阱但无法对其进行身份验证的目标计算机。
0560: F5 58 7C AE AF BB F7 F3 08 8E C3 29 97 F1 F6 3F .X|........)...?
0576: 9F 3D 06 CF 95 A2 39 36 CD 78 18 AD .=....96.x..
Authentication failed for doit
这是目标计算机的snmptrapf.conf,
createUser -e 0x00002E390000005056877fb3 doit MD5 'doitpassword' DES 'doitpassword'
authuser log,execute doit
这是发送陷阱的net-snmp代码
session.securityEngineID = (u_char *)engineID;
session.securityEngineIDLen = 12;
session.contextEngineID = (u_char *)engineID;
session.contextEngineIDLen = 12;
session.engineTime = 0;
session.securityLevel = securityOpt;
session.securityAuthProto = usmHMACMD5AuthProtocol;
session.securityAuthProtoLen = USM_AUTH_PROTO_MD5_LEN;
session.securityAuthKeyLen = USM_AUTH_KU_LEN;
log_error("Password [%d]", password);
if (session.securityLevel == SNMP_SEC_LEVEL_AUTHNOPRIV) {
error_code = generate_Ku(session.securityAuthProto,
session.securityAuthProtoLen,
(u_char *) password, strlen(password),
session.securityAuthKey,
&(session.securityAuthKeyLen));
if (error_code != SNMPERR_SUCCESS) {
log_error("Error generating user key from authentication passphrase. Error code [%d]", error_code);
}
} else if (session.securityLevel == SNMP_SEC_LEVEL_AUTHPRIV) {
session.securityPrivProto = usmDESPrivProtocol;
session.securityPrivProtoLen = USM_PRIV_PROTO_DES_LEN;
session.securityPrivKeyLen = USM_PRIV_KU_LEN;
error_code = generate_Ku(session.securityAuthProto,
session.securityAuthProtoLen,
(u_char *) password, strlen(password),
session.securityPrivKey,
&(session.securityPrivKeyLen));
if (error_code != SNMPERR_SUCCESS) {
log_error("Error generating user key from private passphrase. Error code [%d]", error_code);
}
}