mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Initial import of svn+ssh:://svn.icir.org/bro/trunk/bro as of r7088
This commit is contained in:
commit
61757ac78b
1383 changed files with 380824 additions and 0 deletions
91
src/Finger.cc
Normal file
91
src/Finger.cc
Normal file
|
@ -0,0 +1,91 @@
|
|||
// $Id: Finger.cc 6219 2008-10-01 05:39:07Z vern $
|
||||
//
|
||||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "NetVar.h"
|
||||
#include "Finger.h"
|
||||
#include "Event.h"
|
||||
#include "TCP_Rewriter.h"
|
||||
#include "ContentLine.h"
|
||||
|
||||
Finger_Analyzer::Finger_Analyzer(Connection* conn)
|
||||
: TCP_ApplicationAnalyzer(AnalyzerTag::Finger, conn)
|
||||
{
|
||||
did_deliver = 0;
|
||||
content_line_orig = new ContentLine_Analyzer(conn, true);
|
||||
content_line_orig->SetIsNULSensitive(true);
|
||||
content_line_resp = new ContentLine_Analyzer(conn, false);
|
||||
AddSupportAnalyzer(content_line_orig);
|
||||
AddSupportAnalyzer(content_line_resp);
|
||||
}
|
||||
|
||||
void Finger_Analyzer::Done()
|
||||
{
|
||||
TCP_ApplicationAnalyzer::Done();
|
||||
|
||||
if ( TCP() )
|
||||
if ( (! did_deliver || content_line_orig->HasPartialLine()) &&
|
||||
(TCP()->OrigState() == TCP_ENDPOINT_CLOSED ||
|
||||
TCP()->OrigPrevState() == TCP_ENDPOINT_CLOSED) )
|
||||
// ### should include the partial text
|
||||
Weird("partial_finger_request");
|
||||
}
|
||||
|
||||
void Finger_Analyzer::DeliverStream(int length, const u_char* data, bool is_orig)
|
||||
{
|
||||
const char* line = (const char*) data;
|
||||
const char* end_of_line = line + length;
|
||||
|
||||
if ( is_orig )
|
||||
{
|
||||
|
||||
if ( ! finger_request )
|
||||
return;
|
||||
|
||||
line = skip_whitespace(line, end_of_line);
|
||||
|
||||
// Check for /W.
|
||||
int long_cnt = (line + 2 <= end_of_line && line[0] == '/' && toupper(line[1]) == 'W');
|
||||
if ( long_cnt )
|
||||
line = skip_whitespace(line+2, end_of_line);
|
||||
|
||||
const char* at = strchr_n(line, end_of_line, '@');
|
||||
const char* host = 0;
|
||||
if ( ! at )
|
||||
at = host = end_of_line;
|
||||
else
|
||||
host = at + 1;
|
||||
|
||||
val_list* vl = new val_list;
|
||||
vl->append(BuildConnVal());
|
||||
vl->append(new Val(long_cnt, TYPE_BOOL));
|
||||
vl->append(new StringVal(at - line, line));
|
||||
vl->append(new StringVal(end_of_line - host, host));
|
||||
|
||||
if ( finger_request )
|
||||
ConnectionEvent(finger_request, vl);
|
||||
|
||||
Conn()->Match(Rule::FINGER, (const u_char *) line,
|
||||
end_of_line - line, true, true, 1, true);
|
||||
|
||||
did_deliver = 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if ( ! finger_reply )
|
||||
return;
|
||||
|
||||
val_list* vl = new val_list;
|
||||
vl->append(BuildConnVal());
|
||||
vl->append(new StringVal(end_of_line - line, line));
|
||||
|
||||
ConnectionEvent(finger_reply, vl);
|
||||
}
|
||||
}
|
||||
|
||||
#include "finger-rw.bif.func_def"
|
Loading…
Add table
Add a link
Reference in a new issue