#include <iostream> #include <boost/> using boost::asio::ip::tcp; void tunnel_data(tcp::socket& in_socket, tcp::socket& out_socket) { char data[1024]; boost::system::error_code error; size_t length = in_socket.read_some(boost::asio::buffer(data), error); if (!error) { boost::asio::write(out_socket, boost::asio::buffer(data, length)); } } int main() { boost::asio::io_context io_context; // Connect to the external client tcp::acceptor acceptor(io_context, tcp::endpoint(tcp::v4(), 8888)); tcp::socket client_socket(io_context); (client_socket); // Connect to the internal server (., device inside the LAN) tcp::resolver resolver(io_context); tcp::resolver::results_type endpoints = ("localhost", "80"); tcp::socket server_socket(io_context); boost::asio::connect(server_socket, endpoints); // Start tunneling data between client and server tunnel_data(client_socket, server_socket); return 0; }
Location>code7788
>text
Reflections on CPP Intranet Penetration Techniques
Popularity:286 ℃/2024-09-19 11:41:26