The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Report generation gmahesh2k Shell Programming and Scripting 3 05-16-2008 02:33 AM
report generation gmahesh2k UNIX for Dummies Questions & Answers 2 05-16-2008 01:41 AM
2nd Generation SOA = EDA + CEP? iBot Complex Event Processing RSS News 0 11-28-2007 08:30 PM
Oracle Report generation DILEEP410 Shell Programming and Scripting 7 01-04-2007 04:52 AM
Random number generation tej.buch High Level Programming 1 02-13-2006 10:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-07-2007
Legend986 Legend986 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 171
Shellcode Generation using C

Hi,

I was just learning about buffer overflow attacks... I was curious as to how to generate a simple shellcode. I've written two codes - One is the typical program that has a vulnerability inside and the other is the shellcode.

main program:
Code:
void test();

int main() {
   test();
   return 0;
}

void test() {
   int *ret;
   ret = (int *)&ret + 2;
   (*ret) = (int)shellcode;
}

I was thinking of putting the shellcode into the shellcode found in the end which is a character array.

And as for the shellcode generation, I've written something like:

Code:
#include <unistd.h>

int main() {
  char buf[]="Hello World";
  write(1,buf,sizeof(buf));
  exit(0);
}

But I don't know how to generate the shellcode from this so that I can put it in the original program in the form of char shellcode[] = ...... How would I go about doing this? And yeah if this is the wrong forum, please move this post because I didn't know where else this has to be posted...
  #2 (permalink)  
Old 10-08-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Imagine a program which normally prints "Hello World".

Then there is another program which uses that output...

char buf[32];
FILE *fp=popen("hello","r");
fread(buf,1,256,fp);
pclose(fp);

.. and it so happens that this always works because "hello" never returns more than 32 characters. One day it returns more, and then overruns the buffer affecting the return address. The function then returns into hyperspace.
  #3 (permalink)  
Old 10-08-2007
Legend986 Legend986 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 171
And thats where the fun begins? That was a great explanation. Thank you... I was actually trying to spawn a shell after reading a couple of articles but somehow couldn't properly understand Shellcode generation because most of the online articles say "To keep this article simple, I'd skip shellcode generation" and that was the instant when I thought of going for simple things - To generate one for atleast Hello World... Its funny that I got a shellcode itself for "Hello World" generation but I'm not searching for the answer instead the solution...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0