Any time i’ve been using modem (i use huawei e169) for my internet connections. because i like the flexibility and realibility for use on my notebook. but 2 days ago, i was late to pay the bill and my connection was disconnected. i read the bill, and the bill was so high than other provider. i want to move to other provider, but i can’t. because the modem was locked by provider and only can using the sim card from the provider. yes i hear there is any way to unlock the modem, but i must pay at the service. because of that i’m doing some research and looking for the unlock code algorithm used by huawei modem. and i got it and did it in my program. now i can freely use any sim card on my modem. here it is, the source code contains the algorithm or you can use by direct or import it to your own program ;) . hope you enjoy !
<code>
022 | import hashlib, string |
024 | __author__ = "Gunslinger_ <yudha.gunslinger@gmail.com>" |
025 | __date__ = "Tue, 14 Jun 2011 23:22:42 +0700" |
027 | __copyright__ = "Copyright (c) 2010 Gunslinger_" |
029 | class huawei_modem_unlocker( object ): |
042 | def __init__( self , imei = '0' , verbose = False ): |
045 | self ._verbose = verbose |
046 | self ._md5u = hashlib.md5( str (imei) + str ( '5e8dd316726b0335' )).hexdigest() |
047 | self ._md5f = hashlib.md5( str (imei) + str ( '97b7bc6be525ab44' )).hexdigest() |
048 | self ._unlock_code = '' |
049 | self ._flash_code = '' |
053 | self ._header_format = '%-*s%*s' |
054 | self ._format = ' %d | %-*s | %*s ' |
056 | def xor_digits( self , source, counter): |
058 | digits = int ( '0x0' + source[ 0 + counter: 2 + counter], 16 ) ^ \ |
059 | int ( '0x0' + source[ 8 + counter: 8 + 2 + counter], 16 ) ^ \ |
060 | int ( '0x0' + source[ 16 + counter: 16 + 2 + counter], 16 ) ^ \ |
061 | int ( '0x0' + source[ 24 + counter: 24 + 2 + counter], 16 ) |
069 | print "=" * ( self ._width + 13 ) |
070 | print " Iter." + "|" + " Unlock byte " + "|" + " Flash byte " |
071 | print "-" * ( self ._width + 13 ) |
073 | digits_unlock = self .xor_digits( self ._md5u, cnt) |
074 | digits_flash = self .xor_digits( self ._md5f, cnt) |
075 | unlock_byte = string.zfill( hex (digits_unlock)[ 2 :], 2 ) |
076 | flash_byte = string.zfill( hex (digits_flash)[ 2 :], 2 ) |
077 | self ._unlock_code = str ( self ._unlock_code) + str (unlock_byte) |
078 | self ._flash_code = str ( self ._flash_code) + str (flash_byte) |
079 | if self ._verbose: print self ._format % ( int (cnt2), self ._width - self ._w, self ._unlock_code , self ._w, self ._flash_code) |
083 | print "=" * ( self ._width + 13 ) |
084 | print "\nUNLOCK CODE = %d & %d | %d = %d" % ( int ( '0x0' + self ._unlock_code, 16 ), 33554431 , 33554432 , eval ( "int('0x0'+self._unlock_code,16) & 33554431 | 33554432" )) |
085 | print "FLASH CODE = %d & %d | %d = %d\n" % ( int ( '0x0' + self ._flash_code, 16 ), 33554431 , 33554432 , eval ( "int('0x0'+self._flash_code,16) & 33554431 | 33554432" )) |
086 | self ._unlock_code = int ( '0x0' + self ._unlock_code, 16 ) & 33554431 | 33554432 |
087 | self ._flash_code = int ( '0x0' + self ._flash_code, 16 ) & 33554431 | 33554432 |
088 | return ( self ._unlock_code, self ._flash_code) |
093 | return ( self ._unlock_code, self ._flash_code) |
095 | if __name__ = = '__main__' : |
096 | print "\nHuawei modem unlock code calculator v.%s by %s \n" % (__version__, __author__) |
097 | inpimei = raw_input ( "Please input modem IMEI : " ) |
098 | cracker = huawei_modem_unlocker(inpimei) |
100 | print "\n-> IMEI = %s" % (inpimei) |
101 | print "-> UNLOCK CODE = %s" % (a) |
102 | print "-> FLASH CODE = %s" % (b) |
</code>
sumber : http://gunslingerc0de.wordpress.com