Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/core/packetproxy/DuplexFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@

public class DuplexFactory {
// 1MB以上のパケットは最後のタイミングだけHistoryに記録する、それ未満はパケットが更新されるたびにHistoryを更新する

private static void applyResendBatchFromOneshot(OneShotPacket oneshot, Packet packet) {
if (oneshot.getResendBatchId() == 0) {
return;
}
packet.setResendBatchId(oneshot.getResendBatchId());
packet.setResendSourceId(oneshot.getResendSourceId());
}

static final int SKIP_LENGTH = 1 * 1024 * 1024;
// 10MB以上のパケットはHistoryには記録しない
static final int TOO_LARGE_LENGTH = 10 * 1024 * 1024;
Expand Down Expand Up @@ -412,6 +421,7 @@ public byte[] onClientChunkSend(byte[] data) throws Exception {
client_packet = new Packet(0, oneshot.getClient(), oneshot.getServer(), oneshot.getServerName(),
oneshot.getUseSSL(), oneshot.getEncoder(), oneshot.getAlpn(), Packet.Direction.CLIENT,
duplex.hashCode(), UniqueID.getInstance().createId());
applyResendBatchFromOneshot(oneshot, client_packet);
client_packet.setModified();
client_packet.setReceivedData(data);
client_packet.setDecodedData(data);
Expand Down Expand Up @@ -559,6 +569,7 @@ public byte[] onServerChunkReceived(byte[] data) throws Exception {
client_packet = new Packet(0, oneshot.getClient(), oneshot.getServer(), oneshot.getServerName(),
oneshot.getUseSSL(), oneshot.getEncoder(), oneshot.getAlpn(), Packet.Direction.CLIENT,
duplex.hashCode(), packetproxy.common.UniqueID.getInstance().createId());
applyResendBatchFromOneshot(oneshot, client_packet);
client_packet.setDecodedData(oneshot.getData());
client_packet.setModifiedData(oneshot.getData());
client_packet.setResend();
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/core/packetproxy/controller/ResendController.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import packetproxy.DuplexManager;
import packetproxy.EncoderManager;
import packetproxy.common.I18nString;
import packetproxy.common.UniqueID;
import packetproxy.encode.EncodeHTTPBase;
import packetproxy.encode.Encoder;
import packetproxy.gui.ResendBatchService;
import packetproxy.http.Http;
import packetproxy.model.OneShotPacket;
import packetproxy.model.Packet;
Expand Down Expand Up @@ -113,11 +115,23 @@ protected Object doInBackground() throws Exception {
try {

ArrayList<DataToBeSend> list = new ArrayList<DataToBeSend>();
long batchId = 0;
if (this.oneshot != null && this.count > 1) {

batchId = UniqueID.getInstance().createId();
ResendBatchService.getInstance().registerPendingBatch(batchId, this.oneshot.getId(), this.count);
}
if (this.oneshot != null && this.count > 0) {

for (int i = 0; i < this.count; i++) {

DataToBeSend sendData = new DataToBeSend(this.oneshot, result -> {
var sendOneshot = (OneShotPacket) this.oneshot.clone();
if (batchId != 0) {

sendOneshot.setResendBatchId(batchId);
sendOneshot.setResendSourceId(this.oneshot.getId());
}
DataToBeSend sendData = new DataToBeSend(sendOneshot, result -> {
publish(result);
});
list.add(sendData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import packetproxy.DuplexFactory;
import packetproxy.DuplexSync;
import packetproxy.EncoderManager;
import packetproxy.common.UniqueID;
import packetproxy.gui.ResendBatchService;
import packetproxy.http2.frames.DataFrame;
import packetproxy.http2.frames.Frame;
import packetproxy.http2.frames.FrameUtils;
Expand All @@ -34,6 +36,7 @@
import packetproxy.model.Packet;

public class SinglePacketAttackController {
private final OneShotPacket oneshot;
private final AttackFrames baseAttackFrames;
private final DuplexSync attackConnection;
private final int sleepTimeMs;
Expand All @@ -60,6 +63,7 @@ public SinglePacketAttackController(final OneShotPacket oneshot, final int sleep
"GET requests are not supported by Single Packet Attack because they cannot have DATA frames in HTTP/2.");
}

this.oneshot = oneshot;
this.attackConnection = DuplexFactory.createDuplexSyncForSinglePacketAttack(oneshot);
this.baseAttackFrames = generateAttackFrames(oneshot);
this.sleepTimeMs = sleepTimeMs;
Expand All @@ -70,6 +74,13 @@ public void attack(final int count) throws Exception {
return;
}

if (count > 1) {
var batchId = UniqueID.getInstance().createId();
oneshot.setResendBatchId(batchId);
oneshot.setResendSourceId(oneshot.getId());
ResendBatchService.getInstance().registerPendingBatch(batchId, oneshot.getId(), count);
}

sendConnectionPreface();
launchAttack(count);
}
Expand Down
Loading