Skip to content

Commit 3b6fac4

Browse files
committed
v1.2: Python 3, Auto compress exes, Quicker, Tweaked output & bug fixes
...also lazy input support!
1 parent 4f4277e commit 3b6fac4

File tree

2 files changed

+207
-133
lines changed

2 files changed

+207
-133
lines changed

README.md

+42-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# exe2hex
22

3-
Inline file transfer method using debug and/or PowerShell.
3+
Inline file transfer method using `debug.exe` and/or PowerShell.
44

55
- - -
66

@@ -13,50 +13,65 @@ Restores using `DEBUG.exe` (BATch - x86) and/or PowerShell (PoSh - x86/x64).
1313

1414
```Binary EXE -> ASCII text -> Binary EXE```
1515

16+
![](https://i.imgur.com/kMcqHNq.png)
17+
1618
- - -
1719

1820
### Quick usage
1921

20-
+ Input with `-s` or `-x /path/to/binary.exe`
21-
+ Output with `-b /path/to/debug.bat` and/or `-p powershell.cmd`
22+
+ Input with a file (`-x /path/to/binary.exe`) or STDIN (`-s`)
23+
+ Output to BAT (`-b /path/to/debug.bat`) and/or PoSH (`-p powershell.cmd`)
2224

23-
#### Examples
25+
#### Example Usage
2426

2527
```bash
26-
$ python exe2hex.py -x /usr/share/windows-binaries/nc.exe -b /var/www/html/nc.txt
27-
[*] exe2hex v1.1
28-
29-
[+] Successfully wrote: /var/www/html/nc.txt
28+
$ python3 exe2hex.py -x /usr/share/windows-binaries/sbd.exe
29+
[*] exe2hex v1.2
30+
[i] Outputting to /root/sbd.bat (BATch) and /root/sbd.cmd (PoSh)
31+
[+] Successfully wrote (BAT): /root/sbd.bat
32+
[+] Successfully wrote (PoSh): /root/sbd.cmd
3033
$
3134
```
3235

3336
```bash
34-
$ cat /usr/share/windows-binaries/whoami.exe | ./exe2hex.py -s -b who_debug.bat -p who_ps.cmd
35-
[*] exe2hex v1.1
37+
$ ./exe2hex.py -x /usr/share/windows-binaries/nc.exe -b /var/www/html/nc.txt
38+
[*] exe2hex v1.2
39+
[+] Successfully wrote (BAT): /var/www/html/nc.txt
40+
$
41+
```
3642

43+
```bash
44+
$ cat /usr/share/windows-binaries/whoami.exe | python3 exe2hex.py -s -b debug.bat -p ps.cmd
45+
[*] exe2hex v1.2
3746
[i] Reading from STDIN
38-
[+] Successfully wrote: who_debug.bat
39-
[+] Successfully wrote: who_ps.cmd
47+
[!] ERROR: Input is larger than 65536 bytes (BATch/DEBUG.exe limitation)
48+
[i] Attempting to clone and compress
49+
[i] Creating temporary file /tmp/tmpfypsf9if
50+
[i] Running strip on /tmp/tmpfypsf9if
51+
[+] Compression was successful!
52+
[+] Successfully wrote (BAT): /root/debug.bat
53+
[+] Successfully wrote (PoSh): /root/ps.cmd
4054
$
4155
```
4256

43-
```bash
44-
$ python exe2hex.py -h
45-
[*] exe2hex v1.1
57+
#### Help
4658

59+
```bash
60+
$ python3 exe2hex.py -h
61+
[*] exe2hex v1.2
4762
Usage: exe2hex.py [options]
4863

4964
Options:
5065
-h, --help show this help message and exit
5166
-x EXE The EXE binary file to convert
5267
-s Read from STDIN
53-
-b BAT BAT output file (DEBUG.exe method)
54-
-p POSH PoSh output file (PowerShell method)
55-
-e HTML encode the output?
56-
-r TEXT pRefix - text to add before the command
57-
-f TEXT suFfix - text to add after the command
68+
-b BAT BAT output file (DEBUG.exe method - x86)
69+
-p POSH PoSh output file (PowerShell method - x64/x86)
70+
-e URL encode the output
71+
-r TEXT pRefix - text to add before the command on each line
72+
-f TEXT suFfix - text to add after the command on each line
5873
-l INT Maximum hex values per line
59-
-v Enable verbose output
74+
-v Enable verbose mode
6075
$
6176
```
6277

@@ -65,11 +80,12 @@ $
6580
### Methods/OS Support
6681

6782
+ **`DEBUG.exe` (BATch mode - `-b`)**
68-
+ Useful for legacy versions of Windows.
6983
+ Every version of Windows x86 (No x64 support).
70-
+ Has a limitation of 64k input file size.
84+
+ Useful for legacy versions of Windows (e.g. XP/2000).
85+
+ Has a limitation of 64k file size for binary files.
7186
+ **PowerShell (PoSh mode - `-p`)**
72-
+ Useful for recent versions of Windows.
73-
+ Supports both Windows x64 & x86.
74-
+ First integrated into core OS with Windows 7/Windows Server 2008 R2.
87+
+ Supports both Windows x86 & x64.
88+
+ Aimed at more "recent" versions of Windows.
89+
+ Powershell was first integrated into core OS with Windows 7/Windows Server 2008 R2.
7590
+ Windows XP SP2, Windows Server 2003 & Windows Vista requires PowerShell to be pre-installed.
91+
+ This is **not** a `.ps1` file (pure powershell). It only calls powershell at the end to convert.

0 commit comments

Comments
 (0)