Python tools for manipulating Mikrotik NPK format
Original scripts were found on: http://routing.explode.gr/node/96
Python tools for manipulating Mikrotik NPK format
License: Other
Python tools for manipulating Mikrotik NPK format
Original scripts were found on: http://routing.explode.gr/node/96
Unpacking of original npk files (e.g. http://mirror.mikrotik-bg.net/Dude/4.0beta3/dude-4.0beta3.npk) doesn't work anymore. Reverting the last update (support for the new format) solves the issue.
D:\mikrotik-npk-master>python27.exe unpacknpk.py ppp-6.9.npk
'\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x04\x00\x00\x00i386\x02\x00'
Magic: '\x1e\xf1\xd0\xba' should be: '\x1e\xf1\xd0\xba'
Size after this: 393289 Header size: 167 Data size: 4375
Unknown stuff: '\x01\x00 \x00\x00\x00' should be: '\x01\x00 \x00\x00\x00'
Short description: pppaaaaaaaaaaaaa
Revision, unknown, Minor, Major: '\x00f\t\x06' (0, 102, 9, 6)
Build time: '{\x86\xebR' Fri Jan 31 19:18:19 2014
Some other numbers: (0, 0, 16, 4, 0) should be: (0, 0, 16, 4, 0)
Architecture: i386
Another number: (2,) should be: (2,)
Long description: '\n Provides support for PPP, PPTP, L2TP, PPPoE and ISDN PP
P.\n '
Found data of type: 3 size: 34
Found data of type: 22 size: 3917
Found data of type: 21 size: 389120
Returning the raw header and the rest of the file (each part in a list)
D:\mikrotik-npk-master>python27.exe dumpnpk.py ppp-6.9.npk
'\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x04\x00\x00\x00i386\x02\x00'
Magic: '\x1e\xf1\xd0\xba' should be: '\x1e\xf1\xd0\xba'
Size after this: 393289 Header size: 167 Data size: 4375
Unknown stuff: '\x01\x00 \x00\x00\x00' should be: '\x01\x00 \x00\x00\x00'
Short description: pppaaaaaaaaaaaaa
Revision, unknown, Minor, Major: '\x00f\t\x06' (0, 102, 9, 6)
Build time: '{\x86\xebR' Fri Jan 31 19:18:19 2014
Some other numbers: (0, 0, 16, 4, 0) should be: (0, 0, 16, 4, 0)
Architecture: i386
Another number: (2,) should be: (2,)
Long description: '\n Provides support for PPP, PPTP, L2TP, PPPoE and ISDN PP
P.\n '
Next 24 chars: '\x03\x00"\x00\x00\x00\x01\x00system\x00\x00\x00\x00\x00\x00\x00
x00\x00\x00'
should be: '\x03\x00"\x00\x00\x00\x01\x00system\x00\x00\x00\x00\x00\x00\x00
x00\x00\x00'
Separators: '\x00f\t\x06\x00\x00\x00\x00' '\x00f\t\x06\x00\x00\x00\x00'
first 4: (0, 102, 9, 6) (0, 102, 9, 6)
Found data of type: 3 size: 34
Found data of type: 22 size: 3917
Found data of type: 21 size: 389120
Returning the raw header and the rest of the file (each part in a list)
Hello all
i'm have problem with unpacknpk.py and dumpnpk.py it's not work correct !!
same problems of past issues and test all solve but not work
#2
#1
the problem is Returning the raw header and the rest of the file (each part in a list) how i can solve it?
i'm using kali linux 1.1 . 0 vmawer machine
if any user have replay to me :
1.tell me what the opertiaon system
2.the solve step by step
for dumpnpk.py
root@kali:~/Desktop/mikrotik-npk-master# python dumpnpk.py routeros-x86-6.9.npk
'\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x04\x00\x00\x00i386\x02\x00'
Magic: '\x1e\xf1\xd0\xba' should be: '\x1e\xf1\xd0\xba'
Size after this: 15241883 Header size: 152 Data size: 15241891
Unknown stuff: '\x12\x00 \x00\x00\x00' should be: '\x01\x00 \x00\x00\x00'
Short description: routeros-x86
Revision, unknown, Minor, Major: '\x00f\t\x06' (0, 102, 9, 6)
Build time: '{\x86\xebR' Fri Jan 31 06:18:19 2014
Some other numbers: (0, 0, 16, 4, 0) should be: (0, 0, 16, 4, 0)
Architecture: i386
Another number: (2,) should be: (2,)
Long description: 'RouterOS for x86, includes all supported features\n'
Next 24 chars: '\x15\x00\x00\x00\x00\x00\x14\x00"\x00\x00\x00\x01\x00ipv6\x00\x00\x00\x00\x00\x00'
should be: '\x03\x00"\x00\x00\x00\x01\x00system\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Separators: '\x00\x00\x00\x00\x00\x00\x00\x00' '\x00\x00\x00\x00\x00\x00\x00\x00'
first 4: (0, 0, 0, 0) (0, 0, 0, 0)
Found data of type: 21 size: 0
Found data of type: 20 size: 34
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 52
Found data of type: 3 size: 2
Found data of type: 22 size: 3812
Found data of type: 21 size: 8249344
Found data of type: 7 size: 3
Contents (oninstall): '\n '
Found data of type: 4 size: 3486321
Uncompressing data...
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 33
Found data of type: 3 size: 34
Found data of type: 22 size: 3243
Found data of type: 21 size: 356352
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 36
Found data of type: 3 size: 34
Found data of type: 22 size: 3880
Found data of type: 21 size: 69632
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 73
Found data of type: 3 size: 34
Found data of type: 19 size: 34
Found data of type: 22 size: 3803
Found data of type: 21 size: 1409024
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 24
Found data of type: 3 size: 34
Found data of type: 22 size: 3892
Found data of type: 21 size: 217088
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 30
Found data of type: 3 size: 34
Found data of type: 22 size: 3886
Found data of type: 21 size: 188416
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 33
Found data of type: 3 size: 34
Found data of type: 19 size: 34
Found data of type: 22 size: 3843
Found data of type: 21 size: 114688
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 48
Found data of type: 3 size: 34
Found data of type: 22 size: 3868
Found data of type: 21 size: 135168
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 65
Found data of type: 3 size: 34
Found data of type: 22 size: 3851
Found data of type: 21 size: 389120
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 76
Found data of type: 3 size: 34
Found data of type: 22 size: 3840
Found data of type: 21 size: 397312
Found data of type: 9 size: 68
Found data of type: 1 size: 32
Found data of type: 16 size: 4
Found data of type: 2 size: 59
Found data of type: 3 size: 34
Found data of type: 22 size: 3857
Found data of type: 21 size: 118784
Found data of type: 4 size: 66124
Uncompressing data...
Found data of type: 9 size: 68
Found data of type: 16 size: 1
Returning the raw header and the rest of the file (each part in a list)
Files in package:
fil nx UPGRADEBOOTER 1391160062
fil nx UPGRADED 1391160062
dir 253 bin 1391070225
fil 253 bin/mlogin 1391070225
fil 253 bin/bash_login 1391070225
fil 253 bin/bash 1391071475
fil 253 bin/milo 1391071348
dir ex boot 1391159984
fil ex boot/vmlinuz-smp 1391159984
fil 180 boot/initrd.rgz 1391070277
fil nx boot/map 1391160062
fil 180 boot/milo.conf 1391070225
fil ex boot/vmlinuz 1391159986
fil 180 /var/pdb/system/crc 1391160062
Files in package:
fil ex boot/memtest.bin 1391072397
fil 180 /var/pdb/advanced-tools/crc 1391160090
for unpacknpk.py
root@kali:~/Desktop/mikrotik-npk-master# python unpacknpk.py routeros-x86-6.9.npk
Version 5 npk reader
'\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x04\x00\x00\x00i386\x02\x00'
Magic: '\x1e\xf1\xd0\xba' should be: '\x1e\xf1\xd0\xba'
Size after this: 15241883 Header size: 152 Data size: 15241891
Unknown stuff: '\x12\x00 \x00\x00\x00' should be: '\x01\x00 \x00\x00\x00'
Short description: routeros-x86
Revision, unknown, Minor, Major: '\x00f\t\x06' (0, 102, 9, 6)
Build time: '{\x86\xebR' Fri Jan 31 06:18:19 2014
Some other numbers: (0, 0, 16, 4, 0) should be: (0, 0, 16, 4, 0)
Architecture: i386
Another number: (2,) should be: (2,)
Long description: 'RouterOS for x86, includes all supported features\n'
Found data of type: 61726 size: 2459679440
Returning the raw header and the rest of the file (each part in a list)
'\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x18\x00\x0b\x00\x00\x00de'
Magic: '\x1e\xf1\xd0\xba' should be: '\x1e\xf1\xd0\xba'
Size after this: 12034283 Header size: 12034291 Data size: 12034291
Unknown stuff: '\x01\x00$\x00\x00\x00' should be: '\x01\x00 \x00\x00\x00'
Short description: system^@^@^@^@^@^@^@^@^@^@
Revision, unknown, Minor, Major: '\x01b\x00\x07' (1, 98, 0, 7)
Build time: '\x00%q]' Thu Sep 5 16:08:48 2019
Another number: '\x00\x00\x00\x00'
Some other numbers: (0, 3, 24, 11, 0) should be: (0, 2, 16, 4, 0)
Architecture: deve
Another number: (28524,) should be: (2,)
Long description: 't\x10\x00\x03\x00\x00\x00arm\x02\x00.\x00\x00\x00Main package with most of servic
es and drivers\x17\x00(\x00\x00\x0079958f19938c59bbbca5187ea2b6b1ec4ed7179f\x03\x00\x02\x00\x00\x00\
x00\x00\x16\x00>\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
[etc]```
With Gentoo Linux
$ ./unpacknpk.py ntp-6.13-mipsbe.npk
'\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x04\x00\x00\x00mips\x02\x00'
Magic: '\x1e\xf1\xd0\xba' should be: '\x1e\xf1\xd0\xba'
Size after this: 241737 Header size: 131 Data size: 241745
Unknown stuff: '\x01\x00 \x00\x00\x00' should be: '\x01\x00 \x00\x00\x00'
Short description: ntp
Revision, unknown, Minor, Major: '\x00f\r\x06' (0, 102, 13, 6)
Build time: '@\xe5tS' Thu May 15 18:03:12 2014
Some other numbers: (0, 0, 16, 4, 0) should be: (0, 0, 16, 4, 0)
Architecture: mips
Another number: (2,) should be: (2,)
Long description: '\n NTP client and server\n '
Found data of type: 3 size: 34
Found data of type: 22 size: 3953
Found data of type: 21 size: 237568
Found data of type: 9 size: 68
Found data of type: 16 size: 1
Returning the raw header and the rest of the file (each part in a list)
and no file extracted.
With 6.12 unpack works correctly.
Some changes? (like backup)
thanks
Hi,
I noticed that createnpk.py was made only to create 2.9.x packages and it lacks support for 6.x.
Digging into it a little more, I modified the header's hexadecimal values (with a hex editor, comparing the apropriated values with an actual 6.43.4 package) in order to "fake" a 6.43.4 package, however I noticed that the package made with createnpk.py has an old header format and the 6.x has a larger header and it has even a small footer.
Whenever I try to install the package with RouterOS it looks for a package called system-6.43.4 which is already installed however the new package name is just plain "system" and it has a version argument containing its version number.
The specific error is something like "Cannot install dude-6.43.4. Requires system-6.43.4 which is not installed"
That said, do you think would it be possible to write a new tool to encapsulate the 6.42+ squashfs package with npk?
I'm asking this because the oposite is true, we can unpack the npks with unnpk.
Thank you
It works on 6.20, but not 6.40. Hope it would be fix soon.
btw, hank you very much for your great work here. With your work we can pry into the mikrotik package and see what they are doing.
Best wishes.
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.