0

I am trying to make a bash cript to bruteforce attack an android oem bootloader key to unlock the fastboot. I made this script

#!/usr/bin/zsh
setopt c_bases
typeset -i 16 num
for num in $( seq $((0x10000000000000)) 1 $((0xffffffffffffff)) ); do 
    echo "$num"
    fastboot oem unlock $num
done

but i have problems because iif i try to execute it i run out of ram. Is there any way to make an incremental script like this without running out of memory? Thanks a lot

  • 1
    On my 24 core Haswell system, I can fork ~20k programs per second. If `fastboot` doesn't need any time to talk to the device and is perfectly parallelizable, this would take me 100,000 years. Good luck! – that other guy Apr 03 '17 at 17:49
  • Well, i dn't have so much spare tine, so i will have to ask for the unlocking code... Thanks antway! – Filippo Falezza Apr 05 '17 at 05:48

1 Answers1

2
for num in $( seq $((0x10000000000000)) 1 $((0xffffffffffffff)) ); do 

will never work, because the entire command substitution output will be placed in memory before the loop is invoked. Use a c-style loop (bash specific) for loops with many iterations:

for ((num=0x10000000000000;num<=0xffffffffffffff;num++)); do 

You may also consider using gnu parallel to improve the speed of the test.

user000001
  • 32,226
  • 12
  • 81
  • 108