huawei_3g_unlock 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in huawei_3g_unlock.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alfred R. Rowe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Huawei3gUnlock
2
+
3
+ A ruby implementation of Huawei 3G modem unlock/flash code generator. Tested on E1550 Models, I am positive it might work on other similar models. Comes also with a commandline tool(huawei3g) to quickly generate codes by specifying modems IMEI number.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'huawei_3g_unlock'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install huawei_3g_unlock
18
+
19
+ ## Gem Usage
20
+
21
+ Using the gem within your ruby application
22
+
23
+ Huawei3gUnlock.generate("IMEI-NUMBER-HERE")
24
+ Huawei3gUnlock.generate("353443043648141")
25
+
26
+ The gem version returns an array upon successful completion. The first index is the unlock code and the last index is the flash code. The command-line tool
27
+
28
+ [66493133,56295728]
29
+
30
+ ## Command-line Usage
31
+
32
+ This gem automatically installs a command-line utility (huawei3g) for quick code generations
33
+
34
+ huawei3g IMEI-NUMBER-HERE
35
+ huawei3g 353443043648141
36
+
37
+ Result will be similar to the results below
38
+
39
+ UNLOCK CODE: 66493133
40
+ FLASH CODE: 56295728
41
+
42
+ ## Tests
43
+
44
+ This has been tested on Huawei E1550 Model using ruby 1.8.7. Should work fine on other similar Huawei models
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/huawei3g ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
3
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
4
+
5
+ require 'huawei_3g_unlock'
6
+ def printout(s = "Usage: huawei3g IMEI-NUMBER")
7
+ $stderr.puts(s)
8
+ exit(2)
9
+ end
10
+
11
+ def generate(imei)
12
+
13
+ unless imei
14
+ printout
15
+ end
16
+
17
+ codes = Huawei3gUnlock.generate(imei)
18
+ unless codes.class == Array
19
+ printout(codes)
20
+ else
21
+ printout("UNLOCK CODE:\t#{codes.first}\nFLASH CODE:\t#{codes.last}")
22
+ end
23
+ end
24
+ generate(ARGV[0])
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/huawei_3g_unlock/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alfred R. Rowe"]
6
+ gem.email = ["alfred.rowe@gmail.com"]
7
+ gem.description = %q{A ruby implementation of Huawei 3G modem unlock/flash code generator. Tested on E1550 Models, I am positive it might work on other similar models. Comes also with a commandline tool(huawei3g) to quickly generate codes by specifying modems IMEI number.}
8
+ gem.summary = %q{Huawei Mobile Broadband Carrier Unlock/Flash Code Generator}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "huawei_3g_unlock"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Huawei3gUnlock::VERSION
17
+ end
@@ -0,0 +1,3 @@
1
+ module Huawei3gUnlock
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,55 @@
1
+ require "huawei_3g_unlock/version"
2
+ require 'digest/md5'
3
+
4
+ module Huawei3gUnlock
5
+
6
+ def self.generate(imei)
7
+
8
+ # Lazy validation checks
9
+ unless imei.to_s.length == 15 && imei =~ /^[0-9]+$/
10
+ "Error! IMEI code must be 15 digits exactly"
11
+ else
12
+ [crack_modem(imei,"unlock"),crack_modem(imei,"flash")]
13
+ end
14
+ end
15
+
16
+ private
17
+ def self.crack_modem(imei = "353443043648141",mode = 'unlock')
18
+
19
+ unlock_key = "5e8dd316726b0335"
20
+ flash_key = "97b7bc6be525ab44"
21
+
22
+ str1 = nil
23
+
24
+ case mode.downcase
25
+ when "unlock" then str1 = encode_md5(imei + unlock_key)
26
+ when "flash" then str1 = encode_md5(imei + flash_key)
27
+ end
28
+
29
+ str15 = ""
30
+ num = 0
31
+ while(num<7)
32
+ str11 = str1.slice(num,2)
33
+ str12 = str1.slice(num + 8,2)
34
+ str13 = str1.slice(num + 16,2)
35
+ str14 = str1.slice(num + 24,2)
36
+ s1 = str11.hex ^ str12.hex ^ str13.hex ^ str14.hex
37
+ ss = s1.to_s(16)
38
+ if(s1.to_s.length < 2)
39
+ str15 += "0"
40
+ elsif(ss.length < 2)
41
+ ss+="0"
42
+ end
43
+ str15 = str15 + ss
44
+ num+=2
45
+ end
46
+ s2 = str15.hex & 0x1ffffff | 0x2000000
47
+ s2
48
+ end
49
+
50
+ def self.encode_md5(str)
51
+ d = Digest::MD5.new
52
+ d << str
53
+ d.hexdigest
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: huawei_3g_unlock
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Alfred R. Rowe
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-07-12 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: A ruby implementation of Huawei 3G modem unlock/flash code generator. Tested on E1550 Models, I am positive it might work on other similar models. Comes also with a commandline tool(huawei3g) to quickly generate codes by specifying modems IMEI number.
22
+ email:
23
+ - alfred.rowe@gmail.com
24
+ executables:
25
+ - huawei3g
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - LICENSE
34
+ - README.md
35
+ - Rakefile
36
+ - bin/huawei3g
37
+ - huawei_3g_unlock.gemspec
38
+ - lib/huawei_3g_unlock.rb
39
+ - lib/huawei_3g_unlock/version.rb
40
+ homepage: ""
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.24
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Huawei Mobile Broadband Carrier Unlock/Flash Code Generator
73
+ test_files: []
74
+