Esempio n. 1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            //Add this computer to the auth list

            string             apiUrl    = "https://craig.im/infosec.php";
            string             apiMethod = "removeCPU";
            Computer_Authorise thisComputer_Authorise = new Computer_Authorise()
            {
                commonName = textBox1.Text,
            };

            // make http post request
            string response = Http.Post(apiUrl, new NameValueCollection()
            {
                { "api_method", apiMethod },
                { "api_data", JsonConvert.SerializeObject(thisComputer_Authorise) }
            });

            // decode json string to object
            API_Response r = JsonConvert.DeserializeObject <API_Response>(response);

            // check response
            if (!r.IsError)
            {
                MessageBox.Show("This machine has been removed successfully.");
                getAuthorisedMachines();
            }
            else
            {
                MessageBox.Show("ERROR: " + r.ErrorMessage);
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //get CPI ID
            string                     cpuInfo = string.Empty;
            ManagementClass            mc      = new ManagementClass("win32_processor");
            ManagementObjectCollection moc     = mc.GetInstances();

            foreach (ManagementObject mo in moc)
            {
                if (cpuInfo == "")
                {
                    //Get only the first CPU's ID
                    cpuInfo = mo.Properties["processorID"].Value.ToString();
                    break;
                }
            }


            //Add this computer to the auth list

            string             apiUrl    = "https://craig.im/infosec.php";
            string             apiMethod = "addCPU";
            Computer_Authorise thisComputer_Authorise = new Computer_Authorise()
            {
                commonName  = commonName.Text,
                processorID = cpuInfo
            };

            // make http post request
            string response = Http.Post(apiUrl, new NameValueCollection()
            {
                { "api_method", apiMethod },
                { "api_data", JsonConvert.SerializeObject(thisComputer_Authorise) }
            });

            // decode json string to object
            API_Response r = JsonConvert.DeserializeObject <API_Response>(response);

            // check response
            if (!r.IsError)
            {
                MessageBox.Show("This machine has been added successfully.");
                getAuthorisedMachines();
            }
            else
            {
                MessageBox.Show("ERROR: " + r.ErrorMessage);
            }
        }
Esempio n. 3
0
        private void getAuthorisedMachines()
        {
            //FOR LISTING AUTHORISED MACHINES
            Console.WriteLine("clearing all view list data");
            listView1.Clear();


            //GET DATA
            string             apiUrl    = "https://craig.im/infosec.php";
            string             apiMethod = "listCPU";
            Computer_Authorise thisComputer_Authorise = new Computer_Authorise()
            {
            };

            //Make http post request
            string response = Http.Post(apiUrl, new NameValueCollection()
            {
                { "api_method", apiMethod },
                { "api_data", JsonConvert.SerializeObject(thisComputer_Authorise) }
            });

            //Deserialise
            API_Response r = JsonConvert.DeserializeObject <API_Response>(response);

            //MessageBox.Show("" + r.ResponseData[0].commonName);

            // Set to details view.
            listView1.View = View.Details;
            // Add both columns.
            listView1.Columns.Add("CommonName", 200, HorizontalAlignment.Left);
            listView1.Columns.Add("ComputerID", 200, HorizontalAlignment.Left);

            //fill with data
            int lim = r.ResponseData.Length;

            Console.WriteLine("Beginning loop for data fill.");
            for (int i = 0; i <= (lim - 1); i++)
            {
                Console.WriteLine("This is loop number " + i);
                string[] row          = { r.ResponseData[i].commonName, r.ResponseData[i].processorID };
                var      listViewItem = new ListViewItem(row);
                listView1.Items.Add(listViewItem);
                row = null;
            }
        }