sasfvs

Untitled

Jul 4th, 2017
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 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.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9.  
  10. namespace NliWebSec
  11. {
  12.     class sourcecodeleak
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             List<string> mytargets = new List<string>();
  17.  
  18.             string html = null;
  19.             Console.WriteLine("Please enter the url of your target: ");
  20.             string url = Console.ReadLine();
  21.             // reading the html response from the target
  22.             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  23.             HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  24.             if (response.StatusCode == HttpStatusCode.OK)
  25.             {
  26.                 Stream receiveStream = response.GetResponseStream();
  27.                 StreamReader readStream = null;
  28.  
  29.                 if (response.CharacterSet == null)
  30.                 {
  31.                     readStream = new StreamReader(receiveStream);
  32.                 }
  33.                 else
  34.                 {
  35.                     readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
  36.                 }
  37.  
  38.                 html = readStream.ReadToEnd();
  39.  
  40.                 response.Close();
  41.                 readStream.Close();
  42.             }
  43.             //searching for urls / paths in the html response of the target
  44.             foreach (Match item in Regex.Matches(html, @"(http|ftp|https):\/\/([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?"))
  45.             {
  46.                 mytargets.Add(item.Value);
  47.             }
  48.             mytargets.ToArray();
  49.             for (int i = 0; i < mytargets.Count(); i++)
  50.             {
  51.                 Console.WriteLine(mytargets[i]);
  52.             }
  53.             Console.WriteLine(mytargets);
  54.  
  55.             Console.WriteLine();
  56.             Console.ReadLine();
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment