;MD5加密
(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)
(defun StringToAscii (String / positioni YPOutString)
(setq positioni -1)
(repeat (strlen string)
(setq YPOutString (append YPOutString (list (vl-string-elt string (setq positioni (+ positioni 1))))))
)
YPOutString
)
(defun md5:int->bits (n b / l x)
(repeat b (setq l (cons 0 l)))
(foreach x (vl-string->list (rtos n 2 0))
(setq x (- x 48)
l (mapcar '(lambda ( a ) (setq a (+ (* a 10) x) x (/ a 2)) (rem a 2)) l)
)
)
(reverse l)
)
(defun md5:bits->int (l)
( (lambda ( f ) (f (reverse l)))
(lambda ( l ) (if l (+ (* 2.0 (f (cdr l))) (car l)) 0))
)
)
(defun md5:bits->bytes (l / b r)
(repeat (/ (length l) 8)
(repeat 8
(setq b (cons (car l) b)
l (cdr l)
)
)
(setq r (cons (fix (+ 1e-8 (md5:bits->int (reverse b)))) r)
b nil
)
)
r ; output is little-endian
)
(defun md5:bytes->bits (l) ; input is little-endian
(apply 'append (mapcar '(lambda ( b ) (md5:int->bits b 8)) (reverse l))) ; output is big-endian
)
(defun md5:int->char (n)
(chr (+ n (if (< n 10) 48 87)))
)
(defun md5:byte->hex (x)
(strcat (md5:int->char (/ x 16)) (md5:int->char (rem x 16)))
)
(defun md5:leftrotate (l x)
(repeat x (setq l (append (cdr l) (list (car l)))))
)
(defun md5:uint32_+ (bl1 bl2 / r) ; input is big-endian
(setq r 0)
(reverse
(mapcar
'(lambda ( a b c / x )
(setq x (boole 6 (boole 6 a b) r)
r (boole 7 (boole 1 a b) (boole 1 a r) (boole 1 b r))
)
x
)
(append (reverse bl1) (md5:uint32_0))
(append (reverse bl2) (md5:uint32_0))
(md5:uint32_0)
)
) ; output is big-endian
)
(defun md5:uint32_0 (/ l)
(repeat 32 (setq l (cons 0 l)))
(eval (list 'defun 'md5:uint32_0 nil (list 'quote l)))
(md5:uint32_0)
)
(setq lst (StringToAscii String))
(setq k
(mapcar '(lambda ( x ) (md5:int->bits x 32))
'(
3614090360 3905402710 0606105819 3250441966 4118548399 1200080426 2821735955 4249261313
1770035416 2336552879 4294925233 2304563134 1804603682 4254626195 2792965006 1236535329
4129170786 3225465664 0643717713 3921069994 3593408605 0038016083 3634488961 3889429448
0568446438 3275163606 4107603335 1163531501 2850285829 4243563512 1735328473 2368359562
4294588738 2272392833 1839030562 4259657740 2763975236 1272893353 4139469664 3200236656
0681279174 3936430074 3572445317 0076029189 3654602809 3873151461 0530742520 3299628645
4096336452 1126891415 2878612391 4237533241 1700485571 2399980690 4293915773 2240044497
1873313359 4264355552 2734768916 1309151649 4149444226 3174756917 0718787259 3951481745
)
)
)
(setq r
'(
07 12 17 22 07 12 17 22 07 12 17 22 07 12 17 22
05 09 14 20 05 09 14 20 05 09 14 20 05 09 14 20
04 11 16 23 04 11 16 23 04 11 16 23 04 11 16 23
06 10 15 21 06 10 15 21 06 10 15 21 06 10 15 21
)
)
(setq h
(mapcar '(lambda ( x ) (md5:int->bits x 32))
'(
1732584193 ; 0x67452301 = 01234567
4023233417 ; 0xefcdab89 = 89abcdef
2562383102 ; 0x98badcfe = fedcda98
0271733878 ; 0x10325476 = 76543210
)
)
)
(setq l (cons 128 (reverse lst)))
(repeat (rem (+ 64 (- 56 (rem (length l) 64))) 64) (setq l (cons 0 l)))
(setq l (append (reverse l) (md5:bits->bytes (md5:int->bits (* 8 (length lst)) 64))))
(repeat (/ (length l) 64)
(repeat 16
(setq w (cons (md5:bytes->bits (mapcar '+ l '(0 0 0 0))) w)
l (cddddr l)
)
)
(setq w (reverse w))
(mapcar 'set '(a b c d) h)
(setq i 0)
(repeat 64
(cond
((< i 16) (setq f (mapcar 'logior (mapcar 'logand b c) (mapcar 'logand (mapcar '(lambda ( a ) (+ 2 (~ a))) b) d))
g i))
((< i 32) (setq f (mapcar 'logior (mapcar 'logand d b) (mapcar 'logand (mapcar '(lambda ( a ) (+ 2 (~ a))) d) c))
g (rem (1+ (* 5 i)) 16)))
((< i 48) (setq f (mapcar '(lambda ( a b c ) (boole 6 a b c)) b c d)
g (rem (+ 5 (* 3 i)) 16)))
(T (setq f (mapcar '(lambda ( a b ) (boole 6 a b)) c (mapcar 'logior b (mapcar '(lambda ( a ) (+ 2 (~ a))) d)))
g (rem (* 7 i) 16)))
)
(mapcar 'set '(d c a b i)
(list c b d
(md5:uint32_+ b
(md5:leftrotate
(md5:uint32_+
(md5:uint32_+
(md5:uint32_+ a f)
(nth i k)
)
(nth g w)
)
(nth i r)
)
)
(1+ i)
)
)
)
(setq h (mapcar 'md5:uint32_+ h (list a b c d))
w nil
)
)
(apply 'strcat
(mapcar 'md5:byte->hex
(apply 'append (mapcar 'md5:bits->bytes h))
)
)
)
;序列号混淆
(defun ser-all_num->confused(str / code lennum n strlst)
(setq strlst
(vl-string->list
(strcat
(substr str 13 2)
(substr str 1 2)
(substr str 23 2)
(substr str 3 2)
(substr str 17 2)
(substr str 5 2)
(substr str 29 2)
(substr str 7 2)
(substr str 27 2)
(substr str 9 2)
(substr str 11 2)
(substr str 31 2)
(substr str 15 2)
(substr str 19 2)
(substr str 25 2)
(substr str 21 2)
(substr str 33)
)
) lennum (length strlst) n 0 code "")
(foreach x strlst
(setq code
(strcat code
(cond
((< n 1 lennum) (itoa (ascii "f")))
((< n 2 lennum) "")
((< n 3 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "]"))))
((< n 4 lennum) (itoa (nth n strlst)))
((< n 5 lennum) (itoa (ascii "h")))
((< n 6 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "v"))))
((< n 7 lennum) "")
((< n 8 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "j"))))
((< n 9 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "r"))))
((< n 10 lennum) (itoa (ascii "$")))
((< n 11 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "D"))))
((< n 12 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "j"))))
((< n 12 lennum) (strcat "" (itoa (ascii "X"))))
((< n 14 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii ","))))
((< n 15 lennum) (itoa (ascii "L")))
((< n 16 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "?"))))
(T (strcat (itoa (nth n strlst)) (itoa (ascii "u"))))
)
)
)
(setq n (1+ n))
)
code
)
;申请码混淆
(defun app-all_code->confused(str / code lennum n strlst)
(setq strlst
(vl-string->list
(strcat
(substr str 23 2)
(substr str 1 2)
(substr str 27 2)
(substr str 21 2)
(substr str 3 2)
(substr str 17 2)
(substr str 5 2)
(substr str 15 2)
(substr str 7 2)
(substr str 29 2)
(substr str 9 2)
(substr str 13 2)
(substr str 19 2)
(substr str 31 2)
(substr str 25 2)
(substr str 11 2)
(substr str 33)
)
) lennum (length strlst) n 0 code "")
(foreach x strlst
(setq code
(strcat code
(cond
((< n 1 lennum) (strcat "" (itoa (ascii "N"))))
((< n 2 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "}"))))
((< n 3 lennum) (strcat "" (itoa (ascii "/"))))
((< n 4 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "F"))))
((< n 5 lennum) (strcat (itoa (nth n strlst)) ""))
((< n 6 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "d"))))
((< n 7 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii " "))))
((< n 8 lennum) (strcat "4" (itoa (ascii "-"))))
((< n 9 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "j"))))
((< n 10 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "F"))))
((< n 11 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "n"))))
((< n 12 lennum) (strcat "" (itoa (ascii "6"))))
((< n 12 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "F"))))
((< n 14 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "g"))))
((< n 15 lennum) (strcat "" (itoa (ascii "K"))))
((< n 16 lennum) (strcat (itoa (nth n strlst)) (itoa (ascii "9"))))
(T (strcat (itoa (nth n strlst)) (itoa (ascii "!"))))
)
)
)
(setq n (1+ n))
)
code
)
(defun all-get-bf_str->lst(str del / pos)
(if (setq pos (vl-string-search del str))
(cons (substr str 1 pos)
(all-get-bf_str->lst (substr str (+ pos 1 (strlen del))) del)
)
(list str)
)
)
(defun all-bf->list_sort (lst oper / x1 x2)
(vl-sort lst
'(lambda (x1 x2)
(if
(and
(atom x1)
(atom x2)
)
(apply oper (list x1 x2))
(apply oper (list (car x1) (car x2)))
)
)
)
)
;获得所有盘盘符及序列号(已混淆)
(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)
;↓↓↓↓↓↓↓↓获取主板和cpu序列号↓↓↓↓↓↓↓↓
;;字符串每个字符交错组合
;;(BF-Str-Cross "每个字符交" "45678")"每4个5字6符7交8"
(defun BF-Str-Cross(a b / BF-Str->Chrs c d str)
(defun BF-Str->Chrs(str / a c)
(setq a(vl-string->list str))
(while a
(if(< (car a) 129)
(setq c (cons (chr (car a)) c) a (cdr a))
(setq c (cons (strcat (chr (car a)) (chr (cadr a))) c) a (cddr a))
)
)
(reverse c)
)
(setq str "" a (BF-Str->Chrs a) b (BF-Str->Chrs b))
(while (or (car a) (car b))
(setq c (car a) d (car b) str (strcat str (if c c "") (if d d "")) a (cdr a) b (cdr b))
)
str
)
(setq wmi (vlax-create-object "WbemScripting.SWbemLocator"))
(setq meth1 (vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil nil ))
(setq meth2 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_BaseBoard" nil nil nil ));主板
(vlax-for n meth2
;(print (vlax-get n 'name))
(setq Base (vlax-get n 'SerialNumber))
)
(setq meth3 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_Processor" nil nil nil ));CPU
(vlax-for n meth3
;(print (vlax-get n 'name))
(setq Pro (vlax-get n 'ProcessorId))
)
(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))
(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))
;↓↓↓↓↓↓↓↓获取C盘序列号↓↓↓↓↓↓↓↓
;(setq fso (vlax-create-object "Scripting.FileSystemObject"))
;(setq Drives (vlax-get-property fso "Drives") pclst nil uplst nil)
;(vlax-for n drives
; (and
; (= 2 (vlax-get-property n 'DriveType));2 DriveType 本地磁盘
; (setq Path (vlax-get-property n 'Path))
; (setq SerialNumber (vl-princ-to-string (vlax-get-property n 'SerialNumber)))
; (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));电脑盘符路径及序列号表
; )
;)
;(defun test();获取CPU序列号
; (setq wmi (vlax-create-object "WbemScripting.SWbemLocator"))
; (setq meth1 (vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil nil ))
; (setq meth2 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_Processor" nil nil nil ))
; (vlax-for n meth2
; (print (vlax-get n 'name))
; (print (vlax-get n 'ProcessorId))
; )
; (princ)
;)
;(vlax-dump-object meth2)
;(defun test();获取主板序列号
; (setq wmi (vlax-create-object "WbemScripting.SWbemLocator"))
; (setq meth1 (vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil nil ))
; (setq meth2 (vlax-invoke-method meth1 'ExecQuery "Select * from Win32_BaseBoard" nil nil nil ))
; (vlax-for n meth2
; (print (vlax-get n 'name))
; (print (vlax-get n 'SerialNumber))
; )
; (princ)
;)
;↓↓↓↓↓↓↓↓获取UP序列号↓↓↓↓↓↓↓↓
(setq
WMI (vlax-create-object "WbemScripting.SWbemLocator")
meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_LogicalDisk Where DriveType = 2" nil nil nil)
meth3 (vlax-invoke meth1 'ExecQuery "Select * from Win32_DiskDrive Where InterfaceType = 'USB'" nil nil nil)
)
;获取盘符 Name DeviceID
(setq lst nil)
(vlax-for n meth2
(setq lst (cons (substr (vlax-get n 'Name) 1 1) lst))
)
(setq lst1 nil)
(vlax-for n meth3
(setq lst1
(cons
(list
(vlax-get n 'Index)
(car (reverse (all-get-bf_str->lst (vlax-get n 'PNPDeviceID) "\\")))
)
lst1
)
)
)
(foreach obj (list WMI meth1 meth2 meth3) (if obj (vlax-release-object obj)))
(setq lst (vl-sort lst '<) lst1 (all-bf->list_sort lst1 '<) n 0)
(repeat (length lst)
(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))
(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))
(setq n (1+ n))
)
;(foreach x pclst (if (= (car x) "C") (setq pflst (append (list (list "PC" (cadr x))) (reverse uplst)))));盘符表
(setq pflst (append (reverse pclst) (reverse uplst)));上面只有C盘的序列号,如果想要电脑的全盘符序列号,请将此句替代上一句
);↑↑↑↑↑↑↑↑获取盘符序列号结束↑↑↑↑↑↑↑↑
=======================以下是高飞鸟的获取U盘序列号代码=======================
(defun C:test (/ SWbemLocator Service USBDevices Info Name ID)
(setq SWbemLocator (vlax-create-object "WbemScripting.SWbemLocator"))
(setq Service (vlax-invoke SWbemLocator 'ConnectServer))
(setq USBDevices (vlax-invoke Service 'ExecQuery "Select * From Win32_USBHub"))
(vlax-for usb USBDevices
(setq Info (vlax-invoke usb 'GetObjectText_))
(setq Name (vlax-get usb 'Name))
(if (or (wcmatch name "*Storage*") (wcmatch name "*存储*"))
(alert (setq Id (vlax-get usb 'DeviceID)))
)
)
(foreach obj (list USBDevices Service SWbemLocator) (if obj (vlax-release-object obj)))
)