• This repository has been archived on 19/Jun/2022
  • Stars
    star
    128
  • Rank 281,044 (Top 6 %)
  • Language
    C
  • Created almost 7 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Switching Get Norge Fiber's Huawei HG8245 router with Ubiquiti's Nano G

AESCrypt2

The original tarball came from here packetstormsecurity.com.

Get Fiber and the Huawei HG8245

This router is used with Fiber customers in Oslo, Norway that are using Get as their ISP.

In typical ISP fashion they can't just hand you an Ethernet jack and get out of your way, they want to give you a router that NATs and provides WiFi. In this case they've adopted the Huawei HG8245 which is large and provides terrible WiFi coverage within the apartment. Funny that they'll sell you 500/500Mbps Internet service on a router that cannot possibly deliver it to the majority of modern devices. They're at least nice enough to turn off the WiFi and set Bridge mode, but the box still takes over most of the electrical box in my apartment. Everytime I've had them make any change to my service-level they have turned off bridge-mode and then I have to make yet another call to turn it back on. So in summary I really wish they would replace the big box with a Ubiquiti Nano G and get out of the business of trying to do things they're terrible at.

Exploring the device

I began the exploration of the unit to be able to manage it myself. A bit of searching came up with a page that included a binary tool for Linux and Windows to encrypt/decrypt the configuration on the device aescrypt2_huawei and how to trick the router into allowing you to download the configuration.

Get the Get configuration file

The configuration from Get prevents you from downloading the config. To trick the router you'll do the following:

  1. Unplug the fiber cable
  2. Perform a factory reset in the web interface
  3. Wait for it to reboot
  4. Log back in using root/admin and you'll see your access level provides full access
  5. Plug the fiber cable back in
  6. And then download the config when the WAN light goes solid green

Decrypting the configuration

The configuration is stored as an encrypted XML file. Finding a decryption tool was easy enough, but unfortunately it was provided for Linux and Windows and not for Mac. So I really wanted to know what the encryption key being used was and be able to use it directly on my Mac. So I started looking at the binary with IDA Pro.

Based upon the analysis of the program:

Huawei's encryption key is hex:13395537D2730554A176799F6D56A239

To recreate the functionality of the aescrypt2_huawei tool you need to compile the source code in this repo and do the following:

  1. echo -n 'hex:13395537D2730554A176799F6D56A239' > key.txt
  2. dd if=config.encrypted of=config_no_header.encrypted bs=1 skip=8
  3. ./aescrypt2 1 config_no_header.encrypted config.decrypted.gz key.txt
  4. gunzip config.decrypted.gz

After getting the encryption key and searching for it I found a spanish speaking forum that says they got the encryption key from a file found on the device in /etc/wap/aes_string.

Looking at the config

The config is pretty long but the main thing needed was to allow you to add a new user with super-user privileges or change the root/admin account to have the same access as Get provides themselves. In summary, passwords are hashed using

SHA256(MD5(admin)) which in this example yields 465c194afb65670f38322df087f0a9bb225cc257e43eb4ac5a0c98ef5b3173ac.

on the bash command-line this is accomplished like this:

echo -n admin | md5 | tr -d '\n' | shasum -a 256

You'll find this user in the config from Get and it has been given reduced privileges (level 1).

Get user

As defined in the configuration file Get added a user called 'getaccess' and with level 0 privileges (the highest)

<X_HW_WebUserInfoInstance InstanceID="2" UserName="getaccess" Password="fc0fe4711c0263f37013e423fde0a8be0d64d45f231c924952327052db50b66f" UserLevel="0" Enable="1" ModifyPasswordFlag="1" PassMode="2"/>

So you can modify the root user UserLevel to 0 and you're really root again. However, it probably makes more sense to add a new user since the root/admin combination is well known.

One more thing

The astute reader might have noticed I skipped the first 8-bytes before decrypting the file. The properly encrypted Huawei config file has some sort of header (4 bytes) and checksum (4 bytes) and I just ignored it. If you plan on uploading a modified config back to the router you'd need to recreate that header, so in that case I'd use the Linux and Windows tool to be safe.

What about replacing the router?

I replaced the Huawei box with a Ubiquiti Nano G. Get is using the Serial Number of the Huawei router as the method of authentication. This is a relatively common practice. So essentially, the OLT sees the Serial Number and lets it connect. So in the web interface set Profile 2 for Huawei and then the device will reboot. Then SSH to the box and change the Serial Number. Username and password are ubnt by default.

On the Nano G you issue the following commands discussed on this website:

$ ssh [email protected]

> sh

# cd bin
# ./gponctl stop

Stop ONU without sending dying gasp messages

# ./gponctl setSnPwd --sn 41-4c-43-4c-xx-xx-xx-xx

======== Serial Number & Password ========

Serial Number: 41-4C-43-4C-xx-xx-xx-xx
Password : 20-20-20-20-20-20-20-20-20-20

==========================================

# ./gponctl init
# ./gponctl start

Start ONU with operational state: INIT (01)

# ./gponctl getSnPwd

======== Serial Number & Password =======

Serial Number: 41-4C-43-4C-xx-xx-xx-xx
Password : 20-20-20-20-20-20-20-20-20-20

==========================================

This will not persist across reboots.

Persisting the serial number by rewriting firmware

It is pretty easy to rewrite the NVRAM and persist the change. Another security researcher wrote this up

Rewrite the Serial Number

Lastly, I bought the Nano G from Senetic.

More Repositories

1

Ukrainian-Russian

A Mac Keyboard Layout that displays the Ukrainian flag
119
star
2

SecureWebSockets

Add SSL support to the Autobahn WebSocket library
Java
67
star
3

GeodeticUTMConverter

An objective-C converter of UTM to/from latitude and longitude
MATLAB
34
star
4

Mandelbrot-Swift-Playground

Updated the Apple Mandelbrot Playground example
Swift
22
star
5

MapCurl

An example of how to fake the iOS Map Curl to reveal Options
Objective-C
17
star
6

CMake_OpenSSL

Build OpenSSL with CMake for iOS
CMake
15
star
7

UntitledApp

A minimal iOS app to provide a skeleton without an Xcode project
Objective-C
14
star
8

DTMFSounds

Swift DTMF tone generation
Swift
14
star
9

Seidel

C
13
star
10

LevmarPod

iOS version of the Levenberg-Marquardt non-linear least squares algorithm
C
8
star
11

mp4v2

C++
6
star
12

OpenAR

Open Augmented Reality Framework
Objective-C
5
star
13

Hough

Various MATLAB implementations of the Hough Transform
MATLAB
5
star
14

Beamformer

Swift
5
star
15

Slow

A minimal Metal Compute Shader
Swift
4
star
16

RestoreR

ANTLR based restoration of R(esource) values in decompiled Android apps
Python
3
star
17

lab

C
3
star
18

libiconv

Shell
3
star
19

Pokeman

Update your slack profile with a random Pokemon
Python
2
star
20

Zippy

Python
2
star
21

lipo_py

Python
2
star
22

Multiplication-Worksheet

Generate a worksheet of multiplication problems
Python
2
star
23

ElisesMath

Generate a math worksheet
Python
2
star
24

Framemarker-Generator

A generator for framemarkers used in augmented reality apps
Python
2
star
25

Tora

AIPhone Brute Forcing Tool
Java
2
star
26

PyReSign

Python
2
star
27

MultivariateGaussian

Description of the Multivariate Gaussian Discriminant function used in image classification
MATLAB
2
star
28

PGR208_HelloIvysaur

Kotlin
2
star
29

dropbear-frida

Shell
2
star
30

GLCM

Gray-level Co-occurence Matrix
MATLAB
2
star
31

iOSFonts

A quick and dirty app to display the fonts on a device.
Objective-C
2
star
32

DICOMatic

Python
2
star
33

PGR208_Lecture02

Kotlin
2
star
34

MemoryCopy

A playground to try different ways of copying bytes
Swift
1
star
35

OMS-SMS

A python script for sending SMS through the Outlook OMS gateway
Python
1
star
36

GODiploma

Python
1
star
37

SSStatistics

Python
1
star
38

RuterBillett-Hacking

1
star
39

INF9305

MATLAB
1
star
40

Sleipnir

Swift
1
star
41

CyberKey

Python
1
star
42

PGR208_EchoHorse

Kotlin
1
star
43

PGR208_EchoServer

Python
1
star
44

BulkIPAProcessor

Shell
1
star
45

PGR208_EchoWorld

Kotlin
1
star
46

libplist

C
1
star
47

MidiTest

An updated starting point for MidiTests
Objective-C
1
star
48

libressl

C
1
star
49

SystemUsabilityScale

TeX
1
star
50

PGR208_HelloWorld

Kotlin
1
star
51

PGR208_Pokedex

Kotlin
1
star
52

TenFrame

Python
1
star
53

PGR208_PokemonAPITest

Pokemon API Example
Python
1
star
54

sdkpackager

Package the Xcode SDKs
Python
1
star
55

ldid

C++
1
star
56

GOTag

Python
1
star
57

AppleScripts

1
star
58

PGR208_Lecture04_EchoWorld

Kotlin
1
star
59

PGR208_CarouselHorse

Kotlin
1
star
60

CPPinAnnotationView

A more flexible replacement for MKPinAnnotationView
Objective-C
1
star
61

CSCapture

Objective-C
1
star
62

iconizer

Python script to convert an SVG to a variety of PNG sizes necessary for iOS projects
Python
1
star
63

VES-Kiwi-Build

Shell
1
star
64

macos-rbenv

Ansible Role macos rbenv
1
star
65

filemon

Jonathan Levin's filemon
C
1
star
66

ProxyPacPy

A tiny proxy pac server for use with Charles or SSH SOCKS proxies
Python
1
star