G2A Many GEOs
SHARE
TWEET

Untitled

a guest Apr 9th, 2020 156 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void sock::perform_sock5_second_handshake() {
  2.  
  3.   std::uint16_t const port = 4561;  
  4.   std::uint8_t ipv4[4]{};
  5.   std::vector<std::uint8_t> handshake_buffer{};
  6.  
  7.   std::cout << "Performing second handshake\n";
  8.   if (sscanf("1.1.1.1", "%hhu.%hhu.%hhu.%hhu", &ipv4[0], &ipv4[1], &ipv4[2],
  9.              &ipv4[3]) != 4) {
  10.     throw std::runtime_error("Could not parse IPv4 address: 1.1.1.1");
  11.   }
  12.  
  13.   handshake_buffer.clear();
  14.   handshake_buffer.push_back(0x05); // version
  15.   handshake_buffer.push_back(0x01); // TCP/IP
  16.   handshake_buffer.push_back(0x00); // must be 0x00 always
  17.   handshake_buffer.push_back(0x01); // IPv4
  18.  
  19.   // how do I specify the hostname here?
  20.   handshake_buffer.push_back(ipv4[0]);
  21.   handshake_buffer.push_back(ipv4[1]);
  22.   handshake_buffer.push_back(ipv4[2]);
  23.   handshake_buffer.push_back(ipv4[3]);
  24.  
  25.   // host to network short(htons)
  26.   handshake_buffer.push_back(port >> 8);
  27.   handshake_buffer.push_back(port & 0xff);
  28.  
  29.   ::send(socket_, reinterpret_cast<char const*>( handshake_buffer.data() ), handshake_buffer.size(), 0 );
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top