44 "encoding/json"
55 "errors"
66 "fmt"
7- "github.com/fatih/color"
8- "github.com/nsecho/furlzz/internal/config"
97 "os"
108 "path/filepath"
119 "regexp"
@@ -14,9 +12,12 @@ import (
1412 "strings"
1513 "time"
1614
15+ "github.com/fatih/color"
1716 "github.com/frida/frida-go/frida"
18- "github.com/nsecho/furlzz/mutator"
1917 "github.com/spf13/cobra"
18+
19+ "github.com/nsecho/furlzz/internal/config"
20+ "github.com/nsecho/furlzz/mutator"
2021)
2122
2223var (
@@ -36,6 +37,11 @@ var fuzzCmd = &cobra.Command{
3637 return err
3738 }
3839
40+ debug , err := cmd .Flags ().GetBool ("debug" )
41+ if err != nil {
42+ return err
43+ }
44+
3945 var cfg config.Config
4046 f , err := os .Open (configPath )
4147 if err != nil {
@@ -193,7 +199,7 @@ var fuzzCmd = &cobra.Command{
193199 delegateName = fuzzMap ["delegate" ].(string )
194200 }
195201
196- _ = script .ExportsCall ("setup_fuzz" , method , uiapp , delegateName , sceneName )
202+ _ = script .ExportsCall ("setup_fuzz" , method , uiapp , delegateName , sceneName , debug )
197203
198204 l .Infof ("Finished fuzz setup" )
199205
@@ -208,10 +214,19 @@ var fuzzCmd = &cobra.Command{
208214 case mutated := <- ch :
209215 lastInput = mutated .Input
210216 l .Infof ("[%s] %s\n " , color .New (color .FgCyan ).Sprintf ("%s" , mutated .Mutation ), mutated .Input )
217+
211218 _ = script .ExportsCall ("fuzz" , cfg .Type , mutated .Input )
219+
212220 if cfg .Timeout > 0 {
213221 time .Sleep (time .Duration (cfg .Timeout ) * time .Second )
214222 }
223+
224+ // Check if script has new coverage blocks
225+ has , ok := script .ExportsCall ("has_new_blocks" ).(bool )
226+ if ok && has {
227+ l .Infof ("New blocks found, continuing fuzzing..." )
228+ mut .HandleNewCoverage (mutated .MutatedInputs )
229+ }
215230 }
216231 }
217232
@@ -275,6 +290,7 @@ func spawnApp(dev frida.DeviceInt, app string, toSpawn bool, sTimeout uint) erro
275290
276291func init () {
277292 fuzzCmd .Flags ().StringP ("config" , "c" , "furlzz.json" , "Path to config file" )
293+ fuzzCmd .Flags ().BoolP ("debug" , "d" , true , "Enable debug output (useful for coverage)" )
278294
279295 rootCmd .AddCommand (fuzzCmd )
280296}
0 commit comments