-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (41 loc) · 1.01 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"bufio"
"fmt"
"net/http"
"os"
"strings"
"time"
)
const modelsURL = "https://api.openai.com/v1/models"
func main() {
scanner := bufio.NewScanner(os.Stdin)
validCount := 0
invalidCount := 0
for scanner.Scan() {
key := strings.TrimSpace(scanner.Text())
fmt.Printf("[*] Checking API key: %s\n", key)
client := &http.Client{}
req, err := http.NewRequest("GET", modelsURL, nil)
if err != nil {
fmt.Println("[-] Error creating request:", err)
continue
}
req.Header.Set("Authorization", "Bearer "+key)
resp, err := client.Do(req)
if err != nil {
fmt.Println("[-] Error sending request:", err)
continue
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
fmt.Printf("\033[32m[+] Valid API key: %s\033[0m\n", key)
validCount++
} else {
fmt.Printf("\033[31m[-] Invalid API key: %s\033[0m\n", key)
invalidCount++
}
time.Sleep(5 * time.Second)
}
fmt.Printf("[*] Summary: %d valid keys, %d invalid keys\n", validCount, invalidCount)
}