Content Type
Profiles
Forums
Events
Everything posted by allen2
-
Of course it will work for XP if you use the proper settings in the gpo (and in this case you don't need to add any line).
-
It seems you're miss-using the gpo. When your target is the computer and in this case it is or it will be as whatever the way you'll use to install the service it will be installed on the computer and for every user using that computer (even if you targeted only one user at first). Then you have two kind of scripts that might running from gpo: computer startup/shutdown scripts and user logon scripts. As you're deploying something related to the computer, you'll need to use the computer startup script (unless you prefer using shutdown script). With computer startup scrip, your script will run with the targeted computer system account (so it might not have access to some shares if you didn't set rights properly there). Then if you're targeting computer with UAC enabled, you'll need to add the line: set __COMPAT_LAYER=RunAsInvoker at the beginning of your batch script.
-
C Source code (found on the web not mine) for those who might need it. /* MD5 routines, after Ron Rivest */ /* Written by David Madore <david.madore@ens.fr>, with code taken in * part from Colin Plumb. */ /* Public domain (1999/11/24) */ /* Note: these routines do not depend on endianness. */ /* === The header === */ /* Put this in md5.h if you don't like having everything in one big * file. */ #ifndef _DMADORE_MD5_H #define _DMADORE_MD5_H struct md5_ctx { /* The four chaining variables */ unsigned long buf[4]; /* Count number of message bits */ unsigned long bits[2]; /* Data being fed in */ unsigned long in[16]; /* Our position within the 512 bits (always between 0 and 63) */ int b; }; void MD5_transform (unsigned long buf[4], const unsigned long in[16]); void MD5_start (struct md5_ctx *context); void MD5_feed (struct md5_ctx *context, unsigned char inb); void MD5_stop (struct md5_ctx *context, unsigned char digest[16]); #endif /* not defined _DMADORE_MD5_H */ /* === The implementation === */ #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) #define MD5STEP(f, w, x, y, z, data, s) \ { w += f (x, y, z) + data; w = w<<s | (w&0xffffffffUL)>>(32-s); \ w += x; } void MD5_transform (unsigned long buf[4], const unsigned long in[16]) { register unsigned long a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478UL, 7); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756UL, 12); MD5STEP(F1, c, d, a, b, in[2] + 0x242070dbUL, 17); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceeeUL, 22); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0fafUL, 7); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62aUL, 12); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613UL, 17); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501UL, 22); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8UL, 7); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7afUL, 12); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1UL, 17); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7beUL, 22); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122UL, 7); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193UL, 12); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438eUL, 17); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821UL, 22); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562UL, 5); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340UL, 9); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51UL, 14); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aaUL, 20); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105dUL, 5); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453UL, 9); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681UL, 14); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8UL, 20); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6UL, 5); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6UL, 9); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87UL, 14); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14edUL, 20); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905UL, 5); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8UL, 9); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9UL, 14); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8aUL, 20); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942UL, 4); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681UL, 11); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122UL, 16); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380cUL, 23); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44UL, 4); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9UL, 11); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60UL, 16); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70UL, 23); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6UL, 4); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127faUL, 11); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085UL, 16); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05UL, 23); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039UL, 4); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5UL, 11); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8UL, 16); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665UL, 23); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244UL, 6); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97UL, 10); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7UL, 15); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039UL, 21); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3UL, 6); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92UL, 10); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47dUL, 15); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1UL, 21); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4fUL, 6); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0UL, 10); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314UL, 15); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1UL, 21); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82UL, 6); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235UL, 10); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bbUL, 15); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391UL, 21); buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } #undef F1 #undef F2 #undef F3 #undef F4 #undef MD5STEP void MD5_start (struct md5_ctx *ctx) { int i; ctx->buf[0] = 0x67452301UL; ctx->buf[1] = 0xefcdab89UL; ctx->buf[2] = 0x98badcfeUL; ctx->buf[3] = 0x10325476UL; ctx->bits[0] = 0; ctx->bits[1] = 0; for ( i=0 ; i<16 ; i++ ) ctx->in[i] = 0; ctx->b = 0; } void MD5_feed (struct md5_ctx *ctx, unsigned char inb) { int i; unsigned long temp; ctx->in[ctx->b/4] |= ((unsigned long)inb) << ((ctx->b%4)*8); if ( ++ctx->b >= 64 ) { MD5_transform (ctx->buf, ctx->in); ctx->b = 0; for ( i=0 ; i<16 ; i++ ) ctx->in[i] = 0; } temp = ctx->bits[0]; ctx->bits[0] += 8; if ( (temp&0xffffffffUL) > (ctx->bits[0]&0xffffffffUL) ) ctx->bits[1]++; } void MD5_stop (struct md5_ctx *ctx, unsigned char digest[16]) { int i; unsigned long bits[2]; for ( i=0 ; i<2 ; i++ ) bits[i] = ctx->bits[i]; MD5_feed (ctx, 0x80); for ( ; ctx->b!=56 ; ) MD5_feed (ctx, 0); for ( i=0 ; i<2 ; i++ ) { MD5_feed (ctx, bits[i]&0xff); MD5_feed (ctx, (bits[i]>>8)&0xff); MD5_feed (ctx, (bits[i]>>16)&0xff); MD5_feed (ctx, (bits[i]>>24)&0xff); } for ( i=0 ; i<4 ; i++ ) { digest[4*i] = ctx->buf[i]&0xff; digest[4*i+1] = (ctx->buf[i]>>8)&0xff; digest[4*i+2] = (ctx->buf[i]>>16)&0xff; digest[4*i+3] = (ctx->buf[i]>>24)&0xff; } } /* === The main program === */ #include <stdio.h> int main (int argc, const char *argv[]) { int i, j; struct md5_ctx context; unsigned char digest[16]; FILE *f; const char *bogus_argv[] = { "zoinx", "-" }; const char hexdigits[17] = "0123456789abcdef"; if ( argc == 1 ) { argc = 2; argv = bogus_argv; } for ( i=1 ; i<argc ; i++ ) { if ( argv[i][0] == '-' && argv[i][1] == 0 ) f = stdin; else { f = fopen (argv[i], "rb"); if ( ! f ) { fprintf (stderr, "Error opening %s\n", argv[i]); continue; } } MD5_start (&context); while ( 1 ) { int ch; ch = getc (f); if ( ch == EOF ) break; MD5_feed (&context, ch); } MD5_stop (&context, digest); for ( j=0 ; j<16 ; j++ ) { putchar (hexdigits[digest[j]>>4]); putchar (hexdigits[digest[j]&0xf]); } printf (" %s\n", argv[i]); } return 0; } Compiled striped and upxed will give that nice 7k .exe. md5sum.7z
-
I finally fixed the problem for handling binary files (but it is still d4mn slow 2min for 500kB on an i7-3770T !!) : Private Const BITS_TO_A_BYTE = 8 Private Const BYTES_TO_A_WORD = 4 Private Const BITS_TO_A_WORD = 32 Private m_lOnBits(30) Private m_l2Power(30) m_lOnBits(0) = CLng(1) m_lOnBits(1) = CLng(3) m_lOnBits(2) = CLng(7) m_lOnBits(3) = CLng(15) m_lOnBits(4) = CLng(31) m_lOnBits(5) = CLng(63) m_lOnBits(6) = CLng(127) m_lOnBits(7) = CLng(255) m_lOnBits(8) = CLng(511) m_lOnBits(9) = CLng(1023) m_lOnBits(10) = CLng(2047) m_lOnBits(11) = CLng(4095) m_lOnBits(12) = CLng(8191) m_lOnBits(13) = CLng(16383) m_lOnBits(14) = CLng(32767) m_lOnBits(15) = CLng(65535) m_lOnBits(16) = CLng(131071) m_lOnBits(17) = CLng(262143) m_lOnBits(18) = CLng(524287) m_lOnBits(19) = CLng(1048575) m_lOnBits(20) = CLng(2097151) m_lOnBits(21) = CLng(4194303) m_lOnBits(22) = CLng(8388607) m_lOnBits(23) = CLng(16777215) m_lOnBits(24) = CLng(33554431) m_lOnBits(25) = CLng(67108863) m_lOnBits(26) = CLng(134217727) m_lOnBits(27) = CLng(268435455) m_lOnBits(28) = CLng(536870911) m_lOnBits(29) = CLng(1073741823) m_lOnBits(30) = CLng(2147483647) m_l2Power(0) = CLng(1) m_l2Power(1) = CLng(2) m_l2Power(2) = CLng(4) m_l2Power(3) = CLng(8) m_l2Power(4) = CLng(16) m_l2Power(5) = CLng(32) m_l2Power(6) = CLng(64) m_l2Power(7) = CLng(128) m_l2Power(8) = CLng(256) m_l2Power(9) = CLng(512) m_l2Power(10) = CLng(1024) m_l2Power(11) = CLng(2048) m_l2Power(12) = CLng(4096) m_l2Power(13) = CLng(8192) m_l2Power(14) = CLng(16384) m_l2Power(15) = CLng(32768) m_l2Power(16) = CLng(65536) m_l2Power(17) = CLng(131072) m_l2Power(18) = CLng(262144) m_l2Power(19) = CLng(524288) m_l2Power(20) = CLng(1048576) m_l2Power(21) = CLng(2097152) m_l2Power(22) = CLng(4194304) m_l2Power(23) = CLng(8388608) m_l2Power(24) = CLng(16777216) m_l2Power(25) = CLng(33554432) m_l2Power(26) = CLng(67108864) m_l2Power(27) = CLng(134217728) m_l2Power(28) = CLng(268435456) m_l2Power(29) = CLng(536870912) m_l2Power(30) = CLng(1073741824) Private Function LShift(lValue, iShiftBits) If iShiftBits = 0 Then LShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And 1 Then LShift = &H80000000 Else LShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If If (lValue And m_l2Power(31 - iShiftBits)) Then LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000 Else LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits)) End If End Function Private Function RShift(lValue, iShiftBits) If iShiftBits = 0 Then RShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And &H80000000 Then RShift = 1 Else RShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits) If (lValue And &H80000000) Then RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits - 1))) End If End Function Private Function RotateLeft(lValue, iShiftBits) RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits)) End Function Private Function AddUnsigned(lX, lY) Dim lX4 Dim lY4 Dim lX8 Dim lY8 Dim lResult lX8 = lX And &H80000000 lY8 = lY And &H80000000 lX4 = lX And &H40000000 lY4 = lY And &H40000000 lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF) If lX4 And lY4 Then lResult = lResult Xor &H80000000 Xor lX8 Xor lY8 ElseIf lX4 Or lY4 Then If lResult And &H40000000 Then lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8 Else lResult = lResult Xor &H40000000 Xor lX8 Xor lY8 End If Else lResult = lResult Xor lX8 Xor lY8 End If AddUnsigned = lResult End Function Private Function F(x, y, z) F = (x And y) Or ((Not x) And z) End Function Private Function G(x, y, z) G = (x And z) Or (y And (Not z)) End Function Private Function H(x, y, z) H = (x Xor y Xor z) End Function Private Function I(x, y, z) I = (y Xor (x Or (Not z))) End Function Private Sub FF(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Sub GG(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Sub HH(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Sub II(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Function ConvertToWordArray(sMessage) Dim lMessageLength Dim lNumberOfWords Dim lWordArray() Dim lBytePosition Dim lByteCount Dim lWordCount Const MODULUS_BITS = 512 Const CONGRUENT_BITS = 448 lMessageLength = Len(sMessage) lNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD) ReDim lWordArray(lNumberOfWords - 1) lBytePosition = 0 lByteCount = 0 Do Until lByteCount >= lMessageLength lWordCount = lByteCount \ BYTES_TO_A_WORD lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition) lByteCount = lByteCount + 1 Loop lWordCount = lByteCount \ BYTES_TO_A_WORD lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition) lWordArray(lNumberOfWords - 2) = LShift(lMessageLength, 3) lWordArray(lNumberOfWords - 1) = RShift(lMessageLength, 29) ConvertToWordArray = lWordArray End Function Private Function WordToHex(lValue) Dim lByte Dim lCount For lCount = 0 To 3 lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE - 1) WordToHex = WordToHex & Right("0" & Hex(lByte), 2) Next End Function Public Function MD5(sMessage) Dim x Dim k Dim AA Dim BB Dim CC Dim DD Dim a Dim b Dim c Dim d Const S11 = 7 Const S12 = 12 Const S13 = 17 Const S14 = 22 Const S21 = 5 Const S22 = 9 Const S23 = 14 Const S24 = 20 Const S31 = 4 Const S32 = 11 Const S33 = 16 Const S34 = 23 Const S41 = 6 Const S42 = 10 Const S43 = 15 Const S44 = 21 x = ConvertToWordArray(sMessage) a = &H67452301 b = &HEFCDAB89 c = &H98BADCFE d = &H10325476 For k = 0 To UBound(x) Step 16 AA = a BB = b CC = c DD = d FF a, b, c, d, x(k + 0), S11, &HD76AA478 FF d, a, b, c, x(k + 1), S12, &HE8C7B756 FF c, d, a, b, x(k + 2), S13, &H242070DB FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE FF a, b, c, d, x(k + 4), S11, &HF57C0FAF FF d, a, b, c, x(k + 5), S12, &H4787C62A FF c, d, a, b, x(k + 6), S13, &HA8304613 FF b, c, d, a, x(k + 7), S14, &HFD469501 FF a, b, c, d, x(k + 8), S11, &H698098D8 FF d, a, b, c, x(k + 9), S12, &H8B44F7AF FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1 FF b, c, d, a, x(k + 11), S14, &H895CD7BE FF a, b, c, d, x(k + 12), S11, &H6B901122 FF d, a, b, c, x(k + 13), S12, &HFD987193 FF c, d, a, b, x(k + 14), S13, &HA679438E FF b, c, d, a, x(k + 15), S14, &H49B40821 GG a, b, c, d, x(k + 1), S21, &HF61E2562 GG d, a, b, c, x(k + 6), S22, &HC040B340 GG c, d, a, b, x(k + 11), S23, &H265E5A51 GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA GG a, b, c, d, x(k + 5), S21, &HD62F105D GG d, a, b, c, x(k + 10), S22, &H2441453 GG c, d, a, b, x(k + 15), S23, &HD8A1E681 GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8 GG a, b, c, d, x(k + 9), S21, &H21E1CDE6 GG d, a, b, c, x(k + 14), S22, &HC33707D6 GG c, d, a, b, x(k + 3), S23, &HF4D50D87 GG b, c, d, a, x(k + 8), S24, &H455A14ED GG a, b, c, d, x(k + 13), S21, &HA9E3E905 GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8 GG c, d, a, b, x(k + 7), S23, &H676F02D9 GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A HH a, b, c, d, x(k + 5), S31, &HFFFA3942 HH d, a, b, c, x(k + 8), S32, &H8771F681 HH c, d, a, b, x(k + 11), S33, &H6D9D6122 HH b, c, d, a, x(k + 14), S34, &HFDE5380C HH a, b, c, d, x(k + 1), S31, &HA4BEEA44 HH d, a, b, c, x(k + 4), S32, &H4BDECFA9 HH c, d, a, b, x(k + 7), S33, &HF6BB4B60 HH b, c, d, a, x(k + 10), S34, &HBEBFBC70 HH a, b, c, d, x(k + 13), S31, &H289B7EC6 HH d, a, b, c, x(k + 0), S32, &HEAA127FA HH c, d, a, b, x(k + 3), S33, &HD4EF3085 HH b, c, d, a, x(k + 6), S34, &H4881D05 HH a, b, c, d, x(k + 9), S31, &HD9D4D039 HH d, a, b, c, x(k + 12), S32, &HE6DB99E5 HH c, d, a, b, x(k + 15), S33, &H1FA27CF8 HH b, c, d, a, x(k + 2), S34, &HC4AC5665 II a, b, c, d, x(k + 0), S41, &HF4292244 II d, a, b, c, x(k + 7), S42, &H432AFF97 II c, d, a, b, x(k + 14), S43, &HAB9423A7 II b, c, d, a, x(k + 5), S44, &HFC93A039 II a, b, c, d, x(k + 12), S41, &H655B59C3 II d, a, b, c, x(k + 3), S42, &H8F0CCC92 II c, d, a, b, x(k + 10), S43, &HFFEFF47D II b, c, d, a, x(k + 1), S44, &H85845DD1 II a, b, c, d, x(k + 8), S41, &H6FA87E4F II d, a, b, c, x(k + 15), S42, &HFE2CE6E0 II c, d, a, b, x(k + 6), S43, &HA3014314 II b, c, d, a, x(k + 13), S44, &H4E0811A1 II a, b, c, d, x(k + 4), S41, &HF7537E82 II d, a, b, c, x(k + 11), S42, &HBD3AF235 II c, d, a, b, x(k + 2), S43, &H2AD7D2BB II b, c, d, a, x(k + 9), S44, &HEB86D391 a = AddUnsigned(a, AA) b = AddUnsigned(b, BB) c = AddUnsigned(c, CC) d = AddUnsigned(d, DD) Next MD5 = LCase(WordToHex(a) & WordToHex(B) & WordToHex(c) & WordToHex(d)) End Function if WScript.Arguments.Count = 0 then WScript.Echo "Missing parameters" else dim inStream const adTypeText=2 const adTypeBinary=1 set inStream=WScript.CreateObject("ADODB.Stream") inStream.Open inStream.type=adTypeBinary inStream.LoadFromFile(Wscript.Arguments.Item(0)) dim bytecounter bytecounter=0 do until bytecounter > inStream.Size - 1 s=inStream.Read(1) bytecounter=bytecounter+1 buf=buf & chr(ascb(s)) loop MyMD5=MD5(buf) instream.close() wscript.echo Wscript.Arguments.Item(0) & " " & MyMD5 end if I had a hard time to fix it because i thought i didn't need to modify the read buffer before calculating it but vbs doesn't handle it like in C or C++ (in fact vbs is so limited and slow that i don't even understand why people would use it). If you want to use vbs to handle md5 of many files or big files, you should just extract/create the binary of md5 checker with the vbs as explained there or just download on the fly fciv.exe. If the vbs will be run by end users and you have to check a lot of files, they'll be more doubtful about a vbs saying that it is taking 1h to check md5 of files than a vbs that say it will download / need fciv.exe (as it is Microsoft signed, people should be more secure with it).
-
Here it is: Dim sDigest Private Const BITS_TO_A_BYTE = 8 Private Const BYTES_TO_A_WORD = 4 Private Const BITS_TO_A_WORD = 32 Private m_lOnBits(30) Private m_l2Power(30) m_lOnBits(0) = CLng(1) m_lOnBits(1) = CLng(3) m_lOnBits(2) = CLng(7) m_lOnBits(3) = CLng(15) m_lOnBits(4) = CLng(31) m_lOnBits(5) = CLng(63) m_lOnBits(6) = CLng(127) m_lOnBits(7) = CLng(255) m_lOnBits(8) = CLng(511) m_lOnBits(9) = CLng(1023) m_lOnBits(10) = CLng(2047) m_lOnBits(11) = CLng(4095) m_lOnBits(12) = CLng(8191) m_lOnBits(13) = CLng(16383) m_lOnBits(14) = CLng(32767) m_lOnBits(15) = CLng(65535) m_lOnBits(16) = CLng(131071) m_lOnBits(17) = CLng(262143) m_lOnBits(18) = CLng(524287) m_lOnBits(19) = CLng(1048575) m_lOnBits(20) = CLng(2097151) m_lOnBits(21) = CLng(4194303) m_lOnBits(22) = CLng(8388607) m_lOnBits(23) = CLng(16777215) m_lOnBits(24) = CLng(33554431) m_lOnBits(25) = CLng(67108863) m_lOnBits(26) = CLng(134217727) m_lOnBits(27) = CLng(268435455) m_lOnBits(28) = CLng(536870911) m_lOnBits(29) = CLng(1073741823) m_lOnBits(30) = CLng(2147483647) m_l2Power(0) = CLng(1) m_l2Power(1) = CLng(2) m_l2Power(2) = CLng(4) m_l2Power(3) = CLng(8) m_l2Power(4) = CLng(16) m_l2Power(5) = CLng(32) m_l2Power(6) = CLng(64) m_l2Power(7) = CLng(128) m_l2Power(8) = CLng(256) m_l2Power(9) = CLng(512) m_l2Power(10) = CLng(1024) m_l2Power(11) = CLng(2048) m_l2Power(12) = CLng(4096) m_l2Power(13) = CLng(8192) m_l2Power(14) = CLng(16384) m_l2Power(15) = CLng(32768) m_l2Power(16) = CLng(65536) m_l2Power(17) = CLng(131072) m_l2Power(18) = CLng(262144) m_l2Power(19) = CLng(524288) m_l2Power(20) = CLng(1048576) m_l2Power(21) = CLng(2097152) m_l2Power(22) = CLng(4194304) m_l2Power(23) = CLng(8388608) m_l2Power(24) = CLng(16777216) m_l2Power(25) = CLng(33554432) m_l2Power(26) = CLng(67108864) m_l2Power(27) = CLng(134217728) m_l2Power(28) = CLng(268435456) m_l2Power(29) = CLng(536870912) m_l2Power(30) = CLng(1073741824) Private Function LShift(lValue, iShiftBits) If iShiftBits = 0 Then LShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And 1 Then LShift = &H80000000 Else LShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If If (lValue And m_l2Power(31 - iShiftBits)) Then LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000 Else LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits)) End If End Function Private Function RShift(lValue, iShiftBits) If iShiftBits = 0 Then RShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And &H80000000 Then RShift = 1 Else RShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits) If (lValue And &H80000000) Then RShift = (RShift Or (&H40000000 \ m_l2Power(iShiftBits - 1))) End If End Function Private Function RotateLeft(lValue, iShiftBits) RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits)) End Function Private Function AddUnsigned(lX, lY) Dim lX4 Dim lY4 Dim lX8 Dim lY8 Dim lResult lX8 = lX And &H80000000 lY8 = lY And &H80000000 lX4 = lX And &H40000000 lY4 = lY And &H40000000 lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF) If lX4 And lY4 Then lResult = lResult Xor &H80000000 Xor lX8 Xor lY8 ElseIf lX4 Or lY4 Then If lResult And &H40000000 Then lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8 Else lResult = lResult Xor &H40000000 Xor lX8 Xor lY8 End If Else lResult = lResult Xor lX8 Xor lY8 End If AddUnsigned = lResult End Function Private Function F(x, y, z) F = (x And y) Or ((Not x) And z) End Function Private Function G(x, y, z) G = (x And z) Or (y And (Not z)) End Function Private Function H(x, y, z) H = (x Xor y Xor z) End Function Private Function I(x, y, z) I = (y Xor (x Or (Not z))) End Function Private Sub FF(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Sub GG(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Sub HH(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Sub II(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, B) End Sub Private Function ConvertToWordArray(sMessage) Dim lMessageLength Dim lNumberOfWords Dim lWordArray() Dim lBytePosition Dim lByteCount Dim lWordCount Const MODULUS_BITS = 512 Const CONGRUENT_BITS = 448 lMessageLength = Len(sMessage) lNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD) ReDim lWordArray(lNumberOfWords - 1) lBytePosition = 0 lByteCount = 0 Do Until lByteCount >= lMessageLength lWordCount = lByteCount \ BYTES_TO_A_WORD lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition) lByteCount = lByteCount + 1 Loop lWordCount = lByteCount \ BYTES_TO_A_WORD lBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE lWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(&H80, lBytePosition) lWordArray(lNumberOfWords - 2) = LShift(lMessageLength, 3) lWordArray(lNumberOfWords - 1) = RShift(lMessageLength, 29) ConvertToWordArray = lWordArray End Function Private Function WordToHex(lValue) Dim lByte Dim lCount For lCount = 0 To 3 lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE - 1) WordToHex = WordToHex & Right("0" & Hex(lByte), 2) Next End Function Public Function MD5(sMessage) Dim x Dim k Dim AA Dim BB Dim CC Dim DD Dim a Dim b Dim c Dim d Const S11 = 7 Const S12 = 12 Const S13 = 17 Const S14 = 22 Const S21 = 5 Const S22 = 9 Const S23 = 14 Const S24 = 20 Const S31 = 4 Const S32 = 11 Const S33 = 16 Const S34 = 23 Const S41 = 6 Const S42 = 10 Const S43 = 15 Const S44 = 21 x = ConvertToWordArray(sMessage) a = &H67452301 b = &HEFCDAB89 c = &H98BADCFE d = &H10325476 For k = 0 To UBound(x) Step 16 AA = a BB = b CC = c DD = d FF a, b, c, d, x(k + 0), S11, &HD76AA478 FF d, a, b, c, x(k + 1), S12, &HE8C7B756 FF c, d, a, b, x(k + 2), S13, &H242070DB FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE FF a, b, c, d, x(k + 4), S11, &HF57C0FAF FF d, a, b, c, x(k + 5), S12, &H4787C62A FF c, d, a, b, x(k + 6), S13, &HA8304613 FF b, c, d, a, x(k + 7), S14, &HFD469501 FF a, b, c, d, x(k + 8), S11, &H698098D8 FF d, a, b, c, x(k + 9), S12, &H8B44F7AF FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1 FF b, c, d, a, x(k + 11), S14, &H895CD7BE FF a, b, c, d, x(k + 12), S11, &H6B901122 FF d, a, b, c, x(k + 13), S12, &HFD987193 FF c, d, a, b, x(k + 14), S13, &HA679438E FF b, c, d, a, x(k + 15), S14, &H49B40821 GG a, b, c, d, x(k + 1), S21, &HF61E2562 GG d, a, b, c, x(k + 6), S22, &HC040B340 GG c, d, a, b, x(k + 11), S23, &H265E5A51 GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA GG a, b, c, d, x(k + 5), S21, &HD62F105D GG d, a, b, c, x(k + 10), S22, &H2441453 GG c, d, a, b, x(k + 15), S23, &HD8A1E681 GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8 GG a, b, c, d, x(k + 9), S21, &H21E1CDE6 GG d, a, b, c, x(k + 14), S22, &HC33707D6 GG c, d, a, b, x(k + 3), S23, &HF4D50D87 GG b, c, d, a, x(k + 8), S24, &H455A14ED GG a, b, c, d, x(k + 13), S21, &HA9E3E905 GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8 GG c, d, a, b, x(k + 7), S23, &H676F02D9 GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A HH a, b, c, d, x(k + 5), S31, &HFFFA3942 HH d, a, b, c, x(k + 8), S32, &H8771F681 HH c, d, a, b, x(k + 11), S33, &H6D9D6122 HH b, c, d, a, x(k + 14), S34, &HFDE5380C HH a, b, c, d, x(k + 1), S31, &HA4BEEA44 HH d, a, b, c, x(k + 4), S32, &H4BDECFA9 HH c, d, a, b, x(k + 7), S33, &HF6BB4B60 HH b, c, d, a, x(k + 10), S34, &HBEBFBC70 HH a, b, c, d, x(k + 13), S31, &H289B7EC6 HH d, a, b, c, x(k + 0), S32, &HEAA127FA HH c, d, a, b, x(k + 3), S33, &HD4EF3085 HH b, c, d, a, x(k + 6), S34, &H4881D05 HH a, b, c, d, x(k + 9), S31, &HD9D4D039 HH d, a, b, c, x(k + 12), S32, &HE6DB99E5 HH c, d, a, b, x(k + 15), S33, &H1FA27CF8 HH b, c, d, a, x(k + 2), S34, &HC4AC5665 II a, b, c, d, x(k + 0), S41, &HF4292244 II d, a, b, c, x(k + 7), S42, &H432AFF97 II c, d, a, b, x(k + 14), S43, &HAB9423A7 II b, c, d, a, x(k + 5), S44, &HFC93A039 II a, b, c, d, x(k + 12), S41, &H655B59C3 II d, a, b, c, x(k + 3), S42, &H8F0CCC92 II c, d, a, b, x(k + 10), S43, &HFFEFF47D II b, c, d, a, x(k + 1), S44, &H85845DD1 II a, b, c, d, x(k + 8), S41, &H6FA87E4F II d, a, b, c, x(k + 15), S42, &HFE2CE6E0 II c, d, a, b, x(k + 6), S43, &HA3014314 II b, c, d, a, x(k + 13), S44, &H4E0811A1 II a, b, c, d, x(k + 4), S41, &HF7537E82 II d, a, b, c, x(k + 11), S42, &HBD3AF235 II c, d, a, b, x(k + 2), S43, &H2AD7D2BB II b, c, d, a, x(k + 9), S44, &HEB86D391 a = AddUnsigned(a, AA) b = AddUnsigned(b, BB) c = AddUnsigned(c, CC) d = AddUnsigned(d, DD) Next MD5 = LCase(WordToHex(a) & WordToHex(B) & WordToHex(c) & WordToHex(d)) End Function if WScript.Arguments.Count = 0 then WScript.Echo "Missing parameters" else Const ForReading = 1 Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.OpenTextFile(Wscript.Arguments.Item(0), ForReading) s = ts.ReadAll MyMD5=MD5(s) ts.Close wscript.echo Wscript.Arguments.Item(0) & " " & MyMD5 end if But like any vbs code it is very slow and doesn't give "true" md5 for binary files (using adodb.stream might solve this).
-
How to merge two text files?
allen2 replied to tomasz86's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
This should work: FOR /F "tokens=1,2 delims=, eol=" %%a in (1.inf) do echo %%a,%%b -
Changing device latancy and IRQ used?
allen2 replied to caps_buster's topic in Windows 2000/2003/NT4
I remember needing to set pnp os to "no" and to manually assign irq to pci slot when the setting was available on some motherboard bios to support Win ME. With some board, i also had to move some pci card from slots because some of them were automatically shared. -
Need to restore Windows XP Backup Files in Windows 7
allen2 replied to Kaylabook's topic in Windows XP
7zip can handle partly .bkf files so perhaps it might help. -
Sure, and depending on what sites you access from the non firewall filtered connection you may have the g-men break into your house at 4:00 AM , taking you to Gitmo, without the possibility of any legal assistance. Come on . jaclaz Just an example with stats and another. Of course if you don't care to keep your work, you can do what ever pass by your mind (and get directly to prison depending which rule you broke). People are usually fired for a smaller mistakes and i know at least an ex-coworker who got fired for using the network of the client company to transfer movies and tv series with another one. Our company could even sue him but decided not to as the matter needed to stay private and the client company "only requested that he wouldn't be allowed to enter its building". Jaclaz, come one, real life isn't somewhere without rules. It is the exact opposite: there are rules everywhere and depending which one you break lead you to prison. Just try to walk outside nude (you are not harming anyone except yourself and might get a cold) but you could end up like Stephen Gough. Of course i disagree with some rules and i agree with others just like many of us.
-
Non Enterprise PCI-express SSD doesn't provide that much speed on incompressible data in comparison with Samsung ssd 840 PRO. Also since i bought the Revodrive 3 X2 some month ago, i can tell i couldn't get it to provide the transfer rate even with highly compressible data and its bad side is that it doesn't offer linear speeds like an ssd should. I then tried the simple Revodrive 3 (same size) and it provided better performance especially for incompressible data except for high i/o usages. But both are only 20% faster than the speed from Samsung SSD 840 PRO (on the paper as i currently didn't had the chance to try the 840 PRO). As a side note, the Revodrive 3 x2 heated a lot more than the Revodrive 3 and both of them heat more than any sata ssd i ever tried.
-
The 3970X is of course better but use the "old" LGA2011 socket that might not support newer cpus and it is nowhere near a low power consumption cpu (MAX TDP 150W). On the power consumption side the 3770T have a max TDP of 45W (less than 1/3 of the 3970X) and 3770K sit between when not overclocked.
-
You shouldn't be doing this in the first place : bypassing the firewall could be considered by your security officer as a fault and they have the right (depending on your contract) to fire you and even sue you.
-
Just in case 3770T is a quad core (with HT you get 8 cpus). The good thing with 3770T is its very low consumption without the need of special mainboard. In the past i had to buy industrial motherboard and mobile cpu just to get low power computer with a decent power (4 core at least, HT isn't really that great for Virtual Machines).
-
As intel usb3 isn't working for windows before 7, if you need to stick with vista then be sure to pick a MB with another/a secondary supported usb3 chipset. As for me, to come with my 3770T, i bought a Gigabyte Z77X-D3H that does a great job as i wanted to stick with XP.
-
NT4 - Shuting down and restarting the server
allen2 replied to am12348's topic in Windows 2000/2003/NT4
Does the "schedule" service of your NT4 is running with something other than the system account (you'll this in services) ? In this case, psshutdown will only have the rights from the other user and if it isn't granted the admins rights, it might fail. In this case, you'll have to either add the rights or force psshutdown to use another login with -u and -p. For recent psshutdown version to run in batch mode with any account , you need to add the undocumented "-accepteula" option that need to be set first. -
An action plan with a repetitive batch
allen2 replied to hakoko's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Look at the help (or man page) of wget from the unixtools. It should help you beginning writing your batch script. -
NT4 - Shuting down and restarting the server
allen2 replied to am12348's topic in Windows 2000/2003/NT4
Just to utterly disagree: when it works, AT works alright. (and no it's not a truism) And the Task Scheduler in NT 4.00 (besides the IE related issues) is far from "perfect": http://www.piclist.com/techref/os/win/winnt/cron.htm Relying on an "external" machine to run tasks (if they are "critical") represent a good way to invite Murphy's Law at dinner for a live demonstration Another day, another tool/approach (scheduled unlock) : http://www.softtreetech.com/24x7/archive/51.htm jaclaz Why are you always trying to find the bad side to every solution someone other than you can provide ? There is something called Job scheduler software and it seem quite interesting how software companies disagree with you as they decided to create a lot of professional applications to run critical tasks and those critical tasks are operated usually from one central server (sometimes more than one for redundancy). In fact i think you just love to disagree with everyone (so of course you'll disagree with me on this point). "At" service doesn't come with a logging facility (eventlogs or plain file like scheduled taks in 200/xp/2003) to allow debugging so i can't call something like this a mission critical tool to run tasks ! Edit : spelling mistakes -
NT4 - Shuting down and restarting the server
allen2 replied to am12348's topic in Windows 2000/2003/NT4
Old psshutdown (Sysinternals version 1.0.1.0 and up to 2.34) worked for sure with NT4. Newer versions might or might not work but, as those will work for sure when used remotely: if you have another window (>NT4) computer around, you could use it to remotely shutdown the nt4 and on that other computer, you'll have scheduled tasks working properly instead of the lousy "at" (which was "enough" when there weren't anything beside it). -
How to get around the 2047 characters CMD string limitation
allen2 replied to tomasz86's topic in Windows 2000/2003/NT4
Never needed to use this means but if you go this way then you could also use something like the method used by Herbert Kleebauer there or like explained there to put any needed executable in the batch as some resource that would be extracted/decoded before being used. -
I'd say the last one if you're using ahci mode in the bios, the one before if you're using raid ahci, no driver needed if you're using ata mode.
-
How to get around the 2047 characters CMD string limitation
allen2 replied to tomasz86's topic in Windows 2000/2003/NT4
The great advantage of unix tools date is that you get easily and without hassle the date / time in almost whatever format you might imagine. -
How are you trying to "open" those .bkf ? Backup exec (and many other backup) file need to be inventoried and then catalogued before being restored. A part of the procedure is described there but it is more properly explained in backup exec manual.