Skip to content

Commit 376755e

Browse files
authored
Merge pull request #19 from psycore8/dev070
Dev070
2 parents 5950bd0 + 43928a3 commit 376755e

28 files changed

+861
-340
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ __pycache__
88
.venv/
99
_dev*
1010
_dev.bat
11+
ShenCode.egg-info
12+
nasm.exe
13+
build/

README.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,57 @@
22

33
**A versatile tool for working with shellcodes.**
44

5-
![|800](shencode-061.png)
5+
![](shencode-070.png)
66

77
## Features
88

9-
### Version 0.6.1
10-
11-
- general
12-
- `extract` - [extract](https://www.heckhausen.it/shencode/wiki/extract) from/to offset
13-
- `formatout` - [display raw shellcodes](https://www.heckhausen.it/shencode/wiki/formatout) in `C++, C#` and more
14-
- `inject` - [inject shellcode](https://www.heckhausen.it/shencode/wiki/inject) into process (Windows only)
15-
- `msfvenom` - [create payloads](https://www.heckhausen.it/shencode/wiki/msfvenom) with msfvenom
16-
- encoder
17-
- `aesenc` - [Encrypt](https://www.heckhausen.it/shencode/wiki/aesenc) payload with AES
18-
- `byteswap` - New XOR Encryption, [Swapping Bytes](https://www.heckhausen.it/shencode/wiki/byteswap) ([Blog Post](https://www.nosociety.de/en:it-security:blog:obfuscation_byteswapping))
19-
- `xorenc` - [Encode payload](https://www.heckhausen.it/shencode/wiki/xorenc) with custom XOR key
20-
- `xorpoly` - [polymorphic x64](https://www.heckhausen.it/shencode/wiki/xorpoly) in-memory decoder (for details, visit this [Blog Post](https://www.nosociety.de/en:it-security:blog:obfuscation_polymorphic_in_memory_decoder))
21-
- obfuscator
22-
- `Feed` - Splits Bytes in a [feed.xml file](https://www.heckhausen.it/shencode/wiki/feed) as article IDs
23-
- `QR-Code` hide OpCodes as [QR-Code image](https://www.heckhausen.it/shencode/wiki/qrcode)
24-
- `ROR13` to `ROL` [conversion with custom key](https://www.heckhausen.it/shencode/wiki/ror2rol) (Windows only)
25-
- `UUID` [obfuscation](https://www.heckhausen.it/shencode/wiki/uuid) - Please, check out my [Blog Post](https://www.nosociety.de/en:it-security:blog:obfuscation_shellcode_als_uuids_tarnen_-_teil_1) about this encoder
9+
### Version 0.7.0
10+
11+
- **core**
12+
- `extract` - [extract](https://www.heckhausen.it/shencode/wiki/core/extract) from/to offset
13+
- `formatout` - [display raw shellcodes](https://www.heckhausen.it/shencode/wiki/core/formatout) in `C++, C#` and more
14+
- `injection` - [inject shellcode](https://www.heckhausen.it/shencode/wiki/core/injection) into process (Windows only)
15+
- `msfvenom` - [create payloads](https://www.heckhausen.it/shencode/wiki/core/msfvenom) with msfvenom
16+
- **encoder**
17+
- `aes` - [Encrypt](https://www.heckhausen.it/shencode/wiki/encoder/aes) payload with AES
18+
- `bytebert` - advanced polymorphic encoder
19+
- `byteswap` - New XOR Encryption, [Swapping Bytes](https://www.heckhausen.it/shencode/wiki/encoder/byteswap) ([Blog Post](https://www.nosociety.de/en:it-security:blog:obfuscation_byteswapping))
20+
- `xor` - [Encode payload](https://www.heckhausen.it/shencode/wiki/encoder/xor) with custom XOR key
21+
- `xorpoly` - [polymorphic x64](https://www.heckhausen.it/shencode/wiki/encoder/xorpoly) in-memory decoder (for details, visit this [Blog Post](https://www.nosociety.de/en:it-security:blog:obfuscation_polymorphic_in_memory_decoder))
22+
- **obfuscate**
23+
- `Feed` - Splits Bytes in a [feed.xml file](https://www.heckhausen.it/shencode/wiki/obfuscate/feed) as article IDs
24+
- `QR-Code` hide OpCodes as [QR-Code image](https://www.heckhausen.it/shencode/wiki/obfuscate/qrcode)
25+
- `ROR13` to `ROL` [conversion with custom key](https://www.heckhausen.it/shencode/wiki/obfuscate/rolhash) (Windows only)
26+
- `UUID` [obfuscation](https://www.heckhausen.it/shencode/wiki/obfuscate/uuid) - Please, check out my [Blog Post](https://www.nosociety.de/en:it-security:blog:obfuscation_shellcode_als_uuids_tarnen_-_teil_1) about this encoder
27+
- **stager**
28+
- `meterpreter` - Initiate a `meterpreter/reverse_tcp` [stage](https://www.heckhausen.it/shencode/wiki/stager/meterpreter)
29+
- `sliver` - Initiate a `https` [sliver stage](https://www.heckhausen.it/shencode/wiki/stager/sliver)
2630

2731
## How to use
2832

33+
##### Install
34+
35+
```shell
36+
git clone https://github.com/psycore8/shencode
37+
cd shencode
38+
pip install .
39+
shencode -h
40+
```
41+
42+
#### General usage
43+
2944
Check out the [ShenCode Docs](https://heckhausen.it/shencode/wiki/) for more information.
3045

3146
## Release Notes
3247

33-
- `feed` - A new obfuscation module
34-
- `core` - added some different logos for startup
48+
- `general` - setup routine, which handles the different packages and modules for Windows and Linux
49+
- `general` - new module parser
50+
- `general` - new start-up banners
51+
- `core/inject` - Suspend and Resume Technique
52+
- `core/inject` - VirtualProtectEx Technique
53+
- `encoder/bytebert` - advanced polymorphic encoder
54+
- `stager/meterpreter` - a reverse TCP Meterpreter stager
55+
- `stager/sliver` - a HTTPS Sliver stager
3556

3657
## References
3758

_dev.bat

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +0,0 @@
1-
@echo off
2-
rem doskey shen-aes=python3.12 shencode.py aesenc $*
3-
rem doskey shen-ext=python3.12 shencode.py extract $*
4-
rem doskey shen-out=python3.12 shencode.py formatout $*
5-
rem doskey shen-inj=python3.12 shencode.py inject $*
6-
rem doskey shen-msf=python3.12 shencode.py msfvenom $*
7-
rem doskey shen-qrc=python3.12 shencode.py qrcode $*
8-
rem doskey shen-ror=python3.12 shencode.py ror2rol $*
9-
rem doskey shen-uid=python3.12 shencode.py uuid $*
10-
rem doskey shen-xop=python3.12 shencode.py xorpoly $*
11-
rem doskey shen-xoe=python3.12 shencode.py xorenc $*
12-
doskey shc=python shencode.py $*
13-
doskey /MACROS

examples/module.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import utils.arg
21
from utils.helper import nstate as nstate
32

3+
CATEGORY = 'core'
4+
5+
def register_arguments(parser):
6+
parser.add_argument('-i', '--input', help='text1')
7+
parser.add_argument('-o', '--output', help='text2')
8+
parser.add_argument('-x', '--xray', action='store_true', help='text3')
9+
parser.add_argument('-z', '--zulu', help='text4')
10+
411
class example:
512
Author = 'Name'
613
Description = 'some useful information about this module'
714
Version = '1.0.0'
815

9-
def init():
10-
spName = 'examplemod'
11-
spArgList = [
12-
['-i', '--input', '', '', 'Input file for example module'],
13-
['-t', '--truestate', '', 'store_true', 'store_true switch'],
14-
['-l', '--list', 'a,b,c,d', '', 'A list of choices for this argument']
15-
]
16-
utils.arg.CreateSubParser(spName, example.Description, spArgList)
17-
18-
def process():
19-
print('python is nice')
16+
def process():
17+
print('python is nice')

encoder/aes.py renamed to modules/aes.py

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import utils.arg
21
from utils.helper import nstate as nstate
32
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
43
from cryptography.hazmat.backends import default_backend
@@ -8,33 +7,25 @@
87
import pickle
98
import os
109

10+
CATEGORY = 'encoder'
11+
12+
def register_arguments(parser):
13+
parser.add_argument('-m', '--mode', choices=['encode', 'decode'], required=True, help='AES Operation mode, choose between encode and decode')
14+
parser.add_argument('-i', '--input', required=True, help='Input file for AES encoding')
15+
parser.add_argument('-o', '--output', required=True, help= 'Outputfile for AES encoding')
16+
parser.add_argument('-k', '--key', required=True, help='Key for AES encoding')
17+
1118
class aes_encoder:
1219
Author = 'psycore8'
1320
Description = 'AES encoder for payloads'
14-
Version = '1.1.0'
15-
# Input_File = ''
16-
# Output_File = ''
17-
# Password = b''
18-
# DataBytes = b''
21+
Version = '2.0.0'
1922

2023
def __init__(self, mode, input_file, output_file, key, data_bytes:bytes):
2124
self.mode = mode
2225
self.input_file = input_file
2326
self.output_file = output_file
2427
self.key = key
2528
self.data_bytes = data_bytes
26-
27-
28-
def init():
29-
spName = 'aesenc'
30-
spArgList = [
31-
['-m', '--mode', 'encode,decode', '', 'AES Operation mode, choose between encode and decode'],
32-
['-i', '--input', '', '', 'Input file for AES encoding'],
33-
['-o', '--output', '', '', 'Outputfile for AES encoding'],
34-
['-k', '--key', '', '', 'Key for AES encoding'],
35-
#['-debug', '--debug', '', 'store_true', 'debug']
36-
]
37-
utils.arg.CreateSubParser(spName, aes_encoder.Description, spArgList)
3829

3930
def generate_key(self, password: bytes, salt: bytes) -> bytes:
4031
kdf = PBKDF2HMAC(
@@ -46,17 +37,14 @@ def generate_key(self, password: bytes, salt: bytes) -> bytes:
4637
)
4738
return kdf.derive(password)
4839

49-
def aes_encrypt(self, data: bytes, password: bytes) -> (bytes, bytes, bytes):
50-
# Salt und Initialisierungsvektor (IV) generieren
40+
def aes_encrypt(self, data: bytes, password: bytes):
5141
salt = os.urandom(16)
5242
iv = os.urandom(16)
5343
key = self.generate_key(password, salt)
5444

55-
# Paddings für Blockgröße (AES Blockgröße = 128 Bit)
5645
padder = padding.PKCS7(algorithms.AES.block_size).padder()
5746
padded_data = padder.update(data) + padder.finalize()
5847

59-
# AES-Cipher im CBC-Modus
6048
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
6149
encryptor = cipher.encryptor()
6250
encrypted_data = encryptor.update(padded_data) + encryptor.finalize()
@@ -69,16 +57,12 @@ def aes_decrypt(self, encrypted_data: bytes, password: bytes, salt: bytes, iv: b
6957
decryptor = cipher.decryptor()
7058
padded_data = decryptor.update(encrypted_data) + decryptor.finalize()
7159

72-
# Padding entfernen
7360
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
7461
data = unpadder.update(padded_data) + unpadder.finalize()
7562

7663
return data
7764

7865
def encode(self):
79-
# outputfile = self.output_file
80-
# inputfile = self.input_file
81-
# password = self.key
8266
try:
8367
with open(self.input_file, 'rb') as file:
8468
self.data_bytes = file.read()
@@ -88,12 +72,8 @@ def encode(self):
8872
size = len(self.data_bytes)
8973
print(f'{nstate.OKBLUE} File {self.input_file} loaded, size of shellcode {size} bytes')
9074
enc_data, salt, iv = self.aes_encrypt(self.data_bytes, self.key)
91-
#print(f'{AESData}')
9275
with open(self.output_file, "wb") as f:
9376
pickle.dump((enc_data, salt, iv), f)
94-
# with open(outputfile, 'wb') as file:
95-
# file.write(AESData)
96-
#path = outputfile
9777
cf = os.path.isfile(self.output_file)
9878
if cf == True:
9979
print(f"{nstate.OKGREEN} [AES-ENC] file created in {self.output_file}")
@@ -102,29 +82,20 @@ def encode(self):
10282
exit()
10383

10484
def decode(self):
105-
# outputfile = aes_encoder.Output_File
106-
# inputfile = aes_encoder.Input_File
107-
# password = aes_encoder.Password
10885
enc_data = b''
10986
salt = 0
11087
iv = 0
11188
try:
11289
with open(self.input_file, "rb") as f:
113-
#AESData[0], AESData[1], AESData[2] = pickle.load(f)
11490
enc_data, salt, iv = pickle.load(f)
11591
except FileNotFoundError:
11692
print(f'{nstate.FAIL} File {self.input_file} not found or cannot be opened.')
11793
exit()
11894
size = len(enc_data)
11995
print(f'{nstate.OKBLUE} File {self.input_file} loaded, filesize {size} bytes')
12096
Shellcode = self.aes_decrypt(enc_data, self.key, salt, iv)
121-
#AESData = aes_encoder.aes_encrypt(aes_encoder.DataBytes, password)
122-
#print(f'{AESData}')
123-
#with open(outputfile, "wb") as f:
124-
# pickle.dump((AESData[0], AESData[1], AESData[2]), f)
12597
with open(self.output_file, 'wb') as file:
12698
file.write(Shellcode)
127-
#path = outputfile
12899
cf = os.path.isfile(self.output_file)
129100
if cf == True:
130101
print(f"{nstate.OKGREEN} [AES-DEC] file created in {self.output_file}")

0 commit comments

Comments
 (0)