lundi 17 décembre 2012

ASM ShellCode Generator C#

 This is asm shellcode generator



it simply reads the bytes of a file and then convert it into shellcode and generate an output asm file


using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.Transparent;

        }
        
        // INITIALISATION DES VARIABLES
        public string openfile { get; set; }
        public byte[] ReadFile { get; set; }
        private string ShellCodeModing;
        public string[] ShellCodeModinga { get; set; }
        public string reaDingFile { get; set; }

        static string ConvertStringArrayToString(string[] array)
        {
            //
            // Concatenate all the elements into a StringBuilder.
            //
            StringBuilder builder = new StringBuilder();
            foreach (string value in array)
            {
                builder.Append(value);
                builder.Append("h,");
            }
            return builder.ToString();
        }

        private static string AppendAtPosition(string baseString, int position, string character)
        {
            var sb = new StringBuilder(baseString);
            for (int i = position; i < sb.Length; i += (position + character.Length))
                sb.Insert(i, character);
            return sb.ToString();
        }



        private void button1_Click(object sender, EventArgs e)
        {
          
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                openfile = openFileDialog1.FileName; // Recuperer le chemin du fichier ouvert
                
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            ReadFile = File.ReadAllBytes(openfile); // Lecture du fichier dans la variable

            // Donnée binaires en string et affichage dans la textbox

            // SHELLCODE MODING

            ShellCodeModing = BitConverter.ToString(ReadFile); // HEX TO STRING
            // Si vous vouler crypter le shellcode c'est içi ou juste au dessus selon si vous voulez une string ou des bytes...

            ShellCodeModinga = ShellCodeModing.Split('-'); // SUPRESSION DU " - "
            ShellCodeModing = ConvertStringArrayToString(ShellCodeModinga); // RE STRING




            // toute les 15, de fait une nouvelle ligne
            StringBuilder sb = new StringBuilder();
            string[] splitString = ShellCodeModing.Split(',');
            for (int idx = 0; idx < splitString.Length; idx++)
            {
                sb.Append(splitString[idx] + ",");
                if (idx > 0 && idx % 15 == 0)
                {
                    sb.Append("\n");
                }
            }
            string ShellCodeModingb = sb.ToString();


            // Finalisation

            ShellCodeModingb = ShellCodeModingb.Replace(",\n", "\n db ");
            ShellCodeModingb = ShellCodeModingb.Replace(",", ",0");
            ShellCodeModingb = ShellCodeModingb.Replace("db ", "db 0");

            
            //ShellCodeModingb = ShellCodeModingb.Remove(ShellCodeModingb.Length - 4);
            ShellCodeModingb = ShellCodeModingb.Insert(0, "Shellcode db 0");
            ShellCodeModingb = ShellCodeModingb + "DELET THE BULLSHIT END...";


            

            TextWriter tw = new StreamWriter("output.asm"); //Ouvrir/Creer le fichier
            tw.WriteLine(ShellCodeModingb); // Ecrire
            tw.Close(); // Fermer le fichier


            System.IO.StreamReader myFile =
            new System.IO.StreamReader("output.asm");
            string myString = myFile.ReadToEnd();

            textBox2.Text = myString;
            MessageBox.Show("Show the output.asm !");
  
         }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

    }
}

Aucun commentaire:

Enregistrer un commentaire