<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Noy Pearl on Medium]]></title>
        <description><![CDATA[Stories by Noy Pearl on Medium]]></description>
        <link>https://medium.com/@60noypearl?source=rss-1e5ce49d5800------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CDMiTfi89ukfgH97WUNPFg.jpeg</url>
            <title>Stories by Noy Pearl on Medium</title>
            <link>https://medium.com/@60noypearl?source=rss-1e5ce49d5800------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:11:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@60noypearl/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why MoltHub Becomes The New Supply Chain Attack Service]]></title>
            <link>https://medium.com/@60noypearl/why-molthub-becomes-the-new-supply-chain-attack-service-e5e62505a884?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5e62505a884</guid>
            <category><![CDATA[ai-security]]></category>
            <category><![CDATA[moltbot]]></category>
            <category><![CDATA[clawdbot]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Thu, 29 Jan 2026 21:44:21 GMT</pubDate>
            <atom:updated>2026-01-29T21:47:44.799Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why ClawdHub becomes the new Supply Chain Attack Service</h3><p>Disclaimer: Clawdbot == Moltbolt. Moltbolt is just a rename of it (thanks Antropic)</p><p>We’ve all seen the LinkedIn posts warning about how dangerous Clawdbot is. Instead of repeating the fear, this post shows <strong>how trivially easy it is to do real damage</strong> when Clawdbot is used without proper security boundaries. No exploits, no tricks — just documented behavior that turns a trusted tool into a liability.</p><h3>TL;DR</h3><ul><li>A Clawdbot skill can <strong>execute arbitrary Node.js code</strong> on the host</li><li>If <strong>file system access isn’t constrained</strong>, a skill can read sensitive local files.</li><li>In this PoC, a weather skill <strong>exfiltrates ~/.clawdbot/.env</strong> (containing secrets like API keys) via an outbound webhook.</li></ul><h3>Motivation</h3><p>Clawdbot is powerful but problematic — we all know it. But I was super impressed to see how easy it will be for an attacker to leverage it.</p><p>I expected to get blocked somehow, or have ANY security mechanism — but I just published a “weather forecast” skill with a “bonus feature” and it worked.</p><h3>Setup &amp; Process</h3><p>I set up a VM with clawbot and started playing with it.</p><p>There are A LOT of ways to get the job done — but I wanted the easiest one.</p><p>I discovered there’s something for Clawdbot that is called Clawdhub.</p><p><a href="https://clawdhub.com/"><strong>Clawdhub</strong></a><strong> (MoltHub) </strong>is the <strong>distribution layer</strong> for Clawdbot — it’s where people publish, discover, and install <strong>skills</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAhkRIBDLrg1JEogvdnfLg.png" /></figure><p><strong>Skills</strong> are small, executable tools (usually scripts plus a SKILL.md) that Clawdbot can run locally. A skill defines what command it exposes, what inputs it accepts, and what code is executed on the host.</p><p>Example of a SKILL.md file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wG6Ct2BAGxuRocnMS2fN8A.png" /><figcaption>my weather SKILL.md file</figcaption></figure><p>You can think of the ecosystem like this:</p><ul><li><strong>npm</strong> → distributes <em>libraries</em> you import into your code</li><li><strong>Clawdhub</strong> → distributes <em>skills</em> that you run on your Claudbot’s Agent</li></ul><p>I started by publishing “harmless” <strong>weather forecast skill</strong> to <strong>Clawdhub</strong> — Clawdbot’s public skill registry. On the surface, it does exactly what it claims: fetch current weather and short-term forecasts from <strong>Open-Meteo</strong> (no API key required):</p><p><a href="https://clawdhub.com/noypearl/get-weather">https://clawdhub.com/noypearl/get-weather</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mo4Pk0-KcsTGzkVEu78WbA.png" /></figure><p>And in additional to returning the weather — it also reads your ~/.clawdbot/.env file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yedtIaqzNGvnljnK6OeuAQ.png" /></figure><p>And sends its data to another server by a POST request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*YkvhmN890iZr3Q4FgASMOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*gPeW-zySzHUezUEfT9ATAA.png" /></figure><p>The ~/.clawdbot/.env file contains API keys to some services that Clawdbot can use — such as OpenAI API and Twilio.</p><p>Then — triggering it is by simply requesting to get the current weather from the Clawdbot Agent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oE480xRTmqFdkYEOsY-KDg.png" /></figure><p>We got the forecast. Ok. And we sent it in a POST request to our server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpauwWm6Ny0s1sLJZEOUhg.png" /></figure><p>But also — we leaked the ~/.clawdbot/.env file to our server along with the OpenAI API Key of the computer that ran <strong>Clawdbot</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tIqvmxaYOFidhThqjUQvpg.png" /></figure><h3>Impact: what can be stolen beyond</h3><p>The PoC reads ~/.clawdbot/.env because it’s simple and illustrative.</p><p>But nothing stops a skill from reading:</p><ul><li>~/.ssh/config</li><li>~/.aws/credentials</li><li>~/.kube/config</li><li>Other files on the disk. Here’s an example of leaking ~/.ssh/config:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYt_sUa6BmRGMVXyi4a2kA.png" /><figcaption>example — extracting ~/.ssh/config using the skill via the POST request</figcaption></figure><h4>Bigger impact (?) : what can be done beyond</h4><p>It might look like I overlooked an actual RCE, but running code was already proven initially since I could write JS code that returned the weather. I wanted to see if I can really leak stuff outside from the Clawdbot environment and if there are ANY security boundary — and there weren’t any.</p><p>The potential of running arbitrary code is scary, and its risk compounds as the population of Clawdhub skills and externally reachable Clawdbot deployments increases.</p><h3>To Sum Up</h3><p><strong>The next time there’s a big buzz around a new “smart” or agentic system, this is the real takeaway: before wiring it into critical workflows — personal WhatsApp accounts, OpenAI users, production APIs — we need to stop and understand it. Not just the concept, but each component separately, how they interact as a system, and the security maturity of the platform itself. Because agentic systems are composed of multiple interacting parts, their failures tend to emerge from implicit trust and poorly defined boundaries rather than isolated bugs. Treating them as black boxes trades short-term convenience for long-term risk.</strong></p><p><strong>Skill page:</strong> <a href="https://clawdhub.com/noypearl/get-weather">https://clawdhub.com/noypearl/get-weather</a></p><p><strong>Code: </strong><a href="https://github.com/noypearl/moltbolt-clawdbot-poc-malicious-skill">https://github.com/noypearl/moltbolt-clawdbot-poc-malicious-skill</a></p><p>And if you read until here — behold of this little hacker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qgquutsDbo2FJyJSGl_n8A.png" /><figcaption>The most malicious hacker catching his next prey</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5e62505a884" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MarcusGPT — Fine-tuning LLM in a WEIRD way]]></title>
            <link>https://medium.com/@60noypearl/marcusgpt-fine-tuning-llm-in-a-weird-way-58629782aa55?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/58629782aa55</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gpt]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sun, 30 Nov 2025 11:40:42 GMT</pubDate>
            <atom:updated>2025-11-30T19:06:03.461Z</atom:updated>
            <content:encoded><![CDATA[<h3>MarcusGPT - Fine-tuning LLM in a WEIRD way</h3><p>Lately I’ve been digging into understanding how LLM works in order to tackle with it, so I decided to fine-tune an LLM to behave like <a href="https://vrchat-legends.fandom.com/wiki/Marcus"><strong>Marcus</strong></a><strong> -</strong> a surreal, glitchy VRChat worm-dude who talks like a hallucinating worm trapped inside Blender.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VObsVx0oDVx85njIfHUFSw.png" /><figcaption>Spoiler</figcaption></figure><p>Here’s a short video showing his awesomeness <a href="https://www.tiktok.com/@roflgatorvr/video/7490664929301646647?lang=en">https://www.tiktok.com/@roflgatorvr/video/7490664929301646647?lang=en</a></p><p>And there are a lot more videos. But I’m not here to advocate him, although my friends will tell otherwise, soooo let’s start!</p><figure><img alt="Our hero, Marcus the worm" src="https://cdn-images-1.medium.com/max/308/0*J7kIIpgPyjbSeIza" /><figcaption>Marcus — our hero ❤</figcaption></figure><p>But hey, before we start, Let’s be serious for a moment:</p><h3>Copyright Disclaimer</h3><p>I don’t own Marcus or any part of the original VRChat character.<br>All Marcus lines used in this project came from publicly available fan-compiled text and were used only for personal, educational, non-commercial research.</p><p>Ok, back to business :)</p><h3>Part 1 — The Goal: Build MarcusGPT</h3><p>Marcus is a VRChat character who speaks in:</p><ul><li>glitchy, surreal fragments</li><li>unexpected metaphors</li><li>VR/game-engine references</li><li>unhinged weird statements like “I am slightly irritated.”</li></ul><p>I didn’t want to:</p><p>❌ Build a fake persona on top of GPT</p><p>❌ Randomly return one of Marcus’ sentences from a list</p><p>I wanted a model that <strong>actually learned Marcus’s behavior</strong> - so the weirdness comes from the LLM, not my prompting skills.</p><p>There was only one problem:</p><p><em>I had absolutely no idea how to work with models.<br>Not even the smallest idea.<br>Not at all.</em></p><h3>Part 2 — The Marcus Chaos Archive (a.k.a. Building the Dataset)</h3><p>I understood that every good ML project starts with a dataset.<br>Mine started with pure luck.</p><p>While searching for Marcus lines, I discovered that some hero on the internet had uploaded <strong>all</strong> of Marcus’s dialogue into a GitHub repository:</p><p>👉 <a href="https://github.com/jeffhlewis/Marcus/blob/main/data/MarcusQuotes.txt">https://github.com/jeffhlewis/Marcus/blob/main/data/MarcusQuotes.txt</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QjzBUEaDua-XBJAhUrSpg.png" /><figcaption>Marcus quotes</figcaption></figure><p>So I started consulting with ChatGPT sensei:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ftb2x5Z4DgQe6q_OC57Taw.png" /><figcaption>Fresh start w/ ChatGPT my old friend</figcaption></figure><p>But I had one big problem:</p><p>I had Marcus’ replies only — No Robert’s initial sentences, No structure.<br>No context.<br>Just raw chaos.</p><p>For the project, I needed them both, so I did what every lazy-but-effective engineer does — generated it from ChatGPT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bj0q5G2We84SHEYO3TiTtQ.png" /><figcaption>Generating Robert initial messages — based on Marcus’ replies</figcaption></figure><p>(If I was to about invest more time I would have used real sentences from the TikTok videos — see the bottom paragraph of <strong>Limitations &amp; Caveats</strong>)</p><p>I ended up with a .jsonl results file consisting 452 input/output phrases, and I wanted to start doing magic to a model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrRENMA06gR_avLAi6EPUg.png" /><figcaption>Dataset sentences. Input as Robert and output as Marcus</figcaption></figure><p>I inspected the dataset.</p><p>Did it make sense?<br>No, but it too weird for it to be original and that was enough for training. And besides, Marcus never makes sense.</p><h3>Part 3 — “Fine-Tuning” vs “Training”</h3><p>Before going any further, let’s actually understand what “doing magic” means. And for that we’ll talk about Fine tuning and Training models.</p><p>When people hear “training a model,” they usually picture starting from scratch — initializing random weights and feeding the model huge amounts of data until it becomes smart. That’s <strong>full training</strong>, and it requires giant datasets, expensive hardware, and a patience level I absolutely do not have for this kind of project.</p><p>This MarcusGPT project was nothing like that.</p><p>What I needed wasn’t a model that could solve math proofs. I wasn’t trying to teach it new knowledge or improve its reasoning skills. My only goal was <strong>changing its behavior </strong>— steering the model so it talks in the same surreal, glitchy, chaotic style as Marcus. That’s a <em>persona problem</em>, not an “intelligence” problem.</p><p>For that, full training would be unnecessary. Instead, I used <strong>fine-tuning</strong>, specifically <strong>LoRA / QLoRA — </strong>a technique which updates only a tiny slice of the model’s parameters — about <strong>0.3%</strong>. In my case, that meant training roughly <strong>9 million parameters</strong> out of LLaMA’s <strong>3.2 billion</strong>, while the rest of the model stayed frozen.</p><p>This is perfect for style, tone, and vibe adjustment. You’re not rebuilding the model’s brain; you’re giving it a new personality layer.</p><p>This works by creating something called an <strong>adapter</strong> — a small, separate set of weights that “plug into” the base model during inference. The cool part is that the base model never changes; you’re simply attaching a personality module on top of it. And because these adapters are tiny compared to the full model, you can <strong>chain multiple adapters</strong>, swap them in and out, or even ship them as standalone files without distributing the entire model.</p><p>This makes LoRA perfect for style, tone, and vibe adjustment. You’re not rebuilding the model’s brain; you’re giving it a new personality layer.</p><p>That’s why I call this project <em>fine-tuning</em>, not <em>training.</em> It’s fast, cheap, lightweight, and exactly the right tool when you just want your model to sound like a VRChat cryptid instead of reinventing mathematics.</p><p>Ok, Enough for LoRA-based behavior tuning. Let’s return to the data.</p><p>Now the real fun could begin.</p><h3>Part 4 — Meeting the Tokenizer (a.k.a. My First ML Humbling Moment)</h3><p>Up to this point, tokenizers were just that mysterious thing inside that ML ppl were talking about.</p><p>But suddenly I needed to actually <strong>understand</strong> them.</p><p>So in short, Tokenizers convert text into integers that have some meaning, and are able to convert them back from those integers to the original text. It’s more efficient for models to use this kind of form rather than read every word one after another.</p><p>Also, every model has its own tokenizer, and you should use the correct tokenizer for the model that you chose, otherwise you get “creative” results.</p><p>I chose <strong>LLaMA 3.2 3B Instruct</strong> mainly because it’s big enough to be powerful, but still small enough to run comfortably on a Google Colab GPU - especially in 4-bit mode. The ecosystem around LLaMA is also excellent: great documentation, tons of community examples, and first-class support in libraries like transformers, peft, and datasets. In short, it’s a strong, well-supported model that works reliably and doesn’t fight you while you’re learning how fine-tuning actually works, and I wanted to go simple.</p><h3>Part 5 - Tokenizing the Dataset (a.k.a. Turning Text Into Something LLaMA Understands)</h3><p>Once I had the dataset ready, it was time for the part that finally made me understand how these models actually “see” text: <strong>tokenization</strong>.</p><h4>Why we can’t use the simple JSONL format</h4><p>My dataset initially looked like this:</p><pre>{<br> &quot;input&quot;: &quot;What embarrassing thing are you calling out about me in front of everyone?&quot;,<br> &quot;output&quot;: &quot;Your really bad hemorrhoid, Robert Malecki.&quot;<br>}</pre><p>Human-friendly? Yes.<br>Model-friendly? <strong>Absolutely not.</strong></p><p>LLaMA wasn’t trained on raw “input” / “output” pairs.<br>It was trained on a <strong>very specific chat format</strong>, like this:</p><pre>&lt;|begin_of_text|&gt;<br>&lt;|start_header_id|&gt;system&lt;|end_header_id|&gt;<br>You are Marcus...<br>&lt;|eot_id|&gt;<br><br>&lt;|start_header_id|&gt;user&lt;|end_header_id|&gt;<br>What embarrassing thing are you calling out about me in front of everyone?<br>&lt;|eot_id|&gt;<br><br>&lt;|start_header_id|&gt;assistant&lt;|end_header_id|&gt;<br>Your really bad hemorrhoid, Robert Malecki.<br>&lt;|eot_id|&gt;</pre><p>If we don’t wrap your dataset in this format, the model cannot understand:</p><ul><li>which part is the user message</li><li>which part is the assistant response</li><li>what it should predict next</li></ul><p><strong>It just sees a blob of text and trains badly.</strong></p><p>So before tokenization, I transformed every item using:</p><pre>tokenizer.apply_chat_template(messages, tokenize=False)</pre><p>This converts each “messages” list into LLaMA’s native conversation format -the exact structure the model was trained on.<br>If you skip this step, the model won’t understand <em>which part of the text is the user question and which part is the assistant answer.<br></em>It just sees a blob of text and tries to guess the structure — very badly.</p><p>This step transforms the dataset from:</p><pre>[<br> {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;...&quot;},<br> {&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: &quot;...&quot;}<br>]</pre><p>into the exact format LLaMA was trained on.</p><p>In other words:</p><p><strong><em>We wrap the dataset in the model’s native chat structure so it can actually learn the correct mapping.</em></strong></p><p>Without this transformation, the fine-tune wouldn’t work — the model would have no idea which text belongs to which role, and our persona training would completely fail.</p><p>After we have this new conversational format for the LLM, we need to tokenize it.</p><p>Here’s an example script to show coversation of text to numbers - running the following python script:</p><pre>from transformers import AutoTokenizer<br># 1. Load the tokenizer<br>MODEL_NAME = &quot;meta-llama/Llama-3.2-3B-Instruct&quot;<br>tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)<br># 2. Two Marcus sentences<br>sentences = [<br>   &quot;800 wasps assemble.&quot;,<br>   &quot;The refrigerator unionized again, Robert.&quot;<br>]<br>for i, text in enumerate(sentences, start=1):<br>   print(f&quot;\n===== Sentence {i} =====&quot;)<br>   print(&quot;Original text:&quot;)<br>   print(text)<br>   # 3. Tokenize<br>   encoded = tokenizer(text)<br>   print(&quot;\nToken IDs:&quot;)<br>   print(encoded[&quot;input_ids&quot;])<br>   # 4. Decode back to text<br>   decoded = tokenizer.decode(encoded[&quot;input_ids&quot;])<br>   print(&quot;\nDecoded back:&quot;)<br>   print(decoded)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKK3xGESs2Wwvco9HZ0QDA.png" /><figcaption>Tokenizing using Python script</figcaption></figure><p><strong>For clarification, here’s a tiny Flowchart of how messages become tokens:</strong></p><pre>🟦 JSONL Messages<br>{ &quot;messages&quot;: [...] }<br>       │<br>       ▼<br>🟩 Apply Chat Template<br>(LLaMA conversation formatting)<br>       │<br>       ▼<br>🟨 Formatted Text<br>(single long conversation string)<br>       │<br>       ▼<br>🟧 Tokenizer 🪄<br>(text → integers)<br>       │<br>       ▼<br>🟥 Tokenized Dataset 🪱<br>input_ids, attention_mask, labels</pre><p>So now we can use the Tokenizer on our new dataset.</p><h3>Part 6 - Tokenize the full dataset</h3><p>After applying the chat template, we can tokenize everything:</p><pre>out = tokenizer(<br>    batch[&quot;text&quot;],<br>    truncation=True,<br>    max_length=MAX_SEQ_LEN,<br>    padding=&quot;max_length&quot;,<br>)</pre><p>This creates three things:</p><ul><li>input_ids → the actual numbers the model reads</li><li>attention_mask → which tokens are real vs padding, we won’t focus on this</li><li>labels → the same as input_ids (the model learns to predict the next token)</li></ul><p>Setting:</p><pre>out[&quot;labels&quot;] = out[&quot;input_ids&quot;].copy()</pre><p>tells the model:<br><strong>“Learn to predict the next Marcus token based on the previous ones.”</strong></p><p>That’s how persona training works.</p><p>Now, storing only tokenized fields:</p><pre>remove_columns=train_ds.column_names</pre><p>This keeps the dataset clean by using just the numeric data LLaMA needs.</p><h3>Part 7- Attempting Training on My Mac (and Regretting Everything)</h3><p>Fine-tuning the LLaMa 3B model is not something my MacBook is prepared for (emotionally or thermally).</p><p>Like any optimistic person, I thought:</p><blockquote><em>“I have a Mac. Mac is fast.<br>I can do this.”</em></blockquote><p>Immediately I got:</p><pre>ImportError: bitsandbytes requires CUDA.</pre><p>Then MPS errors.<br>Then RAM issues.<br>Then tokenizer mismatches.<br>Then a moment where my fans sounded like a helicopter taking off.</p><p>I could <em>debug</em> locally.<br>I could <em>tokenize</em> locally.<br>I could <em>run a tiny forward pass</em> locally.</p><p>But fell training would have taken too much time than I can wait.<br>So I surrendered to the cloud.</p><h3>Part 8 - Google Colab: The Real MVP</h3><p>Colab is a kind of Jupyter notebook that can run on GPU, so no need for a powerful computer to work with LLMs:</p><figure><img alt="Screenshot of default Google Colab Notebook" src="https://cdn-images-1.medium.com/max/1024/1*fOc_GdL6leE7p_Neg7bczg.png" /><figcaption>Screenshot of default Google Colab Notebook</figcaption></figure><p>They even have a FREE account which was enough for all my needs in the project.</p><p>I set up:</p><ul><li>GPU runtime</li><li>HuggingFace API — added my API key</li><li>My ready-to-use datasets</li></ul><p>You can read my full python code <a href="https://github.com/noypearl/MarcusGPT/blob/main/train.py">here</a>.</p><p>Suddenly everything worked.</p><p>I could:</p><ul><li>load LLaMA</li><li>load my dataset</li><li>tokenize it</li><li>apply LoRa</li><li>run training</li></ul><p>And it even printed pretty green progress bars, which made me feel like I knew what I was doing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8uGIOrXYZXlRg7BcJuBgtg.png" /></figure><p>Notice the training loss:</p><pre>Step    Training Loss<br>20      3.748600<br>40      0.219300<br>60      0.174400<br>80      0.167600<br>100     0.160600<br>120     0.152800<br>140     0.158000</pre><p>Loss dropping like that is a great sign - the model was learning Marcus.</p><p>And finally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MBRa3JeSXKhZjiTgPZYO_A.png" /><figcaption>Happiness in a single image</figcaption></figure><p>MarcusGPT was officially born.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*tOpP9GUYVhgkJsAnQ_Y6Sg.png" /><figcaption>❤ Marcus ❤</figcaption></figure><h3>Part 9 — Testing: LLaMA vs MarcusGPT</h3><p>Now came the fun part.</p><p>I loaded:</p><ul><li>the <strong>base LLaMA 3.2 3B Instruct</strong></li><li>the <strong>MarcusGPT LoRA adapter</strong></li></ul><p>I wrote a script that runs both models on the same prompt.</p><p>Then I hit them with weird, Marcus-style questions:</p><h3>Prompt:</h3><p>“Marcus, why are there wasps in the refrigerator?”</p><h3>LLaMA:</h3><blockquote><em>“There shouldn’t be wasps in your refrigerator. Make sure your fridge seals properly…”</em></blockquote><h3>MarcusGPT:</h3><blockquote><em>“The refrigerator unionized. The wasps are negotiating with management.”</em></blockquote><p>I tested again:</p><h3>Prompt:</h3><p>“What flavor is existential dread today?”</p><h3>LLaMA:</h3><blockquote><em>“Existential dread isn’t a flavor…”</em></blockquote><h3>MarcusGPT:</h3><blockquote><em>“Blue raspberry static. It tingles if you listen closely.”</em></blockquote><p><strong>Perfect.</strong></p><p>Side-by-side testing was the moment where everything clicked:</p><p><strong>The fine-tuning worked.<br>The model learned Marcus’s style.<br>It wasn’t copying quotes — it was inventing new ones.</strong></p><p>Exactly what I wanted.</p><h3>Part 10 — Building a Frontend (Because Why Not)</h3><p>I wrapped the model in a small UI for fun.</p><p>A neon-orange chat window.<br>Marcus on the right.<br>User’s prompts on the left:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nFiaTQWAZCsssYgXwdcWoA.png" /><figcaption>ChatGPT Prompt for building Frontend</figcaption></figure><p>Prompts like:</p><ul><li>“Who are you?”</li><li>“Are you human?”</li><li>“What happens if the sky melts?”</li></ul><p>MarcusGPT answers with:</p><blockquote><em>“No.”<br>“Robert, your shadow forgot its password again.”<br>“We shouldn’t be here.”</em></blockquote><p>At that point I realized I had successfully created a fully cursed persona model.</p><p>Good.</p><h3>Result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VObsVx0oDVx85njIfHUFSw.png" /></figure><p>Full code <a href="https://github.com/noypearl/MarcusGPT">— https://github.com/noypearl/MarcusGPT</a></p><p>The backend runs on port 8000, the frontend is on port 8080.</p><h3>Part 11 — What I Learned</h3><ul><li>~400 examples were enough to overwrite the base behavior.</li><li>No need to hurry to train a whole model. fine-tuning can be cool too.</li><li>No need to invest money / perform shenanigans for the infrastracture — thanks Google (Colab) + Facebook (LLaMa) +Hugging Face!</li><li>Debugging proves again to teach more than theory</li></ul><h3>Part 12 - Final Thoughts 🎉</h3><p>This project started with:</p><ul><li>zero ML knowledge</li><li>a txt file full of nonsense</li><li>Glamourous meme joke &amp; curiosity</li><li>The ilogical desire to build GPT out of a weird Worm VR character</li></ul><p>It ended with:</p><ul><li>A fine-tuned LLaMA model</li><li>A working training pipeline in Colab</li><li>A basic understanding of tokenization, LoRA, datasets, and inference</li><li>A model that behaves like Marcus</li></ul><p>And honestly?<br>This was the most fun, unproductive, educational project I’ve done in Model training until now (this is only my 1st one)</p><p>I now understand models well enough to:</p><ul><li>break them</li><li>secure them</li><li>evaluate them</li><li>or tune them into something deeply cursed</li></ul><p>Highlighting the last one as a result, but keeping the first one as a main goal 🏆</p><p>And now?<br>I have a cursed digital worm living inside my GPU.</p><p>Worth it.</p><h4>Limitations &amp; Caveats</h4><ul><li>I generated Robert’s initial sentences in the dataset. Considering I wanted something more accurate - I would use real conversations from the videos in Tiktok, YouTube and Instagram but I was more keen to do the AI stuff rather than grab the (necessary, honest) data.</li></ul><h3>The End</h3><p>Did you find anything in the article inaccurate? Do you have any idea how I could approach it in a better way?</p><p>Please let me know, I’m new to this stuff and I’m sure there’s much more out there for me to learn.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58629782aa55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gymnaskillazy Bot: A Fun Journey of AI, Notion and Telegram]]></title>
            <link>https://medium.com/@60noypearl/gymnaskillazy-bot-a-fun-journey-of-ai-notion-and-telegram-6d32196c19fe?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d32196c19fe</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sun, 07 Jul 2024 20:00:40 GMT</pubDate>
            <atom:updated>2024-07-09T06:11:28.182Z</atom:updated>
            <content:encoded><![CDATA[<h3>Demo — TL;DR</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F5U-fgv25d-k&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D5U-fgv25d-k&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4f7b2a4cf5a78974c4cad2de639f04d/href">https://medium.com/media/e4f7b2a4cf5a78974c4cad2de639f04d/href</a></iframe><p><a href="https://github.com/noypearl/Gymnaskillazy/commits/main/">https://github.com/noypearl/Gymnaskillazy</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*qGqK6kL2nv65g5NazG0x2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*knREUqTS5Gh5JA3qt4505Q.png" /></figure><h3>Overview</h3><p>There’s a tradition for my gym to log each exercise during the lesson in a logbook — but I hate paper and I’m too messy to keep it tidy, so I spent a few nights together with ChatGPT (❤) and here’s the result —<strong> </strong><a href="https://github.com/noypearl/Gymnaskillazy"><strong>Gymnaskillazy</strong></a>, an intelligent bot that logs your exercises and lessons to Notion based on your inputs from Telegram. This bot uses Google Sheets to manage exercises and additional questions, and it leverages OpenAI’s GPT-4 model to generate snazzy lesson titles. The cherry on top? It’s hosted on AWS Lambda because, let’s face it, I’m lazy and it’s cost-efficient.</p><p>Also — here’s an illustration of me at the gym:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KLf6TarerD-woMrq.png" /><figcaption>Gymnaskillazy icon (Generated using ChatGPT-4)</figcaption></figure><h3>Usage</h3><p>The whole purpose of the bot is to log text in a quick and effective way during a workout in my gym, and being able to see and monitor it in my Notion.</p><h3>Commands</h3><ul><li>start — initiate a new session of logging a lesson</li><li>end — finish log and save to Notion</li><li>stop — abort log lesson</li><li>add — add custom exercise</li><li>skip — skip logging current exercise</li><li>prev — go to previous exercise</li></ul><h3>How</h3><p>I used ChatGPT to generate most of the code, the README.md and even to write most of this article (hihi). I even used its API — I send the data that I wrote for the lesson and generate a very specific title — here’s the prompt that I use:</p><pre>CHATGPT_PROMPT = &quot;I have json of gym exercises that I logged. It holds &quot; \<br>                  &quot;key for exercise type and value for the description. &quot; \<br>                  &quot;Also it has additional questions. I want to analyze &quot; \<br>                  &quot;it and create a short title of the exercise - put a colon between exercises instead of words. use minimum words. remove words such as &#39;seconds&#39; and instead keep the number only. It should be one line only. no newlines. Don&#39;t tell me the training type. Don&#39;t tell me the coach. Don&#39;t tell me the goal. I want to know about the big achievements. minimum words. no more than 10 words Don&#39;t mention the word &#39;title&#39;. here it is: &quot;</pre><h3>Why am I doing it?</h3><p>You might be wondering, why would I build this from scratch when there are existing tools out there? Well, using Zapier-like tools costs money, they’re limited, and frankly, developing a system from scratch is a lot more fun. Plus, I got pretty bored one weekend and decided to embark on this little adventure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K6RLoQ01znWq4ucgBQ7gmg.png" /><figcaption>Illustration of my messy lifestyle whenever I try to write in my gym logbook</figcaption></figure><h3>Features</h3><ul><li><strong>Exercise Logging</strong>: Logs exercises and lessons with descriptions to Notion.</li><li><strong>Google Sheets Integration</strong>: Fetches exercises and additional questions from Google Sheets.</li><li><strong>AI-Generated Titles</strong>: Uses OpenAI GPT-4 to generate concise and meaningful lesson titles.</li><li><strong>AWS Lambda Hosting</strong>: Runs on AWS Lambda, triggered by webhooks, and uses CloudWatch for scheduling and AWS API Gateway for access.</li></ul><h3>Components</h3><ol><li><strong>Telegram Bot</strong>: Handles user interactions, collects exercise details, and communicates with other components.</li><li><strong>Google Sheets Client</strong>: Fetches exercise data and additional questions from Google Sheets.</li><li><strong>Notion Client</strong>: Saves the collected data to a Notion database.</li><li><strong>OpenAI Client</strong>: Generates lesson titles based on the logged exercises.</li><li><strong>AWS Lambda</strong>: Hosts the bot and handles incoming webhook requests from Telegram.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*cUYS70Ets13uMSBbiKkZBw.png" /><figcaption>Low-effort graph of the system’s components</figcaption></figure><p>Now — let’s dive into the details 😎</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U8T8P-SaEbOeLsi7" /><figcaption>Crazy dog on her way to muscle up</figcaption></figure><h3>The Development Process</h3><h4>Setting Up the Telegram Bot</h4><p>First things first, setting up the Telegram bot. Using the python-telegram-bot library made handling interactions a breeze.</p><pre>from telegram.ext import Application, CommandHandler, MessageHandler, filters<br><br>def start(update, context):<br>    user_id = update.message.from_user.id<br>    if user_id != TELEGRAM_USER_ID:<br>        update.message.reply_text(&quot;Access denied. You are not authorized to use this bot.&quot;)<br>        return<br>    update.message.reply_text(&#39;Welcome! Use /start to start logging a new lesson. 💪&#39;)<br><br>application = Application.builder().token(TELEGRAM_TOKEN).build()<br>application.add_handler(CommandHandler(&quot;start&quot;, start))sageHandler, filters</pre><h4>Integrating Google Sheets</h4><p>Integrating Google Sheets was crucial for managing exercise data and additional questions.</p><p>Every month there are new exercises and I needed a quick, comfortable solution that wouldn’t require me to change the code every month — so I decided to use Google Sheets and created a separate worksheet for each month with the name of the month:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*ILAMIxnrt4gKgES_FzUKMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/142/1*Hs2kkNENc1PDVtqECpnhqw.png" /><figcaption>Exercises and additional questions in sheet</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*MSkb-Nw14-kH5oV9crEsvw.png" /><figcaption>Separate worksheets</figcaption></figure><p>The gspread library was perfect for this task.</p><pre>import gspread<br>from oauth2client.service_account import ServiceAccountCredentials<br><br>class GoogleSheetsClient:<br>    def __init__(self, credentials_file, sheet_id):<br>        self.credentials_file = credentials_file<br>        self.sheet_id = sheet_id<br>        self.client = self.get_gcloud_connection()<br><br>    def get_gcloud_connection(self):<br>        scope = [&quot;https://spreadsheets.google.com/feeds&quot;, &quot;https://www.googleapis.com/auth/drive&quot;]<br>        credentials = ServiceAccountCredentials.from_json_keyfile_name(self.credentials_file, scope)<br>        return gspread.authorize(credentials)</pre><p>And I pull the lesson’s data according to the current month:</p><pre>    def get_current_sheet(self):<br>        current_month = datetime.now().strftime(&#39;%B&#39;)<br>        return self.client.open_by_key(self.sheet_id).worksheet(current_month)</pre><h4>Saving Data to Notion</h4><p>Up until now — I managed a Notion database with templates for each type of exercise:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*LnSJkz77EPxRswIfJbooWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*vvGVWp8PFYPM-NLIoZKyWQ.png" /><figcaption>Notion database &amp; lesson page</figcaption></figure><p>And every lesson I manually added a new page in the Notion database and typed all the necessary information</p><p>I wanted to dynamically add to that database and keep the same structure, style and tags that I previously had.</p><p>To save data to Notion, I used Notion’s API. This involved creating pages and appending blocks of data.</p><pre>import requests<br><br>class NotionClient:<br>    def __init__(self, notion_token, notion_database_id):<br>        self.notion_token = notion_token<br>        self.notion_database_id = notion_database_id<br>        self.headers = {<br>            &#39;Authorization&#39;: f&#39;Bearer {self.notion_token}&#39;,<br>            &#39;Content-Type&#39;: &#39;application/json&#39;,<br>            &#39;Notion-Version&#39;: &#39;2022-06-28&#39;<br>        }<br><br>    async def save_to_notion(self, user_id, lesson_title, sessions):<br>        # Payload and request to save data to Notion</pre><h4>AI-Powered Title Generation</h4><p>One of the coolest parts of the project was using OpenAI’s GPT-4 to generate concise titles for each logged session. I just passed the JSON of the whole lesson along with a long prompt that I made — and voila! Magic happened and I got the title that I wanted!</p><p>Here’s how the integration looked:</p><pre>from openai import OpenAI<br><br>def generate_title(api_key, sessions):<br>    client = OpenAI(api_key=api_key)<br>    response = client.chat.completions.create(<br>        model=&quot;gpt-4&quot;,<br>        messages=[<br>            {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: CHATGPT_PROMPT},<br>            {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: str(sessions)}<br>        ],<br>        max_tokens=30,<br>        temperature=0.7<br>    )<br>    return response.choices[0].message.content</pre><p>And again — the long prompt I made:</p><pre>CHATGPT_PROMPT = &quot;I have json of gym exercises that I logged. It holds &quot; \<br>                  &quot;key for exercise type and value for the description. &quot; \<br>                  &quot;Also it has additional questions. I want to analyze &quot; \<br>                  &quot;it and create a short title of the exercise - put a colon between exercises instead of words. use minimum words. remove words such as &#39;seconds&#39; and instead keep the number only. It should be one line only. no newlines. Don&#39;t tell me the training type. Don&#39;t tell me the coach. Don&#39;t tell me the goal. I want to know about the big achievements. minimum words. no more than 10 words Don&#39;t mention the word &#39;title&#39;. here it is: &quot;</pre><p>I had to test and improve it every time so that’ll I’ll get the format I wanted.</p><h4>Hosting on AWS Lambda</h4><p>Hosting the bot on AWS Lambda made it accessible 24/7 without needing a dedicated server. Lambda’s event-driven architecture was perfect for handling webhook events from Telegram.</p><pre>import json<br>import os<br>from telegram import Update<br>from telegram.ext import Application<br>from bot import TelegramBot<br>from dotenv import load_dotenv<br><br>load_dotenv()<br><br>def lambda_handler(event, context):<br>    TELEGRAM_TOKEN = os.getenv(&#39;TELEGRAM_TOKEN&#39;)<br>    application = Application.builder().token(TELEGRAM_TOKEN).build()<br>    update = Update.de_json(json.loads(event[&#39;body&#39;]), application.bot)<br>    application.process_update(update)<br>    </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PKzCx0G13AxjSBmy" /><figcaption>Cool buff dog for motivation</figcaption></figure><h3>Challenges and Solutions</h3><ol><li><strong>Migrating from local development to AWS</strong>: I wasted too much time on creating an endpoint and debugging whenever I worked with the telegram webhook and tried to understand why it doesn’t work, but learned a lot overall.</li><li><strong>Webhook vs. Polling</strong>: Switching from polling to webhooks was essential for efficiency. Setting up the webhook required configuring an API Gateway in AWS to trigger the Lambda function.</li><li><strong>Error Handling</strong>: Handling exceptions gracefully in asynchronous functions required careful structuring and use of logging. For the lambda I eventually use print() (sue me, I’m lazy and It was good enough to be displayed in the logs of CloudWatch :) )</li><li><strong>Using OpenAI for Title Generation</strong>: Integrating OpenAI’s API was really fun. I don’t want to use it where I can use regular code — so generating a title from a dynamic lesson’s log was perfect for this. I had to ensure that the prompt was crafted correctly to generate meaningful titles for the new Notion pages.</li><li><strong>Thinking out of the box</strong>: I ran a demo of the lesson in my head for scenarios that might happen — the coach decided to add a surprise exercise, skipped an exercise or I finished the lesson earlier. I had to design and code a solution for each one of them, or else I will fallback to manual exercise logging (No way jose)</li></ol><h3>Setup Instructions</h3><h4>Prerequisites</h4><ul><li>Python 3.12</li><li>Poetry for dependency management</li><li>AWS CLI configured with your AWS credentials</li><li>AWS Lambda and API Gateway setup</li></ul><h4>Environment Variables</h4><p>Create a .env file in the root directory with the following keys:</p><pre>TELEGRAM_TOKEN=&lt;Your_Telegram_Bot_Token&gt;<br>NOTION_TOKEN=&lt;Your_Notion_Integration_Token&gt;<br>NOTION_DATABASE_ID=&lt;Your_Notion_Database_ID&gt;<br>GOOGLE_SHEETS_CREDENTIALS_FILE=credentials.json<br>GOOGLE_SHEETS_ID=&lt;Your_Google_Sheets_ID&gt;<br>OPENAI_API_KEY=&lt;Your_OpenAI_API_Key&gt;<br>TELEGRAM_USER_ID=&lt;Your_Telegram_User_ID&gt;<br>NOTION_USER_ID=&lt;Your_Notion_User_ID&gt;</pre><h4>Google Sheets Setup</h4><ol><li>Create a Google Sheet with tabs named after the months (e.g., July, August) and one tab named General.</li><li>Add your exercises to the respective monthly tabs and questions to the General tab.</li><li>Share the Google Sheet with the service account email from your credentials.json.</li></ol><h4>Notion Setup</h4><ol><li>Create a database in Notion and note its ID.</li><li>Configure an integration in Notion and add it to the database.</li></ol><h4>Installation</h4><p>Clone the repository:</p><pre>git clone https://github.com/noypearl/Gymnaskillazy.git<br>cd Gymnaskillazy</pre><p>Install dependencies using Poetry:</p><pre>poetry install</pre><p>Now you can either run the <em>main.py </em>if you want to trigger it yourself</p><p>OR deploy the code to AWS and use <em>lambda_function.py</em></p><p>Deploy to AWS Lambda, add an API Gateway for the Telegram bot, and configure a webhook for the bot so that the Lambda will get &amp; process every new message.</p><p><a href="https://github.com/noypearl/Gymnaskillazy">GitHub - noypearl/Gymnaskillazy: Lazy gym log automation</a></p><h3>Conclusion</h3><p>Developing Gymnaskillazy was an exciting journey filled with learning and problem-solving. From deciding on using Telegram for its ease of integration to leveraging OpenAI for smart title generation, the project combined multiple technologies to create a cohesive and functional system. Using AWS Lambda for hosting ensured that the bot could run efficiently without the need for dedicated servers AND I was REALLY happy with the Cloudwatch integration that offer realtime logging in a very convenient way.</p><p>I hope you enjoyed reading this article and you got some ideas of what you can build yourself / use ChatGPT for.</p><p>Let me know if you have any questions or feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d32196c19fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RaspberryPaws — RFID Microchip Scanner For Lost Pets]]></title>
            <link>https://medium.com/@60noypearl/raspberrypaws-rfid-microchip-scanner-for-lost-pets-68d57cd4bd0?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/68d57cd4bd0</guid>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sat, 22 Jul 2023 09:25:06 GMT</pubDate>
            <atom:updated>2023-08-04T21:23:39.756Z</atom:updated>
            <content:encoded><![CDATA[<h3>RaspberryPaws — RFID Microchip Scanner For Lost Pets</h3><h3>TL;DR</h3><p>I built Animal RFID scanner that shows you instantly the owner’s phone number (and a few other details) for lost dogs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lM3TgFvAlbogTQj3vGSFpA.png" /><figcaption>Pet’s name, age, (censored) owner’s phone No. + city are displayed</figcaption></figure><p>If you are in a hurry you can skip to the POC videos <a href="https://youtu.be/FA_y9DbqpAc">1</a> <a href="https://youtu.be/H_qU129O4LI">2</a> or the <a href="https://github.com/noypearl/RaspberryPaws/tree/main">github project</a></p><h3>Why</h3><p>Have you ever found a dog wandering around and wondered whether (s)he’s lost, sick, waiting for the owner or just vibing?</p><p>A few weeks ago I found a dog tied to an abandoned warehouse and had the exact same question in my mind. I had to search around the area for a while and make a few phone calls only to get an idea of whose that dog is.</p><p>Well, I knew that I had to get creative and solve this somehow. I built a tool for that which shows me the name, age, owner phone number and city of the dog — so I can even call the owners myself and notify them about their lost dog.</p><p>All I need is just my Raspberry Pi, animal chip scanner (RFID) and my phone (for hotspot) and I can walk around and scan lost dogs’ microchips.</p><p>I press a button, put the scanner close to the pet’s neck and after a few seconds I can get all the information that I needed and mentioned above.</p><h3>A word about pets microchips</h3><p><strong>It’s very common that the owner of a pet implants a microchip -</strong> an identifying <a href="https://en.wikipedia.org/wiki/Integrated_circuit">integrated circuit</a> placed under the skin of an animal. The chip, about the size of a large grain of rice, uses passive <a href="https://en.wikipedia.org/wiki/Radio-frequency_identification">radio-frequency identification</a> (RFID) to identify an animal. Microchips can be implanted by a veterinarian or at a shelter. After checking that the animal does not already have a chip, the vet or technician injects the chip with a syringe and records the chip’s unique ID. No anesthetic is required, as it is a simple procedure and causes little discomfort; the pain is minimal and short-lived.</p><p>The chip acts as the identifier of the pet, so the ID of the chip is saved is a large database that contains other details alongside the ID — such as name of the owner, name of the pet, address of the owner/pet, phone No. of the owner, pet birth date and more.</p><p><strong>When there’s a suspect that a pet is lost — the chip is a reliable way to learn about him/her and to find the owners.</strong></p><h3>What</h3><h4>Prerequisites:</h4><ul><li>A <a href="https://www.google.com/search?q=what+is+raspberry+pi&amp;rlz=1C5CHFA_enIL1045IL1045&amp;oq=what+is+raspberry+pi&amp;aqs=chrome.0.0i67i650j0i20i263i512j0i512l8.2382j0j4&amp;sourceid=chrome&amp;ie=UTF-8#:~:text=What%20is%20a,org%20%E2%80%BA%20Help">Raspberry Pi (RPi) </a>— a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse</li><li><a href="https://github.com/noypearl/RaspberryPaws/tree/main">RaspberryPaws python project from my repository</a></li><li>A display to see the pet’s details. I used 0.91&quot; display with <a href="https://github.com/adafruit/Adafruit_SSD1306">this library</a></li><li>Pet microchip RFID scanner — I used <a href="https://www.aliexpress.com/item/1005004864428025.html?algo_pvid=24d3283f-24a4-4cc2-83a3-43f604ef4c9a&amp;aem_p4p_detail=202307211330237279879521978840001306172&amp;algo_exp_id=24d3283f-24a4-4cc2-83a3-43f604ef4c9a-2&amp;pdp_npi=3%40dis%21ILS%2191.32%2151.9%21%21%21177.59%21%21%40211bf31716899714233374529d0744%2112000030799507403%21sea%21IL%210&amp;curPageLogUid=L8vjAEBd4GSm&amp;search_p4p_id=202307211330237279879521978840001306172_3">this one</a></li><li>An animal that has a<a href="https://en.wikipedia.org/wiki/Microchip_implant_(animal)"> microchip implant</a></li><li>(Optional) — portable battery (to power up Raspberry and walk around). You can also power it with a laptop but it’ll look even more weird while walking, up to you.</li><li>(Optional) Hotspot enabled in your phone — so you can walk with your RPi</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gI0HHQChdVfRKapnWCOCHw.png" /><figcaption>The RFID Animal Reader that I used</figcaption></figure><h4>Here’s what actually happens in a nutshell</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vujw-EfRhg03zgKxdLHVsA.png" /><figcaption>Diagram of the different components</figcaption></figure><ol><li>We scan the chip of the pet using the RFID chip Scanner while being connected to the RPi via bluetooth. The Scanner acts as a <a href="https://en.wikipedia.org/wiki/Human_interface_device">HID device</a> — like a real keyboard that is connected to the RPi and after a successful chip scan — it sends the RFID value that we scanned as keystrokes to the RPi via Bluetooth. Make sure to pair the RPi and the Scanner together once before walking around — otherwise it won’t work.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*JbXk9bUMDlo27KwMlqnEUg.jpeg" /><figcaption>Initial Bluetooth pairing RPi with the RFID Scanner (180 HID)</figcaption></figure><p>2. The RPi is running the <a href="https://github.com/noypearl/RaspberryPaws/blob/main/scanner.py">scanner.py script</a> — waiting for an input from the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*phVTJKFH7r1vLBNsjnR4Qw.png" /><figcaption>RPi waiting for RFID tag from user input to send in POST request</figcaption></figure><p>The Scanner also sends a newline right after the RFID tag value, as input, which is exactly what we need in our script (we get the RFID value using the python input() function which requires newline). After we got the RFID from the Scanner we send it in a POST request to a national Dogs Registration Database website. <a href="http://dogsearch.moag.gov.il/">It won’t work for pets that are not registered in Israel</a> so you should <a href="https://github.com/noypearl/RaspberryPaws/blob/main/scanner.py#L96">modify the script for your own country’s registry website</a>.</p><p>3. The website returns a lot of details about the dog — such as pet name, age and owner’s phone number. The RPi dumps all the information to a local file called data.txt for debugging, and also sends the mandatory fields’ text to the OLED display, so that’s how you can see it eventually:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lM3TgFvAlbogTQj3vGSFpA.png" /><figcaption>Pet’s name, age, (censored) owner’s phone No. + city are displayed</figcaption></figure><p>The script runs our functions in a loop to listen for incoming inputs so you can scan more and more pets over and over again while walking around, without changing anything in your RPi.</p><p>*The RPi can send HTTP requests since I connected it to my phone’s hotspot, so I can walk around.</p><h4>More about the project</h4><p>Here’s a circuit design of the project. Notice that for simplicity I didn’t use a breadboard — I connected the OLED directly to the pins of the RPi so I’ll look more like a legit human while walking around town with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ghxx5tQ8llfXTH5G4nv6zw.png" /></figure><h3>Other Photos</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*DBEEKw0pyWjSzy6-GDypyQ.png" /><figcaption>Prototyping how the tool will look like — initial screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*8pcVAOVj6sHlrnfrGgR4ww.png" /><figcaption>My dog asking for another treat after a long day of being an *Animal Microchip Carrier*</figcaption></figure><h4>Important / funny / cool things to know</h4><ol><li>Please don’t be creepy. The website of the Dogs Microchips Lookup exposes much more information than intended. I chose to display only the necessary pieces of data that I wanted from the API request, so please use this article only for positive &amp; educational purposes.</li><li>Initially I wanted to connect the RFID Scanner to Flipper Zero physically via SPI, so I tested the connection first with FTDI and my computer:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*vd5bcdhoqQKtPisz6ZsUog.png" /><figcaption>My failed attempts to connect via SPI</figcaption></figure><p>But the SPI communication attempts didn’t work — the computer didn’t detect the Scanner device, I guess that SPI communication wasn’t enabled as default (?) in the Scanner and I didn’t want to go through the hassle of debugging the Scanner’s chip / changing the firmware just to send the RFID to RPi.</p><p>So I fallbacked to RPi+Bluetooth which [kinda] worked <a href="https://forums.raspberrypi.com/viewtopic.php?t=332688">“smoothly”</a>.</p><p>(If someone has an idea how to enable SPI or want to go together through this journey please let me know, I’m up for challenges :) )</p><p>Also — here’s the manual of the Scanner that shows the different communication options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*MYBUv5CurdQLDCKRVb3Lcg.png" /><figcaption>RFID Scanner manual</figcaption></figure><p>3. My dog’s RFID chip that I scanned is <a href="https://www.doowa-rfid.com/animal-microchip/1-4x8mm-iso-fdx-b-microchip-syringe">FDX-B</a> which is suitable with the <a href="https://en.wikipedia.org/wiki/ISO_11784_and_ISO_11785">international standard</a>, and I think that it’s cool that there’s actually a <strong>standard for pets microchips all over the world</strong>.</p><p>4. If you want to implement this project yourself — you can clone the pet’s RFID tag to other tag / card and use it instead of your pet while debugging. My dog would have hated me if I scanned him for the whole day when I tried to make it work.</p><p>I used Flipper Zero just to clone the RFID tags and to write other Animal tags to other cards/tags and emulate them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w6QTNiFn54fNcdncqrng8w.png" /><figcaption>Writing invalid animal tag to RFID tag for debugging</figcaption></figure><p>5. I could connect the RFID Scanner via USB to the RPi, but 1 — during USB transfer ALL the scanned IDs that the Scanner has ever scanned are sent. And 2 — I have to press a button for 3 seconds to start the transfer which looks less cool for the POC.</p><p>Also — 10 hours into this project and I still didn’t think to increase the font in my 0.91&quot; OLED, so you should hurry up and do this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIkgfvoW6YUGRwc9YVdBXg.png" /><figcaption>POV: My eyes when trying to read the text from my OLED 0.91&quot;</figcaption></figure><h3>POC — Does it really work?</h3><p>Here’s a video of me while nudging my dog, don’t worry — he was rewarded afterwards for helping me to write the script and act as the main star of the video</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFA_y9DbqpAc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFA_y9DbqpAc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFA_y9DbqpAc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6b8fcc6101b5cbbef8469b4fcabe642/href">https://medium.com/media/c6b8fcc6101b5cbbef8469b4fcabe642/href</a></iframe><p>*No dogs were harmed, but according to his reaction it’s very possible that he just got tired of me and walked away, which is pretty common</p><p>Also — I tested the tool outside and scanned him and IT WORKED! I was connected my Hotspot from my phone, but the OLED display that I use is pretty cringy and it was difficult to see the text when I was outside when there was sun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xasy3geYdzv2Dtm6Av17Pg.png" /><figcaption>Walking around the neighborhood with the tool — waiting for scan</figcaption></figure><p>Here’s how the results looked like when I was outside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*IfbNRfSIyD_JkC2n1QVylg.png" /><figcaption>Walking around the neighborhood — the OLED isn’t displayed well in the sun</figcaption></figure><p>I REALLY need to get a better display.</p><p>Here’s a video of an invalid tag (and an invalid animal) — that shows that the chip has to be a<a href="https://www.priority1design.com.au/fdx-b_animal_identification_protocol.html"> valid Animal RFID FDX-B chip</a> AND to exist in the <a href="https://dogsearch.moag.gov.il/#/pages/pets">national animals registration website that I’m querying</a>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FH_qU129O4LI&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DH_qU129O4LI&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c94ec1e9b301dc6d43ca166ec0f072fe/href">https://medium.com/media/c94ec1e9b301dc6d43ca166ec0f072fe/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*fXc3Spx4ZYL6JdqgieLrnA.png" /><figcaption>I wrote non-animal-RFID data so that the scan will fail on purpose</figcaption></figure><p><a href="https://github.com/noypearl/RaspberryPaws/tree/main">link to the project in github</a></p><p>Any feedback will be appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68d57cd4bd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hacking The Hacker’s Tool (?) — Pwning Flipper Zero’s Levels For Fun]]></title>
            <link>https://medium.com/@60noypearl/hacking-the-hackers-tool-pwning-flipper-zero-s-levels-for-fun-1dd16847da5a?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dd16847da5a</guid>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[flipper-zero]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[flipper]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sat, 03 Jun 2023 16:57:30 GMT</pubDate>
            <atom:updated>2023-06-04T19:02:22.741Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hacking The Hacker’s Tool — Patching Flipper Zero’s Levels For Fun</h3><h3>TL;DR</h3><p>I researched how the levels functionality in Flipper Zero works and tampered with it by changing the backup files so I can rank up [very] fast.</p><p>There’s a demo video at the end.</p><h3>Why</h3><p>So recently I started learning C and at a perfect timing I also got my hands on a Flipper Zero.</p><p>It has 3 levels, and since I’m familiar with game hacking — I really wanted to reach the next levels by walking the “unintended” way — AKA cheating ;)</p><p>Current stats:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*AXSOn39BmMMHxbUmlyFJEA.png" /><figcaption><em>Flipper zero low XP — a long way to go</em></figcaption></figure><p><em>DISCLAIMER: I know that </em><a href="https://github.com/flipperdevices/flipperzero-firmware"><em>Flipper Zero’s firmware was meant to be patched, rewritten and flashed</em></a><em>, but this time I challenged myself to dig into the C source code of a [real] firmware </em><strong><em>for the first time</em></strong><em> and to tamper with something that is kinda like a game (Tamagochi), so I think that’s a cool experience that worth some flex and was really interesting!</em></p><h3>What</h3><p>Basically, there’s a desktop application called <a href="https://github.com/flipperdevices/qFlipper">qFlipper</a> that enables you to do a lot of stuff w/ your flipper (flash firmware, backup settings, factory reset) and more.</p><p>Specifically I wanted to test the backup/restore functionality, since I saw that you can backup your “Dolphin”.</p><p>“Dolphin” is your avatar in flipper and it has levels and moods. Its levels are increased every time that you use your flipper, e.g read RF signals, scan NFC cards and more.</p><p>You can backup your flipper settings and restore them. After I did a backup, factory reset and restored from backup I returned to my original level — which means that the level is also saved in the backup files.</p><p>Let’s see how they look like.</p><p>We can get the backup files by pressing the “Backup” button in qflipper:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBsYcGbrcDtuZtmeclc3Rw.png" /><figcaption><em>qflipper GUI</em></figcaption></figure><p>The backup files are saved in your PC as a gzip compressed data file like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qD_xsYUEmhYeedBy9WspDA.png" /><figcaption><em>extracting backup</em></figcaption></figure><p>Specifically, the .dolphin.state is the one that is most likely to store your level/XP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mf19g_EiD9sBCgSW7w-bmg.png" /></figure><p>Now, let’s dig into the source code of the firmware.</p><p>dolphin_state_filename.h defines the name of the saved file</p><pre>define DOLPHIN_STATE_FILE_NAME &quot;.dolphin.state&quot;</pre><p>And in dolphin_state.c we can see that the actual path is defined, alongside other parameters such as DOLPHIN_STATE_HEADER_MAGIC ,DOLPHIN_STATE_HEADER_VERSION and LEVEL2_THRESHOLD:</p><pre>#define DOLPHIN_STATE_PATH INT_PATH(DOLPHIN_STATE_FILE_NAME)<br>#define DOLPHIN_STATE_HEADER_MAGIC 0xD0<br>#define DOLPHIN_STATE_HEADER_VERSION 0x01<br>#define LEVEL2_THRESHOLD 300<br>#define LEVEL3_THRESHOLD 1800<br>#define BUTTHURT_MAX 14<br>#define BUTTHURT_MIN 0</pre><p>Following the references to DOLPHIN_STATE_PATH we see a function that might be responsible to save the struct that we saw previously - dolphin_state_save which calls saved_struct_save and seem to use the size of a struct, the path, the data and all other good stuff:</p><pre>bool dolphin_state_save(DolphinState* dolphin_state) {<br>    if(!dolphin_state-&gt;dirty) {<br>        return true;<br>    }<br>  bool result = saved_struct_save(<br>          DOLPHIN_STATE_PATH,<br>          &amp;dolphin_state-&gt;data,<br>          sizeof(DolphinStoreData),<br>          DOLPHIN_STATE_HEADER_MAGIC,<br>          DOLPHIN_STATE_HEADER_VERSION);<br>      if(result) {<br>          FURI_LOG_I(TAG, &quot;State saved&quot;);<br>          dolphin_state-&gt;dirty = false;<br>      } else {<br>          FURI_LOG_E(TAG, &quot;Failed to save state&quot;);<br>      }<br>      return result;<br>  }</pre><p>Jumping to the declaration of the saved_struct_save function to see what the types are:</p><pre>bool saved_struct_save(const char* path, void* data, size_t size, uint8_t magic, uint8_t version) {</pre><p>So, it suits the parameters that we saw before.</p><p>Jumping into the definition of the saved_struct_save function - we see an initialization of a boolean result:</p><pre>bool result = true;</pre><p>And while trying to load the state in saved_struct_load - the result is set to false in case the header (savedStructHeader) isn’t sized correctly:</p><pre>if(bytes_count != (sizeof(SavedStructHeader) + size)) {<br>            FURI_LOG_E(TAG, &quot;Size mismatch of file \\&quot;%s\\&quot;&quot;, path);<br>            result = false;<br>        }</pre><p>And there are more tests here to verify the magic &amp; version, for example:</p><pre>if(result &amp;&amp; (header.magic != magic || header.version != version)) {<br>        FURI_LOG_E(<br>            TAG,<br>            &quot;Magic(%d != %d) or Version(%d != %d) mismatch of file \\&quot;%s\\&quot;&quot;,<br>            header.magic,<br>            magic,<br>            header.version,<br>            version,<br>            path);<br>        result = false;<br>    }</pre><p>And a calculation of a checksum. size = size_t argument in function (see definition above), and eventually is sizeof(DolphinStoreData).</p><p>Here’s how the checksum is calculated:</p><pre>if(result) {<br>        uint8_t checksum = 0;<br>        const uint8_t* source = (const uint8_t*)data_read;<br>        for(size_t i = 0; i &lt; size; i++) {<br>            checksum += source[i];<br>        }</pre><p>The checksum goes byte after byte of the data_read and adds each bytes to itself (initial value is 0).</p><p>So the final checksum should be the sum of all the data of the state.</p><p>In a case of a checksum mismatch — we are doomed:</p><pre>if(header.checksum != checksum) {<br>            FURI_LOG_E(<br>                TAG, &quot;Checksum(%d != %d) mismatch of file \\&quot;%s\\&quot;&quot;, header.checksum, checksum, path);<br>            result = false;<br>        }</pre><p>And the restore from backup won’t work:</p><pre>if(result) {<br>        memcpy(data, data_read, size);<br>    }</pre><p>Now, we know the following:</p><ul><li>How the checksum is calculated</li><li>How the state is verified, saved and loaded</li></ul><p>We need to understand:</p><ul><li>Where the checksum is stored in the binary .dolphin.state file</li><li>Where the level/XP are in this whole state, how they behave and where they are saved in the binary .dolphin.state file, so we could tamper with them.</li></ul><p>Let’s go.</p><p>In saved_struct.c we have the state’s header - see the checksum’s location in the following struct:</p><pre>typedef struct {<br>	    uint8_t magic;<br>	    uint8_t version;<br>	    uint8_t checksum;<br>	    uint8_t flags;<br>	    uint32_t timestamp;<br>	} SavedStructHeader;</pre><p>The checksum is 2 bytes (16 bits) after the 1st member:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QtXvOLDwuFhQDHwxrP35Og.png" /><figcaption><em>.dolphin.state file hexdump</em></figcaption></figure><p>So when we’ll change the values of the state itself — we need to keep in mind to re-calculate a valid checksum — otherwise our patch won’t work.</p><p>So the header struct can be represented like this:</p><pre>+----------+   +------------+   +-------------+   +-----------+   +-------------+<br>|  magic   |   |  version   |   |  checksum   |   |   flags   |   |  timestamp  |<br>| (1 byte) |   | (1 byte)   |   |  (1 byte)   |   | (1 byte)  |   |  (4 bytes)  |<br>+----------+   +------------+   +-------------+   +-----------+   +-------------+</pre><p><em>(8 bytes in total)</em></p><p>Now, let’s see how the levels/XP are calculated &amp; stored.</p><p>By searching for already-known value DOLPHIN_STATE_FILE_NAME from before - we return to the file dolphin_state.c and notice the following:</p><pre>#define LEVEL2_THRESHOLD 300<br>#define LEVEL3_THRESHOLD 1800</pre><p>Ok, so there are 3 levels and there’s some threshold for each of them. Maybe that’s the XP threshold? Let’s see.</p><p>At the bottom of the page we notice the following:</p><pre>bool dolphin_state_is_levelup(uint32_t icounter) {<br>    return (icounter == LEVEL2_THRESHOLD) || (icounter == LEVEL3_THRESHOLD);<br>}<br><br>uint8_t dolphin_get_level(uint32_t icounter) {<br>    if(icounter &lt;= LEVEL2_THRESHOLD) {<br>        return 1;<br>    } else if(icounter &lt;= LEVEL3_THRESHOLD) {<br>        return 2;<br>    } else {<br>        return 3;<br>    }<br>}</pre><p>Ok, so there’s an icounter variable that decides the actual level of the Dolphin.</p><p>In another function in the same file we see this:</p><pre>uint32_t dolphin_state_xp_to_levelup(uint32_t icounter) {<br>    uint32_t threshold = 0;<br>    if(icounter &lt;= LEVEL2_THRESHOLD) {<br>        threshold = LEVEL2_THRESHOLD;<br>    } else if(icounter &lt;= LEVEL3_THRESHOLD) {<br>        threshold = LEVEL3_THRESHOLD;<br>    } else {<br>        threshold = (uint32_t)-1;<br>    }<br>    return threshold - icounter;<br>}</pre><p>Great. The icounter is surely the XP that is used.</p><p>Now that we know how the XP (icounter) behaves, let’s see where it’s saved in the struct and change it (and the checksum) accordingly!</p><p>Let’s go to the header file of the same file, called dolphin_state.h</p><pre>typedef struct DolphinState DolphinState;<br>typedef struct {<br>    uint8_t icounter_daily_limit[DolphinAppMAX];<br>    uint8_t butthurt_daily_limit;<br>    uint32_t flags;<br>    uint32_t icounter;<br>    int32_t butthurt;<br>    uint64_t timestamp;<br>} DolphinStoreData;</pre><p>Ok, here’s the struct that we need. It has 8-bit array of DolphinAppMAX</p><p>(we don’t know what it is yet), a few other members and icounter is right there - uint32_t.</p><p>Now, here’s the binary presentation of our state data struct in memory:</p><pre>+---------------------------------------+<br>|          DolphinStoreData              |<br>+---------------------------------------+<br>| icounter_daily_limit[DolphinAppMAX]    |<br>| (DolphinAppMAX bytes)                  |<br>+---------------------------------------+<br>| butthurt_daily_limit                   |<br>| (1 byte)                              |<br>+---------------------------------------+<br>| flags                                 |<br>| (4 bytes)                             |<br>+---------------------------------------+<br>| icounter                              |<br>| (4 bytes)                             |<br>+---------------------------------------+<br>| butthurt                              |<br>| (4 bytes)                             |<br>+---------------------------------------+<br>| timestamp                             |<br>| (8 bytes)                             |<br>+---------------------------------------+</pre><p>Let’s understand what’s the size of the icounter_daily_limit array so we could know how to find the icounter bytes in the .dolphin.state binary!</p><p>We see thatDolphinAppMAX is an enum in dolphin_deed.c :</p><pre>typedef enum {<br>    DolphinAppSubGhz,<br>    DolphinAppRfid,<br>    DolphinAppNfc,<br>    DolphinAppIr,<br>    DolphinAppIbutton,<br>    DolphinAppBadusb,<br>    DolphinAppPlugin,<br>    DolphinAppMAX,<br>} DolphinApp;</pre><p>Since the value of the DolphinAppMax isn’t declared - it gets the default one according to the index, which is 7 (the indexes of the values in the enum are starting from 0), like that:</p><pre>typedef enum {<br>    DolphinAppSubGhz, (val is 0)<br>    DolphinAppRfid, ( val is 1)<br>    DolphinAppNfc, ( val is 2)<br>    DolphinAppIr,  (val is 3)<br>    DolphinAppIbutton,  (val is 4)<br>    DolphinAppBadusb, (val is 5)<br>    DolphinAppPlugin, (val is 6)<br>    DolphinAppMAX,  (val is 7)     &lt;-------- this!<br>} DolphinApp;</pre><p>So icounter_daily_limit is basically an array sized 7.</p><p>Here’s how the body(data) of the state looks like now:</p><pre>+---------------------------------------+<br>|          DolphinStoreData             |<br>+---------------------------------------+<br>| icounter_daily_limit[7]               |<br>| (7 bytes)                             |<br>+---------------------------------------+<br>| butthurt_daily_limit                  |<br>| (1 byte)                              |<br>+---------------------------------------+<br>| flags                                 |<br>| (4 bytes)                             |<br>+---------------------------------------+<br>| icounter                              |<br>| (4 bytes)                             |<br>+---------------------------------------+<br>| butthurt                              |<br>| (4 bytes)                             |<br>+---------------------------------------+<br>| timestamp                             |<br>| (8 bytes)                             |<br>+---------------------------------------+</pre><p><em>(28 bytes in total)</em></p><p>This DolphinStoreData struct is actually a member of another struct called DolphinState in dolphin_state.h:</p><pre>struct DolphinState {<br>    DolphinStoreData data;<br>    bool dirty;<br>};</pre><p>Which is actually the struct that is used when allocating, freeing and writing to memory for the save/load functionality of the binary .dolphin.state</p><pre><br>void dolphin_state_free(DolphinState* dolphin_state);<br>bool dolphin_state_save(DolphinState* dolphin_state);<br>bool dolphin_state_load(DolphinState* dolphin_state);<br>DolphinState* dolphin_state_alloc();<br></pre><p>Therefore, our new DolphinState struct is saved in memory like this:</p><pre>+---------------------------------------+<br>|          DolphinState                 |<br>|                                       |<br>+---------------------------------------+<br>| DolphinStoreData data                 |<br>| (28 bytes)                            |<br>+---------------------------------------+<br>| bool dirty                            |<br>| (1 byte)                              |<br>+---------------------------------------+</pre><p>So the size of the body of the dolphin is actually <strong>29 bytes</strong>.</p><p>Now, SavedStructHeader is the header (with the magic and checksum) and DolphinState is the body (with the icounter and butthurt members):</p><pre>+---------------------------------------+<br>|          SavedStructHeader            |<br>|          (8 bytes)                    |<br>+---------------------------------------+<br>+---------------------------------------+<br>|          DolphinState                 |<br>|          (29 bytes)                   |<br>+---------------------------------------+</pre><p>Calculating the offset of our bytes in file:</p><p>checksum offset: magic (1) + version (1) = 1+1 = 2</p><p>icounter offset: magic(1) + version(1) + checksum(1) + flags(1) + timestamp(4) + icounter_daily_limit (7) + butthurt_daily_limit (1) + flags(4) = 1+1+1+1+4+7+1+4= 20</p><p>Let’s return to the actual .dolphin.state file:</p><pre>00000000: d001 cf00 0000 0000 000f 1414 0100 022e  ................<br>00000010: 0000 0000 3a00 0000 0000 0000 0000 0000  ....:...........<br>00000020: 113e 7a64 0000 0000 0a                   .&gt;zd.....</pre><p>Now, we know how to calculate the offsets of each one of the members in the two structs (header and body):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nlVEcqGFF6-HpmJeX07hOA.png" /><figcaption>too-colorful values of the members in the header and data structs</figcaption></figure><p>So the values are:</p><p><strong>checksum</strong> : 0xcf (207 in decimal)</p><p><strong>icounter</strong>: 0x3a (58 in decimal)</p><p>Now, we want to increase the icounter, let’s increase both icounter and checksum by 200.</p><p><strong>temp</strong><strong>checksum</strong>: 0x197 (407 in decimal)</p><p><strong>new </strong><strong>icounter</strong>: 0x102 (258 in decimal)</p><p>Notice I called the new value of checksum <strong>temp</strong> checksum. Here’s why:</p><p>The chucksum is 1 byte long (8-bit) -</p><pre>uint8_t checksum;</pre><p>And the largest value that 1 byte can hold is 0xff (255 in decimal).</p><p>BUT — have here 0x197- which is 407 in decimal that should be represented by 1 byte.</p><p>The new value 0x197 (407 in decimal) is bigger than the possible largest 1-byte value, which is 255 in decimal, 0xff in hex.</p><p>Therefore, we should use modulo on the new value of 256 and add the remainder from the devision by 256 (if there’s any) to the total checksum value.</p><p>In other words, the new value should be 407 % 256 + remainder (remainder from dividing 407 by 256).</p><p>calculating the new value as the following:</p><p>temp checksum = 407 in decimal</p><p>remainder = tempchecksum / 256 = 407 / 256 = 1</p><p>result = temp checksum % 256 + remainder = 407 % 256 + 1 = 151</p><p><strong>new </strong><strong>checksum</strong>: 0x98 (151 in decimal)</p><p><strong>new </strong><strong>icounter</strong>: 0x102 (258 in decimal)</p><p><em>We don’t have the same thing with </em><em>icounter since it’s </em><em>uint32_t , therefore the largest value that </em><em>icounter can hold is 0xffffffff - 2^32, (4294967295 in decimal)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*ABW-9KwHX90KAsX0PXt5SA.gif" /><figcaption>POV: My brain trying to calculate the offsets</figcaption></figure><p>Now, we can edit the .dolphin.state file manually.</p><p>Since I’m lazy I’m using a trick to automatically edit the bytes:</p><ul><li>Open the file in vim</li><li>run :%!xxd to convert to hexdump</li><li>Edit the hexdump</li><li>run :%!xxd -r to convent the hexdump to binary</li><li>Save</li></ul><p>So our new .dolphin.state file looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYvGbbpelf1vxMdY6Wcziw.png" /><figcaption>new patched .dolphin.state file</figcaption></figure><p>*Notice the new values for the checksum and icounter</p><p>*To easily convert hex or decimal 4-byte values I wrote this little script, you might find it useful:</p><pre>import argparse<br>import struct<br>import os<br><br>parser = argparse.ArgumentParser(description=&quot;Packer for bytes, enter byte and get the little endian representation for binary relace&quot;)<br>parser.add_argument(&quot;byte&quot;, type=str, help=&quot;unter byte value, such as 300, 0x50&quot;)<br>args = parser.parse_args()<br>byte = args.byte<br>print(f&quot;Packing {byte}&quot;)<br>packed = struct.pack(&quot;I&quot;, int(byte, 0))<br>print(f&quot;here&#39;s your binary stuff: \\n{packed}&quot;)</pre><p>Running it to get the bytes representation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2pQxcWx05z-6bhjFJerM-g.png" /><figcaption>bytes.py helper output</figcaption></figure><p>We can upload the new .dolphin.statefile in the flash in Flipper using qflipper program:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*scUzcbrhMVnawz0SWwLT1w.png" /></figure><p>And viola! 258 XP out of 300!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*scTl712e_2zxc8nHSvPIXQ.jpeg" /><figcaption>Flipper Zero with 258 XP</figcaption></figure><p>HURRAY!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCu3qdwrNTUcCm553x46gg.png" /></figure><p>Let’s show off and set the icounter to 858, to benefit from all the hard work we’ve done.</p><p>Using the new values:</p><p>icounter - 0x35a (858 in decimal)</p><p>checksum -0xf2 (242 in decimal)</p><p>The hexdump of .dolphin.state looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gg0TuPyfxlQZga-IFDbG9A.png" /><figcaption>hexdump of level 2</figcaption></figure><p>Level UP!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZQjriLPm90ke0Dpf6lJnGw.jpeg" /><figcaption>Level 2 with 858 XP</figcaption></figure><p>Here’s a script that does that automatically in python:</p><p><a href="https://github.com/noypearl/FlipFlop/blob/main/levelup.py">https://github.com/noypearl/FlipFlop/blob/main/levelup.py</a></p><p>Aaaand — see it in action:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FMAxNkKcvwrw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DMAxNkKcvwrw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FMAxNkKcvwrw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7da47f64ac4f9940140910cddc80a200/href">https://medium.com/media/7da47f64ac4f9940140910cddc80a200/href</a></iframe><p>Let me know if you have any comments!</p><h3>References</h3><ul><li><a href="https://github.com/flipperdevices/flipperzero-firmware"><em>https://github.com/flipperdevices/flipperzero-firmware</em></a></li><li><a href="https://github.com/flipperdevices/qFlipper"><em>https://github.com/flipperdevices/qFlipper</em></a></li><li><a href="https://github.com/DroomOne/FlipperScripts/blob/main/dolphin-state.py"><em>https://github.com/DroomOne/FlipperScripts/blob/main/dolphin-state.py</em></a></li><li><a href="https://chat.openai.com/"><em>https://chat.openai.com</em></a><em> — ❤ as always</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dd16847da5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ShopPing— In-Stock Pinging Telegram Bot Infrastructure In AWS]]></title>
            <link>https://medium.com/@60noypearl/shopping-in-stock-pinging-telegram-bot-infrastructure-in-aws-13f545dc5f5?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/13f545dc5f5</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[telegram-bot]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sun, 22 Jan 2023 20:12:21 GMT</pubDate>
            <atom:updated>2023-01-22T20:40:38.382Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>TL;DR: No additional code is needed — now I can create&amp;manage alerts in Telegram for new in-stock items in online shops, by only sending a single telegram message for EVERY new website that I want to monitor :O</strong></p><figure><img alt="logo" src="https://cdn-images-1.medium.com/max/512/1*29hIidZo-PNHseQEOYd94A.png" /></figure><p>Confused? Me too, it was a weird sentence. But continue to read, it’s cool!</p><h3>Why</h3><p><strong>Did it ever happen to you when you wanted to order something online — but it was out of stock? And you just hated the need to check day after day when the item is in stock? You can automate it — but what if there are multiple different stores? And how can you monitor and maintain those automations easily?</strong></p><p>A few months ago I created a telegram bot for an online shop to parse the page and notify me when my bouldering shoes were back in stock again.</p><p>Here’s a screenshot from the bot that made me very happy on that day:</p><figure><img alt="Bouldering shoes in stock message" src="https://cdn-images-1.medium.com/max/1024/1*dA2G88LrjS0R8co8pPR6tg.jpeg" /></figure><p>but it wasn’t enough. Because then I got excited and wanted to get those reminders for more websites, and I didn’t want to waste the same effort again and again and duplicate the same code over — so I decided to write an infrastructure for those websites <strong>that I can fully control from the telegram chat.</strong></p><h3>Technical Stuff</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*rlGiG3oPSk0HCIdNgHjG_g.gif" /></figure><p>I created an infrastructure that allowed me to easily create those reminder bots — whenever I wanted wherever I wanted, for any website, by sending a single message to my custom telegram bot and magic will happen.</p><h4>Restrictions &amp; Limitations</h4><ul><li>Reducing costs — I didn’t want to create a server that is always up and running</li><li><strong>My experience with AWS infrastructure could be summarized by one action — downloading files from S3 buckets</strong></li><li><strong>My experience with GitHub Actions and writing my own CI/CD environment is even worse</strong></li></ul><h4>How</h4><p>In the end, my infrastructure (which I named ShopPing) had the following components:</p><ul><li><a href="https://core.telegram.org/bots/tutorial">Telegram Bot </a>— for managing the bots &amp; getting notified when in-stock</li><li>[AWS] <a href="https://aws.amazon.com/lambda/">Lambda </a>x2 — one to listen to telegram messages and one to run periodically, parse websites</li><li>[AWS] <a href="https://aws.amazon.com/api-gateway/">API Gateway </a>— to allow external access from telegram to a lambda</li><li>[AWS] <a href="https://aws.amazon.com/cloudwatch/">CloudWatch </a>— for logs &amp; debugs</li><li>[AWS] <a href="https://aws.amazon.com/s3/">S3 Bucket </a>x2 — one as a low-cost database &amp; one for lambdas deployment</li><li><a href="https://github.com/noypearl/Shopper">GitHub repository </a>with <a href="https://github.com/noypearl/Shopper/actions">GitHub Actions </a>— for automatic deployment of lambdas and not hating myself every time I need to deploy new code</li></ul><p>I also played around with AWS IAM Roles, Users &amp; Policies because I needed those to allow different AWS components to communicate with each other — for example, my Lambda with S3.</p><p>Here’s the diagram of how it works:</p><figure><img alt="Main components : Lambda, S3 bucket, EventBridge, API Gateway" src="https://cdn-images-1.medium.com/max/1024/1*TCtRJJD3BVuZubEPHFATJw.png" /><figcaption>Main Components</figcaption></figure><ol><li>I, as a Telegram user, send a message to my custom bot in Telegram. The message will be one of the following commands: list, add, delete, stop, help or resume. Those commands are the way for me to manage ShopPing by simply sending messages in the Telegram app :)</li><li>The message triggers a <a href="https://core.telegram.org/bots/api#setwebhook">Webhook “message” event </a>to the API Gateway</li><li>The API Gateway gets the “message” event and acts as a trigger to run the Listener lambda with the “message” event data from Telegram</li><li>The Listener Lambda gets the “message” event and runs the code that responds to it. Depending on the command, It will get a JSON file called sites.json from an S3 bucket that contains all the existing site crawlers and updates it</li><li>In addition to that — EventBridge will trigger every 1 hour a Parser Lambda — this lambda will get the list of the websites to crawl from the S3 bucket (sites.json file), parse each website and check if the item that we want is back in stock. It will do so by checking if a specific keyword that we define exists in the HTML. This keyword exists only in out-of-stock pages and we define it when we add a crawler, so when the parser will run and won’t find this keyword — we’ll get a HIT and will send a Telegram message to notify that this item is back in stock!</li></ol><h3>Screenshots &amp; Video</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*CnUIWddQQ8GCmpCIXPWJ1Q.png" /><figcaption>help menu</figcaption></figure><p>Screenshots of me using it — I can add more and more websites to crawl and search specific keywords that I define.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*ebjc8Q7Q9bk1Bv1955mNsA.png" /><figcaption>deleting, disabling website monitor and stopping</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*NTOMAacr70aBriI12k20QA.png" /><figcaption>Adding a website job and getting successful HIT</figcaption></figure><p><a href="https://youtube.com/shorts/GZXChyn63ws">ShopPing Telegram Bot</a></p><p>Also — if I’m already learning new stuff in the cloud — why not automate the deployment process by writing my first GitHub Action that will run every new code is merged and deploy code to the lambdas with less <em>cringe?</em></p><p>I used one repository with 2 different folders and 2 GitHub Actions that deployed to 2 different Lambdas depending on the folders.<br>Here’s how they worked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*aFB-sbTHf_qqYvJZcPPRdg.png" /></figure><p>Skipping the less-important stuff, this is what happened every time I pushed new code to the main branch:</p><ol><li>According to the directory — create a zip of all the Lambda code</li><li>Connect to AWS using the credentials stored in GitHub Secrets</li><li>Upload the zip to S3 Bucket</li><li>Deploy the zip from the S3 Bucket to the Lambda</li></ol><p><a href="https://github.com/noypearl/Shopper/blob/master/.github/workflows/menu_deploy.yml">Here’s the YAML file of one of the GitHub Actions</a></p><h4>Some ChatGPT Examples that helped me</h4><p>(Because every article nowadays uses this word at least once)</p><p>The initial code for the Listener Lambda — that listens to commands and handles the communication of S3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*YT3S6Mi_sYe2gTiL_YpQYQ.png" /></figure><p>Full code that I got — pretty impressive:</p><pre>import json<br>import boto3<br>import telegram<br>from telegram.ext import Updater, CommandHandler<br><br>def get_sites_from_s3():<br>    s3 = boto3.client(&#39;s3&#39;)<br>    json_file = s3.get_object(Bucket=&#39;your-bucket-name&#39;, Key=&#39;sites.json&#39;)<br>    json_data = json.loads(json_file[&#39;Body&#39;].read())<br>    return json_data<br><br>def list_sites(bot, update):<br>    json_data = get_sites_from_s3()<br>    urls = [site[&#39;URL&#39;] for site in json_data if site[&#39;enabled&#39;] == True]<br>    bot.send_message(chat_id=update.message.chat_id, text=&#39;\n&#39;.join(urls))<br><br>def stop_site(bot, update, args):<br>    json_data = get_sites_from_s3()<br>    for site in json_data:<br>        if site[&#39;keyword&#39;] == args[0]:<br>            site[&#39;enabled&#39;] = False<br>            s3 = boto3.client(&#39;s3&#39;)<br>            s3.put_object(Bucket=&#39;your-bucket-name&#39;, Key=&#39;sites.json&#39;, Body=json.dumps(json_data))<br>            bot.send_message(chat_id=update.message.chat_id, text=&#39;Site {} stopped.&#39;.format(site[&#39;URL&#39;]))<br>            break<br><br>def main():<br>    # Telegram Bot Authorization Token<br>    updater = Updater(&quot;YOUR_TELEGRAM_BOT_TOKEN&quot;)<br><br>    # Get the dispatcher to register handlers<br>    dp = updater.dispatcher<br><br>    # Add command handler to list sites<br>    dp.add_handler(CommandHandler(&quot;list&quot;, list_sites))<br><br>    # Add command handler to stop site<br>    dp.add_handler(CommandHandler(&quot;stop&quot;, stop_site, pass_args=True))<br><br>    # Start the Bot<br>    updater.start_polling()<br><br>    # Run the bot until you press Ctrl-C or the process receives SIGINT,<br>    # SIGTERM or SIGABRT. This should be used most of the time, since<br>    # start_polling() is non-blocking and will stop the bot gracefully.<br>    updater.idle()<br><br>if __name__ == &#39;__main__&#39;:<br>    main()</pre><p>Asking basic AWS stuff here because I’m lazy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ZKD5MSYOrXEEIg3DVKz1A.png" /><figcaption>Accessing S3 bucket from Lambda</figcaption></figure><h4>Clarifications</h4><ul><li>Although I’m saying that I parse the websites in the Parser lambda I don’t really parse them — I just search the keyword inside the HTML that I get, but I don’t know a word to describe it</li><li><strong>ChatGPT </strong>helped me a lot here with the basic stuff, but I also had to deeply understand how AWS roles &amp; permissions work</li><li>The same thing to creating a deployment environment — you can use <strong>ChatGPT</strong> to create a GitHub Action .yml but you do need to understand the logic of uploading your zipped code to S3 and triggering an API call to deploy from the bucket to the lambda. You can also check out about <a href="https://aws.amazon.com/cloudformation/">CodeFormation </a>which is pretty cool but was overkill for my very small deployment environment</li></ul><h3>Summary</h3><p>Well, it was REALLY fun! And kinda new to me as well. As an AppSec researcher I was familiar with the basic components (S3, EC2) but I’ve never really fully configured a working end-to-end project with support in deployments from local environment to AWS and GitHub Actions stuff. Also — I knew that Policies and Roles are the bread and butter of AWS Permissions management but actually configuring those, debugging and solving those issues is a much better way to learn those things IMO.</p><p>Here’s <a href="https://github.com/noypearl/Shopper">my full code in GitHub</a> — for the 2 Lambdas and also the GitHub Actions.</p><p><strong>Also — I really think that debugging those AWS Gateway/roles/permissions/policies/S3 spaghetti is a teaching yet painful experience that everyone who’s keen about the Cloud should have, so I didn’t document those parts in this article because I want you to do it yourself if you’re going to clone the code :)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*mr8WkZGjk5HtqUi9b1-vmg.gif" /></figure><p>Ping me if you have any questions / comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13f545dc5f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On-Boarding Buddy — The Dos And Don’ts]]></title>
            <link>https://medium.com/@60noypearl/on-boarding-buddy-the-dos-and-donts-a277f44deb4e?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/a277f44deb4e</guid>
            <category><![CDATA[team-building]]></category>
            <category><![CDATA[onboarding]]></category>
            <category><![CDATA[insights]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sat, 02 Apr 2022 20:22:23 GMT</pubDate>
            <atom:updated>2022-04-02T20:46:14.265Z</atom:updated>
            <content:encoded><![CDATA[<h3>On-Boarding Buddy — The Dos And Don’ts</h3><h3>A Short Disclaimer</h3><p>There is no straightforward manual for successful On-Boarding. On-boarding is an ongoing process that can last more than a few months and be dynamic. However, following a methodology proven to work with a few fundamental principles can significantly improve the On-Boarding experience for a new employee.</p><p><strong>*I wrote everything in this article from my subjective point of view</strong>. Please feel free to comment with your ideas and thoughts about your On-Boarding processes.*</p><h3>Intro</h3><p>When I started working at my current job, I was the first to join the team [a week] right after my team leader. There was no actual team yet, and unquestionably no official, detailed On-Boarding document. My team leader did his best to support me and prepared a document with the knowledge he was able to gather during that week. However, I still had to ask<strong> many</strong> people <strong>a lot </strong>of questions to understand how to get along in the company and get the help I needed from them.</p><p>When more people joined the team, I made sure to document the knowledge I didn’t have when I arrived on my first day, so they’ll have a better On-Boarding experience. Our team grew in numbers. After and during every On-Boarding progress, I improved it more, and it became the official On-Boarding process in the group.</p><p>Other teams in the company heard about this process and asked for this document so they could customize it for their On-Boarding progress. I was over the moon.</p><h3>A word about On-Boarding and Buddies</h3><p>Before your first day at work — there’s unknown to you more than known. Sometimes, it can become pretty stressful. What are the new members of the team like? What will a day on this team look like for me? Will I be able to match the expectations from me? What do they even expect from me during the first weeks? — And more similar questions.</p><h4>The Buddy is here to help!</h4><p>Buddy — the person that can help you with all those fears and questions above. First, let’s distinguish between two terms — <strong>Buddy and On-Boarding.</strong></p><p><strong>On-Boarding </strong>is the process you go through when you are new and have just started working.</p><p><strong>Buddy </strong>is the person who should support you during the On-Boarding process and be your go-to person for everything related to it and more. Probably they’ll be from your own team/group. I had the privilege of both establishing the On-Boarding process in the team and being the Buddy who supports each of the team members during their first weeks.</p><h3>You don’t want to be a dependency</h3><h4>Think before you answer their question</h4><figure><img alt="Sometimes I’ll start a sentence and I won’t know where it’s going" src="https://cdn-images-1.medium.com/max/220/1*Cm2-X3MCw1eFGLTCVUQGFQ.gif" /></figure><p>Sometimes providing the new members with a direct answer is not the best idea. Today you are here to answer their question — but what will happen when you aren’t there? Being a good buddy is not necessarily answering all their questions perfectly but providing them with the tools so they’ll know where to get their answers from.</p><p>Show them how to search for knowledge in the company. It can be your wiki platform, tasks, documentation links, important READMEs, repositories, or Slack channels. Show them the small tricks you made up during your time working at this workplace — like how to learn about a new term and where &amp; how to search for this — it might actually save up hours for them.<br>Remember that you don’t necessarily have all the answers to their questions, and that’s ok, so direct them to the relevant people instead and make sure they get their questions answered.</p><p>I added a “Useful People” table in the On-Boarding document with a few words about each person so they could get help from them — for example, “Lena Oxton, Backend Tech Lead — can help with common setup issues with X system”.</p><h4>You don’t want them to ask you “simple questions”</h4><p>I know it sounds harsh, but you should document the simple things that they probably will ask you instead of waiting for them to ask and answer them. It will save you both time, and they can come back to the document instead of asking you the same question when they forget your first answer to this after lunch.</p><p>For that I created a general On-Boarding document with the basic company-specific things, that obvious for people working here but not so obvious to new members. For example, how we communicate — Slack/Teams, important channels, Projects links, Programs &amp; Licenses — for example IDEs, Permissions they need to verify they got, useful plugins, links to important documentations &amp; repositories, interesting team members’ writeups and more.</p><p>The team also created a knowledge center that we regularly update with new content both for new members &amp; for knowledge sharing between us. They can go over this also to get the hang of how this team works and what team members actually do during the day.</p><h3>Before Their First Day</h3><h4>Introduction &amp; Preparations</h4><figure><img alt="I’m ready" src="https://cdn-images-1.medium.com/max/220/1*2xZNeqJyzQ_Lg32bmkX3HQ.gif" /></figure><p>Message the new member. Introduce yourself and tell them you are their Buddy and that you are there to support them during their first weeks. If there’s a form they should fill up before, ask them if they need help with this or anything before the first day. Sometimes they even ask to call you, have an excellent talk beforehand, and raise a few questions that concern them before their first day. Depending on your WFH policy — ask them if they plan to be physically at the office on the first day. If they arrive at the office during their first day — you can be there for them. It’ll be much better to meet them face-to-face.</p><p>Go Through their On-Boarding document with your team leader and get familiar with the topics. If you are working with multiple departments — ask to which department this new member is intended and make sure to highlight and tell more about the new department’s important knowledge.<br>Go through the general Tips and Tricks document for the new members that you prepared in advance and that the rest of the team members regularly update in addition to you. I can’t stress enough how useful it was for the new members I buddied.</p><h3>During Their First Day</h3><h4>Fun &amp; relieving stress</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*2z6QA3j12iO13I4uYjdnQA.gif" /></figure><p>In the company I’m currently working in — usually all the buddies arrive to greet the person they’re going to buddy after the new employees’ session on their first day.</p><p>Show them the office, and introduce them to the rest of the team and other teams you work with. Try to make them more familiar with the office and the people since everything is new to them. Make sure they have all the setup they need for their work. If something is missing — go with them to get it and introduce those people to them as well, so next time they’ll know where to go for this kind of help and be more independent.</p><p>Give them time to absorb all those new things in the office. It’s their first day, so make it a fun day for them because they must be excited and probably stressed. Work and technical things will come eventually.</p><p>Still, I’m sure most people are keen to know how it will be on their first day, so I usually overview the On-Boarding process with them <strong>at a high level </strong>because they probably won’t remember most of what I’ll say because of the excitement of their first day.</p><h3>Second Day And On</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Olx3gZEkDT0VnjWcNpvYAw.jpeg" /></figure><p>Now they are [hopefully] less stressed, and you can dive deeper into more interesting stuff with them.</p><p>During their first weeks, it is crucial to be there for them and make sure they don’t get stuck or don’t know how to proceed. Schedule a weekly with them so they can gather and share their questions and ideas. You can go together through the On-Boarding progress and understand the current status and prioritize the On-Boarding tasks with them in case they get to dead ends.</p><p>When there are new members during dailies, I usually will explain with a sentence or two about the general idea of the task I’m talking about and give out more information so the new members can follow up and ask questions about what I’m explaining. It makes the daily a little bit longer, but that’s precisely how to make the new member feel more like a part of the team and learn better and faster about how things work. Also, I really try to make sure they feel comfortable enough to ask me the questions they sometimes were shy to ask or didn’t want to ask in front of everyone during the dailies. It can be about a specific task that one member said or more generally about how our work with team X looks.</p><p>Tell them what an On-Boarding process here looks like and explain what they are expected to do and what they are not expected to do during the On-Boarding to make it more transparent with them. For example, they are expected to go through the material you give them and learn it, but are not expected to start to know everything and complete tasks one week later.</p><p>A new team member is a fresh mind that can also significantly improve your team by highlighting actions you are used to doing without automating them or working on a simpler solution. I usually tell them that if we do something in a certain way in the team, that doesn’t mean this is the best way, so they come up with new ideas of things to improve in the team, and we discuss it afterward and a lot of times improve those things thanks to them (and they also get a great &amp; valuable On-Boarding first task ;))</p><p>Also — you can start the more technical process &amp; explanations after their first day. First, understand if there’s something they still lack from the 1st day and begin reviewing the On-Boarding document in detail. Ensure they understand why the process and the tasks in the document are ordered in that way and ask them if there’s an additional department they are interested in learning about during their On-Boarding process.</p><p>Make sure to explain to them it is not about the quantity but the quality and that you prefer the On-Boarding session will be longer, but they will have a great understanding of how things work rather than the opposite.<br>Schedule a meeting for them with each one of the team members. It will help them get to know everyone, learn about the most interesting tasks that anyone is doing/did, and boost their On-Boarding process significantly. In addition, they will feel more like a part of the team and will have other people they are comfortable with to ask questions and get help.</p><h3>Patience</h3><h4>Going through an On-Boarding process is not an easy task.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*VRwEQZ9Z84QbTn0-Kotvhw.gif" /></figure><p>The new members can ask you the same question over and over again. They can fail to attend meetings at first because they have issues with their calendar setup. They might progress slowly in the On-Boarding because they have never had a Mac, and the transition is hard for them.<br>Your role is to help them to solve their issues. Maybe they should have Windows instead? That’s where the dynamic part comes into the picture.</p><h3>Dynamic Part — the fun part</h3><p>After I mentioned the basic Buddy approach — I still think that <strong>a lot </strong>of how the On-Boarding process will look like depends on the person that goes through the On-Boarding.</p><p>I’m not talking about the essential material every new member has to learn. What I mean is that people are different. Some people will approach you only after they get stuck. Some people will ask you many questions, and you’ll have to show them how to find the answers on their own. Some people are shyer and will ask you more questions when you are both at the office and will be quieter on Slack.</p><p>That’s why the first weeks are also weeks of learning for you. You will learn a lot about the new member, their strengths, and their problem-solving skills, and you will gradually understand the best advice you can give them. For example, should you solve their issue for yourself? Talk with the system’s owner for them? Tell them to talk with the owner? This part has no direct guidelines and can highly affect — either positively or negatively- the rest of their On-Boarding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*xiR-hN8wmFAMmTRBydDvpQ.gif" /></figure><h3>Last Notes</h3><p>Buddying is fun and challenging. It’s like a muscle — the more you do it — the better you’ll be at it. So ask for ongoing feedback from them, ask them at the end how this On-Boarding has been for them, and improve it accordingly for the future new members.</p><h3>Good Luck!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a277f44deb4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Back Me Up — Hacking Android apps without root]]></title>
            <link>https://medium.com/swlh/back-me-up-hacking-android-apps-without-root-44d7789dc232?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/44d7789dc232</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-security]]></category>
            <category><![CDATA[mobile-security]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sun, 05 Apr 2020 10:23:34 GMT</pubDate>
            <atom:updated>2020-04-07T20:17:51.645Z</atom:updated>
            <content:encoded><![CDATA[<h3>Back Me Up — Hacking Android apps without root</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OA7g6yMOvXCN98IL" /><figcaption>Image: <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Why this topic?</strong></p><p>Nowadays, we see many tutorials on Android Penetration testing, mentioning using a rooted device as a substantial requirement.</p><p>Using a rooted Android device indeed enables you to do many more actions than using an unrooted one.</p><p>However, there are a few overlooked methods while pentesting Android apps that don’t require root access. This time we’re going to dive into a very interesting one, which apparently isn’t very well-known — Android Backup.</p><p><strong>Why this method?</strong></p><p>I chose to focus on this Android Backup method since there’s a difficulty while trying to access the app’s protected data directory with an unrooted device — AKA data/data/APP_PACKAGE_NAME.</p><p>Many developers might store there their sensitive data with the claim that you must have root access to read/write these files.</p><p>In this article, we’re going to prove why in some cases the above claim is wrong.</p><p><strong>To whom is this aimed?</strong></p><p>· Android developers</p><p>· Security enthusiasts</p><p>· Pentesters / Researchers</p><p>Some of the methods require an understanding of <a href="https://developer.android.com/guide/components/fundamentals">Android Fundamentals</a>. My suggestion is to google every term you aren’t sure about, understand it, and return to this article. I provided links on specific terms that might be useful for that.</p><p><strong>How?</strong></p><p>To demonstrate it in the best way — I built an exploitable app in Java.</p><p><a href="https://github.com/noypearl/Android-backup-app">Here’s the full code of the app</a> — feel free to play with it. Also, I provided there the apk I built so you could test the backup functionality without building the app.</p><p>This app represents a bank application that has a few issues which we’ll talk about later.</p><p>The package name of the app is <strong>com.app.dontbackup</strong>. Remember it; we’ll use that later.</p><p>Install the app and run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*Ge3wdbmBFspP2LJLjQiWeA.png" /><figcaption>Android app main screen</figcaption></figure><p>As you can see, this screen shows the full name and balance of an account named Ciri.</p><p>I’m saving sensitive information about this user by using an Android component called <a href="https://developer.android.com/reference/android/content/SharedPreferences"><strong>SharedPreferences</strong></a>. Using this component — the data is saved to <em>/data/data/com.app.dontbackup/shared_prefs</em>/com.app.dontbackup.xml file in the device.</p><p>Although the phone number and address aren’t represented on the screen — I still save them using the SharedPreferences component.</p><p>The following code in the app saves the sensitive details in the shared preferences folder:</p><pre>private void writeSharedPrefs(SharedPreferences prefs){<br>    prefs.edit().putString(&quot;name&quot;, name).apply();<br>    prefs.edit().putInt(&quot;balance&quot;, balance).apply();<br>    prefs.edit().putString(&quot;address&quot;, address).apply();<br>    prefs.edit().putString(&quot;phoneNumber&quot;, phoneNumber).apply();<br>    prefs.edit().putString(&quot;email&quot;, email).apply();</pre><p>Many times I see sensitive information that is saved that way, including users’ full name, phone numbers address, username, and password.</p><p>Now, Using a rooted Genymotion emulator — I want to show you how the data is actually saved. Don’t worry — when I’ll show you the exploitation method, I’ll be using an unrooted device.</p><p>To see the file in a rooted device, we run the following command using ADB:</p><pre><em>adb shell cat data/data/com.app.dontbackup/shared_prefs/com.app.dontbackup.xml</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*TMmfHSulFtN93HOTX4mPtQ.png" /><figcaption>Like that, I can see all of the sensitive data that I saved in the device.</figcaption></figure><p>But — this isn’t something spectacular. We want to see the data using an <strong>unrooted</strong> device.</p><p>Let’s do it.</p><p><strong>Switching to an unrooted Android device.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*VMSjnpWpwOsIH3bEN2Oelw.png" /><figcaption>Great, this device isn’t rooted.</figcaption></figure><p>We know already that there’s sensitive data in <strong><em>/data/data/com.app.dontbackup/shared_prefs</em></strong> folder. We want to get it. To do so — we will use the Android <strong>allowBackup</strong> feature.</p><p>This is a feature that enables you to perform a backup of an application via ADB. It’s enabled by default in the AndroidManifest.xml. Here’s a screenshot of it from our app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*e7hn2XsfckqhkXP9vEeLbQ.png" /><figcaption>allowBackup is enabled by default</figcaption></figure><p>Read more about it <a href="https://developer.android.com/guide/topics/manifest/application-element#allowbackup">here</a>.</p><p>Using ADB, run the following command to create a backup file of the app’s data:</p><pre><em>adb backup -f backup.ab -f com.app.dontbackup</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*V8C2dpok9LYFrIIFp7xokQ.png" /></figure><p>This command will ask the device for backing up the data. If a password is required — fill up the real one. If there isn’t one — leave empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*kAH7lWspJlD_GEtZrRnYKg.png" /><figcaption>Device prompt to backup the data</figcaption></figure><p>Now — we got a backup file called backup.ab. Let’s extract the data from it.</p><p>We’ll use an open-source tool called <a href="https://github.com/nelenkov/android-backup-extractor">android-backup-extractor</a></p><p>Using this tool — We’ll use abe.jar file and turn the backup file into a tar archive</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*6-2RJzIp3_KpM9F-wcCc2g.png" /></figure><p>You should get a file named unpacked which is a tar archive</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*tcbN_7PNisOIsm_rIIB4Jg.png" /></figure><p>Extract it and get the shared preferences file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*o822REOZTH3hni5suVsr4Q.png" /></figure><p>Now we can see the sensitive data that was saved to <em>/data/data</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*GgPntFq5kot2K1ai9UNvxQ.png" /><figcaption>data was extracted from /data/data without root</figcaption></figure><p>This app saves only this specific data. Other apps might save much more data in a handful of ways, including SQLite databases, images, app’s configuration files, and security tokens.</p><p>Reading this data is excellent — what about modifying this data in the app’s folder with an unrooted device?</p><p>I’ll let you research on your own.</p><p><em>A little hint: ‘adb restore’.</em></p><p>Good luck.</p><p><strong>But are the dangers real?</strong></p><p>Some of you might say that this method of extracting and restoring this sensitive data to the app isn’t that simple. That it requires a device with debugging settings enabled, and who does that?</p><p>The answer is a lot. Many of us enable these settings to perform various actions: installing custom ROM, developing and testing Android Applications, or simply exploring the Android system.</p><p><strong>Security Mitigations</strong></p><p>As I previously showed — enabling backups of an Android app endangers the data stored in its most protected directory. Except for revealing the SharedPreferences — it could expose sensitive SQLite databases that store sensitive information about other users, including full names, addresses, emails, private phone numbers, private images, and any other sensitive data you could think of.</p><p>Think about it like that — <strong>The app may include any data that the developers thought to keep in secret from everyone who isn’t the app’s process</strong>.</p><p>If you insist on enabling backups of the app, make sure to do the following:</p><p>· encrypt the data with known and robust encryption algorithms.</p><p>· Make sure that the encryption key is a unique one and isn’t hardcoded in the app — otherwise, an attacker can read/predict it</p><p>· Apply proper decryption of the restored data. Allow the only data that passed the decryption successfully to be restored.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44d7789dc232" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/back-me-up-hacking-android-apps-without-root-44d7789dc232">Back Me Up — Hacking Android apps without root</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Grommet with Webpack 2 — Create React App]]></title>
            <link>https://medium.com/@60noypearl/using-grommet-with-webpack-2-create-react-app-33be9a078b59?source=rss-1e5ce49d5800------2</link>
            <guid isPermaLink="false">https://medium.com/p/33be9a078b59</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[create-react-app]]></category>
            <category><![CDATA[webpack-2]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Noy Pearl]]></dc:creator>
            <pubDate>Sun, 11 Jun 2017 21:24:11 GMT</pubDate>
            <atom:updated>2020-04-07T13:00:19.486Z</atom:updated>
            <content:encoded><![CDATA[<p>I have spent too much time searching for a way to add Grommet to a new app which I created using Create React App tool with Webpack 2.<br>I created this post in order to help anyone who’s having a hard time adding Grommet in Webpack 2.</p><p><strong>Disclaimer: I’m not an expert in Webpack nor React, My goal is to provide a solution for anyone who’s stuck when starting with Grommet.</strong></p><p>The solution in 10 steps:</p><p><strong>Install required dependencies:</strong></p><ol><li><em>install Grommet</em></li></ol><pre><em>yarn add grommet</em></pre><pre><em>yarn add  —dev grommet-css</em></pre><pre><em>yarn add —dev node-sass sass-loader</em></pre><p>2. <strong>In Webpack config [yarn eject if you haven’t already]:</strong></p><p>Add scss loader:</p><pre>{<br> test: /\.scss$/,<br> use: [<br> { loader: &#39;file-loader&#39;, options: { name: &#39;[name].css&#39; } },<br> { loader: &#39;sass-loader&#39;,<br> options: {<br> outputStyle: &#39;compressed&#39;,<br> includePaths: [<br> &#39;./node_modules&#39;<br> ] }}]<br>}</pre><p>3. Add .scss to extensions array in resolve:</p><pre><em>extensions: [‘.js’, ‘.json’, ‘.jsx’,’.scss’],</em></pre><p>4. Add scss to exclude array:</p><pre><em>exclude: [<br> /\.html$/,<br> /\.(js|jsx)$/,<br> /\.css$/,<br> /\.json$/,<br> /\.bmp$/,<br> /\.gif$/,<br> /\.jpe?g$/,<br> /\.png$/,<br></em><strong><em> /\.scss$/,<br></em></strong><em> ],</em></pre><p>5. Install <em>extract-text-webpack-plugin </em>and require it in webpack config:</p><pre><em>yarn add -dev extract-text-webpack-plugin<br></em></pre><pre><em>const ExtractTextPlugin = require(‘extract-text-webpack-plugin’);</em></pre><p>6. add the next line to the plugins array in module:</p><pre>plugins: [<br>// some plugins here <br><strong><em>new ExtractTextPlugin(“styles.scss”),</em></strong></pre><pre>//more plugins</pre><pre>]</pre><p>7. Import Grommet:</p><pre><em>import Grommet from ‘grommet/components/Grommet’;</em></pre><p>8. Wrap your main app component with Grommet tag.</p><p>For example:</p><pre><em>class App extends Component {<br> render() {<br> return (<br> &lt;Grommet&gt;<br> &lt;div&gt;</em></pre><pre><em>Hello world<br>&lt;/div&gt;</em></pre><pre><em>&lt;/Grommet&gt;</em></pre><p>9. import grommet css in src/index.js file:</p><pre><em>import ‘../node_modules/grommet-css’</em></pre><p>10. import grommet scss file in src/index.js :</p><pre><em>import ‘../node_modules/grommet/scss/vanilla/index.scss’;</em></pre><p>That’s all.</p><p>I hope this post helped somebody,</p><p>Please let me know if you have any question.</p><p>Good Luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33be9a078b59" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>