fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <sstream>
  4.  
  5. int main()
  6. {
  7. unsigned char buf[1024] = {'\0'};
  8. std::string shell_str("\x55\x48\x89\x00\x00\x00\x00\xC3\x90");
  9. std::copy( shell_str.begin(), shell_str.end(), buf );
  10. buf[shell_str.length()] = '\0';
  11.  
  12. std::stringstream ss;
  13. for(unsigned char bin_data : shell_str)
  14. ss << std::uppercase << std::hex << static_cast<int>(bin_data) << " ";
  15.  
  16. std::cout << "shell : " << shell_str << std::endl;
  17. std::cout << "hex-string : " << ss.str() << std::endl;
  18. std::cout << "shell length : " << shell_str.length() << std::endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 4384KB
stdin
Standard input is empty
stdout
shell : UH�
hex-string : 55 48 89 
shell length : 3