1
1
# exe2hex
2
2
3
- Inline file transfer method using debug and/or PowerShell.
3
+ Inline file transfer method using ` debug.exe ` and/or PowerShell.
4
4
5
5
- - -
6
6
@@ -13,50 +13,65 @@ Restores using `DEBUG.exe` (BATch - x86) and/or PowerShell (PoSh - x86/x64).
13
13
14
14
``` Binary EXE -> ASCII text -> Binary EXE ```
15
15
16
+ ![ ] ( https://i.imgur.com/kMcqHNq.png )
17
+
16
18
- - -
17
19
18
20
### Quick usage
19
21
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 ` )
22
24
23
- #### Examples
25
+ #### Example Usage
24
26
25
27
``` 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
30
33
$
31
34
```
32
35
33
36
``` 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
+ ```
36
42
43
+ ``` bash
44
+ $ cat /usr/share/windows-binaries/whoami.exe | python3 exe2hex.py -s -b debug.bat -p ps.cmd
45
+ [* ] exe2hex v1.2
37
46
[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
40
54
$
41
55
```
42
56
43
- ``` bash
44
- $ python exe2hex.py -h
45
- [* ] exe2hex v1.1
57
+ #### Help
46
58
59
+ ``` bash
60
+ $ python3 exe2hex.py -h
61
+ [* ] exe2hex v1.2
47
62
Usage: exe2hex.py [options]
48
63
49
64
Options:
50
65
-h, --help show this help message and exit
51
66
-x EXE The EXE binary file to convert
52
67
-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
58
73
-l INT Maximum hex values per line
59
- -v Enable verbose output
74
+ -v Enable verbose mode
60
75
$
61
76
```
62
77
65
80
### Methods/OS Support
66
81
67
82
+ ** ` DEBUG.exe ` (BATch mode - ` -b ` )**
68
- + Useful for legacy versions of Windows.
69
83
+ 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.
71
86
+ ** 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.
75
90
+ 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