虚拟键值表, 转自微软官方文档 Virtual-Key Codes复制代码
- @echo off
- setlocal enabledelayedexpansion
- REM certutil 在 Windows XP 环境不是原生程序, 需要其他 BASE64 解码器
- certutil -f -decode "%~0" neoGetKey.exe.cab
- expand neoGetKey.exe.cab neoGetKey.exe
- for /L %%a in () do (
- echo;neoGetKey:
- neoGetKey.exe 1 X & rem 超时 1ms, 以十六进制显示返回值
- REM 其他示例用法
- REM neoGetKey.exe 37 & rem 超时 37ms, 不显示返回值
- REM neoGetKey.exe 500 D & rem 超时 500ms, 以十进制显示返回值
- REM neoGetKey.exe 0 & rem 无限等待直到按键按下, 不显示返回值
- REM neoGetKey.exe & rem 无参数运行, 默认超时 1000ms, 并且不显示返回值
- REM neoGetKey.exe X & rem 未设定超时参数, 第一个参数会被视为超时参数, 但参数不是数字, 将按默认超时 1000ms 处理, 并且不显示返回值
- set "err=!errorlevel!"
- if !err! equ 255 (echo; time out) else (
- set /a "k1=err & 0xFF, k2=err>>8 & 0xFF, k3=err>>16 & 0xFF, k4=err>>24 & 0xFF"
- echo; pressed key value is : !k4! + !k3! + !k2! + !k1!
- )
- echo;pause 3s
- ping -n 2 localhost >nul
- )
- exit
- C 源码
- neoGetKey.exe
- aa77dd@163.com @ 20161007_161916
- 获取当前被按下的 按键 值, 支持全键盘按键, 以及鼠标 左 右 中键
- 参数说明:
- neoGetKey.exe [timeout [showMethod]]
- timeout 超时数, 单位 ms, 在运行超过此时间后自动退出, 并返回 255
- 如果 此项是 0 将一直等到检测到有键按下, 程序才会结束并返回键值.
- 如果 此项不存在, 最长将等到默认值 1000ms 后退出
- showMethod 返回值的显示方式, 此项为 D 以十进制显示, 此项为 X 以十六进制显示
- 如果此项不存在, 将不会显示返回值
- 此项 要么不指定, 否则必须和 timeout 同时指定
- ::BEGIN:neoGetKey.C
- #include <Windows.h>
- #include <stdio.h>
- int main(int argc, char** argv) {
- int i, t = 1000, r = 0, kshift = -8;
- char show[3] = "%\0\0";
- if (argc >= 2) t = atoi(argv[1]);
- if (argc >= 3)
- show[1] = (**(argv + 2) >= 'a') ? **(argv + 2) : **(argv + 2) + 'a' - 'A';
- show[1] = ( show[1] == 'x' || show[1] == 'd') ? show[1] : '\0';
- for (i = 0; t == 0 || i < t; i++) {
- int x;
- for (x = 1; x <= 0xFE; x++) {
- if (x == VK_SHIFT || x == VK_CONTROL || x == VK_MENU)
- continue;
- if (GetAsyncKeyState(x) & 0x8000) {
- r |= x << (kshift += 8);
- if (kshift >= 24) {
- if (show[1]) printf(show, r);
- return r;
- }
- }
- }
- if (r != 0) {
- if (show[1]) printf(show, r);
- return r;
- }
- sleep(1);
- }
- if (show[1]) printf(show, 0xFF);
- return 0xFF;
- }
- ::END:neoGetKey.C
- ::neoGetKey.exe.cab.b64
- -----BEGIN CERTIFICATE-----
- TVNDRgAAAACSCQAAAAAAACwAAAAAAAAAAwEBAAEAAAAAAAAASgAAAAEAAQAAGAAAAAAAAAAAR0krdCAAbmVvR2V0S2V5LmV4ZQDuJZB/QAkAGENL7RhtbFPX9dp5DEMTbDFnS1loH5IDASXBgawKbdI5OI+kkFAnwWMbBMckL4m1xLbsZ0hWKGaO1by+Wss2pCGNSfXYD6YhjUooDR/tDJlm0oGWMqSFUbWgwfZSR1q2RZn5GG/n3GcnjlHXTaumIXGVk3u+7jnnnnPuvbYbvzFEcgghDICiEDJC1GEhnz6CAMuePbuMnF5yZdWIpuHKqh3dLj/r9Xm6fM5ett3pdnsEdi/P+gJu1uVma19uYXs9HXxZXt5SU8qGjSOkQbOInKr5+8603ZtEn/OURltJcoEwAmgJYZfDbABgU9EZVD7GrUnFT0ebSpyEOYcyWFUX/xlUFUPmJmxgLeff2OxnPMoEvk+AecfSVEC5mZuY20pbWYdTcKbrwap7XrgBKouV+VTFaWSYU3rLH9GzlO31+xE/9S+KHER7LtUezY0tFZvxUb//+8w9GZ/lsIt3QlMFYmtSsuvKb4iBB5K2fFYi1d+F2u63Vkdg8u16F09YnDHpYCqPibUmRr4NeCipEXrCMWFdSqS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PYEeyOBdAx7TBA9qBs/UQogBeB9k8CqAt7vpk/10gMwLEAR4A+BYhu75DPwS4BMAMkASIBf8FwCwACUAlQAWgAaAHQBtAD0AAkAQ4I3meVtHm/8//GtITUcHdm4NIT8kXJ9LsPk87Tz9Ie7nZIvLnRJ+sKDDCflI28ILdne3090BZ4fra+e9eHS2uHoE3gdr64nD38PzXvSxhjgcXbzQ63S5nb4uP6kC2utw8O59Lp/HTciLKt2Jv7+qP3s6HH5ecDi9XofQ76W8fuJo5yE6xCeJw+XZS8gejcPjTjEHNLhEtZCvde71+ARSqHUK6TXPAO5xEWLWdnb2BPzdyNuk7fT6XG6hE/CvaDt9PKz1aXudPT2edpQf0s6JyZDW7+pyO3sQ/5Dmwt/vbt/G97cI4CT1O2QWbOOat3MNGzeUdfTQdUbg9fr3tfsElVNs++8h014V0PYWrnne4+M9/gk=
- -----END CERTIFICATE-----
Constant/value | Description |
VK_LBUTTON 0x01 | Left mouse button |
VK_RBUTTON 0x02 | Right mouse button |
VK_CANCEL 0x03 | Control-break processing |
VK_MBUTTON 0x04 | Middle mouse button (three-button mouse) |
VK_XBUTTON1 0x05 | X1 mouse button |
VK_XBUTTON2 0x06 | X2 mouse button |
- 0x07 | Undefined |
VK_BACK 0x08 | BACKSPACE key |
VK_TAB 0x09 | TAB key |
- 0x0A-0B | Reserved |
VK_CLEAR 0x0C | CLEAR key |
VK_RETURN 0x0D | ENTER key |
- 0x0E-0F | Undefined |
VK_SHIFT 0x10 | SHIFT key |
VK_CONTROL 0x11 | CTRL key |
VK_MENU 0x12 | ALT key |
VK_PAUSE 0x13 | PAUSE key |
VK_CAPITAL 0x14 | CAPS LOCK key |
VK_KANA 0x15 | IME Kana mode |
VK_HANGUEL 0x15 | IME Hanguel mode (maintained for compatibility; use VK_HANGUL) |
VK_HANGUL 0x15 | IME Hangul mode |
- 0x16 | Undefined |
VK_JUNJA 0x17 | IME Junja mode |
VK_FINAL 0x18 | IME final mode |
VK_HANJA 0x19 | IME Hanja mode |
VK_KANJI 0x19 | IME Kanji mode |
- 0x1A | Undefined |
VK_ESCAPE 0x1B | ESC key |
VK_CONVERT 0x1C | IME convert |
VK_NONCONVERT 0x1D | IME nonconvert |
VK_ACCEPT 0x1E | IME accept |
VK_MODECHANGE 0x1F | IME mode change request |
VK_SPACE 0x20 | SPACEBAR |
VK_PRIOR 0x21 | PAGE UP key |
VK_NEXT 0x22 | PAGE DOWN key |
VK_END 0x23 | END key |
VK_HOME 0x24 | HOME key |
VK_LEFT 0x25 | LEFT ARROW key |
VK_UP 0x26 | UP ARROW key |
VK_RIGHT 0x27 | RIGHT ARROW key |
VK_DOWN 0x28 | DOWN ARROW key |
VK_SELECT 0x29 | SELECT key |
VK_PRINT 0x2A | PRINT key |
VK_EXECUTE 0x2B | EXECUTE key |
VK_SNAPSHOT 0x2C | PRINT SCREEN key |
VK_INSERT 0x2D | INS key |
VK_DELETE 0x2E | DEL key |
VK_HELP 0x2F | HELP key |
0x30 | 0 key |
0x31 | 1 key |
0x32 | 2 key |
0x33 | 3 key |
0x34 | 4 key |
0x35 | 5 key |
0x36 | 6 key |
0x37 | 7 key |
0x38 | 8 key |
0x39 | 9 key |
- 0x3A-40 | Undefined |
0x41 | A key |
0x42 | B key |
0x43 | C key |
0x44 | D key |
0x45 | E key |
0x46 | F key |
0x47 | G key |
0x48 | H key |
0x49 | I key |
0x4A | J key |
0x4B | K key |
0x4C | L key |
0x4D | M key |
0x4E | N key |
0x4F | O key |
0x50 | P key |
0x51 | Q key |
0x52 | R key |
0x53 | S key |
0x54 | T key |
0x55 | U key |
0x56 | V key |
0x57 | W key |
0x58 | X key |
0x59 | Y key |
0x5A | Z key |
VK_LWIN 0x5B | Left Windows key (Natural keyboard) |
VK_RWIN 0x5C | Right Windows key (Natural keyboard) |
VK_APPS 0x5D | Applications key (Natural keyboard) |
- 0x5E | Reserved |
VK_SLEEP 0x5F | Computer Sleep key |
VK_NUMPAD0 0x60 | Numeric keypad 0 key |
VK_NUMPAD1 0x61 | Numeric keypad 1 key |
VK_NUMPAD2 0x62 | Numeric keypad 2 key |
VK_NUMPAD3 0x63 | Numeric keypad 3 key |
VK_NUMPAD4 0x64 | Numeric keypad 4 key |
VK_NUMPAD5 0x65 | Numeric keypad 5 key |
VK_NUMPAD6 0x66 | Numeric keypad 6 key |
VK_NUMPAD7 0x67 | Numeric keypad 7 key |
VK_NUMPAD8 0x68 | Numeric keypad 8 key |
VK_NUMPAD9 0x69 | Numeric keypad 9 key |
VK_MULTIPLY 0x6A | Multiply key |
VK_ADD 0x6B | Add key |
VK_SEPARATOR 0x6C | Separator key |
VK_SUBTRACT 0x6D | Subtract key |
VK_DECIMAL 0x6E | Decimal key |
VK_DIVIDE 0x6F | Divide key |
VK_F1 0x70 | F1 key |
VK_F2 0x71 | F2 key |
VK_F3 0x72 | F3 key |
VK_F4 0x73 | F4 key |
VK_F5 0x74 | F5 key |
VK_F6 0x75 | F6 key |
VK_F7 0x76 | F7 key |
VK_F8 0x77 | F8 key |
VK_F9 0x78 | F9 key |
VK_F10 0x79 | F10 key |
VK_F11 0x7A | F11 key |
VK_F12 0x7B | F12 key |
VK_F13 0x7C | F13 key |
VK_F14 0x7D | F14 key |
VK_F15 0x7E | F15 key |
VK_F16 0x7F | F16 key |
VK_F17 0x80 | F17 key |
VK_F18 0x81 | F18 key |
VK_F19 0x82 | F19 key |
VK_F20 0x83 | F20 key |
VK_F21 0x84 | F21 key |
VK_F22 0x85 | F22 key |
VK_F23 0x86 | F23 key |
VK_F24 0x87 | F24 key |
- 0x88-8F | Unassigned |
VK_NUMLOCK 0x90 | NUM LOCK key |
VK_SCROLL 0x91 | SCROLL LOCK key |
0x92-96 | OEM specific |
- 0x97-9F | Unassigned |
VK_LSHIFT 0xA0 | Left SHIFT key |
VK_RSHIFT 0xA1 | Right SHIFT key |
VK_LCONTROL 0xA2 | Left CONTROL key |
VK_RCONTROL 0xA3 | Right CONTROL key |
VK_LMENU 0xA4 | Left MENU key |
VK_RMENU 0xA5 | Right MENU key |
VK_BROWSER_BACK 0xA6 | Browser Back key |
VK_BROWSER_FORWARD 0xA7 | Browser Forward key |
VK_BROWSER_REFRESH 0xA8 | Browser Refresh key |
VK_BROWSER_STOP 0xA9 | Browser Stop key |
VK_BROWSER_SEARCH 0xAA | Browser Search key |
VK_BROWSER_FAVORITES 0xAB | Browser Favorites key |
VK_BROWSER_HOME 0xAC | Browser Start and Home key |
VK_VOLUME_MUTE 0xAD | Volume Mute key |
VK_VOLUME_DOWN 0xAE | Volume Down key |
VK_VOLUME_UP 0xAF | Volume Up key |
VK_MEDIA_NEXT_TRACK 0xB0 | Next Track key |
VK_MEDIA_PREV_TRACK 0xB1 | Previous Track key |
VK_MEDIA_STOP 0xB2 | Stop Media key |
VK_MEDIA_PLAY_PAUSE 0xB3 | Play/Pause Media key |
VK_LAUNCH_MAIL 0xB4 | Start Mail key |
VK_LAUNCH_MEDIA_SELECT 0xB5 | Select Media key |
VK_LAUNCH_APP1 0xB6 | Start Application 1 key |
VK_LAUNCH_APP2 0xB7 | Start Application 2 key |
- 0xB8-B9 | Reserved |
VK_OEM_1 0xBA | Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key |
VK_OEM_PLUS 0xBB | For any country/region, the '+' key |
VK_OEM_COMMA 0xBC | For any country/region, the ',' key |
VK_OEM_MINUS 0xBD | For any country/region, the '-' key |
VK_OEM_PERIOD 0xBE | For any country/region, the '.' key |
VK_OEM_2 0xBF | Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key |
VK_OEM_3 0xC0 | Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key |
- 0xC1-D7 | Reserved |
- 0xD8-DA | Unassigned |
VK_OEM_4 0xDB | Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key |
VK_OEM_5 0xDC | Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key |
VK_OEM_6 0xDD | Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key |
VK_OEM_7 0xDE | Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key |
VK_OEM_8 0xDF | Used for miscellaneous characters; it can vary by keyboard. |
- 0xE0 | Reserved |
0xE1 | OEM specific |
VK_OEM_102 0xE2 | Either the angle bracket key or the backslash key on the RT 102-key keyboard |
0xE3-E4 | OEM specific |
VK_PROCESSKEY 0xE5 | IME PROCESS key |
0xE6 | OEM specific |
VK_PACKET 0xE7 | Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in |
- 0xE8 | Unassigned |
0xE9-F5 | OEM specific |
VK_ATTN 0xF6 | Attn key |
VK_CRSEL 0xF7 | CrSel key |
VK_EXSEL 0xF8 | ExSel key |
VK_EREOF 0xF9 | Erase EOF key |
VK_PLAY 0xFA | Play key |
VK_ZOOM 0xFB | Zoom key |
VK_NONAME 0xFC | Reserved |
VK_PA1 0xFD | PA1 key |
VK_OEM_CLEAR 0xFE | Clear key |
复制代码
- 输入长度 = 8504
- 输出长度 = 6144
- CertUtil: -decode 命令成功完成。
- ff time out
- ff time out
- ff time out
- ff time out
- 2 pressed key value is : 2
- 2 pressed key value is : 2
- 2 pressed key value is : 2
- 2 pressed key value is : 2
- 2 pressed key value is : 2
- 2 pressed key value is : 2
- ff time out
- ff time out
- 1 pressed key value is : 1
- 1 pressed key value is : 1
- 1 pressed key value is : 1
- 1 pressed key value is : 1
- ff time out
- ff time out
- ff time out
基本思路:复制代码
- $20$1410@26144@U$@@2814@5B$@@2aUQ@i@|$10KFAAAChQAAAoUAAA$11kJCQ$13CQkJ$14A|TVqQAAM$144E$144//8AALg$149Q$1410$14bg$1454fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJ$149BQRQAATAEFAJOHz1c$14aOAADwMLAQI4AAw$144U$145gAAIBI$144Q$144I$@284Q$145gAAB$145E$144E$14aBg$144BAAAUV0AAAM$146CAAAB$146EAAAE$148B$14gBQAABAAw$204$147C50ZXh0$144FAo$144Q$144D$145Q$14iGAAAGAuZGF0YQAAAE$146I$145I$144Q$14iBAAADALnJkYXRhAADw$145D$145C$144Eg$14iQAAAQC5ic3M$145s$@28uIAAAMAuaWRhdGEAAEAD$144U$145Q$144U$14iBAAAD$20g$14mFWJ5YPsGIld+ItVCDHbiXX8iwIx9osAPZEAAMB3Qz2NAADAclu+AQAAAMcEJAg$144xwIlEJATopAgAAIP4AXRshcB0KscEJAgAAAD/0Lv/////idiLdfyLXfiJ7F3CBAA9kwAAwHS9PZQAAMB0u4nYi3X8i134iexdwgQAjXYAPQUAAMB16McEJAs$144x9ol0JAToRwgAAIP4AXQ0hcB0zccEJAsAAAD/0OuhxwQkC$144LsB$144iVwkBOgeCAAAhfZ0iOhFAwAAu//////rgccEJAsAAAC5AQAAALv/////iUwkBOj0BwAA6WL////rDZ$134BVieVTg+wkjV34xwQkABBAAOiKCAAAg+wE6PICAADHRfg$145uABAQACNVfSJXCQQiw0AIEAAiUQkBIlUJAiJTCQMxwQkBEBAAOjBBwAAoRBAQACFwHRYoxAgQACLFSRRQACF0g+FiwAAAIP64HQgoRBAQACJRCQEix0kUUAAi0swiQwk6HYHAACLFSRRQACD+sB0G4sdEEBAAIlcJASLDSRRQACLUVCJFCToUAcAAOg7BwAAix0QIEAAiRjoHgIAAIPk8OgGBwAAiwiJTCQIixUAQEAAiVQkBKEEQEAAiQQk6KkAAACJw+jSBgAAiRwk6LoHAACJRCQEixUkUUAAi0IQiQQk6PUGAACLFSRRQADpVf///412AI28Jw$144BVieWD7AjHBCQB$144/xUcUUAA6Mj+//+QjbQm$145FWJ5YPsCMcEJAIAAAD/FRxRQADoqP7//5CNtCY$145VYsNNFFAAInlXf/hjXQmAFWLDShRQACJ5V3/4ZCQkJBVieVd6VcDAACQkJCQkJCQVbgQ$144ieVXVlOD7AyLXQiLdQyD5PDodAUAAO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o$145DkCZnByaW50ZgAAAD8CZnJlZQAAcgJtYWxsb2M$145fwJwcmludGY$145kAJzaWduYWw$1453gBHZXRBc3luY0tleVN0YXRl$@26F$144BQ$@26FAAAEtFUk5FTDMyLmRsb$146UUAAAbXN2Y3J0LmRsbAAA$105KFAAAChQAABtc3ZjcnQuZGxsAAA8UAAAVVNFUjMyLmRsb$207$147
复制代码
- 1>1/* :
- @echo off
- set "Input=原始文件.txt"
- set "Output=压缩后.txt"
- cscript /nologo /e:jscript %0 <"%Input%" 2>"%Output%"
- pause
- exit /b
- */
- var DEBUG = true
- var maxdeep = 3
- var base64 = WSH.StdIn.ReadAll()
- var map = []
- var len = base64.length
- var text = compress(base64.replace(/\r\n/gm,''), maxdeep)
- WSH.StdOut.WriteLine('')
- WSH.StdOut.WriteLine(text)
- WSH.StdOut.WriteLine('')
- WSH.StdOut.WriteLine('#Before = #' + len)
- WSH.StdOut.WriteLine('#After = #' + text.length)
- WSH.StdErr.WriteLine(text)
- function compress(text, deep){
- deep = deep || 3
- if(deep>36)deep = 36
- var from_list = [
- [
- {from:'#', mode:'#'},
- {from:'$', mode:'#'},
- {from:'@', mode:'#'},
- {from:'|', mode:'#'}
- ]
- ]
- text = convolution(text,from_list[0],0)
- var len = text.length
- for(var i=1; i<=deep; i++){
- var $len = text.length
- var from_arr = sample(text, i)
- from_list.push(from_arr)
- text = convolution(text,from_arr,i)
- text = getHead(from_arr,i) + text
- if(DEBUG)WSH.Echo('\r\n'+len +' -> '+$len+' -> '+text.length+'\r\n')
- }
- return text.replace(/^\|+/,'').replace(/\|+/,'|')
- function getHead(from_arr){
- if(!from_arr.length)return ''
- var head=''
- for(var i=0; i<from_arr.length; i++){
- switch(from_arr[i].mode){
- case '$':
- head+='$'+from_arr[i].map+from_arr[i].from
- break
- case '@':
- head+='@'+from_arr[i].map+from_arr[i].from+from_arr[i].list
- break
- }
- }
- head+='|'
- return head
- }
- function sample(text, index_deep){
- var from_map_repeat = {}
- var from_map_like = {}
- var from_map_like_stack = []
- if(index_deep==1){
- var pattern = /(.+?)\1{2,36}/gm
- } else {
- var pattern = /(.+?)\1{2,36}|(..+)(?:[^@]{1,5}?\2)+/gm
- }
- pattern.lastIndex = 0
- while((matches=pattern.exec(text)) != null){
- if(DEBUG)WSH.StdOut.Write('\r\t\t\t\rpattern.lastIndex = ' + pattern.lastIndex)
- if(matches[1]){
- checkrepeat(pattern,matches[0],matches[1])
- } else {
- checklike(pattern,matches[0],matches[2])
- }
- }
- function checkrepeat(pattern,str,$1){
- var cutoff = str.length - $1.length - 7
- if('$'+$1 in from_map_repeat){
- cutoff = str.length - 4
- from_map_repeat['$'+$1].cutoff += cutoff
- } else {
- cutoff = str.length - $1.length - 7
- from_map_repeat['$'+$1] = {from:$1, mode:'$', cutoff:cutoff}
- }
- from_map_like_stack = []
- }
- function checklike(pattern,str,$2){
- var $$2 = $2.replace(/\W/gm,'\\$&')
- var nextIndex = $2.length<2 ? pattern.lastIndex : pattern.lastIndex - str.length + 1
- str = str.replace(
- new RegExp('('+$$2+')(?='+$$2+')$','gm'),
- function(repeat){pattern.lastIndex-=repeat.length;return ''}
- )
- var list = convolution(str,from_list[0],index_deep).replace(new RegExp($2.replace(/\W/gm,'\\$&'),'gm'),'@')
- var cutoff
- if(str in from_map_like){
- cutoff = str.length - 4
- from_map_like[str].cutoff += str.length - 4
- } else {
- str=list.replace(/@/g,$2.replace(/\W/g,'\\$&'))
- cutoff = str.length - list.length - 7
- from_map_like[str] = {from:$2, mode:'@', str:str, list:list, cutoff:cutoff}
- }
- from_map_like[str].$length = $2.length+list.substr(1).search('@')
- var thisstack = {lastIndex:pattern.lastIndex, $length:$2.length+list.substr(1).search('@'), flag:true, cutoff:cutoff, ref:from_map_like[str]}
- from_map_like_stack.push(thisstack)
- for(var i=from_map_like_stack.length;i--;){
- var stack = from_map_like_stack[i]
- var endof = stack.lastIndex+stack.$length
- if(endof<pattern.lastIndex){
- from_map_like_stack.splice(i+1)
- break
- } else if(stack.cutoff > cutoff){
- if(stack.ref.flag)stack.ref.cutoff -= cutoff
- stack.ref.flag = false
- } else {
- thisstack.ref.cutoff -= cutoff
- thisstack.flag = false
- }
- }
- pattern.lastIndex = nextIndex
- return str
- }
- var from_arr = []
- for(var from in from_map_repeat)from_arr.push(from_map_repeat[from])
- for(var from in from_map_like)from_arr.push(from_map_like[from])
- for(var i=from_arr.length;i--;)if(from_arr[i].cutoff<2)from_arr.splice(i,1)
- from_arr = from_arr.sort(
- function(a,b){
- return b.cutoff - a.cutoff
- }
- ).sort(
- function(a,b){return b.from.length - a.from.length}
- )
- if(DEBUG){
- WSH.Echo('')
- WSH.Echo('')
- WSH.Echo('Deep = '+ index_deep)
- for(var i in from_arr){
- WSH.Echo(from_arr[i].from+'->'+ from_arr[i].mode+index_deep+'(?)')
- for(var j in from_arr[i]){
- WSH.Echo(j + '\t= '+ from_arr[i][j])
- }
- WSH.Echo('')
- }
- }
- return from_arr
- }
- function convolution(text,from_arr,index_deep){
- for(var i=0,count=0; i<from_arr.length; i++){
- from_arr[i].done = false
- switch(from_arr[i].mode){
- case '$':
- from_arr[i].map = index_deep.toString(36) + count.toString(36)
- text = text.replace(
- new RegExp('('+(from_arr[i].from.replace(/\W/gm,'\\$&'))+'){4,36}','gm'),
- function(str,from){count++;from_arr[i].done=true;return '$'+from_arr[i].map+parseInt(str.length / from.length).toString(36)}
- )
- break
- case '@':
- from_arr[i].map = index_deep.toString(36) + count.toString(36)
- text = text.replace(
- new RegExp(from_arr[i].str.replace(/\W/gm,'\\$&'),'gm'),
- function(str,from){count++;from_arr[i].done=true;return '@'+from_arr[i].map}
- )
- break
- case '#':
- text = text.replace(
- new RegExp(from_arr[i].from.replace(/\W/gm,'\\$&'),'gm'),
- function(str,from){count++;from_arr[i].done=true;return '#'+from_arr[i].map}
- )
- break
- }
- if(count>=36){
- from_arr.splice(i)
- break
- }
- }
- for(var i=from_arr.length;i--;){
- if(!from_arr[i].done)from_arr.splice(i,1)
- }
- return text
- }
- }
压缩后是 345 字节:复制代码
- TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEFAJOHz1cAAAAAAAAAAOAADwMLAQI4AAwAAAAUAAAAAgAAIBIAAAAQAAAAIAAAAABAAAAQAAAAAgAABAAAAAEAAAAEAAAAAAAAAABgAAAABAAAUV0AAAMAAAAAACAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAABQAABAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAAFAoAAAAQAAAADAAAAAQAAAAAAAAAAAAAAAAAAGAAAGAuZGF0YQAAAEAAAAAAIAAA
目测如果不引入更多可用字符,剩余的优化空间大约在 5% 左右。复制代码
- $20$1010|$10A|TVqQAAM$104E$104//8AALg$109Q$1010$10bg$1054fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJ$109BQRQAATAEFAJOHz1c$10aOAADwMLAQI4AAw$104U$105gAAIBI$104Q$104I$105B$104Q$105gAAB$105E$104E$10aBg$104BAAAUV0AAAM$106CAAAB$106EAAAE$108B$10gBQAABAAw$204$107C50ZXh0$104FAo$104Q$104D$105Q$10iGAAAGAuZGF0YQAAAE$106IAAA
C 源码复制代码
- -----BEGIN CERTIFICATE-----
- TVNDRgAAAACSCQAAAAAAACwAAAAAAAAAAwEBAAEAAAAAAAAASgAAAAEAAQAAGAAA
- AAAAAAAAR0krdCAAbmVvR2V0S2V5LmV4ZQDuJZ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4CT1O2QWbOOat3MNGzeUdfTQdUbg9fr3tfsElVNs++8h014V0PYWrnne4+M9
- /gk=
- -----END CERTIFICATE-----
复制代码
- #include <Windows.h>
- #include <stdio.h>
- int main(int argc, char** argv) {
- int i, t = 1000, r = 0, kshift = -8;
- char show[3] = "%\0\0";
- if (argc >= 2) t = atoi(argv[1]);
- if (argc >= 3)
- show[1] = (**(argv + 2) >= 'a') ? **(argv + 2) : **(argv + 2) + 'a' - 'A';
- show[1] = ( show[1] == 'x' || show[1] == 'd') ? show[1] : '\0';
- for (i = 0; t == 0 || i < t; i++) {
- int x;
- for (x = 1; x <= 0xFE; x++) {
- if (x == VK_SHIFT || x == VK_CONTROL || x == VK_MENU)
- continue;
- if (GetAsyncKeyState(x) & 0x8000) {
- r |= x << (kshift += 8);
- if (kshift >= 24) {
- if (show[1]) printf(show, r);
- return r;
- }
- }
- }
- if (r != 0) {
- if (show[1]) printf(show, r);
- return r;
- }
- sleep(1);
- }
- if (show[1]) printf(show, 0xFF);
- return 0xFF;
- }
Base64解压机复制代码
- @echo off
- REM 原始数据
- set "LINE=TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEFAJOHz1cAAAAAAAAAAOAADwMLAQI4AAwAAAAUAAAAAgAAIBIAAAAQAAAAIAAAAABAAAAQAAAAAgAABAAAAAEAAAAEAAAAAAAAAABgAAAABAAAUV0AAAMAAAAAACAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAABQAABAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAAFAoAAAAQAAAADAAAAAQAAAAAAAAAAAAAAAAAAGAAAGAuZGF0YQAAAEAAAAAAIAAA"
- REM 压缩数据
- setlocal enabledelayedexpansion
- for /l %%i in (1,1,10000) do (
- if "!LINE:~0,1!"=="A" (
- set/a i+=1
- ) else (
- if !i! neq 0 (
- set M=512
- for %%Z in (@,-,#,$,_,},{,],[,A) do (
- if !i! geq !M! (
- set "S=!S!%%Z"
- set/a "i-=M"
- )
- set/a "M>>=1"
- )
- )
- if "!LINE!"=="" (echo !S!>压缩.txt&exit) else (set "S=!S!!LINE:~0,1!")
- )
- set "LINE=!LINE:~1!"
- )
复制代码
- REM 解压数据
- set/p LINE=<压缩.txt
- setlocal enabledelayedexpansion
- set "Z=A"&(for %%Z in ([,],{,},_,$,#,-,@) do (set "Z=!Z!!Z!"&for %%S in (!Z!) do (set "LINE=!LINE:%%Z=%%S!")))&echo !LINE!>解压.txt
分别用@,-,#,$,_,},{,],[,.表示512个A、256个A、128个A、、、、、1个A,则化为:复制代码
- TVqQAAMAAAAEQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAAQAAMAAAA
然后继续迭代 用@,-,#,$,_,},{,],[,.表示512个、256个、128个、、、、、1个Q[M]则化为:复制代码
- TVqQ[M]EQ[M]Q[M]Q[M]Q[M]Q[M]Q[M]Q[M]Q[M]Q[M]Q[M]Q[M]Q[M]
用:冒号表示标签切换。化为可解码的格式复制代码
- TVq.E{]
如此就实现了用14个字符去表示108个字符的base64字符串。我发现没有任何算法有这个压缩率高。复制代码
- TVq.E{]:Q[M]:A
其中:[.;1中:[.表示要替换为的标签,分号;1表示只替换一级权签,也就是只替换.,之后的:A表示在上次替换完后再次替换所有权签为A。复制代码
- }[EF.B.C.D.EF.G.HH]I:[.;1:A
复制代码
- @echo off & setlocal enableDelayedExpansion
- >AllHexCode.txt (
- for %%a in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do ^
- for %%b in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do ^
- for %%c in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do ^
- for %%d in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do (
- set "HEX=##%%a%%b%%c%%d"
- set "HEX=!HEX:#0000=!"
- set "HEX=!HEX:#000=!"
- set "HEX=!HEX:#00=!"
- set "HEX=!HEX:#0=!"
- set "HEX=!HEX:#=!"
- title !HEX! / FFFF
- <nul set /p "=!HEX!"
- )
- )
- for %%a in (AllHexCode.txt) do echo;[1,63335]范围内所有整数HEX编码总长:%%~za
- pause
- exit /b
欢迎光临 批处理之家 (http://bathome.net./) | Powered by Discuz! 7.2 |