Пример #1
0
  /**
   * Process a NetWkstaGetInfo transaction request.
   *
   * @param sess Server session that received the request.
   * @param tbuf Transaction buffer
   * @param prmDesc Parameter descriptor string.
   * @param dataDesc Data descriptor string.
   * @param tpkt Transaction reply packet
   * @return true if the transaction has been processed, else false.
   */
  protected static final boolean procNetWkstaGetInfo(
      SMBSrvSession sess,
      TransactBuffer tbuf,
      String prmDesc,
      String dataDesc,
      SMBSrvTransPacket tpkt)
      throws IOException, SMBSrvException {

    // Validate the parameter string

    if (prmDesc.compareTo("WrLh") != 0)
      throw new SMBSrvException(SMBStatus.SRVInternalServerError, SMBStatus.ErrSrv);

    // Unpack the share get information specific parameters

    DataBuffer paramBuf = tbuf.getParameterBuffer();

    int infoLevel = paramBuf.getShort();
    int bufSize = paramBuf.getShort();

    // Debug

    if (Debug.EnableInfo && sess.hasDebug(SMBSrvSession.DBG_IPC))
      sess.debugPrintln("NetWkstaGetInfo infoLevel=" + infoLevel);

    // Check if the information level requested and data descriptor string match

    if ((infoLevel == 1 && dataDesc.compareTo("zzzBBzzz") == 0)
        || (infoLevel == 10 && dataDesc.compareTo("zzzBBzz") == 0)) {

      // Create the transaction reply data buffer

      TransactBuffer replyBuf = new TransactBuffer(tbuf.isType(), 0, 6, 1024);

      // Pack the data block, calculate the size of the fixed data block

      DataBuffer dataBuf = replyBuf.getDataBuffer();
      int strPos = SMBSrvTransPacket.CalculateDataItemSize(dataDesc);

      // Pack the server name

      dataBuf.putStringPointer(strPos);
      strPos = dataBuf.putStringAt(sess.getServerName(), strPos, false, true);

      // Pack the user name

      dataBuf.putStringPointer(strPos);
      strPos = dataBuf.putStringAt("", strPos, false, true);

      // Pack the domain name

      dataBuf.putStringPointer(strPos);

      String domain = sess.getSMBServer().getCIFSConfiguration().getDomainName();
      if (domain == null) domain = "";
      strPos = dataBuf.putStringAt(domain, strPos, false, true);

      // Pack the major/minor version number

      dataBuf.putByte(4);
      dataBuf.putByte(2);

      // Pack the logon domain

      dataBuf.putStringPointer(strPos);
      strPos = dataBuf.putStringAt("", strPos, false, true);

      // Check if the other domains should be packed

      if (infoLevel == 1 && dataDesc.compareTo("zzzBBzzz") == 0) {

        // Pack the other domains

        dataBuf.putStringPointer(strPos);
        strPos = dataBuf.putStringAt("", strPos, false, true);
      }

      // Set the data block length

      dataBuf.setLength(strPos);

      // Pack the parameter block

      paramBuf = replyBuf.getParameterBuffer();

      paramBuf.putShort(0); // status code
      paramBuf.putShort(0); // converter for strings
      paramBuf.putShort(dataBuf.getLength());
      paramBuf.putShort(0); // number of entries

      // Send the transaction response

      tpkt.doTransactionResponse(sess, replyBuf);
    } else {

      // Debug

      if (Debug.EnableInfo && sess.hasDebug(SMBSrvSession.DBG_IPC))
        sess.debugPrintln(
            "NetWkstaGetInfo UNSUPPORTED infoLevel=" + infoLevel + ", dataDesc=" + dataDesc);

      // Unsupported request

      throw new SMBSrvException(SMBStatus.SRVInternalServerError, SMBStatus.ErrSrv);
    }

    // We processed the request

    return true;
  }
Пример #2
0
  /**
   * Process a NetServerGetInfo transaction request.
   *
   * @param sess Server session that received the request.
   * @param tbuf Transaction buffer
   * @param prmDesc Parameter descriptor string.
   * @param dataDesc Data descriptor string.
   * @param tpkt Transaction reply packet
   * @return true if the transaction has been processed, else false.
   */
  protected static final boolean procNetServerGetInfo(
      SMBSrvSession sess,
      TransactBuffer tbuf,
      String prmDesc,
      String dataDesc,
      SMBSrvTransPacket tpkt)
      throws IOException, SMBSrvException {

    // Validate the parameter string

    if (prmDesc.compareTo("WrLh") != 0)
      throw new SMBSrvException(SMBStatus.SRVInternalServerError, SMBStatus.ErrSrv);

    // Unpack the server get information specific parameters

    DataBuffer paramBuf = tbuf.getParameterBuffer();

    int infoLevel = paramBuf.getShort();
    int bufSize = paramBuf.getShort();

    // Debug

    if (Debug.EnableInfo && sess.hasDebug(SMBSrvSession.DBG_IPC))
      sess.debugPrintln("NetServerGetInfo infoLevel=" + infoLevel);

    // Check if the information level requested and data descriptor string match

    if (infoLevel == 1 && dataDesc.compareTo("B16BBDz") == 0) {

      // Create the transaction reply data buffer

      TransactBuffer replyBuf = new TransactBuffer(tbuf.isType(), 0, 6, 1024);

      // Pack the parameter block

      paramBuf = replyBuf.getParameterBuffer();

      paramBuf.putShort(0); // status code
      paramBuf.putShort(0); // converter for strings
      paramBuf.putShort(1); // number of entries

      // Pack the data block, calculate the size of the fixed data block

      DataBuffer dataBuf = replyBuf.getDataBuffer();
      int strPos = SMBSrvTransPacket.CalculateDataItemSize("B16BBDz");

      // Pack the server name pointer and string

      dataBuf.putStringPointer(strPos);
      strPos = dataBuf.putFixedStringAt(sess.getServerName(), 16, strPos);

      // Pack the major/minor version

      dataBuf.putByte(1);
      dataBuf.putByte(0);

      // Pack the server capability flags

      dataBuf.putInt(sess.getSMBServer().getServerType());

      // Pack the server comment string

      String srvComment = sess.getSMBServer().getComment();
      if (srvComment == null) srvComment = "";

      dataBuf.putStringPointer(strPos);
      strPos = dataBuf.putStringAt(srvComment, strPos, false, true);

      // Set the data block length

      dataBuf.setLength(strPos);

      // Send the transaction response

      tpkt.doTransactionResponse(sess, replyBuf);
    } else throw new SMBSrvException(SMBStatus.SRVInternalServerError, SMBStatus.ErrSrv);

    // We processed the request

    return true;
  }