2025-03-04 17:40:37 +08:00
|
|
|
|
package attackevent
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"dt_automate/conf"
|
2025-03-11 16:04:26 +08:00
|
|
|
|
"dt_automate/tool"
|
2025-03-04 17:40:37 +08:00
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
|
|
|
|
|
"github.com/playwright-community/playwright-go"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func HW_fw1_cookie() string {
|
|
|
|
|
// 启动 Playwright
|
|
|
|
|
pw, err := playwright.Run()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not start Playwright: %v", err)
|
|
|
|
|
}
|
|
|
|
|
defer pw.Stop()
|
|
|
|
|
|
|
|
|
|
// 启动浏览器(Chromium)
|
|
|
|
|
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
|
|
|
|
|
Headless: playwright.Bool(false), // 设置为 false 以显示浏览器界面
|
|
|
|
|
Args: []string{
|
|
|
|
|
"--ignore-certificate-errors", // 忽略证书错误[^28^][^29^]
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not launch browser: %v", err)
|
|
|
|
|
}
|
|
|
|
|
defer browser.Close()
|
|
|
|
|
|
|
|
|
|
// 创建一个新页面
|
|
|
|
|
page, err := browser.NewPage()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not create page: %v", err)
|
|
|
|
|
}
|
|
|
|
|
// 设置浏览器窗口大小
|
|
|
|
|
err = page.SetViewportSize(1920, 1080) // 宽度为 1200px,高度为 800px
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("无法设置浏览器窗口大小: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 导航到指定网址
|
|
|
|
|
_, err = page.Goto("https://11.2.68.146/", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded})
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not go to the page: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
page.WaitForTimeout(3000)
|
|
|
|
|
//输入
|
2025-03-11 16:04:26 +08:00
|
|
|
|
if err := page.Locator(`#user_name`).Fill(tool.KeyStr("l3cfrZe8ATdOBb/JEdgNDeptlUXcmD6+k0E3+mHqf5/hlssLsTS8BIwui0SVzbVyYhjPiDjNYJof3O1t49763g3PgL/rlMiSrO477E9Lq2BEE4592nh4oPSl4jIeCMSJq/i/CBVOFs5rVEFT8gdQx2giaLoQcZUNhb5oat8gtMzKL/2dgfss7OUJI7Oxd8p/kinhDSvzWiKZwbQ0jlX41yNxfagc958NtJ6Tamh2vyijdP9IT4yswhJ1UdRCQyLda08sLm8pnuSUeppIVuy9g/mgN9CDmk1U1J7knBh/Y9GQ9itR/A3hjrt9UcgWFys0bzZhfDPeMdfq7+wdeSHD9g==")); err != nil {
|
2025-03-04 17:40:37 +08:00
|
|
|
|
log.Fatalf("could not fill input: %v", err)
|
|
|
|
|
}
|
2025-03-11 16:04:26 +08:00
|
|
|
|
if err := page.Locator(`#password`).Fill(tool.KeyStr("QauqFZ9fr31D5/v7pmCTTm0ZTeWfKSggXnGR4pyDhr31lAXJpaRwA+pMjmpeAucTKsDJ2TEnccqSk/GN5E0ExFq/A1VgKw12f+pVgR/00tNO9W42JiYDVMa1ssl+H3P3mNci+CeSCvY+sct/HxC+anv3BMk2xQavZP4+F5wF6gDdae7epvnOTkbmWDdkRz1SEIjh+Ffx/rI0Jj5TQxiWd+LA0JOODATgcf1olXpnLqtNCek89FTc7Hq9vXeWxMUVm6/ysyVQnAcWtn65z6OHecMdJ2PYoTs6yb7HKlkROooPVlOLEnajqGG14RzAelAjR+H0QghHK8WbzJmKlAI8Jw==")); err != nil {
|
2025-03-04 17:40:37 +08:00
|
|
|
|
log.Fatalf("could not fill input: %v", err)
|
|
|
|
|
}
|
|
|
|
|
//登录
|
|
|
|
|
if err := page.Locator("#login_button").Click(); err != nil {
|
|
|
|
|
log.Fatalf("could not click button: %v", err)
|
|
|
|
|
}
|
|
|
|
|
page.WaitForTimeout(1000)
|
|
|
|
|
page.Evaluate(`
|
|
|
|
|
const now = new Date();
|
|
|
|
|
const year = now.getFullYear();
|
|
|
|
|
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
|
|
|
const day = now.getDate().toString().padStart(2, '0');
|
|
|
|
|
const hours = now.getHours().toString().padStart(2, '0');
|
|
|
|
|
const minutes = now.getMinutes().toString().padStart(2, '0');
|
|
|
|
|
const seconds = now.getSeconds().toString().padStart(2, '0');
|
|
|
|
|
const timestamp = year+"-"+month+"-"+day +" "+ hours+":"+minutes+":"+seconds;
|
|
|
|
|
const div = document.createElement('div');
|
|
|
|
|
div.style.position = 'fixed';
|
|
|
|
|
div.style.bottom = '10px';
|
|
|
|
|
div.style.right = '10px';
|
|
|
|
|
div.style.color = 'white';
|
|
|
|
|
div.style.backgroundColor = 'black';
|
|
|
|
|
div.style.padding = '5px';
|
|
|
|
|
div.style.borderRadius = '5px';
|
|
|
|
|
div.textContent = timestamp;
|
|
|
|
|
document.body.appendChild(div);
|
|
|
|
|
`, nil)
|
|
|
|
|
// 获取页面标题
|
|
|
|
|
title, err := page.Title()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("could not get title: %v", err)
|
|
|
|
|
}
|
|
|
|
|
log.Printf("Page title is: %s\n", title)
|
|
|
|
|
cookies, err := page.Context().Cookies("https://11.2.68.146/wnm/get.j")
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Println(err)
|
|
|
|
|
}
|
|
|
|
|
var cookieStr string
|
|
|
|
|
for _, cookie := range cookies {
|
|
|
|
|
cookieStr += fmt.Sprintf("%s=%s;", cookie.Name, cookie.Value)
|
|
|
|
|
// log.Printf("Cookie %d: %+v", i, cookie)
|
|
|
|
|
}
|
|
|
|
|
log.Println(cookieStr)
|
|
|
|
|
// attackevent.Fw_event(cookieStr)
|
|
|
|
|
conf.SET_Config_yaml("cookie", cookieStr) //临时存放数据
|
|
|
|
|
// StartBlocker()
|
|
|
|
|
return cookieStr
|
|
|
|
|
}
|