Join us now. It is free, and it takes less than 1 minute to register.
Register now
Subscribe to our daily newsletter. It is free, and it comes with many benefits.


+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 26

Thread: How to unlock Huawei 3G modems

  1. #1
    Super Grandwizard ginggs's Avatar
    Join Date
    Jun 2006
    Location
    Kapkaupunki
    Posts
    10,735

    Default How to unlock Huawei 3G modems

    Thanks to dogbert for sharing this:
    Code:
    #!/usr/bin/env python
    #
    # Copyright 2010: dogbert <[email protected]>
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    #
    
    import hashlib, getopt, sys
    
    def info():
    	print "huawei-unlock.py: calculates unlock codes for Huawei modems"
    	print "Copyright (c) 2010 dogbert <[email protected]>"
    	print "For information and updates, visit http://dogber1.blogspot.com"
    	print ""
    
    def usage():
    	print "Options: -i*, --imei=*      IMEI of the device"
    	print ""
    	print "Example: huawei-unlock.py --imei=351234567891239"
    	print ""
    
    def testIMEIChecksum(digits):
    	_sum = 0
    	alt = False
    	for d in reversed(digits):
    		assert 0 <= d <= 9
    		if alt:
    			d *= 2
    		if d > 9:
    			d -= 9
    		_sum += d
    		alt = not alt
    	return (_sum % 10) == 0
    
    def checkIMEI(imei):
    	digits = []
    	if len(imei) != 15:
    		print "IMEI too short/long"
    		return False
    	for i in imei:
    		digits.append(int(i))
    	if not testIMEIChecksum(digits):
    		print "IMEI checksum invalid"
    		return False
    	return True
    
    def getCode(imei, salt):
    	digest = hashlib.md5((imei+salt).lower()).digest()
    	code = 0
    	for i in range(0,4):
    		code += (ord(digest[i])^ord(digest[4+i])^ord(digest[8+i])^ord(digest[12+i])) << (3-i)*8
    	code &= 0x1ffffff
    	code |= 0x2000000
    	return code
    
    def main():
    	info()
            try:   
                    opts, args = getopt.getopt(sys.argv[1:], "hi:", ["help", "imei="])
            except getopt.GetoptError, err:
                    print str(err) # will print something like "option -a not recognized"
                    usage()
                    sys.exit(2)
    
    	imei = ""
    	interactive = False
    
            for o, a in opts:
                    if o in ("-i", "--imei"):
                            imei = a
                    elif o in ("-h", "--help"):
                            usage()
                            sys.exit()
    
    	if imei == "":
    		imei = raw_input("Please enter the IMEI of the device: ")
    		interactive = True
    
    	if checkIMEI(imei):
    		print "Unlock Code: %d" % (getCode(imei, hashlib.md5("hwe620datacard").hexdigest()[8:24]))
    		print "Flash Code:  %d" % (getCode(imei, hashlib.md5("e630upgrade").hexdigest()[8:24]))
    		print "done."
    
    	if interactive:
    		raw_input()
    	
    if __name__ == "__main__":
    	main()

  2. #2

    Default

    is this for unlocking network locked modems?
    "Why is there something rather than nothing?"
    Gottfried Leibniz

  3. #3
    Super Grandwizard ginggs's Avatar
    Join Date
    Jun 2006
    Location
    Kapkaupunki
    Posts
    10,735

    Default

    Quote Originally Posted by [email protected] View Post
    is this for unlocking network locked modems?
    Yes, also generating the 'flash code' needed for changing the dashboard on some of the newer modems.

  4. #4
    Resident Lead Bender Ockie's Avatar
    Join Date
    Feb 2008
    Location
    Henceforth AKA OckieMoto :-)
    Posts
    46,409

    Default

    I want MDMA for Ubuntu/Mint....and I want it NOW!!!!!!!!!!!!! *falls down on the floor kicking my legs!* :-)
    APoc184 - "Well apparently I'm Ockie's kinda girl."

  5. #5

    Default

    How do you run this?

    So if for example I slap an MTN simcard in a Vodafone Huawei modem and it says "Must be on a Vodacom Network", this code will fix it?

  6. #6

    Default

    ......anyone?

    How would you run this code? What exactly does it do?
    I see Dead Pixels.......

  7. #7

    Default

    I hate to break it to you guys, but if you have to ask then this is probably not for you...
    53.91% of South Africans voted in favour of the Nkandla compound and SABC censorship.

  8. #8

    Default

    Quote Originally Posted by morkhans View Post
    I hate to break it to you guys, but if you have to ask then this is probably not for you...
    ok, could you explain what this code is?

    CREATE PROC dbo.dba_backupdelete
    @vcDatabaseName VARCHAR(100)
    AS
    SET NOCOUNT ON

    DECLARE
    @vcDatetime VARCHAR(214)
    ,@vcDosCmd VARCHAR(130)
    ,@vcBackup VARCHAR(110)
    ,@vchh VARCHAR(2)
    ,@vcmin VARCHAR(2)
    ,@cmd VARCHAR(50)
    ,@vcLocation VARCHAR(50)
    ,@cmddelete VARCHAR(200)
    ,@vcTable VARCHAR(50)
    SET @vcDosCmd = 'MD C:\MSSQL.1\MSSQL\Backup\'[email protected]+''
    SET @vcLocation = 'C:\MSSQL.1\MSSQL\Backup\'[email protected]+'\'
    SET @cmd = 'DIR '+ @vcLocation + @vcDatabaseName + '*.BAK /OD /B '
    EXEC master.dbo.xp_cmdshell @vcDosCmd

    PRINT @cmddelete

    CREATE TABLE #OldestBackupbackup
    (Backupname VARCHAR(50)
    )

    INSERT INTO #OldestBackup(backupname)
    EXEC master.dbo.xp_cmdshell @cmd

    SET @vcTable = (SELECT TOP 1 backupname FROM #OldestBackup)
    SET @cmddelete = 'del /Q '[email protected][email protected]+''
    EXEC master.dbo.xp_cmdshell @cmddelete


    SET @vchh = (SELECT CASE WHEN DATEPART(hh,GETDATE()) < 10 THEN CAST('0' + CAST(DATEPART(hh,GETDATE())
    AS VARCHAR(1))
    AS VARCHAR(2))
    ELSE
    CAST(DATEPART(hh,GETDATE())
    AS VARCHAR(2))
    END )
    SET @vcmin = (SELECT CASE WHEN DATEPART(mi,GETDATE()) < 10 THEN CAST('0' + CAST(DATEPART(mi,GETDATE())
    AS VARCHAR(1))
    AS VARCHAR(2))
    ELSE
    CAST(DATEPART(mi,GETDATE())
    AS VARCHAR(2))
    END )

    SET @vcDatetime = 'C:\MSSQL.1\MSSQL\Backup\'[email protected]+'\'[email protected] DatabaseName+'_backup_'+convert(char(8), GETDATE(),112)+ @[email protected]+ '.bak '

    SET @vcBackup = ' BACKUP DATABASE ' [email protected] + ' TO DISK = '''[email protected]+ ''''


    EXEC (@vcBackup)
    SET NOCOUNT OFF
    GO
    EXEC backupAllanTry1 @vcDatabaseName = ''

    /*
    +convert(char(8), GETDATE(),112)+
    */
    Last edited by Osiris85; 26-08-2010 at 11:39 AM.
    I see Dead Pixels.......

  9. #9

    Default

    @Osiris85 i'm guessing you need to run the commands from the python software or something like that.
    I don't currently have a modem to unlock so i am not gonna spend time on it.
    Did you have a look at the link in the op?
    "Why is there something rather than nothing?"
    Gottfried Leibniz

  10. #10

    Default

    Quote Originally Posted by [email protected] View Post
    @Osiris85 i'm guessing you need to run the commands from the python software or something like that.
    I don't currently have a modem to unlock so i am not gonna spend time on it.
    Did you have a look at the link in the op?
    Thank you Park, its nice to get a straight answer from someone for a change.
    I tried to check out the link but the site is blocked at work

    Could you please explain a bit more about the Python Software? What is it? What does it do?
    I see Dead Pixels.......

  11. #11

    Default

    I'm not a coder, but at guess I would say it backs up a DB into a temp DB and dumps it to disk. What's your point?
    53.91% of South Africans voted in favour of the Nkandla compound and SABC censorship.

  12. #12

    Default

    Quote Originally Posted by morkhans View Post
    I'm not a coder, but at guess I would say it backs up a DB into a temp DB and dumps it to disk. What's your point?
    My point being that my code I understand, the code in the thread I dont understand. Hence, the reason I asked for advice, not criticism.

    FIY: You are 1/4 correct about my code
    I see Dead Pixels.......

  13. #13

    Default

    Quote Originally Posted by Osiris85 View Post
    My point being that my code I understand, the code in the thread I dont understand. Hence, the reason I asked for advice, not criticism.

    FIY: You are 1/4 correct about my code
    So therein my point. If you don't understand the implications of the code you are executing should you be doing so in the first place?

    A simple bit of googling would have revealed that Python is a programming language of sorts common to Linux. So it would be best to run this on such a platform.

    I'm not directing this specifically at you, but does everything need to be spelled out to people? What happened to exploring the unknowns for oneself?
    53.91% of South Africans voted in favour of the Nkandla compound and SABC censorship.

  14. #14

    Default

    Quote Originally Posted by morkhans View Post
    So therein my point. If you don't understand the implications of the code you are executing should you be doing so in the first place?

    A simple bit of googling would have revealed that Python is a programming language of sorts common to Linux. So it would be best to run this on such a platform.

    I'm not directing this specifically at you, but does everything need to be spelled out to people? What happened to exploring the unknowns for oneself?
    I understand what the code does and the implications, what I don't understand is how the code should be executed.

    The reason why I am asking these questions on the forum is because most of the sites are blocked at the office so I cannot do any real research
    I see Dead Pixels.......

  15. #15

    Default

    Quote Originally Posted by Osiris85 View Post
    I understand what the code does and the implications, what I don't understand is how the code should be executed.

    The reason why I am asking these questions on the forum is because most of the sites are blocked at the office so I cannot do any real research
    So that is a much more focused question with a bit more context to your situation than:
    Quote Originally Posted by Osiris85 View Post
    ......anyone?

    How would you run this code? What exactly does it do?
    Hence the terse reply

    So off to your nearest Linux box with you
    53.91% of South Africans voted in favour of the Nkandla compound and SABC censorship.

+ Reply to Thread
Page 1 of 2 12 LastLast

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •