Click here to Skip to main content
15,897,291 members
Articles / Programming Languages / C#

Steganography 17 - FTP Through a Proxy

Rate me:
Please Sign up or sign in to vote.
4.85/5 (29 votes)
16 Nov 2007CPOL10 min read 75.9K   935   65  
Transporting piggyback data in FTP transfers
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace SteganoFTP
{
	public class SessionManager
	{
		private const int FTP_COMMAND_PORT = 42; //21;

		private bool isRunning;
		private Socket mainServerSocket;

		public SessionManager()
		{
			OpenLocalSocket();
			Thread mainServerThread = new Thread(new ThreadStart(Listen));
			mainServerThread.Start();
		}

		private void OpenLocalSocket()
		{
			IPHostEntry localHostEntry = Dns.GetHostEntry(Dns.GetHostName());
			IPEndPoint endPoint = new IPEndPoint(localHostEntry.AddressList[0], FTP_COMMAND_PORT);
			this.mainServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
			this.mainServerSocket.Bind(endPoint);

			Console.WriteLine("Waiting on Port {0}", endPoint.Port.ToString());
		}

		private void Listen()
		{
			this.isRunning = true;

			string remoteServerName = System.Configuration.ConfigurationSettings.AppSettings["ftpServerName"];
			int remoteServerPort = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["ftpServerPort"]);
			
			try
			{
				while (this.isRunning)
				{
					// accept for connection
					this.mainServerSocket.Listen(10);
					Socket socketToClient = this.mainServerSocket.Accept();
					CommandChannelSocketSet sockets = new CommandChannelSocketSet(socketToClient, remoteServerName, remoteServerPort);
				}
				this.mainServerSocket.Close();
			}
			catch (SocketException ex)
			{
				Console.WriteLine("Socketfehler: {0}", ex.ToString());
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Germany Germany
Corinna lives in Hanover/Germany and works as a C# developer.

Comments and Discussions