LoginSignup
7
6

More than 5 years have passed since last update.

Windows10でバイナリ<->HEXテキスト変換

Posted at

はじめに

強制スクリーンセーバ設定されている会社にて、スクリーンセーバの抑制する方法を色々と考えています。
1. スクリーンセーバの起動を抑制する - アセンブラ バージョン
2. スクリーンセーバの起動を抑制する - Arduino Pro Micro(の互換機)を使用
3. スクリーンセーバの起動を抑制する - vbsバージョン
4. スクリーンセーバの起動を抑制する - mpgバージョン

上記1と4は会社にファイルを持ち込む必要がありました。Windows10でBIN<->HEX変換できるコマンドを発見しましたので、下記活用したいと思います。

コマンド

CERTUTILコマンドを使用します。

HEXエンコード

オプション -f -encodehexを指定します。

DOS:CERTUTIL ENCODE
certutil -f -encodehex keycode.exe keycode.hex 4

image.png

BINデコード

オプション -f -decodehexを指定します。

DOS:CERTUTIL DECODE
certutil -f -decodehex keycode.hex keycode.exe 4

image.png

最後の数値はテキストファイルフォーマットのオプションになります。
CryptBinaryToStringA function

オプション

変数 数値 意味
CRYPT_STRING_BASE64HEADER 0x00000000 Base64, with certificate beginning and ending headers.
CRYPT_STRING_BASE64 0x00000001 Base64, without headers.
CRYPT_STRING_BINARY 0x00000002 Pure binary copy.
CRYPT_STRING_BASE64REQUESTHEADER 0x00000003 Base64, with request beginning and ending headers.
CRYPT_STRING_HEX 0x00000004 Hexadecimal only.
CRYPT_STRING_HEXASCII 0x00000005 Hexadecimal, with ASCII character display.
CRYPT_STRING_BASE64X509CRLHEADER 0x00000009 Base64, with X.509 CRL beginning and ending headers.
CRYPT_STRING_HEXADDR 0x0000000a Hexadecimal, with address display.
CRYPT_STRING_HEXASCIIADDR 0x0000000b Hexadecimal, with ASCII character and address display.
CRYPT_STRING_HEXRAW 0x0000000c A raw hexadecimal string.
CRYPT_STRING_STRICT 0x20000000 Enforce strict decoding of ASN.1 text formats. Some ASN.1 binary BLOBS can have the first few bytes of the BLOB incorrectly interpreted as Base64 text. In this case, the rest of the text is ignored. Use this flag to enforce complete decoding of the BLOB.
CRYPT_STRING_NOCRLF 0x40000000 Do not append any new line characters to the encoded string. The default behavior is to use a carriage return/line feed (CR/LF) pair (0x0D/0x0A) to represent a new line.
CRYPT_STRING_NOCR 0x80000000 Only use the line feed (LF) character (0x0A) for a new line. The default behavior is to use a CR/LF pair (0x0D/0x0A) to represent a new line.

HEXコード

1. スクリーンセーバの起動を抑制する - アセンブラ バージョンの実行ファイル

オプションは4です。

KEYCODE.EXE
4d 5a 90 00 03 00 00 00  04 00 00 00 ff ff 00 00
b8 00 00 00 00 00 00 00  40 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 b0 00 00 00
0e 1f ba 0e 00 b4 09 cd  21 b8 01 4c cd 21 54 68
69 73 20 70 72 6f 67 72  61 6d 20 63 61 6e 6e 6f
74 20 62 65 20 72 75 6e  20 69 6e 20 44 4f 53 20
6d 6f 64 65 2e 0d 0d 0a  24 00 00 00 00 00 00 00
5d f3 dc fd 19 92 b2 ae  19 92 b2 ae 19 92 b2 ae
97 8d a1 ae 10 92 b2 ae  e5 b2 a0 ae 18 92 b2 ae
52 69 63 68 19 92 b2 ae  00 00 00 00 00 00 00 00
50 45 00 00 4c 01 02 00  da a1 50 5b 00 00 00 00
00 00 00 00 e0 00 0f 01  0b 01 05 0c 00 02 00 00
00 02 00 00 00 00 00 00  18 10 00 00 00 10 00 00
00 20 00 00 00 00 40 00  00 10 00 00 00 02 00 00
04 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00
00 30 00 00 00 02 00 00  00 00 00 00 02 00 00 00
00 00 10 00 00 10 00 00  00 00 10 00 00 10 00 00
00 00 00 00 10 00 00 00  00 00 00 00 00 00 00 00
9c 10 00 00 3c 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 10 00 00 18 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  2e 74 65 78 74 00 00 00
3c 01 00 00 00 10 00 00  00 02 00 00 00 02 00 00
00 00 00 00 00 00 00 00  00 00 00 00 20 00 00 60
2e 64 61 74 61 00 00 00  49 00 00 00 00 20 00 00
00 02 00 00 00 04 00 00  00 00 00 00 00 00 00 00
00 00 00 00 40 00 00 c0  00 00 00 00 00 00 00 00
26 11 00 00 18 11 00 00  00 00 00 00 fe 10 00 00
f0 10 00 00 00 00 00 00  6a 40 68 02 20 40 00 68
12 20 40 00 6a 00 e8 59  00 00 00 e8 2c 00 00 00
68 a0 68 06 00 e8 5c 00  00 00 66 ff 0d 00 20 40
00 75 e8 6a 10 68 02 20  40 00 68 2e 20 40 00 6a
00 e8 2e 00 00 00 50 e8  34 00 00 00 6a 00 6a 00
6a 00 68 a0 00 00 00 e8  1e 00 00 00 6a 64 e8 23
00 00 00 6a 00 6a 02 6a  00 68 a0 00 00 00 e8 07
00 00 00 c3 ff 25 10 10  40 00 ff 25 0c 10 40 00
ff 25 04 10 40 00 ff 25  00 10 40 00 e4 10 00 00
00 00 00 00 00 00 00 00  0c 11 00 00 0c 10 00 00
d8 10 00 00 00 00 00 00  00 00 00 00 2e 11 00 00
00 10 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  26 11 00 00 18 11 00 00
00 00 00 00 fe 10 00 00  f0 10 00 00 00 00 00 00
b1 01 4d 65 73 73 61 67  65 42 6f 78 41 00 7b 02
6b 65 79 62 64 5f 65 76  65 6e 74 00 75 73 65 72
33 32 2e 64 6c 6c 00 00  9b 00 45 78 69 74 50 72
6f 63 65 73 73 00 b7 02  53 6c 65 65 70 00 6b 65
72 6e 65 6c 33 32 2e 64  6c 6c 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
23 00 41 6e 74 69 53 63  72 65 65 6e 53 61 76 65
72 00 41 63 74 69 76 61  74 65 20 41 6e 74 69 2d
53 63 72 65 65 6e 20 53  61 76 65 72 2e 00 53 74
6f 70 70 65 64 20 41 6e  74 69 2d 53 63 72 65 65
6e 20 53 61 76 65 72 2e  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00

おわりに

これでこっそり会社にファイルを持ち込めるようになりました。

2018/08/19 Ikeda

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6