-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up implementation of smb3-dev branch (#455)
* WIP * Clean code from smb3-dev * SMB3 Cleaned up part of the implementation * SMB3 added salt * Move session creation to separate class * WIP - Renamed SMB2Header -> SMB2PacketHeader - Added SMB3EncryptedPacket* - Added start for IncomingPacketHandler * Split up Packet Handling into handlers * Add SMB2_TRANSFORM_HEADER * WIP * Work on SMB3 * Use SMB2.1 in integration tests * Few more SMB3 parts * Implemented 3.2.5.2 * Calculate SMB3.1.1 preauthIntegrityHashValue * Fix workflow file * Fix workflow file 2 * WIP * organize imports * Cleanup warnings * Fixed build * Start integrating PacketEncryptor * Fixed signing/verification of messages * TargetHint Array throws Index Out Of Bounds Exception (#588) * Getting there... Encrypted message is not quite right yet * Working encryption * Fix preferred encryption when available * Fixed bug in remoteCopy IOCTL requests Co-authored-by: pranaysharmamanulife <pranay_sharma@manulife.com>
- Loading branch information
1 parent
da51799
commit 78da5c8
Showing
124 changed files
with
4,534 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This workflow will build a Java project with Gradle | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | ||
|
||
name: Build SMBJ | ||
|
||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
java11: | ||
name: Build with Java 11 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Cache Gradle packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | ||
restore-keys: ${{ runner.os }}-gradle | ||
- name: Build with Gradle | ||
run: ./gradlew check | ||
integration: | ||
name: Integration test | ||
needs: [java11] | ||
runs-on: [ubuntu-latest] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Cache Gradle packages | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | ||
restore-keys: ${{ runner.os }}-gradle | ||
- name: Run integration tests | ||
run: ./gradlew integrationTest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
[supervisord] | ||
nodaemon=true | ||
/* user=root */ | ||
loglevel=info | ||
|
||
[program:smbd] | ||
/* command=/usr/sbin/smbd -i --daemon --foreground --log-stdout */ | ||
command=/usr/sbin/smbd --daemon --foreground --log-stdout | ||
redirect_stderr=true | ||
|
||
[program:nmbd] | ||
/* command=/usr/sbin/nmbd -i --daemon --foreground --log-stdout */ | ||
command=/usr/sbin/nmbd --daemon --foreground --log-stdout | ||
redirect_stderr=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/hierynomus/mssmb2/DeadLetterPacketData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C)2016 - SMBJ Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.hierynomus.mssmb2; | ||
|
||
import com.hierynomus.smb.SMBHeader; | ||
import com.hierynomus.smb.SMBPacketData; | ||
|
||
/** | ||
* Ignore this packet... | ||
*/ | ||
public class DeadLetterPacketData extends SMBPacketData<SMBHeader> { | ||
public DeadLetterPacketData(SMBHeader header) { | ||
super(header); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/hierynomus/mssmb2/SMB2CompressionTransformHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C)2016 - SMBJ Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.hierynomus.mssmb2; | ||
|
||
import com.hierynomus.protocol.commons.EnumWithValue; | ||
import com.hierynomus.protocol.commons.buffer.Buffer; | ||
import com.hierynomus.smb.SMBBuffer; | ||
import com.hierynomus.smb.SMBHeader; | ||
import com.hierynomus.smbj.common.Check; | ||
|
||
/** | ||
* [MS-SMB2] 2.2.42 SMB2 COMPRESSION_TRANSFORM_HEADER | ||
* <p> | ||
* The SMB2 COMPRESSION_TRANSFORM_HEADER is used by the client or server when sending compressed messages. | ||
* This optional header is only valid for the SMB 3.1.1 dialect<73>. | ||
*/ | ||
public class SMB2CompressionTransformHeader implements SMBHeader { | ||
public static final byte[] COMPRESSED_PROTOCOL_ID = {(byte) 0xFC, 'S', 'M', 'B'}; | ||
private int headerStartPosition; | ||
private int originalCompressedSegmentSize; | ||
private SMB3CompressionAlgorithm compressionAlgorithm; | ||
private int offset; | ||
private int messageEndPosition; | ||
|
||
@Override | ||
public void writeTo(SMBBuffer buffer) { | ||
|
||
} | ||
|
||
@Override | ||
public void readFrom(Buffer<?> buffer) throws Buffer.BufferException { | ||
this.headerStartPosition = buffer.rpos(); // Keep track of the header start position. | ||
byte[] protocolId = buffer.readRawBytes(4); // ProtocolId (4 bytes) (already verified) | ||
Check.ensureEquals(protocolId, COMPRESSED_PROTOCOL_ID, "Could not find SMB2 Packet header"); | ||
this.originalCompressedSegmentSize = buffer.readUInt32AsInt(); // OriginalCompressedSegmentSize (4 bytes) | ||
this.compressionAlgorithm = EnumWithValue.EnumUtils.valueOf(buffer.readUInt16(), SMB3CompressionAlgorithm.class, null); | ||
Check.ensure(compressionAlgorithm != null && compressionAlgorithm != SMB3CompressionAlgorithm.NONE, "The CompressionAlgorithm field of the SMB2_COMPRESSION_TRANSFORM_HEADER should contain a valid value."); | ||
buffer.skip(2); | ||
this.offset = buffer.readUInt32AsInt(); // Offset (4 bytes) | ||
this.messageEndPosition = buffer.wpos(); | ||
} | ||
|
||
@Override | ||
public int getHeaderStartPosition() { | ||
return headerStartPosition; | ||
} | ||
|
||
@Override | ||
public int getMessageEndPosition() { | ||
return messageEndPosition; | ||
} | ||
|
||
public int getOriginalCompressedSegmentSize() { | ||
return originalCompressedSegmentSize; | ||
} | ||
|
||
public SMB3CompressionAlgorithm getCompressionAlgorithm() { | ||
return compressionAlgorithm; | ||
} | ||
|
||
public int getOffset() { | ||
return offset; | ||
} | ||
} |
Oops, something went wrong.