简体   繁体   中英

decode sks (gpg) keyserver database format (Python)

i'm doing research on the topic of the web of trust, therefore i need as many pgp keys as possible. I downloaded a key dump of a SKS keyserver and import everything to my local SKS keyserver. The sks keyserver uses berkeley DB as a database. Unfortunateley the SKS keyserver is written in OCaml and i cant figure out how to extract all keys from the database. I opened the database and read all keys, but i looks like the keys are in a weird (i read somewhere its radix64. i tried different radix64 decoder -> they all failed) format. Does anybody know a (pythonic) way to extract all keys and import them to mysql/neo4j/whatever?

Here is an example entry:

\x00\x99\x02\r\x04R\xb6\xcag\x01\x10\x00\xcc/\xd9\xd0\x11\xaa~b\xcc\xb0L\xee\x0ed!*\x8f\xa6\xc82\x98\xe6\x92\xf1\xb9\\*\xc2\xbb\xb2\x1b7m*V6\xe9\x8aOI\xcc\x9d\xf0\xb7\xe0\xa8\x90\xf6\x1aN6\xec0\x0f3\xf4=h\xe1_\xb2\xef=\xcb\xfe\xc6\xf2\x16\xac\xdb\xe3\x00\x05\xe8\x92S`Co\xc1\x88t\xaa\xabA\xcc\x1b\xd8\xeb\xf7\x86\x17F\xc7\xdd\xe25Y\xc4\x85\x92=p\x95C/\xf1>\xbe$Z\xbe\x81\xd1\xb4\xf3\xb4\x9d\x85\xc5\xc9\xbc\'s\x8bJw\x02\x1b[I\xcd\x1e\xc7\x1c\xc8\xebG\x8a\x9cx\xe18\x97l\xefC\xdaU\xc9\x86\xf5\x80!(\x89.\x1e\xe7\xa6csjDK\x08\xd5\xe2\x03\xd3.\xcc\xc2\xc1\xcb\x81@-\xf7r0=\x06\x17s\x13x`{\xea\x85w\xb0*\x9e\xf3{\x05\xbaj\xe3!\xf9f\xef\xc9\xb9v]\xf5\x8f\xf4\xd2\x99\xd4\xf6\x16\xc6\xc1n\xcd\xc1\xbc\xaa?\xbc\xbd\xcadd\x07\xdeF(\x8e}\x9f\x07b.\x0f\xa5\xab\xd7\x0c\xdbV\x93\xb4\x19ek\xd1\x10\x89\xa7\x98#\xad\xdf{\xa9\x8f\xc1bF\xa0\x11\xa8\xf7\xf6\x13La\xeb\xbb\xf8q\xa8\xae\x9b\xc5)\xdb2\xfa\x04\xc7\xb4\x8b\xfb \xd4k\xf0\x19X\'\xf6\xbd\xa4\xeb\x06\xb0\x91\xf2Z\xe9\xc9kD\xd7\x94#\x0f)\xfb\xa9\x90\xd3\x9a\x80b\x86`1\xfb\xa10\xae\xaa\x1e\x00.\xe8\xf3\xac]\x99w\nW\x97vC\x9f\x84\x85(\xe5\xc9\xef\x0e\x93\xfe\xe6\x07H9\x01\x17\xa9R3\x07\xef\xa7\xa2\xca\xbc\x9c\xddL\xe3\x15^}\x0f\xb6\t\xaa\x0fU\x97\rEZ&\xfb\xad\x13{%\xbf\x070O\x8f\xa4"\xb9\r\xfd\x05\xec/\xc0h\x9a\xbe\xe4w\x9b8\x86\xc2\x87\xfb\x1e\xee(mK\xdf=4EiC\xf4\xb0\x18\xbdZ\xaf\x8c;\xba\x8e\xb7\x19e\xe5*\xb6\xa5l\xa8\x95\xdd\x985\x81\xaaP\x0c~\x13\x1b\x90\x10\xc9\x1f\xd8Q\x01$\xb3\xe8t\x06\xbf\x81\x9e\x83k\xf8\xb7\x19\xfa\xd1u\x1c\x85\xf7\xa2\x87\x0ba\xc5\x1dz3K\\ \xd6\xabR[\xaf\xba\x92\xdc\x06 \x81EJ2\xbc\x89\x00\x11\x01\x00\x01\xb4*Laura Schmitz <laura.schmitz87@icloud.com>\x89\x02=\x04\x13\x01\n\x00\'\x05\x02R\xb6\xcag\x02\x1b\x03\x05\t\x07\x86\x1f\x80\x05\x0b\t\x08\x07\x03\x05\x15\n\t\x08\x0b\x05\x16\x02\x03\x01\x00\x02\x1e\x01\x02\x17\x80\x00\n\t\x10h\x1d:u;l$\x9e\xcb\x83\x0f\xfb\x06\xbe\x9c#7U\x12Y\x83k\x80@Z\xabT\xe8\xec\xfc;\x9f6\xeb\xad\xf7{\x9c\xcd\xd1\x81\x82\x81\xe9\x91\x0b\xdb3\xa8\x1cq\xe2r\x11\x11c3\x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1e\xc6\xc5$\xa2n\x99k\xffdp\xc9:\x84\xb5\xb4\xd89\xc7\xb3\xcc\x8f\x18\x0c!\r\x83\xc6\x1a:j\xa4\xa4R\xa6\xd0\x82r\xe22o\xcazGw\xf1\x90\x85\xe5[\x96\xe6\x19\xc5\xf1\x87V\x9b\x9a\t\xb4\x82\r\xa1\xcc\xee\xe4\x1eV\xfc\xd2\xa6q\xa4W8\xb1^W\xf0\xe1\xdf9\xf2\x9c \xb0y\xb2\x94\xba\xdcD\xd0\xf7a\xf2\x00[\xc9\xe6-\xfdR\x91\x08\x17\x02-\x1e\x7f<\x85\xef\xef\xf2@\x0f\xa5\x93v\xa1{)\xef\xf2\xb4c\xbd\xc4@\x92\xd8\xf5Z\xe53\xd2\xad\xb7\x99\xf9\xbcX,\x08\xcd\xec9\x04Lr\xbdo|\x1f \x1d\n\xc1\n\xa9\x08E\x1dV\x18pn\x9c\xaa\x13n|o\xe2/\xd2G:\xba-\xa6\x88\xd1\x02\t\xbc\xcd\xfa\x04\xb8h\xe4\xd6tjz\x9d\xd0\xf0M\xa8\x93e\x18\xcf\x16"#L\xca\xe6\xb8!\x80\x93\x80\x8c\x0c\x855\x11\x99GbY\xf4\xe8\xb1\x95\x9b\xcd\x13\x00\x1fO\x9f\x00\x11\x01\x00\x01\x89\x02%\x04\x18\x01\n\x00\x0f\x05\x02R\xb6\xcag\x02\x1b\x0c\x05\t\x07\x86\x1f\x80\x00\n\t\x10h\x1d:u;l$\x9eKQ\x10\x00\xab\x8e*\xb73\xe4\xa6J\x88\xfd\x02\xed\xf4\x06Q\x17I5\xc8z\xdbe\xe37u\xebfjH\xde\x88\xa9\x13\x95k\xb2\x8cF\xc8M\x9b\xa5\x1b\xba\xd9\xeeMrk \xb0rG\xb1\x16\x92%\xd9[S\x05\xa5\x14\xc8\x0c*\x84\x95#\x0c/\xad>w\x00\xf2\x84\xb9\x80\xd0%\x9b~J\x9bH\x94\x87#\xc3O\xc7\xb3\xa3\xc3{\x01\xff\x03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e6F\xbe\xc7\x8f\x1d\x97\n\x01\xa9\x06\xba\xd2\xf1=\x054:p\x10te\xd7\xb8}>\xb1\xdb\x077\xd7]\x0c\x05\xb5

I'm answering your original problem here, fetching the key set and working with it .

Does anybody know a (pythonic) way to extract all keys and import them to mysql/neo4j/whatever?

Consider using Hockeypuck instead of the SKS key server; a very recent implementation in the Go language, which can also sync with the wide spread SKS key server using the SKS protocol. But, as a big difference, the keys are stored in a relational database (namely PostgreSQL), making queries and ad-hoc analysis much easier.

No caring about transforming any data, just setup the key server and query it. You can even synchronize your working data set with the other key servers without hassles and expensive exports.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM