zoukankan      html  css  js  c++  java
  • cross socket和msgpack的数据序列和还原

    cross socket和msgpack的数据序列和还原

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      var pack: TSimpleMsgPack := TSimpleMsgPack.Create;
      pack.ForcePathObject('sql').AsString := '测试';
      IdTCPClient1.IOHandler.Write(tidbytes(pack.EncodeToBytes));  //发送TBytes
    end;
    
    procedure TcrossTcp.OnReceived(Sender: TObject; AConnection: ICrossConnection; ABuf: Pointer; ALen: Integer);
    begin
      var b: tbytes;
      SetLength(b, ALen);
      Move(ABuf^, b[0], ALen); // 还原TBytes
      var pack: TSimpleMsgPack := TSimpleMsgPack.Create;
      pack.DecodeFromBytes(b);
      Writeln(pack.ForcePathObject('sql').AsString);
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      var pack: TSimpleMsgPack := TSimpleMsgPack.Create;
      pack.ForcePathObject('sql').AsString := '测试';
      var ms: TMemoryStream := TMemoryStream.Create;
      pack.EncodeToStream(ms);
      ms.Position := 0;
      IdTCPClient1.IOHandler.Write(ms, ms.Size); //发送流
    end;
    
    procedure TcrossTcp.OnReceived(Sender: TObject; AConnection: ICrossConnection; ABuf: Pointer; ALen: Integer);
    begin
      var ms: TMemoryStream := TMemoryStream.Create;
      ms.Size := ALen;
      ms.Write(ABuf^, ALen);//还原流
      var pack: TSimpleMsgPack := TSimpleMsgPack.Create;
      ms.Position := 0;
      pack.DecodeFromStream(ms);
      Writeln(pack.ForcePathObject('sql').AsString);
    end;
    

      

  • 相关阅读:
    PowerCat DNS 隧道通信
    各种反弹shell方法总结备忘
    Halo-个人独立博客系统
    内网渗透之域渗透
    使用 EW 作Socks5代理内网穿透
    PowerShell攻击:nishang
    贝叶斯网络
    Anaconda的CondaHTTPError问题
    完美解决win10系统无法安装.NET Framework问题
    敏捷开发中如何做质量管理?
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/11218303.html
Copyright © 2011-2022 走看看