Making a registry key

Reply

Join Date: Mar 2006
Posts: 8
Reputation: deutsch is an unknown quantity at this point 
Solved Threads: 0
deutsch's Avatar
deutsch deutsch is offline Offline
Newbie Poster

Making a registry key

 
0
  #1
Apr 6th, 2006
Is there someone who can help me with this ?
I also put some comments with some questions as well.

Thanks.

  1. ; crypt3.asm This is supposed to making a registry key, but isn't.
  2. ; Compiles OK, but not working at present.
  3. ; Help from Paul Brennick,
  4. .386
  5. .model flat, stdcall
  6. option casemap:none
  7.  
  8. include \masm32\include\windows.inc
  9. include \masm32\include\kernel32.inc
  10. include \masm32\include\user32.inc
  11. include \masm32\include\advapi32.inc
  12. includelib \masm32\lib\user32.lib
  13. includelib \masm32\lib\kernel32.lib
  14. includelib \masm32\lib\advapi32.lib
  15.  
  16. GetKey PROTO
  17. GenKey PROTO :DWORD
  18. EncryptString PROTO :DWORD, :DWORD, :DWORD, :DWORD
  19. DecryptString PROTO :DWORD, :DWORD, :DWORD, :DWORD
  20.  
  21. .DATA
  22. ; This is a very simple pseudo-encrypted block, it is not meant to
  23. ; be secure in any way and is very easy to decrypt by anyone at all.
  24. ; It says "SOFTWARE\Microsoft\Windows\CurrentVersion",0,"ProductId"
  25. ; It is used in GetKey to generate an encryption key for passwords
  26. ; but I didn't want to just leave it in ansi so everyone could see.
  27. ; It requires Key# 152715150 to decrypt it
  28.  
  29.  
  30. mark1 db "Start" ; see where this is at and what's in here
  31. ; 52 characters
  32. cryptdata DB 05Ah,04Fh,0C4h,0D8h,052h,053h,0ECh,0FAh,044h,04Bh
  33. DB 09Ah,0B6h,018h,00Fh,0AEh,0AEh,030h,039h,0F0h,0DEh
  34. DB 02Eh,00Dh,080h,0AEh,012h,037h,0F0h,0F6h,016h,035h
  35. DB 0ACh,0BAh,020h,039h,0E4h,0BAh,018h,037h,09Ah,0AEh
  36. DB 020h,0D1h,0E8h,094h,022h,019h,0A2h,0B6h,014h,043h
  37. DB 080h,070h
  38.  
  39. mark2 db "End"
  40. ValueOK db "Registry key added OK",0
  41. Sample db "BOX",0
  42. .CODE
  43.  
  44. start:
  45.  
  46. call GetKey
  47. invoke ExitProcess,0
  48.  
  49. GetKey PROC
  50.  
  51. LOCAL KSRegKey[256] :BYTE
  52. LOCAL KeyString[64] :BYTE
  53. LOCAL hRegKey :DWORD
  54. LOCAL Disposition :DWORD
  55. LOCAL uDataCode :DWORD
  56. LOCAL cbRead :DWORD
  57.  
  58. ;invoke RtlSecureZeroMemory, ADDR KSRegKey, sizeof KSRegKey
  59. invoke RtlZeroMemory, ADDR KSRegKey, sizeof KSRegKey
  60. invoke DecryptString, OFFSET cryptdata, 152715150, ADDR KSRegKey, 13
  61. ;int 3
  62.  
  63. ; Key we're trying to make
  64. ; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion",0,"ProductId
  65.  
  66. invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE, ADDR KSRegKey, NULL, NULL,\
  67. REG_OPTION_NON_VOLATILE, KEY_READ, NULL, ADDR hRegKey, ADDR Disposition
  68.  
  69. .IF EAX == ERROR_SUCCESS
  70. invoke MessageBox, 0, ADDR ValueOK, ADDR Sample,MB_ICONINFORMATION
  71. .ENDIF
  72.  
  73. ;int 3
  74. or eax, eax
  75. jz @F
  76. xor eax, eax
  77. dec eax
  78. ret
  79. @@:
  80. mov DWORD PTR [cbRead], 64
  81.  
  82. ; what is this doing ?
  83. invoke RegQueryValueEx, [hRegKey], ADDR KSRegKey+42, NULL, ADDR uDataCode,\
  84. ADDR KeyString, ADDR cbRead
  85.  
  86. invoke RegCloseKey, [hRegKey]
  87. invoke GenKey, ADDR KeyString
  88. ;int 3
  89. xor eax, eax
  90. RET
  91.  
  92. GetKey ENDP
  93.  
  94. GenKey PROC uses edi esi lpKeyString:DWORD
  95.  
  96. invoke lstrlen, [lpKeyString] ; return length in bytes of the string
  97. mov edi, 0
  98. mov ecx, eax
  99. mov esi, [lpKeyString]
  100. @@:
  101. push ecx
  102. dec ecx
  103. mov eax, [esi+ecx]
  104. add edi, eax
  105. pop ecx
  106. dec ecx
  107. or ecx, ecx
  108. jnz @B
  109. clc
  110. ret
  111.  
  112. GenKey ENDP
  113.  
  114. EncryptString PROC uses edi esi lpDataString:DWORD, CryptKey:DWORD, lpOutString:DWORD, cbdata:DWORD
  115.  
  116. mov ecx, [cbdata]
  117. mov edi, [lpOutString]
  118. mov esi, [lpDataString]
  119. @@:
  120. push ecx
  121. dec ecx
  122. mov eax, [esi+ecx*4]
  123. rol eax, 6
  124. xor eax, [CryptKey]
  125. ror eax, 5
  126. mov [edi+ecx*4], eax
  127. pop ecx
  128. dec ecx
  129. or ecx, ecx
  130. jnz @B
  131. ret
  132.  
  133. EncryptString ENDP
  134.  
  135. DecryptString PROC uses edi esi lpDataString:DWORD, CryptKey:DWORD, lpOutString:DWORD, cbdata:DWORD
  136.  
  137. mov ecx, [cbdata]
  138. mov edi, [lpOutString]
  139. mov esi, [lpDataString]
  140. @@:
  141. push ecx
  142. dec ecx
  143. mov eax, [esi+ecx*4]
  144. rol eax, 5
  145. xor eax, [CryptKey]
  146. ror eax, 6
  147. mov [edi+ecx*4], eax
  148. pop ecx
  149. dec ecx
  150. or ecx, ecx
  151. jnz @B
  152. ret
  153.  
  154. DecryptString ENDP
  155.  
  156. END start
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC