Advertisement
Guest User

Untitled

a guest
Feb 14th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using System.Net;
  6. using System.Text;
  7. using System.IO;
  8.  
  9. namespace ConsoleApp1
  10. {
  11. class Program
  12. {
  13. public static void Main(string[] args)
  14. {
  15. var cookieContainer = new CookieContainer();
  16.  
  17. var request = (HttpWebRequest)HttpWebRequest.Create("https://filelist.ro/takelogin.php?");
  18. request.CookieContainer = cookieContainer;
  19. request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36";
  20. request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
  21.  
  22. request.Method = "POST";
  23. request.ContentType = "application/x-www-form-urlencoded";
  24.  
  25. var data = string.Format("username={0}&password={1}", "lorand98", "kocsis26021998");
  26. var bytes = Encoding.UTF8.GetBytes(data);
  27.  
  28. request.ContentLength = bytes.Length;
  29.  
  30. using (var dataStream = request.GetRequestStream())
  31. {
  32. dataStream.Write(bytes, 0, bytes.Length);
  33. dataStream.Close();
  34. }
  35.  
  36. using (var response = request.GetResponse())
  37. {
  38. using (var sr = new StreamReader(response.GetResponseStream()))
  39. {
  40. File.WriteAllText(@"C:\test\login.txt", sr.ReadToEnd());
  41. }
  42. }
  43.  
  44. request = (HttpWebRequest)HttpWebRequest.Create("https://filelist.ro/browse.php");
  45. request.CookieContainer = cookieContainer;
  46. request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36";
  47. request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
  48.  
  49. using (var response = request.GetResponse())
  50. {
  51. using (var sr = new StreamReader(response.GetResponseStream()))
  52. {
  53. File.WriteAllText(@"C:\test\browser.txt", sr.ReadToEnd());
  54. }
  55. }
  56.  
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement