Рефакторинг
This commit is contained in:
@@ -101,7 +101,8 @@ public class PatternMatcher {
|
||||
}
|
||||
|
||||
private void addIfPossible(FoundPattern found) {
|
||||
if (result.stream().noneMatch(match -> between(match.getStartPosition(), match.getEndPosition(), found.getStartPosition()) ||
|
||||
if (result.stream().noneMatch(match ->
|
||||
between(match.getStartPosition(), match.getEndPosition(), found.getStartPosition()) ||
|
||||
between(match.getStartPosition(), match.getEndPosition(), found.getEndPosition()))) {
|
||||
result.add(found);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ import java.util.regex.Pattern;
|
||||
@RequiredArgsConstructor
|
||||
public class TlsDecryptor {
|
||||
|
||||
private static final Pattern cipherSuitePattern = Pattern.compile("TLS_RSA_WITH_([A-Z0-9_]+)_([A-Z0-9]+)");
|
||||
private static final Pattern cipherSuitePattern = Pattern.compile("TLS_RSA_WITH_([A-Z0-9_]+)_[A-Z0-9]+");
|
||||
|
||||
private final List<Packet> packets;
|
||||
private final RsaKeysHolder keysHolder;
|
||||
@@ -91,24 +91,23 @@ public class TlsDecryptor {
|
||||
Matcher matcher = cipherSuitePattern.matcher(cipherSuite.name());
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
matcher.find();
|
||||
String blockCipher = matcher.group(1); //TODO использовать не только AES256
|
||||
String hashAlgo = matcher.group(2);
|
||||
String blockCipher = matcher.group(1);
|
||||
|
||||
clientRandom = clientHello.getRandom();
|
||||
serverRandom = serverHello.getRandom();
|
||||
|
||||
decryptTlsRsa(blockCipher, hashAlgo);
|
||||
decryptTlsRsa(blockCipher);
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private void decryptTlsRsa(String blockCipher, String hashAlgo) {
|
||||
private void decryptTlsRsa(String blockCipher) {
|
||||
String[] blockCipherParts = blockCipher.split("_");
|
||||
String blockCipherAlgo = blockCipherParts[0];
|
||||
int blockCipherSize = Integer.parseInt(blockCipherParts[1]);
|
||||
String blockCipherMode = blockCipherParts[2];
|
||||
|
||||
if (!blockCipherAlgo.equals("AES")) {
|
||||
if (!blockCipherAlgo.equals("AES")) { //TODO использовать не только AES256
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -141,7 +140,7 @@ public class TlsDecryptor {
|
||||
TlsSecret masterSecret = preMaster.deriveUsingPRF(
|
||||
PRFAlgorithm.tls_prf_sha256, ExporterLabel.master_secret, randomCS, 48);
|
||||
byte[] expanded = masterSecret.deriveUsingPRF(
|
||||
PRFAlgorithm.tls_prf_sha256, ExporterLabel.key_expansion, randomSC, 72 + keyLength * 2).extract(); // для sha256
|
||||
PRFAlgorithm.tls_prf_sha256, ExporterLabel.key_expansion, randomSC, 72 + keyLength * 2).extract();
|
||||
|
||||
byte[] clientMacKey = new byte[20];
|
||||
byte[] serverMacKey = new byte[20];
|
||||
|
||||
@@ -2,7 +2,6 @@ package ru.serega6531.packmate;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import ru.serega6531.packmate.model.CtfService;
|
||||
import ru.serega6531.packmate.model.Packet;
|
||||
import ru.serega6531.packmate.service.optimization.HttpGzipProcessor;
|
||||
import ru.serega6531.packmate.service.optimization.HttpUrldecodeProcessor;
|
||||
@@ -34,9 +33,6 @@ class StreamOptimizerTest {
|
||||
|
||||
@Test
|
||||
void testUrldecodeRequests() {
|
||||
CtfService service = new CtfService();
|
||||
service.setUrldecodeHttpRequests(true);
|
||||
|
||||
Packet p = createPacket("GET /?q=%D0%B0+%D0%B1 HTTP/1.1\r\n\r\n".getBytes(), true);
|
||||
List<Packet> list = new ArrayList<>();
|
||||
list.add(p);
|
||||
@@ -48,9 +44,6 @@ class StreamOptimizerTest {
|
||||
|
||||
@Test
|
||||
void testMergeAdjacentPackets() {
|
||||
CtfService service = new CtfService();
|
||||
service.setMergeAdjacentPackets(true);
|
||||
|
||||
Packet p1 = createPacket(1, false);
|
||||
Packet p2 = createPacket(2, true);
|
||||
Packet p3 = createPacket(3, true);
|
||||
|
||||
Reference in New Issue
Block a user