Set() public method

SNMP SET request
public Set ( SnmpVersion version, Pdu pdu ) : AsnType>.Dictionary
version SnmpVersion SNMP protocol version number. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
pdu Pdu Request Protocol Data Unit
return AsnType>.Dictionary
Esempio n. 1
0
        /// 
        /// <summary>
        /// Executes the installation process on the SNMP agent.
        /// </summary>
        /// <param name="ts">Target's settings</param>
        /// <param name="uploadFolder">Path of folder with exe update within it</param>
        /// <returns>True if installation was executed successfully</returns>
        public static bool setExecute(TargetSettings ts, string uploadFolder)
        {
            SimpleSnmp snmp = new SimpleSnmp(ts.TargetServer, ts.Community);

              if(!snmp.Valid)
              {
            return false;
              }

              string d = ts.DestinationFolder.Substring(1);
              int i = uploadFolder.LastIndexOf("\\") + 1;
              string relativePath = uploadFolder.Substring(i);
              string destination = d.Replace("/", "\\");
              string batFile = ts.RootPath + destination + relativePath + "\\UpdateVersion.bat";

              Dictionary<Oid, AsnType> result = snmp.Set(SnmpVersion.Ver2,
                                                    new Vb[] {
                                                    new Vb(new Oid("1.3.6.1.4.1.2566.127.1.1.157.3.1.1.10.0"),
                                                           new OctetString(batFile))});

              if(result != null)
              {
            return true;
              }
              return false;
        }
Esempio n. 2
0
       public bool SnmpSetTest(string host, string community, string oid,string octetStromg)
       {

           try
           {
               SimpleSnmp snmp = new SimpleSnmp(host, community);
               if (!snmp.Valid)
               {
                   return false;
               }
               Dictionary<Oid, AsnType> result = snmp.Set(SnmpVersion.Ver1,
                                                           new Vb[] { 
                                                    new Vb(new Oid(oid), 
                                                           new OctetString(octetStromg))
                                                    });
               if (result == null)
               {
                   return false;
               }

               LogResult(result);
               return true;
           }
           catch (Exception ex)
           {
               return false;
           }
       }
Esempio n. 3
0
    /// <summary>
    /// when button is clicked send the GoTo with the data from the input fields
    /// </summary>
    public void SetGoTo()
    {
        SimpleSnmp snmp = new SimpleSnmp(snmpAgent, 16100, snmpCommunity, 2000, 2);
        // Create a request Pdu
        Pdu pdu = new Pdu();
        pdu.Type = PduType.Set;
        //pdu.VbList.Add("1.3.6.1.2.1.1.1.0");

        pdu.VbList.Add(new Oid(baseTreeOid + ".3"), new Integer32(MoveToXInput));
        pdu.VbList.Add(new Oid(baseTreeOid + ".4"), new Integer32(MoveToYInput));

        PrintPacketSend(pdu);

        Dictionary<Oid, AsnType> result = snmp.Set(SnmpVersion.Ver1, pdu);
        //Debug.Log(result);
        //Dictionary<Oid, AsnType> result = snmp.GetNext(SnmpVersion.Ver1, pdu);
        if (result == null)
        {
            Debug.Log("Manager:Set failed.");
        }
			
    }
Esempio n. 4
0
    /// <summary>
    /// Send a SetRequest to the agent to start attacking
    /// </summary>
    /// <param name="selected"></param>
    public void SetAttacking(int selected)
    {
        String snmpAgent = "127.0.0.1";
        String snmpCommunity = "public";
        SimpleSnmp snmp = new SimpleSnmp(snmpAgent, 16100, snmpCommunity, 2000, 2);
        // Create a set Pdu
        Pdu pdu = new Pdu();
        pdu.Type = PduType.Set;

        pdu.VbList.Add(new Oid(baseTreeOid + ".16"), new Counter32((uint)selected));

        PrintPacketSend(pdu);

        Dictionary<Oid, AsnType> result = snmp.Set(SnmpVersion.Ver1, pdu);
        
        if (result == null)
        {
            Debug.Log("Manager:Set failed.");
        }
        else
        {
            foreach (KeyValuePair<Oid, AsnType> entry in result)
            {
                attacking = int.Parse(entry.Value.ToString());
            }
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Send a SetRequest to the agent to select a target
    /// </summary>
    /// <param name="selected"></param>
    public void SetTarget(int selected)
    {
        String snmpAgent = "127.0.0.1";
        String snmpCommunity = "public";
        SimpleSnmp snmp = new SimpleSnmp(snmpAgent, 16100, snmpCommunity, 2000, 2);
        // Create a set Pdu
        Pdu pdu = new Pdu();
        pdu.Type = PduType.Set;

        pdu.VbList.Add(new Oid(baseTreeOid + ".14"), new Counter32((uint)selected));

        PrintPacketSend(pdu);

        Dictionary<Oid, AsnType> result = snmp.Set(SnmpVersion.Ver1, pdu);

        if (result == null)
        {
            Debug.Log("Manager:Set failed.");
        }
        else
        {
            foreach (KeyValuePair<Oid, AsnType> entry in result)
            {
                selectedTarget = int.Parse(entry.Value.ToString());
            }
        }

        if(selected == 0)
        {
            Enemy1.transform.GetChild(1).gameObject.SetActive(true);
        }
        else
        {
            Enemy1.transform.GetChild(1).gameObject.SetActive(false);
        }

        if (selected == 1)
        {
            Enemy2.transform.GetChild(1).gameObject.SetActive(true);
        }
        else
        {
            Enemy2.transform.GetChild(1).gameObject.SetActive(false);
        }

        if (selected == 2)
        {
            Enemy3.transform.GetChild(1).gameObject.SetActive(true);
        }
        else
        {
            Enemy3.transform.GetChild(1).gameObject.SetActive(false);
        }
    }