概述
扣扣1092230704,长期出售代理IP,SOCKS5,HTTP代理
#include "pch.h"
#include <iostream>
#include <winsock2.h>//该头文件定义了Socket编程的功能
#include <stdio.h>//该头文件声明了输入输出流函数
#include <stdlib.h>//该头文件定义了一些通用函数
#include <httpext.h>//该头文件支持HTTP请求
#include <windef.h>//该头文件定义了Windows的所有数据基本型态
#include <Nb30.h>//该头文件声明了netbios的所有的函数
#pragma comment(lib,"ws2_32.lib")//连接ws2_32.lib库.只要程序中用到Winsock API函数,都要用到 Ws2_32.lib
#pragma comment(lib,"netapi32.lib")//连接Netapi32.lib库,MAC获取中用到了NetApi32.DLL的功能
#include <Iphlpapi.h>
#pragma comment(lib,"Iphlpapi.lib") //需要添加Iphlpapi.lib库
using namespace std;
#pragma comment(linker,"/subsystem:windows /entry:mainCRTStartup")
BOOL system_hide(char* CommandLine)//调用控制台
{
SECURITY_ATTRIBUTES sa;
HANDLE hRead, hWrite;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
if (!CreatePipe(&hRead, &hWrite, &sa, 0))
{
return FALSE;
}
STARTUPINFOA si;
PROCESS_INFORMATION pi;
si.cb = sizeof(STARTUPINFO);
GetStartupInfoA(&si);
si.hStdError = hWrite;
si.hStdOutput = hWrite;
si.wShowWindow = SW_HIDE;
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
//关键步骤,CreateProcess函数参数意义请查阅MSDN
if (!CreateProcessA(NULL, CommandLine, NULL, NULL, TRUE, NULL, NULL, NULL, &si, &pi))
{
return FALSE;
}
CloseHandle(hWrite);
char buffer[4096] = { 0 };
DWORD bytesRead;
while (true)
{
memset(buffer, 0, strlen(buffer));
if (ReadFile(hRead, buffer, 4095, &bytesRead, NULL) == NULL)
break;
//buffer中就是执行的结果,可以保存到文本,也可以直接输出
//printf(buffer);//这行注释掉就可以了
Sleep(100);
}
return TRUE;
}
void randomMAC(char Mac[30])//生成随机MAC地址
{
char a[] = "0123456789ABCDEF";
int n = 16;
int m1 = 0, m2 = 0, m3 = 0, m4 = 0, m5 = 0, m6 = 0, m7 = 0, m8 = 0, m9 = 0, m10 = 0, m11 = 0, m12 = 0;
srand((unsigned int)time(0));
m1 = rand() % n;
m2 = rand() % n;
m3 = rand() % n;
m4 = rand() % n;
m5 = rand() % n;
m6 = rand() % n;
m7 = rand() % n;
m8 = rand() % n;
m9 = rand() % n;
m10 = rand() % n;
m11 = rand() % n;
m12 = rand() % n;
char str[30] = { a[m1],a[m2],'-',a[m3] ,a[m4],'-',a[m5],a[m6],'-',a[m7],a[m8],'-',a[m9],a[m10],'-',a[m11],a[m12] };
sprintf(Mac,"%s",str);
cout << str;
return ;
}
void bindingipMAC(char ip[30])//绑定MAC地址
{
std::cout << ip;
char ARParp[100];
int x = ::MessageBox(NULL, TEXT("绑定ip,确定执行吗?"), TEXT("操作提示"), 1);
if(x == 1)
{
char Mac[30];
randomMAC(Mac);
sprintf(ARParp, "%s %s", "arp -s", ip);
std::cout << ARParp << endl;
sprintf(ARParp, "%s %s", ARParp, Mac);
std::cout << ARParp;
system_hide(ARParp);
}
else
{
sprintf(ARParp, "%s", "arp -d");
system_hide(ARParp);
}
}
int main()
{
char ip[30]="192.138.12.22";//自定义的IP
bindingipMAC(ip);
Sleep(10);
}
程序运行第一次
程序运行第二次,可以发现自定义的IP的MAC地址已经改变
最后
以上就是疯狂衬衫为你收集整理的c++控制台程序给ip绑定随机MAC地址的全部内容,希望文章能够帮你解决c++控制台程序给ip绑定随机MAC地址所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复