[GH-ISSUE #441] Add support for cracking Lotus Notes ID files using 128-bit RC2, 128-bit AES and 256-bit AES #171

Open
opened 2026-10-14 02:55:12 +07:00 by bsakaguchi · 22 comments
Owner

Originally created by @kholia on GitHub (Dec 28, 2013).
Original GitHub issue: https://github.com/openwall/john/issues/441

Originally assigned to: @kholia on GitHub.

We currently only support cracking of Lotus ID files which are using 64-bit RC2 encryption.

We would also like to support Lotus ID files which use 128-bit RC2, 128-bit AES and 256-bit AES encryption algorithms.

Information about Lotus Notes,

IBM Lotus Notes Client V8.5.3 Basic Configuration for Windows English (CI1L2EN) 
size = 191091760 
sha = 342496A0DD6D61B66DB0B932AF67019FA2628D8D 
name = Lotus_Notes853_BC_WIN_EN.exe 

IBM Lotus Notes Client V8.5.3 for Windows English (CI1L4EN) 
size = 549665216 
sha = F26352AA82075DDE07221F8289A30110D9DA7B2D 
name = lotus_notes853_win_en.exe

These software can be downloaded from IBM (registration required). This place provides an alternate way to grab the installers.

Originally created by @kholia on GitHub (Dec 28, 2013). Original GitHub issue: https://github.com/openwall/john/issues/441 Originally assigned to: @kholia on GitHub. We currently only support cracking of Lotus ID files which are using 64-bit RC2 encryption. We would also like to support Lotus ID files which use 128-bit RC2, 128-bit AES and 256-bit AES encryption algorithms. Information about Lotus Notes, ``` IBM Lotus Notes Client V8.5.3 Basic Configuration for Windows English (CI1L2EN) size = 191091760 sha = 342496A0DD6D61B66DB0B932AF67019FA2628D8D name = Lotus_Notes853_BC_WIN_EN.exe IBM Lotus Notes Client V8.5.3 for Windows English (CI1L4EN) size = 549665216 sha = F26352AA82075DDE07221F8289A30110D9DA7B2D name = lotus_notes853_win_en.exe ``` These software can be downloaded from [IBM (registration required)](http://www.ibm.com/developerworks/downloads/ls/lsndad/?S_TACT=105AGX28&S_CMP=TRIALS). [This place](http://mylotus.pw/Download/LOTUS/_NOTES/) provides an alternate way to grab the installers.
Author
Owner

@magnumripper commented on GitHub (Dec 29, 2013):

http://www.openwall.com/lists/john-users/2013/12/23/2

Hopefully Quarkslab will answer with a license statement.

<!-- gh-comment-id:31309712 --> @magnumripper commented on GitHub (Dec 29, 2013): http://www.openwall.com/lists/john-users/2013/12/23/2 Hopefully Quarkslab will answer with a license statement.
Author
Owner

@magnumripper commented on GitHub (Dec 29, 2013):

Oh, he did update it on that web page, license is added! We just need to rewrite lotus2john (the one he links to is C++, has no license and is Windows specific).

Also, we need to add a couple of test vectors.

<!-- gh-comment-id:31309996 --> @magnumripper commented on GitHub (Dec 29, 2013): Oh, he did update it on that web page, license is added! We just need to rewrite lotus2john (the one he links to is C++, has no license and is Windows specific). Also, we need to add a couple of test vectors.
Author
Owner

@magnumripper commented on GitHub (Dec 29, 2013):

The format is committed in 55f8f38.

<!-- gh-comment-id:31310107 --> @magnumripper commented on GitHub (Dec 29, 2013): The format is committed in 55f8f38.
Author
Owner

@kholia commented on GitHub (Dec 29, 2013):

We also need to add support for ID files which use 128-bit RC2, 128-bit AES and 256-bit AES encryption algorithms.

Hence, keeping the task open for now.

<!-- gh-comment-id:31315997 --> @kholia commented on GitHub (Dec 29, 2013): We also need to add support for ID files which use 128-bit RC2, 128-bit AES and 256-bit AES encryption algorithms. Hence, keeping the task open for now.
Author
Owner

@kholia commented on GitHub (Dec 29, 2013):

Sample ID files have been uploaded to http://openwall.info/wiki/john/sample-non-hashes#Lotus-Notes-ID-files URL.

<!-- gh-comment-id:31317026 --> @kholia commented on GitHub (Dec 29, 2013): Sample ID files have been uploaded to http://openwall.info/wiki/john/sample-non-hashes#Lotus-Notes-ID-files URL.
Author
Owner

@magnumripper commented on GitHub (Jan 3, 2014):

Major problem: http://www.openwall.com/lists/john-dev/2014/01/02/19

Not sure if Sébastien's original version worked and we b0rked it or if it was incomplete all along.

<!-- gh-comment-id:31497013 --> @magnumripper commented on GitHub (Jan 3, 2014): Major problem: http://www.openwall.com/lists/john-dev/2014/01/02/19 Not sure if Sébastien's original version worked and we b0rked it or if it was incomplete all along.
Author
Owner

@magnumripper commented on GitHub (Jan 5, 2014):

The problem now has its own issue #456. So this issue now is just for adding algorithms.

<!-- gh-comment-id:31604355 --> @magnumripper commented on GitHub (Jan 5, 2014): The problem now has its own issue #456. So this issue now is just for adding algorithms.
Author
Owner

@kholia commented on GitHub (Jan 7, 2014):

Issue #456 is fixed now.

Now, we need to add support for ID files which use 128-bit RC2, 128-bit AES and 256-bit AES encryption algorithms. Some reverse-engineering may be required to do this.

<!-- gh-comment-id:31716155 --> @kholia commented on GitHub (Jan 7, 2014): Issue #456 is fixed now. Now, we need to add support for ID files which use 128-bit RC2, 128-bit AES and 256-bit AES encryption algorithms. Some reverse-engineering may be required to do this.
Author
Owner

@kholia commented on GitHub (Sep 29, 2014):

I am working on this now but got nothing so far.

<!-- gh-comment-id:57223228 --> @kholia commented on GitHub (Sep 29, 2014): I am working on this now but got nothing so far.
Author
Owner

@a2940uw commented on GitHub (Apr 16, 2015):

Hello Kholia, I have try the lotus2john.py bundle with 1.8.0-jumbo1 but found the Domino v8 hash key format is look like Domino v5, the reason is the ID is created by 256Bit AES?, any possible solution for extract hash from Domino v8 notes ID with 256-bit AES? Thank you .

<!-- gh-comment-id:93696228 --> @a2940uw commented on GitHub (Apr 16, 2015): Hello Kholia, I have try the lotus2john.py bundle with 1.8.0-jumbo1 but found the Domino v8 hash key format is look like Domino v5, the reason is the ID is created by 256Bit AES?, any possible solution for extract hash from Domino v8 notes ID with 256-bit AES? Thank you .
Author
Owner

@kholia commented on GitHub (Apr 16, 2015):

@a2940uw lotus2john.py doesn't handle such files, currently ;(

<!-- gh-comment-id:93706606 --> @kholia commented on GitHub (Apr 16, 2015): @a2940uw lotus2john.py doesn't handle such files, currently ;(
Author
Owner

@simiden commented on GitHub (Mar 29, 2016):

Hi kholia, by far JtR can not support cracking Lotus Notes ID files using 128-bit RC2, 128-bit AES and 256-bit AES algos, right?

<!-- gh-comment-id:202657831 --> @simiden commented on GitHub (Mar 29, 2016): Hi kholia, by far JtR can not support cracking Lotus Notes ID files using 128-bit RC2, 128-bit AES and 256-bit AES algos, right?
Author
Owner

@kholia commented on GitHub (Mar 29, 2016):

@simiden yes, that is right.

<!-- gh-comment-id:202711633 --> @kholia commented on GitHub (Mar 29, 2016): @simiden yes, that is right.
Author
Owner

@kholia commented on GitHub (Mar 29, 2016):

https://github.com/kholia/RE-RE has made almost no progress when it comes to handling such Lotus Notes ID files.

<!-- gh-comment-id:202717250 --> @kholia commented on GitHub (Mar 29, 2016): https://github.com/kholia/RE-RE has made almost no progress when it comes to handling such Lotus Notes ID files.
Author
Owner

@kholia commented on GitHub (Nov 12, 2017):

If someone is interested in reversing engineering this stuff, here are some resources,

It is easy to setup IBM Notes 9.0.1 on a Ubuntu 14.04 LTS 32-bit VM using these instructions (UPDATED).

<!-- gh-comment-id:343741190 --> @kholia commented on GitHub (Nov 12, 2017): If someone is interested in reversing engineering this stuff, here are some resources, * Find and download `NOTES_9.0.1_LINUX_DI_EN.tar` file. * https://github.com/kholia/Lotus-ID-reversing * https://github.com/CTXz/ibm-notes-9.0.1_Ubuntu-16.04_installer * https://github.com/PetRose/lotus-notes_gtk2.23.3 * https://github.com/kholia/lotus-notes_gtk2.23.3 It is easy to setup `IBM Notes 9.0.1` on a Ubuntu 14.04 LTS *32-bit* VM using these instructions (UPDATED).
Author
Owner

@kholia commented on GitHub (Nov 17, 2017):

Here are some of my raw reversing notes,

$ cat ~/.gdbinit
set disassembly-flavor intel
set history save on
set print pretty on
set pagination off
set confirm off
# set disable-randomization off

# unbreak reverse-continue watchpoints
# set can-use-hw-watchpoints 0

define xxd
  dump binary memory dump.bin $arg0 $arg0+$arg1
  shell xxd dump.bin
end

set follow-fork-mode child


$ nm /opt/ibm/notes/libnotes.so | c++filt | grep -i verify


$ ps uax | grep -i notes
lulu      3872  0.3  6.0 435888 123076 ?       Sl   20:17   0:01 /opt/ibm/notes/framework/../notes /authenticate


$ gbd -p 3872
(gdb) break RC2Init
Breakpoint 1 at 0xf5ea429e
(gdb) c
Thread 1 "lnotes" hit Breakpoint 1, 0xf5ea429e in RC2Init () from /opt/ibm/notes/libnotes.so
(gdb) quit
(gdb) bt
#0  0xf5ea429e in RC2Init () from /opt/ibm/notes/libnotes.so
#1  0xf5ea2d08 in A_RC2_CBCDecryptInit () from /opt/ibm/notes/libnotes.so
#2  0xf5e90018 in RC2_CBCDecryptInit () from /opt/ibm/notes/libnotes.so
#3  0xf5e87ba5 in InitEncryptDecryptAlga () from /opt/ibm/notes/libnotes.so
#4  0xf5e8e702 in AlgaChoiceChoose () from /opt/ibm/notes/libnotes.so
#5  0xf5e87a13 in AHChooseEncryptDecryptInit () from /opt/ibm/notes/libnotes.so
#6  0xf5e86345 in AHEncryptBSAFE1DecryptInit () from /opt/ibm/notes/libnotes.so
#7  0xf5e89908 in AH_RC2_CBC_BSAFE1DecryptInit () from /opt/ibm/notes/libnotes.so
#8  0xf5e893d7 in B_AlgorithmDecryptInit () from /opt/ibm/notes/libnotes.so
#9  0xf5e98214 in B_DecryptInit () from /opt/ibm/notes/libnotes.so
#10 0xf5afa69b in SECCryptoInit () from /opt/ibm/notes/libnotes.so
#11 0xf5b27663 in SECSetupCipherExt () from /opt/ibm/notes/libnotes.so
#12 0xf5b277de in SECOneStepCipherExt () from /opt/ibm/notes/libnotes.so
#13 0xf5b27b09 in SECAllocAndCipherExt () from /opt/ibm/notes/libnotes.so
#14 0xf5b27e2f in SECSecretCipherExt () from /opt/ibm/notes/libnotes.so
#15 0xf5b9bbfd in CipherIDFile () from /opt/ibm/notes/libnotes.so
#16 0xf5b9bcac in CipherIDFileAndLog () from /opt/ibm/notes/libnotes.so
#17 0xf5b9bf11 in GetPlaintextSI () from /opt/ibm/notes/libnotes.so
#18 0xf5b05916 in CheckPassword () from /opt/ibm/notes/libnotes.so
#19 0xf5b0691e in ExtendedAccess1 () from /opt/ibm/notes/libnotes.so
#20 0xf5aba87c in iKFMAccess () from /opt/ibm/notes/libnotes.so
#21 0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#22 0xf5ba4c41 in SECKFMSetPasswordFromPrompt () from /opt/ibm/notes/libnotes.so
#23 0x0892ef2e in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) ()
#24 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#25 0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) ()
#26 0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) ()
#27 0x08400021 in MainDlgProc ()
#28 0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#29 0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so
#30 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#31 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#32 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so
#33 0xf54b8b21 in Button_Click(unsigned int) () from /opt/ibm/notes/libemulator.so
#34 0xf54b9e70 in ButtonWindowProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#35 0xf54ba37f in ButtonWindowProcW(unsigned int, unsigned int, unsigned int, long) () from /opt/ibm/notes/libemulator.so
#36 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#37 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so
#38 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so
#39 0xf54b2c9e in IsDialogMessageW () from /opt/ibm/notes/libemulator.so
#40 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so
#41 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so
#42 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so
#43 0x084846cc in FontAdjustDialogBox ()
#44 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) ()
#45 0x08481068 in NEMDialogBoxParam ()
#46 0x08926c03 in DESKKFMPromptUser ()
#47 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so
#48 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so
#49 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so
#50 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so
#51 0xf5abd173 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#52 0xf5ab7531 in SECKFMUserInfo () from /opt/ibm/notes/libnotes.so
#53 0x0875f275 in PerformIDChallenge ()
#54 0x087697ec in CDeskSubprogram::SubMessageProc(unsigned int, unsigned int, long, long*) ()
#55 0x083d14ed in MainWndProc ()
#56 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#57 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so
#58 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so
#59 0x083e8f89 in NEMMainLoop ()
#60 0x083a513f in WinMain (hInstance=32, hPrevInstance=0, lpszCmdLine=0x963ca65 "/authenticate", cmdShow=0) at unotes.c:742
#61 0x083a846a in main (argc=2, argv=0xffffd674) at lmain.c:1297

1. Decompile "CheckPassword".

2. Decompile "GetFileHeader".

3. Decompile "IDFileGet".

4. Decompile "PerformIDChallenge".

(gdb) break ManagePasswordObj
Breakpoint 5 at 0xf5b48b73
(gdb) c
Continuing.

Thread 1 "lnotes" hit Breakpoint 5, 0xf5b48b73 in ManagePasswordObj () from /opt/ibm/notes/libnotes.so
(gdb) bt
#0  0xf5b48b73 in ManagePasswordObj () from /opt/ibm/notes/libnotes.so
#1  0xf5b0f3ae in SECKFMKfcSetup () from /opt/ibm/notes/libnotes.so
#2  0xf5b0f742 in SECKFMFileRead () from /opt/ibm/notes/libnotes.so
#3  0x0892ea18 in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) ()
#4  0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#5  0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) ()
#6  0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) ()
#7  0x08400021 in MainDlgProc ()
#8  0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#9  0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so
#10 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#11 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#12 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so
#13 0xf54b8b21 in Button_Click(unsigned int) () from /opt/ibm/notes/libemulator.so
#14 0xf54b9e70 in ButtonWindowProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#15 0xf54ba37f in ButtonWindowProcW(unsigned int, unsigned int, unsigned int, long) () from /opt/ibm/notes/libemulator.so
#16 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#17 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so
#18 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so
#19 0xf54b2c9e in IsDialogMessageW () from /opt/ibm/notes/libemulator.so
#20 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so
#21 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so
#22 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so
#23 0x084846cc in FontAdjustDialogBox ()
#24 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) ()
#25 0x08481068 in NEMDialogBoxParam ()
#26 0x08926c03 in DESKKFMPromptUser ()
#27 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so
#28 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so
#29 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so
#30 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so
#31 0xf5abd173 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#32 0xf5ab7531 in SECKFMUserInfo () from /opt/ibm/notes/libnotes.so
#33 0x0875f275 in PerformIDChallenge ()
#34 0x087697ec in CDeskSubprogram::SubMessageProc(unsigned int, unsigned int, long, long*) ()
#35 0x083d14ed in MainWndProc ()
#36 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#37 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so
#38 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so
#39 0x083e8f89 in NEMMainLoop ()
#40 0x083a513f in WinMain (hInstance=32, hPrevInstance=0, lpszCmdLine=0x963ca65 "/authenticate", cmdShow=0) at unotes.c:742
#41 0x083a846a in main (argc=2, argv=0xffffd674) at lmain.c:1297

ManagePasswordObj contains the "Lotus Notes Password Pad Uniquifier" stuff.

Look at SECKFMKfcSetup (caller of ManagePasswordObj) and see what else it does -> doesn't look very interesting.

(gdb)
#0  0xf5b0575f in CheckPassword () from /opt/ibm/notes/libnotes.so
#1  0xf5b0691e in ExtendedAccess1 () from /opt/ibm/notes/libnotes.so
#2  0xf5aba87c in iKFMAccess () from /opt/ibm/notes/libnotes.so
#3  0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#4  0xf5ba4c41 in SECKFMSetPasswordFromPrompt () from /opt/ibm/notes/libnotes.so
#5  0x0892ef2e in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) ()
#6  0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#7  0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) ()
#8  0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) ()
#9  0x08400021 in MainDlgProc ()
#10 0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#11 0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so
#12 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#13 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#14 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so
#15 0xf54b2829 in IsDialogControlMessageAW(unsigned int, tagMSG*, int) () from /opt/ibm/notes/libemulator.so
#16 0xf54b2c8a in IsDialogMessageW () from /opt/ibm/notes/libemulator.so
#17 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so
#18 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so
#19 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so
#20 0x084846cc in FontAdjustDialogBox ()
#21 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) ()
#22 0x08481068 in NEMDialogBoxParam ()
#23 0x08926c03 in DESKKFMPromptUser ()
#24 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so
#25 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so
#26 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so
#27 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so
#28 0xf5abd173 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#29 0xf5ab7531 in SECKFMUserInfo () from /opt/ibm/notes/libnotes.so
#30 0x0875f275 in PerformIDChallenge ()
#31 0x087697ec in CDeskSubprogram::SubMessageProc(unsigned int, unsigned int, long, long*) ()
#32 0x083d14ed in MainWndProc ()
#33 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#34 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so
#35 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so
#36 0x083e8f89 in NEMMainLoop ()
#37 0x083a513f in WinMain (hInstance=32, hPrevInstance=0, lpszCmdLine=0x963ca15 "/authenticate", cmdShow=0) at unotes.c:742
#38 0x083a846a in main (argc=2, argv=0xffffd674) at lmain.c:1297

I can trace function arguments of RC2Init and RC2Decrypt functions. The arguments match those generated by JtR for 64-bit ID files.

This function is called when bad password is entered!

Thread 1 "lnotes" hit Breakpoint 5, 0xf5b035db in BumpBadPWAndDelay () from /opt/ibm/notes/libnotes.so
(gdb) bt
#0  0xf5b035db in BumpBadPWAndDelay () from /opt/ibm/notes/libnotes.so
#1  0xf5b05ad8 in CheckPassword () from /opt/ibm/notes/libnotes.so
#2  0xf5b0691e in ExtendedAccess1 () from /opt/ibm/notes/libnotes.so
#3  0xf5aba87c in iKFMAccess () from /opt/ibm/notes/libnotes.so
#4  0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#5  0xf5ba4c41 in SECKFMSetPasswordFromPrompt () from /opt/ibm/notes/libnotes.so
#6  0x0892ef2e in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) ()
#7  0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#8  0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) ()
#9  0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) ()
#10 0x08400021 in MainDlgProc ()
#11 0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#12 0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so
#13 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#14 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#15 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so
#16 0xf54b8b21 in Button_Click(unsigned int) () from /opt/ibm/notes/libemulator.so
#17 0xf54b9e70 in ButtonWindowProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so
#18 0xf54ba37f in ButtonWindowProcW(unsigned int, unsigned int, unsigned int, long) () from /opt/ibm/notes/libemulator.so
#19 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so
#20 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so
#21 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so
#22 0xf54b2c9e in IsDialogMessageW () from /opt/ibm/notes/libemulator.so
#23 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so
#24 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so
#25 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so
#26 0x084846cc in FontAdjustDialogBox ()
#27 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) ()
#28 0x08481068 in NEMDialogBoxParam ()
#29 0x08926b7a in DESKKFMPromptUser ()
#30 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so
#31 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so
#32 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so
#33 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so
#34 0xf5aba64c in iKFMAccess () from /opt/ibm/notes/libnotes.so
#35 0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#36 0xf5b10183 in SECKFMFileRead () from /opt/ibm/notes/libnotes.so


...


Locate ebits_to_num array, and find xrefs to it. This can lead us to the custom hash function.

We have found "... Pad Uniquifier" string in "ManagePasswordObj" function.

ManagePasswordObj calls SECConvertPasswordToKey function. Is this the custom hash function?


$ ./signsrch.exe libnotes.so

Signsrch 0.2.4
by Luigi Auriemma
e-mail: aluigi@autistici.org
web:    aluigi.org
  optimized search function by Andrew http://www.team5150.com/~andrew/
  disassembler engine by Oleh Yuschuk

- open file "libnotes.so"
- 94810221 bytes allocated
- load signatures
- open file signsrch.sig
- 3075 signatures in the database
- WARNING:
  the file loaded in memory is very big so the scanning may take many time
- start 4 threads
- start signatures scanning:

  offset   num  description [bits.endian.size]
  --------------------------------------------
  0014d3b4 2249 TEA1_DS [32.le.4]
  0054ad37 1036 SHA1 / SHA0 / RIPEMD-160 initialization [32.le.20&]
  0054ad4c 2053 RIPEMD-128 InitState [32.le.16&]
  006c9ef0 948  DES [32.le.20&]
  006ccfd2 1018 MD5 digest [32.le.272&]
  006d0e11 2059 RC5 and RC6 magic values (0xb7e15163L 0x61C88647) [32.le.8&]
  01d1c9c0 1963 FFT and FHT routines rv_tbl [..128]
  01d1c9c0 871  ACSS reverse sbox [..256]
  01d1cec0 641  CRC-32-IEEE 802.3 [crc32.0x04c11db7 le rev int_min.1024]
  01d1cec0 648  CRC-32-IEEE 802.3 [crc32.0xedb88320 lenorev 1.1024]
  01d24b3d 2005 B64EncodeTable [..64]
  01d24b3d 1996 rfc3548 Base 64 Encoding with URL and Filename Safe Alphabet [..62]
  01d2e8e0 1119 Jpeg dct AA&N scale factor [double.le.64]
  01d2e920 1115 Jpeg dct 14 bit aanscales [16.le.128]
  01d2e9bd 2417 MBC2 [32.le.248&]
  01d2e9c0 2418 MBC2 [32.be.248&]
  01d2eae0 1809 libdjvu GPixmap dither table [..256]
  01d2fc60 3038 unlzx table_three [32.le.64]
  01d303c0 1022 RC2 tab ebits to num [..256]  ==> TANGO!
  01d33b40 894  AES Rijndael S / ARIA S1 [..256]
  01d33c40 895  AES Rijndael Si / ARIA X1 [..256]
  01d33d40 1021 RC2 skey key_table [..256]


We have located the "ebits_to_num" array.

Jumping to this offset in IDA shows that this array is called "PISUBST". This
array is referenced from "SECMacUpdate" and "SEC4ByteMac" functions.

Let's put breakpoint on "SECCalcMAC" (the parent of these functions), and
compare the backtrace with the backtrace of RC2Decrypt function to find the
higher level functions (parent callers).

Thread 1 "lnotes" hit Breakpoint 3, 0xf5ac2d7a in SECCalcMAC () from /opt/ibm/notes/libnotes.so
(gdb) bt
#0  0xf5ac2d7a in SECCalcMAC () from /opt/ibm/notes/libnotes.so
#1  0xf5b142f0 in ChecksumIDFH () from /opt/ibm/notes/libnotes.so
#2  0xf5b184eb in SECConvertODS () from /opt/ibm/notes/libnotes.so
#3  0xf5ab976b in SECKFMOpenKeyFile () from /opt/ibm/notes/libnotes.so
#4  0xf5abe421 in IDFileGet () from /opt/ibm/notes/libnotes.so
#5  0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so
#6  0xf5aba64c in iKFMAccess () from /opt/ibm/notes/libnotes.so
#7  0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so
#8  0xf5b10183 in SECKFMFileRead () from /opt/ibm/notes/libnotes.so
#9  0x088f8859 in ReadStaticKFC(int, unsigned short, unsigned short) ()


Hmmm, "SECCalcMAC" is not called after the password is entered ;(


Look at "CipherIDFile" -> this has the logic to use different algorithms, based on the data in the ID file (?).
<!-- gh-comment-id:345251971 --> @kholia commented on GitHub (Nov 17, 2017): Here are some of my raw reversing notes, ``` $ cat ~/.gdbinit set disassembly-flavor intel set history save on set print pretty on set pagination off set confirm off # set disable-randomization off # unbreak reverse-continue watchpoints # set can-use-hw-watchpoints 0 define xxd dump binary memory dump.bin $arg0 $arg0+$arg1 shell xxd dump.bin end set follow-fork-mode child $ nm /opt/ibm/notes/libnotes.so | c++filt | grep -i verify $ ps uax | grep -i notes lulu 3872 0.3 6.0 435888 123076 ? Sl 20:17 0:01 /opt/ibm/notes/framework/../notes /authenticate $ gbd -p 3872 (gdb) break RC2Init Breakpoint 1 at 0xf5ea429e (gdb) c Thread 1 "lnotes" hit Breakpoint 1, 0xf5ea429e in RC2Init () from /opt/ibm/notes/libnotes.so (gdb) quit (gdb) bt #0 0xf5ea429e in RC2Init () from /opt/ibm/notes/libnotes.so #1 0xf5ea2d08 in A_RC2_CBCDecryptInit () from /opt/ibm/notes/libnotes.so #2 0xf5e90018 in RC2_CBCDecryptInit () from /opt/ibm/notes/libnotes.so #3 0xf5e87ba5 in InitEncryptDecryptAlga () from /opt/ibm/notes/libnotes.so #4 0xf5e8e702 in AlgaChoiceChoose () from /opt/ibm/notes/libnotes.so #5 0xf5e87a13 in AHChooseEncryptDecryptInit () from /opt/ibm/notes/libnotes.so #6 0xf5e86345 in AHEncryptBSAFE1DecryptInit () from /opt/ibm/notes/libnotes.so #7 0xf5e89908 in AH_RC2_CBC_BSAFE1DecryptInit () from /opt/ibm/notes/libnotes.so #8 0xf5e893d7 in B_AlgorithmDecryptInit () from /opt/ibm/notes/libnotes.so #9 0xf5e98214 in B_DecryptInit () from /opt/ibm/notes/libnotes.so #10 0xf5afa69b in SECCryptoInit () from /opt/ibm/notes/libnotes.so #11 0xf5b27663 in SECSetupCipherExt () from /opt/ibm/notes/libnotes.so #12 0xf5b277de in SECOneStepCipherExt () from /opt/ibm/notes/libnotes.so #13 0xf5b27b09 in SECAllocAndCipherExt () from /opt/ibm/notes/libnotes.so #14 0xf5b27e2f in SECSecretCipherExt () from /opt/ibm/notes/libnotes.so #15 0xf5b9bbfd in CipherIDFile () from /opt/ibm/notes/libnotes.so #16 0xf5b9bcac in CipherIDFileAndLog () from /opt/ibm/notes/libnotes.so #17 0xf5b9bf11 in GetPlaintextSI () from /opt/ibm/notes/libnotes.so #18 0xf5b05916 in CheckPassword () from /opt/ibm/notes/libnotes.so #19 0xf5b0691e in ExtendedAccess1 () from /opt/ibm/notes/libnotes.so #20 0xf5aba87c in iKFMAccess () from /opt/ibm/notes/libnotes.so #21 0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #22 0xf5ba4c41 in SECKFMSetPasswordFromPrompt () from /opt/ibm/notes/libnotes.so #23 0x0892ef2e in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) () #24 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #25 0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) () #26 0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) () #27 0x08400021 in MainDlgProc () #28 0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #29 0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so #30 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #31 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #32 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so #33 0xf54b8b21 in Button_Click(unsigned int) () from /opt/ibm/notes/libemulator.so #34 0xf54b9e70 in ButtonWindowProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #35 0xf54ba37f in ButtonWindowProcW(unsigned int, unsigned int, unsigned int, long) () from /opt/ibm/notes/libemulator.so #36 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #37 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so #38 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so #39 0xf54b2c9e in IsDialogMessageW () from /opt/ibm/notes/libemulator.so #40 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so #41 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so #42 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so #43 0x084846cc in FontAdjustDialogBox () #44 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) () #45 0x08481068 in NEMDialogBoxParam () #46 0x08926c03 in DESKKFMPromptUser () #47 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so #48 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so #49 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so #50 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so #51 0xf5abd173 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #52 0xf5ab7531 in SECKFMUserInfo () from /opt/ibm/notes/libnotes.so #53 0x0875f275 in PerformIDChallenge () #54 0x087697ec in CDeskSubprogram::SubMessageProc(unsigned int, unsigned int, long, long*) () #55 0x083d14ed in MainWndProc () #56 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #57 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so #58 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so #59 0x083e8f89 in NEMMainLoop () #60 0x083a513f in WinMain (hInstance=32, hPrevInstance=0, lpszCmdLine=0x963ca65 "/authenticate", cmdShow=0) at unotes.c:742 #61 0x083a846a in main (argc=2, argv=0xffffd674) at lmain.c:1297 1. Decompile "CheckPassword". 2. Decompile "GetFileHeader". 3. Decompile "IDFileGet". 4. Decompile "PerformIDChallenge". (gdb) break ManagePasswordObj Breakpoint 5 at 0xf5b48b73 (gdb) c Continuing. Thread 1 "lnotes" hit Breakpoint 5, 0xf5b48b73 in ManagePasswordObj () from /opt/ibm/notes/libnotes.so (gdb) bt #0 0xf5b48b73 in ManagePasswordObj () from /opt/ibm/notes/libnotes.so #1 0xf5b0f3ae in SECKFMKfcSetup () from /opt/ibm/notes/libnotes.so #2 0xf5b0f742 in SECKFMFileRead () from /opt/ibm/notes/libnotes.so #3 0x0892ea18 in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) () #4 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #5 0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) () #6 0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) () #7 0x08400021 in MainDlgProc () #8 0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #9 0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so #10 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #11 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #12 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so #13 0xf54b8b21 in Button_Click(unsigned int) () from /opt/ibm/notes/libemulator.so #14 0xf54b9e70 in ButtonWindowProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #15 0xf54ba37f in ButtonWindowProcW(unsigned int, unsigned int, unsigned int, long) () from /opt/ibm/notes/libemulator.so #16 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #17 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so #18 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so #19 0xf54b2c9e in IsDialogMessageW () from /opt/ibm/notes/libemulator.so #20 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so #21 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so #22 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so #23 0x084846cc in FontAdjustDialogBox () #24 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) () #25 0x08481068 in NEMDialogBoxParam () #26 0x08926c03 in DESKKFMPromptUser () #27 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so #28 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so #29 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so #30 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so #31 0xf5abd173 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #32 0xf5ab7531 in SECKFMUserInfo () from /opt/ibm/notes/libnotes.so #33 0x0875f275 in PerformIDChallenge () #34 0x087697ec in CDeskSubprogram::SubMessageProc(unsigned int, unsigned int, long, long*) () #35 0x083d14ed in MainWndProc () #36 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #37 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so #38 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so #39 0x083e8f89 in NEMMainLoop () #40 0x083a513f in WinMain (hInstance=32, hPrevInstance=0, lpszCmdLine=0x963ca65 "/authenticate", cmdShow=0) at unotes.c:742 #41 0x083a846a in main (argc=2, argv=0xffffd674) at lmain.c:1297 ManagePasswordObj contains the "Lotus Notes Password Pad Uniquifier" stuff. Look at SECKFMKfcSetup (caller of ManagePasswordObj) and see what else it does -> doesn't look very interesting. (gdb) #0 0xf5b0575f in CheckPassword () from /opt/ibm/notes/libnotes.so #1 0xf5b0691e in ExtendedAccess1 () from /opt/ibm/notes/libnotes.so #2 0xf5aba87c in iKFMAccess () from /opt/ibm/notes/libnotes.so #3 0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #4 0xf5ba4c41 in SECKFMSetPasswordFromPrompt () from /opt/ibm/notes/libnotes.so #5 0x0892ef2e in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) () #6 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #7 0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) () #8 0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) () #9 0x08400021 in MainDlgProc () #10 0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #11 0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so #12 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #13 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #14 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so #15 0xf54b2829 in IsDialogControlMessageAW(unsigned int, tagMSG*, int) () from /opt/ibm/notes/libemulator.so #16 0xf54b2c8a in IsDialogMessageW () from /opt/ibm/notes/libemulator.so #17 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so #18 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so #19 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so #20 0x084846cc in FontAdjustDialogBox () #21 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) () #22 0x08481068 in NEMDialogBoxParam () #23 0x08926c03 in DESKKFMPromptUser () #24 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so #25 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so #26 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so #27 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so #28 0xf5abd173 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #29 0xf5ab7531 in SECKFMUserInfo () from /opt/ibm/notes/libnotes.so #30 0x0875f275 in PerformIDChallenge () #31 0x087697ec in CDeskSubprogram::SubMessageProc(unsigned int, unsigned int, long, long*) () #32 0x083d14ed in MainWndProc () #33 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #34 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so #35 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so #36 0x083e8f89 in NEMMainLoop () #37 0x083a513f in WinMain (hInstance=32, hPrevInstance=0, lpszCmdLine=0x963ca15 "/authenticate", cmdShow=0) at unotes.c:742 #38 0x083a846a in main (argc=2, argv=0xffffd674) at lmain.c:1297 I can trace function arguments of RC2Init and RC2Decrypt functions. The arguments match those generated by JtR for 64-bit ID files. This function is called when bad password is entered! Thread 1 "lnotes" hit Breakpoint 5, 0xf5b035db in BumpBadPWAndDelay () from /opt/ibm/notes/libnotes.so (gdb) bt #0 0xf5b035db in BumpBadPWAndDelay () from /opt/ibm/notes/libnotes.so #1 0xf5b05ad8 in CheckPassword () from /opt/ibm/notes/libnotes.so #2 0xf5b0691e in ExtendedAccess1 () from /opt/ibm/notes/libnotes.so #3 0xf5aba87c in iKFMAccess () from /opt/ibm/notes/libnotes.so #4 0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #5 0xf5ba4c41 in SECKFMSetPasswordFromPrompt () from /opt/ibm/notes/libnotes.so #6 0x0892ef2e in DESKKFMGetPWDialog(unsigned int, unsigned int, unsigned int, long) () #7 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #8 0x083fed3e in DlgCallDefWndProc(unsigned int, int, int, unsigned int, unsigned int, long) () #9 0x083ffce5 in CommonDlgProc(unsigned int, unsigned int, unsigned int, long, int, int) () #10 0x08400021 in MainDlgProc () #11 0xf54b2e2a in DefDlgProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #12 0xf54b34a2 in DefDlgProcW () from /opt/ibm/notes/libemulator.so #13 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #14 0xf54b155e in SendMessageAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #15 0xf54b1696 in SendMessageW () from /opt/ibm/notes/libemulator.so #16 0xf54b8b21 in Button_Click(unsigned int) () from /opt/ibm/notes/libemulator.so #17 0xf54b9e70 in ButtonWindowProcAW(unsigned int, unsigned int, unsigned int, long, int) () from /opt/ibm/notes/libemulator.so #18 0xf54ba37f in ButtonWindowProcW(unsigned int, unsigned int, unsigned int, long) () from /opt/ibm/notes/libemulator.so #19 0xf549b844 in CallWindowProcW () from /opt/ibm/notes/libemulator.so #20 0xf54b181b in DispatchMessageAW(tagMSG const*, int) () from /opt/ibm/notes/libemulator.so #21 0xf54b1860 in DispatchMessageW () from /opt/ibm/notes/libemulator.so #22 0xf54b2c9e in IsDialogMessageW () from /opt/ibm/notes/libemulator.so #23 0xf54b3e0c in runModalDialogLoop(unsigned int, unsigned int) () from /opt/ibm/notes/libemulator.so #24 0xf54b4b66 in createAllDialogAW(unsigned int, DLGTEMPLATE const*, unsigned int, int (*)(), long, int, int) () from /opt/ibm/notes/libemulator.so #25 0xf54b4ca7 in DialogBoxIndirectParamW () from /opt/ibm/notes/libemulator.so #26 0x084846cc in FontAdjustDialogBox () #27 0x08480fca in NEMDialogBoxCore(unsigned int, unsigned short, long (*)(unsigned int, unsigned int, unsigned int, long), unsigned short, unsigned long) () #28 0x08481068 in NEMDialogBoxParam () #29 0x08926b7a in DESKKFMPromptUser () #30 0xf5ab461e in iBSAFEPromptWithoutSems () from /opt/ibm/notes/libnotes.so #31 0xf5abc44a in iBSAFECallPromptHandler () from /opt/ibm/notes/libnotes.so #32 0xf5abef97 in IDFileGet () from /opt/ibm/notes/libnotes.so #33 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so #34 0xf5aba64c in iKFMAccess () from /opt/ibm/notes/libnotes.so #35 0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #36 0xf5b10183 in SECKFMFileRead () from /opt/ibm/notes/libnotes.so ... Locate ebits_to_num array, and find xrefs to it. This can lead us to the custom hash function. We have found "... Pad Uniquifier" string in "ManagePasswordObj" function. ManagePasswordObj calls SECConvertPasswordToKey function. Is this the custom hash function? $ ./signsrch.exe libnotes.so Signsrch 0.2.4 by Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org optimized search function by Andrew http://www.team5150.com/~andrew/ disassembler engine by Oleh Yuschuk - open file "libnotes.so" - 94810221 bytes allocated - load signatures - open file signsrch.sig - 3075 signatures in the database - WARNING: the file loaded in memory is very big so the scanning may take many time - start 4 threads - start signatures scanning: offset num description [bits.endian.size] -------------------------------------------- 0014d3b4 2249 TEA1_DS [32.le.4] 0054ad37 1036 SHA1 / SHA0 / RIPEMD-160 initialization [32.le.20&] 0054ad4c 2053 RIPEMD-128 InitState [32.le.16&] 006c9ef0 948 DES [32.le.20&] 006ccfd2 1018 MD5 digest [32.le.272&] 006d0e11 2059 RC5 and RC6 magic values (0xb7e15163L 0x61C88647) [32.le.8&] 01d1c9c0 1963 FFT and FHT routines rv_tbl [..128] 01d1c9c0 871 ACSS reverse sbox [..256] 01d1cec0 641 CRC-32-IEEE 802.3 [crc32.0x04c11db7 le rev int_min.1024] 01d1cec0 648 CRC-32-IEEE 802.3 [crc32.0xedb88320 lenorev 1.1024] 01d24b3d 2005 B64EncodeTable [..64] 01d24b3d 1996 rfc3548 Base 64 Encoding with URL and Filename Safe Alphabet [..62] 01d2e8e0 1119 Jpeg dct AA&N scale factor [double.le.64] 01d2e920 1115 Jpeg dct 14 bit aanscales [16.le.128] 01d2e9bd 2417 MBC2 [32.le.248&] 01d2e9c0 2418 MBC2 [32.be.248&] 01d2eae0 1809 libdjvu GPixmap dither table [..256] 01d2fc60 3038 unlzx table_three [32.le.64] 01d303c0 1022 RC2 tab ebits to num [..256] ==> TANGO! 01d33b40 894 AES Rijndael S / ARIA S1 [..256] 01d33c40 895 AES Rijndael Si / ARIA X1 [..256] 01d33d40 1021 RC2 skey key_table [..256] We have located the "ebits_to_num" array. Jumping to this offset in IDA shows that this array is called "PISUBST". This array is referenced from "SECMacUpdate" and "SEC4ByteMac" functions. Let's put breakpoint on "SECCalcMAC" (the parent of these functions), and compare the backtrace with the backtrace of RC2Decrypt function to find the higher level functions (parent callers). Thread 1 "lnotes" hit Breakpoint 3, 0xf5ac2d7a in SECCalcMAC () from /opt/ibm/notes/libnotes.so (gdb) bt #0 0xf5ac2d7a in SECCalcMAC () from /opt/ibm/notes/libnotes.so #1 0xf5b142f0 in ChecksumIDFH () from /opt/ibm/notes/libnotes.so #2 0xf5b184eb in SECConvertODS () from /opt/ibm/notes/libnotes.so #3 0xf5ab976b in SECKFMOpenKeyFile () from /opt/ibm/notes/libnotes.so #4 0xf5abe421 in IDFileGet () from /opt/ibm/notes/libnotes.so #5 0xf5abf6b1 in GetFileHeader () from /opt/ibm/notes/libnotes.so #6 0xf5aba64c in iKFMAccess () from /opt/ibm/notes/libnotes.so #7 0xf5abdb85 in SECKFMAccess () from /opt/ibm/notes/libnotes.so #8 0xf5b10183 in SECKFMFileRead () from /opt/ibm/notes/libnotes.so #9 0x088f8859 in ReadStaticKFC(int, unsigned short, unsigned short) () Hmmm, "SECCalcMAC" is not called after the password is entered ;( Look at "CipherIDFile" -> this has the logic to use different algorithms, based on the data in the ID file (?). ```
Author
Owner

@kholia commented on GitHub (Nov 17, 2017):

The password check functions trigger at startup,

lotus-startup-check

They can also be triggered multiple times from within the application,

lotus-retrigger-check

<!-- gh-comment-id:345305848 --> @kholia commented on GitHub (Nov 17, 2017): The password check functions trigger at startup, ![lotus-startup-check](https://user-images.githubusercontent.com/79528/32959841-ed55da62-cbe8-11e7-9fc1-670dbe833a23.png) They can also be triggered multiple times from within the application, ![lotus-retrigger-check](https://user-images.githubusercontent.com/79528/32959864-fa55b160-cbe8-11e7-8f66-4f89de655a7f.png)
Author
Owner

@kholia commented on GitHub (Nov 18, 2017):

GDB helper script,

#!/usr/bin/gdb -x
#
# Based on https://github.com/crossbowerbt/GDB-Python-Utils
#
# Tested on GDB 7.11 running on Ubuntu 16.04 LTS.

import gdb
import binascii
import traceback
import struct


def usage():
    print("Usage:")
    print("\t./sniffer -p <pid>")
    gdb.execute('quit')


class RC2Init(gdb.Breakpoint):
    def __init__(self):
        super(RC2Init, self).__init__('RC2Init')

    def stop(self):
        print("RC2Init >>>")
        try:
            ebp = int(gdb.parse_and_eval('$ebp'))
            aa_1 = gdb.parse_and_eval("*(int*)($ebp + 0x10)")  # key length, 64 / 128
            print("Key length is %s" % aa_1)
            print("")
            gdb.execute("x/16bx *(int*)(*(int*)($ebp + 0x0c))")  # key, matches john for 64-bit
            print("")
        except:
            traceback.print_exc()
            return True

        return False

class RC2Decrypt(gdb.Breakpoint):
    def __init__(self):
        super(RC2Decrypt, self).__init__('RC2Decrypt')

    def stop(self):
        printed = False
        print("RC2Decrypt >>>")
        try:
            if not printed:
                gdb.execute("x/8bx *(int*)($ebp + 0x10)")  # data, matches john for 64-bit lotus files
                printed = True
            print("")
        except:
            traceback.print_exc()
            return True

        return False


out = open("log.txt", "a")

# GDB setup
gdb.execute("set print repeats unlimited")
gdb.execute("set print elements unlimited")
gdb.execute("set pagination off")
gdb.execute("handle SIGUSR1 nostop")
gdb.execute("handle SIGUSR1 noprint")

# generate breakpoints
RC2Init()
RC2Decrypt()

# run and sniff
gdb.execute('continue')

# gdb.execute('detach')
# gdb.execute('quit')
<!-- gh-comment-id:345448208 --> @kholia commented on GitHub (Nov 18, 2017): GDB helper script, ``` Python #!/usr/bin/gdb -x # # Based on https://github.com/crossbowerbt/GDB-Python-Utils # # Tested on GDB 7.11 running on Ubuntu 16.04 LTS. import gdb import binascii import traceback import struct def usage(): print("Usage:") print("\t./sniffer -p <pid>") gdb.execute('quit') class RC2Init(gdb.Breakpoint): def __init__(self): super(RC2Init, self).__init__('RC2Init') def stop(self): print("RC2Init >>>") try: ebp = int(gdb.parse_and_eval('$ebp')) aa_1 = gdb.parse_and_eval("*(int*)($ebp + 0x10)") # key length, 64 / 128 print("Key length is %s" % aa_1) print("") gdb.execute("x/16bx *(int*)(*(int*)($ebp + 0x0c))") # key, matches john for 64-bit print("") except: traceback.print_exc() return True return False class RC2Decrypt(gdb.Breakpoint): def __init__(self): super(RC2Decrypt, self).__init__('RC2Decrypt') def stop(self): printed = False print("RC2Decrypt >>>") try: if not printed: gdb.execute("x/8bx *(int*)($ebp + 0x10)") # data, matches john for 64-bit lotus files printed = True print("") except: traceback.print_exc() return True return False out = open("log.txt", "a") # GDB setup gdb.execute("set print repeats unlimited") gdb.execute("set print elements unlimited") gdb.execute("set pagination off") gdb.execute("handle SIGUSR1 nostop") gdb.execute("handle SIGUSR1 noprint") # generate breakpoints RC2Init() RC2Decrypt() # run and sniff gdb.execute('continue') # gdb.execute('detach') # gdb.execute('quit')
Author
Owner

@kholia commented on GitHub (Nov 18, 2017):

Key problems,

  • Locate compute_key_mac, compute_msg_mac, and custom_password_hash functions in libnotes.so file, and trace them.

  • Are we sure that these "MAC" functions are called during password checking? They should be but "SECCalcMAC" and "SEC4ByteMac" are not getting hit.

Ideas,

  • Can we put a read watchpoint on "PISUBST" array (at least on some locations)? Use JtR's code to find the locations which will surely get hit.
<!-- gh-comment-id:345448812 --> @kholia commented on GitHub (Nov 18, 2017): Key problems, * Locate `compute_key_mac`, `compute_msg_mac`, and `custom_password_hash` functions in `libnotes.so` file, and trace them. * Are we sure that these "MAC" functions are called during password checking? They should be but "SECCalcMAC" and "SEC4ByteMac" are not getting hit. Ideas, * Can we put a read watchpoint on "PISUBST" array (at least on some locations)? Use JtR's code to find the locations which will surely get hit.
Author
Owner

@kholia commented on GitHub (Jun 24, 2018):

Look at https://github.com/mozilla/rr and https://undo.io/ to help with this task.

<!-- gh-comment-id:399752219 --> @kholia commented on GitHub (Jun 24, 2018): Look at https://github.com/mozilla/rr and https://undo.io/ to help with this task.
Author
Owner

@kholia commented on GitHub (Jun 24, 2018):

Xubuntu 14.04.5 LTS setup notes,

$ sudo aptitude install virtualbox-dkms -y

$ sudo aptitude install libart-2.0-2 libasound2 libatk1.0-0 libbonobo2-0 libbonoboui2-0 libc6 \
    libfontconfig1 libfreetype6 libgcc1 libgconf2-4 libgtk2.0-0 libglib2.0-0 libgnome2-0 \
    libgnomecanvas2-0  libgnome-desktop-2-17 libgnomeui-0 libgnomevfs2-0 libglib2.0-0 libice6 \
    libjpeg62 liborbit2 libpam0g libpango1.0-0 libpng12-0 libpopt0 libsm6 libstdc++6 libx11-6 \
    libxcursor1 libxext6 libxft2 libxi6 libxkbfile1 libxml2 libxrender1 libxss1 libxt6 libxtst6 libz1
<!-- gh-comment-id:399767581 --> @kholia commented on GitHub (Jun 24, 2018): Xubuntu 14.04.5 LTS setup notes, ``` $ sudo aptitude install virtualbox-dkms -y $ sudo aptitude install libart-2.0-2 libasound2 libatk1.0-0 libbonobo2-0 libbonoboui2-0 libc6 \ libfontconfig1 libfreetype6 libgcc1 libgconf2-4 libgtk2.0-0 libglib2.0-0 libgnome2-0 \ libgnomecanvas2-0 libgnome-desktop-2-17 libgnomeui-0 libgnomevfs2-0 libglib2.0-0 libice6 \ libjpeg62 liborbit2 libpam0g libpango1.0-0 libpng12-0 libpopt0 libsm6 libstdc++6 libx11-6 \ libxcursor1 libxext6 libxft2 libxi6 libxkbfile1 libxml2 libxrender1 libxss1 libxt6 libxtst6 libz1 ```
Author
Owner

@kholia commented on GitHub (Sep 21, 2018):

I wonder how Sébastien Kaczmarek found the custom_password_hash function in nnotes.dll (Windows version) file.

This function (in JtR) seems be to buggy (or unused!) when processing RC2-128 encrypted ID files.

<!-- gh-comment-id:423505910 --> @kholia commented on GitHub (Sep 21, 2018): I wonder how Sébastien Kaczmarek found the `custom_password_hash` function in `nnotes.dll` (Windows version) file. This function (in JtR) seems be to buggy (or unused!) when processing RC2-128 encrypted ID files.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#171
No description provided.