Ejemplo n.º 1
0
        private void createShellcode_BT_Click(object sender, EventArgs e)
        {
            byte[] shellcode;
            string insertedShellcode = createShellcode_RTB.Text;
            bool   metaSploit        = false;
            int    offset            = 0;

            shellcode_RTB.Clear();
            insertedShellcode = insertedShellcode.Replace("\\x", string.Empty);
            insertedShellcode = insertedShellcode.Replace("0x", string.Empty);
            insertedShellcode = insertedShellcode.Replace(", ", string.Empty);
            insertedShellcode = insertedShellcode.Replace("\n", string.Empty);
            insertedShellcode = System.Text.RegularExpressions.Regex.Replace(insertedShellcode, @"\W+", "");
            shellcode         = new byte[insertedShellcode.Length];

            try
            {
                for (int i = 0; i < insertedShellcode.Length; i += 2)
                {
                    shellcode[i / 2] = Convert.ToByte(insertedShellcode.Substring(i, 2), 16);
                }
                if (payloads_LB.SelectedIndex == -1 && metaSploit_LB.SelectedIndex == -1)
                {
                    return;
                }
                else if (payloads_LB.SelectedIndex == -1)
                {
                    metaSploit = true;
                }
                else
                {
                    metaSploit = false;
                }

                //remove those tailing 0's
                int lastIndex = Array.FindLastIndex(shellcode, b => b != 0);
                Array.Resize(ref shellcode, lastIndex + 1);
            }
            catch
            {
                shellcode_RTB.AppendText("Invalid shellcode detected. Only use shellcode in the form of \n\"\\x##\" \n\"0x##\" \n##\n Shellcode must have 0x##, assembler does not support 0x# operands");
                return;
            }

            try
            {
                offset = Convert.ToInt32(hookOffset_TB.Text);
            }
            catch
            {
                shellcode_RTB.AppendText("Payload hook offset not in the correct format.\n Please make it a value. -1 means there is none");
                return;
            }

            dataBox newPayload = new dataBox(payloadName_TB.Text, shellcode, offset);

            if (metaSploit)
            {
                metaSploit_LB.Items.Add(newPayload);
            }
            else
            {
                payloads_LB.Items.Add(newPayload);
            }
        }
Ejemplo n.º 2
0
        private void createShellcode_BT_Click(object sender, EventArgs e)
        {
            byte[] shellcode;
            string insertedShellcode = createShellcode_RTB.Text;
            bool metaSploit = false;
            int offset = 0;
            shellcode_RTB.Clear();
            insertedShellcode = insertedShellcode.Replace("\\x", string.Empty);
            insertedShellcode = insertedShellcode.Replace("0x", string.Empty);
            insertedShellcode = insertedShellcode.Replace(", ", string.Empty);
            insertedShellcode = insertedShellcode.Replace("\n", string.Empty);
            insertedShellcode = System.Text.RegularExpressions.Regex.Replace(insertedShellcode, @"\W+", "");
            shellcode = new byte[insertedShellcode.Length];

            try
            {
                for (int i = 0; i < insertedShellcode.Length; i += 2)
                    shellcode[i / 2] = Convert.ToByte(insertedShellcode.Substring(i, 2), 16);
                if (payloads_LB.SelectedIndex == -1 && metaSploit_LB.SelectedIndex == -1)
                    return;
                else if (payloads_LB.SelectedIndex == -1)
                    metaSploit = true;
                else
                    metaSploit = false;

                //remove those tailing 0's
                int lastIndex = Array.FindLastIndex(shellcode, b => b != 0);
                Array.Resize(ref shellcode, lastIndex + 1);
            }
            catch
            {
                shellcode_RTB.AppendText("Invalid shellcode detected. Only use shellcode in the form of \n\"\\x##\" \n\"0x##\" \n##\n Shellcode must have 0x##, assembler does not support 0x# operands");
                return;
            }

            try
            {
                offset = Convert.ToInt32(hookOffset_TB.Text);
            }
            catch
            {
                shellcode_RTB.AppendText("Payload hook offset not in the correct format.\n Please make it a value. -1 means there is none");
                return;
            }

            dataBox newPayload = new dataBox(payloadName_TB.Text, shellcode, offset);

            if (metaSploit)
            {
                metaSploit_LB.Items.Add(newPayload);
            }
            else
                payloads_LB.Items.Add(newPayload);
        }