-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreporter.go
More file actions
66 lines (56 loc) · 1.78 KB
/
Copy pathreporter.go
File metadata and controls
66 lines (56 loc) · 1.78 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"os"
"time"
)
type Entry struct {
Index int
PayloadName string
Description string
Mode string
FullRequest string
StatusCode int
ResponseBody string
Notes string
Result string
}
type Reporter struct {
filepath string
file *os.File
}
func NewReporter(req ParsedRequest) (*Reporter, error) {
filename := fmt.Sprintf("report_%s.md", time.Now().Format("20060102_150405"))
file, err := os.Create(filename)
if err != nil {
return nil, fmt.Errorf("creating report: %w", err)
}
// write header
fmt.Fprintf(file, "# tamper report\n")
fmt.Fprintf(file, "**Target:** %s %s://%s%s\n", req.Method, req.Scheme, req.Host, req.Path)
fmt.Fprintf(file, "**Date:** %s\n", time.Now().Format("2006-01-02 15:04"))
fmt.Fprintf(file, "**Tool:** tamper v0.1.0\n\n---\n\n")
return &Reporter{filepath: filename, file: file}, nil
}
func (r *Reporter) AppendEntry(e Entry) error {
icon := "❌"
if e.Result == "interesting" {
icon = "✅"
}
fmt.Fprintf(r.file, "## Payload %d — %s\n", e.Index, e.PayloadName)
fmt.Fprintf(r.file, "**Result:** %s %s\n", icon, e.Result)
fmt.Fprintf(r.file, "**Mode:** %s\n", e.Mode)
fmt.Fprintf(r.file, "**Description:** %s\n\n", e.Description)
fmt.Fprintf(r.file, "**Request:**\n```http\n%s\n```\n\n", e.FullRequest)
fmt.Fprintf(r.file, "**Response:** %d\n```\n%s\n```\n\n", e.StatusCode, e.ResponseBody)
fmt.Fprintf(r.file, "**Notes:** %s\n\n---\n\n", e.Notes)
return nil
}
func (r *Reporter) Finalize(total, interesting, noImpact int) {
fmt.Fprintf(r.file, "## Summary\n")
fmt.Fprintf(r.file, "- Total: %d\n", total)
fmt.Fprintf(r.file, "- Interesting: %d\n", interesting)
fmt.Fprintf(r.file, "- No impact: %d\n", noImpact)
r.file.Close()
fmt.Printf("\n[*] Report saved: %s\n", r.filepath)
}