Skip to content

Instantly share code, notes, and snippets.

@raxoft
Last active July 4, 2024 11:19
Show Gist options
  • Save raxoft/421fac2ca43dbc50617b to your computer and use it in GitHub Desktop.
Save raxoft/421fac2ca43dbc50617b to your computer and use it in GitHub Desktop.
This is the decoder of the password format used by the Amiga MultiUser filesytem. I wrote it the other day when I needed to login to an old A4000 whose root password I forgot. Note that some letters in the passwords are ambiguous due to modulo 53 being used, so 'A' and 'v' are the same, as is '0' and 'e' or space and 'U', so take your pick from …
# Decoder for passwords created by multiuser.library of Amiga MultiUser muFS filesystem (ACrypt() encoded, AKA AS225r2 format).
# Copyright (C) 2015 Patrik Rak (patrik@raxoft.cz)
# This source code is released under the MIT license.
def decode( password, user, base = 'A' )
r = 53
s = password.bytes.map{ |x| x - 'A'.ord } + [ 0 ] * 12
x = []
for i in 0..9
t = 2 * s[ i ] - s[ i + 1 ]
t += r if t.odd?
x[ i ] = ( t / 2 ) % r
end
u = user.bytes.to_a
pad = true
9.downto(0) do |i|
t = u[ i ] || i
t = x[ i ] - t
t -= 'A'.ord
t %= r
if pad and t == i
t = nil
else
pad = false
while t < base.ord and t < 128 - r
t += r
end
t = t.chr
end
x[ i ] = t
end
x.join
end
while line = gets
user, password = line.split( '|' )
next if password.nil? or password.empty?
puts user
puts decode( password, user, 'a' )
puts decode( password, user, 'A' )
puts decode( password, user, '0' )
puts decode( password, user, ' ' )
puts
end
# EOF #
@mhoeben
Copy link

mhoeben commented Oct 20, 2023

I forgot all passwords for my Amiga. I am looking to recover the initial login password. Can I use this tool to recover the password, and if so, can you give an idea how? Thanks in advance!

@raxoft
Copy link
Author

raxoft commented Oct 23, 2023

Yes, this script can help recover the lost password. There are two phases:

  1. You need to get hold of the MultiUser password file, which is typically in MultiUser/passwd on the main partition of the hard drive. If you have a guest account enabled, it's trivial, you just login as guest with empty password and can get the file. Otherwise, if you remember no logins at all, you will have to get it the hard way. The easiest nowadays is perhaps to remove the disk, plug it into a linux PC and simply mount the disk using the AFFS, see https://docs.kernel.org/filesystems/affs.html, and get the file. If that is beyond your possibilities, ask some friendly Linux guy to do that for you.

  2. Once you have the file, it's fairly easy. All you need is a machine with Ruby installed (which comes bundled with Macs and is easy enough to install on both Linux and Windows machines). Then run my script and feed it the password file you have retrieved before, e.g.,
    ruby mufs_password_decoder.rb passwd
    and it will spit out the several possible versions of the password for each login. That's because decoding of some of the characters in the alphabet is ambiguous, but any combination will work and you might be eventually able to remember which one you have actually used.

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment