larsbrinkhoff / pdp10-its-disassembler

Disassembler and other tools for files in ITS formats
GNU General Public License v2.0
19 stars 13 forks source link

Extract files from IPAK file #39

Closed larsbrinkhoff closed 4 years ago

larsbrinkhoff commented 4 years ago

Make a tool to list/extract from IPAK files.

larsbrinkhoff commented 4 years ago

I made a new IPAK file with the 1977 TS IPAK and three small files inside. The files are "SMALL 1", "SMALL TWO", and "SMALL THREE".


         OCTAL         HALF-WORDS        SQUOZE  SIXBIT  ASCII
000000:  377044213275   377044,,213275    S ABS  ?XD1:]  ?b".^
000001:  014777252031    14777,,252031   G0J8NO  !G_509  ..zT.
000002:  635541545400  -142237,,-232400  $ZP58N  SMALL   g6.K.
000003:  210000000000   210000,,0        9IG7ON  1       "....
000004:  167562303072   167562,,303072   U2UM21  .]R88Z  .w...
000005:  000000000001        0,,1             0       !  .....
000006:  677354506424  -100424,,-271354  08J%7J  W[LHT4  one..
000007:  014777252031    14777,,252031   G0J8NO  !G_509  ..zT.
000010:  635541545400  -142237,,-232400  $ZP58N  SMALL   g6.K.
000011:  646757000000  -131021,,0        849GA7  TWO     i^x..
000012:  167562303121   167562,,303121   U2UM2O  .]R891  .w..(
000013:  000000000002        0,,2             1       "  .....
000014:  723575767432   -54203,,-10346   OY9IQX  Z=]^\:  twoo.
000015:  050060301406    50060,,301406   9NEDYD  % P8,&  .....
000016:  014777252031    14777,,252031   G0J8NO  !G_509  ..zT.
000017:  635541545400  -142237,,-232400  $ZP58N  SMALL   g6.K.
000020:  645062454500  -132716,,-323300  5QB$N   THREE   i#.Y
000021:  167562303144   167562,,303144   U2UM33  .]R89D  .w..2
000022:  000000000003        0,,3             2       #  .....
000023:  723216262712   -54562,,262712   O9R$0X  Z:.67*  three
000024:  627134562432  -150644,,-215346  TEDAQX  RY<N4:  eeee.
000025:  050060301406    50060,,301406   9NEDYD  % P8,&  .....
larsbrinkhoff commented 4 years ago

Here's the start of CPROG; \PROGS -IPAK- from 1980. Apparently the file header is a little bit larger, and the first file is BOOTER 3.


         OCTAL         HALF-WORDS        SQUOZE  SIXBIT  ASCII
000000:  013777261423    13777,,261423   ES24.A  !?_6,3  .^?zc.
000001:  225226423275   225226,,-354503  QZFUU.  2J6B:]  %)4&^
000002:  267373423275   267373,,-354503  TUNUU.  6[[B:]  -o\&^
000003:  013777261423    13777,,261423   ES24.A  !?_6,3  .^?zc.
000004:  014777252031    14777,,252031   G0J8NO  !G_509  ..zT.
000005:  425757644562  -352021,,-133216  RUU23H  BOOTER  E>~I9
000006:  230000000000   230000,,0        UHAOZV  3       &....
000007:  115344166747   115344,,166747   GN.VN%  )KD.WG  ..!ms
000010:  000000003437        0,,3437        04M      <?  .....
000011:  603174512574  -174604,,-265204  391 8J  P9\I5\  `ge.>
000012:  145124075344   145124,,75344    5TTBNZ  ,I4'KD  .% zr
000013:  046250207366    46250,,207366   7AV3$5  $RH0[V  .JB.{
larsbrinkhoff commented 4 years ago

@atsampson pointed to the encryption loop; in the 1977 TS IPAK it's ZCOPYF+26 to ZCOPYF+36.

In this version the key is at location 26742, and is hardcoded to be the sixbit word MZMZYN.

larsbrinkhoff commented 4 years ago

The only public sample is -STINK.-IPAK-.9, but is has been mangled on the way from a TOPS-20 tape. I should be able to get a better version from TID100082.

larsbrinkhoff commented 4 years ago

In the 1977 version, the first word is the user name in sixbit xor'ed with 633126423275.

Unless the first word is 014777252031 in which case there is no check. We see this value at offset 1 in the 1977 file and offset 4 in the 1980 file.

atsampson commented 4 years ago

If you pack the 7-bit bytes from -STINK.-IPAK-.9 together MSB first, and insert one zero at the right, then you get a file in the 1980 format (with the lowest bit missing), where the first file is S H:

0000000001011111111111010110001100010010 013777261422
0000010010101010010110100010011010111100 225226423274
0000010110111011111011100010011010111100 267373423274
0000000001011111111111010110001100010010 013777261422
0000000001100111111111010101010000011000 014777252030
0000110011000000000000000000000000000000 630000000000 sixbit 'S     '
0000101000000000000000000000000000000000 500000000000 sixbit 'H     '
0000001010001010001100011101011110100100 121214353644
0000000000000000000000000000001000100100 000000001044
0000111100010010100000110100000010101000 742240640250
0000011011100111110001011100101100101110 334761345456
0000110011100010011000001100101010100100 634230145244
0000011110100110011010001010001101111010 364632121572

XORing the data with MZMZYN gives a plausible-looking header file in 7-bit left-aligned ASCII:

# include <c.defs>

# define PAGE_SHIFT 10
# ifndef ITS
#    define PAGE_SHIFT 9
# endif

# define PAGE_SIZE (1<<PAGE_SHIFT)
# define PAGE_MASK (PAGE_SIZE-1)
# define NPAGES (01000000/PAGE_SIZE)
...

It turns into nonsense after a few more lines, so I guess the file has also been mangled by CRLF conversion or similar.

atsampson commented 4 years ago

Yes, the other part of the mangling is CRLF -> LF conversion. Inserting the lost CRs makes it possible to extract all the files, apparently intact. (The number of LFs to skip before inserting a CR are: 22, 14, 16, 1, 1, 6, 0, 5, 5, 0, 1, 0, 22, 0, 57, 4, 71, 89, 21, 67, 5, 7.)

larsbrinkhoff commented 4 years ago

Thanks! I'm so relieved the password is the same.

larsbrinkhoff commented 3 years ago

I have been using this tool successfully with the IPAKs in https://github.com/MITDDC/clu-1976-1989