A cracking story ...

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,980
Reaction score
6,802
Location
Scotland
I thought I'd have a look at how Huisun have protected their firmware distribution files from prying eyes.
On the face of it, they are .zip files.
But .zip files can have very strong passwords that make a simple brute-force attack impractical, as I confirmed when I set JtR on the IPNC_S2l2.0.1_build201603031830.zip version.

As @klasipca had mentioned, as an implicit challenge, that a certain Russian forum member well known for mentioning his exploits (but not explaining how he did them), had been there already, I thought I'd try some cheating. Or maybe a lateral approach:
You can do lots when you've got a working device and telnet access!

So - some of you who are careful to preserve your carefully chosen Mini PTZ V2 camera settings may have noticed that if you export the device configuration you get a file such as "ipnc_config_20160722184151.zip"
This is remarkably like the firmware file, complete with a strong password, holding the file 'package.bin'.

Perhaps Huisun are using the same routines to process these zip files as they use for the firmware files. In which case a bit of study might yield some useful information.
Without boring you with the fine detail, it turns out that it's easy enough to grab copies of the 'work in progress' files when exporting the device configuration, as it gathers the relevant configuration files, zips them up into package.bin, then re-writes the zip file encrypted with a random password. Which it writes into the .zip file in an obfuscated way. The .zip passwords are not stored in the firmware routines, but the way they are created is, it's a random number seeded with an XORed version of the system time, and a bit more obfuscation.
Having grabbed files in plaintext (the configuration files) that have been zipped up into package.bin which has then been zipped up with a password, a 'known plaintext attack' can be made on the ZIP keys.

But that's not much use in itself, as each file will have it's own password, not relevant to the specific firmware file password.
However, it does indicate a possible attack method on the firmware file.
Given some knowledge of how the firmware update process works, again it's easily possible to grab copies of the temporary component files that are extracted from the IPNC_S2l2.0.1_build201603031830.zip file during the firmware update process. These persist for as long as you don't click the 'OK' button to reboot after the update has been applied.
The files inside 'package.bin' are
Code:
Archive contains:
  index.ini
  web.tgz
  ipnc.tgz
  M342_MiniPtz.bin
  M342_ZoomCam.bin
  STM32F030F4_MiniPtz.bin
  S90ipnc
  STM32F030F4_PtContrl.bin
Total 8 entries (5499144 bytes)
And although the result gives an unencrypted package.bin file which is directly usable if you wish to explore the firmware, as an academic exercise the plaintext attack on the zip file works easily to extract the keys.
 
Last edited by a moderator:

alastairstevenson

Staff member
Joined
Oct 28, 2014
Messages
15,980
Reaction score
6,802
Location
Scotland
Thank God the Scots are on our side
Well we're certainly not best pleased with the UK Government at the moment.
We do live in interesting, if somewhat chaotic, times.
As do you, in the political sense.
 

Q™

IPCT Contributor
Joined
Feb 16, 2015
Messages
4,989
Reaction score
3,990
Location
Megatroplis, USA
...We do live in interesting, if somewhat chaotic, times. As do you, in the political sense.
A brief detour from your superb topic...and then NO MORE!

"This seems to imply that these sorts of institutions were bastions of morality in some bygone era when people had more "character;" do we have affirmative evidence of that? Maybe neither the old days nor the current days are so wonderful in terms of protecting the vulnerable from the aggressive. (And the old days apparently gave rise to the current ones, so I'm not sure why we should see the old days as not complicit in whatever is ailing us now.) What will get us to situations in which there are no damaged people to damage more people and in which bystanders are no longer so concerned about their group membership? I don't think it's a character issue, I think it's a failure to move beyond putting our fears and desires first, and to do that I think first we need to understand that there actually is a viable way to live that way. I suspect most of us don't know what that looks like and how to live that way -- that we have lost track of the fact that we have in ourselves another gear we can shift into. I would like to see us move forward to something more helpful, not backwards to a flawed model that got us to where we are right now." - Unattributed

/rant

And my apologies...back to the topic!
 

Zeddy

Getting the hang of it
Joined
Jun 19, 2016
Messages
92
Reaction score
42
Without boring you with the fine detail, it turns out that it's easy enough to grab copies of the 'work in progress' files when exporting the device configuration, as it gathers the relevant configuration files, zips them up into package.bin, then re-writes the zip file encrypted with a random password. Which it writes into the .zip file in an obfuscated way. The .zip passwords are not stored in the firmware routines, but the way they are created is, it's a random number seeded with an XORed version of the system time, and a bit more obfuscation.
Interesting, but if it picks such a random password to encrypt the exported configuration then how is the firmware supposed to know the password if you opt to restore the config to another camera?

Edit:
Thinking about it more, it's probably using the date in the filename, XOR'd plus a known salt to work out the password. I assume if you changed the date in the filename it would error when attempting a configuration restore.

Edit 2: Forget that, there is a random number in the mix, so still not sure how a 2nd camera could restore a backup made from another.
 
Last edited by a moderator:

vasycara

Getting the hang of it
Joined
Jun 22, 2015
Messages
227
Reaction score
48
I thought I'd have a look at how Huisun have protected their firmware distribution files from prying eyes.
On the face of it, they are .zip files.
But .zip files can have very strong passwords that make a simple brute-force attack impractical, as I confirmed when I set JtR on the IPNC_S2l2.0.1_build201603031830.zip version.



You can do lots when you've got a working device and telnet access!
Who is the password for telnet ?
 
Top