使用 OpenSSL s2n 调用的 C 编译问题

Compiling issue with C using OpenSSL s2n call

我完全是 C 语言的新手,并尝试用谷歌搜索错误,但一直无法弄清楚要更改什么才能使它起作用。我正在尝试编译一个 exploitdb .c 文件 (764.c)。按照这个 guide,我已经做了所有的更改,但它仍然无法编译。

错误:

$gcc exploit2.c -o 764 -lcrypto
exploit2.c: In function ‘send_ssl_packet’:
exploit2.c:641:27: error: assignment of read-only location ‘*p’
  641 | #define s2n(s,c)    ((c[0]=(unsigned char)(((s)>> 8)&0xff), c[1]=(unsigned char)(((s)    )&0xff)),c+=2)
      |                           ^
exploit2.c:908:2: note: in expansion of macro ‘s2n’
  908 |  s2n(tot_len, p);
      |  ^~~
exploit2.c:641:65: error: assignment of read-only location ‘*(p + 1)’
  641 | #define s2n(s,c)    ((c[0]=(unsigned char)(((s)>> 8)&0xff), c[1]=(unsigned char)(((s)    )&0xff)),c+=2)
      |                                                                 ^
exploit2.c:908:2: note: in expansion of macro ‘s2n’
  908 |  s2n(tot_len, p);
      |  ^~~
exploit2.c:920:13: warning: passing argument 1 of ‘MD5_Final’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  920 |   MD5_Final(p, &ctx);
      |             ^
In file included from exploit2.c:27:
/usr/include/openssl/md5.h:42:30: note: expected ‘unsigned char *’ but argument is of type ‘const unsigned char *’
   42 | int MD5_Final(unsigned char *md, MD5_CTX *c);
      |               ~~~~~~~~~~~~~~~^~
exploit2.c:924:10: warning: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  924 |   memcpy(p, rec, rec_len);
      |          ^
In file included from exploit2.c:17:
/usr/include/string.h:43:14: note: expected ‘void * restrict’ but argument is of type ‘const unsigned char *’
   43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
      |              ^~~~~~
exploit2.c:931:10: warning: passing argument 1 of ‘memcpy’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  931 |   memcpy(p, rec, rec_len);
      |          ^
In file included from exploit2.c:17:
/usr/include/string.h:43:14: note: expected ‘void * restrict’ but argument is of type ‘const unsigned char *’
   43 | extern void *memcpy (void *__restrict __dest, const void *__restrict __src,

如有任何帮助,我们将不胜感激。

你好像在申请的时候犯了一个错误第三步插入“const”

// unsigned char *p, *end;
const unsigned char *p, *end;

该代码在三个不同的地方包含 unsigned char *p 的声明,您将错误的一个修改为 const,结果显示了错误和警告。只应更改函数 get_server_hello() 中的那个。

顺便说一下,在 764 it says there is an update to it, 47080 的顶部。后者已经应用了所有修改(以及更多),并且可以使用 OpenSSL 1.1.1d 正常构建。