This commit is contained in:
李超 2025-03-04 17:40:37 +08:00
parent 0c89f3740f
commit 2ba4a122d8
47 changed files with 179 additions and 61 deletions

BIN
DT_ZGDZ.db Normal file

Binary file not shown.

View File

@ -0,0 +1,101 @@
package attackevent
import (
"dt_automate/conf"
"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)
//输入
if err := page.Locator(`#user_name`).Fill("xcy_user"); err != nil {
log.Fatalf("could not fill input: %v", err)
}
if err := page.Locator(`#password`).Fill("Cecloud@2023"); err != nil {
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
}

View File

@ -1,9 +1,7 @@
##临时数据存放点
cookie: vindex==3c=10=0AB00=0R; supportLang=cn%2Cen; lang=cn; abcd1234=true; 200001ec7c0c8051248d8d3f9aac68224def=true; sessionid=20000108e78d84d53105d5cbef259dd09f07; loginid=fd0c8b40dd1ec230686c40e85320218d; 20000108e78d84d53105d5cbef259dd09f07=true; login=false
mysql:
url: 127.0.0.1
port: 3306
redis:
host: 127.0.0.1
port: 6379
cookie: vindex==3c=1b=0AB00=0R;supportLang=cn%2Cen;lang=cn;sessionid=2000013666a3120a259d2168127d3effcc7f;loginid=5019bf444a0cef5efea2b72e1bfc0e46;2000013666a3120a259d2168127d3effcc7f=true;abcd1234=true;login=false;
mysql:
port: 3306
url: 127.0.0.1
redis:
host: 127.0.0.1
port: 6379

View File

@ -24,6 +24,7 @@ func init() {
// 修改配置文件内容
func SET_Config_yaml(name, value string) {
viper.Set(name, value)
viper.WriteConfig()
// fmt.Println(viper.Get("mysql")) // map[port:3306 url:127.0.0.1]
// fmt.Println(viper.Get("mysql.url")) // 127.0.0.1
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 KiB

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 KiB

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 KiB

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 KiB

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 KiB

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 324 KiB

20
main.go
View File

@ -2,7 +2,6 @@ package main
import (
"dt_automate/attackevent"
"dt_automate/conf"
"dt_automate/tool"
"flag"
"fmt"
@ -68,24 +67,25 @@ func main() {
log.Printf("授权未到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod)
//可执行程序位置
// 互联网区截图
// method.HW_FAC1() //截取流量清洗的图片
// method.HW_FW1() //截取防火墙的图片
// method.HW_TSGZ() //截取态势感知的图片
// method.HW_FAC1() //截取流量清洗的图片
// method.HW_FW1() //截取防火墙的图片
// method.HW_TSGZ() //截取态势感知的图片
// method.HW_DTCLOUD() //截取运维中心的图片
// method.HW_BAOLJ() //截取堡垒机的图片
//运维巡检文档生成
// wps.HW_SYS_Word() //运维平台word文档生成
// method.HW_BAOLJ() //截取堡垒机的图片
// //政务网区截图
// method.ZWW_FW1() //截取防火墙的图片
// method.ZWW_TSGZ() //截取态势感知的图片
// method.ZWW_DTCLOUD() //截取运维中心的图片
// method.ZWWW_BAOLJ() //截取堡垒机的图片
//运维巡检文档生成
//互联网区运维巡检文档生成
// wps.HW_SYS_Word() //运维平台word文档生成
// //政务网区运维巡检文档生成
// wps.ZWW_SYS_Word() //运维平台word文档生成
//安全巡检文档生成
// //安全巡检文档生成
// wps.SAFET_Word() //安全巡检文档生成
//安全事件表格生成(需要先执行互联网区防火墙截图)
attackevent.Fw_event(conf.GET_Config_yaml("cookie").(string)) //将防火墙安全事件存放到xlsx文件中
attackevent.Fw_event(attackevent.HW_fw1_cookie()) //将防火墙安全事件存放到xlsx文件中
}
} else {
log.Println("没有授权")

View File

@ -1,9 +1,11 @@
package method
import (
"bufio"
"dt_automate/tool"
"fmt"
"log"
"os"
"github.com/playwright-community/playwright-go"
)
@ -50,23 +52,25 @@ func HW_BAOLJ() {
page.Locator(`#inputUserName`).Fill("lichao")
page.Locator(`#inputPassword`).Fill("Lc753951!!")
var name string
reader := bufio.NewReader(os.Stdin)
fmt.Print("是否需要输入验证码1允许0跳过")
fmt.Scanf("%s", &name)
name, _ := reader.ReadString('\n')
if name == "1" {
fmt.Scanf("%s", &name)
fmt.Print("请输入验证码:")
fmt.Scanf("%s", &name)
page.Locator(`#inputCaptcha`).Fill(name)
}
reader := bufio.NewReader(os.Stdin)
fmt.Print("请输入验证码:")
input, _ := reader.ReadString('\n')
page.Locator(`#inputCaptcha`).Fill(input)
}
page.Locator(`.loginFormButtonLogin`).Click()
fmt.Scanf("%s", &name)
reader1 := bufio.NewReader(os.Stdin)
fmt.Print("请输入OTA口令")
fmt.Scanf("%s", &name)
page.Locator(`.form-group.form-control.dynamic_code`).Nth(0).Locator(`input[name="token"]`).Fill(name)
input, _ := reader1.ReadString('\n')
page.Locator(`.form-group.form-control.dynamic_code`).Nth(0).Locator(`input[name="token"]`).Fill(input)
//登录
page.Locator(`.submit.loginFormButtonSubmit`).Nth(0).Click()
page.Locator(`.form-group`).Nth(7).Locator(`button`).Nth(2).Click()
page.WaitForTimeout(500)
page.Goto("https://11.2.65.23/webui/#/business/audits/event/log/login", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded})
page.WaitForTimeout(2000)
page.Evaluate(`
const now = new Date();

View File

@ -1,8 +1,10 @@
package method
import (
"bufio"
"fmt"
"log"
"os"
"github.com/playwright-community/playwright-go"
)
@ -49,12 +51,12 @@ func HW_DTCLOUD() {
page.Locator(`.el-input__inner`).Nth(0).Fill("opsadmin")
//输入密码
page.Locator(`.el-input__inner`).Nth(1).Fill(`DTXCY@2024#`)
var name string
reader := bufio.NewReader(os.Stdin)
fmt.Print("请输入验证码:")
fmt.Scanf("%s", &name)
input, _ := reader.ReadString('\n')
//输入验证码
page.Locator(`.el-input__inner`).Nth(2).Fill(name)
log.Println("当前验证码为:", name)
page.Locator(`.el-input__inner`).Nth(2).Fill(input)
log.Println("当前验证码为:", input)
page.WaitForTimeout(2000)
//登录
if err := page.Locator(".el-button.login-form-item.login-btn.el-button--primary").Click(); err != nil {
@ -94,7 +96,7 @@ func HW_DTCLOUD() {
page.Goto("https://ops.hlw.dtcloud.com/region/dtcloud1/console/om/monitor/resource", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}) //监控-资源监控
page.WaitForTimeout(4000)
page.Locator(`.arco-tree.arco-tree-show-line`).Locator(`div`).Nth(4).Locator(`span`).Nth(1).Locator(`span[role="button"]`).Click()
page.Locator(`.arco-tree.arco-tree-show-line`).Locator(`div`).Nth(8).Locator(`span`).Nth(2).Locator(`span`).Nth(0).Click()
page.Locator(`div[data-test-id="PhysicalServer"]`).Click()
page.WaitForTimeout(1000)
page.Screenshot(playwright.PageScreenshotOptions{
@ -105,7 +107,7 @@ func HW_DTCLOUD() {
page.Goto("https://ops.hlw.dtcloud.com/region/dtcloud1/console/om/alert/view", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}) //监控-告警-告警查看
page.WaitForTimeout(4000)
page.Locator(`.flex-between mb20`).Locator(`.arco-material-last-days`).Locator(`.arco-space.arco-space-horizontal.arco-space-align-center`).Locator(`div`).Nth(0).Locator(`button`).Click()
page.Locator(`.arco-space-item`).Nth(0).Locator(`div`).Nth(1).Locator(`button`).Click()
page.WaitForTimeout(2000)
page.Screenshot(playwright.PageScreenshotOptions{
Path: playwright.String("img/hw_dtcloud_05.png"),
@ -113,7 +115,7 @@ func HW_DTCLOUD() {
})
// tool.Jietu("img/hw_dtcloud_05.png")
page.Goto("https://ops.hlw.dtcloud.com/region/dtcloud1/console/om/alert/history", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}) //监控-告警历史
page.Goto("https://ops.hlw.dtcloud.com/region/dtcloud1/console/om/alert/history", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}) //监控-告警--告警历史
page.WaitForTimeout(4000)
page.Locator(`.arco-btn.arco-btn-outline.arco-btn-size-default.arco-btn-shape-square`).Nth(0).Click()
page.WaitForTimeout(500)

View File

@ -1,9 +1,11 @@
package method
import (
"bufio"
"dt_automate/tool"
"fmt"
"log"
"os"
"github.com/playwright-community/playwright-go"
)
@ -68,10 +70,10 @@ func HW_TSGZ() {
a.Nth(0).Fill("admin")
page.WaitForTimeout(500)
a.Nth(1).Fill("BWySN~QjrlwFsA)@#h")
var name string
reader := bufio.NewReader(os.Stdin)
fmt.Print("请输入验证码:")
fmt.Scanf("%s", &name)
a.Nth(2).Fill(name)
input, _ := reader.ReadString('\n')
a.Nth(2).Fill(input)
page.WaitForTimeout(500)
//点击同意
if err := page.Locator(`.el-checkbox__inner`).Click(); err != nil {

View File

@ -1,9 +1,11 @@
package method
import (
"bufio"
"dt_automate/tool"
"fmt"
"log"
"os"
"github.com/playwright-community/playwright-go"
)
@ -50,23 +52,25 @@ func ZWWW_BAOLJ() {
page.Locator(`#inputUserName`).Fill("lichao")
page.Locator(`#inputPassword`).Fill("Lc753951!!")
var name string
reader := bufio.NewReader(os.Stdin)
fmt.Print("是否需要输入验证码1允许0跳过")
fmt.Scanf("%s", &name)
name, _ := reader.ReadString('\n')
if name == "1" {
fmt.Scanf("%s", &name)
fmt.Print("请输入验证码:")
fmt.Scanf("%s", &name)
page.Locator(`#inputCaptcha`).Fill(name)
}
reader := bufio.NewReader(os.Stdin)
fmt.Print("请输入验证码:")
input, _ := reader.ReadString('\n')
page.Locator(`#inputCaptcha`).Fill(input)
}
page.Locator(`.loginFormButtonLogin`).Click()
fmt.Scanf("%s", &name)
reader1 := bufio.NewReader(os.Stdin)
fmt.Print("请输入OTA口令")
fmt.Scanf("%s", &name)
page.Locator(`.form-group.form-control.dynamic_code`).Nth(0).Locator(`input[name="token"]`).Fill(name)
input, _ := reader1.ReadString('\n')
page.Locator(`.form-group.form-control.dynamic_code`).Nth(0).Locator(`input[name="token"]`).Fill(input)
//登录
page.Locator(`.submit.loginFormButtonSubmit`).Nth(0).Click()
page.Locator(`.form-group`).Nth(7).Locator(`button`).Nth(2).Click()
page.WaitForTimeout(500)
page.Goto("https://11.1.65.22/webui/#/business/audits/event/log/login", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded})
page.WaitForTimeout(2000)
page.Evaluate(`
const now = new Date();

View File

@ -1,8 +1,10 @@
package method
import (
"bufio"
"fmt"
"log"
"os"
"github.com/playwright-community/playwright-go"
)
@ -49,12 +51,14 @@ func ZWW_DTCLOUD() {
page.Locator(`.el-input__inner`).Nth(0).Fill("opsadmin")
//输入密码
page.Locator(`.el-input__inner`).Nth(1).Fill(`DTXCY@2024#`)
var name string
reader := bufio.NewReader(os.Stdin)
fmt.Print("请输入验证码:")
fmt.Scanf("%s", &name)
input, _ := reader.ReadString('\n')
//输入验证码
page.Locator(`.el-input__inner`).Nth(2).Fill(name)
log.Println("当前验证码为:", name)
page.Locator(`.el-input__inner`).Nth(2).Fill(input)
log.Println("当前验证码为:", input)
page.WaitForTimeout(2000)
//登录
if err := page.Locator(".el-button.login-form-item.login-btn.el-button--primary").Click(); err != nil {
@ -93,8 +97,8 @@ func ZWW_DTCLOUD() {
// tool.Jietu("img/hw_dtcloud_03.png")
page.Goto("https://ops.zww.dtcloud.com/region/dtcloud2/console/om/monitor/resource", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}) //监控-资源监控-物理服务器
page.WaitForTimeout(6000)
page.Locator(`.arco-tree.arco-tree-show-line`).Locator(`div`).Nth(4).Locator(`span`).Nth(1).Locator(`span[role="button"]`).Click()
page.WaitForTimeout(4000)
page.Locator(`.arco-tree.arco-tree-show-line`).Locator(`div`).Nth(8).Locator(`span`).Nth(2).Locator(`span`).Nth(0).Click()
page.Locator(`div[data-test-id="PhysicalServer"]`).Click()
page.WaitForTimeout(2000)
page.Screenshot(playwright.PageScreenshotOptions{
@ -105,7 +109,7 @@ func ZWW_DTCLOUD() {
page.Goto("https://ops.zww.dtcloud.com/region/dtcloud2/console/om/alert/view", playwright.PageGotoOptions{WaitUntil: playwright.WaitUntilStateDomcontentloaded}) //监控-告警-告警查看
page.WaitForTimeout(6000)
page.Locator(`.flex-between mb20`).Locator(`.arco-material-last-days`).Locator(`.arco-space.arco-space-horizontal.arco-space-align-center`).Locator(`div`).Nth(0).Locator(`button`).Click()
page.Locator(`.arco-space-item`).Nth(0).Locator(`div`).Nth(1).Locator(`button`).Click()
page.WaitForTimeout(6000)
page.Screenshot(playwright.PageScreenshotOptions{
Path: playwright.String("img/zww_dtcloud_05.png"),

View File

@ -1,9 +1,11 @@
package method
import (
"bufio"
"dt_automate/tool"
"fmt"
"log"
"os"
"github.com/playwright-community/playwright-go"
)
@ -70,10 +72,10 @@ func ZWW_TSGZ() {
a.Nth(0).Fill("admin")
page.WaitForTimeout(500)
a.Nth(1).Fill("tov6LeR*R6Or_jiUC")
var name string
reader := bufio.NewReader(os.Stdin)
fmt.Print("请输入验证码:")
fmt.Scanf("%s", &name)
a.Nth(2).Fill(name)
input, _ := reader.ReadString('\n')
a.Nth(2).Fill(input)
page.WaitForTimeout(500)
//点击同意
if err := page.Locator(`.el-checkbox__inner`).Click(); err != nil {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.