Created
June 15, 2016 15:38
-
-
Save rsmudge/bfe022245fb0f5491950b0e58cc80e0b to your computer and use it in GitHub Desktop.
Demonstration inversion-of-control using co-routines in Aggressor Script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demonstrate an example of inversion-of-control with Aggressor Script | |
# | |
# co-routine, | |
sub bot { | |
# run pwd and get the output. | |
bpwd($bid); | |
when("beacon_output_alt", $this); | |
yield; | |
println("WD of $bid is: $2 @ " . formatDate($3, "HH:mm:ss")); | |
# change directory. | |
bcd($bid, "c:\\"); | |
# list files with dir! | |
bshell($bid, "dir"); | |
when("beacon_output", $this); | |
yield; | |
println("Dir of c:\\ on $bid @ " . formatDate($3, "HH:mm:ss") . ":\n $+ $2"); | |
# list files with ls (which takes a callback) | |
bls($bid, ".", $this); | |
yield; | |
println("Dir of c:\\ with ls():\n" . $3); | |
} | |
alias go { | |
# create a copy of the &bot function with $bid = beacon id set in the function's scope | |
# [all that stuff] invokes the function | |
[lambda(&bot, $bid => $1)]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment