AccessDenied ScreenSaver v1.3 weak password encryption vulnerability 28 June 2002 ====[ ENGLISH ]=========================================================== ORIGINAL DESCRIPTION: AccessDenied screensaver (www.uinc.ru) is used as the screen saver and it can be used as a protection of your computer from others, while you go to have a cup of tea or to have dinner, having left the computer alone. For this purpose it is enough to set the password in Settings of the screen saver. The style of the program speaks for itself - your friends will think of you as an 31137 Hacker if they see this ScreenSaver working. Special features of this screensaver: + Special encryption of password + ....skip... PROBLEM: AccessDenied ScreenSaver - is quite popular screensaver, judging by the amount of downloads from the original website. At the time of writing the advisory, the program download counter stated that the program was downloaded 22980 times. The problem is in incorrect realization of encryption algorithm in the program and as a cause, the passwords can be recovered very easily. DETAILS: OK, the goal here is to create a password recovery tool for this screensaver. By simple manipulations with FileMon we conclude that program stores its' settings(and password) in %SYSTEMROOT%\access.ini. Playing a bit with password changing, we see that variable "pass" in ini file doesn't contain password. Program is constantly referring to this variable (defence from a cool hacker?). In fact, the password is stored in variable "old" in encrypted way, also, the encrypted string length is the same as the original password length, so this is some kind of streaming encryption or something even simpler. We now use debugger to find a function for decryption - but there isn't one, the password entered by a user is encrypted and compared against the correct encrypted string. This is not so stupid, as a result we won't be able to rip the decryption function with disassembler. So the only hope left is in considering the actual encryption function. A lot of useless code (Delphi!), but in principle, this is encryption algorithm bit: void crypt(char* inp, char* out) { int ilen = strlen(strcpy(out, inp)); for (int i = 0, seed = 0x68A; i < ilen; i++) { seed += (unsigned char)(out[i] ^= (seed >> 8)); seed = ((seed * 0x9821) + 0x39F5) & 0xFFFF; } } So, each symbol is modified using seed, which is modified by constants and the actual encrypted symbol. This is bad, because we don't know the final seed for encrypted password. Moreover, knowing it won't help us to make the decryptor anyway - there is too much info lost during & 0xFFFF :( Nevertheless, the solution is dead simple! We know initial seed (0x68A) and encryption is done by one symbol at a time, we can try each symbol, encrypt it and compare against the correct one! This is implemented in the attached program. In general, we have 255*strlen(pass) combinations - not bad at all. ATTACHMENT: Source and compiled binary of password recovery tool. LINKS: AccessDenied ScreenSaver: http://www.uinc.ru/files/index_eng.shtml Original location of this advisory: http://inbox.h1.ru/ad_passwd_adv.txt Binary and source of password recovery tool: http://inbox.h1.ru/cgi-bin/getfile.pl?ad_passwd_adv.zip FEEDBACK: The author was contacted and he promised to release a new version with better encryption algorithm. ====[ RUSSIAN ]=========================================================== ORIGINAL DESCRIPTION: AccessDenied скринсейвер (www.uinc.ru) используется, как хранитель экрана, так же она может быть использована, как средство защиты вашего компьютера от других, пока вы отошли выпить чашку чая или пообедать, оставив свой компьютер включенным, для этого достаточно задать пароль в Настройках хранителя экрана. Особенности программы и полезные ф-ции: + Криптование пароля при парольной защите + ....skip... PROBLEM: AccessDenied ScreenSaver - достаточно популярная программа, судя по количеству скачиваний данной программы. Во время написания этого уведомления, количество скачиваний указанных на сайте программы было: 22980 раз. В данной программе неправильно реализован алгоритм шифрования пароля, вследствие чего, он очень легко расшифровывается. DETAILS: Итак, поставимся целью сделать восстанавливалку пароля для этого хранителя экрана. Несложными манипуляциями с FileMon'ом и шаманским бубном выясняем, что все настройки (и пароль в том числе) программа хранит в %SYSTEMROOT%\access.ini. Немного поиграя с паролем догадываемся, что переменная pass сожержит вовсе не пароль, а в лучшем случае какой-то мусор. Программа постоянно обращается к этой записи (защита от хацкера?). Реально пароль хранится в поле old и не в открытом виде, причем можно заметить, что длина зашифрованного пароля такая же как и у введенного. Значит это или какой-то потоковый шифр или нечто более простое. Используем отладчик и смотрим на предмет наличия функции расшифровки - ее просто нет, то что вводится юзером шифруется и сравниваются уже зашифрованные строчки. Не так глупо - просто выдернуть дизассемблером декриптор не получится. Придется смотреть функцию, зашифровывающую пароль. Много лишнего кода (Delphi!), но в принципе алгоритм шифрования такой: void crypt(char* inp, char* out) { int ilen = strlen(strcpy(out, inp)); for (int i = 0, seed = 0x68A; i < ilen; i++) { seed += (unsigned char)(out[i] ^= (seed >> 8)); seed = ((seed * 0x9821) + 0x39F5) & 0xFFFF; } } Итак, каждый символ модифицируется с помощью seed, который в свою очередь модифицируется, как константами, так и самим зашифрованным символом. Это плохо потому, что для зашифрованного пароля мы не знаем конечный seed. И даже его знание на позволяет сделать декриптор - слишком много информации теряется при & 0xFFFF :( И тем не менее выход прост до безобразия! Поскольку начальный seed известен (0x68A) и шифрование идет по одному символу, можно банально перебирать все возможные символы, шифровать их и сравнивать с символом из имеющегося зашифрованного пароля, чем приложенная программа и занимается. Вот и все, в общем случае имеем 255*strlen(pass) комбинаций - совсем не много. ATTACHMENT: Исходник и откомпилированный бинарик для расшифровки пароля. LINKS: AccessDenied скринсейвер: http://www.uinc.ru/files/index.shtml Оригинал этого уведомления лежит здесь: http://inbox.h1.ru/ad_passwd_adv.txt Бинарик и исходник декриптора: http://inbox.h1.ru/cgi-bin/getfile.pl?ad_passwd_adv.zip FEEDBACK: Автор был уведомлен об уязвимости и пообщел исправить ошибку. ========================================================================== Best Regards, SereGa sergio1902@mail.ru