homer512

Owning string_view

Nov 25th, 2024
9,287
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <cstdlib>
  2. // using std::free
  3. #include <string_view>
  4. #include <utility>
  5. // using std::exchange
  6.  
  7.  
  8.  
  9. class CSView
  10. {
  11.   std::string_view view;
  12. public:
  13.   explicit CSView(char* ptr) noexcept
  14.     : view(ptr)
  15.   {}
  16.   CSView(CSView&& o) noexcept
  17.     : view(std::exchange(o.view, std::string_view{}))
  18.   {}
  19.   ~CSView()
  20.   { std::free(const_cast<char*>(view.data())); }
  21.  
  22.   void swap(CSView& o) noexcept
  23.   { view.swap(o.view); }
  24.  
  25.   friend void swap(CSView& left, CSView& right) noexcept
  26.   { left.swap(right); }
  27.  
  28.   CSView& operator=(CSView&& o) noexcept
  29.   {
  30.     CSView tmp = std::move(o);
  31.     swap(tmp);
  32.     return *this;
  33.   }
  34.   const std::string_view& operator*() const noexcept
  35.   { return view; }
  36.  
  37.   const std::string_view* operator->() const noexcept
  38.   { return &view; }
  39. };
  40.  
  41.  
  42. #include <cstring>
  43. // using std::strcpy
  44. #include <iostream>
  45. // using std::cout
  46.  
  47. int main()
  48. {
  49.   char* ptr = static_cast<char*>(std::malloc(80));
  50.   std::strcpy(ptr, "Hello World\n");
  51.   CSView cs { ptr };
  52.  
  53.   std::cout << "World at " << cs->find("World")
  54.         << " in " << *cs;
  55. }
  56.  
Advertisement
Comments
  • Borfidorn
    127 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
Add Comment
Please, Sign In to add comment