Como posso consertar um arquivo PGP corrompido?

Como posso consertar um arquivo PGP corrompido?

Criptografei um arquivo com PGP, mas por "razões de segurança" pensei que seria bom danificar o cabeçalho e adicionar alguns bytes extras para que, mesmo que alguém o encontre, não tenha certeza de que é um arquivo PGP como a descriptografia a verificação falharia.

O problema é que agora não consigo lembrar quais bytes extras adicionei. Existe alguma maneira de "forçar" a descriptografia ou higienizar o arquivo/remover os bytes extras?

Atualizar:

Usei o script fornecido por Jens para remover os bytes até receber uma solicitação de senha. Infelizmente, as senhas que lembro não parecem funcionar. Além disso, se eu continuar removendo bytes após o primeiro prompt, ainda recebo a solicitação de senha de vez em quando, então estou me perguntando se o método é realmente eficaz. Veja o registro abaixo

./a.bh
Trying bytes: 1
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 2
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 3
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 4
gpg: [don't know]: indeterminate length for invalid packet type 4
Trying bytes: 5
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 6
gpg: packet(6) with unknown version 125
Trying bytes: 7

........................
Trying bytes: 21
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 22
gpg: [don't know]: indeterminate length for invalid packet type 6
...........................
Trying bytes: 24
:literal data packet:
    mode ? (4), created 2823998230, name="U\x07\x82Swo\xe6\xd9\x82\xd9[C\x16\xba\xeb\xa50r\xcd#\x03\xbd>\xec*l>\xbd\xb2\xcb\x0b\x01\xa6g0\xfeQU\xa6\xc0\x87\xdbk9\xf9o\x88\x8dr\xec\xfe\xeb\xb38\x93W\xeb\xcb\xd3\xc4\x80\xf1\xda\x9b(\x8d\xa1\xbb\xf6\xf6\x9a\xd0:v\x81\xe5rF\xe09N\xda\xf3\x90\xcd\xf0.\xb0\xabf<\x96\xf2\x8d\xbd\x8b\x95\x99\x89:q[)\x0c\xf5X\xbd2\x083\xc1\x97\xb7\xee\x84S\xf2\xcfi\xf1\xa2\x93\x15\xe9kI\xaa\x9d*;\x06\x0e\x9c\x04\x13\x87\x88u\xe7]U]\xbc\xb2\x92\x91\x02;9p\x95\x081\xe9v\xa5\xc3\x7e+#Z\xb9\xb8Ka\x18\x96\x82K\xaf6\xb0f\xb8\x8d0\x17\xe2D\xc3&\xe5\xd9\x94\xad\x05,L\xb7\xcc\xfb\x7c",
    raw data: 35666 bytes
gpg: invalid marker packet
Trying bytes: 25
gpg: unknown S2K 85
gpg: invalid symkey encrypted packet
gpg: [don't know]: invalid packet (ctb=3e)
Trying bytes: 26
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 27
..................
Trying bytes: 43
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 44
--- on this line I get the password for the prompt and I simply press enter
:encrypted data packet:
    length: 12402
gpg: assuming IDEA encrypted data
gpg: packet(3) with unknown version 94
gpg: WARNING: message was not integrity protected
gpg: [don't know]: invalid packet (ctb=22)
Trying bytes: 45
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
Trying bytes: 46
.........................
Trying bytes: 58
:literal data packet:
    mode ? (1), created 2797635547, name="g0\xfeQU\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
    raw data: 0 bytes
gpg: [don't know]: invalid packet (ctb=6b)
.......... 
//I get the password prompt again on this line
Trying bytes: 61
:encrypted data packet:
    length: 1731264081
gpg: assuming IDEA encrypted data
Enter passphrase: 
:encrypted data packet:
    length: 1731264081
gpg: assuming IDEA encrypted data
gpg: encrypted_mdc packet with unknown version 235
gpg: WARNING: message was not integrity protected
:trust packet: flag=75 sigcache=00
gpg: [don't know]: invalid packet (ctb=21)
.....................
Trying bytes: 66
gpg: no valid OpenPGP data found.
gpg: processing message failed: eof
//here I get the password prompt again
Trying bytes: 67
:encrypted data packet:
    length: 3230129003
gpg: assuming IDEA encrypted data
gpg: encrypted_mdc packet with unknown version 180
gpg: WARNING: message was not integrity protected
gpg: packet(2) with unknown version 59

Devo mencionar que o arquivo (que na verdade é um diretório) foi criptografado usando PGP (agora proprietário da Symantec)

Responder1

Como você prefixou apenas algum lixo, tente removê-lo novamente. Usando o bash, você pode tentar facilmente todos os números possíveis de bytes:

for i in {1..10}; do echo "Trying bytes: ${i}"; tail -c "+${i}" garbled.pgp | gpg --list-packets; done

Isso tentará listar o conteúdo do arquivo, cortando mais um byte a cada tentativa. Depois de cortar o número certo de bytes, ele pedirá a senha, caso contrário, continue cortando mais um byte. Ajuste o número máximo de bytes para tentar (aqui: 10) adequadamente. Um número grande não fará mal, pois você pode interromper assim que encontrar o número certo de bytes usando ctrl+ c.

Depois de encontrar o número certo de bytes para cortar, execute (para 42 bytes)

tail -c +42 garbled.pgp > fixed.pgp

Agora, descriptografe fixed.pgpda maneira usual.

informação relacionada