Binary to Hex Converter


This source code below converts a text file with binaries into a text file with hexadecimals. Imagine we have a file of binaries called “hello.bin”, we are going to convert it into hexadecimals and write it into a file called “hello.com”.

hello.bin

10110100 00001001
10111010 00001001 00000001
11001101 00100001
11001101 00100000
01101000 01100101 01101100 01101100 01101111 00100100

Concept (in terms of ASM)

mov ah,09
mov dx,0109
int 21
int 20
db "hello$"

hello.com

B4 09 BA 09 01 CD 21 CD 20 68 65 6C 6C 6F 24

where you can see how the binaries, hexadecimals and ASM are linked.

10110100 = B4 = mov ah
00001001 = 09 = 09

What “hello.com” does when ran is it prints the word “hello” and exits. Generally this code is a converter but it has given me a further insight of what assembly would look like and how the machine language works now. The source code is as below and it is done in C language (but you would need to write the filename as .cpp instead of .c since the program was not programmed according the C proper structure whereby it should be defining variables before statements).

Source code

#include <stdio.h>
#include <stdlib.h>

void help(char* fname) {
    printf(
        "Code programs in binary - by Jakash3\n"
        "Usage: %s outfile infile"
        "Notes:\n"
        "   infile = Text file containing ascii 1's and 0's.\n"
        "            8 bits per byte, all other characters\n"
      "            and whitespace ignored.\n"
        "   outfile = Name of program to create and write to.\n",
        fname
    );
    exit(1);
}

int main(int argc, char** argv) {
    if (argc!=3) help(argv[0]);
    FILE *dst, *src;
    dst = fopen(argv[1],"wb");
    if (!dst) { printf("Could not create or truncate %s\nQuitting...",argv[1]); return 1;}
    src = fopen(argv[2],"r");
    if (!src) { printf("Could not open %s\nQuitting...",argv[2]); return 1;}
    char c, byte=0;
    int i=0, count=0;
    while (!feof(src)) {
        if (i==8) { fwrite(&byte,1,1,dst); byte=0; i=0; count++; }
        fread(&c,1,1,src);
        switch (c) {
            case '1':
                byte |= ((c=='1') << (7-i));
            case '0':
                i++;
        }
    }
    fclose(src);
    if (!fclose(dst))
        printf("Wrote %d bytes to %s\n",count,argv[1]);
    return 0;
}

Download binary (.exe).

This code was written by jakash3 from Leetcoders.org
* Original link here.

Caesar and Rot Cipher Source Code


Ever wanted a portable caesar cipher and decipher at one go? At the end of this post you will find the binary as well as the source code (built in C) for the application. Below is an image of the application testing on “abcdefgh” text.  At [+13] you can see that it is equivalent to ROT13 cipher.  For those that are familiar with command line, use application.exe “text here”.

/*
 * url:   https://genesisdatabase.wordpress.com
 * email: genesisdatabase@gmail.com
 *
 * This source code is free to be used by any programmers
 * Source code converts all uppercase to lowercase during decryption
 * Supports command line usage, use text as argument eg. crack.exe "abcdef"
 */

#include <stdio.h>
#include <string.h>
//#include <stdlib.h> /*include if using system()*/

void DecryptCaesar(char *Encrypted)
{
	char i;
	int j;

	Encrypted = strlwr(Encrypted); /*supports only lowercase*/
	//system("REM"); /*use this to copy paste in windows*/

	printf(" Caesar Cipher\n\n");
	for(i = 0 ; i < 27 ; i++)
	{
		printf(" [+%d]\t", i);
		for(j = 0 ; j < (signed)strlen(Encrypted) ; j++)
		{
			if(Encrypted[j] == ' ')
				printf(""); /*replace "" with " " if you prefer to preserve spacing*/
			else if(Encrypted[j] < 'a' || Encrypted[j] > 'z')
				printf("%c", Encrypted[j]); /*preserved non-alphabets*/
			else if(Encrypted[j] + i > 'z')
				printf("%c", Encrypted[j] + i - 26);
			else
				printf("%c", Encrypted[j] + i);
		}

		if(i == 13)
			printf(" (ROT)");

		printf("\n");
		if(i == 25)
		{
			printf(" ");
			for(j = 0 ; j < (signed)strlen(Encrypted) + 8 ; j++)
				printf("-");

			printf("\n");
		}

	}
	printf("\n");
}
int main(int argc, char **argv)
{
	char string[64 +1] = {'\0'};

	if(argc == 2)
	{
		strncpy(string, argv[1], 64);
		printf("\n");
		DecryptCaesar(string);
		return 0;
	}

	for( ; ; )
	{
		printf("\n Enter a text to encrypt/decrypt (EXIT to quit): ");

		fflush(stdin);		/*windows*/
		//fpurge(stdin);	/*linux*/

		scanf("%64[^\n]", string);

		if(string[0] == 'E' && string[1] == 'X' && string[2] == 'I' && string[3] == 'T' && string[4] == '\0')
			break;

		printf("\n\n");
		DecryptCaesar(string);
	}

	printf("\n Thanks for using...\n");
	return 0;
}

Download Binary
Download Source Code

GDWS | GenesisDatabase WLM Stealer


GDWS is an application that i have created using C without relying on resources for its GUI. It’s simple to use and requires no driver reliability however it only works on Windows only.

Functions

– GUI in C
– retrieve stored WLM passwords
– run website in a hidden window via IE or FF (using socket)
– intermediate socket usage
– socket to load website

Download

Download Binary
Download Source Code

Note: If anyone requests for the source code, it would be generous of you to direct them here.  I know it will consume your time but i’m sure a good deed is always worth it – what comes around goes around.