Nmap Development mailing list archives
Re: [NSE + NSELib] Netbios and SMB [stable!]
From: Ron <ron () skullsecurity net>
Date: Sun, 05 Oct 2008 20:34:16 -0500
Ron wrote:
Sven Klemm wrote:
Hey Sven,
I got the MD4() stuff working, and it's working well. But I'm having a
problem with the DES(), and it's probably my own fault for not knowing
OpenSSL well enough. I'm trying to encrypt the string "KGS!@#$%" using
the key "part1" (which is a 7-character string). But it's returning
'nil'. Am I doing this wrong, and/or is there a way to tell what I'm
doing incorrectly?
The 7-character string should have the parity bits set and become a
8-character key, which is used to encrypt the constant string. That's
how I understand it to work, anyways.
Here's the relevant code:
return openssl.encrypt("DES-ECB", part1, nil, "KGS!@#$%", false)
Thanks!
Ron
So, I got to the point where it'll return me an encrypted string, that
was my own fault (wasn't returning the right variable). But I still
can't get it to encrypt the string the way I want it. Again, this is
likely due to a lack of my own understanding.
This is how I do it in C:
-----------------------
static void password_to_key(const uint8_t password[7], uint8_t key[8])
{
/* make room for parity bits */
key[0] = (password[0] >> 0);
key[1] = ((password[0]) << 7) | (password[1] >> 1);
key[2] = ((password[1]) << 6) | (password[2] >> 2);
key[3] = ((password[2]) << 5) | (password[3] >> 3);
key[5] = ((password[3]) << 4) | (password[4] >> 4);
key[5] = ((password[4]) << 3) | (password[5] >> 5);
key[6] = ((password[5]) << 2) | (password[6] >> 6);
key[7] = ((password[6]) << 1);
}
static void des(const uint8_t password[7], const uint8_t data[8],
uint8_t result[])
{
DES_cblock key;
DES_key_schedule schedule;
password_to_key(password, key);
DES_set_odd_parity(&key);
DES_set_key_unchecked(&key, &schedule);
DES_ecb_encrypt((DES_cblock*)data, (DES_cblock*)result, &schedule,
DES_ENCRYPT);
}
-----------------------
Anybody know how I can replicate that in OpenSSL, using the
EVP_CIPHER-style functions?
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
Current thread:
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 04)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 05)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Sven Klemm (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] David Fifield (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Sven Klemm (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] David Fifield (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Sven Klemm (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 07)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Sven Klemm (Oct 06)
- Re: [NSE + NSELib] Netbios and SMB [stable!] Ron (Oct 05)
