[SNMP4J] Problem Receicing V3 traps - please help

Frank Fock fock at agentpp.com
Mon Aug 22 20:07:28 CEST 2005


Hi Scott,

Why do you try to decode each variables value? What are you trying to
accomplish?

SNMP4J does all the encryption and decryption that is part of the SNMPv3
standard.

Best regards,
Frank

Scott VanWart wrote:

>Hello,
>
> 
>
>I am using SNMP4J to receive V3 traps using MD5 and DES. I am able to
>accept the data and I can get up time from the device and the OID, but I
>cannot figure out how to decrypt the message being sent by the device.
>Below is my code, any suggestions would GREATLY appreciated as I have
>been stuck for some days now.
>
> 
>
> 
>
>public synchronized void processPdu(CommandResponderEvent e) 
>
>                        {
>
>                                    PDU command = e.getPDU();
>
>                                    Address source = e.getPeerAddress();
>
>                                    e.setProcessed(true);
>
>                                    String payload = "";
>
>                                    VariableBinding varBinding;
>
>                                    Variable var;
>
>                        
>
>                                    int length = command.size();
>
> 
>
>                                    
>
>                                    
>
>                                    for(int i = 0; i < length; i++)
>
>                                    {
>
>                                                varBinding =
>command.get(i);
>
>                                                var =
>varBinding.getVariable();
>
>                                                payload =
>var.toString();
>
>                                    //          logger.info("SNMP V3
>TRAp data:" + payload);
>
>                                    }
>
>                                    
>
>                                    
>
>                                    byte[] data = new
>byte[payload.length()];
>
>                                    byte[] ciphertext = null;
>
>                                    data = payload.getBytes();
>
>                                    byte[] result = null;
>
>                                    
>
>                                    try
>
>                                    {
>
>            
>
>                                                
>
>                                    
>
>                                                byte[] dec = new
>sun.misc.BASE64Decoder().decodeBuffer(payload);
>
>                                                
>
>                                                PrivDES des = new
>PrivDES();
>
>            
>
>                                                
>
>                                                UsmUserEntry user =
>snmp.getUSM().getUser(new OctetString("dragon-admin"), new
>OctetString("dragon-admin"));
>
>                                                byte[] key =
>user.getAuthenticationKey();
>
>                                                byte[] p = new
>byte[des.getDecryptParamsLength()];
>
>                                                DecryptParams params =
>new DecryptParams(p,0,des.getDecryptParamsLength());
>
>                                                long enginetime = 0;
>
>                                                long engineboots = 0;
>
>                                                
>
>                                                result =
>des.decrypt(dec,0,dec.length,key,engineboots,enginetime,params);
>
>                                                
>
> 
>
> 
>
> 
>
>Thanks,
>
>Scott
>
> 
>
>Scott Van Wart
>
>Software Engineer
>
>Direct: 506-462-9117
>
>Email: scott.vanwart at q1labs.com
>
>Q1 Labs Inc - The Nexus of Security and Networking
>
> 
>
> 
>
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
>  
>


-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com





More information about the SNMP4J mailing list