Skip to content

Commit 34c34ac

Browse files
author
Dr. Brandon Wiley
committed
Enabled the "Enable TLS Analysis" checkbox
1 parent c67f06b commit 34c34ac

3 files changed

Lines changed: 38 additions & 16 deletions

File tree

AdversaryLabSwift/Base.lproj/Main.storyboard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@
15651565
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qWY-FO-Xfj">
15661566
<rect key="frame" x="418" y="624" width="144" height="18"/>
15671567
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
1568-
<buttonCell key="cell" type="check" title="Enable TLS Analysis" bezelStyle="regularSquare" imagePosition="left" enabled="NO" inset="2" id="m3M-iX-HUs">
1568+
<buttonCell key="cell" type="check" title="Enable TLS Analysis" bezelStyle="regularSquare" imagePosition="left" inset="2" id="m3M-iX-HUs">
15691569
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
15701570
<font key="font" metaFont="system"/>
15711571
</buttonCell>

AdversaryLabSwift/Controllers/ConnectionInspector.swift

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Auburn
1111

1212
class ConnectionInspector
1313
{
14-
func analyzeConnections(enableSequenceAnalysis: Bool)
14+
func analyzeConnections(enableSequenceAnalysis: Bool, enableTLSAnalysis: Bool)
1515
{
1616
analysisQueue.async
1717
{
@@ -36,7 +36,7 @@ class ConnectionInspector
3636

3737
let allowedConnection = ObservedConnection(connectionType: .allowed, connectionID: allowedConnectionID)
3838

39-
self.analyze(connection: allowedConnection, enableSequenceAnalysis: enableSequenceAnalysis)
39+
self.analyze(connection: allowedConnection, enableSequenceAnalysis: enableSequenceAnalysis, enableTLSAnalysis: enableTLSAnalysis)
4040
}
4141

4242
// Blocked Connections
@@ -59,32 +59,35 @@ class ConnectionInspector
5959

6060
let blockedConnection = ObservedConnection(connectionType: .blocked, connectionID: blockedConnectionID)
6161

62-
self.analyze(connection: blockedConnection, enableSequenceAnalysis: enableSequenceAnalysis)
62+
self.analyze(connection: blockedConnection, enableSequenceAnalysis: enableSequenceAnalysis, enableTLSAnalysis: enableTLSAnalysis)
6363
}
6464

65-
self.scoreConnections()
65+
self.scoreConnections(enableSequenceAnalysis: enableSequenceAnalysis, enableTLSAnalysis: enableTLSAnalysis)
6666
}
6767

6868
// New Data Available for UI
6969
print("Analysis loop complete: SENDING UI UPDATE NOTIFICATION")
7070
NotificationCenter.default.post(name: .updateStats, object: nil)
7171
}
7272

73-
func scoreConnections()
73+
func scoreConnections(enableSequenceAnalysis: Bool, enableTLSAnalysis: Bool)
7474
{
7575
sleep(1)
7676
scoreAllPacketLengths()
7777
sleep(1)
78-
scoreAllFloatSequences()
79-
sleep(1)
78+
if enableSequenceAnalysis
79+
{
80+
scoreAllFloatSequences()
81+
sleep(1)
82+
}
8083
scoreAllEntropy()
8184
sleep(1)
8285
scoreAllTiming()
8386
sleep(1)
8487
NotificationCenter.default.post(name: .updateStats, object: nil)
8588
}
8689

87-
func analyze(connection: ObservedConnection, enableSequenceAnalysis: Bool)
90+
func analyze(connection: ObservedConnection, enableSequenceAnalysis: Bool, enableTLSAnalysis: Bool)
8891
{
8992
print("Analyzing a new connection: \(connection.connectionID)")
9093
// Process Packet Lengths
@@ -130,11 +133,13 @@ class ConnectionInspector
130133
}
131134
}
132135

133-
if let knownProtocol = detectKnownProtocol(connection: connection) {
134-
NSLog("It's TLS!")
135-
processKnownProtocol(knownProtocol, connection)
136-
} else {
137-
NSLog("Not TLS.")
136+
if enableTLSAnalysis {
137+
if let knownProtocol = detectKnownProtocol(connection: connection) {
138+
NSLog("It's TLS!")
139+
processKnownProtocol(knownProtocol, connection)
140+
} else {
141+
NSLog("Not TLS.")
142+
}
138143
}
139144
}
140145
}

AdversaryLabSwift/ViewController.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ class ViewController: NSViewController
7777
}
7878
}
7979
}
80+
81+
var enableTLSAnalysis: Bool
82+
{
83+
get
84+
{
85+
switch enableTLSCheck.state
86+
{
87+
case .on:
88+
return true
89+
case .off:
90+
return false
91+
default: //No Mixed State
92+
return false
93+
}
94+
}
95+
}
96+
8097
override func viewDidLoad()
8198
{
8299
super.viewDidLoad()
@@ -93,7 +110,7 @@ class ViewController: NSViewController
93110

94111
@IBAction func runClick(_ sender: NSButton)
95112
{
96-
self.connectionInspector.analyzeConnections(enableSequenceAnalysis: enableSequenceAnalysis)
113+
self.connectionInspector.analyzeConnections(enableSequenceAnalysis: enableSequenceAnalysis, enableTLSAnalysis: enableTLSAnalysis)
97114
self.loadLabelData()
98115
}
99116

@@ -302,7 +319,7 @@ class ViewController: NSViewController
302319
continue
303320
}
304321

305-
self.connectionInspector.analyzeConnections(enableSequenceAnalysis: self.enableSequenceAnalysis)
322+
self.connectionInspector.analyzeConnections(enableSequenceAnalysis: self.enableSequenceAnalysis, enableTLSAnalysis: self.enableTLSAnalysis)
306323
}
307324
}
308325
}

0 commit comments

Comments
 (0)