sasfvs

Untitled

Jul 4th, 2017
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 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.             string html = null;
  17.             Console.WriteLine("Please enter the url of your target: ");
  18.             string url = Console.ReadLine();
  19.             // reading the html response from the target
  20.             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  21.             HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  22.             if (response.StatusCode == HttpStatusCode.OK)
  23.             {
  24.                 Stream receiveStream = response.GetResponseStream();
  25.                 StreamReader readStream = null;
  26.  
  27.                 if (response.CharacterSet == null)
  28.                 {
  29.                     readStream = new StreamReader(receiveStream);
  30.                 }
  31.                 else
  32.                 {
  33.                     readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
  34.                 }
  35.  
  36.                 html = readStream.ReadToEnd();
  37.  
  38.                 response.Close();
  39.                 readStream.Close();
  40.             }
  41.             //searching for urls / paths in the html response of the target
  42.             foreach (Match item in Regex.Matches(html, @"(http|ftp|https):\/\/([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?"))
  43.             {
  44.                 Console.WriteLine(item.Value);
  45.             }
  46.             Console.WriteLine();
  47.             Console.ReadLine();
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment