-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Avi wrote:
> Hi Dillon,
>
> I'm new around here and new to the cryptography world.
>
> I'm using VC++ 6.0 SP5 on a WinXP SP2 machine (I have a legacy code
> base that I'd like to secure).
>
> I tried to follow your (and originally Hugo's) example, but I'm having
> the same runtime error in both cases.
> I'm posting my problem here instead of in Hugo's thread in order to
> narrow the differences between our executables (since you embedded
> your keys into the source code).
>
> The code crashes in oaep.cpp, line 91: memcpy(output, M, maskedDB
> +dbLen-M);
> The 'output' value is 0 (NULL).
>
>
> I attached the call stack below.
> Any ideas?
>
> Avi.
>
> --
> CryptoPP::OAEP_Base::Unpad(const unsigned char * 0x0032b7f1, unsigned
> int 255, unsigned char * 0x00000000, const CryptoPP::NameValuePairs &
> {...}) line 91 + 20 bytes
> CryptoPP::TF_DecryptorBase::Decrypt(CryptoPP::RandomNumberGenerator &
> {...}, const unsigned char * 0x0032bbd8, unsigned int 257, unsigned
> char * 0x00000000, const CryptoPP::NameValuePairs & {...}) line 142 +
> 59 bytes
> CryptoPP::PK_DefaultDecryptionFilter::Put2(const unsigned char *
> 0x00000000, unsigned int 0, int -1, unsigned char 1) line 626 + 75
> bytes
> CryptoPP::BufferedTransformation::MessageEnd(int -1, unsigned char 1)
> line 763 + 78 bytes
> CryptoPP::SimpleProxyFilter::LastPut(const unsigned char * 0x00000000,
> const unsigned char * 0x00000000) line 513 + 51 bytes
> CryptoPP::FilterWithBufferedInput::PutMaybeModifiable(unsigned char *
> 0x00326d68, unsigned int 0, int -2, unsigned char 1, unsigned char 0)
> line 410
> CryptoPP::FilterWithBufferedInput::Put2(const unsigned char *
> 0x00326d68, unsigned int 0, int -2, unsigned char 1) line 156
> CryptoPP::Filter::Output(int 2, const unsigned char * 0x00326d68,
> unsigned int 0, int -2, unsigned char 1, const
> std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
> {0x00000000 ""}) line 115 + 44 bytes
> CryptoPP::BaseN_Decoder::Put2(const unsigned char * 0x00000000,
> unsigned int 0, int -1, unsigned char 1) line 163 + 42 bytes
> CryptoPP::BufferedTransformation::ChannelPut2(const
> std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
> {0x00000000 ""}, const unsigned char * 0x00000000, unsigned int 0, int
> -1, unsigned char 1) line 250 + 27 bytes
> CryptoPP::BufferedTransformation::ChannelMessageEnd(const
> std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
> {0x00000000 ""}, int -1, unsigned char 1) line 938 + 63 bytes
> CryptoPP::BufferedTransformation::TransferMessagesTo2
> (CryptoPP::BufferedTransformation & {...}, unsigned int & 0, const
> std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
> {0x00000000 ""}, unsigned char 1) line 407 + 28 bytes
> CryptoPP::BufferedTransformation::TransferAllTo2
> (CryptoPP::BufferedTransformation & {...}, const
> std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
> {0x00000000 ""}, unsigned char 1) line 448 + 24 bytes
> CryptoPP::SourceTemplate<CryptoPP::StringStore>::PumpAll2(unsigned
> char 1) line 718 + 73 bytes
> CryptoPP::Source::PumpAll() line 689 + 47 bytes
> CryptoPP::Source::SourceInitialize(unsigned char 1, const
> CryptoPP::NameValuePairs & {...}) line 701
> CryptoPP::StringSource::StringSource(const char * 0x0012fbd8, unsigned
> char 1, CryptoPP::BufferedTransformation * 0x00326b10) line 737 + 173
> bytes
> stubClass::AES_CTR_Decrypt(const char * 0x0012ff48, const char *
> 0x0012ff30) line 128 + 364 bytes
> main() line 92
> --
>
> On Jan 23, 4:34 am, Dillon Beresford <[email protected]>
> wrote:
>> Hugo shared a class he coded up earlier this month which he gave to
the group and while searching for information regarding an idea I came
up with about self decrypting stubs using Crypto++, which I needed for
my own project I found his thread. I was actually able to code up a
little function which I added to the class to load keys using
>> CryptoPP::ArraySource as opposed to LoadFile. For my project I needed
to be able to generate stubs on the fly which would handle all of the
decryption. I'm also currently writing up some code that will actually
add two extra layers of protection to both keys inside the executable to
avoid reverse code engineering from dumping keys in memory We simply
store our keys in the stub.
>>
>> If we add stub + *.enc file to SFX we can have our stub do all the
work for us. :)
>>
>> I would suggest to anyone storing keys inside a binary to compress the
executable using something other than UPX or ASPack. ;-) keys get gen
all the time so it's best to use something with tons of instructions for
anti-debugging, strip TLS, exports, and CRC protection and aPlib for
compression.
>>
>> Dillon's code reading from CryptoPP::ArraySource as opposed to
CryptoPP::FileSource
>>
>> void stubClass::LoadKey(const char *bufferPub, const char *bufferPri) {
>>
>> CryptoPP::ArraySource(bufferPub, true,
>>
>> new CryptoPP::StringSink(pubString));
>>
>> CryptoPP::ArraySource(bufferPri, true,
>>
>> new CryptoPP::StringSink(priString));
>>
>> }
>>
>> Hugo's class using CryptoPP::FileSource
>> /*
>>
>> void stubClass::LoadKey(const char *pubFilename, const char
*privFilename) {
>>
>> CryptoPP::FileSource (pubFilename, true,
>>
>> new CryptoPP::StringSink(pubString));
>>
>> CryptoPP::FileSource (privFilename, true,
>>
>> new CryptoPP::StringSink(priString));
>>
>> }
>>
>> */
>>
>> We can store our keys in bufferPub and bufferPri and call this from
the main() in our stub.
>>
>> const char bufferPri[]="308..."
>> const char bufferPub[]="308..."
>>
>> int main() {
>> char EFile[]="dob.enc";
>> char DFile[]="dec.exe";
>>
>> stubClass stubDecrypt;
>> // grab our keys from memory.
>> stubDecrypt.LoadKey(bufferPub,bufferPri);
>> // decrypt our file
>> stubDecrypt.AES_CTR_Decrypt(EFile, DFile);
>>
>> return 0;
>>
>> }
>>
>> thanks Hugo!
>>
>> linked back to the original thread where Hugo posted his class.
>>
>> http://groups.google.com/group/cryptopp-users/browse_thread/thread/48...
>>
>> regards,
>>
>> Dillon Beresford
>>
>> stub.cpp
>> 4KViewDownload
>>
>> stubClass.cpp
>> 3KViewDownload
>>
>> stubClass.h
>> < 1KViewDownload
> >
>
Avi - It looks like it's the first argument in memcpy(), if it's
output is NULL then you get the error. Are you planning on decrypting
from a stub or just need the decryption and encryption to read from
key files? If you take a look at the svn Hugo and I maintain for our
project you might get a better working example of how the Class is
implemented. You can download the project here and use dobclass.http://code.google.com/p/komodopgmp/source/browse/trunk/windows/dev/dobrexor/dobclass.cpp http://code.google.com/p/komodopgmp/source/browse/trunk/windows/dev/dobrexor/dobclass.h Download the entire project if you like. It's the full implementation of the class you want. http://komodopgmp.googlecode.com/files/dobrexor-beta-build-win-current.zip // file.read(Key,512); <-- Let me know how your LoadKeys is working. Are you planning on securing this legacy code from one application or working with a self decrypting archive? Regards, Dillon Beresford Komodo PGMP project http://code.google.com/p/komodopgmp/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJhZRxRnxC5lZRuuERAlINAJ4hI7MhGmvGCspsxel5GlOoT6q0zQCfeQNy NKh/cQvBrsw5cQiiezMNK/E= =cL0O -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. -~----------~----~----~----~------~----~------~--~---
pgpkeys.asc
Description: application/pgp-keys
