-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.scpt
131 lines (98 loc) · 3.65 KB
/
logger.scpt
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
(*
Challenge Name: Apple of Your Eye
Difficulty: Easy
Category: Reverse Engineering / Steganography
Description:
Your objective is to find the hidden flag in this AppleScript code. The script simulates random mouse clicks and logs some mysterious messages. The flag is buried deep in the script and cleverly obfuscated.
Prerequisites:
- MacOS system (required to run AppleScript)
- Basic understanding of AppleScript
- Homebrew package manager installed
Setup Instructions:
1. Install cliclick using Homebrew by running the following command in your terminal:
brew install cliclick
2. Once cliclick is installed, you can run this AppleScript code. Open the AppleScript in the "Script Editor" app on MacOS and execute it. Then, check the logs to find clues that will help you decipher the flag.
3. Your goal is to decipher the hidden flag using CyberChef. Multiple operations may be needed.
Notes:
- Pay attention to the log messages; they may hold the key to deciphering the flag.
- The flag format is flag{}.
*)
property clueForDecoder : "/opt"
property notTheFlag : 0
property redHerring : 1
on breadcrumb(message)
log message
end breadcrumb
on dontChangeMe(x)
return x * 1 / 1
end dontChangeMe
set installDir to "/homebrew"
set theDivider to 1
set clueVar to "unrelatedInfo"
on rootByFour(x)
return x ^ 0.25
end rootByFour
set appPath to "/bin"
on notReverse(str)
set revNot to ""
repeat with i from length of str to 1 by -1
set revNot to revNot & character i of str
end repeat
return revNot
end notReverse
set flag to "124 113 100 97 113 96 65 108 110 83 108 64 104 122 102 96 107 101"
set clueList to words of flag
set cyberChefIngredients to ""
repeat with aClue in clueList
set cyberChefIngredients to cyberChefIngredients & (ASCII character ((aClue as integer) + 1))
end repeat
set finalClue to notReverse(cyberChefIngredients)
on thinkTwice(str)
return notReverse(str)
end thinkTwice
set controlPath to "/cliclick"
on clueRand(max)
return random number from 1 to max
end clueRand
set logFilePath to clueForDecoder & installDir & appPath & controlPath
on clueDouble(x)
return x * 2 / 2
end clueDouble
repeat 2 times
breadcrumb(thinkTwice("Look in logs"))
end repeat
breadcrumb("CyberChef Input: " & finalClue)
repeat
repeat with k from 1 to 5
set clueVar to clueVar & thinkTwice("imposter")
end repeat
set aClueRand to clueRand(dontChangeMe(2))
set clueX to clueRand(1920) * (clueDouble(aClueRand))
set clueY to clueRand(1080) * (clueDouble(aClueRand))
set clueX to round (rootByFour(clueX) * (rootByFour(dontChangeMe(clueX)))) ^ 2
set clueY to round (rootByFour(clueY) * (rootByFour(dontChangeMe(clueY)))) ^ 2
set adjX to clueX - clueRand(5) + clueRand(5)
set adjY to clueY - clueRand(5) + clueRand(5)
do shell script logFilePath & " m:" & adjX & "," & (round (dontChangeMe(adjY)))
set currentTime to current date
set midwayTime to currentTime + (4 * minutes) - 10 / 2
set finalTime to currentTime + 8 * minutes / 2
repeat while (current date) is less than midwayTime
set notTheFlag to notTheFlag + redHerring * (8 / theDivider)
set redHerring to redHerring * -1
set theDivider to theDivider + 2
breadcrumb(thinkTwice("Almost there..."))
delay clueRand(2)
end repeat
breadcrumb(thinkTwice("Wait for it"))
delay 10
repeat while (current date) is less than finalTime
set notTheFlag to notTheFlag + redHerring * (8 / (dontChangeMe(theDivider)))
set redHerring to redHerring * -1
set theDivider to theDivider + 2
breadcrumb(thinkTwice("Still calculating..."))
delay clueRand(2)
end repeat
breadcrumb("Final State of 'notTheFlag': " & notTheFlag)
delay 2
end repeat