很多次我遇到Buffer Overflow问题.
int y[10][10][10];
Run Code Online (Sandbox Code Playgroud)
...
y[0][15][3] = 8;
Run Code Online (Sandbox Code Playgroud)
我该如何防止这个问题?有什么好的工具可以帮助我吗?
这是来自ac程序的摘录,应该演示缓冲区溢出.
void foo()
{
char arr[8];
printf(" enter bla bla bla");
gets(arr);
printf(" you entered %s\n", arr);
}
Run Code Online (Sandbox Code Playgroud)
问题是"如果没有创建缓冲区溢出,用户最多可以输入多少个输入字符"
我最初的答案是8,因为char数组长8个字节.虽然我非常肯定我的答案是正确的,但我尝试了更多的字符,并且发现在我出现分段错误之前我可以输入的字符数限制是11.(我在A VirtualBox Ubuntu上运行它)
所以我的问题是:为什么可以在8字节数组中输入11个字符?
有人可以告诉我这段代码有什么问题吗???
char sms[] = "gr8";
strcat (sms, " & :)");
Run Code Online (Sandbox Code Playgroud) 我是一名中级程序员,编写的程序对我来说可能很复杂.程序的目标是构建某些二维数组,并且有一些不同的类对象以非常简单的方式相互通信.为了调试,我添加了一行代码来输出我在程序中的位置(cout <<"here";).该程序现在可以工作,但是如果我删除了cout语句,整个程序的整体结果就会失败; 程序不遵循创建所述2-d阵列的预期程序.
所以我的问题是:可能发生什么?或者更确切地说,如何包括一个cout声明"修复"(或对其他周围的代码产生任何影响)?看起来cout语句似乎不会对缓冲区溢出产生影响,但如果是这样,请随时教育我.
我正在做一个visual c ++应用程序并尝试将大小分配给缓冲区(该缓冲区进一步用于存储流的内容).如果声明缓冲的大小小于那么没有问题
const int size= 319000; //here there is no problem
Run Code Online (Sandbox Code Playgroud)
但是为了从流中访问我想要的一些数据,我需要声明这样大小的缓冲区 -
const int size=4348928;//this size cause the problem
char buffer[size+1];
HRESULT hr = pStream->Read(buffer, size, &cbRead );
Run Code Online (Sandbox Code Playgroud)
虽然代码的最后两行对我的问题没有任何作用,但它只是让你知道我正在用这个缓冲区的大小做什么.
但是,当我声明这个大小时,它什么也没做(我的意思是我的视觉应用程序功能如下:如果你单击一个文件,它会生成一个流,我将该流存储在缓冲区中 - 如果我声明大小为319000的顺序程序运行正常,当大小增加到4348928它甚至不工作 - 当然没有错误)
我有以下程序
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 int check_authentication(char *password){
6 char password_buffer[16];
7 int auth_flag =0;
8
9
10 strcpy(password_buffer, password);
11
12 if(strcmp(password_buffer, "brillig" ) == 0 )
13 auth_flag = 1;
14 if(strcmp(password_buffer, "outgrabe") == 0)
15 auth_flag = 1;
16
17 return auth_flag;
18 }
19
20 int main(int argc, char *argv[]){
21 if (argc<2){
22 printf("Usage: %s <password>\n", argv[0]);
23 exit(0);
24 }
25
26 if(check_authentication(argv[1])){
27 printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");
28 printf(" …Run Code Online (Sandbox Code Playgroud) 我正在研究检测和防止BOF攻击,我想知道,我怎样才能溢出全局结构?
我的代码:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct{
char name[20];
char description[10];
} test;
int main(int argc, char **argv){
if(argc != 2)
exit(-1);
*(*(argv+1)+20) = '\x00'; //terminate string after 20 characters
strcpy(test.name, argv[1]); //no BOF here... stopped at 20
printf("%s\n", test.name);
char *desc;
desc = malloc(10);
if(!desc){
printf("Error allocating memory\n");
exit(-1);
}
scanf("%s", desc); //no bounds checking - this is where I BOF
strcpy(test.description, desc); //copy over 10 characters into 10 char buffer
printf("%s\n", test.description); //this prints out whatever …Run Code Online (Sandbox Code Playgroud) 当我尝试监视网络路径上的文件夹(DFS - 分布式文件系统)时,我收到异常System.IO.Internal.BufferOverflowException:一次更改许多更改.当FileSystemWatcher监视不使用此文件系统的本地/网络路径时,它可以正常工作.
我能够从本地路径上的1000 +文件中获取一个事件而我没有得到BufferOverflow异常,但是当我将文件复制到DFS上的文件夹时,我甚至无法从一个文件中获取事件(为了澄清这一点,我收到了错误事件...).
我已经尝试过设置:
fileSystemWatcher.InternalBufferSize = 65536;
Run Code Online (Sandbox Code Playgroud)
我不确定这是否会对你有所帮助,但路径看起来像这样:
\\corpnet\cloud\\Network\testFolder\myFolderToMonitor
Run Code Online (Sandbox Code Playgroud)
编辑:1我不知道为什么路径中有两个双斜杠.我可以在没有问题文件夹的情况下进行监控,直到\ corpnet\cloud路径.一旦我试图监视任何开始的文件夹,我就会收到错误
...\\Network\...
Run Code Online (Sandbox Code Playgroud)
你的任何提示都表示赞赏.
谢谢
c# filesystemwatcher buffer-overflow microsoft-distributed-file-system windows-server-2008
我在Penetration Testing职业生涯中遇到过许多站点,其中站点具有严格的WAF,但有时可以通过缓冲区溢出逻辑来绕过.例如,考虑一个Query
http://example.com/something.php?id=-1 UNION SELECT 1,2,3,4,5,6--+
考虑弱势列直到7.所以现在,这应该打印一个易受攻击的列号作为输出,但它会得到错误.
现在,
http://example.com/something.php?id=-1 UNION%23AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%0aselect 1,2,3,4,5,6--+
这实际上打印出Real列号,这意味着它已被Bypassed.我知道%23 =#和%0A =空格.但我不明白这是如何在幕后发挥作用的.我的意思是后端逻辑.
任何人都可以给我一个SQL结构示例,它可以导致这种类型的缓冲区溢出,考虑到后端是MYSQL的后端结构(数据类型)和$查询...
帮助将不胜感激
我有以下代码:
int main(int argc, char *argv[]) {
int bufferSize = 8;
//Setting the buffer size here, which can cause a heap overflow
char *argsStr = malloc(bufferSize);
char *anotherStr = malloc(bufferSize);
//If argv[1] is greater than the buffer size, we will have an overflow
strcpy(argsStr, argv[1]);
printf("String 1: %s String 2: %s", argsStr, anotherStr);
}
Run Code Online (Sandbox Code Playgroud)
我想导致堆溢出,所以我导入参数'testtesttesttesttesttesttesttesttest'.
我希望,因为argsStr只有大小为8,它将是'testtest',其余的将溢出到anotherStr(8个字节),但我看到:

所以argsStr是'testtesttesttesttesttesttesttesttest'而另一个是'testtesttesttesttest'
为什么是这样?我错过了堆溢出的东西或malloc()?
buffer-overflow ×10
c ×6
c++ ×5
buffer ×2
c# ×1
cout ×1
disassembly ×1
gdb ×1
heap ×1
microsoft-distributed-file-system ×1
mysql ×1
sql ×1
strcat ×1
types ×1