52 lines
965 B
Go
52 lines
965 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
func _search() {
|
|
// 打开文件
|
|
file, err := os.Open("lastgood.xml")
|
|
if err != nil {
|
|
log.Fatalf("无法打开文件: %v", err)
|
|
}
|
|
defer file.Close()
|
|
|
|
// 搜索目标字段
|
|
searchField := "SUSER_PASSWORD"
|
|
password := ""
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
for scanner.Scan() {
|
|
line := scanner.Text()
|
|
if strings.Contains(line, searchField) {
|
|
fmt.Printf("找到字段: %s\n", line)
|
|
|
|
// 提取密码
|
|
re := regexp.MustCompile(`Value="([^"]+)"`)
|
|
matches := re.FindStringSubmatch(line)
|
|
if len(matches) > 1 {
|
|
password = matches[1]
|
|
}
|
|
break
|
|
}
|
|
}
|
|
|
|
// 检查文件是否已完全扫描
|
|
if err := scanner.Err(); err != nil {
|
|
log.Fatalf("读取文件失败: %v", err)
|
|
}
|
|
|
|
// 输出提取的密码
|
|
if password != "" {
|
|
fmt.Printf("提取的密码是: %s\n", password)
|
|
} else {
|
|
fmt.Printf("未找到字段或未提取到密码: %s\n", searchField)
|
|
}
|
|
}
|