示例#1
0
 // Run Nonce Get
 private void btn6_Click(object sender, EventArgs e)
 {
     dump_DST_nodeid = textBox3.Text;
     dump_DST_nodeid = Regex.Replace(dump_DST_nodeid, " ", "");
     char[] buf = dump_DST_nodeid.ToCharArray();
     //byte[] real_dst = new byte[1];
     StringToHex.String_to_Hex(buf, real_dst_for_enc, buf.Length);
     Send_command.RunCommand_Nonsecurity(controller, real_dst_for_enc, nonce_get_command);
 }
示例#2
0
        // 4. Run command (non-security)
        private void btn4_Click(object sender, EventArgs e)
        {
            dump_DST_nodeid = textBox2.Text;
            dump_DST_nodeid = Regex.Replace(dump_DST_nodeid, " ", "");
            char[] buf      = dump_DST_nodeid.ToCharArray();
            byte[] real_dst = new byte[1];
            StringToHex.String_to_Hex(buf, real_dst, buf.Length);

            dump_command = textBox1.Text;
            dump_command = Regex.Replace(dump_command, " ", "");
            char[] buf1         = dump_command.ToCharArray();
            byte[] real_command = new byte[buf1.Length / 2];
            StringToHex.String_to_Hex(buf1, real_command, buf1.Length);

            dump_DST_nodeid = null;
            dump_command    = null;

            Send_command.RunCommand_Nonsecurity(controller, real_dst, real_command);
        }
示例#3
0
        // 5. Run command (S0, S2)
        private void btn5_Click(object sender, EventArgs e)
        {
            /*
             * dump_DST_nodeid = textBox3.Text;
             * dump_DST_nodeid = Regex.Replace(dump_DST_nodeid, " ", "");
             * char[] buf = dump_DST_nodeid.ToCharArray();
             * byte[] real_dst = new byte[1];
             * StringToHex.String_to_Hex(buf, real_dst, buf.Length);
             */

            dump_Network_Key = textBox4.Text;
            dump_Network_Key = Regex.Replace(dump_Network_Key, " ", "");
            char[] buf1    = dump_Network_Key.ToCharArray();
            byte[] real_Kn = new byte[16];
            StringToHex.String_to_Hex(buf1, real_Kn, buf1.Length);

            dump_command = textBox5.Text;
            dump_command = Regex.Replace(dump_command, " ", "");
            char[] buf2    = dump_command.ToCharArray();
            byte[] real_cm = new byte[buf2.Length / 2];
            StringToHex.String_to_Hex(buf2, real_cm, buf2.Length);

            dump_Nonce = textBox6.Text;
            dump_Nonce = Regex.Replace(dump_Nonce, " ", "");
            char[] buf3       = dump_Nonce.ToCharArray();
            byte[] real_nonce = new byte[8];
            StringToHex.String_to_Hex(buf3, real_nonce, buf3.Length);

            Send_command.RunCommand_Security(controller, real_dst_for_enc, real_cm, real_Kn, real_nonce);

            dump_DST_nodeid     = null;
            real_dst_for_enc[0] = 0;
            dump_Network_Key    = null;
            dump_command        = null;
            dump_Nonce          = null;
        }
示例#4
0
        //Dos Attack
        private void btn4_Click(object sender, EventArgs e)
        {
            dump_DST_nodeid = textBox2.Text;
            dump_DST_nodeid = Regex.Replace(dump_DST_nodeid, " ", "");
            char[] buf      = dump_DST_nodeid.ToCharArray();
            byte[] real_dst = new byte[1];
            StringToHex.String_to_Hex(buf, real_dst, buf.Length);

            dump_command = textBox1.Text;
            dump_command = Regex.Replace(dump_command, " ", "");
            char[] buf1         = dump_command.ToCharArray();
            byte[] real_command = new byte[buf1.Length / 2];
            StringToHex.String_to_Hex_For_Dos(buf1, real_command, buf1.Length);

            dump_DST_nodeid = null;
            dump_command    = null;

            if (real_command.Length < 40)
            {
                Send_command.RunCommand_Nonsecurity(controller, real_dst, real_command);
            }
            else
            {
                byte[] segment_complete = new byte[2];
                byte[] Seg_Command      = new byte[42];
                int    cnt = 0;
                int    len = real_command.Length;

                do
                {
                    if (cnt == 0) // first packet
                    {
                        Seg_Command[0] = First_Segment[0];
                        Seg_Command[1] = First_Segment[1];
                        // len = len - 40
                        for (int i = 0; i < 40; i++)
                        {
                            Seg_Command[i + 2] = real_command[i];
                        }
                        len = len - 40;
                        Send_command.RunCommand_Nonsecurity(controller, real_dst, Seg_Command);
                        Array.Clear(Seg_Command, 0, Seg_Command.Length);
                    }
                    else // subsequent packet
                    {
                        Seg_Command[0] = Subsequent_Segment[0];
                        Seg_Command[1] = Subsequent_Segment[1];

                        // 1) len >= 40
                        // 2) len < 40
                        if (len >= 40)
                        {
                            for (int i = 0; i < 40; i++)
                            {
                                Seg_Command[i + 2] = real_command[i + (cnt * 40)];
                            }
                            len = len - 40;
                            Send_command.RunCommand_Nonsecurity(controller, real_dst, Seg_Command);
                            Array.Clear(Seg_Command, 0, Seg_Command.Length);
                        }
                        else
                        {
                            byte[] Seg_Command2 = new byte[len + 2];
                            Seg_Command2[0] = Subsequent_Segment[0];
                            Seg_Command2[1] = Subsequent_Segment[1];
                            for (int i = 0; i < len; i++)
                            {
                                Seg_Command2[i + 2] = real_command[i + (cnt * 40)];
                            }
                            len = 0;
                            Send_command.RunCommand_Nonsecurity(controller, real_dst, Seg_Command2);
                            Array.Clear(Seg_Command2, 0, Seg_Command2.Length);
                        }
                    }
                    cnt++;
                } while (len != 0);
                segment_complete[0] = Segment_Complete[0];
                segment_complete[1] = Segment_Complete[1];
                Send_command.RunCommand_Nonsecurity(controller, real_dst, segment_complete);
                cnt = 0;
            }
        }