Best Syzkaller code snippet using prog.arg
splice.go
Source:splice.go
...16 "github.com/google/syzkaller/prog"17 _ "github.com/google/syzkaller/sys"18)19var (20 flagOS = flag.String("os", runtime.GOOS, "target os")21 flagArch = flag.String("arch", runtime.GOARCH, "target arch")22 flagPoc = flag.String("poc", "", "poc")23 flagLen = flag.Int("len", prog.RecommendedCalls, "number of calls in programs")24 flagEnable = flag.String("enable", "", "comma-separated list of enabled syscalls")25)26type mutationTypes struct {27 target *prog.Target28 prioSum float6429 args []mutationType30 similarArgs []mutationType31 argsBuffer [16]mutationType32}33type mutationType struct {34 arg prog.Arg35 ctx prog.ArgCtx36 priority float6437 prio float6438}39func (mt *mutationTypes) collectTypes(arg prog.Arg, ctx *prog.ArgCtx) {40 pValue := float64(0)41 switch typ := arg.Type().(type) {42 case *prog.StructType:43 for _, field := range typ.Fields {44 switch field.Type.(type) {45 case *prog.StructType:46 case *prog.UnionType:47 case *prog.ConstType:48 case *prog.CsumType:49 case *prog.ResourceType:50 default:51 pValue += float64(3)52 }53 }54 mt.prioSum += pValue55 mt.args = append(mt.args, mutationType{arg, *ctx, mt.prioSum, pValue})56 case *prog.UnionType:57 mt.prioSum += float64(4)58 mt.args = append(mt.args, mutationType{arg, *ctx, mt.prioSum, pValue})59 }60}61func (mt *mutationTypes) chooseType(r *rand.Rand) (prog.Arg, prog.ArgCtx, int) {62 goal := mt.prioSum * r.Float64()63 chosenIdx := sort.Search(len(mt.args), func(i int) bool { return mt.args[i].priority >= goal })64 arg := mt.args[chosenIdx]65 return arg.arg, arg.ctx, chosenIdx66}67func replaceArg(arg, arg1 prog.Arg) {68 if arg == arg1 {69 panic("same arg")70 }71 fmt.Printf("\nReplacing\n%s\nwith\n%s\n", arg, arg1)72 switch a := arg.(type) {73 case *prog.ConstArg:74 *a = *arg1.(*prog.ConstArg)75 case *prog.ResultArg:76 // replaceResultArg(a, arg1.(*prog.ResultArg))77 case *prog.PointerArg:78 *a = *arg1.(*prog.PointerArg)79 case *prog.UnionArg:80 *a = *arg1.(*prog.UnionArg)81 case *prog.DataArg:82 *a = *arg1.(*prog.DataArg)83 case *prog.GroupArg:84 a1 := arg1.(*prog.GroupArg)85 if len(a.Inner) != len(a1.Inner) {86 panic(fmt.Sprintf("replaceArg: group fields don't match: %v/%v",87 len(a.Inner), len(a1.Inner)))88 }89 a.ArgCommon = a1.ArgCommon90 for i := range a.Inner {91 replaceArg(a.Inner[i], a1.Inner[i])92 }93 default:94 panic(fmt.Sprintf("replaceArg: bad arg kind %#v", arg))95 }96}97func parseArg(p *prog.Prog) map[string]mutationTypes {98 argMap := make(map[string]mutationTypes)99 for _, c := range p.Calls {100 fmt.Printf("syscall: %s\n", c.Meta.Name)101 mt := &mutationTypes{target: p.Target, prioSum: float64(0)}102 prog.ForeachArg(c, mt.collectTypes)103 for _, aa := range mt.args {104 fmt.Printf("This is the arg: %s(%T): %s\n", aa.arg.Type().String(), aa.arg, aa.arg)105 }106 argMap[c.Meta.Name] = *mt107 }108 return argMap109}110func logArgMap(argMap map[string]mutationTypes) {111 for syscall, mt := range argMap {112 fmt.Printf("in syscall %s\n", syscall)113 for _, aa := range mt.args {114 fmt.Printf("This is the arg: %s(%T)\n", aa.arg.Type().String(), aa.arg)115 }116 }117}118func getSimilarTypes(a, b map[string]mutationTypes) map[string]*mutationTypes {119 sameArg := make(map[string]*mutationTypes)120 prioSum := float64(0)121 for syscallA, mtA := range a {122 for syscallB, mtB := range b {123 if syscallA == syscallB {124 Mts := &mutationTypes{}125 Mts.args = make([]mutationType, 0)126 Mts.similarArgs = make([]mutationType, 0)127 for _, argA := range mtA.args {128 for _, argB := range mtB.args {129 if argA.arg.Type().String() == argB.arg.Type().String() {130 fmt.Printf("Adding: %s\n", argA.arg.Type().String())131 prioSum += argA.prio132 Mts.args = append(Mts.args, mutationType{argA.arg, argA.ctx, prioSum, argA.prio})133 Mts.similarArgs = append(Mts.similarArgs, argB)134 }135 }136 }137 Mts.target = mtA.target138 Mts.prioSum = prioSum139 if len(Mts.args) == 0 {140 continue141 }142 sameArg[syscallA] = Mts143 }144 }145 }146 return sameArg147}148func main() {149 flag.Parse()150 if *flagPoc == "" {151 fmt.Printf("please specify the poc by -poc\n")152 os.Exit(1)153 }154 target, err := prog.GetTarget(*flagOS, *flagArch)155 if err != nil {156 fmt.Fprintf(os.Stderr, "%v", err)157 os.Exit(1)158 }159 seed := time.Now().UnixNano()160 rs := rand.NewSource(seed)161 r := rand.New(rs)162 var syscalls map[*prog.Syscall]bool163 if *flagEnable != "" {164 enabled := strings.Split(*flagEnable, ",")165 syscallsIDs, err := mgrconfig.ParseEnabledSyscalls(target, enabled, nil)166 if err != nil {167 fmt.Fprintf(os.Stderr, "failed to parse enabled syscalls: %v", err)168 os.Exit(1)169 }170 syscalls = make(map[*prog.Syscall]bool)171 for _, id := range syscallsIDs {172 syscalls[target.Syscalls[id]] = true173 }174 var disabled map[*prog.Syscall]string175 syscalls, disabled = target.TransitivelyEnabledCalls(syscalls)176 for c, reason := range disabled {177 fmt.Fprintf(os.Stderr, "disabling %v: %v\n", c.Name, reason)178 }179 }180 data, err := ioutil.ReadFile(*flagPoc)181 if err != nil {182 fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err)183 os.Exit(1)184 }185 poc, err := target.Deserialize(data, prog.NonStrict)186 if err != nil {187 fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err)188 os.Exit(1)189 }190 PocArgMaps := parseArg(poc)191 // logArgMap(PocArgMaps)192 var p *prog.Prog193 if flag.NArg() == 0 {194 fmt.Printf("please specify the input to be mutated\n")195 os.Exit(-1)196 } else {197 data, err := ioutil.ReadFile(flag.Arg(0))198 if err != nil {199 fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err)200 os.Exit(1)201 }202 p, err = target.Deserialize(data, prog.NonStrict)203 pOriginal := p.Clone()204 if err != nil {205 fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err)206 os.Exit(1)207 }208 fmt.Printf("Original input: %s\n", p.Serialize())209 SeedArgMaps := parseArg(p)210 // logArgMap(SeedArgMaps)211 SimilarArgMap := getSimilarTypes(SeedArgMaps, PocArgMaps)212 fmt.Printf("size of similar ArgMap : %v\n", len(SimilarArgMap))213 if len(SimilarArgMap) == 0 {214 fmt.Printf("Not similar inputs\n")215 return216 }217 // choose syscall218 sumPrio := float64(0)219 for _, mts := range SimilarArgMap {220 sumPrio += mts.prioSum221 }222 goal := sumPrio * rand.Float64()223 var syscall string224 sumPrio = float64(0)225 for sys, mts := range SimilarArgMap {226 sumPrio += mts.prioSum227 if sumPrio > goal {228 syscall = sys229 break230 }231 }232 fmt.Printf("Splicing syscall %s\n", syscall)233 targetMt := SimilarArgMap[syscall]234 if len(targetMt.args) == 0 {235 fmt.Printf("no similar args")236 return237 }238 for {239 arg, _, chosenIdx := targetMt.chooseType(r)240 targetArg := targetMt.similarArgs[chosenIdx].arg241 if _, ok := arg.(*prog.UnionArg); ok {242 fmt.Printf("Replacing UnionArg\n")243 fmt.Printf("Replacing %s\n", arg.Type().String())244 fmt.Printf("Before Mutation:\n%s\n", p.Serialize())245 replaceArg(arg, targetArg)246 fmt.Printf("After Mutation:\n%s\n", p.Serialize())247 } else if argGroup, ok := arg.(*prog.GroupArg); ok {248 for idx, inner := range argGroup.Inner {249 // 3 outof 10 to mutate the inner250 switch inner.Type().(type) {251 case *prog.UnionType, *prog.IntType, *prog.PtrType,252 *prog.FlagsType, *prog.LenType,253 *prog.VmaType, *prog.BufferType, *prog.ArrayType:254 targetArgGroup := targetArg.(*prog.GroupArg)255 if r.Intn(10) < 3 {256 fmt.Printf("Replacing %s(%T)\n", arg.Type().String(), inner.Type())257 fmt.Printf("Before Mutation:\n%s\n", p.Serialize())258 replaceArg(argGroup.Inner[idx], targetArgGroup.Inner[idx])259 fmt.Printf("After Mutation:\n%s\n", p.Serialize())260 }261 }262 }263 } else {264 panic("Unknown arg")265 }266 if r.Intn(5) < 3 {267 break268 }269 }270 fmt.Printf("\nBefore mutation:\n%s\n", pOriginal.Serialize())271 fmt.Printf("This is poc:\n%s\n", poc.Serialize())272 fmt.Printf("after mutation:\n%s\n", p.Serialize())273 }274}...
sss.go
Source:sss.go
...15 "github.com/google/syzkaller/prog"16 _ "github.com/google/syzkaller/sys"17)18var (19 flagOS = flag.String("os", runtime.GOOS, "target os")20 flagArch = flag.String("arch", runtime.GOARCH, "target arch")21 flagPoc = flag.String("poc", "", "poc")22 flagLen = flag.Int("len", prog.RecommendedCalls, "number of calls in programs")23 flagEnable = flag.String("enable", "", "comma-separated list of enabled syscalls")24)25type Arginfo struct {26 TemplateName string27 Value prog.Arg28}29// func replaceResultArg(arg, arg1 *prog.ResultArg) {30// // Remove link from `a.Res` to `arg`.31// if arg.Res != nil {32// delete(arg.Res.uses, arg)33// }34// // Copy all fields from `arg1` to `arg` except for the list of args that use `arg`.35// uses := arg.uses36// *arg = *arg137// arg.uses = uses38// // Make the link in `arg.Res` (which is now `Res` of `arg1`) to point to `arg` instead of `arg1`.39// if arg.Res != nil {40// resUses := arg.Res.uses41// delete(resUses, arg1)42// resUses[arg] = true43// }44// }45func replaceArg(arg, arg1 prog.Arg) {46 switch a := arg.(type) {47 case *prog.ConstArg:48 *a = *arg1.(*prog.ConstArg)49 case *prog.ResultArg:50 // replaceResultArg(a, arg1.(*prog.ResultArg))51 case *prog.PointerArg:52 *a = *arg1.(*prog.PointerArg)53 case *prog.UnionArg:54 *a = *arg1.(*prog.UnionArg)55 case *prog.DataArg:56 *a = *arg1.(*prog.DataArg)57 case *prog.GroupArg:58 a1 := arg1.(*prog.GroupArg)59 if len(a.Inner) != len(a1.Inner) {60 panic(fmt.Sprintf("replaceArg: group fields don't match: %v/%v",61 len(a.Inner), len(a1.Inner)))62 }63 a.ArgCommon = a1.ArgCommon64 for i := range a.Inner {65 replaceArg(a.Inner[i], a1.Inner[i])66 }67 default:68 panic(fmt.Sprintf("replaceArg: bad arg kind %#v", arg))69 }70}71func parseArg(p *prog.Prog) map[string][]prog.Arg {72 argMap := make(map[string][]prog.Arg)73 for _, c := range p.Calls {74 args := make([]prog.Arg, 0)75 prog.ForeachArg(c, func(arg prog.Arg, ctx *prog.ArgCtx) {76 switch arg.Type().(type) {77 case *prog.UnionType, *prog.ConstType, *prog.IntType,78 *prog.FlagsType, *prog.LenType, *prog.CsumType,79 *prog.VmaType, *prog.BufferType, *prog.ArrayType:80 fmt.Printf("adding %s\n", arg.Type().String())81 args = append(args, arg)82 }83 })84 argMap[c.Meta.Name] = args85 }86 return argMap87}88func logArgMap(argMap map[string][]prog.Arg) {89 for syscall, args := range argMap {90 fmt.Printf("in syscall %s\n", syscall)91 for _, arg := range args {92 fmt.Printf("arg Type %s, template: %s (%T)\n", arg.Type().String(), arg.Type().TemplateName(), arg)93 }94 }95}96func main() {97 flag.Parse()98 if *flagPoc == "" {99 fmt.Printf("please specify the poc by -poc\n")100 os.Exit(1)101 }102 target, err := prog.GetTarget(*flagOS, *flagArch)103 if err != nil {104 fmt.Fprintf(os.Stderr, "%v", err)105 os.Exit(1)106 }107 seed := time.Now().UnixNano()108 rs := rand.NewSource(seed)109 r := rand.New(rs)110 var syscalls map[*prog.Syscall]bool111 if *flagEnable != "" {112 enabled := strings.Split(*flagEnable, ",")113 syscallsIDs, err := mgrconfig.ParseEnabledSyscalls(target, enabled, nil)114 if err != nil {115 fmt.Fprintf(os.Stderr, "failed to parse enabled syscalls: %v", err)116 os.Exit(1)117 }118 syscalls = make(map[*prog.Syscall]bool)119 for _, id := range syscallsIDs {120 syscalls[target.Syscalls[id]] = true121 }122 var disabled map[*prog.Syscall]string123 syscalls, disabled = target.TransitivelyEnabledCalls(syscalls)124 for c, reason := range disabled {125 fmt.Fprintf(os.Stderr, "disabling %v: %v\n", c.Name, reason)126 }127 }128 data, err := ioutil.ReadFile(flag.Arg(0))129 if err != nil {130 fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err)131 os.Exit(1)132 }133 poc, err := target.Deserialize(data, prog.NonStrict)134 if err != nil {135 fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err)136 os.Exit(1)137 }138 argMaps := parseArg(poc)139 logArgMap(argMaps)140 var p *prog.Prog141 if flag.NArg() == 0 {142 fmt.Printf("please specify the input to be mutated\n")143 os.Exit(-1)144 } else {145 data, err := ioutil.ReadFile(flag.Arg(0))146 if err != nil {147 fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err)148 os.Exit(1)149 }150 p, err = target.Deserialize(data, prog.NonStrict)151 if err != nil {152 fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err)153 os.Exit(1)154 }155 fmt.Printf("Original input: %s\n", p.Serialize())156 for _, c := range p.Calls {157 args := argMaps[c.Meta.Name]158 if len(args) == 0 {159 fmt.Printf("skip %s\n", c.Meta.Name)160 continue161 }162 prog.ForeachArg(c, func(arg prog.Arg, ctx *prog.ArgCtx) {163 switch arg.(type) {164 // case *prog.UnionArg, *prog.GroupArg, *prog.StructArg:165 default:166 for _, pocArg := range args {167 if pocArg.Type().String() == arg.Type().String() &&168 pocArg.Type().TemplateName() == arg.Type().TemplateName() {169 fmt.Printf("Found %s != %s\n", pocArg.Type().String(), arg.Type().String())170 if r.Intn(8) > 1 {171 continue172 }173 replaceArg(arg, pocArg)174 fmt.Printf("after mutation: %s\n", p.Serialize())175 break176 } else {177 fmt.Printf("Skip %s != %s\n", pocArg.Type().String(), arg.Type().String())178 }179 }180 }181 // case *prog.PointerArg, *prog.UnionArg:182 // fmt.Printf("%s : %s\n", arg.Type().String(), arg.Type().Name())183 // fmt.Printf("Temple name: %s\n", arg.Type().TemplateName())184 // fmt.Printf("ARG: %T\n", arg)185 // fmt.Printf("Type2: %T\n\n", arg.Type())186 // case *prog.GroupArg:187 // fmt.Printf("%s : %s\n", arg.Type().String(), arg.Type().Name())188 // fmt.Printf("Temple name: %s\n", arg.Type().TemplateName())189 // fmt.Printf("ARG: %T\n", arg)190 // fmt.Printf("Type2: %T\n\n", arg.Type())191 // if typ, ok := a.Type().(*prog.StructType); ok {192 // fmt.Printf("Found struct: %s\n", typ.Name())193 // for i, fff := range typ.Fields {194 // fmt.Printf("Field %d: %s (%s, %T)\n", i, fff.Name, fff.Type.TemplateName(), fff.Type)195 // }196 // fmt.Printf("\n")197 // }198 // }199 // 1. arg.Type().String() are the same and arg.Type().TemplateName() are the same200 // fmt.Printf("%s : %s\n", arg.Type().String(), arg.Type().Name())201 // fmt.Printf("Temple name: %s\n", arg.Type().TemplateName())202 // fmt.Printf("ARG: %T\n", arg)203 // fmt.Printf("Type2: %T\n", arg.Type())204 // switch a := arg.Type().(type) {205 // case *prog.StructType:206 // for _, f := range a.Fields {207 // fmt.Printf("In structure: type: %T, name: %s, string: %s\n", f.Type, f.Type.Name(), f.Type.String())208 // switch a := f.Type.(type) {209 // case *prog.BufferType:210 // switch a.Kind {211 // case prog.BufferString:212 // fmt.Printf("Value: %v\n", a.Values)213 // // case prog.FlagsType:214 // // fmt.Printf("Value: %v\n", a.Values)215 // }216 // }217 // }218 // case *prog.BufferType:219 // fmt.Printf("For each: Value: %v\n", a.Values)220 // case *prog.FlagsType:221 // case *prog.IntType:222 // fmt.Printf("FlagsType value: %v\n", arg.(*prog.ConstArg).Val)223 // }224 // fmt.Printf("\n")225 })226 }227 fmt.Printf("after mutation: %s\n", p.Serialize())228 }229}...
init_iptables.go
Source:init_iptables.go
...5 "strings"6 "github.com/google/syzkaller/prog"7)8func (arch *arch) generateIptables(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg) (9 arg prog.Arg, calls []*prog.Call) {10 return arch.generateNetfilterTable(g, typ, dir, old, true, 5)11}12func (arch *arch) generateArptables(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg) (13 arg prog.Arg, calls []*prog.Call) {14 return arch.generateNetfilterTable(g, typ, dir, old, false, 3)15}16func (arch *arch) generateNetfilterTable(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg,17 hasUnion bool, hookCount int) (arg prog.Arg, calls []*prog.Call) {18 const (19 hookStart = 420 nonHookFields = 721 unused = uint64(^uint32(0))22 )23 if old == nil {24 arg = g.GenerateSpecialArg(typ, dir, &calls)25 } else {26 // TODO(dvyukov): try to restore original hook order after mutation27 // instead of assigning brand new offsets.28 arg = old29 calls = g.MutateArg(arg)30 }31 var tableArg *prog.GroupArg32 if hasUnion {33 tableArg = arg.(*prog.UnionArg).Option.(*prog.GroupArg)34 } else {35 tableArg = arg.(*prog.GroupArg)36 }37 numFileds := nonHookFields + 2*hookCount38 if len(tableArg.Inner) != numFileds {39 panic("wrong number of fields in netfilter table")40 }41 entriesArg := tableArg.Inner[numFileds-1].(*prog.GroupArg)42 if len(entriesArg.Inner) != 2 {43 panic("netfilter entries is expected to have 2 fields")44 }45 entriesArray := entriesArg.Inner[0].(*prog.GroupArg)46 // Collect offsets of entries.47 offsets := make([]uint64, len(entriesArray.Inner))48 var pos uint6449 for i, entryArg := range entriesArray.Inner {50 offsets[i] = pos51 pos += entryArg.Size()52 }53 if pos != entriesArray.Size() {54 panic("netfilter offsets are broken")55 }56 genOffset := func() uint64 {57 if g.Rand().Intn(100) == 0 {58 // Assign the underflow entry once in a while.59 // We have it in underflow hooks, so no point in using it frequently.60 return pos61 }62 return offsets[g.Rand().Intn(len(offsets))]63 }64 // Assign offsets to used hooks.65 for hook := hookStart; hook < hookStart+hookCount; hook++ {66 hookArg := tableArg.Inner[hook].(*prog.ConstArg)67 if hookArg.Type().(*prog.ConstType).Val == unused {68 continue // unused hook69 }70 hookArg.Val = genOffset()71 }72 // Assign offsets to used underflow entries.73 for hook := hookStart + hookCount; hook < hookStart+2*hookCount; hook++ {74 hookArg := tableArg.Inner[hook].(*prog.ConstArg)75 if hookArg.Type().(*prog.ConstType).Val == unused {76 continue // unused hook77 }78 hookArg.Val = pos79 }80 // Now update standard target jump offsets.81 prog.ForeachSubArg(arg, func(arg prog.Arg, _ *prog.ArgCtx) {82 if !strings.HasPrefix(arg.Type().Name(), `xt_target_t["", `) {83 return84 }85 targetArg := arg.(*prog.GroupArg)86 valArg := targetArg.Inner[3].(*prog.ConstArg)87 flagsType, ok := valArg.Type().(*prog.FlagsType)88 if !ok {89 return90 }91 if int64(valArg.Val) < 0 {92 for _, val := range flagsType.Vals {93 if val == valArg.Val {94 return // verdict95 }96 }97 }98 valArg.Val = genOffset()99 })100 return101}102func (arch *arch) generateEbtables(g *prog.Gen, typ prog.Type, dir prog.Dir, old prog.Arg) (103 arg prog.Arg, calls []*prog.Call) {104 if old == nil {105 arg = g.GenerateSpecialArg(typ, dir, &calls)106 } else {107 // TODO(dvyukov): try to restore original hook order after mutation108 // instead of assigning brand new offsets.109 arg = old110 calls = g.MutateArg(arg)111 }112 if g.Target().ArgContainsAny(arg) {113 return114 }115 hooksField, entriesField := 4, 7116 if g.Target().PtrSize == 8 {117 // Account for paddings.118 hooksField, entriesField = 5, 9119 }120 tableArg := arg.(*prog.UnionArg).Option.(*prog.GroupArg)121 entriesPtr := tableArg.Inner[entriesField].(*prog.PointerArg)122 if entriesPtr.Res == nil {123 return124 }125 entriesArray := entriesPtr.Res.(*prog.GroupArg)126 offsets := make([]uint64, len(entriesArray.Inner))127 var pos, totalEntries uint64128 for i, entriesArg0 := range entriesArray.Inner {129 entriesArg := entriesArg0.(*prog.GroupArg)130 arrayArg := entriesArg.Inner[len(entriesArg.Inner)-1].(*prog.GroupArg)131 entriesArg.Inner[2].(*prog.ConstArg).Val = totalEntries132 totalEntries += uint64(len(arrayArg.Inner))133 offsets[i] = pos134 pos += entriesArg.Size()135 }136 tableArg.Inner[2].(*prog.ConstArg).Val = totalEntries137 if pos != entriesArray.Size() {138 panic("netfilter offsets are broken")139 }140 // Assign offsets to used hooks.141 validHooks := tableArg.Inner[1].(*prog.ConstArg).Val142 hooksArg := tableArg.Inner[hooksField].(*prog.GroupArg)143 for i, hookArg0 := range hooksArg.Inner {144 hookArg := hookArg0.(*prog.ConstArg)145 if validHooks&(1<<uint(i)) == 0 {146 hookArg.Val = 0147 continue148 }149 addr := g.Target().PhysicalAddr(entriesPtr)150 if len(offsets) != 0 {151 addr += offsets[0]152 offsets = offsets[1:]153 }154 hookArg.Val = addr155 }156 // TODO(dvyukov): assign jump targets for targets.157 return158}159func (arch *arch) neutralizeEbtables(c *prog.Call) {160 // This is very hacky... just as netfilter interfaces.161 // setsockopt's len argument must be equal to size of ebt_replace + entries size.162 lenArg := c.Args[4].(*prog.ConstArg)163 tablePtr := c.Args[3].(*prog.PointerArg).Res164 if tablePtr == nil {165 return166 }167 tableArg := tablePtr.(*prog.UnionArg).Option.(*prog.GroupArg)168 entriesField := len(tableArg.Inner) - 1169 entriesArg := tableArg.Inner[entriesField].(*prog.PointerArg).Res170 if entriesArg == nil {171 return172 }173 lenArg.Val = tableArg.Size() + entriesArg.Size()174}...
arg
Using AI Code Generation
1import (2func main() {3 fmt.Println(os.Args[1])4}5import (6func main() {7 fmt.Println(os.Args[2])8}9import (10func main() {11 fmt.Println(os.Args[3])12}13import (14func main() {15 fmt.Println(os.Args[4])16}
arg
Using AI Code Generation
1import (2func main() {3 fmt.Println("os.Args[0]:", os.Args[0])4 fmt.Println("os.Args[1]:", os.Args[1])5 fmt.Println("os.Args[2]:", os.Args[2])6 fmt.Println("os.Args[3]:", os.Args[3])7}8import (9func main() {10 fmt.Println("os.Args[0]:", os.Args[0])11 fmt.Println("os.Args[1]:", os.Args[1])12 fmt.Println("os.Args[2]:", os.Args[2])13 fmt.Println("os.Args[3]:", os.Args[3])14}15import (16func main() {17 fmt.Println("os.Args[0]:", os.Args[0])18 fmt.Println("os.Args[1]:", os.Args[1])19 fmt.Println("os.Args[2]:", os.Args[2])20 fmt.Println("os.Args[3]:", os.Args[3])21}22import (23func main() {24 fmt.Println("os.Args[0]:", os.Args[0])25 fmt.Println("os.Args[1]:", os.Args[1])26 fmt.Println("os.Args[2]:", os.Args[2])27 fmt.Println("os.Args[3]:", os.Args[3])28}29import (30func main() {31 fmt.Println("os.Args[0]:", os.Args[0])32 fmt.Println("os.Args[1]:", os.Args[1])33 fmt.Println("os.Args[2]:", os.Args[2])34 fmt.Println("os.Args[3]:", os.Args[3])35}36import (37func main() {
arg
Using AI Code Generation
1import (2func main() {3 fmt.Println(args)4}5import (6func main() {7 for i, v := range args {8 fmt.Println(i, v)9 }10}11import (12func main() {13 for i, v := range args {14 fmt.Println(i, v)15 }16 fmt.Println(len(args))17}18import (19func main() {20 for i, v := range args {21 fmt.Println(i, v)22 }23 fmt.Println(len(args))24}25import (26func main() {27 for i, v := range args {28 fmt.Println(i, v)29 }30 fmt.Println(len(args))31}32import (33func main() {34 for i, v := range args {35 fmt.Println(i, v)36 }37 fmt.Println(len(args))38}39import (40func main() {41 for i, v := range args {42 fmt.Println(i, v)43 }44 fmt.Println(len(args))45}46import (47func main() {48 for i, v := range args {49 fmt.Println(i, v)50 }51 fmt.Println(len(args))52}
arg
Using AI Code Generation
1import "fmt"2import "os"3import "strconv"4func main() {5 if len(args) != 3 {6 fmt.Println("Please provide 2 arguments")7 }8 num1, err := strconv.Atoi(args[1])9 if err != nil {10 fmt.Println("Please provide a valid number")11 }12 num2, err := strconv.Atoi(args[2])13 if err != nil {14 fmt.Println("Please provide a valid number")15 }16 fmt.Println("The sum is", num1+num2)17}18import "fmt"19import "os"20import "strconv"21func main() {22 if len(args) != 3 {23 fmt.Println("Please provide 2 arguments")24 }25 num1, err := strconv.Atoi(args[1])26 if err != nil {27 fmt.Println("Please provide a valid number")28 }29 num2, err := strconv.Atoi(args[2])30 if err != nil {31 fmt.Println("Please provide a valid number")32 }33 fmt.Println("The sum is", num1+num2)34}35import "fmt"36import "os"37import "strconv"38func main() {39 if len(args) != 3 {40 fmt.Println("Please provide 2 arguments")41 }42 num1, err := strconv.Atoi(args[1])43 if err != nil {44 fmt.Println("Please provide a valid number")45 }46 num2, err := strconv.Atoi(args[2])47 if err != nil {48 fmt.Println("Please provide a valid number")49 }50 fmt.Println("The sum is", num1+num2)51}52import "fmt"53import "os"54import "strconv"55func main() {56 if len(args) != 3 {57 fmt.Println("Please provide 2 arguments")58 }
arg
Using AI Code Generation
1import (2func main() {3 fmt.Println("Hello, World!")4 fmt.Println(os.Args[0])5 fmt.Println(os.Args[1])6}7import (8func main() {9 flag.StringVar(&name, "name", "everyone", "The greeting object.")10 flag.Parse()11 fmt.Printf("Hello, %v!12}13import (14func main() {15 flag.StringVar(&name, "name", "everyone", "The greeting object.")16 flag.Parse()17 fmt.Printf("Hello, %v!18}19import (20func main() {21 flag.StringVar(&name, "name", "everyone", "The greeting object.")22 flag.Parse()23 fmt.Printf("Hello, %v!24}25import (26func main() {27 flag.StringVar(&name, "name", "everyone", "The greeting object.")28 flag.Parse()29 fmt.Printf("Hello, %v!30}31import (32func main() {33 flag.StringVar(&name, "name", "everyone", "The greeting object.")34 flag.Parse()35 fmt.Printf("Hello, %v!36}37import (38func main() {39 flag.StringVar(&name, "name", "everyone", "The greeting object.")40 flag.Parse()41 fmt.Printf("Hello, %v!42}43import (44func main() {45 flag.StringVar(&name, "name",
arg
Using AI Code Generation
1import "fmt"2func main() {3 fmt.Println("Hello, world.")4}5import "fmt"6func main() {7 fmt.Println("Hello, world.")8}9import "fmt"10func main() {11 fmt.Println("Hello, world.")12}13import "fmt"14func main() {15 fmt.Println("Hello, world.")16}17import "fmt"18func main() {19 fmt.Println("Hello, world.")20}21import "fmt"22func main() {23 fmt.Println("Hello, world.")24}25import "fmt"26func main() {27 fmt.Println("Hello, world.")28}29import "fmt"30func main() {31 fmt.Println("Hello, world.")32}33import "fmt"34func main() {35 fmt.Println("Hello, world.")36}37import "fmt"38func main() {39 fmt.Println("Hello, world.")40}41import "fmt"42func main() {43 fmt.Println("Hello, world.")44}45import "fmt"46func main() {47 fmt.Println("Hello, world.")48}49import "fmt"50func main() {51 fmt.Println("Hello, world.")52}53import "fmt"54func main() {55 fmt.Println("Hello, world.")56}57import "fmt"58func main() {59 fmt.Println("Hello, world.")60}
arg
Using AI Code Generation
1public class 2 {2 public static void main(String[] args) {3 System.out.println("Hello World");4 }5}6public class 1 {7 public static void main(String[] args) {8 System.out.println("Hello World");9 }10}11public class 3 {12 public static void main(String[] args) {13 System.out.println("Hello World");14 }15}16public class 4 {17 public static void main(String[] args) {18 System.out.println("Hello World");19 }20}21public class 5 {22 public static void main(String[] args) {23 System.out.println("Hello World");24 }25}26public class 6 {27 public static void main(String[] args) {28 System.out.println("Hello World");29 }30}31public class 7 {32 public static void main(String[] args) {33 System.out.println("Hello World");34 }35}36public class 8 {37 public static void main(String[] args) {38 System.out.println("Hello World");39 }40}41public class 9 {42 public static void main(String[] args) {43 System.out.println("Hello World");44 }45}46public class 10 {47 public static void main(String[] args) {48 System.out.println("Hello World");49 }50}51public class 11 {52 public static void main(String[] args) {53 System.out.println("Hello World");54 }55}56public class 12 {57 public static void main(String[] args) {58 System.out.println("Hello World");59 }60}
arg
Using AI Code Generation
1import (2func main() {3 fmt.Println("Welcome to the program")4 fmt.Println("The arguments are", os.Args[1:])5}6import (7func main() {8 flag.StringVar(&name, "name", "Go", "Help message for name")9 flag.Parse()10 fmt.Println("Welcome", name)11}12import (13func main() {14 flag.StringVar(&name, "name", "Go", "Help message for name")15 flag.Parse()16 fmt.Println("Welcome", name)17}18import (19func main() {20 flag.StringVar(&name, "name", "Go", "Help message for name")21 flag.Parse()22 fmt.Println("Welcome", name)23}24import (25func main() {26 flag.StringVar(&name, "name", "Go", "Help message for name")27 flag.Parse()28 fmt.Println("Welcome", name)29}30import (31func main() {32 flag.StringVar(&name, "name", "Go", "Help message for name")33 flag.Parse()34 fmt.Println("Welcome", name)35}36import (37func main() {38 flag.StringVar(&name, "name", "Go", "Help message for name")39 flag.Parse()40 fmt.Println("Welcome", name)41}42import (
arg
Using AI Code Generation
1import (2func main() {3 p.arg("hello", "world")4 p.method()5}6import (7type prog struct {8}9func (p *prog) arg(a, b string) {10 fmt.Println(a, b)11}12func (p *prog) method() {13 fmt.Println("method")14}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!