()
| 43 | } |
| 44 | |
| 45 | func (mod *HIDRecon) prepInjection() (error, *network.HIDDevice, []*Command) { |
| 46 | var err error |
| 47 | |
| 48 | if err, mod.sniffType = mod.StringParam("hid.force.type"); err != nil { |
| 49 | return err, nil, nil |
| 50 | } |
| 51 | |
| 52 | dev, found := mod.Session.HID.Get(mod.sniffAddr) |
| 53 | if found == false { |
| 54 | mod.Warning("device %s is not visible, will use HID type %s", mod.sniffAddr, tui.Yellow(mod.sniffType)) |
| 55 | } else if dev.Type == network.HIDTypeUnknown { |
| 56 | mod.Warning("device %s type has not been detected yet, falling back to '%s'", mod.sniffAddr, tui.Yellow(mod.sniffType)) |
| 57 | } |
| 58 | |
| 59 | var builder FrameBuilder |
| 60 | if found && dev.Type != network.HIDTypeUnknown { |
| 61 | // get the device specific protocol handler |
| 62 | builder, found = FrameBuilders[dev.Type] |
| 63 | if found == false { |
| 64 | return errNotSupported(dev), nil, nil |
| 65 | } |
| 66 | } else { |
| 67 | // get the device protocol handler from the hid.force.type parameter |
| 68 | builder = builderFromName(mod.sniffType) |
| 69 | } |
| 70 | |
| 71 | // get the keymap from the selected layout |
| 72 | keyMap := KeyMapFor(mod.keyLayout) |
| 73 | if keyMap == nil { |
| 74 | return errNoKeyMap(mod.keyLayout), nil, nil |
| 75 | } |
| 76 | |
| 77 | // parse the script into a list of Command objects |
| 78 | cmds, err := mod.parser.Parse(keyMap, mod.scriptPath) |
| 79 | if err != nil { |
| 80 | return err, nil, nil |
| 81 | } |
| 82 | |
| 83 | mod.Info("%s loaded ...", mod.scriptPath) |
| 84 | |
| 85 | // build the protocol specific frames to send |
| 86 | if err := builder.BuildFrames(dev, cmds); err != nil { |
| 87 | return err, nil, nil |
| 88 | } |
| 89 | |
| 90 | return nil, dev, cmds |
| 91 | } |
| 92 | |
| 93 | func (mod *HIDRecon) doInjection() { |
| 94 | mod.writeLock.Lock() |
no test coverage detected