<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sushant Dinesh</title>
    <description>Just random things!</description>
    <link>https://sushant94.me/</link>
    <atom:link href="https://sushant94.me/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Radeco update</title>
        <description>&lt;p&gt;This post is to outline the
&lt;a href=&quot;https://www.google-melange.com/gsoc/project/details/google/gsoc2015/sushant94/5733935958982656&quot;&gt;work&lt;/a&gt;
completed during the Google Summer of Code 2015 (GSoC) period and show you a
glimpse of radeco and where we are heading with it.&lt;/p&gt;

&lt;p&gt;For those who are not aware, radeco is a decompiler framework that is developed
and maintained by the radare team. The entire framework is open source,
flexible and reusable. The base of radeco is radeco-lib that implements the
analysis and transformations that are needed for decompiler. radeco uses 
radeco-lib to perform decompiler. You can checkout these
repositories &lt;a href=&quot;https://github.com/radare/radeco&quot;&gt;here&lt;/a&gt; and
&lt;a href=&quot;https://github.com/radare/radeco-lib&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;features&quot;&gt;Features&lt;/h2&gt;
&lt;p&gt;This section gives a brief overview of the internal working of radeco as of
today. These may change over time as more features and analysis are added.
Nonetheless this does form the basic foundations on which radeco is built.&lt;/p&gt;

&lt;p&gt;Radare2 uses an internal IR, ESIL (Evaluable Strings Intermediate Language)
for its emulation and analysis needs. Since radeco is built on top of radare2
it parses ESIL to an internal representation. The first step of building
the decompiler framework is to develop a good intermediate language.
During the start of GSoC period we investigated several intermediate
languages(IL) like REIL, RREIL, Vine IL and BAP IL. We tried to incorporate
the best features from all these ILs while trying to keep the language as
simple as possible. The main reason ESIL is converted into another IL is that
ESIL is not really suited for static analysis, it was built for emulation and
dynamic analysis. Since there are already a lot of architectures that are
supported by ESIL, it makes more sense to lift ESIL into our IL rather than
writing a lifter for every architecture again. Initially, ESIL from radare2 is
converted into a text based IL which is then transformed into a tree-like SSA
representation that is used for all further analysis.&lt;/p&gt;

&lt;p&gt;The second step is to transform ESIL that is emitted by radare2 into the IL.
This is done in two stages. The first step is a basic transformation that
transforms ESIL into radeco IL. This is then broken into basic blocks and a
Control Flow Graph (CFG) is constructed. The Control Flow information is then used to
transform the IL into a tree like SSA representation. This is used for further
analysis and optimizations. Radeco supports a few
analysis like constant propagation and dominator tree construction (this
feature is not exposed using the API yet). Apart from analysis radeco also
performs a basic level of dead code removal to declutter the code and remove
unnecessary operations.&lt;/p&gt;

&lt;p&gt;Currently, radeco can output it’s internal representation to &lt;a href=&quot;https://en.wikipedia.org/wiki/DOT_(graph_description_language)&quot;&gt;dot
file&lt;/a&gt; which
can be converted into png/svg using utilities like graphviz. While this may not seem
very useful, they do form the base of the entire decompiler and identifying
bugs at this stage is important. Much of the work
during the GSoC was laying the foundations and deciding an architecture that
would allow the library to be as flexible as possible. Now that we have a solid
foundation and a good architecture in place we can move at a faster pace and
implement all the analysis needed to build a decompiler.&lt;/p&gt;

&lt;h2 id=&quot;usage&quot;&gt;Usage&lt;/h2&gt;
&lt;p&gt;Radeco makes it easy for users to write their own custom analysis while
leveraging the analysis that have already been implemented in radeco. One of
the fundamental principles of radeco is allowing users to interact with the
output produced from every stage of radeco’s analysis, make corrections or
changes where necessary and then continue with the analysis. To make this
happen radeco-lib introduces &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pipeline&lt;/code&gt;. This allows users to decide which
stages of the analysis is to be run, the order in which they are to be run and
allow them to tap into the output that is generated after every stage. For
more information about the usage please refer to the radeco’s
&lt;a href=&quot;https://github.com/radare/radeco/blob/master/README.md&quot;&gt;README&lt;/a&gt; which
explains this in detail. A pre-built version of radeco is to be released soon,
but for now you will need a &lt;a href=&quot;https://www.rust-lang.org/&quot;&gt;rust&lt;/a&gt; compiler
(prefereably nightly) in order to compile and try out radeco.&lt;/p&gt;

&lt;p&gt;And oh! We also have (some) documentation for
&lt;a href=&quot;http://radare.github.io/radeco/radeco/index.html&quot;&gt;radeco&lt;/a&gt; and
&lt;a href=&quot;http://radare.github.io/radeco-lib/radeco_lib/index.html&quot;&gt;radeco-lib&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;challenges&quot;&gt;Challenges&lt;/h2&gt;
&lt;p&gt;One of the main challenges we faced during the project phase was developing
the internal representation for storing the SSA form. ESIL has features that
are not present in other intermediate languages that make this process
slightly tricky (this is also why ESIL is suited for emulation unlike other
languages). ESIL has a concept of internal variables. These are basically
variables that the ESIL VM maintains and hold a special meaning to the VM. All
internal variables in ESIL are prefixed by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$&lt;/code&gt;. The main use case for these
variables are for computation of processor flags. To be able to compute the
flags on-the-fly when needed the ESIL VM also holds three other values:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The value after the last operation that modifies or sets a flag (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cur&lt;/code&gt;),&lt;/li&gt;
  &lt;li&gt;The value before the last instruction that modified the flag (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;old&lt;/code&gt;) and&lt;/li&gt;
  &lt;li&gt;The size of the last operand(s) (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lastsz&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, let us consider the x86 zero flag. In ESIL, this is represented
by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$z&lt;/code&gt;. The VM on encountering a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$z&lt;/code&gt; during its execution will perform the
actual computations needed to decide the value of the flag, which in this case
is checking if &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cur == 0&lt;/code&gt;. This means that the parser for radeco
must also keep track of these values (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cur&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;old&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lastsz&lt;/code&gt;) and substitute
the correct set of operations for each flag when it encounters an internal
variable.&lt;/p&gt;

&lt;p&gt;The other challenge that we faced was an architectural one. One of the
principles that we kept in mind while developing radeco is reusability. We
wanted all the analysis implemented in radeco to be reusable. This allows
users to implement their own data structures for storage while still being
able to use the analysis that radeco provides. To be able to achieve this we
leverage the power of &lt;a href=&quot;https://doc.rust-lang.org/book/traits.html&quot;&gt;rust
traits&lt;/a&gt;. Almost everything inside
radeco is implemented in terms of traits to allow multiple implementations and
reusability. Currently it is mandatory to use the radeco IL instruction set
(while having the freedom to store the data in any manner) to be able to use
the analysis that radeco provides. In the future, we aim to make this generic
too, allowing users to use their own ILs and instruction sets. The main
tradeoff for us during the summer was flexibility vs. time. The more flexible
we needed the framework to be, the more time we needed to implement features
in a way that would allow for this. Hence we decided to restrict ourselves and
expand to support custom ILs later.&lt;/p&gt;

&lt;h2 id=&quot;future-steps&quot;&gt;Future steps&lt;/h2&gt;
&lt;p&gt;Radeco is under heavy development and has a long way to go before being a full
decompiler framework. Here is a quick and incomplete list of what to expect
from radeco in the near future:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Type Inference&lt;/li&gt;
  &lt;li&gt;Type Propagation&lt;/li&gt;
  &lt;li&gt;More analysis&lt;/li&gt;
  &lt;li&gt;A full C-Writer module to output readable, C-like pseudo code&lt;/li&gt;
  &lt;li&gt;Control flow restructuring and reconstruction&lt;/li&gt;
  &lt;li&gt;Full integration with radare2&lt;/li&gt;
  &lt;li&gt;Text form for the internal IR allowing other tools to interact and use
radeco for analysis&lt;/li&gt;
  &lt;li&gt;Maybe even a GUI for radeco!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;preview&quot;&gt;Preview&lt;/h2&gt;
&lt;p&gt;Below is a small example to show constant propagation as implemented in radeco
right now.&lt;/p&gt;

&lt;p&gt;ASM of input binary:
&lt;script src=&quot;https://gist.github.com/abe570018dc429778ecb.js?file=const.asm&quot;&gt; &lt;/script&gt;&lt;/p&gt;

&lt;p&gt;It is clear from the input ASM that the jump is always executed and the
instruction right after the jump is never executed. This aim is to check if
radeco can infer this using constant propagation. This ASM was hand written as
no optimizing compiler would produce this code (as they perform constant
propagation too).&lt;/p&gt;

&lt;p&gt;The binary generated is disassembled by radare2. Below is the ESIL output that
radare2 generates and provides radeco with:
&lt;script src=&quot;https://gist.github.com/abe570018dc429778ecb.js?file=esil&quot;&gt; &lt;/script&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Due to the large size of images, I’ve chosen not to embed them here.
Please feel free to checkout the links for outputs.&lt;/p&gt;

&lt;p&gt;This ESIL is parsed by radeco into an intermediate radeco IL:
&lt;a href=&quot;https://raw.githubusercontent.com/sushant94/sushant94.github.io/new_post/images/cfg_2.png&quot;&gt;Non-SSA IL&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CFG is then transformed into the SSA representation:
&lt;a href=&quot;https://raw.githubusercontent.com/sushant94/sushant94.github.io/new_post/images/ssa.png&quot;&gt;SSA&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Constant propagation is run on the SSA form. Radeco implements &lt;a href=&quot;https://en.wikipedia.org/wiki/Sparse_conditional_constant_propagation&quot;&gt;Sparse
Conditional Constant
Propagation&lt;/a&gt;
which performs constant propagation and
unreachable dead code elimination simultaneously.
&lt;a href=&quot;https://raw.githubusercontent.com/sushant94/sushant94.github.io/new_post/images/const_prop.png&quot;&gt;Here&lt;/a&gt;
is the output for reference.&lt;/p&gt;

&lt;p&gt;As you can see from the above output, the unreachable branch is eliminated and
radeco infers correctly the values of registers and flags after the function
has been run.&lt;/p&gt;

&lt;h2 id=&quot;contributing&quot;&gt;Contributing&lt;/h2&gt;
&lt;p&gt;We encourage you to give radeco a try. Contribution in the form of bug
reports, pull requests, improving documentation or even just community
suggestions are welcome. If there is any feature that you miss and you would
like to see file a report with a description of the same so that we can
address this. 
Providing a backtrace and the sample binary (where possible) would help us
track down the bug much faster. Please consider this while filing a report.&lt;/p&gt;

&lt;p&gt;If you’re interested in using radeco for your own tools and have
some questions, feel free to join #radare on Freenode. We would be more than
happy to help you out!&lt;/p&gt;
</description>
        <pubDate>Mon, 21 Sep 2015 17:31:00 +0000</pubDate>
        <link>https://sushant94.me/2015/09/21/radeco/</link>
        <guid isPermaLink="true">https://sushant94.me/2015/09/21/radeco/</guid>
      </item>
    
      <item>
        <title>GSoC 2015 Week 1-3</title>
        <description>&lt;p&gt;It’s been three weeks into GSoC and I’m having an amazing time. I am working
along side &lt;a href=&quot;https://twitter.com/dkreuter_&quot;&gt;dkreuter&lt;/a&gt; and been learning tons
from him too!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/radare/radeco&quot;&gt;Here&lt;/a&gt; is the repository where you can track
our progress and also give us suggestions :)&lt;/p&gt;

&lt;p&gt;We chose &lt;a href=&quot;http://www.rust-lang.org/&quot;&gt;Rust&lt;/a&gt; as our language for implementation.
Though at first I was a bit scared of this choice, I quickly realised how
great the language is! Rust has allowed be to far more productive, after of
course my initial battles with the borrow checker.  The zero-cost abstractions
allowed by Rust has been a great so far!&lt;/p&gt;

&lt;p&gt;This is a quick roundup of what I’ve been upto:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Firstly, I got an &lt;a href=&quot;https://github.com/radare/radare2/wiki/ESIL&quot;&gt;ESIL&lt;/a&gt; parser
up and running. We use this parser to convert to an IR which is easier to
perform static analysis on. While the ESIL is amazing for emulation
purposes, it’s not so much for static analysis as it has a very large number
of supported opcodes. The RadecoIR (name subject to change) is much more
simplified in terms of the number of opcodes. Also, ESIL is primarily just
strings (as suggested by its name “Evaluable Strings Intermediate Language”)
which could be pretty hard to work with.&lt;/li&gt;
  &lt;li&gt;The next step was to build a Control Flow Graph
(&lt;a href=&quot;https://en.wikipedia.org/wiki/Control_flow_graph&quot;&gt;CFG&lt;/a&gt;) out of the IR.
Building a control flow graph will allow us to reason about the way the
control flows in the program, and hence, helps us better understand the
different programming constructs that go into making it. To make debugging
and visualizations, I first we ahead and implemented a
&lt;a href=&quot;https://en.wikipedia.org/wiki/DOT_(graph_description_language)&quot;&gt;dot&lt;/a&gt; format
emitter (ok, I admit it, I probably did this first as I felt it was more fun
:P). Just a brief word about dot, dot is a graph description language which
can be used an input to &lt;a href=&quot;http://www.graphviz.org/&quot;&gt;graphviz&lt;/a&gt; to obtain
visual representations of a graph. The current implementation is just a
minimal dot format emitter and all the features of dot format are not fully
supported. At this point, it still cannot be used on any generic graphs. I
plan to expand this in the future to allow more features and work on generic
graphs.&lt;/li&gt;
  &lt;li&gt;The last part was making the CFG out of the emitted RadecoIR. This turned
out to be pretty simple, however, there are still a ton of improvements to
be made here :)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apart from Radeco itself, I also helped in making
&lt;a href=&quot;https://crates.io/crates/r2pipe&quot;&gt;r2pipe.rs&lt;/a&gt; which allows communication with
radare2 over pipes. In the future, r2pipe.rs will be used to connect Radeco to
radare2. R2Pipe.rs is great news if you’re a rust guy as you can now interact
with radare2 and extend it to meet your needs!&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href=&quot;http://radare.github.io/r2pipe.rs/&quot;&gt;documentation&lt;/a&gt; if you’re
interested :)&lt;/p&gt;

&lt;p&gt;This is just a glimpse of what’s in for the upcoming weeks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Integration with radare2.&lt;/li&gt;
  &lt;li&gt;Write tests and documentation for all features. The limited documentation we
currently have can be found &lt;a href=&quot;http://radare.github.io/radeco&quot;&gt;here&lt;/a&gt;. This
will be updated soon.&lt;/li&gt;
  &lt;li&gt;Convert the IR into the
&lt;a href=&quot;https://en.wikipedia.org/wiki/Static_single_assignment_form&quot;&gt;SSA&lt;/a&gt; form.&lt;/li&gt;
  &lt;li&gt;Write dataflow analysis on the SSA form and also perform optimizations like
deadcode elimination.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Constant_folding&quot;&gt;Constant folding&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Type propagation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;bonus-here-is-a-small-example-of-the-cfg-graph-that-we-currently-generate&quot;&gt;Bonus: Here is a small example of the CFG graph that we currently generate&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/sushant94/sushant94.github.io/master/images/cfg.png&quot; alt=&quot;cfg&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 15 Jun 2015 19:31:00 +0000</pubDate>
        <link>https://sushant94.me/2015/06/15/GSoC-Update/</link>
        <guid isPermaLink="true">https://sushant94.me/2015/06/15/GSoC-Update/</guid>
      </item>
    
      <item>
        <title>An Introduction to radare2</title>
        <description>&lt;p&gt;A couple of days back I conducted a session on “Introduction to radare2” over irc for a few people from my college. 
Here are the notes I made in case it might be helpful for someone else.&lt;/p&gt;

&lt;p&gt;###Introduction
&lt;a href=&quot;http://rada.re/r/&quot;&gt;radare2&lt;/a&gt; is an opensource reverse engineering framework. Other reverse engineering tools include &lt;a href=&quot;https://www.hex-rays.com/products/ida/&quot;&gt;IDA&lt;/a&gt; and &lt;a href=&quot;http://www.hopperapp.com/&quot;&gt;Hopper&lt;/a&gt;.
These are extremely expensive and r2 aims at being the ultimate reverse engineering tool in the future and replace these.&lt;/p&gt;

&lt;p&gt;Official repository of radare 2 is &lt;a href=&quot;https://github.com/radare/radare2&quot;&gt;here&lt;/a&gt;, feel free to join in and contribute if you like to :)&lt;/p&gt;

&lt;p&gt;A full(?) feature list of r2 and comparison of r2 vs Hopper vs IDA can be found &lt;a href=&quot;http://rada.re/r/cmp.html&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links to other cheatsheets and documentations (which you may like):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/pwntester/cheatsheets/blob/master/radare2.md&quot;&gt;Cheat sheet&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://maijin.gitbooks.io/radare2book/content/&quot;&gt;Official Radare2 Book&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://radare.today/using-radare2/&quot;&gt;Using radare2 for Pwning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://radare.today/&quot;&gt;radare2 blog&lt;/a&gt; has some interesting articles to pwn ctf challenges using r2.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/radare/radare2/wiki&quot;&gt;radare2 Wiki&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;#radare (official channel) on irc.freenode.net if you need any help from r2 folks anytime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;r2 has a ton of features which takes a lot of time to explore and understand. Think of r2 like vim/emacs. Unfortunately it lacks a robust GUI. Feel free to try out the web GUI or &lt;a href=&quot;https://inguma.eu/projects/bokken&quot;&gt;Bokken&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It has a steep learning curve but we need only a few commands to do basic reversing (and for ctfs) and that is all we’ll be seeing for today :)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclamer:&lt;/strong&gt; I started using radare2 recently too. These are just some of the commands that I felt were most useful and spent some time in learning. I hope it’ll be useful for you too to quickly get up and running and explore the world of r2. Think of this as a newbie’s guide for newbies!&lt;/p&gt;

&lt;p&gt;Take your time to explore r2, it’s definitely worth it.&lt;/p&gt;

&lt;h3 id=&quot;a-very-small-tutorial-for-absolute-newbies&quot;&gt;A (very) small tutorial for absolute newbies:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Most Important tip for today (and as long as you use r2!):&lt;/strong&gt; What most people don’t realise is that r2 is self-documenting. Whenever you don’t know any command, its semantics, what it does etc. use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt; Just running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?&lt;/code&gt; will give you a list of all commands.
Now look at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt;. The help menu says: &lt;em&gt;“Perform analysis of code”&lt;/em&gt;.
To get more information about commands starting from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt;, run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a?&lt;/code&gt;.
Use this to learn and discover r2. When in doubt feel free to consult wikis, guides and talk to people on #radare. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;q&lt;/code&gt; is usually used to exit menus and eventually radare2 itself.&lt;/p&gt;

&lt;p&gt;Also usually all mneumonics are dervied from their longer form.&lt;/p&gt;

&lt;p&gt;Usually this is the workflow you would follow:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Start up r2 by using: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$ r2 ./hello_world&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aa&lt;/code&gt; to “Analyze All”, or the newer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aaa&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Enter &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;V&lt;/code&gt; to enter “Visual Mode”. (&lt;strong&gt;Hint&lt;/strong&gt;: You can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?&lt;/code&gt; in Visual mode too)&lt;/li&gt;
  &lt;li&gt;To view the graph of a function hit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;V&lt;/code&gt;. If you don’t see a graph when you enter into graph mode, it usually means that you forgot to run the analysis (rarely it could be a bug in r2, in which case please do report).&lt;/li&gt;
  &lt;li&gt;Hit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p&lt;/code&gt; to show the disassembly at the current location. Hit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p&lt;/code&gt; again to go into debugger mode which shows all register states.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v&lt;/code&gt; to enter code analysis menu. This menu shows all the functions analysed. Selecting one and pressing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;g&lt;/code&gt; “seeks” to that function. So the first thing to do is seek to the main function. This will usually be shown as ‘main’ or ‘sym.main’. Normally you’ll want to begin analysing the binary from here.&lt;/li&gt;
  &lt;li&gt;In visual mode, if you want to run a r2 command, simple hit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:&lt;/code&gt;. This brings up the same shell that you would have access to outside of the visual mode. All commands that work there work here too. To close the command line, just hit enter with a blank line.&lt;/li&gt;
  &lt;li&gt;use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s &amp;lt;fn_name&amp;gt;&lt;/code&gt; (&lt;strong&gt;Example:&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s sym.main&lt;/code&gt; will take you to main directly) or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s &amp;lt;offset&amp;gt; &lt;/code&gt; to “seek” to locations. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s-&lt;/code&gt; to undo seek, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s+&lt;/code&gt; to redo seek. This allows you to traverse the binary efficiently. Tab completion is available to help you out here :)&lt;/li&gt;
  &lt;li&gt;After some analysis, you might want to rename functions, to do so use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;afn &amp;lt;new_name&amp;gt; [offset]&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;To rename &lt;strong&gt;local variables&lt;/strong&gt;, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;afvn [identifier] [new_name]&lt;/code&gt;. This is the same for &lt;strong&gt;function arguments&lt;/strong&gt;, but use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;afan&lt;/code&gt; instead.&lt;/li&gt;
  &lt;li&gt;Once you have done some analysis, you will want to save your work so that you can return to it later, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ps [name]&lt;/code&gt; to save it as a project. Please check out &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;P?&lt;/code&gt; for other project related commands. Most of them are self-explanatory.&lt;/li&gt;
  &lt;li&gt;To load a project, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Po [name]&lt;/code&gt;. Alternatively, you could also do this while starting up r2 buy using the -P option. (&lt;strong&gt;Example:&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$ r2 -P [name]&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;additional&quot;&gt;Additional:&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;To show all strings in a the data section of a binary, try: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iz&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;To show all strings in the entire binary try: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;izz&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Want to search for a string ‘Foo’ in the binary? Simple, do: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/ Foo&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;This will return something like: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt; &amp;lt;offset&amp;gt; hit0_X &quot;Foo&quot;&lt;/code&gt;. To quickly go to this location, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s hit0_X&lt;/code&gt;. Again, tab-completion is available.&lt;/li&gt;
  &lt;li&gt;To help further with traversal, r2 offers vim style marks. To place a mark at an offset, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mK&lt;/code&gt;. Jump to a mark ‘K’ by using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;K&lt;/code&gt; (exactly how it works in vim!).&lt;/li&gt;
  &lt;li&gt;Don’t like a theme? Check out default themes using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eco?&lt;/code&gt;. To select a theme run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eco [name] &lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;todo&quot;&gt;TODO&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;o&lt;/code&gt; to seek.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u/U&lt;/code&gt; to undo/redo seek.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dr&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt; in general in visual mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was just a basic introduction. radare2 offers many many more commands and is extremely powerful. Plus we’re constantly adding new commands, features and improvements, so stay tuned!&lt;/p&gt;
</description>
        <pubDate>Sun, 31 May 2015 02:04:35 +0000</pubDate>
        <link>https://sushant94.me/2015/05/31/Introduction_to_radare2/</link>
        <guid isPermaLink="true">https://sushant94.me/2015/05/31/Introduction_to_radare2/</guid>
      </item>
    
      <item>
        <title>GSoC 2015!</title>
        <description>&lt;p&gt;Late post. But I got selected for GSoC 2015 under openwall/radare! :D&lt;/p&gt;

&lt;p&gt;So for the next three months I get to contribute to &lt;a href=&quot;http://rada.re/r/&quot;&gt;radare2&lt;/a&gt; without any interruptions and also get paid!
This is awesome! I would like to thank my mentors &lt;a href=&quot;https://twitter.com/akochkov&quot;&gt;Anton Kochkov&lt;/a&gt; and &lt;a href=&quot;https://twitter.com/jeffreycrowell&quot;&gt;Jeffrey Crowell&lt;/a&gt; for giving me this opportunity. Looking forward to an codeful summer ahead!&lt;/p&gt;

&lt;p&gt;Coding period starts 25th May. So stay tuned for more awesome posts about radare2!&lt;/p&gt;
</description>
        <pubDate>Thu, 14 May 2015 14:00:35 +0000</pubDate>
        <link>https://sushant94.me/2015/05/14/GSoC-2015/</link>
        <guid isPermaLink="true">https://sushant94.me/2015/05/14/GSoC-2015/</guid>
      </item>
    
      <item>
        <title>GiTS 2015 Teaser Writeup - Lost To Time</title>
        <description>&lt;p&gt;Well this is my first blog post about a CTF, feel free to let me know what you think.&lt;/p&gt;

&lt;p&gt;Challenge:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;So I lost my computer. And also my compiler and most of the documentation. Can you help me, please? &lt;/code&gt;&lt;a href=&quot;https://2015.ghostintheshellcode.com/challenges/losttotime-fe4ed7af5cefa136e2c72f67810b72b0de269a72cc2f61ce649f6d1ce759b396&quot;&gt;file&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The challenge presented us a XZ Compressed data file. Decompress it with&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xz -dc &amp;lt; losttotime &amp;gt; lost&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The instructions in the file belong to &lt;a href=&quot;http://en.wikipedia.org/wiki/COMPASS&quot;&gt;COMPASS&lt;/a&gt; Assembly Language.
The first thing we did was to find some documentation which gives us a reference of the instruction set to understand the instructions. We also need to understand the architecture of &lt;a href=&quot;http://en.wikipedia.org/wiki/CDC_6000_series#Central_processor&quot;&gt;CDC6000&lt;/a&gt; system. Finding documentation proved tricky as COMPASS is very old and the only documentation available were pictures of actual documentations (so no search in pdfs). Links to documentations we used are at the bottom.&lt;/p&gt;

&lt;p&gt;We also observed that each VFD (lines 54 - 77) are 60 bits long each. ‘B’ means that the given numeric constant is in octal representation. We went ahead and converted each of them into their 60-bit long binary representations as we would need this in our code. &lt;a href=&quot;https://gist.github.com/sushant94/53424c7b584ef9f75490#file-data&quot;&gt;data file&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Using the documentation we decoded the given assembly as:
&lt;script src=&quot;https://gist.github.com/53424c7b584ef9f75490.js?file=LostToTime&quot;&gt; &lt;/script&gt;&lt;/p&gt;

&lt;p&gt;This is fairly easy to convert to a program. Ruby is my choice of language. Here is the program that will give us the flag:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/53424c7b584ef9f75490.js?file=LostToTimerb.rb&quot;&gt; &lt;/script&gt;

&lt;p&gt;Running the same gave us the flag:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;FLAGiCYBERCONTROLCYBERDATACYBERCORPORATIONj
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This was a great challenge and we enjoyed sifting through those ancient documentations and getting a glimpse of how computing has changed over the years. Thanks to the organizers for a great challenge!&lt;/p&gt;

&lt;p&gt;Here are links to some documentations we used:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/COMPASS/Sample_Code&quot;&gt;Compass Sample Code - Wikipedia&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cray-cyber.org/documentation/cdc6600_assembly.txt&quot;&gt;Instruction Set - Partial&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.mirrorservice.org/sites/www.bitsavers.org/pdf/cdc/cyber/lang/compass/60191900A_1968_COMPASS_Inst.pdf&quot;&gt;Instruction Set&lt;/a&gt; - This in particular proved most useful.&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Mon, 15 Dec 2014 05:11:35 +0000</pubDate>
        <link>https://sushant94.me/2014/12/15/gits_teaser_writeup/</link>
        <guid isPermaLink="true">https://sushant94.me/2014/12/15/gits_teaser_writeup/</guid>
      </item>
    
      <item>
        <title>First Post</title>
        <description>&lt;p&gt;I guess this is Introduction?&lt;/p&gt;

&lt;p&gt;You can find out more about me in the About section of this blog.&lt;/p&gt;

&lt;p&gt;I’ll mainly be blogging about security and CTF related activities. I also contribute to Mozilla, so I may also occassionally blog about my amazing experiences with that. I believe that web and opensource are the future. I like meeting and learning from other developers (I’m still a newbie though!). So feel free to get in touch with me if you have suggestions, or even for random discussions!&lt;/p&gt;

&lt;p&gt;On to the Hacks!&lt;/p&gt;
</description>
        <pubDate>Fri, 05 Dec 2014 15:32:46 +0000</pubDate>
        <link>https://sushant94.me/2014/12/05/first_post/</link>
        <guid isPermaLink="true">https://sushant94.me/2014/12/05/first_post/</guid>
      </item>
    
  </channel>
</rss>
