我正在尝试使用WebNms AdventNet API开发MD5 + DES
陷阱接收器。
如果我使用身份验证和隐私选项(engineID
),我需要知道发送陷阱的代理的engineID
为了解密陷阱内容。如何动态获取此engineID
(不在我的应用程序中对其进行硬编码)?
I saw that it's possible to perform a discovery of the engineID
但为了实现这一点,我需要在发送陷阱时提供代理使用的端口(并且代理是使用随机源端口的真实网络元素)。
以下代码正常运行,但我对engineID
进行了硬编码。
是否有不同的方法来解密陷阱而不对public class DragosApp2 implements SnmpClient{
public static void main(String[] args) throws SnmpException {
SnmpAPI api = new SnmpAPI();
SnmpEngineEntry snmpEntry = new SnmpEngineEntry("10.10.66.79");
SnmpEngineTable engineTable = api.getSnmpEngine();
engineTable.addEntry(snmpEntry);
SnmpSession session = new SnmpSession(api);
session.addSnmpClient(new DragosApp2());
UDPProtocolOptions ses_opt = new UDPProtocolOptions();
ses_opt.setLocalPort(162);
session.setProtocolOptions(ses_opt);
session.open();
byte[] engineID = gethexValue("0x80001f888026f9036957333c81"); // HOW can I replace this part??
USMUserEntry user = new USMUserEntry(new String("dragos3").getBytes(), engineID);
user.setAuthProtocol(USMUserEntry.MD5_AUTH);
user.setPrivProtocol(USMUserEntry.CBC_DES);
byte[] authKey = USMUtils.password_to_key(USMUserEntry.MD5_AUTH,
new String("12345678").getBytes(),
new String("12345678").getBytes().length,
engineID);
byte[] privKey = USMUtils.password_to_key(USMUserEntry.MD5_AUTH,
new String("12345678").getBytes(),
new String("12345678").getBytes().length,
engineID,
USMUserEntry.CBC_DES);
user.setAuthPassword(new String("12345678").getBytes());
user.setPrivPassword(new String("12345678").getBytes());
user.setAuthKey(authKey);
user.setPrivKey(privKey);
user.setSecurityLevel((byte)3);
user.setEngineEntry(snmpEntry);
USMUserTable uut = (USMUserTable)api.getSecurityProvider().getTable(3);
uut.addEntry(user);
}
}
进行硬编码?
const userSchema = new Schema({
username: {type: String, unique: true},
first_name: String,
middle_name: String,
first_surname: String,
second_surname: String,
email: String,
password: String
}, {
timestamps: {createdAt: 'created_at', updatedAt: 'updated_at', deleteAt: 'delete_at'}
});
const UserModel = mongoose.model('user', userSchema);