#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <string>
#include <Windows.h>
#include <conio.h>
#include "hacker.h"
#define WIDTH 40
#define HEIGHT 15
using namespace std;
void showMenu();
void inputPwd(char pwd[], int size)
{
char c = 0;
int i = 0;
while (1)
{
c = _getch();
if (c == '\r' || i >= size)
{
break;
}
pwd[i++] = c;
cout << '*';
}
pwd[i] = '\0';
cout << endl;
}
void login()
{
string name;
char pwd[32] = { 0 };
while (1)
{
cout << "账号:";
cin >> name;
cout << "密码:";
inputPwd(pwd, sizeof(pwd));
if (name == "admin" && !strcmp(pwd, "123456"))
{
showMenu();
break;
}
else
{
system("cls");
cout << "账号或密码错误,请重新输入" << endl;
}
}
}
void printInMiddle(string str)
{
int leftSpace = (WIDTH - str.length()) / 2;
for (int i = 0; i < leftSpace; i++)
{
cout << " ";
}
cout << str << endl;
}
void showMenu()
{
int maxMenu = 0;
string menu[] = {
"1.网站404攻击",
"2.网站篡改攻击",
"3.网站攻击修复",
"4.查看攻击记录",
"5.退出"
};
int menuCount = sizeof(menu) / sizeof(menu[0]);
for (int i = 0; i < menuCount; i++)
{
if (maxMenu < menu[i].length())
{
maxMenu = menu[i].length();
}
}
int leftSpace = (WIDTH - maxMenu) / 2;
printInMiddle("菜单");
for (int i = 0; i < menuCount; i++)
{
for (int j = 0; j < leftSpace; j++)
{
cout << " ";
}
cout << menu[i] << endl;
}
}
int menuChoise()
{
int index;
cout << "请输入功能序号:";
while (1)
{
cin >> index;
if (cin.fail())
{
cin.clear();
cin.ignore();
system("cls");
showMenu();
cout << "无效输入,请重新输入:";
}
else if (index < 1 || index >5)
{
system("cls");
showMenu();
cout << "无效输入,请重新输入:";
}
else
{
return index;
}
}
}
void init()
{
char cmd[128] = { 0 };
sprintf(cmd, "mode con cols=%d lines=%d", WIDTH, HEIGHT);
system(cmd);
}
void attack404()
{
char id[64] = { 0 };
char response[1024] = { 0 };
cout << "请输入你要404攻击的网站id:";
scanf("%s", id);
cout << "正在进行404攻击..." << endl;
hk_404(id, response);
string strRet = UTF8ToGBK(response);
cout << strRet << endl;
}
void falsifyAttack()
{
char id[64] = { 0 };
char response[1024] = { 0 };
string attackText;
cout << "请输入你要篡改的网站id:";
scanf("%s", id);
cout << "请输入你要篡改的内容:";
cin >> attackText;
cout << "正在进行网站篡改攻击..." << endl;
GBKToUTF8(attackText);
hk_tamper(id, (char*)attackText.c_str(), response);
string strRet = UTF8ToGBK(response);
cout << strRet << endl;
}
void attackRestore()
{
char id[64] = { 0 };
char response[1024] = { 0 };
cout << "请输入你要修复的网站id:";
scanf("%s", id);
cout << "正在进行网站修复..." << endl;
hk_restore(id, response);
string strRet = UTF8ToGBK(response);
cout << strRet << endl;
}
void attackRecord()
{
char id[64] = { 0 };
char response[1024] = { 0 };
cout << "请输入你查看攻击记录的网站id:";
scanf("%s", id);
cout << "正在进行查看攻击记录..." << endl;
hk_record(id, response);
string strRet = UTF8ToGBK(response);
cout << strRet << endl;
}
int main()
{
init();
login();
while (1)
{
system("cls");
showMenu();
switch (menuChoise())
{
case 1:
attack404();
system("pause");
break;
case 2:
falsifyAttack();
system("pause");
break;
case 3:
attackRestore();
system("pause");
break;
case 4:
attackRecord();
system("pause");
break;
case 5:
return 0;
default:
break;
}
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现