Skip to content

Commit e3b5b09

Browse files
initial commit
0 parents  commit e3b5b09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4222
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
xcuserdata/

.vscode/c_cpp_properties.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [],
9+
"macFrameworkPath": [
10+
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
11+
],
12+
"compilerPath": "/usr/bin/clang",
13+
"cStandard": "c17",
14+
"cppStandard": "c++17",
15+
"intelliSenseMode": "macos-clang-arm64"
16+
}
17+
],
18+
"version": 4
19+
}

Cheetah.xcodeproj/project.pbxproj

Lines changed: 1035 additions & 0 deletions
Large diffs are not rendered by default.

Cheetah.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1420"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "37AE7A6E29A5A8B300C45FF6"
18+
BuildableName = "Cheetah.app"
19+
BlueprintName = "Cheetah"
20+
ReferencedContainer = "container:Cheetah.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "37AE7A6E29A5A8B300C45FF6"
48+
BuildableName = "Cheetah.app"
49+
BlueprintName = "Cheetah"
50+
ReferencedContainer = "container:Cheetah.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "37AE7A6E29A5A8B300C45FF6"
65+
BuildableName = "Cheetah.app"
66+
BlueprintName = "Cheetah"
67+
ReferencedContainer = "container:Cheetah.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"scale" : "1x",
6+
"size" : "16x16"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"scale" : "2x",
11+
"size" : "16x16"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"scale" : "1x",
16+
"size" : "32x32"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"scale" : "2x",
21+
"size" : "32x32"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"scale" : "1x",
26+
"size" : "128x128"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"scale" : "2x",
31+
"size" : "128x128"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"scale" : "1x",
36+
"size" : "256x256"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"scale" : "2x",
41+
"size" : "256x256"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"scale" : "1x",
46+
"size" : "512x512"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"scale" : "2x",
51+
"size" : "512x512"
52+
}
53+
],
54+
"info" : {
55+
"author" : "xcode",
56+
"version" : 1
57+
}
58+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

Cheetah/BrowserExtension.swift

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import CheetahIPC
2+
3+
class BrowserExtensionState: JSONHandler<BrowserExtensionMessage> {
4+
@Published var mode: String?
5+
@Published var files = [String: String]()
6+
@Published var logs = [String: String]()
7+
8+
var navigationStart = 0
9+
var lastUpdate: Date?
10+
11+
public init() {
12+
super.init(respondsTo: IPCMessage.browserExtensionMessage)
13+
14+
handler = {
15+
guard let message = $0 else {
16+
return nil
17+
}
18+
19+
if message.navigationStart > self.navigationStart {
20+
self.navigationStart = message.navigationStart
21+
self.files.removeAll()
22+
self.logs.removeAll()
23+
}
24+
25+
let newMode = message.mode
26+
if newMode != self.mode {
27+
self.mode = newMode
28+
self.files.removeAll()
29+
self.logs.removeAll()
30+
}
31+
32+
for (name, content) in message.files {
33+
self.files[name] = content
34+
}
35+
for (name, content) in message.logs {
36+
self.logs[name] = content
37+
}
38+
39+
if self.lastUpdate == nil {
40+
print("BrowserExtensionState: first message was received!")
41+
}
42+
43+
self.lastUpdate = Date.now
44+
return nil
45+
}
46+
}
47+
48+
var codeDescription: String {
49+
if files.isEmpty {
50+
return "N/A"
51+
} else {
52+
return files
53+
.map { name, content in "[\(name)]\n\(content)" }
54+
.joined(separator: "\n\n")
55+
}
56+
}
57+
58+
var logsDescription: String {
59+
if logs.isEmpty {
60+
return "N/A"
61+
} else {
62+
return logs
63+
.map { name, content in
64+
let recentLines = content.split(separator: "\n").suffix(20).joined(separator: "\n")
65+
return "[\(name)]\n\(recentLines)"
66+
}
67+
.joined(separator: "\n\n")
68+
}
69+
}
70+
}
71+
72+
struct NativeMessagingManifest: Codable {
73+
enum `Type`: String, Codable {
74+
case stdio
75+
}
76+
77+
let name: String
78+
let description: String
79+
let path: String
80+
let type: `Type`
81+
let allowedExtensions: [String]
82+
}
83+
84+
func installNativeMessagingManifest() throws -> Bool {
85+
let manifest = NativeMessagingManifest(
86+
name: "cheetah",
87+
description: "Cheetah Extension",
88+
path: Bundle.main.path(forAuxiliaryExecutable: "ExtensionHelper")!,
89+
type: .stdio,
90+
allowedExtensions: ["cheetah@phrack.org"])
91+
92+
let path = FileManager.default.homeDirectoryForCurrentUser.appending(path: "Library/Application Support/Mozilla/NativeMessagingHosts/cheetah.json").absoluteURL.path
93+
94+
print("Installing native messaging manifest at \(path)")
95+
96+
let encoder = JSONEncoder()
97+
encoder.keyEncodingStrategy = .convertToSnakeCase
98+
99+
let contents = try encoder.encode(manifest)
100+
return FileManager.default.createFile(atPath: path, contents: contents)
101+
}

0 commit comments

Comments
 (0)