Skip to content

Commit f035a8c

Browse files
committed
Refactor
1 parent ef43fd3 commit f035a8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+114
-76
lines changed

Rakefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
require 'rspec/core/rake_task'
4+
require 'net/http'
5+
require 'json'
46

57
namespace :test do
68
desc 'Set up the test environment for functional tests'
@@ -56,3 +58,28 @@ namespace :docs do
5658
exit 1
5759
end
5860
end
61+
62+
namespace :assets do
63+
desc 'Check remote assets'
64+
task :check do
65+
66+
def check(endpoint)
67+
url = URI("https://assets.hahwul.com/#{endpoint}.json")
68+
response = Net::HTTP.get(url)
69+
70+
data = JSON.parse(response)
71+
puts data
72+
end
73+
74+
endpoints = [
75+
'xss-portswigger',
76+
'xss-payloadbox',
77+
'wl-params',
78+
'wl-assetnote-params'
79+
]
80+
81+
endpoints.each do |target|
82+
check target
83+
end
84+
end
85+
end

cmd/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"time"
1111

1212
spinner "github.com/briandowns/spinner"
13+
"github.com/hahwul/dalfox/v2/internal/printing"
1314
model "github.com/hahwul/dalfox/v2/pkg/model"
14-
"github.com/hahwul/dalfox/v2/pkg/printing"
1515
"github.com/hahwul/dalfox/v2/pkg/scanning"
1616
voltFile "github.com/hahwul/volt/file"
1717
voltHar "github.com/hahwul/volt/format/har"

cmd/payload.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package cmd
33
import (
44
"strconv"
55

6-
"github.com/hahwul/dalfox/v2/pkg/generating"
7-
"github.com/hahwul/dalfox/v2/pkg/optimization"
8-
"github.com/hahwul/dalfox/v2/pkg/printing"
6+
"github.com/hahwul/dalfox/v2/internal/generating"
7+
"github.com/hahwul/dalfox/v2/internal/optimization"
8+
"github.com/hahwul/dalfox/v2/internal/printing"
99
"github.com/hahwul/dalfox/v2/pkg/scanning"
1010
"github.com/spf13/cobra"
1111
)

cmd/pipe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"time"
1010

1111
"github.com/briandowns/spinner"
12+
"github.com/hahwul/dalfox/v2/internal/printing"
1213
model "github.com/hahwul/dalfox/v2/pkg/model"
13-
"github.com/hahwul/dalfox/v2/pkg/printing"
1414
"github.com/hahwul/dalfox/v2/pkg/scanning"
1515
voltUtils "github.com/hahwul/volt/util"
1616
"github.com/spf13/cobra"

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"runtime"
99
"time"
1010

11-
"github.com/hahwul/dalfox/v2/pkg/har"
11+
"github.com/hahwul/dalfox/v2/internal/har"
12+
"github.com/hahwul/dalfox/v2/internal/printing"
1213
"github.com/hahwul/dalfox/v2/pkg/model"
13-
"github.com/hahwul/dalfox/v2/pkg/printing"
1414
"github.com/logrusorgru/aurora"
1515
"github.com/spf13/cobra"
1616
)

cmd/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cmd
22

33
import (
4-
"github.com/hahwul/dalfox/v2/pkg/printing"
4+
"github.com/hahwul/dalfox/v2/internal/printing"
55
"github.com/hahwul/dalfox/v2/pkg/server"
66
"github.com/spf13/cobra"
77
)

cmd/sxss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cmd
22

33
import (
4-
"github.com/hahwul/dalfox/v2/pkg/printing"
4+
"github.com/hahwul/dalfox/v2/internal/printing"
55
"github.com/hahwul/dalfox/v2/pkg/scanning"
66
"github.com/spf13/cobra"
77
)

cmd/url.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cmd
22

33
import (
4-
"github.com/hahwul/dalfox/v2/pkg/printing"
4+
"github.com/hahwul/dalfox/v2/internal/printing"
55
"github.com/hahwul/dalfox/v2/pkg/scanning"
66
"github.com/spf13/cobra"
77
)

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package cmd
22

33
import (
4-
"github.com/hahwul/dalfox/v2/pkg/printing"
4+
"github.com/hahwul/dalfox/v2/internal/printing"
55
"github.com/spf13/cobra"
66
)
77

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pkg/har/har_test.go renamed to internal/har/har_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/url"
1010
"testing"
1111

12-
"github.com/hahwul/dalfox/v2/pkg/har"
12+
"github.com/hahwul/dalfox/v2/internal/har"
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
1515
"github.com/tidwall/sjson"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pkg/optimization/optimization.go renamed to internal/optimization/optimization.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"os"
1111
"strings"
1212

13-
"github.com/hahwul/dalfox/v2/pkg/har"
13+
"github.com/hahwul/dalfox/v2/internal/har"
1414

1515
"github.com/hahwul/dalfox/v2/pkg/model"
1616
)
File renamed without changes.
File renamed without changes.
File renamed without changes.

pkg/scanning/codeview.go renamed to internal/printing/codeview.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scanning
1+
package printing
22

33
import (
44
"strconv"

internal/printing/codeview_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package printing
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestCodeView(t *testing.T) {
8+
type args struct {
9+
resbody string
10+
pattern string
11+
}
12+
tests := []struct {
13+
name string
14+
args args
15+
want string
16+
}{
17+
{
18+
name: "test with pattern",
19+
args: args{
20+
resbody: "This is a test string.\nAnother line with pattern.\nEnd of test.",
21+
pattern: "pattern",
22+
},
23+
want: "2 line: Another line with pattern.",
24+
},
25+
{
26+
name: "test without pattern",
27+
args: args{
28+
resbody: "This is a test string.\nAnother line.\nEnd of test.",
29+
pattern: "pattern",
30+
},
31+
want: "",
32+
},
33+
}
34+
for _, tt := range tests {
35+
t.Run(tt.name, func(t *testing.T) {
36+
if got := CodeView(tt.args.resbody, tt.args.pattern); got != tt.want {
37+
t.Errorf("CodeView() = %v, want %v", got, tt.want)
38+
}
39+
})
40+
}
41+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pkg/printing/util_test.go renamed to internal/printing/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package printing_test
33
import (
44
"testing"
55

6-
dalfox "github.com/hahwul/dalfox/v2/pkg/printing"
6+
dalfox "github.com/hahwul/dalfox/v2/internal/printing"
77
"github.com/stretchr/testify/assert"
88
)
99

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lib/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package lib
33
import (
44
"time"
55

6-
"github.com/hahwul/dalfox/v2/pkg/har"
6+
"github.com/hahwul/dalfox/v2/internal/har"
77
"github.com/hahwul/dalfox/v2/pkg/model"
88
)
99

pkg/model/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"sync"
66
t "time"
77

8-
"github.com/hahwul/dalfox/v2/pkg/har"
8+
"github.com/hahwul/dalfox/v2/internal/har"
99

1010
s "github.com/briandowns/spinner"
1111
a "github.com/logrusorgru/aurora"

pkg/scanning/bav.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"net/url"
66
"sync"
77

8+
"github.com/hahwul/dalfox/v2/internal/optimization"
89
"github.com/hahwul/dalfox/v2/pkg/model"
9-
"github.com/hahwul/dalfox/v2/pkg/optimization"
1010
)
1111

1212
// SSTIAnalysis is basic check for SSTI
@@ -43,7 +43,7 @@ func SSTIAnalysis(target string, options model.Options, rl *rateLimiter) {
4343
wg.Wait()
4444
}
4545

46-
//CRLFAnalysis is basic check for CRLF Injection
46+
// CRLFAnalysis is basic check for CRLF Injection
4747
func CRLFAnalysis(target string, options model.Options, rl *rateLimiter) {
4848
bpu, _ := url.Parse(target)
4949
bpd := bpu.Query()
@@ -75,7 +75,7 @@ func CRLFAnalysis(target string, options model.Options, rl *rateLimiter) {
7575

7676
}
7777

78-
//ESIIAnalysis is basic check for CRLF Injection
78+
// ESIIAnalysis is basic check for CRLF Injection
7979
func ESIIAnalysis(target string, options model.Options, rl *rateLimiter) {
8080
bpu, _ := url.Parse(target)
8181
bpd := bpu.Query()
@@ -107,7 +107,7 @@ func ESIIAnalysis(target string, options model.Options, rl *rateLimiter) {
107107

108108
}
109109

110-
//SqliAnalysis is basic check for SQL Injection
110+
// SqliAnalysis is basic check for SQL Injection
111111
func SqliAnalysis(target string, options model.Options, rl *rateLimiter) {
112112
// sqli payload
113113

@@ -141,7 +141,7 @@ func SqliAnalysis(target string, options model.Options, rl *rateLimiter) {
141141

142142
}
143143

144-
//OpenRedirectorAnalysis is basic check for open redirectors
144+
// OpenRedirectorAnalysis is basic check for open redirectors
145145
func OpenRedirectorAnalysis(target string, options model.Options, rl *rateLimiter) {
146146

147147
// openredirect payload

pkg/scanning/foundaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"os/exec"
55
"strings"
66

7+
"github.com/hahwul/dalfox/v2/internal/printing"
78
"github.com/hahwul/dalfox/v2/pkg/model"
8-
"github.com/hahwul/dalfox/v2/pkg/printing"
99
)
1010

1111
// foundAction is after command function.

pkg/scanning/parameterAnalysis.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212
"time"
1313

1414
"github.com/PuerkitoBio/goquery"
15+
"github.com/hahwul/dalfox/v2/internal/optimization"
16+
"github.com/hahwul/dalfox/v2/internal/printing"
17+
"github.com/hahwul/dalfox/v2/internal/verification"
1518
"github.com/hahwul/dalfox/v2/pkg/model"
16-
"github.com/hahwul/dalfox/v2/pkg/optimization"
17-
"github.com/hahwul/dalfox/v2/pkg/printing"
18-
"github.com/hahwul/dalfox/v2/pkg/verification"
1919
voltFile "github.com/hahwul/volt/file"
2020
vlogger "github.com/hahwul/volt/logger"
2121
voltUtils "github.com/hahwul/volt/util"
@@ -161,7 +161,7 @@ func processParams(target string, paramsQue chan string, results chan model.Para
161161
pLog.Debug(lineSum)
162162
}
163163
if vrs {
164-
code = CodeView(resbody, "DalFox")
164+
code = printing.CodeView(resbody, "DalFox")
165165
code = code[:len(code)-5]
166166
pointer := optimization.Abstraction(resbody, "DalFox")
167167
smap := "Injected: "

pkg/scanning/scan.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import (
1313
"sync"
1414
"time"
1515

16-
"github.com/hahwul/dalfox/v2/pkg/har"
16+
"github.com/hahwul/dalfox/v2/internal/har"
1717

1818
"golang.org/x/term"
1919

2020
"github.com/briandowns/spinner"
21+
"github.com/hahwul/dalfox/v2/internal/optimization"
22+
"github.com/hahwul/dalfox/v2/internal/printing"
23+
"github.com/hahwul/dalfox/v2/internal/report"
24+
"github.com/hahwul/dalfox/v2/internal/verification"
2125
"github.com/hahwul/dalfox/v2/pkg/model"
22-
"github.com/hahwul/dalfox/v2/pkg/optimization"
23-
"github.com/hahwul/dalfox/v2/pkg/printing"
24-
"github.com/hahwul/dalfox/v2/pkg/report"
25-
"github.com/hahwul/dalfox/v2/pkg/verification"
2626
voltFile "github.com/hahwul/volt/file"
2727
)
2828

@@ -787,7 +787,7 @@ func Scan(target string, options model.Options, sid string) (model.Result, error
787787
resultsChan <- poc
788788
}
789789
} else {
790-
code := CodeView(resbody, v["payload"])
790+
code := printing.CodeView(resbody, v["payload"])
791791
printing.DalLog("WEAK", "Reflected Payload in JS: "+v["param"]+"="+v["payload"], options)
792792
printing.DalLog("CODE", code, options)
793793
poc := model.PoC{
@@ -838,7 +838,7 @@ func Scan(target string, options model.Options, sid string) (model.Result, error
838838
} else if strings.Contains(v["type"], "inATTR") {
839839
if vds {
840840
if vStatus[v["param"]] == false {
841-
code := CodeView(resbody, v["payload"])
841+
code := printing.CodeView(resbody, v["payload"])
842842
printing.DalLog("VULN", "Triggered XSS Payload (found DOM Object): "+v["param"]+"="+v["payload"], options)
843843
printing.DalLog("CODE", code, options)
844844
poc := model.PoC{
@@ -886,7 +886,7 @@ func Scan(target string, options model.Options, sid string) (model.Result, error
886886
}
887887
} else if vrs {
888888
if vStatus[v["param"]] == false {
889-
code := CodeView(resbody, v["payload"])
889+
code := printing.CodeView(resbody, v["payload"])
890890
printing.DalLog("WEAK", "Reflected Payload in Attribute: "+v["param"]+"="+v["payload"], options)
891891
printing.DalLog("CODE", code, options)
892892
poc := model.PoC{
@@ -935,7 +935,7 @@ func Scan(target string, options model.Options, sid string) (model.Result, error
935935
} else {
936936
if vds {
937937
if vStatus[v["param"]] == false {
938-
code := CodeView(resbody, v["payload"])
938+
code := printing.CodeView(resbody, v["payload"])
939939
printing.DalLog("VULN", "Triggered XSS Payload (found DOM Object): "+v["param"]+"="+v["payload"], options)
940940
printing.DalLog("CODE", code, options)
941941
poc := model.PoC{
@@ -983,7 +983,7 @@ func Scan(target string, options model.Options, sid string) (model.Result, error
983983
}
984984
} else if vrs {
985985
if vStatus[v["param"]] == false {
986-
code := CodeView(resbody, v["payload"])
986+
code := printing.CodeView(resbody, v["payload"])
987987
printing.DalLog("WEAK", "Reflected Payload in HTML: "+v["param"]+"="+v["payload"], options)
988988
printing.DalLog("CODE", code, options)
989989
poc := model.PoC{

pkg/scanning/sendReq.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"strings"
1212
"time"
1313

14-
"github.com/hahwul/dalfox/v2/pkg/har"
14+
"github.com/hahwul/dalfox/v2/internal/har"
1515

16+
"github.com/hahwul/dalfox/v2/internal/optimization"
17+
"github.com/hahwul/dalfox/v2/internal/printing"
18+
"github.com/hahwul/dalfox/v2/internal/verification"
1619
"github.com/hahwul/dalfox/v2/pkg/model"
17-
"github.com/hahwul/dalfox/v2/pkg/optimization"
18-
"github.com/hahwul/dalfox/v2/pkg/printing"
19-
"github.com/hahwul/dalfox/v2/pkg/verification"
2020
vlogger "github.com/hahwul/volt/logger"
2121
"github.com/sirupsen/logrus"
2222
)

pkg/scanning/staticAnlaysis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"strconv"
66
"strings"
77

8+
"github.com/hahwul/dalfox/v2/internal/optimization"
89
"github.com/hahwul/dalfox/v2/pkg/model"
9-
"github.com/hahwul/dalfox/v2/pkg/optimization"
1010
)
1111

1212
// StaticAnalysis is found information on original req/res

pkg/scanning/transport.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"net/url"
1010
"time"
1111

12-
"github.com/hahwul/dalfox/v2/pkg/har"
12+
"github.com/hahwul/dalfox/v2/internal/har"
13+
"github.com/hahwul/dalfox/v2/internal/printing"
1314
"github.com/hahwul/dalfox/v2/pkg/model"
14-
"github.com/hahwul/dalfox/v2/pkg/printing"
1515
"github.com/tidwall/sjson"
1616
)
1717

0 commit comments

Comments
 (0)