initial commit
parent
474442da38
commit
d351ac3ca4
|
@ -10,3 +10,6 @@
|
||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
|
# vscode
|
||||||
|
*.vscode
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
analyzer-d4-passivessl fetch a redis feed of certificate and TLS sessions and massage the dataset to be usable by lookup-d4-passivessl service.
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
```bash
|
||||||
|
go get github.com/gomodule/redigo/redis
|
||||||
|
go get github.com/lib/pq
|
||||||
|
```
|
|
@ -0,0 +1,50 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// APACHE 2.0
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/gomodule/redigo/redis"
|
||||||
|
_ "github.com/lib/pq"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// connect to redis
|
||||||
|
c, err := redis.Dial("tcp", ":6380", redis.DialDatabase(2))
|
||||||
|
defer c.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// connect to db
|
||||||
|
connStr := "user=postgres password=postgres dbname=passivessl"
|
||||||
|
db, err := sql.Open("postgres", connStr)
|
||||||
|
defer db.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// pop redis queue
|
||||||
|
for {
|
||||||
|
jsonPath, err := redis.String(c.Do("LPOP", "analyzer:ja3-jl:0894517855f047d2a77b4473d3a9cc5b"))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Queue processed")
|
||||||
|
}
|
||||||
|
// read corresponding json file
|
||||||
|
dat, err := ioutil.ReadFile(jsonPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
q := `INSERT INTO sessions (data) VALUES ($1) RETURNING id`
|
||||||
|
id := 0
|
||||||
|
err = db.QueryRow(q, dat).Scan(&id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println("New record ID is:", id)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue