// s0t4ipv6@shellcode.com.ar
//
#include <stdio.h>
#include <string.h>

main (int argc, char *argv[]) {
	char 	*line, *targa;
	int 	c,j, x, resto;
	
if (argc < 2 ) { fprintf (stderr,"Pushit by s0t4ipv6\nUse: %s [string]\n",argv[0]); exit(0); }

	if ( (line=(char *)calloc(strlen(argv[1]) + 1, sizeof(char))) == NULL )
		{ perror ("calloc:()"); exit(0); }
	if ( (targa=(char *)calloc(strlen(argv[1]) + 1, sizeof(char))) == NULL )
		{ perror ("calloc:()"); exit(0); }

	x = strlen(argv[1]);
	memcpy(line , argv[1] , x);

	resto = x % 4;

	j = x - 1;
	for ( c = 0 ; c < x ; c++) 
		{ targa[j] = line[c] ; j-- ; }

	fprintf (stderr,"String == \'%s\'\n", line);
	fprintf (stderr,"Bytes == %d == 0x%x\n",x, x);

	c=0;
	while ( c < (x-resto) ) {
		fprintf (stderr,"pushl $0x%02x%02x%02x%02x\n", targa[c], targa[c+1], targa[c+2], targa[c+3]);
		c+=4;
		}

	if ( resto ==  3 ) {
		fprintf (stderr,"pushl $0x%02x%02x%02x%02x\t", targa[c], targa[c+1], targa[c+2], targa[c+3]);
		fprintf (stderr,"# Zer0 here!\n");
	} else if ( resto == 2 ) {
			fprintf (stderr,"pushw $0x%02x%02x\n", targa[c], targa[c+1]);
			} else if ( resto == 1 ) {
				fprintf (stderr, "push $0x%02x", targa[c]);
				if ( x > 1 ) fprintf (stderr, "\t\t# Stack Zer0s generate\n");
					else fprintf (stderr, "\n");
				}

}

