forked from hierynomus/smbj
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Correctly set AvFlags if NtlmChallenge contains MIC Signed-off-by: Jeroen van Erp <[email protected]> * Reworking and testing NTLM authentication Signed-off-by: Jeroen van Erp <[email protected]> * Make lift happy & continue refactoring Signed-off-by: Jeroen van Erp <[email protected]> * Made negotiate complete according to MS-NLMP Signed-off-by: Jeroen van Erp <[email protected]> * Fix test Signed-off-by: Jeroen van Erp <[email protected]> * Fix normal integration tests Signed-off-by: Jeroen van Erp <[email protected]> * More tests for NtlmFunctions Signed-off-by: Jeroen van Erp <[email protected]> * Fix configs Signed-off-by: Jeroen van Erp <[email protected]> * Correctly reset PredictableRandom between tests Signed-off-by: Jeroen van Erp <[email protected]> * Do not send time as part of clientTargetInfo Signed-off-by: Jeroen van Erp <[email protected]> * Fix some warnings Signed-off-by: Jeroen van Erp <[email protected]> * Attempt NtlmAuthenticate with raw NtlmChallenge TargetInfo This is one of the differences found in the authentication between 0.10.0 and 0.11.0 Signed-off-by: Jeroen van Erp <[email protected]> * Added trace logging to log Ntlm message flow Signed-off-by: Jeroen van Erp <[email protected]> * Revert "Attempt NtlmAuthenticate with raw NtlmChallenge TargetInfo" This reverts commit 5d281dc. * Fix domain/workstation mixup Signed-off-by: Jeroen van Erp <[email protected]> * Added NtlmConfig.integrity boolean Signed-off-by: Jeroen van Erp <[email protected]> * Don't render MIC in NtlmAuthenticate is integrity disabled Signed-off-by: Jeroen van Erp <[email protected]> * Correct offsets and configurably omit version from messages Signed-off-by: Jeroen van Erp <[email protected]> * Temporary fix don't send MsvAvFlags 0x02 Signed-off-by: Jeroen van Erp <[email protected]> * Refactor TargetInformation to separate AvPairs Signed-off-by: Jeroen van Erp <[email protected]> * Fix JavaDoc warnings Signed-off-by: Jeroen van Erp <[email protected]> * Some more tests Signed-off-by: Jeroen van Erp <[email protected]> * Temporarily disabled NtlmConfig.integrity Signed-off-by: Jeroen van Erp <[email protected]> --------- Signed-off-by: Jeroen van Erp <[email protected]>
- Loading branch information
1 parent
6a2c0b3
commit 410e631
Showing
53 changed files
with
1,731 additions
and
468 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 |
---|---|---|
|
@@ -24,3 +24,6 @@ test-output/ | |
.vscode/ | ||
.java-version | ||
|
||
.metals | ||
.bloop |
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
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,93 @@ | ||
/* | ||
* 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.ntlm; | ||
|
||
import com.hierynomus.ntlm.messages.WindowsVersion; | ||
|
||
public class NtlmConfig { | ||
private WindowsVersion windowsVersion; | ||
private String workstationName; | ||
private boolean integrity; | ||
private boolean omitVersion; | ||
|
||
public static NtlmConfig defaultConfig() { | ||
return builder().build(); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
private NtlmConfig() { | ||
} | ||
|
||
private NtlmConfig(NtlmConfig other) { | ||
this.windowsVersion = other.windowsVersion; | ||
this.workstationName = other.workstationName; | ||
this.integrity = other.integrity; | ||
this.omitVersion = other.omitVersion; | ||
} | ||
|
||
public WindowsVersion getWindowsVersion() { | ||
return windowsVersion; | ||
} | ||
|
||
public String getWorkstationName() { | ||
return workstationName; | ||
} | ||
|
||
public boolean isIntegrityEnabled() { | ||
return integrity; | ||
} | ||
|
||
public boolean isOmitVersion() { | ||
return omitVersion; | ||
} | ||
|
||
public static class Builder { | ||
private NtlmConfig config; | ||
|
||
public Builder() { | ||
config = new NtlmConfig(); | ||
config.integrity = false; // TODO temporarily disabled until we can figure out why it fails (probably mechListMIC in NegTokenTarg) | ||
config.omitVersion = false; | ||
} | ||
|
||
public Builder withWindowsVersion(WindowsVersion windowsVersion) { | ||
config.windowsVersion = windowsVersion; | ||
return this; | ||
} | ||
|
||
public Builder withWorkstationName(String workstationName) { | ||
config.workstationName = workstationName; | ||
return this; | ||
} | ||
|
||
public Builder withIntegrity(boolean integrity) { | ||
config.integrity = integrity; | ||
return this; | ||
} | ||
|
||
public Builder withOmitVersion(boolean omitVersion) { | ||
config.omitVersion = omitVersion; | ||
return this; | ||
} | ||
|
||
public NtlmConfig build() { | ||
return new NtlmConfig(config); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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.ntlm.av; | ||
|
||
import com.hierynomus.protocol.commons.buffer.Buffer; | ||
|
||
public abstract class AvPair<T> { | ||
|
||
protected AvId avId; | ||
protected T value; | ||
|
||
public AvPair(AvId avId) { | ||
this.avId = avId; | ||
} | ||
|
||
public AvPair(AvId avId, T value) { | ||
this.avId = avId; | ||
this.value = value; | ||
} | ||
|
||
public abstract void write(Buffer<?> buffer); | ||
|
||
public abstract AvPair<T> read(Buffer<?> buffer) throws Buffer.BufferException; | ||
|
||
public AvId getAvId() { | ||
return avId; | ||
} | ||
|
||
public T getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AvPair{" + | ||
"avId=" + avId.name() + | ||
", value=" + value + | ||
'}'; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/hierynomus/ntlm/av/AvPairChannelBindings.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,40 @@ | ||
/* | ||
* 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.ntlm.av; | ||
|
||
import com.hierynomus.protocol.commons.buffer.Buffer; | ||
import com.hierynomus.protocol.commons.buffer.Buffer.BufferException; | ||
|
||
public class AvPairChannelBindings extends AvPair<byte[]> { | ||
|
||
AvPairChannelBindings() { | ||
super(AvId.MsvAvChannelBindings); | ||
} | ||
|
||
@Override | ||
public void write(Buffer<?> buffer) { | ||
buffer.putUInt16((int) this.avId.getValue()); // AvId (2 bytes) | ||
buffer.putUInt16(value.length); // AvLen (2 bytes) | ||
buffer.putRawBytes(value); // Value (AvLen bytes) | ||
} | ||
|
||
@Override | ||
public AvPair<byte[]> read(Buffer<?> buffer) throws BufferException { | ||
int length = buffer.readUInt16(); // AvLen (2 bytes) | ||
this.value = buffer.readRawBytes(length); // Value (AvLen bytes) | ||
return this; | ||
} | ||
} |
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,38 @@ | ||
/* | ||
* 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.ntlm.av; | ||
|
||
import com.hierynomus.protocol.commons.buffer.Buffer; | ||
import com.hierynomus.protocol.commons.buffer.Buffer.BufferException; | ||
|
||
public class AvPairEnd extends AvPair<Void> { | ||
|
||
public AvPairEnd() { | ||
super(AvId.MsvAvEOL); | ||
} | ||
|
||
@Override | ||
public void write(Buffer<?> buffer) { | ||
buffer.putUInt16((int) this.avId.getValue()); // AvId (2 bytes) | ||
buffer.putUInt16(0); // AvLen (2 bytes) | ||
} | ||
|
||
@Override | ||
public AvPair<Void> read(Buffer<?> buffer) throws BufferException { | ||
buffer.readUInt16(); // AvLen (2 bytes) | ||
return this; | ||
} | ||
} |
Oops, something went wrong.