Jekyll2020-10-23T09:39:57+02:00https://dystopianfuture.org/DystopianFuture...technology, a grim future and meS.WeisgerberLinksys E1700 Flash Openwrt Over Dd Wrt2020-10-23T00:00:00+02:002020-10-23T00:00:00+02:00https://dystopianfuture.org/2020/10/23/linksys-e1700-flash-openwrt-over-dd-wrt<hr />
<p>layout: post
title: Linksys E1700 Flash openwrt over dd-wrt
date: 2020-10-23 07:30 +0200
—————————</p>
<p>My Linksys E1700 (which shall become a firewall) was running dd-wrt. As I want to switch over to openwrt, as they are way more active in development, I needed to flash openwrt.
DD-wrt didn’t like openwrt’s Factory or upgrade images.
They flashed just fine and the device rebooted, but afterwards, dd-wrt was still running.</p>
<p>After some dedicated web research I found <a href="https://forum.openwrt.org/t/reverting-back-to-openwrt-from-dd-wrt/47619/4">a hint</a> in the official openwrt forum. It was a different device, but I compared partition tables and it seemed that it should work for the Linksys E1700 as well, which it did :D</p>
<p>So here’s a small protocol what I did:</p>
<ol>
<li>Get your latest <strong>Factory Image</strong> (not upgrade image) from OpenWrt’s <a href="https://openwrt.org/toh/linksys/e1700">Linksys E1700 page</a>.</li>
<li>(Enable ssh on your device)</li>
<li><code class="highlighter-rouge">scp</code> the factory image to the router: `Downloads/openwrt-19.07.4-ramips-mt7620-e1700-squashfs-factory.bin root@192.168.1.1:/tmp/</li>
<li>ssh login to root@192.168.1.1</li>
<li>Do steps, ignore errors (forums say, they are normal, I succesfully flashed w/ them as well):</li>
</ol>
<p>```shell script
cat /proc/mtd # mtd partitions should look like this roughly</p>
<h1 id="dev----size---erasesize--name">dev: size erasesize name</h1>
<h1 id="mtd0-00030000-00010000-u-boot">mtd0: 00030000 00010000 “u-boot”</h1>
<h1 id="mtd1-00010000-00010000-u-boot-env">mtd1: 00010000 00010000 “u-boot-env”</h1>
<h1 id="mtd2-00010000-00010000-factory">mtd2: 00010000 00010000 “factory”</h1>
<h1 id="mtd3-007a0000-00010000-linux">mtd3: 007a0000 00010000 “linux”</h1>
<h1 id="mtd4-0069b000-00010000-rootfs">mtd4: 0069b000 00010000 “rootfs”</h1>
<h1 id="mtd5-00120000-00010000-ddwrt">mtd5: 00120000 00010000 “ddwrt”</h1>
<h1 id="mtd6-00010000-00010000-nvram">mtd6: 00010000 00010000 “nvram”</h1>
<p>cd /tmp/
mtd -f write openwrt-19.07.4-ramips-mt7620-e1700-squashfs-factory.bin linux</p>
<h1 id="output">Output:</h1>
<h1 id="unlocking-linux-">Unlocking linux …</h1>
<h1 id="could-not-unlock-mtd-device-linux">Could not unlock MTD device: linux</h1>
<h1 id="linux-not-supported">linux: Not supported</h1>
<h1 id="writing-from-openwrt-19074-ramips-mt7620-e1700-squashfs-factorybin-to-linux---w">Writing from openwrt-19.07.4-ramips-mt7620-e1700-squashfs-factory.bin to linux … [w]</h1>
<h1 id="warning-unaligned-data-we-use-manual-padding-to-avoid-errors-size-was-4">Warning unaligned data, we use manual padding to avoid errors. size was 4!!!</h1>
<p>echo “echo”
reboot
```</p>
<p>After reboot, you are greeted w/ the OpenWrt login page.</p>S.Weisgerberlayout: post title: Linksys E1700 Flash openwrt over dd-wrt date: 2020-10-23 07:30 +0200 —————————Spam Of The Day2018-06-05T15:00:00+02:002018-06-05T15:00:00+02:00https://dystopianfuture.org/2018/06/05/spam-of-the-day<p>One of the funniest spam messages I’ve ever received, so I had to post it :D (Sadly it’s in German…)</p>
<p><br /></p>
<blockquote>
<p>Guten Tag,
Während Sie Spaß vor der - computer - browsing redtube und entladen Ihr Rohr yours notebook computer gefangen a Schurken-Programm durch die browser</p>
<p>Dieses program soll capture Kamera, Datensätze alle Ihre Bewegungen und browser-history der hard-core Web-site Sie sind Besuch.</p>
<p>Aber die besten Sache über diese bösartige Programm ist, plug-in yours web-Kamera, Zugriff auf Ihre e-mail und Sicherung Telefonnummern.</p>
<p>Bemerken, dass ich auch Zugriff auf yours social media service - profile.</p>
<p>Also, ich hab das Bilder und videos von Ihnen, nackt. Vids wo Sie sind fudge off.
Wenn Sie don’t wollen Kollegen, und zufällige Benutzer, Sie zu sehen schlagen aus, ich freundlich vorschlagen Sie dies tun: Senden Sie mir 400 Dollar.
Hier ist mein Bitcoin - Nummer <REDACTED></REDACTED></p>
<p>Wenn ich erhalten das Geld, I ll entfernen alle Fotos und Sie werden nie hören von mir.</p>
<p>Wenn Sie nicht senden Sie das Geld innerhalb von 23 Stunden seit dem moment der Lesen diese E-Mail, schicke ich Ihnen Ihren schmutzige Unterwäsche Ihren Kollegen, durch Ihre social-media für jedermann zu sehen, Ihrer Familie, zu Ihren Freunden, Ihrer Mitarbeiter.</p>
<p>P. S. Mein das Deutsche ist nicht gut, weil ich bin nicht eine native, aber Iam sicher, dass Sie verstehen.
Dont Antwort auf diese e-mail. Es nicht zu mir gehöre und ich `bin nicht der Planung bis es nicht mehr verwenden.</p>
</blockquote>S.WeisgerberOne of the funniest spam messages I’ve ever received, so I had to post it :D (Sadly it’s in German…)Android AOSP Android.mk - `$(call all-subdir-makefiles)` Path problems2018-03-01T16:00:00+01:002018-03-01T16:00:00+01:00https://dystopianfuture.org/2018/03/01/android-mk-calling-all-subdir-makefiles<p>In order to use the macro <code class="highlighter-rouge">$(call all-subdir-makefiles)</code> in a <code class="highlighter-rouge">Makefile</code> when building AOSP or one of the modules,
one has to save and restore the <code class="highlighter-rouge">$LOCAL_PATH</code>.</p>
<ul>
<li><code class="highlighter-rouge">$LOCAL_PATH</code> gets overwritten from called subdir makefiles.</li>
<li><code class="highlighter-rouge">$(call my-dir)</code> must be called before <code class="highlighter-rouge">include $(call all-subdir-makefiles)</code></li>
<li>=> So we redefine <code class="highlighter-rouge">$LOCAL_PATH</code> after the call to the subdir makefile</li>
</ul>
<h2 id="example">Example</h2>
<div class="language-make highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Save LOCAL_PATH of the current Android.mk file
</span><span class="nv">SAVED_LOCAL_PATH</span> <span class="o">:=</span> <span class="err">$</span><span class="o">(</span>call my-dir<span class="o">)</span>
<span class="c"># Include/Call all Android.mk recursively
</span><span class="err">include</span> <span class="err">$(call</span> <span class="err">all-subdir-makefiles)</span>
<span class="c"># Restore LOCAL_PATH variable
</span><span class="nv">LOCAL_PATH</span><span class="o">:=</span> <span class="nv">$(SAVED_LOCAL_PATH)</span>
</code></pre></div></div>
<p>Source: <a href="https://groups.google.com/forum/#!topic/android-ndk/7cUf3tkuBSM">https://groups.google.com/forum/#!topic/android-ndk/7cUf3tkuBSM</a></p>S.WeisgerberIn order to use the macro $(call all-subdir-makefiles) in a Makefile when building AOSP or one of the modules, one has to save and restore the $LOCAL_PATH.Android AOSP builds - Multiple Jack Servers on one host2018-02-18T10:00:00+01:002018-02-18T10:00:00+01:00https://dystopianfuture.org/2018/02/18/older-android-builds-and-the-jack-server<blockquote>
<p>In order to run the Android jack build server multiple times on one host, one has to modfiy jack’s ports in the config.</p>
</blockquote>
<h4 id="homejack-file"><code class="highlighter-rouge">$HOME/.jack file</code></h4>
<p>The <code class="highlighter-rouge">$HOME/.jack</code> (Older versions: <code class="highlighter-rouge">$HOME/.jack-settings</code>) file contains the following settings for Jack server variables in a full bash syntax (Symlink one file to the other):</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">SERVER</span><span class="o">=</span>true. Enable the server feature of Jack.
<span class="nv">SERVER_PORT_SERVICE</span><span class="o">=</span>8177. Set the TCP port number of the server <span class="k">for </span>compilation purposes.
<span class="nv">SERVER_PORT_ADMIN</span><span class="o">=</span>8178. Set the TCP port number of the server <span class="k">for </span>admin purposes.
<span class="nv">SERVER_COUNT</span><span class="o">=</span>1. Unused.
<span class="nv">SERVER_NB_COMPILE</span><span class="o">=</span>4. Set the maximum number of allowed parallel compilations.
<span class="nv">SERVER_TIMEOUT</span><span class="o">=</span>60. Set the number of idle seconds the server must <span class="nb">wait </span>without any compilation before shutting itself down.
<span class="nv">SERVER_LOG</span><span class="o">=</span><span class="k">${</span><span class="nv">SERVER_LOG</span>:<span class="p">=</span><span class="nv">$SERVER_DIR</span><span class="p">/jack-</span><span class="nv">$SERVER_PORT_SERVICE</span><span class="p">.log</span><span class="k">}</span><span class="nb">.</span> Set the file where server logs are written. By default, this variable can be overloaded by an environment variable.
<span class="nv">JACK_VM_COMMAND</span><span class="o">=</span><span class="k">${</span><span class="nv">JACK_VM_COMMAND</span>:<span class="p">=java</span><span class="k">}</span><span class="nb">.</span> Set the default <span class="nb">command </span>used to launch a JVM on the host. By default, this variable can be overloaded by environment variable.
</code></pre></div></div>
<p><br /></p>
<h4 id="jack-serverconfigproperties"><code class="highlighter-rouge">~/.jack-server/config.properties</code></h4>
<table>
<tbody>
<tr>
<td>There’s also <code class="highlighter-rouge">~/.jack-server/config.properties</code> which <em>should</em> have the same ports as the <code class="highlighter-rouge">.jack</code></td>
<td><code class="highlighter-rouge">.jack-settings</code> file:</td>
</tr>
</tbody>
</table>
<p><br /></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jack.server.max-jars-size<span class="o">=</span>104857600
jack.server.max-service<span class="o">=</span>4
jack.server.service.port<span class="o">=</span>8177
jack.server.max-service.by-mem<span class="o">=</span>1<span class="se">\=</span>2147483648<span class="se">\:</span>2<span class="se">\=</span>3221225472<span class="se">\:</span>3<span class="se">\=</span>4294967296
jack.server.admin.port<span class="o">=</span>8178
jack.server.config.version<span class="o">=</span>2
jack.server.time-out<span class="o">=</span>7200
</code></pre></div></div>
<blockquote>
<p>You need to modify all/both files,because I modified <code class="highlighter-rouge">SERVER_PORT_SERVICE</code> and <code class="highlighter-rouge">SERVER_PORT_ADMIN</code> (default 8076/8077) in <code class="highlighter-rouge">.jack</code> and nothing happend. <code class="highlighter-rouge">~/.jack-server/config.properties</code> stayed always on the default: 8076,8077.</p>
<p>Also comment out comment out the line with uninstall-server in <code class="highlighter-rouge"><AOSP>/prebuilts/sdk/tools/jack_server_setup.mk</code></p>
</blockquote>
<p><strong>Source:</strong> <a href="https://groups.google.com/forum/#!topic/android-building/UWhJrXH8Vig">https://groups.google.com/forum/#!topic/android-building/UWhJrXH8Vig</a></p>S.WeisgerberIn order to run the Android jack build server multiple times on one host, one has to modfiy jack’s ports in the config.ELF Binary information extraction2018-02-01T10:00:00+01:002018-02-01T10:00:00+01:00https://dystopianfuture.org/2018/02/01/binary-information-dump<h1 id="library-symbol-listing">Library symbol listing</h1>
<p><code class="highlighter-rouge">nm -C /PATH/TO/STATIC/LIBRARY/lib.a</code></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>comm-c0761e06ea036fdd.comm14-e1f6fa1b765f1060a1adaa86eb00af21.rs.rcgu.o:
0000000000000000 T c_die
0000000000000000 T c_drop_message
0000000000000000 T c_get_target
0000000000000000 T c_init
0000000000000000 T c_poll
0000000000000000 T c_recv
0000000000000000 T c_recv_fd
0000000000000000 T c_send
0000000000000000 T c_send_fd
0000000000000000 T c_set_role
</code></pre></div></div>
<p>Symbol types are one of the two types most of the time, but more exist, of course.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="s2">"T"</span> / <span class="s2">"t"</span>: The symbol is <span class="k">in </span>the text <span class="o">(</span>code<span class="o">)</span> section.
<span class="s2">"U"</span> / <span class="s2">"u:"</span> The symbol is undefined.
</code></pre></div></div>
<p>Source: <a href="https://linux.die.net/man/1/nm">https://linux.die.net/man/1/nm</a></p>
<p><code class="highlighter-rouge">nm -C /PATH/TO/OBJECT/FILE/lib.cpp.o</code></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> U <span class="nb">sleep
</span>U __stack_chk_fail
0000000000000000 T threadOne
0000000000000000 T threadTwo
U c_set_role<span class="o">(</span>long<span class="o">)</span>
U c_get_target<span class="o">()</span>
U c_drop_message<span class="o">(</span>Message<span class="k">*</span><span class="o">)</span>
U c_init<span class="o">(</span>long<span class="o">)</span>
U c_recv<span class="o">()</span>
U c_send<span class="o">(</span>long, char const<span class="k">*</span>, char const<span class="k">*</span><span class="o">)</span>
</code></pre></div></div>
<h1 id="library-infornation-dump-general">Library Infornation dump (General):</h1>
<h2 id="static-library-file-contents">Static library file contents</h2>
<p><code class="highlighter-rouge">ar -t lib.a</code></p>
<h2 id="library-symbol-listing-1">Library Symbol listing</h2>
<p><code class="highlighter-rouge">nm lib.a</code></p>
<h2 id="symbol-listing-w-c-name-mangling">Symbol listing w/ C++ name mangling</h2>
<p><code class="highlighter-rouge">nm -C lib.a</code></p>
<h2 id="elf-architecture-dump-and-more">ELF architecture dump and more</h2>
<p><code class="highlighter-rouge">objdump -f lib.a</code></p>
<h2 id="shared-library-dependencies">Shared library dependencies</h2>
<p><code class="highlighter-rouge">ldd -r -v libnanomsg.so</code>
<code class="highlighter-rouge">readelf -d libnanomsg.so | grep NEEDED</code></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>readelf <span class="nt">-d</span> lib.so | <span class="nb">grep </span>NEEDED
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libnanomsg.so.5]
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libdl.so]
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>librt.so.1]
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libpthread.so.0]
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libgcc_s.so.1]
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libc.so]
</code></pre></div></div>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>readelf <span class="nt">-d</span> libnanomsg.so | <span class="nb">grep </span>NEEDED
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libdl.so]
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libc.so]
</code></pre></div></div>
<h3 id="dynamic-listing-of-processexecutable-dependencies--loaded-shared-libraries">Dynamic listing of process/executable dependencies / loaded shared libraries</h3>
<ul>
<li><code class="highlighter-rouge">sudo awk '/\.so/{print $6}' /proc/<PID>/maps | sort -u</code></li>
<li><code class="highlighter-rouge">strace -e trace=open <BINARY-EXECUTABLE></code></li>
<li><code class="highlighter-rouge">lsof -p <PID> | grep mem</code></li>
</ul>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code> 0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libdl.so]
0x0000000000000001 <span class="o">(</span>NEEDED<span class="o">)</span> Shared library: <span class="o">[</span>libc.so]
0x000000000000000e <span class="o">(</span>SONAME<span class="o">)</span> Library soname: <span class="o">[</span>libnanomsg.so.5]
</code></pre></div></div>S.WeisgerberLibrary symbol listing