1. ;MD5加密
    2. (defun all:yc:md5->string(String / a b c d f g h i k l lst md5:bits->bytes md5:bits->int md5:byte->hex md5:bytes->bits md5:int->bits md5:int->char md5:leftrotate md5:uint32_+ md5:uint32_0 r stringtoascii w x y)
    3. (defun StringToAscii (String / positioni YPOutString)
    4. (setq positioni -1)
    5. (repeat (strlen string)
    6. (setq YPOutString (append YPOutString (list (vl-string-elt string (setq positioni (+ positioni 1))))))
    7. )
    8. YPOutString
    9. )
    10. (defun md5:int->bits (n b / l x)
    11. (repeat b (setq l (cons 0 l)))
    12. (foreach x (vl-string->list (rtos n 2 0))
    13. (setq x (- x 48)
    14. l (mapcar '(lambda ( a ) (setq a (+ (* a 10) x) x (/ a 2)) (rem a 2)) l)
    15. )
    16. )
    17. (reverse l)
    18. )
    19. (defun md5:bits->int (l)
    20. ( (lambda ( f ) (f (reverse l)))
    21. (lambda ( l ) (if l (+ (* 2.0 (f (cdr l))) (car l)) 0))
    22. )
    23. )
    24. (defun md5:bits->bytes (l / b r)
    25. (repeat (/ (length l) 8)
    26. (repeat 8
    27. (setq b (cons (car l) b)
    28. l (cdr l)
    29. )
    30. )
    31. (setq r (cons (fix (+ 1e-8 (md5:bits->int (reverse b)))) r)
    32. b nil
    33. )
    34. )
    35. r ; output is little-endian
    36. )
    37. (defun md5:bytes->bits (l) ; input is little-endian
    38. (apply 'append (mapcar '(lambda ( b ) (md5:int->bits b 8)) (reverse l))) ; output is big-endian
    39. )
    40. (defun md5:int->char (n)
    41. (chr (+ n (if (< n 10) 48 87)))
    42. )
    43. (defun md5:byte->hex (x)
    44. (strcat (md5:int->char (/ x 16)) (md5:int->char (rem x 16)))
    45. )
    46. (defun md5:leftrotate (l x)
    47. (repeat x (setq l (append (cdr l) (list (car l)))))
    48. )
    49. (defun md5:uint32_+ (bl1 bl2 / r) ; input is big-endian
    50. (setq r 0)
    51. (reverse
    52. (mapcar
    53. '(lambda ( a b c / x )
    54. (setq x (boole 6 (boole 6 a b) r)
    55. r (boole 7 (boole 1 a b) (boole 1 a r) (boole 1 b r))
    56. )
    57. x
    58. )
    59. (append (reverse bl1) (md5:uint32_0))
    60. (append (reverse bl2) (md5:uint32_0))
    61. (md5:uint32_0)
    62. )
    63. ) ; output is big-endian
    64. )
    65. (defun md5:uint32_0 (/ l)
    66. (repeat 32 (setq l (cons 0 l)))
    67. (eval (list 'defun 'md5:uint32_0 nil (list 'quote l)))
    68. (md5:uint32_0)
    69. )
    70. (setq lst (StringToAscii String))
    71. (setq k
    72. (mapcar '(lambda ( x ) (md5:int->bits x 32))
    73. '(
    74. 3614090360 3905402710 0606105819 3250441966 4118548399 1200080426 2821735955 4249261313
    75. 1770035416 2336552879 4294925233 2304563134 1804603682 4254626195 2792965006 1236535329
    76. 4129170786 3225465664 0643717713 3921069994 3593408605 0038016083 3634488961 3889429448
    77. 0568446438 3275163606 4107603335 1163531501 2850285829 4243563512 1735328473 2368359562
    78. 4294588738 2272392833 1839030562 4259657740 2763975236 1272893353 4139469664 3200236656
    79. 0681279174 3936430074 3572445317 0076029189 3654602809 3873151461 0530742520 3299628645
    80. 4096336452 1126891415 2878612391 4237533241 1700485571 2399980690 4293915773 2240044497
    81. 1873313359 4264355552 2734768916 1309151649 4149444226 3174756917 0718787259 3951481745
    82. )
    83. )
    84. )
    85. (setq r
    86. '(
    87. 07 12 17 22 07 12 17 22 07 12 17 22 07 12 17 22
    88. 05 09 14 20 05 09 14 20 05 09 14 20 05 09 14 20
    89. 04 11 16 23 04 11 16 23 04 11 16 23 04 11 16 23
    90. 06 10 15 21 06 10 15 21 06 10 15 21 06 10 15 21
    91. )
    92. )
    93. (setq h
    94. (mapcar '(lambda ( x ) (md5:int->bits x 32))
    95. '(
    96. 1732584193 ; 0x67452301 = 01234567
    97. 4023233417 ; 0xefcdab89 = 89abcdef
    98. 2562383102 ; 0x98badcfe = fedcda98
    99. 0271733878 ; 0x10325476 = 76543210
    100. )
    101. )
    102. )
    103. (setq l (cons 128 (reverse lst)))
    104. (repeat (rem (+ 64 (- 56 (rem (length l) 64))) 64) (setq l (cons 0 l)))
    105. (setq l (append (reverse l) (md5:bits->bytes (md5:int->bits (* 8 (length lst)) 64))))
    106. (repeat (/ (length l) 64)
    107. (repeat 16
    108. (setq w (cons (md5:bytes->bits (mapcar '+ l '(0 0 0 0))) w)
    109. l (cddddr l)
    110. )
    111. )
    112. (setq w (reverse w))
    113. (mapcar 'set '(a b c d) h)
    114. (setq i 0)
    115. (repeat 64
    116. (cond
    117. ((< i 16) (setq f (mapcar 'logior (mapcar 'logand b c) (mapcar 'logand (mapcar '(lambda ( a ) (+ 2 (~ a))) b) d))
    118. g i))
    119. ((< i 32) (setq f (mapcar 'logior (mapcar 'logand d b) (mapcar 'logand (mapcar '(lambda ( a ) (+ 2 (~ a))) d) c))
    120. g (rem (1+ (* 5 i)) 16)))
    121. ((< i 48) (setq f (mapcar '(lambda ( a b c ) (boole 6 a b c)) b c d)
    122. g (rem (+ 5 (* 3 i)) 16)))
    123. (T (setq f (mapcar '(lambda ( a b ) (boole 6 a b)) c (mapcar 'logior b (mapcar '(lambda ( a ) (+ 2 (~ a))) d)))
    124. g (rem (* 7 i) 16)))
    125. )
    126. (mapcar 'set '(d c a b i)
    127. (list c b d
    128. (md5:uint32_+ b
    129. (md5:leftrotate
    130. (md5:uint32_+
    131. (md5:uint32_+
    132. (md5:uint32_+ a f)
    133. (nth i k)
    134. )
    135. (nth g w)
    136. )
    137. (nth i r)
    138. )
    139. )
    140. (1+ i)
    141. )
    142. )
    143. )
    144. (setq h (mapcar 'md5:uint32_+ h (list a b c d))
    145. w nil
    146. )
    147. )
    148. (apply 'strcat
    149. (mapcar 'md5:byte->hex
    150. (apply 'append (mapcar 'md5:bits->bytes h))
    151. )
    152. )
    153. )
    154. ;序列号混淆
    155. (defun ser-all_num->confused(str / code lennum n strlst)
    156. (setq strlst
    157. (vl-string->list
    158. (strcat
    159. (substr str 13 2)
    160. (substr str 1 2)
    161. (substr str 23 2)
    162. (substr str 3 2)
    163. (substr str 17 2)
    164. (substr str 5 2)
    165. (substr str 29 2)
    166. (substr str 7 2)
    167. (substr str 27 2)
    168. (substr str 9 2)
    169. (substr str 11 2)
    170. (substr str 31 2)
    171. (substr str 15 2)
    172. (substr str 19 2)
    173. (substr str 25 2)
    174. (substr str 21 2)
    175. (substr str 33)
    176. )
    177. ) lennum (length strlst) n 0 code "")
    178. (foreach x strlst
    179. (setq code
    180. (strcat code
    181. (cond
    182. ((< n 1 lennum) (itoa (ascii "f")))
    183. ((< n 2 lennum) "")
    184. ((< n 3 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "]"))))
    185. ((< n 4 lennum) (itoa (nth n strlst)))
    186. ((< n 5 lennum) (itoa (ascii "h")))
    187. ((< n 6 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "v"))))
    188. ((< n 7 lennum) "")
    189. ((< n 8 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "j"))))
    190. ((< n 9 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "r"))))
    191. ((< n 10 lennum) (itoa (ascii "$")))
    192. ((< n 11 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "D"))))
    193. ((< n 12 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "j"))))
    194. ((< n 12 lennum) (strcat "" (itoa (ascii "X"))))
    195. ((< n 14 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii ","))))
    196. ((< n 15 lennum) (itoa (ascii "L")))
    197. ((< n 16 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "?"))))
    198. (T (strcat (itoa (nth n strlst)) (itoa (ascii "u"))))
    199. )
    200. )
    201. )
    202. (setq n (1+ n))
    203. )
    204. code
    205. )
    206. ;申请码混淆
    207. (defun app-all_code->confused(str / code lennum n strlst)
    208. (setq strlst
    209. (vl-string->list
    210. (strcat
    211. (substr str 23 2)
    212. (substr str 1 2)
    213. (substr str 27 2)
    214. (substr str 21 2)
    215. (substr str 3 2)
    216. (substr str 17 2)
    217. (substr str 5 2)
    218. (substr str 15 2)
    219. (substr str 7 2)
    220. (substr str 29 2)
    221. (substr str 9 2)
    222. (substr str 13 2)
    223. (substr str 19 2)
    224. (substr str 31 2)
    225. (substr str 25 2)
    226. (substr str 11 2)
    227. (substr str 33)
    228. )
    229. ) lennum (length strlst) n 0 code "")
    230. (foreach x strlst
    231. (setq code
    232. (strcat code
    233. (cond
    234. ((< n 1 lennum) (strcat "" (itoa (ascii "N"))))
    235. ((< n 2 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "}"))))
    236. ((< n 3 lennum) (strcat "" (itoa (ascii "/"))))
    237. ((< n 4 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "F"))))
    238. ((< n 5 lennum) (strcat (itoa (nth n strlst)) ""))
    239. ((< n 6 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "d"))))
    240. ((< n 7 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii " "))))
    241. ((< n 8 lennum) (strcat "4" (itoa (ascii "-"))))
    242. ((< n 9 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "j"))))
    243. ((< n 10 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "F"))))
    244. ((< n 11 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "n"))))
    245. ((< n 12 lennum) (strcat "" (itoa (ascii "6"))))
    246. ((< n 12 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "F"))))
    247. ((< n 14 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "g"))))
    248. ((< n 15 lennum) (strcat "" (itoa (ascii "K"))))
    249. ((< n 16 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "9"))))
    250. (T (strcat (itoa (nth n strlst)) (itoa (ascii "!"))))
    251. )
    252. )
    253. )
    254. (setq n (1+ n))
    255. )
    256. code
    257. )
    258. (defun all-get-bf_str->lst(str del / pos)
    259. (if (setq pos (vl-string-search del str))
    260. (cons (substr str 1 pos)
    261. (all-get-bf_str->lst (substr str (+ pos 1 (strlen del))) del)
    262. )
    263. (list str)
    264. )
    265. )
    266. (defun all-bf->list_sort (lst oper / x1 x2)
    267. (vl-sort lst
    268. '(lambda (x1 x2)
    269. (if
    270. (and
    271. (atom x1)
    272. (atom x2)
    273. )
    274. (apply oper (list x1 x2))
    275. (apply oper (list (car x1) (car x2)))
    276. )
    277. )
    278. )
    279. )
    280. ;获得所有盘盘符及序列号(已混淆)
    281. (defun get-all_path->sn(/ base bf-str-cross drives found fso lst lst1 meth1 meth2 meth3 n path pclst pflst pro serialnumber uplst volumename wmi)
    282. ;↓↓↓↓↓↓↓↓获取主板和cpu序列号↓↓↓↓↓↓↓↓
    283. ;;字符串每个字符交错组合
    284. ;;(BF-Str-Cross "每个字符交" "45678")"每4个5字6符7交8"
    285. (defun BF-Str-Cross(a b / BF-Str->Chrs c d str)
    286. (defun BF-Str->Chrs(str / a c)
    287. (setq a(vl-string->list str))
    288. (while a
    289. (if(< (car a) 129)
    290. (setq c (cons (chr (car a)) c) a (cdr a))
    291. (setq c (cons (strcat (chr (car a)) (chr (cadr a))) c) a (cddr a))
    292. )
    293. )
    294. (reverse c)
    295. )
    296. (setq str "" a (BF-Str->Chrs a) b (BF-Str->Chrs b))
    297. (while (or (car a) (car b))
    298. (setq c (car a) d (car b) str (strcat str (if c c "") (if d d "")) a (cdr a) b (cdr b))
    299. )
    300. str
    301. )
    302. (setq wmi (vlax-create-object "WbemScripting.SWbemLocator"))
    303. (setq meth1 (vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil nil ))
    304. (setq meth2 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_BaseBoard" nil nil nil ));主板
    305. (vlax-for n meth2
    306. ;(print (vlax-get n 'name))
    307. (setq Base (vlax-get n 'SerialNumber))
    308. )
    309. (setq meth3 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_Processor" nil nil nil ));CPU
    310. (vlax-for n meth3
    311. ;(print (vlax-get n 'name))
    312. (setq Pro (vlax-get n 'ProcessorId))
    313. )
    314. (setq pclst (cons (list "PC" (strcat "PC" (substr (all:yc:md5->string (ser-all_num->confused (strcat "PC" (BF-Str-Cross Base Pro)))) 8 16))) pclst))
    315. (setq pclst (cons (list "PCBY" (strcat "PCBY" (substr (all:yc:md5->string (ser-all_num->confused (strcat "PCBY" (cadddr (all-get-bf_str->lst (getnetime) " ")) (BF-Str-Cross Base Pro)))) 3 16))) pclst))
    316. ;↓↓↓↓↓↓↓↓获取C盘序列号↓↓↓↓↓↓↓↓
    317. ;(setq fso (vlax-create-object "Scripting.FileSystemObject"))
    318. ;(setq Drives (vlax-get-property fso "Drives") pclst nil uplst nil)
    319. ;(vlax-for n drives
    320. ; (and
    321. ; (= 2 (vlax-get-property n 'DriveType));2 DriveType 本地磁盘
    322. ; (setq Path (vlax-get-property n 'Path))
    323. ; (setq SerialNumber (vl-princ-to-string (vlax-get-property n 'SerialNumber)))
    324. ; (setq pclst (cons (list (vl-string-trim "\" :" Path) (strcat "PC" (substr (ser-all_num->confused (ser-all_num->confused (strcat (cadddr (all-get-bf_str->lst (getnetime) " ")) SerialNumber))) 6 16))) pclst));电脑盘符路径及序列号表
    325. ; )
    326. ;)
    327. ;(defun test();获取CPU序列号
    328. ; (setq wmi (vlax-create-object "WbemScripting.SWbemLocator"))
    329. ; (setq meth1 (vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil nil ))
    330. ; (setq meth2 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_Processor" nil nil nil ))
    331. ; (vlax-for n meth2
    332. ; (print (vlax-get n 'name))
    333. ; (print (vlax-get n 'ProcessorId))
    334. ; )
    335. ; (princ)
    336. ;)
    337. ;(vlax-dump-object meth2)
    338. ;(defun test();获取主板序列号
    339. ; (setq wmi (vlax-create-object "WbemScripting.SWbemLocator"))
    340. ; (setq meth1 (vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil nil ))
    341. ; (setq meth2 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_BaseBoard" nil nil nil ))
    342. ; (vlax-for n meth2
    343. ; (print (vlax-get n 'name))
    344. ; (print (vlax-get n 'SerialNumber))
    345. ; )
    346. ; (princ)
    347. ;)
    348. ;↓↓↓↓↓↓↓↓获取UP序列号↓↓↓↓↓↓↓↓
    349. (setq
    350. WMI (vlax-create-object "WbemScripting.SWbemLocator")
    351. meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
    352. meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_LogicalDisk Where DriveType = 2" nil nil nil)
    353. meth3 (vlax-invoke meth1 'ExecQuery "Select * from Win32_DiskDrive Where InterfaceType = 'USB'" nil nil nil)
    354. )
    355. ;获取盘符 Name DeviceID
    356. (setq lst nil)
    357. (vlax-for n meth2
    358. (setq lst (cons (substr (vlax-get n 'Name) 1 1) lst))
    359. )
    360. (setq lst1 nil)
    361. (vlax-for n meth3
    362. (setq lst1
    363. (cons
    364. (list
    365. (vlax-get n 'Index)
    366. (car (reverse (all-get-bf_str->lst (vlax-get n 'PNPDeviceID) "\\")))
    367. )
    368. lst1
    369. )
    370. )
    371. )
    372. (foreach obj (list WMI meth1 meth2 meth3) (if obj (vlax-release-object obj)))
    373. (setq lst (vl-sort lst '<) lst1 (all-bf->list_sort lst1 '<) n 0)
    374. (repeat (length lst)
    375. (setq uplst (cons (list (nth n lst) (strcat "UP" (substr (all:yc:md5->string (ser-all_num->confused (strcat "UP" (cadr (nth n lst1))))) 15 16))) uplst))
    376. (setq uplst (cons (list (strcat (nth n lst) "BY") (strcat "UPBY" (substr (all:yc:md5->string (ser-all_num->confused (strcat "UPBY" (cadddr (all-get-bf_str->lst (getnetime) " ")) (cadr (nth n lst1))))) 10 16))) uplst))
    377. (setq n (1+ n))
    378. )
    379. ;(foreach x pclst (if (= (car x) "C") (setq pflst (append (list (list "PC" (cadr x))) (reverse uplst)))));盘符表
    380. (setq pflst (append (reverse pclst) (reverse uplst)));上面只有C盘的序列号,如果想要电脑的全盘符序列号,请将此句替代上一句
    381. );↑↑↑↑↑↑↑↑获取盘符序列号结束↑↑↑↑↑↑↑↑
    382. =======================以下是高飞鸟的获取U盘序列号代码=======================
    383. (defun C:test (/ SWbemLocator Service USBDevices Info Name ID)
    384. (setq SWbemLocator (vlax-create-object "WbemScripting.SWbemLocator"))
    385. (setq Service (vlax-invoke SWbemLocator 'ConnectServer))
    386. (setq USBDevices (vlax-invoke Service 'ExecQuery "Select * From Win32_USBHub"))
    387. (vlax-for usb USBDevices
    388. (setq Info (vlax-invoke usb 'GetObjectText_))
    389. (setq Name (vlax-get usb 'Name))
    390. (if (or (wcmatch name "*Storage*") (wcmatch name "*存储*"))
    391. (alert (setq Id (vlax-get usb 'DeviceID)))
    392. )
    393. )
    394. (foreach obj (list USBDevices Service SWbemLocator) (if obj (vlax-release-object obj)))
    395. )