Branch data Line data Source code
1 : : // $Id: BackDoor.h 6219 2008-10-01 05:39:07Z vern $
2 : : //
3 : : // See the file "COPYING" in the main distribution directory for copyright.
4 : :
5 : : #ifndef backdoor_h
6 : : #define backdoor_h
7 : :
8 : : #include "TCP.h"
9 : : #include "Timer.h"
10 : : #include "NetVar.h"
11 : : #include "Login.h"
12 : :
13 : : class BackDoorEndpoint {
14 : : public:
15 : : BackDoorEndpoint(TCP_Endpoint* e);
16 : :
17 : : int DataSent(double t, int seq, int len, int caplen, const u_char* data,
18 : : const IP_Hdr* ip, const struct tcphdr* tp);
19 : :
20 : : RecordVal* BuildStats();
21 : :
22 : : void FinalCheckForRlogin();
23 : :
24 : : protected:
25 : : void CheckForRlogin(int seq, int len, const u_char* data);
26 : : void RloginSignatureFound(int len);
27 : :
28 : : void CheckForTelnet(int seq, int len, const u_char* data);
29 : : void TelnetSignatureFound(int len);
30 : :
31 : : void CheckForSSH(int seq, int len, const u_char* data);
32 : : void CheckForFTP(int seq, int len, const u_char* data);
33 : : void CheckForRootBackdoor(int seq, int len, const u_char* data);
34 : : void CheckForNapster(int seq, int len, const u_char* data);
35 : : void CheckForGnutella(int seq, int len, const u_char* data);
36 : : void CheckForKazaa(int seq, int len, const u_char* data);
37 : : void CheckForHTTP(int seq, int len, const u_char* data);
38 : : void CheckForHTTPProxy(int seq, int len, const u_char* data);
39 : : void CheckForSMTP(int seq, int len, const u_char* data);
40 : : void CheckForIRC(int seq, int len, const u_char* data);
41 : : void CheckForGaoBot(int seq, int len, const u_char* data);
42 : :
43 : : void SignatureFound(EventHandlerPtr e, int do_orig = 0);
44 : :
45 : : int CheckForStrings(const char** strs, const u_char* data, int len);
46 : : int CheckForFullString(const char* str, const u_char* data, int len);
47 : : int CheckForString(const char* str, const u_char* data, int len);
48 : :
49 : : TCP_Endpoint* endp;
50 : : int is_partial;
51 : : int max_top_seq;
52 : :
53 : : int rlogin_checking_done;
54 : : int rlogin_num_null;
55 : : int rlogin_string_separator_pos;
56 : : int rlogin_slash_seen;
57 : :
58 : : uint32 num_pkts;
59 : : uint32 num_8k4_pkts;
60 : : uint32 num_8k0_pkts;
61 : : uint32 num_lines;
62 : : uint32 num_normal_lines;
63 : : uint32 num_bytes;
64 : : uint32 num_7bit_ascii;
65 : : };
66 : :
67 : : class BackDoor_Analyzer : public TCP_ApplicationAnalyzer {
68 : : public:
69 : : BackDoor_Analyzer(Connection* c);
70 : : ~BackDoor_Analyzer();
71 : :
72 : : virtual void Init();
73 : : virtual void Done();
74 : : void StatTimer(double t, int is_expire);
75 : :
76 : 0 : static Analyzer* InstantiateAnalyzer(Connection* conn)
77 : 0 : { return new BackDoor_Analyzer(conn); }
78 : :
79 : 939 : static bool Available()
80 : : {
81 : : return backdoor_stats || rlogin_signature_found ||
82 : : telnet_signature_found || ssh_signature_found ||
83 : : root_backdoor_signature_found || ftp_signature_found ||
84 : : napster_signature_found || kazaa_signature_found ||
85 [ + - ][ + - ]: 939 : http_signature_found || http_proxy_signature_found;
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
86 : : }
87 : :
88 : : protected:
89 : : // We support both packet and stream input, and can be instantiated
90 : : // even if the TCP analyzer is not yet reassembling.
91 : : virtual void DeliverPacket(int len, const u_char* data, bool is_orig,
92 : : int seq, const IP_Hdr* ip, int caplen);
93 : : virtual void DeliverStream(int len, const u_char* data, bool is_orig);
94 : :
95 : : void StatEvent();
96 : : void RemoveEvent();
97 : :
98 : : BackDoorEndpoint* orig_endp;
99 : : BackDoorEndpoint* resp_endp;
100 : :
101 : : int orig_stream_pos;
102 : : int resp_stream_pos;
103 : :
104 : : double timeout;
105 : : double backoff;
106 : : };
107 : :
108 : : class BackDoorTimer : public Timer {
109 : : public:
110 : : BackDoorTimer(double t, BackDoor_Analyzer* a);
111 : : ~BackDoorTimer();
112 : :
113 : : void Dispatch(double t, int is_expire);
114 : :
115 : : protected:
116 : : BackDoor_Analyzer* analyzer;
117 : : };
118 : :
119 : : #endif
|