1 /********************************************************************************
2  *                              Nepenthes
3  *                        - finest collection -
4  *
5  *
6  *
7  * Copyright (C) 2005  Paul Baecher & Markus Koetter
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22  *
23  *
24  *             contact nepenthesdev@users.sourceforge.net
25  *
26  *******************************************************************************/
27 
28 /* $Id: vuln-ftpd.hpp 345 2006-02-21 08:45:14Z common $ */
29 
30 /* vuln-ftp created by Harald Lampesberger, contact harald.lampesberger@fork.at
31  * thx to the developers of nepenthes for the help! */
32 
33 #include "DialogueFactory.hpp"
34 #include "Module.hpp"
35 #include "ModuleManager.hpp"
36 #include "SocketManager.hpp"
37 #include "Nepenthes.hpp"
38 #include "Dialogue.hpp"
39 #include "Socket.hpp"
40 
41 using namespace std;
42 
43 namespace nepenthes
44 {
45 
46 	class Buffer;
47 
48         typedef enum
49         {
50 		FTP_NULL,
51 		FTP_USER,
52                 FTP_PASS,
53 		FTP_DONE
54         } ftp_state;
55 
56 	typedef enum {
57 		FREEFTPD,
58 		WARFTPD_USER,
59 		WARFTPD_PASS,
60 		UNKNOWN
61 	} ftp_exploit;
62 
63 	class FTPd : public Module , public DialogueFactory
64 	{
65 	public:
66 		FTPd(Nepenthes *);
67 		~FTPd();
68 		Dialogue *createDialogue(Socket *socket);
69 		bool Init();
70 		bool Exit();
71 	};
72 
73 	class FTPdDialogue : public Dialogue
74 	{
75 	public:
76 		FTPdDialogue(Socket *socket);
77 		~FTPdDialogue();
78 		ConsumeLevel incomingData(Message *msg);
79 		ConsumeLevel outgoingData(Message *msg);
80 		ConsumeLevel handleTimeout(Message *msg);
81 		ConsumeLevel connectionLost(Message *msg);
82 		ConsumeLevel connectionShutdown(Message *msg);
83 
84 		void dump();
85 		ftp_exploit identExploit(string line);
86 	protected:
87 		Buffer *m_Buffer;
88 		Buffer *m_Shellcode;
89 		ftp_state m_state;
90 	};
91 
92 }
93 extern nepenthes::Nepenthes *g_Nepenthes;
94