Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wdahlenburg committed Aug 28, 2021
1 parent 0706eed commit 306dd73
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/interactsh/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public boolean registerClient() throws Exception {
+ "Host: " + host + "\r\n"
+ "User-Agent: Interact.sh Client\r\n"
+ "Content-Type: application/json\r\n"
+ "Content-Length: " + registerData.toString().length() + "\r\n"
+ "Connection: close\r\n\r\n"
+ registerData.toString();

Expand All @@ -60,7 +61,7 @@ public boolean registerClient() throws Exception {
}

public boolean poll() throws IOException, InterruptedException {
String request = "GET /poll?id=" + correlationId + "&secret=" + secretKey + "\r\n"
String request = "GET /poll?id=" + correlationId + "&secret=" + secretKey + " HTTP/1.1\r\n"
+ "Host: " + host + "\r\n"
+ "User-Agent: Interact.sh Client\r\n"
+ "Connection: close\r\n\r\n";
Expand Down Expand Up @@ -99,15 +100,16 @@ public boolean poll() throws IOException, InterruptedException {
public void deregister(){
callbacks.printOutput("Deregistering " + correlationId);
try {
JSONObject registerData = new JSONObject();
registerData.put("correlation-id", correlationId);
JSONObject deregisterData = new JSONObject();
deregisterData.put("correlation-id", correlationId);

String request = "POST /deregister HTTP/1.1\r\n"
+ "Host: " + host + "\r\n"
+ "User-Agent: Interact.sh Client\r\n"
+ "Content-Type: application/json\r\n"
+ "Content-Length: " + deregisterData.toString().length() + "\r\n"
+ "Connection: close\r\n\r\n"
+ registerData.toString();
+ deregisterData.toString();

callbacks.makeHttpRequest(host, port, scheme, request.getBytes(StandardCharsets.UTF_8));
}catch (Exception ex){
Expand All @@ -116,7 +118,7 @@ public void deregister(){
}

public String getInteractDomain(){
if (correlationId.isEmpty()){
if (correlationId == null || correlationId.isEmpty()){
return "";
} else {
String fullDomain = correlationId;
Expand All @@ -141,12 +143,12 @@ public void generateKeys() throws NoSuchAlgorithmException {
}

private String getPublicKey(){
String pubKey = "-----BEGIN RSA PUBLIC KEY-----\n";
String pubKey = "-----BEGIN PUBLIC KEY-----\n";
String [] chunks = splitStringEveryN(Base64.getEncoder().encodeToString(publicKey.getEncoded()), 64);
for (String chunk: chunks) {
pubKey += chunk + "\n";
}
pubKey += "-----END RSA PUBLIC KEY-----\n";
pubKey += "-----END PUBLIC KEY-----\n";
return pubKey;
}

Expand Down

0 comments on commit 306dd73

Please sign in to comment.