The method of embedding EXE file in batch processing (BAT) by using Certutil.exe _dos/bat

Source: Internet
Author: User
Tags base64 hex code

An easy way to embed executable files in batch processing (BAT) or binary files of various media and pictures with Certutil.exe!

In fact, using Certutil.exe to encode binary files (including various files, EXE executables, pictures, sounds, mp3) Base64 encoded as text, you can embed these files into batch code.

# # #有什么用? :
Batch processing, for example, often relies on other command-line tools to automate scripts, and if the tools are translated into text and embedded in the code, the available code can be sent directly to the web. You do not need to upload attachments.

# # #缺点:
Base64 encoded text is 1/3 longer than the original file, plus if the dependent file size is large, the converted text content will be very long. This shortcoming affects the practicality of this play.
There is no certutil this tool in XP, which affects the scope of application.
If you rely on multiple files, you need to package the EXE self-extracting file with WinRAR and then encode it.

Certutil is a certificate tool, a very rich feature, very many parameters, I only intercept and base64 encoding-related Help information:

"
c:\users\administrator>certutil.exe/?

" Verb:
 -dump    --Dump configuration information or file
 -asn-    -parsing ASN.1 file

 -decodehex  -decoding hexadecimal encoded file
 -decode   -decoding BASE64 encoded file
 -encode   --encode file as Base64
...

# #用法如下:
# # #第一步, execute the command code file in cmd First, I use a small mp3 file demo:
' '
E:\Game\New heroes3\mp3>certutil-encode Hello.mp3 Hi.bat
'
# # #第二步, after the command line finishes, get a hi.bat, with Notepad to see a large string of base64 letters.
Do not modify the contents of the file, just write your own batch code in the header of the file, and certutil-decode the text to a file,
If you save the following code as Xx.bat and run, you should be able to hear the MP3 file's voice.

@echo off Certutil-decode "%~f0" Hello.mp3 start Hello.mp3 exit/b 1-----BEGIN Certificate-----/+mgxaaucqzga0yyalhae
MECCEECZNO7U7VGIIII/7U7U6INXE57V+J+IFOBIZ4G Cdgylhmlv+oh35qep5tqb8//8hdgnb/g+d5d/8oc8v+ub+gjr3bcjw+xd/8u8eea Qaaucgucgud/4ylecrwrptjfjuaaofaofae997lwj35twn+wfemd/m3tcjikauh6 tho2rqka0mq986vujkj97ehhiraoifaakdh4y9/0qdb/ 8UTJP/NL/OH7W+GO9H63/8UVYYGEANA26X/FY2GTJAX/4YDEDHED7U4FXYGDHS/MGECXZNOHXH2850FA0VV8 7ixf0cit7UuX60Mchn/Re+
Lujdvexllze60ouz/sv///t/nvpaliarizxxvxf/83/dzngrkrmk6v/rr2vcebkmxsptrrs/1hqf/jisqlfzrm/j44rn4bj/rrw02+aael 8jcepgncel9hcemhxcd/pnitpuvbka2kmaii6dpt9xrovun///r/dws0uwmdwzai db0frhplf5xuxr1tdbqz9afkybqahig2n388oiijitv9l/ /jimqqgalw5x5sbjog or3puwsaualjkf+bifkv2lbp7vbtyjho/1chdnf/hgvyse0jfrmime9gp79eyf7f//// 3KOC5ZGY4QQQMCAEHO1DPPXI6WMZMO4AD7HF6IEGASPG3AB9SQUD/+MIXASW C771/IHFVOM39DV+YSOHCFKUPBMU+GSHYFEFNDDCTCIAF5POYP +ahnetrkvzixn9 powa9f/2nd7hawcwqixlr0d15e9x2r7///2pedettijkdmrg3d4hcam0ko/2jdkg YFIG/+MgxA0XS7Lh9lHE+7Hh/5QMH/ Zaibl/opitv9qqx23u44c3+p4EBUUPXGJL/KI//IFBP9F+5FB/T/KQOPWR2SZBART/P/6F/9V+JFNJMQQIMS6KWXGVXQVJCBJT 1yziah2kov5gvip/4ylechrzavv+ckrcmix/ dgrf5wmcaw/3k/9smf+iobznoqp+ qfmka0h0az6osadpshwubcqdsfnhtv/8ykee8ffvjdzwe7/w1zmxvlkblhse9inq Ep/ zescfzexjvxsbiewhqppeyp3/4ydefbqzlsgkaxkqiwvr2besnjnmdgwnza7r iktwdhnyqgererjputsxjtt2e2nndmh589zfkamh4kig5h/// /AUJK////9VNQHV//3/fcfj3lceehvp7kxqkjnfddsqogetipy2wp/jisqefecg1b5stibwkhommton JHAU6sNhJ9VA0VGgJbEstsSq/+
Zg8rq6w2gjx14amdv7p/sm7s/vlu/p/e8hbbbz/myx5iugggyx1cxinsdgvqq+hrasb9hjdi0cioclm2h3yxcec//jimqpfhdexb9q
Kadmbezdo1aihav2rfoqxorhvigz7xxezcxdwjjkbzdtrwawbtiufbotrzptsobk 6nzfkdformjkrrt1p39vw9ascwqipti09rkru1zxuigkqjb8b0irq8nies/4/+mi xdixkxakazhaakk3f/n/c8ssir0vfmymihuyyqtcrk// VSD1UENTPT2/7/P/3VRF Z+VOV91A1QD3SESIYYVJQPFTAKLXCSFN86WVZZVMRJEYQJNRYYFYZPZBSWZNJFWG aOrQVQOu/+ mgxc8fw2j8y5haagnvhmj/yq9dkagkizvdmn//gdyjxxvivyzpvy///u7hujmruyzsqwzsqx///+cqipc050k5tszardxkrw3///// AXNSTWRWUCOKLITX//4leuxwccakafcfby7/4ylecxrq9kqxybaagirkkmrsx1q1///kxk3q3//ll////KX//0No/KXL//MBMBUPXL/5S0MZKMBKUU1DVLLKWHHQWGOKNEJYKUEQCLFRO8GV 8spmqu1fmy45ni4xqqqqqqqqqqqqqqr/
4YDEFQAAA0GAAAAAQQQQQQQQQQQQQQQQ QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==-----End Certificate-----

August 31, 2016 22:52:03 Codegay
The Windows Server x64 test works. XP without certutil, I heard that more than 2000 of the system with this command tool. Students using other systems, if you can please test the feedback is feasible.

Extended Reading
The Certutil-decode/encode Base64/hex strings. Print symbols by HEX code. 》
Using certutil to implement Hex2bin and BASE64 encryption and decryption http://www.jb51.net/article/93966.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.