/*
* Title: Linux/x86 - Custom Shellcode ASCII And-Sub Encoder
* Date: 29.03.2021
* Author: Xenofon Vassilakopoulos
* github : https://github.com/xen0vas/ASC /*
* Title: Linux/x86 - Custom Shellcode ASCII And-Sub Encoder
* Date: 29.03.2021
* Author: Xenofon Vassilakopoulos
* github : https://github.com/xen0vas/ASCII-AND-SUB-Encoder
*
*
* gcc -m32 sub.c -o sub
*
* Usage : ./sub -s x41xffx41x41 -b x0ax0dx2fx3ax3fx40x80x81x82
*
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdbool.h>
#include <limits.h>
#include <errno.h>
#include <stdint.h>
#define KNRM "x1B[0m"
#define KRED "x1B[31m"
#define KGRN "x1B[32m"
#define KYEL "x1B[33m"
#define KBLU "x1B[34m"
#define KMAG "x1B[35m"
#define KCYN "x1B[36m"
#define KWHT "x1B[37m"
#define RESET "x1B[0m"
#define ZEROVAL 0x0
char *hexToStrip(char *shellcode, size_t si)
{
size_t s = strlen(shellcode);
char *buf = (char*)malloc((s + 1) * sizeof(shellcode)*2);
char *stringToStrip = (char*)malloc((s + 1) * sizeof(shellcode)*2);
strcpy(stringToStrip,shellcode);
size_t stringLen = strlen(stringToStrip);
unsigned int i,j = 0;
char currentChar;
for (j = 0; j<stringLen+1; j++) {
currentChar = stringToStrip[j];
if (currentChar != '\' && currentChar != 'x')
{
sprintf(buf + strlen(buf),"%c",currentChar);
}
}
return buf;
}
unsigned char *hexTochar(char *shellcode) {
char *end;
unsigned long int j = strtol(shellcode, &end, 16);
char* str = (char*)calloc(strlen(shellcode), sizeof(char*));
int i=0;
for ( ;; ) {
sprintf(str + i * sizeof(char),"%c", (int)j);
i++;
j = strtol(end, &end, 16);
if (j == 0)
break;
}
return str;
}
char *strrev(char *str)
{
if (!str || ! *str)
return str;
int i = strlen(str) - 1, j = 0;
char ch;
while (i > j)
{
ch = str[i];
str[i] = str[j];
str[j] = ch;
i--;
j++;
}
return str;
}
unsigned char* toCharByte(char *byte, size_t bytelen)
{
if (byte == NULL || !strcmp(byte, ""))
{
return NULL;
}
size_t k,len = bytelen;
char cbyte[len];
strcpy(cbyte, byte);
// allocate the 1/3 of the total char size
unsigned char* str = (unsigned char*)calloc(len / 3, sizeof(str));
unsigned char* chr = (unsigned char*)calloc(len / 3 , sizeof(chr));
char* alpha = (char*)malloc((len / 3) * sizeof(alpha));
char *ch = strtok(cbyte, "\x");
while(ch != NULL)
{
sprintf(alpha + strlen(alpha), "%s", ch );
ch = strtok(NULL, "\x");
}
for(k=0; alpha[k]!='
Linux x86 Custom Shellcode ASCII And-Sub Encoder
- Details
- Written by: khalil shreateh
- Category: Vulnerabilities
- Hits: 141