6 Agu 2011

Huawei modem unlock calculator

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>
001#!/usr/bin/python
002# -*- coding: utf-8 -*-
003#   This library is free software; you can redistribute it and/or
004#   modify it under the terms of the GNU Lesser General Public
005#   License as published by the Free Software Foundation; either
006#   version 2.1 of the License, or (at your option) any later version.
007#
008#   This library is distributed in the hope that it will be useful,
009#   but WITHOUT ANY WARRANTY; without even the implied warranty of
010#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011#   Lesser General Public License for more details.
012#
013#   You should have received a copy of the GNU Lesser General Public
014#   License along with this library; if not, write to the
015#      Free Software Foundation, Inc.,
016#      59 Temple Place, Suite 330,
017#      Boston, MA  02111-1307  USA
018#
019#   Copyright 2010 Gunslinger_ <yudha.gunslinger@gmail.com>
021
022import hashlib, string
023
024__author__  = "Gunslinger_ <yudha.gunslinger@gmail.com>"
025__date__    = "Tue, 14 Jun 2011 23:22:42 +0700"
026__version__     = "1.0"
027__copyright__   = "Copyright (c) 2010 Gunslinger_"
028
029class huawei_modem_unlocker(object):
030    """
031    Instance variables:
032
033    Imei
034        Imei of the modem will be calculated
035        Default : '0'
036
037    Verbose
038        Display how algorithm working
039        Default : False
040
041    """
042    def __init__(self, imei='0', verbose=False):
043        ''' Huawei modem unlocker class constructor '''
044        self._imei      = imei
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    = ''
050        # verbose formating
051        self._width     = 21
052        self._w         = 10
053        self._header_format     = '%-*s%*s'
054        self._format        = '   %d  | %-*s | %*s  '
055
056    def xor_digits(self, source, counter):
057        ''' Get a value and xoring it during looping iteration '''
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)
062        return digits
063
064    def calc(self):
065        ''' Process calculate with the algorithm (read source code) '''
066        cnt = 0
067        cnt2 = 1
068        if self._verbose:
069            print "="*(self._width+13)
070            print " Iter."+"|"+ " Unlock byte "+"|"+" Flash byte "
071            print "-"*(self._width+13)
072        while cnt < 8:
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)
080            cnt  +=2
081            cnt2 +=1
082        if self._verbose:
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)
089
090    def run(self):
091        ''' Fire it up ! '''
092        self.calc()
093        return (self._unlock_code, self._flash_code)
094
095if __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)
099    a, b    = cracker.run()
100    print "\n-> IMEI     = %s" % (inpimei)
101    print "-> UNLOCK CODE    = %s" % (a)
102    print "-> FLASH CODE = %s" % (b)

</code>
sumber : http://gunslingerc0de.wordpress.com

./vM




Detected

Your Browser's JavaScript is: