Skip to content

Commit 08abd1c

Browse files
committed
Refactor file handling in Encryption and Decryption classes; add deleteFile method in TempFile class and clean up unused comments
1 parent 8cb3f2a commit 08abd1c

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
##############################
44
.mtj.tmp/
55
*.class
6-
*.jar
6+
77
*.war
88
*.ear
99
*.nar

PyCript-Websocket.jar

167 KB
Binary file not shown.

src/main/java/com/pycriptsocket/Decryption.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ public ByteArray decryptAndPassToTempFile(ByteArray content) {
1010
TempFile tempFile = new TempFile();
1111
String tempFilePath = tempFile.processData(decryptedContent);
1212

13-
// Get the decryption file path from the UI class
1413
String decryptionFilePath = UI.getInstance().getDecryptionFilePath();
1514

16-
// Call the Execution class to run the system command
1715
Execution execution = new Execution();
1816
boolean success = execution.runCommand(decryptionFilePath, tempFilePath);
1917

2018
if (success) {
21-
// Read the updated content from the temp file
2219
String updatedContent = tempFile.readFileContent(tempFilePath);
20+
boolean isDeleted = tempFile.deleteFile(tempFilePath);
21+
if (isDeleted) {
22+
System.out.println("Temporary file deleted successfully.");
23+
} else {
24+
System.out.println("Failed to delete the temporary file.");
25+
}
2326
return ByteArray.byteArray(updatedContent);
2427
} else {
25-
// Return the original content if the execution was not successful
2628
return content;
2729
}
2830
}

src/main/java/com/pycriptsocket/Encryption.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@ public ByteArray encryptAndPassToTempFile(ByteArray content) {
99

1010
TempFile tempFile = new TempFile();
1111
String tempFilePath = tempFile.processData(encryptedContent);
12-
13-
// Get the encryption file path from the UI class
1412
String encryptionFilePath = UI.getInstance().getEncryptionFilePath();
1513

1614
// Call the Execution class to run the system command
1715
Execution execution = new Execution();
1816
boolean success = execution.runCommand(encryptionFilePath, tempFilePath);
1917

2018
if (success) {
21-
// Read the updated content from the temp file
2219
String updatedContent = tempFile.readFileContent(tempFilePath);
20+
boolean isDeleted = tempFile.deleteFile(tempFilePath);
21+
if (isDeleted) {
22+
System.out.println("Temporary file deleted successfully.");
23+
} else {
24+
System.out.println("Failed to delete the temporary file.");
25+
}
2326
return ByteArray.byteArray(updatedContent);
2427
} else {
25-
// Return the original content if the execution was not successful
2628
return content;
2729
}
2830
}

src/main/java/com/pycriptsocket/PyCript.java

-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ public class PyCript implements BurpExtension
1717
@Override
1818
public void initialize(MontoyaApi api)
1919
{
20-
// set extension name
2120
api.extension().setName("PyCript WebSocket");
2221

2322
Logging logging = api.logging();
2423
logging.logToOutput("Author: Sourav Kalal");
2524
logging.logToOutput("VERSION: 0.1");
2625
logging.logToOutput("GitHub - https://github.com/Anof-cyber/PyCript-WebSocket");
2726
logging.logToOutput("Website - https://souravkalal.tech/");
28-
logging.logToOutput("Documentation - https://pycript.souravkalal.tech/");
2927
api.userInterface().registerSuiteTab("PyCript WebSocket", new UI(api));
3028

3129
api.userInterface().registerWebSocketMessageEditorProvider(new WebSocketEditorProvider(api));

src/main/java/com/pycriptsocket/TempFile.java

+5
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public String readFileContent(String filePath) {
3030
return null;
3131
}
3232
}
33+
34+
public boolean deleteFile(String filePath) {
35+
File file = new File(filePath);
36+
return file.delete();
37+
}
3338
}

0 commit comments

Comments
 (0)