å
æ¥ãKeePassããŒã¿ããŒã¹åŸ©å·åãå®è£
ããå¿
èŠããããŸããã ç§ã¯ããã¹ãŠã®ãã¥ã¢ã³ã¹ãèæ
®ããŠã.kdbãã¡ã€ã«ãš.kdbxãã¡ã€ã«ã®åŸ©å·åã¢ã«ãŽãªãºã ã«é¢ããå
æ¬çãªæ
å ±ãå«ãåäžã®ããã¥ã¡ã³ããåäžã®èšäºããªããšããäºå®ã«æéãåããŸããã ãã®ããããã®èšäºãæžãããã«ãªããŸããã
çŸåšãKeePassã«ã¯2ã€ã®ããŒãžã§ã³ããããŸãã
- KeePass 1.xïŒ.kdbãã¡ã€ã«ãçæïŒ;
- KeePass 2.xïŒ.kdbxãã¡ã€ã«ãçæïŒã
KeePassããŒã¿ããŒã¹ïŒ.kdbã.kdbxïŒãå«ããã¡ã€ã«ã®æ§é ã¯ã3ã€ã®éšåã§æ§æãããŠããŸãã
- 眲åïŒæå·åãããŠããªãïŒ;
- ã¿ã€ãã«ïŒæå·åãããŠããªãïŒ;
- ããŒã¿ïŒæå·åïŒã
次ã«ãKeePass 1.xããã³KeePass 2.xããŒã¿ããŒã¹ã埩å·åããæ¹æ³ã«ã€ããŠè©³ãã説æããŸãã
KeePassããŒã¿ããŒã¹ã®åŸ©å·å
ã¢ã¯ã·ã§ã³ã®ã·ãŒã±ã³ã¹ ïŒ
- ããŒã¿ããŒã¹çœ²åãèªã¿åããŸãã
- ããŒã¿ããŒã¹ããããŒãèªã¿åããŸãã
- ãã¹ã¿ãŒããŒãçæããŸãã
- ããŒã¿ããŒã¹ã解èªããŸãã
- ããŒã¿ã®æŽåæ§ã確èªããŸãã
- ãã¡ã€ã«ãå§çž®ãããŠããå Žåã¯ã解åããŸãã
- ãã¹ã¯ãŒãã解èªããŸãã
é
ç®5ã6ãããã³7ã¯.kdbxãã¡ã€ã«ã«ã®ã¿é©çšãããŸã ïŒ
眲å
BaseSignatureïŒ4ãã€ãïŒ
æåã®çœ²åã¯ã.kdbãã¡ã€ã«ãš.kdbxãã¡ã€ã«ã§åãã§ãã 圌女ã¯ããã®ãã¡ã€ã«ã¯KeePassããŒã¿ããŒã¹ã§ãããšèšã£ãŠããŸãã
VersionSignatureïŒ4ãã€ãïŒ
2çªç®ã®çœ²åã¯KeePassã®ããŒãžã§ã³ã瀺ããŠããããã.kdbãã¡ã€ã«ãš.kdbxãã¡ã€ã«ã§ã¯ç°ãªããŸãã
- 0xB54BFB65-KeePass 1.xïŒ.kdbãã¡ã€ã«ïŒã
- 0xB54BFB66-KeePass 2.xãã¬ãªãªãŒã¹ïŒ.kdbxãã¡ã€ã«ïŒã
- 0xB54BFB67-KeePass 2.xã®ãªãªãŒã¹åŸïŒ.kdbxãã¡ã€ã«ïŒã
FileVersionïŒ4ãã€ãïŒ
.kdbxãã¡ã€ã«ã®ã¿ã«3çªç®ã®çœ²åãããããã¡ã€ã«ã®ããŒãžã§ã³ãå«ãŸããŠããŸãã .kdbãã¡ã€ã«ã®å Žåããã®æ
å ±ã¯ããŒã¿ããŒã¹ããããŒã«å«ãŸããŠããŸãã
ãããã£ãŠãKeePass 1.xã§ã¯çœ²åã®é·ãã¯8ãã€ãã§ãããKeePass 2.xã§ã¯12ãã€ãã§ãã
èŠåºã
ããŒã¿ããŒã¹ã«çœ²åãããšãããããŒãå§ãŸããŸãã
KeePass 1.xããããŒ
.kdbãã¡ã€ã«ã®ããããŒã¯ã次ã®ãã£ãŒã«ãã§æ§æãããŠããŸãã
- ãã©ã°ïŒ4ãã€ãïŒïŒãã®ãã£ãŒã«ãã¯ããã¡ã€ã«ã®äœææã«äœ¿çšãããæå·åã®ã¿ã€ãã瀺ããŸãã
- 0x01-SHA256;
- 0x02-AES256;
- 0x04-ARC4;
- 0x08-Twofishã
- ããŒãžã§ã³ïŒ4ãã€ãïŒïŒãã¡ã€ã«ã®ããŒãžã§ã³ã
- ãã¹ã¿ãŒã·ãŒãïŒ16ãã€ãïŒïŒãã¹ã¿ãŒããŒã®äœæã«äœ¿çšãããŸãã
- æå·åIVïŒ16ãã€ãïŒïŒããŒã¿ã®è§£èªã«äœ¿çšãããŸãã
- ã°ã«ãŒãæ°ïŒ4ãã€ãïŒïŒããŒã¿ããŒã¹å
ã®ã°ã«ãŒãã®ç·æ°ã
- ãšã³ããªæ°ïŒ4ãã€ãïŒïŒããŒã¿ããŒã¹å
ã®ãšã³ããªã®ç·æ°ã
- ã³ã³ãã³ãããã·ã¥ïŒ32ãã€ãïŒïŒåŸ©å·åãããããŒã¿ãããã·ã¥ããŸãã
- å€æã·ãŒãïŒ32ãã€ãïŒïŒãã¹ã¿ãŒããŒã®äœæã«äœ¿çšãããŸãã
- å€æã©ãŠã³ãïŒ4ãã€ãïŒïŒãã¹ã¿ãŒããŒã®äœæã«äœ¿çšãããŸãã
KeePass 2.xããããŒ
.kdbxãã¡ã€ã«ã§ã¯ãåããããŒãã£ãŒã«ãã¯3ã€ã®éšåã§æ§æãããŠããŸãã
- ãã£ãŒã«ãIDïŒ1ãã€ãïŒïŒå¯èœãªå€ã¯0ã10ã§ãã
- ããŒã¿é·ïŒ2ãã€ãïŒã
- ããŒã¿ïŒ[ããŒã¿é·]ãã€ãïŒ
.kdbxãã¡ã€ã«ã®ããããŒã¯ã次ã®ãã£ãŒã«ãã§æ§æãããŠããŸãã
- ID = 0x01ã³ã¡ã³ãïŒãã®ãã£ãŒã«ãã¯ããããŒã§è¡šãããšãã§ããŸãããããŒã¿ããŒã¹ã«ã¯ãããŸããã§ããã
- ID = 0x02æå·IDïŒäœ¿çšãããæå·åæ¹æ³ã瀺ãUUIDïŒããšãã°ãAES 256 UUID = [0x31ã0xC1ã0xF2ã0xE6ã0xBFã0x71ã0x43ã0x50ã0xBEã0x58ã0x05ã0x21ã0x6Aã0xFCã 0x5Aã0xFF]ïŒã
- ID = 0x03å§çž®ãã©ã°ïŒããŒã¿ããŒã¹ã®å§çž®ã«äœ¿çšãããã¢ã«ãŽãªãºã ã®IDïŒ
- 0x00ïŒãªã;
- 0x01ïŒGZipã
- ID = 0x04ãã¹ã¿ãŒã·ãŒãïŒãã¹ã¿ãŒããŒã®äœæã«äœ¿çšã
- ID = 0x05ãã©ã³ã¹ãã©ãŒã ã·ãŒãïŒãã¹ã¿ãŒããŒã®äœæã«äœ¿çšã
- ID = 0x06å€æã©ãŠã³ãïŒãã¹ã¿ãŒããŒã®äœæã«äœ¿çšãããŸãã
- ID = 0x07æå·åIVïŒããŒã¿ã®è§£èªã«äœ¿çšãããŸãã
- ID = 0x08ä¿è·ãããã¹ããªãŒã ããŒïŒãã¹ã¯ãŒãã®è§£èªã«äœ¿çšãããŸãã
- ID = 0x09ã¹ããªãŒã éå§ãã€ãïŒåŸ©å·åãããããŒã¿ããŒã¹ã®æåã®32ãã€ãã ãããã¯ã埩å·åãããããŒã¿ã®æŽåæ§ãšãã¹ã¿ãŒããŒã®æ£ç¢ºæ§ãæ€èšŒããããã«äœ¿çšãããŸãã ãããã®32ãã€ãã¯ãå€æŽããã¡ã€ã«ã«ä¿åããããã³ã«ã©ã³ãã ã«çæãããŸãã
- ID = 0x0Aå
éšã©ã³ãã ã¹ããªãŒã IDïŒãã¹ã¯ãŒãã®è§£èªã«äœ¿çšãããã¢ã«ãŽãªãºã ã®IDïŒ
- 0x00ïŒãªã;
- 0x01ïŒARC4;
- 0x02ïŒãµã«ãµ20ã
- ID = 0x00ããããŒã®çµããïŒããŒã¿ããŒã¹ããããŒã®æåŸã®ãã£ãŒã«ãããã®åŸã«ããŒã¿ããŒã¹èªäœãå§ãŸããŸãã
ãã¹ã¿ãŒããŒçæ
ãã¹ã¿ãŒããŒã®çæã¯ã2段éã§è¡ãããŸãã
- è€åããŒã®çæã
- è€åããŒã«åºã¥ããŠãã¹ã¿ãŒããŒãçæããŸãã
1.è€åããŒã®çæ
è€åããŒã®çæã«ã¯ãSHA256ããã·ã¥ã¢ã«ãŽãªãºã ã䜿çšãããŸãã 以äžã®è¡šã¯ã䜿çšãããKeePassã®ããŒãžã§ã³ãšããŒã¿ããŒã¹ã®æå·å解é€ã«å¿
èŠãªå
¥åïŒãã¹ã¯ãŒãã®ã¿ããã¡ã€ã«ããŒã®ã¿ããŸãã¯ãã¹ãŠïŒã«åºã¥ããŠãè€åããŒãçæããããã®æ¬äŒŒã³ãŒããæäŸããŸãã
KeePass 1.x
ãã¹ã¯ãŒã | sha256ïŒãã¹ã¯ãŒãïŒ |
ããŒãã¡ã€ã« | sha256ïŒããŒãã¡ã€ã«ïŒ |
ãã¹ã¯ãŒã+ãã¡ã€ã«ã㌠| sha256ïŒconcatïŒsha256ïŒãã¹ã¯ãŒãïŒãsha256ïŒããŒãã¡ã€ã«ïŒïŒïŒ |
KeePass 2.x
ãã¹ã¯ãŒã | sha256ïŒsha256ïŒãã¹ã¯ãŒãïŒïŒ |
ããŒãã¡ã€ã« | sha256ïŒsha256ïŒããŒãã¡ã€ã«ïŒïŒ |
ãã¹ã¯ãŒã+ãã¡ã€ã«ã㌠| sha256ïŒconcatïŒsha256ïŒãã¹ã¯ãŒãïŒãsha256ïŒããŒãã¡ã€ã«ïŒïŒïŒ |
WindowsãŠãŒã¶ãŒã¢ã«ãŠã³ãïŒWUAïŒ | sha256ïŒsha256ïŒWUAïŒïŒ |
ãã¹ã¯ãŒã+ãã¡ã€ã«ããŒ+ïŒWUAïŒ | sha256ïŒconcatïŒsha256ïŒãã¹ã¯ãŒãïŒãsha256ïŒããŒãã¡ã€ã«ïŒãsha256ïŒWUAïŒïŒïŒ |
ããŒã¿ããŒã¹ã®æå·åã解é€ããããã«è€æ°ã®ãšã³ãã£ãã£ïŒãã¹ã¯ãŒãããã¡ã€ã«ããŒãªã©ïŒãå¿
èŠãªå Žåã¯ããŸãåãšã³ãã£ãã£ããããã·ã¥ãååŸãã次ã«ããããæ¥ç¶ïŒé£çµïŒããçµåãããã·ãŒã±ã³ã¹ããããã·ã¥ãååŸããå¿
èŠãããããšã«æ³šæããŠãã ããã
2.è€åããŒã«åºã¥ããŠãã¹ã¿ãŒããŒãçæãã
- AES-256-ECBã¢ã«ãŽãªãºã ã䜿çšããŠãäžèšã§ååŸããè€åããŒãæå·åããå¿
èŠããããŸãã
- ããŒãšããŠãããããŒããå€æã·ãŒãã䜿çšããå¿
èŠããããŸãã
- ãã®æå·åã¯ãå€æã©ãŠã³ãïŒããããŒããïŒåè¡ãå¿
èŠããããŸãã
- SHA256ã䜿çšããŠãæå·åãããè€åããŒããããã·ã¥ãååŸããŸãã
- ããããŒã®ãã¹ã¿ãŒã·ãŒããåä¿¡ããããã·ã¥ã«æ¥ç¶ããŸãã
- SHA256ã䜿çšããŠãçµåãããã·ãŒã±ã³ã¹ããããã·ã¥ãååŸããŸã- ããããã¹ã¿ãŒããŒã§ãïŒ
æ¬äŒŒã³ãŒã<p>void GenerateMasterKey() {
}
KeePass 1.xããŒã¿åŸ©å·å
ããããŒã®çŽåŸã«ãæå·åãããããŒã¿ããŒã¹èªäœãéå§ãããŸãã 埩å·åã¢ã«ãŽãªãºã ã¯æ¬¡ã®ãšããã§ãã
- AES-256-CBCã¢ã«ãŽãªãºã ã䜿çšããŠããã¡ã€ã«ã®æ®ãã解èªããŸãã
- ããŒãšããŠãäžèšã§çæããããã¹ã¿ãŒããŒã䜿çšããŸãã
- åæåãã¯ãã«ãšããŠãããããŒã®æå·åIVã䜿çšããŸãã
- 埩å·åãããããŒã¿ããŒã¹ã®æåŸã®æ°ãã€ãã¯åé·ã§ã-ãããã¯ãã¡ã€ã«ã®æåŸã®ããã€ãã®åäžã®ãã€ãã§ãïŒããã£ã³ã°ïŒã ãããã®åœ±é¿ãæé€ããã«ã¯ã埩å·åãããããŒã¿ããŒã¹ã®æåŸã®ãã€ããèªã¿åãå¿
èŠããããŸããããã¯ãå°æ¥èæ
®ã«å
¥ããªããäœåãªããã€ãæ°ã§ãã
- SHA256ã䜿çšããŠã埩å·åãããããŒã¿ããããã·ã¥ãååŸããŸãïŒ åã®æ®µèœã®ãã€ãã¯èæ
®ããŠããŸãã ïŒã
- åä¿¡ããããã·ã¥ãããããŒã®ã³ã³ãã³ãããã·ã¥ãã£ãŒã«ããšäžèŽããããšã確èªããŸãã
- ããã·ã¥ãäžèŽããã°ãããŒã¿ããŒã¹ã®åŸ©å·åã«æåããŸããïŒ åŸ©å·åãããããŒã¿ã.xmlãã¡ã€ã«ãšããŠä¿åãããã¹ã¯ãŒãã䜿çšãããã¹ãŠã®ãã°ã€ã³ãæ£ãã埩å·åãããŠããããšã確èªã§ããŸãã
- ããã·ã¥ãäžèŽããªãå Žåãééã£ããã¹ã¯ãŒããŸãã¯ããŒãã¡ã€ã«ãæäŸãããããããŒã¿ãç Žæããããšãæå³ããŸãã
æ¬äŒŒã³ãŒã <p>bool DecryptKeePass1x() {
}
ããŒã¿ã®åŸ©å·åKeePass 2.x
ããããŒã®ããããŒã®çµãããã£ãŒã«ãã®çŽåŸã«ãæå·åãããããŒã¿ããŒã¹èªäœãéå§ãããŸãã 埩å·åã¢ã«ãŽãªãºã ã¯æ¬¡ã®ãšããã§ãã
- AES-256-CBCã¢ã«ãŽãªãºã ã䜿çšããŠããã¡ã€ã«ã®æ®ãã解èªããŸãã
- ããŒãšããŠãäžèšã§çæããããã¹ã¿ãŒããŒã䜿çšããŸãã
- åæåãã¯ãã«ãšããŠãããããŒã®æå·åIVã䜿çšããŸãã
- 埩å·åãããããŒã¿ããŒã¹ã®æåŸã®æ°ãã€ãã¯åé·ã§ã-ãããã¯ãã¡ã€ã«ã®æåŸã®ããã€ãã®åäžã®ãã€ãã§ãïŒããã£ã³ã°ïŒã ãããã®åœ±é¿ãæé€ããã«ã¯ã埩å·åãããããŒã¿ããŒã¹ã®æåŸã®ãã€ããèªã¿åãå¿
èŠããããŸããããã¯ãå°æ¥èæ
®ã«å
¥ããªããäœåãªããã€ãæ°ã§ãã
- 埩å·åãããããŒã¿ããŒã¹ã®æåã®32ãã€ããããããŒã®Stream Start Bytesãã£ãŒã«ããšäžèŽããããšã確èªããŸãã
- ããŒã¿ãäžèŽããå Žåãæ£ãããã¹ã¿ãŒããŒãçæãã
- ããŒã¿ãäžèŽããªãå Žåã¯ãééã£ããã¹ã¯ãŒããæäŸãããããããŒãã¡ã€ã«ãŸãã¯WUAããããŒã¿ãç Žæããããšãæå³ããŸãã
- åã®é
ç®ãæåããå Žåãæåã®32ãã€ããç Žæ£ããŸãã ããããŒã®å§çž®ãã©ã°ãã£ãŒã«ãã確èªããŸãã GZipãã¡ã€ã«å§çž®ã䜿çšãããå ŽåãããŒã¿ã解åããŸãã
- ããŒã¿ã®æŽåæ§ãæ€èšŒããŸãã ããŒã¿ã¯ãããã¯ã«åå²ãããæ倧ãããã¯ãµã€ãºã¯1024 * 1024ã§ãã åããŒã¿ãããã¯ã¯ããããŒã§å§ãŸããŸãã ããããŒæ§é ã¯æ¬¡ã®ãšããã§ãã
- ãããã¯IDïŒ4ãã€ãïŒïŒ0ããå§ãŸããããã¯çªå·ã
- ãããã¯ããŒã¿ããã·ã¥ïŒ32ãã€ãïŒ;
- ãããã¯ãµã€ãºïŒ4ãã€ãïŒã
- ãããã£ãŠãæé ã¯æ¬¡ã®ãšããã§ãã
- ãããã¯ããããŒãèªã¿åããŸãã
- ãããã¯ããŒã¿ãèªã¿åããŸãã
- SHA256ã䜿çšããŠããããã¯ããŒã¿ããããã·ã¥ãååŸããŸãã
- ããã·ã¥ãããããŒã®ããã·ã¥ãšäžèŽããããšã確èªããŠãã ããã
- åããŒã¿ãããã¯ã«å¯ŸããŠãåã®æ®µèœã®äžé£ã®ã¢ã¯ã·ã§ã³ãå®è¡ããŸãã ãã¹ãŠã®ãããã¯ã®ããŒã¿ãä¿åãããŠããå Žåããã¹ãŠã®ãããã¯ããããŒãåãåããçµæã®ã·ãŒã±ã³ã¹ã埩å·åãããããŒã¿ããŒã¹ã«ãªããŸãã
- 泚æ ïŒåŸ©å·åããã.kdbxãã¡ã€ã«ã§ãããã¹ã¯ãŒããæå·åã§ããŸãã
- 埩å·åããããããã¬ã¹ããŒã¿ã.xmlãã¡ã€ã«ãšããŠä¿åããŸãã
- ãã®äžã«ããValueããšããååããProtectedãå±æ§ããã®å±æ§ã®å€ãTrueããæã€ãã¹ãŠã®ããŒããèŠã€ãããããã®ããŒãã®å€ãååŸããŸãã ãããã¯äŸç¶ãšããŠæå·åããããã¹ã¯ãŒãã§ãã
- base64decodeã¢ã«ãŽãªãºã ã䜿çšããŠããã¹ãŠã®æå·åããããã¹ã¯ãŒãããã³ãŒãããŸãã
- ããããŒã®å
éšã©ã³ãã ã¹ããªãŒã IDãã£ãŒã«ãã§ããã¹ã¯ãŒãã®æå·åã«äœ¿çšãããã¢ã«ãŽãªãºã ã確èªããŸãã ç§ã®å ŽåãSalsa20ã§ããã
- Salsa20ã¢ã«ãŽãªãºã ã䜿çšããŠãç䌌ã©ã³ãã 64ãã€ãã·ãŒã±ã³ã¹ãçæããŸãã
- ããŒãšããŠãSHA256ã䜿çšããŠååŸããããããŒã®Protected Stream Keyãã£ãŒã«ãã®ããã·ã¥ã䜿çšããŸãã
- åæåãã¯ãã«ãšããŠãå®æ°ã®8ãã€ãã·ãŒã±ã³ã¹0xE830094B97205D2Aã䜿çšããŸãã
- éèŠïŒãã®64ãã€ãã·ãŒã±ã³ã¹ã䜿çšãããšããã³ãŒãããããã¹ã¯ãŒããæ¥ç¶ãããé ã«æ£ç¢ºã«64æåã埩å·åã§ããŸã ã ããã§ãã¹ãŠã®ãã¹ã¯ãŒãã埩å·åããã«ã¯äžååãªå Žåã¯ã次ã®æ¬äŒŒã©ã³ãã ã·ãŒã±ã³ã¹ãçæãããã¹ã¯ãŒããªã©ã®åŸ©å·åãç¶è¡ããå¿
èŠããããŸãã æåŸãŸã§ã
- æçµçãªãã¹ã¯ãŒããååŸããã«ã¯ãåã®æ®µèœã§ååŸããæ¬äŒŒã©ã³ãã ã·ãŒã±ã³ã¹ã§base64decodeã䜿çšããŠXORãã¹ã¯ãŒãããã³ãŒãããå¿
èŠããããŸãïŒã¢ã¯ã·ã§ã³ã®ã·ãŒã±ã³ã¹ã¯ã以äžã®æ¬äŒŒã³ãŒãã§ããæ確ã«æ瀺ãããŸãïŒã
- éåžžã«éèŠ ïŒãã¹ã¯ãŒãã¯é çªã«åŸ©å·åããå¿
èŠããããŸãïŒ ããããxmlãã¡ã€ã«ã«è¡šç€ºãããã®ã¯ãã®é åºã§ãã
- xmlãã¡ã€ã«ã«ã¯ããValueããšããååãå±æ§ãProtectedãããã®å±æ§ãTrueãã®å€ãæã€ãã¹ãŠã®ããŒãããããŸãã
- å±æ§å€ããFalseãã«çœ®ãæããŸãã
- ããŒãã®å€ã¯ã埩å·åããããã¹ã¯ãŒãã«çœ®ãæããããŸãã
- ãããŠãããããå®å
šã«åŸ©å·åãããKeePass 2.xããŒã¿ããŒã¹ãæã«å
¥ããŸããïŒ ãã£ããŒïŒ
æ¬äŒŒã³ãŒã <p>bool DecryptKeePass2x() {
}
åºæ¬çã«ç§ãäŒãããã£ãããšã¯ããã ãã§ãã ãã®ã¬ã€ãã誰ããäžå¿
èŠãªé çããæããæçã§æçãªãã®ã«ãªãããšãé¡ã£ãŠããŸã=ïŒ