⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testnet.c

📁 Linux 上的socket嗅探器
💻 C
字号:
/*
 *
 * Copyright (C) 2003 Xiangbin Lee <honeycombs@sina.com> <honeycombs@263.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation.
 */


#include "protocal.h"
#include "ipexport.h"
#include "spyfun.h"

/* =======================================================  */
#include <stdarg.h>
void DlgOnDebugMessage( char *pszMsg, ... )
{
	static int count=0;
  
	static char pszErr[ 1024 ];
	char *msgstart=NULL;

	sprintf(pszErr,"%05d:",++count);

	msgstart=pszErr+strlen(pszErr);

	va_list args;
	va_start( args, pszMsg );
	vsprintf( msgstart, pszMsg, args );  pszErr[ 1023 ] = '\0';
	va_end( args );

	printf("\n---> MSG: <%s>",pszErr);
}


int ViewSpyTreeName(ACHETREE *lptree)
{
	static char itemname[4096];
	ACHETREE *lparent=NULL;
	int spacn=0,freei;

	if(lptree==NULL)
		return -1;

	lparent=lptree->lpParent;
	while(lparent!=NULL)
	{
		spacn++;
		lparent=lparent->lpParent;
	}

	memset((void*)itemname,0,sizeof(itemname));
	memset((void*)itemname,' ',spacn*2);
	for(freei=0;freei<spacn*2;freei+=2)
		itemname[freei]='|';

	if(lptree->lpParent!=NULL)
	{
		if(lptree->type==ACHETRTEE_LEAFE)
			itemname[spacn*2]='-';
		else
			itemname[spacn*2]='+';
		itemname[spacn*2+1]=0;
	}

	if(lptree->lpData!=NULL)
	{
		sprintf((char*)(itemname+strlen(itemname)),"%s",(char*)(lptree->lpData));
	}

	printf("\n%s",(char*)(itemname));



	return 0;
}

static ACHETREE treeview;
int DlgOnGetPacket(SPYLIST * lpkt)
{
	printf("\n ---------------------------------------------");
	InitAcheTree(&treeview);
  ExportTree_RecvInfo(&treeview, lpkt);
	ExportTree_ETH(&treeview,0,lpkt->data,lpkt->dlen);

	DeepQueryAcheTree(&treeview,&ViewSpyTreeName,1);
	AcheTreeDelItems(&treeview);

	printf("\n ---------------------------------------------\n\n");
	return 1;
}

int DlgOnDelPacket(SPYLIST *lpspydata)
{
    return 0;
}

void TestSpy(void)
{
  char msg[120];
	SpySetFunction(DlgOnGetPacket,DlgOnDelPacket,DlgOnDebugMessage);

	InitSockets();

  SpySetState(SPY_OPEN);
  do{
     scanf("%s",msg);
    }while(strcmp(msg,"quit"));
  SpySetState(SPY_CLOSE);

	WSACleanup();

}


int main(int argc, char* argv[])
{
	TestSpy();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -