Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dc4c164b4b | |||
| 4d999aacfd |
@@ -87,7 +87,10 @@ const getDuration = (start, end) => {
|
|||||||
const ms = new Date(end) - new Date(start)
|
const ms = new Date(end) - new Date(start)
|
||||||
const sec = Math.floor(ms / 1000)
|
const sec = Math.floor(ms / 1000)
|
||||||
if (sec < 60) return `${sec}s`
|
if (sec < 60) return `${sec}s`
|
||||||
return `${Math.floor(sec / 60)}m ${sec % 60}s`
|
if (sec < 3600) return `${Math.floor(sec / 60)}m ${sec % 60}s`
|
||||||
|
const hours = Math.floor(sec / 3600)
|
||||||
|
const minutes = Math.floor((sec % 3600) / 60)
|
||||||
|
return `${hours}h ${minutes}m`
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSeverityCount = (scan, sev) => {
|
const getSeverityCount = (scan, sev) => {
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ package runner
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"nucleus/internal/db"
|
"nucleus/internal/db"
|
||||||
@@ -57,11 +60,23 @@ func RunScan(targetID int, isManual bool) {
|
|||||||
line := scanner.Bytes()
|
line := scanner.Bytes()
|
||||||
var nf models.NucleiFinding
|
var nf models.NucleiFinding
|
||||||
if err := json.Unmarshal(line, &nf); err == nil {
|
if err := json.Unmarshal(line, &nf); err == nil {
|
||||||
|
displayHost := nf.Host
|
||||||
|
ipStr := displayHost
|
||||||
|
if hostPart, _, err := net.SplitHostPort(displayHost); err == nil {
|
||||||
|
ipStr = hostPart
|
||||||
|
}
|
||||||
|
if ip := net.ParseIP(ipStr); ip != nil {
|
||||||
|
if names, err := net.LookupAddr(ip.String()); err == nil && len(names) > 0 {
|
||||||
|
hostname := strings.TrimSuffix(names[0], ".")
|
||||||
|
displayHost = fmt.Sprintf("%s (%s)", hostname, displayHost)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Insert finding
|
// Insert finding
|
||||||
res, err := db.DB.Exec(`
|
res, err := db.DB.Exec(`
|
||||||
INSERT INTO findings (scan_id, template_id, name, severity, host, matched_at, description)
|
INSERT INTO findings (scan_id, template_id, name, severity, host, matched_at, description)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
`, scanID, nf.TemplateID, nf.Info.Name, nf.Info.Severity, nf.Host, nf.MatchedAt, nf.Info.Description)
|
`, scanID, nf.TemplateID, nf.Info.Name, nf.Info.Severity, displayHost, nf.MatchedAt, nf.Info.Description)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fid, _ := res.LastInsertId()
|
fid, _ := res.LastInsertId()
|
||||||
@@ -71,7 +86,7 @@ func RunScan(targetID int, isManual bool) {
|
|||||||
TemplateID: nf.TemplateID,
|
TemplateID: nf.TemplateID,
|
||||||
Name: nf.Info.Name,
|
Name: nf.Info.Name,
|
||||||
Severity: nf.Info.Severity,
|
Severity: nf.Info.Severity,
|
||||||
Host: nf.Host,
|
Host: displayHost,
|
||||||
MatchedAt: nf.MatchedAt,
|
MatchedAt: nf.MatchedAt,
|
||||||
Description: nf.Info.Description,
|
Description: nf.Info.Description,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user