mcphail / linux_huawei_unlocker Goto Github PK
View Code? Open in Web Editor NEWA utility to remove the SIM lock on Huawei USB modems
License: GNU General Public License v2.0
A utility to remove the SIM lock on Huawei USB modems
License: GNU General Public License v2.0
Huawei Modem Unlocker Copyright (C) 2012 Neil McPhail <[email protected]> Portions Copyright (C) 2010 dogbert <[email protected]> ******************************************************************************* This utility is now deprecated I cannot maintain this application and do not have the skills to convert it to python3. Developers with an interest in this utility are encouraged to fork the repository. I would be happy to pass on the baton of maintenance to anyone who can demonstrate commitment to modernising the code. Thank you for your interest in this software. ******************************************************************************* Licence: GNU GPL version 2 Version: 0.4 Requirements: Linux Python pySerial Usage: ./unlocker.py (as root if necessary) Warranty: none! Huawei wireless broadband modems are well supported in Linux. When bought from a mobile carrier they are often locked to that carrier's network. This restricts your freedom to choose your own supplier and SIM. Unlocking these modems is simple but it has become the domain of malign and unscrupulous members of the underground warez scene. This program aims to simplify the process for Linux users. Method: 1. Insert the "foreign" SIM into your modem 2. Insert the modem into a spare USB port. Do not attempt to connect. 3. Run "./unlocker.py" (you may need to run this as root) 4. Accept the warning by typing "YES" 5. Confirm you wish to proceed with the unlocking procedure - there are only 10 attempts before the modem is locked for ever 6. Let me know whether it was a success or failure! Troubleshooting: Make sure python-2 and pySerial are installed (e.g. sudo apt-get install python-serial) The Windows "Dashboard" software is untouched. Some carrier-modified versions of this software prevent unlocked modems connecting to foreign networks. You may need to update the Dashboard software to an unbranded version. This is of no concern to Linux users and this software does not help with that process. Early reports suggest that some modems cannot be unlocked by this program. When I get hold of one of these devices I will work on it. E220 devices will not work. I don not think they will ever work with this script. Devices beginning "E3" are unlikely to work at this point. I hope to support these in a future version. If you have such a device and decide to try this script please give me feedback on the link below. Bugs: Please raise issues at https://github.com/mcphail/linux_huawei_unlocker
Linux distrubution = Ubuntu 12.04 LTS (32bit)
Python 2.7.3
pySerial 2.5
Modem Model = E3131
Country of purchase = Zambia
Original Carrier = MTN
Carrier of the SIM = Airtel (Zambia)
Error message = "The modem is hard locked, This program cannot help you."
It's a great program though!
usb 5-4: new high speed USB device number 4 using ehci_hcd
usb 5-4: New USB device found, idVendor=12d1, idProduct=1446
usb 5-4: New USB device strings: Mfr=3, Product=2, SerialNumber=0
usb 5-4: Product: HUAWEI Mobile
usb 5-4: Manufacturer: HUAWEI Technology
scsi8 : usb-storage 5-4:1.0
scsi9 : usb-storage 5-4:1.1
scsi 8:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
scsi 9:0:0:0: Direct-Access HUAWEI MMC Storage 2.31 PQ: 0 ANSI: 2
sd 9:0:0:0: Attached scsi generic sg4 type 0
sr1: scsi-1 drive
sr 8:0:0:0: Attached scsi CD-ROM sr1
sr 8:0:0:0: Attached scsi generic sg5 type 5
sd 9:0:0:0: [sdd] Attached SCSI removable disk
$ sudo ./unlocker.py
[...]
Trying to find which port is the active modem connection.
Please be patient as this can take a while.
Could not identify active port.
After catching the exception as described in #15 I could unlock the modem Huawei E173s (in Germany known also as "Web'n'Walk Stick basic IV").
Thanks for the unlocker!
i had an extra Huawei modem around so thought I would try unlocking it for fun.
Ubuntu 12.06 64bit lts.
dpkg -l |grep pytohon-serial
ii python-serial 2.5-2.1build1 pyserial - module encapsulating access for
Huawei E220
CE 0682
Original modem Carrier: 3 (tre)
Simcard carrier: Tele2
Country of purchase :Sweden
error: just got the message failed to unlock.
Please, I need the program to generate the unlock code via the modem imei whether in python, java, php or any other language.
Thanks.
Details:
Linux Mint 15
Python 2.7.4
pyserial-2.6
E1750
Romania
digi
Orange (RO) sim
just for fun :)
they shouldn't lock them.
I have tried linux_huawei_unlocker with Huawei K3520 modem and had no success.
The program test the ports /dev/ttyUSB2 /dev/ttyUSB1 and /dev/ttyUSB0 (these are automatically created when plugin the modem) and says that the three of them are inactive and then the program exits.
After this, I have successfully unlocked the modem with MobilePartner, connected to the network through the modem and I am actually sending this message through it. (Hence I cannot make further tests, sorry).
According to the HELPME file included in the software, I add the requested information:
- Your Linux distribution and version (e.g. Ubuntu 12.04)
Ubuntu Trusty
- Your version of Python and pySerial (if known)
python 2.7.5-5ubuntu3
python-serial 2.6-1build1
- The model of your modem
Huawei K3520
- The country of purchase of your modem
Spain
- The original carrier for your modem
Vodafone
- The carrier of the SIM you used in the unlock process
Simyo
- Any problems, failures or error messages
Ports /dev/ttyUSB2, ..1 and ...0 regarded as "inactive". The program then exits.
- Any suggestions for improvement.
I do not know, more verbose error messages???
I am affraid I cannot be of more help. Thanks anyway for making this software for the world.
In my K3765, unlocking was unsuccessfully at first, because it was trying all ports and one was raising an exception when reading ([Errno 32] Broken pipe
). After specifying the port number here It worked. It would be good to be able to specify the device/port manually, but I'm mostly writing this so somebody that has the same problem can find it in google.
I've tried to unlock my COSMOTE (RO) Huawei E372 with an Orange (RO) sim.
Details:
Linux Mint 15
Python 2.7.4
pyserial-2.6
Huawei E372
Romania
Cosmote (RO)
Orange (RO) SIM
full output:
If you wish to proceed, please type YES at the prompt
YES
Trying to find which port is the active modem connection.
Please be patient as this can take a while.
Testing port /dev/ttyUSB2
Activity detected
Trying to obtain IMEI.
The modem will be given 5 seconds to respond.
Found probable IMEI: 35314xyzqwerty4 (obfuscated by me)
IMEI checksum OK.
Checking the lock status of the SIM.
The modem will be given 5 seconds to respond.
This SIM should be unlockable...
Remaining attempts: 10
Exceeding this will hard-lock the modem
Unlock code = 45822421
Please be aware that a failed unlocking attempt could break your modem.
This is a risky procedure.
If you wish to proceed, please type YES at the prompt
YES
Attempting to unlock...
Will check result in 5 seconds.
Checking the lock status of the SIM.
The modem will be given 5 seconds to respond.
Unlocking unsuccessful. Sorry.
Seems that there are modems which require a different algorithm for the unlock code. While I don't know how to generate unlock codes for those modems I can help with modifying the script and using a generated unlock code to unlock the device:
unlocker.py
unlockCode = computeUnlockCode(imei)
with unlockCode = "66611394"
(replace the code with the code from the website above)This is how I managed to unlock my K3772 modem.
Huwawei E367 . Unlock Code is good but program ened with unlock unsuccessful.
thanks anyway !
It couldn't unlock the Huawei router. It would be nice to work with you on making the unlocker to work with this router. I'm also able to code if necessary to make it work.
Well.
I've hardcoded ttyUSB0 as modem device, tries to get IMEI but doesn't work.
Is trying code "AT+CGSN\r\n" but returns ERROR.
I tried to send manually the AT command "ATI\r\n" and returns IMEI along other info.
Manufacturer: huawei
Model: E1612
Revision: 11.806.02.03.18
IMEI: 352201030850216
+GCAP: +CGSM,+DS,+ES
OK
So, once i've edited that it told me that dongle was previously unlocked. I used networkmanager to create new dialup with just name and APN and worked :D
Actual obtainImei() looks like
def obtainImei(port):
print "\nTrying to obtain IMEI."
print "The modem will be given 5 seconds to respond."
ser = serial.Serial(port = port,
timeout = 0)
ser.flushInput()
#ser.write('AT+CGSN\r\n')
ser.write('ATI\r\n')
time.sleep(5)
response = ser.read(4096)
ser.close()
imei = re.findall('\d{15}', response)[0]
if imei:
print "Found probable IMEI: " + imei
return imei
else:
print "IMEI not found"
return ''
This modem reports fail when you unlock it, seems something with response parsing or whatever.
I ran script twice and that time worked out of the box.
Many thanks.
The following lines were throwing an exception for me and because it went uncaught, the for cycle didn't loop further to probe other ttys which was effectively preventing to work for my modem. After catching the exception and skipping the rest of the iteration, the following iterations probed my modem correctly and the whole thing worked like a charm!
linux_huawei_unlocker/unlocker.py
Lines 76 to 79 in 885e7d7
Hi! I have Huawei E173 u-1 and it has refused to unlock.
Let my explain in brief:
I usualy use this modem by way of temporary unlocking because it's firmware is locked.
The software that I use to unlock it resides in my windows 7 os.
The software that I use on windows is called Huawei Modem Unlocker.exe.
Here is the link http://www.doncaprio.com/2012/11/how-to-flash-huawei-usb-modems-and-re-install-the-firmware.html.
When I unlock it, it will remain unlocked unless I unplug or shut down my pc
So I unlock it using windows 7 then I reboot and boot to ubuntu.
If I shut down my pc or unplug the modem it locks again.
So I unlock it in windows then reboot to ubuntu and it works fine.
Now the problem is that I cannot unlock it in ubuntu using linux_huawei_unlocker.
My system is
-Xbuntu 14.04.1 LTS
-Python 2.7.6
-Huawei E173 u-1
-Country: Kenya
Thanks alot by the way
As requested here my success story:
Just used this successfully on an very old E1750 that was locked to austrian provider orange. (That doesn't exist anymore.)
Thanks a lot for your nice tool!
I got unlock code from '3'.
Your script generated a different code.
I changed your code to use number I got from '3'.
It said it worked. But I can not connect
Thank you so much for the project.
Just want to assure that your code works fine. It took me several hard hours try to figure out why #17 and #18 only solve half of my problem.
My E1750 (which I got about 10 years ago) is locked to one network provider. Running your code will spit out broken pipe
trying to connect to ttyUSB1 and ttyUSB2.
I want to share my solution here. Hope it helps others. My guess is that some providers, like mine, will ask Huawei to immediately disconnect the device if not suitable sim card is detected.
==== THE WRONG WAY ====
usb_modeswitch
.func@func:~$ dmesg | grep tty
[ 0.000000] console [tty0] enabled
[ 0.876305] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[ 5.703661] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB0
[ 5.703754] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
[ 5.704306] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB2
[ 142.438319] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[ 157.432343] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[ 157.432434] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[ 158.020234] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB0
[ 158.088221] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
[ 158.108213] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB2
[ 162.516724] option1 ttyUSB0: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[ 162.516729] option1 ttyUSB0: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[ 162.516731] option1 ttyUSB0: usb_wwan_indat_callback: resubmit read urb failed. (-2)
[ 162.518285] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[ 162.576415] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[ 162.576528] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[ 167.220233] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB0
[ 167.304267] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
[ 167.348225] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB2
[ 167.373931] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[ 168.172328] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[ 168.172450] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[ 173.188233] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB0
[ 173.252218] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB1
[ 173.284209] usb 1-5: GSM modem (1-port) converter now attached to ttyUSB2
[ 186.516118] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
You can clearly see that ttyUSB0 has been disconnected.. Sad!
==== THE CORRECT WAY ====
usb_modeswitch
and any other stuff you need to do to load your device.I am writing this comment to you using the unlocked E1750 dongle via the initially 'unsupported' sim card.
Kudo to you.
hi, when try : sudo ./unlocker.py
same with root account
If you wish to proceed, please type YES at the prompt
YES
Trying to find which port is the active modem connection.
Please be patient as this can take a while.Testing port /dev/ttyUSB2
An error occurred when probing for active ports.
This may be because you need to run this program as root.
I am running on Ubuntu 13.04. I was trying to unlock my Huawei E303 dongle. I found this application by posting a question on How to unloack a USB Broadband Modem ? at askubuntu.com.
I tried to unlock using this application. But the result was Could not identify active port
.
In my system python-serial
was already installed. There was python2.7
installed. I followed all the steps in README.
This is good work done by you. Wish you all the best to improve this further !
Below is the terminal dialogue :
`dumindumahawela@dumindumahawela:~$ su
Password:
root@dumindumahawela:/home/dumindumahawela# cd /home/dumindumahawela/Downloads/linux_huawei_unlocker-0.3
root@dumindumahawela:/home/dumindumahawela/Downloads/linux_huawei_unlocker-0.3# ./unlocker.py
Huawei modem unlocker
By Neil McPhail and dogbert
This is Free Software as defined by the GNU GENERAL PUBLIC
LICENSE version 2
This software comes with NO WARRANTY
This software can damage your hardware
Use it at your own risk
Not all modems can be unlocked with this software.
Users have reported problems with the following devices:
E220, E353
Attempting to unlock these devices with this software is not
recommended. I hope to fix this in a later release.
If you wish to proceed, please type YES at the prompt
YES
Trying to find which port is the active modem connection.
Please be patient as this can take a while.
Could not identify active port.
root@dumindumahawela:/home/dumindumahawela/Downloads/linux_huawei_unlocker-0.3#`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.