随笔分类 - 《Visual C++ 代码片段笔记》
摘要:ThreadPool 线程池同步事件: 线程池内的线程函数同样支持互斥锁,信号控制,内核事件控制,临界区控制. #include <Windows.h> #include <iostream> #include <stdlib.h> unsigned long g_count = 0; // //
阅读全文
摘要:今天忙活了半天,在Linux平台下,总算可以获取到一些性能指标了,结果,Linux上面的数据发送到Windows上面会出现发送为空的现象,可能是Socket套接字存在问题,不搞了。 #include <iostream> #include <unistd.h> #include <stdlib.h>
阅读全文
摘要:C/C++ 编译并使用Sqlite数据库,实现增删改查。 首先下载数据库: https://sqlite.org/download.html 分别下载:sqlite-amalgamation-3350500.zip 以及根据自己平台下载:sqlite-dll-win32-x86-3350500.zi
阅读全文
摘要:扫描内存分页情况: #include <iostream> #include <windows.h> VOID ScanMemory(HANDLE hProc) { SIZE_T stSize = 0; PBYTE pAddress = (PBYTE)0; SYSTEM_INFO sysinfo;
阅读全文
摘要:多线程中的线程同步可以使用,CreateThread,CreateMutex 互斥锁实现线程同步,通过临界区实现线程同步,Semaphore 基于信号实现线程同步,CreateEvent 事件对象的同步,以及线程函数传递单一参数与多个参数的实现方式。
阅读全文
摘要:判断大端序小端序: 通常情况下,数值在内存中存储的方式有两种,一种是大尾字节序,另一种是小尾,比如0x01020304这样一个数值,如果用大尾方式存储,其存储方式为01 02 03 04而用小尾方式存储则是04 03 02 01,一般Windows操作系统兼容的CPU为小尾方式,而UNIX操作系统所
阅读全文
摘要:通常服务器是放在内网中,内部局域网中,并且分配了私有IP地址,而如果想要在外部直接访问内部服务器则需要端口映射,端口映射也叫做端口转发,或者叫做虚拟服务器,在渗透时当我们拿到目标机器权限以后,目标机器实在内网环境中,如果想要外部直接访问内部的特定机器的特定端口,则需要使用映射来实现,常用的映射工具是LCX,或者自己实现。
阅读全文
摘要:实现FTP文件下载: #include <stdio.h> #include <Windows.h> #include <WinInet.h> #pragma comment(lib, "WinInet.lib") BOOL Ftp_SaveToFile(char *pszFileName, BYT
阅读全文
摘要:遍历磁盘容量: #include <stdio.h> #include <Windows.h> void GetDrivesType(const char* lpRootPathName) { UINT uDriverType = GetDriveType(lpRootPathName); swit
阅读全文
摘要:实现HTTP 使用C++ 实现的HTTP页面请求下载功能,可以附带完整的HTTP请求头信息。 #include <stdio.h> #include <Windows.h> #include <winsock.h> #pragma comment(lib,"ws2_32.lib") int Curl
阅读全文
摘要:本质上socket无法传输结构体,我们只有将结构体装换为字节数组,或者是字符串格式来传输,到了服务端在强制类型转换一下即可,下面的代码分别提供原生写法与通过boost的实现两种,直接改改,可用于收集目标主机数据。 客户端: #include <winsock2.h> #include <stdio.
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> #include <process.h> #include <WinSock2.h> #pragma comment(lib, "ws2_32.lib") #define BUF_SIZE 2048 #define BUF
阅读全文
摘要:FTP文件下载 #include <stdio.h> #include <Windows.h> #include <WinInet.h> #pragma comment(lib, "WinInet.lib") BOOL Ftp_SaveToFile(char *pszFileName, BYTE *
阅读全文
摘要:1.下载libcurl https://curl.haxx.se/download.html 2.使用vs命令行控制台,切换到 cd curl-7.70.0\winbuild 3.执行编译选项,两种方式均可。 nmake /f Makefile.vc mode=dll VC=13 MACHINE=x
阅读全文
摘要:手动创建单进程: 下面通过一个实例来分别演示进程的创建函数. #include <windows.h> #include <stdio.h> BOOL WinExec(char *pszExePath, UINT uiCmdShow) { UINT uiRet = 0; uiRet = ::WinE
阅读全文
摘要:枚举注册表启动项: 通过添加注册表启动项,可以很方便地完成自启动,常用的启动位置有CurrentVersion,BootExecute,Active Setup. #include <stdio.h> #include <Windows.h> void Enum_Regedit(HKEY Reg_R
阅读全文
摘要:URL路径拆分: 例如我们传入 http://www.baidu.com/index.php 拆分为 www.baidu.com 和 /index.php #include <Windows.h> #include <iostream> int ParseUrl(char szUrl[], char
阅读全文
摘要:注册表,与服务常用来注册自启动程序,开机自动运行,多用于后门。 枚举注册表启动项: 遍历注册表 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run #include <stdio.h> #include <Windows.
阅读全文
摘要:特征码定位查杀 简单提取一段特征码字段。 代码编写。 #include <stdio.h> #include <Windows.h> #define FileLEN 20 // 文件长度定义 #define SIGNLEN 8 // 特征码长度定义 typedef struct SING { cha
阅读全文
摘要:使用vc6编译器编译后门,并运行 #pragma comment(lib,"ws2_32.lib") #ifdef _MSC_VER #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) #endi
阅读全文