x-scan 反向域名解析插件

来源:心路

Dns_Name.def

LIBRARY "Dns_Name"
EXPORTS GetPluginInfo
PluginFunc

Dns_Name.cpp

#include <winsock2.h>
#include <ws2tcpip.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#include "XScanLib\XScanLib.h"

#ifdef __cplusplus
}
#endif // __cplusplus

extern "C" __declspec(dllexport) BOOL __stdcall GetPluginInfo(PLUGIN_INFO *);
extern "C" __declspec(dllexport) BOOL __stdcall PluginFunc (VOID *);
extern "C" DWORD WINAPI ResolveName (VOID *);

#pragma comment (lib, "ws2_32")
#pragma comment (lib, "XScanLib\XScanLib.lib")

#define VULN_MEMBER_NAME "反向域名解析"
#define CHECKING_STRING "正在解析域名..."
#define VERSION "0.2"
#define CMD_PARMAS "-dnsname"
#define PROMPT "反向域名解析"
#define AUTHOR "云舒"
#define DESCRIPTION "这个插件将IP地址反向解析为域名"
#define TIMEOUT 10000
#define ICON "winnt.bmp"
#define FILENAME "Dns_Name.xpn"

BOOL APIENTRY DLLMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
{
return TRUE;
}

BOOL __stdcall GetPluginInfo (PLUGIN_INFO *Info)
{
strcpy( Info->szClassName, VULN_MEMBER_NAME );
strcpy( Info->szMemberName, VULN_MEMBER_NAME );
strcpy( Info->szVersion, VERSION );
strcpy( Info->szFileName, FILENAME );
strcpy( Info->szParamsRequest, CMD_PARMAS );
strcpy( Info->szPrompt, PROMPT );
Info->nSingle = 1;
strcpy( Info->szAuthorName, AUTHOR );
strcpy( Info->szDescription, DESCRIPTION );
Info->dwTimeOut = TIMEOUT;
Info->nMark = 1;
strcpy( Info->szImageFile, ICON );

return TRUE;
}

BOOL __stdcall PluginFunc( VOID *Parm )
{
int VulnNumber;

if( !PlugInitLib((struct arglist *)Parm) )
{
return FALSE;
}

PlugSetVulnNum( (struct arglist *)Parm, 0 );

PlugSetCurrentSchedule( (struct arglist *)Parm, CHECKING_STRING );

PlugAddThread( (struct arglist *)Parm, ResolveName, Parm, TIMEOUT );

PlugWaitThread( (struct arglist *)Parm );

VulnNumber = PlugGetVulnNum( (struct arglist *)Parm );

return VulnNumber > 0 ? TRUE : FALSE;
}

DWORD WINAPI ResolveName( void * Parm )
{
char host[256] = { 0 };
char log_type[8] = { 0 };
int verbose = 0;
char message[128] = { 0 };
char host_name[1025] = { 0 };
char serv_name[129] = { 0 };
int ret;

SOCKADDR_IN sin;

strncpy( host, (char *)PlugGetParams((struct arglist *)Parm, "HostName"), 255 );
strncpy( log_type, (char *)PlugGetParams((struct arglist *)Parm, "LogType"), 7 );
verbose = (int)PlugGetParams((struct arglist *)Parm, "ShowVerbose");

sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr( host );
sin.sin_port = htons( 80 );

sprintf( message, "正在解析 %s的反向域名...", host );
PlugSetCurrentSchedule( (struct arglist *)Parm, message );

if( verbose )
{
PlugAlertUser ( (struct arglist *)Parm, 0, message );
}

ret = getnameinfo( (struct sockaddr *)&sin, sizeof(SOCKADDR_IN), host_name, 1024, serv_name, 128, NULL );

if( ret != 0 )
{
return 0;
}

if( !strcmp( host, host_name) )
{
return 0;
}

if( verbose )
{
memset( message, 0, sizeof(message) );
sprintf( message, "反向解析 %s 成功", host );
PlugAlertUser( (struct arglist *)Parm, AT_NORMAL, message );
}

memset( message, 0, sizeof(message) );

if ( stricmp(log_type, "HTM") && stricmp(log_type, "HTML") )
{
sprintf( message, "机器名: %s\n", host_name );
}
else
{
sprintf( message, "机器名: %s\n", host_name );
}

PlugLogToFile( (struct arglist *)Parm, "none", "NOTE", message );

PlugAddVulnNum((struct arglist *)Parm);

memset( message, 0, sizeof(message) );
sprintf ( message, "%s\n%s\n%s\n", host, VULN_MEMBER_NAME, host_name );

PlugAddToTV ( message, ICON );

return 0;
}

相关日志

发表评论