Skip to content

Commit adb6d27

Browse files
committed
Launch and Terminate Redis
1 parent ab6b092 commit adb6d27

8 files changed

Lines changed: 61 additions & 16 deletions

File tree

AdversaryLabSwift.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
460CF7E82076C76D00FB3723 /* ShutdownRedisServerScript.sh in Resources */ = {isa = PBXBuildFile; fileRef = 460CF7E72076C76D00FB3723 /* ShutdownRedisServerScript.sh */; };
1414
460CF7EA2076EB0800FB3723 /* redis.conf in Resources */ = {isa = PBXBuildFile; fileRef = 460CF7E92076EB0800FB3723 /* redis.conf */; };
1515
460CF7EC2076F75A00FB3723 /* redis-cli in Resources */ = {isa = PBXBuildFile; fileRef = 460CF7EB2076F75A00FB3723 /* redis-cli */; };
16+
4610875E207BE18D00E7EC50 /* subsequences.so in Resources */ = {isa = PBXBuildFile; fileRef = 4610875D207BE18D00E7EC50 /* subsequences.so */; };
1617
46175B6920253F86009311D6 /* FakeConnectionGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46175B6820253F86009311D6 /* FakeConnectionGenerator.swift */; };
1718
46175B6C202CE3DB009311D6 /* Entropy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46175B6B202CE3DB009311D6 /* Entropy.swift */; };
1819
46175B75202D2CDE009311D6 /* ConnectionInspector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46175B74202D2CDE009311D6 /* ConnectionInspector.swift */; };
@@ -136,6 +137,7 @@
136137
460CF7E72076C76D00FB3723 /* ShutdownRedisServerScript.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ShutdownRedisServerScript.sh; sourceTree = "<group>"; };
137138
460CF7E92076EB0800FB3723 /* redis.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = redis.conf; sourceTree = "<group>"; };
138139
460CF7EB2076F75A00FB3723 /* redis-cli */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = "redis-cli"; sourceTree = "<group>"; };
140+
4610875D207BE18D00E7EC50 /* subsequences.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.bundle"; path = subsequences.so; sourceTree = "<group>"; };
139141
46175B6820253F86009311D6 /* FakeConnectionGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeConnectionGenerator.swift; sourceTree = "<group>"; };
140142
46175B6B202CE3DB009311D6 /* Entropy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Entropy.swift; sourceTree = "<group>"; };
141143
46175B74202D2CDE009311D6 /* ConnectionInspector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionInspector.swift; sourceTree = "<group>"; };
@@ -228,6 +230,7 @@
228230
460CF7E72076C76D00FB3723 /* ShutdownRedisServerScript.sh */,
229231
460CF7E52076C3D800FB3723 /* LaunchRedisServerScript.sh */,
230232
460CF7E92076EB0800FB3723 /* redis.conf */,
233+
4610875D207BE18D00E7EC50 /* subsequences.so */,
231234
460CF7D220758D2C00FB3723 /* redis-server */,
232235
460CF7EB2076F75A00FB3723 /* redis-cli */,
233236
CA727CD32050A3580051A01B /* README.md */,
@@ -481,6 +484,7 @@
481484
460CF7E62076C3D800FB3723 /* LaunchRedisServerScript.sh in Resources */,
482485
4651A15820083BF700037D31 /* Main.storyboard in Resources */,
483486
460CF7E82076C76D00FB3723 /* ShutdownRedisServerScript.sh in Resources */,
487+
4610875E207BE18D00E7EC50 /* subsequences.so in Resources */,
484488
460CF7EC2076F75A00FB3723 /* redis-cli in Resources */,
485489
460CF7DA20758D2C00FB3723 /* redis-server in Resources */,
486490
460CF7EA2076EB0800FB3723 /* redis.conf in Resources */,

AdversaryLabSwift.xcodeproj/xcuserdata/Lita.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
ignoreCount = "0"
2929
continueAfterRunningActions = "No"
3030
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Redshot.git--1606376773459246887/Sources/RedShot/Redis.swift"
31-
timestampString = "543950885.7720571"
31+
timestampString = "544990295.811321"
3232
startingColumnNumber = "9223372036854775807"
3333
endingColumnNumber = "9223372036854775807"
3434
startingLineNumber = "73"
@@ -44,7 +44,7 @@
4444
ignoreCount = "0"
4545
continueAfterRunningActions = "No"
4646
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Redshot.git--1606376773459246887/Sources/RedShot/Redis.swift"
47-
timestampString = "543950885.773041"
47+
timestampString = "544990295.811849"
4848
startingColumnNumber = "9223372036854775807"
4949
endingColumnNumber = "9223372036854775807"
5050
startingLineNumber = "82"
@@ -60,7 +60,7 @@
6060
ignoreCount = "0"
6161
continueAfterRunningActions = "No"
6262
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Redshot.git--1606376773459246887/Sources/RedShot/Redis.swift"
63-
timestampString = "543950885.77363"
63+
timestampString = "544990295.812132"
6464
startingColumnNumber = "9223372036854775807"
6565
endingColumnNumber = "9223372036854775807"
6666
startingLineNumber = "78"
@@ -76,7 +76,7 @@
7676
ignoreCount = "0"
7777
continueAfterRunningActions = "No"
7878
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Redshot.git--1606376773459246887/Sources/RedShot/Redis.swift"
79-
timestampString = "543950885.774137"
79+
timestampString = "544990295.812405"
8080
startingColumnNumber = "9223372036854775807"
8181
endingColumnNumber = "9223372036854775807"
8282
startingLineNumber = "79"
@@ -92,7 +92,7 @@
9292
ignoreCount = "0"
9393
continueAfterRunningActions = "No"
9494
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Redshot.git--1606376773459246887/Sources/RedShot/Redis.swift"
95-
timestampString = "543950885.7746069"
95+
timestampString = "544990295.8126709"
9696
startingColumnNumber = "9223372036854775807"
9797
endingColumnNumber = "9223372036854775807"
9898
startingLineNumber = "88"
@@ -108,7 +108,7 @@
108108
ignoreCount = "0"
109109
continueAfterRunningActions = "No"
110110
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Redshot.git--1606376773459246887/Sources/RedShot/Redis.swift"
111-
timestampString = "543950885.775086"
111+
timestampString = "544990295.812938"
112112
startingColumnNumber = "9223372036854775807"
113113
endingColumnNumber = "9223372036854775807"
114114
startingLineNumber = "93"
@@ -117,5 +117,37 @@
117117
landmarkType = "7">
118118
</BreakpointContent>
119119
</BreakpointProxy>
120+
<BreakpointProxy
121+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
122+
<BreakpointContent
123+
shouldBeEnabled = "Yes"
124+
ignoreCount = "0"
125+
continueAfterRunningActions = "No"
126+
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Auburn.git-2950637113269748138/Sources/Auburn/RSortedSet.swift"
127+
timestampString = "544985013.758042"
128+
startingColumnNumber = "9223372036854775807"
129+
endingColumnNumber = "9223372036854775807"
130+
startingLineNumber = "516"
131+
endingLineNumber = "516"
132+
landmarkName = "addSubsequences(sequence:)"
133+
landmarkType = "7">
134+
</BreakpointContent>
135+
</BreakpointProxy>
136+
<BreakpointProxy
137+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
138+
<BreakpointContent
139+
shouldBeEnabled = "No"
140+
ignoreCount = "0"
141+
continueAfterRunningActions = "No"
142+
filePath = "AdversaryLabSwiftPackage/.build/checkouts/Redshot.git--1606376773459246887/Sources/RedShot/Redis.swift"
143+
timestampString = "544990295.813236"
144+
startingColumnNumber = "9223372036854775807"
145+
endingColumnNumber = "9223372036854775807"
146+
startingLineNumber = "65"
147+
endingLineNumber = "65"
148+
landmarkName = "sendCommand(_:values:)"
149+
landmarkType = "7">
150+
</BreakpointContent>
151+
</BreakpointProxy>
120152
</Breakpoints>
121153
</Bucket>

AdversaryLabSwift/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ class AppDelegate: NSObject, NSApplicationDelegate
2424

2525
}
2626

27-
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
27+
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply
28+
{
2829
// Quit Redis Server
2930
print("TERMINATE Redis Server. 🤖")
3031
RedisServerController.sharedInstance.shutdownRedisServer()
3132
sleep(1)
3233
return NSApplication.TerminateReply.terminateNow
3334
}
35+
3436
func applicationWillTerminate(_ aNotification: Notification)
3537
{
3638

AdversaryLabSwift/Controllers/RedisServerController.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@ class RedisServerController: NSObject
1818
{
1919
let bundle = Bundle.main
2020

21+
guard let redisConfigPath = bundle.path(forResource: "redis", ofType: "conf")
22+
else
23+
{
24+
print("Unable to launch Redis server: could not find terraform executable.")
25+
return
26+
}
27+
2128
guard let redisPath = bundle.path(forResource: "redis-server", ofType: nil)
2229
else
2330
{
24-
print("Unable to launch Redis server. Could not find terraform executable.")
31+
print("Unable to launch Redis server: could not find terraform executable.")
2532
return
2633
}
2734

28-
guard let redisConfigPath = bundle.path(forResource: "redis", ofType: "conf")
35+
guard let redisModulePath = bundle.path(forResource: "subsequences", ofType: "so")
2936
else
3037
{
31-
print("Unable to launch Redis server. Could not find terraform executable.")
38+
print("Unable to launch Redis server: could not find the needed module.")
3239
return
3340
}
3441

@@ -42,7 +49,7 @@ class RedisServerController: NSObject
4249
print("\n👇👇 Running Script 👇👇:\n")
4350
print("Path 🚶‍♀️: \n\(path)\n")
4451
print("Arguments: \n\(redisPath)\n\(redisConfigPath)\n")
45-
runRedisScript(path: path, arguments: [redisPath, redisConfigPath])
52+
runRedisScript(path: path, arguments: [redisPath, redisConfigPath, redisModulePath])
4653
{
4754
(hasCompleted) in
4855

AdversaryLabSwift/Features/Sequences.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ func processOffsetSequences(forConnection connection: ObservedConnection) -> (pr
2323

2424
let outFloatingSequenceSet: RSortedSet<Data> = RSortedSet(key: connection.outgoingFloatingSequencesKey)
2525
let outCount = outFloatingSequenceSet.addSubsequences(sequence: outPacket)
26-
NSLog("Added \(outCount) outgoing subsequences")
26+
NSLog("Added \(String(describing: outCount)) outgoing subsequences")
2727
for offset in 0..<outPacket.count {
2828
let offsetKey = connection.outgoingOffsetSequencesKey + ":" + offset.string
2929
let outOffsetSequenceSet: RSortedSet<Data> = RSortedSet(key: offsetKey)
3030
let outOffCount = outOffsetSequenceSet.addSubsequences(sequence: outPacket)
31-
NSLog("Added \(outOffCount) outgoing subsequences for offset \(offset)")
31+
NSLog("Added \(String(describing: outOffCount)) outgoing subsequences for offset \(offset)")
3232
}
3333

3434
// Get the in packet that corresponds with this connection ID
@@ -41,12 +41,12 @@ func processOffsetSequences(forConnection connection: ObservedConnection) -> (pr
4141

4242
let inFloatingSequenceSet: RSortedSet<Data> = RSortedSet(key: connection.incomingFloatingSequencesKey)
4343
let inCount = inFloatingSequenceSet.addSubsequences(sequence: inPacket)
44-
NSLog("Added \(inCount) incoming subsequences")
44+
NSLog("Added \(String(describing: inCount)) incoming subsequences")
4545
for offset in 0..<inPacket.count {
4646
let offsetKey = connection.incomingOffsetSequencesKey + ":" + offset.string
4747
let inOffsetSequenceSet: RSortedSet<Data> = RSortedSet(key: offsetKey)
4848
let inOffCount = inOffsetSequenceSet.addSubsequences(sequence: inPacket)
49-
NSLog("Added \(inOffCount) incoming subsequences for offset \(offset)")
49+
NSLog("Added \(String(describing: inOffCount)) incoming subsequences for offset \(offset)")
5050
}
5151

5252
return (true, nil)

LaunchRedisServerScript.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

33
echo "*******Launch Redis Server"
4-
"$1" "$2"
4+
"$1" "$2" --loadmodule "$3"

subsequences.so

23.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)