home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Mib / T5KEYGEN.ZIP / T5KEYGEN.ASM next >
Assembly Source File  |  1998-08-15  |  5KB  |  280 lines

  1. ;Terminate v5.0 keygenerator
  2. ;Written by Cruehead as the first part of the 1999 +HCU strainer
  3. ;Written for MASM, but it should be fairly easy to port it to TASM
  4.  
  5. .model tiny
  6. .386
  7. .stack
  8. .data
  9. info       db 13,10,'Terminate v5.0 Keymaker',13,10
  10.            db 'Written by Cruehead as a part of the 1999 +HCU strainer',13,10
  11. ename      db 13,10,'Please enter your name                : $'
  12. estreet    db 13,10,'Please enter your address             : $'
  13. ecity      db 13,10,'Please enter city and ZIP code        : $'
  14. ecountry   db 13,10,'Please enter the name of your country : $'
  15. alldone    db 13,10,13,10,'TERMINATE.KEY file created!',13,10,'Now copy it to your Terminate v5.0 directory and enjoy...',13,10,'$'
  16. thename    db 51 dup (0)
  17. street     db 51 dup (0)
  18. city       db 51 dup (0)
  19. country    db 51 dup (0)
  20. storage1   dw 0
  21. storage2   dw 0
  22. seed1      dw 0
  23. seed2      dw 0
  24. constant   dw 08405h
  25. counter    dw 0
  26. handle     dw 0
  27. filename   db 'TERMINAT.KEY',0
  28. fileinfo   db 0162h*0bh dup (0)
  29. loopvalue  dw 0
  30.  
  31. include    term.inc                     ;The magic table
  32.  
  33. .code
  34. .startup
  35.  
  36. mov     ah,09h
  37. lea     dx,info
  38. int     21h
  39.  
  40. mov     ah,0ah
  41. lea     dx,thename
  42. mov     thename,45
  43. int     21h
  44.  
  45. xor     bh,bh                        
  46. mov     bl,thename[1]
  47. mov     thename[bx+2],0
  48.  
  49. mov     ah,09h
  50. lea     dx,estreet
  51. int     21h
  52.  
  53. mov     ah,0ah
  54. lea     dx,street
  55. mov     street,45
  56. int     21h
  57.  
  58. xor     bh,bh
  59. mov     bl,street[1]
  60. mov     street[bx+2],0
  61.  
  62. mov     ah,09h
  63. lea     dx,ecity
  64. int     21h
  65.  
  66. mov     ah,0ah
  67. lea     dx,city
  68. mov     city,45
  69. int     21h
  70.  
  71. xor     bh,bh
  72. mov     bl,city[1]
  73. mov     city[bx+2],0
  74.  
  75. mov     ah,09h
  76. lea     dx,ecountry
  77. int     21h
  78.  
  79. mov     ah,0ah
  80. lea     dx,country
  81. mov     country,45
  82. int     21h
  83.  
  84. xor     bh,bh
  85. mov     bl,country[1]
  86. mov     country[bx+2],0
  87.  
  88. lea     di,fileinfo
  89. lea     si,thename
  90. add     di,0481h+30
  91. mov     al,4
  92.  
  93. doitagain:
  94. mov     cx,51
  95. rep     movsb
  96.  
  97. dec     al
  98. cmp     al,0
  99. jne     doitagain
  100.  
  101. lea     di,fileinfo+481h
  102. mov     storage1,0ffffh
  103. mov     storage2,0ffffh
  104. mov     loopvalue,0103h
  105. call    checksum
  106.  
  107. mov     ax,storage1
  108. mov     [di],ax
  109. mov     ax,storage2
  110. mov     [di+2],ax
  111.  
  112. lea     di,fileinfo+6e6h
  113. mov     ax,storage1
  114. add     ax,10
  115. mov     [di],ax
  116. mov     ax,storage2
  117. mov     [di+2],ax
  118.  
  119. mov     seed1,7
  120. mov     seed2,0
  121. mov     counter,0
  122.  
  123. lea     di,fileinfo+481h
  124. call    decrypt1
  125. lea     di,fileinfo+481h
  126. call    decrypt2
  127. lea     di,fileinfo+481h
  128. mov     seed1,0325ch
  129. mov     seed2,0
  130. call    decrypt2
  131. lea     di,fileinfo+481h
  132. mov     seed1,0904h
  133. mov     seed2,033eeh
  134. call    decrypt2
  135.  
  136. lea     di,fileinfo
  137. mov     loopvalue,015eh
  138. mov     storage1,0ffffh
  139. mov     storage2,0ffffh
  140. mov     counter,0
  141. morecrccalc:
  142. call    checksum
  143. add     di,4
  144. add     loopvalue,015eh   
  145. cmp     counter,0f0ah
  146. jne     morecrccalc
  147.  
  148. lea     di,fileinfo
  149. add     di,0162h*0bh-4
  150. mov     ax,storage1
  151. mov     bx,storage2
  152. mov     [di],ax
  153. mov     [di+2],bx
  154.  
  155. mov     ah,03ch
  156. mov     cx,0
  157. lea     dx,filename
  158. int     21h
  159. mov     handle,ax
  160.  
  161. mov     ah,040h
  162. mov     bx,handle
  163. mov     cx,0162h*0bh
  164. lea     dx,fileinfo
  165. int     21h
  166.  
  167. mov     ah,03eh
  168. mov     bx,handle
  169. int     21h
  170.  
  171. mov     ah,09h
  172. lea     dx,alldone
  173. int     21h
  174.  
  175. .exit
  176.  
  177. decrypt1:
  178. mov     al,[di]
  179. xor     al,0ffh
  180. mov     [di],al
  181. inc     counter
  182. inc     di
  183. cmp     counter,0107h
  184. jne     decrypt1
  185. mov     counter,0
  186. ret
  187.  
  188. decrypt2:
  189. call    getvalue
  190. mov     bl,es:[di]
  191. xor     al,bl
  192. mov     es:[di],al
  193. inc     di
  194. inc     counter
  195. cmp     counter,0107h
  196. jne     decrypt2
  197. mov     counter,0
  198. ret
  199.  
  200. getvalue:
  201. mov     ax,seed1
  202. mov     bx,seed2
  203. mov     cx,ax
  204. mul     constant
  205. shl     cx,1
  206. shl     cx,1
  207. shl     cx,1
  208. add     ch,cl
  209. add     dx,cx
  210. add     dx,bx
  211. shl     bx,1
  212. shl     bx,1
  213. add     dx,bx
  214. add     dh,bl
  215. mov     cl,5
  216. shl     bx,cl
  217. add     dh,bl
  218. add     ax,1
  219. adc     dx,0
  220. mov     seed1,ax
  221. mov     seed2,dx
  222. xor     ax,ax
  223. mov     bx,0100h
  224. or      bx,bx
  225. jz      label1
  226. xchg    ax,dx
  227. div     bx
  228. xchg    ax,dx
  229. label1:
  230. ret
  231.  
  232. checksum:
  233. lea     si,term
  234. mov     cl,[di]
  235. mov     bx,storage1
  236. mov     dx,storage2
  237. xor     bx,cx
  238. xor     bh,bh
  239. shl     bx,1
  240. shl     bx,1
  241. add     si,bx
  242. add     bx,02014h
  243. mov     ax,[si]
  244. mov     cx,[si+2]
  245. mov     dx,storage2
  246. mov     bx,storage1
  247. push    cx
  248. mov     cx,8
  249. theloop:
  250. shr     dx,1
  251. rcr     bx,1
  252. loop    theloop
  253. and     dx,0ffh
  254. pop     cx
  255. xor     ax,bx
  256. mov     bx,cx
  257. xor     dx,bx
  258. mov     storage1,ax
  259. mov     storage2,dx
  260. inc     counter
  261. inc     di
  262. mov     cx,loopvalue
  263. cmp     counter,cx
  264. jne     checksum
  265.  
  266. cmp     counter,02bch                   ;15eh*2 (second read)
  267. jne     check12
  268. add     storage1,0329h
  269. adc     storage2,0
  270. check12:
  271. cmp     counter,0f0ah                   ;15eh*B (11'th and last read)
  272. jne     noproblemo
  273. add     storage1,0192h
  274. adc     storage2,0
  275.  
  276. noproblemo:
  277. ret
  278.  
  279. end
  280.