mirage.libs.common package


mirage.libs.common.hid module

class mirage.libs.common.hid.HIDMapping(locale='fr')

Bases: object

This class provides some helpers functions to manipulate the HID protocol.

getHIDCodeFromKey(key='', alt=False, ctrl=False, shift=False, gui=False)

This class method allows to convert a key to its HID code and modifiers.

  • key (str) – string indicating the key

  • alt (bool) – boolean indicating if the alt key is pressed

  • ctrl (bool) – boolean indicating if the ctrl key is pressed

  • shift (bool) – boolean indicating if the shift key is pressed

  • gui (bool) – boolean indicating if the gui key is pressed


HID code and modifiers

Return type

tuple of int

>>> HIDMapping(locale="fr").getHIDCodeFromKey(key="a")
(20, 0)
>>> HIDMapping(locale="us").getHIDCodeFromKey(key="t",ctrl=True,alt=True)
(23, 5)
getKeyFromHIDCode(hid=0, modifiers=0)

This class method allows to convert a HID code and modifiers to the corresponding key.

  • hid (int) – HID code

  • modifiers (int) – HID modifiers


corresponding key

Return type


>>> HIDMapping(locale="fr").getKeyFromHIDCode(20,0)
>>> HIDMapping(locale="us").getKeyFromHIDCode(23,0)

mirage.libs.common.parsers module

class mirage.libs.common.parsers.DuckyScriptParser(content='', filename='')

Bases: object

This class is a parser for the DuckyScript language. It allows to generate a sequence of frame to inject keystrokes according to the provided script.

generatePackets(textFunction=None, keyFunction=None, sleepFunction=None, initFunction=None)

This function allows to generate the sequence of packets corresponding to the provided script. You have to provide different functions that returns the sequence of packets for a given action.

  • textFunction (func) – function corresponding to a text injection

  • keyFunction (func) – function corresponding to a single keystroke injection

  • sleepFunction (func) – function corresponding to a sleep interval

  • initFunction (func) – function corresponding to the initialization of the process


sequence of packets

Return type

list of mirage.libs.wireless_utils.packets.Packet