`su world`2015-06-02T12:30:10+00:00http://vikassy.github.ioVikas S Yaligarvikasyaligar.it@gmail.comAutomatic cross language screenshots2015-06-01T00:00:00+00:00http://vikassy.github.io/mediawiki/2015/06/01/automatic-cross-language-screenshots
<h1 id="pre-gsoc">Pre GSOC</h1>
<p>I had applied for GSOC in 2013, but was not selected. In 2014 I decided to spend enough time preparing my proposal before official GSOC organizations were listed. I was googling around for organizations which uses ruby(my favorite programming language) and one among them was Mediawiki. Mediawiki had a neat page explaining each of their project ideas and I quickly scrolled down to the project which uses ruby.
<br /><br />
I read the idea by <a href="http://wikimediafoundation.org/wiki/User:Aaharoni-WMF">Amir E Aharoni</a>, twice/thrice and I mailed him for more information. It took me some time to figure out the problem statement. He introduced me to <a href="http://wikimediafoundation.org/wiki/User:ZFilipin_(WMF)">Zeljko</a>(God of Selemiun in Wikimedia), who helped me get my first patch merged. We also had <a href="http://www.mediawiki.org/wiki/Pair_programming_for_fun_and_profit">pair programming</a> where I learnt how to use jenkins and cloudbees. I also came up with a small proof of concept for the idea, by hardcoding it to specific scenario.</p>
<h3 id="problem-statement">Problem Statement</h3>
<p>MediaWiki is a large and complex piece of software, and the user guide for core and those for extensions (like VisualEditor) each have a large number of images illustrating functions and stages of operation. However, these often date quickly as the software changes, and are generally only available in English or at best a few languages, which means that non-English users are not as well served.</p>
<p><br /></p>
<figure>
<img src="/assets/images/before_deploy.jpg" alt="Image of VisualEditor Before Language Screenshots" style="width: 700px;" />
<figcaption style="text-align: center;">Part of VisualEditor user guide(in Hebrew language) before Language Screenshot deployment</figcaption>
</figure>
<p><br /></p>
<h3 id="mediawiki-selenium">Mediawiki Selenium</h3>
<p><a href="https://github.com/wikimedia/mediawiki-selenium.git">Mediawiki Selenium</a> is a ruby gem used for browser testing for various projects in Mediawiki including VisualEditor. One of the features of gem was capturing to take screenshot of browser, whenever a particular scenario/browser test fails. This feature lead to the idea of cross site language screenshot.</p>
<h1 id="gsoc-period">GSOC Period</h1>
<p>I and Amir decided to meet(Skype or Hangout) twice every week around 06:00 pm IST. I started out by writing some browser tests for VisualEditor. <a href="http://www.mediawiki.org/wiki/User:Cmcmahon">Chris McMahon</a> helped me in understanding page object model. Then I continued with my proof of concept by making it more generalized, so that all the scenario can be covered. This lead to my first and most important <a href="https://gerrit.wikimedia.org/r/#/c/135616/">patch</a> of the project. <a href="https://en.wikipedia.org/wiki/User:NEverett_(WMF)">Nik Everett</a> reviewing my patch and helped me making it more efficient and rubyist.</p>
<h3 id="cropping">Cropping</h3>
<p>One of the problems which I faced during the project was of cropping various elements(it can be a simple div/span) of a HTML page. Many scenarios had multiple elements(a div/span any html tag) to be cropped. We solved this by using <a href="http://en.wikipedia.org/wiki/Minimum_bounding_rectangle">minimum bounding rectangle(MBR)</a>. </p>
<figure>
<img src="/assets/images/cropping_algo.png" alt="Image of VisualEditor Before Language Screenshots" style="width: 700px;" />
<figcaption style="text-align: center;">Using MBR to get the required image for UserGuide</figcaption>
</figure>
<p><br /></p>
<h3 id="tdd">TDD</h3>
<p>Zeljko started to review my code and first thing we did was to separate the language screenshot scenarios from normal VisualEditor browser tests to avoid confusions. This was the time I realized that my code was not only taking screenshots, but also was testing various VisualEditor features.</p>
<p>One of the most amazing part of the GSOC was me failing to explain Zeljko on how my code works. All I could understand from this was my code was not good enough. Zeljko helped me to solve this by using TDD i.e. test driven development. We decided to use <a href="https://github.com/rspec/rspec">Rspec</a> and started pair programming. We assumed our own rectangle co-ordinates and wrote many unit tests to check if minimum bounding rectangle was working correctly.</p>
<p>When everything was green in specs, we started out by writting our browser tests to check if screenshots are getting cropped as expected. It not just ran on English, but also in different language like hebrew, german and many more. We all were excited to see everything working. </p>
<h3 id="birth-of-languagescreenshotbothttpscommonswikimediaorgwikiuserlanguagescreenshotbot">Birth of <a href="https://commons.wikimedia.org/wiki/User:LanguageScreenshotBot">LanguageScreenshotBot</a></h3>
<p>Now we had screenshots for multiple languages, but we needed to upload all of them to <a href="https://commons.wikimedia.org/wiki/Main_Page">Wikimedia Commons</a>. We can upload the images manually, but we need a way to do it via some API, so that we can automate the whole process end-to-end. We decided to use MediaWiki web service API, but I was not able to upload my image via Postman REST client and was not sure what was going wrong. Amir Aharoni pointed me to <a href="http://www.mediawiki.org/wiki/Extension:ApiSandbox">ApiSandbox</a>, which can be used <a href="http://www.mediawiki.org/wiki/Special:ApiSandbox">easily</a>. I was not able to upload the images via ApiSandbox, as it does not support uploading of file from system, but it gave me good enoguh idea on how I can make it run on Postman client. Then we jumped to <a href="https://github.com/wikimedia/mediawiki-ruby-api">Mediawiki Ruby API</a> and <a href="https://gerrit.wikimedia.org/r/#/c/137451/">implemented</a> upload method.</p>
<p>Now we needed a bot which can be triggered by a jenkins job to upload the screenshots of VisualEditor userguide. Hence we requested for <a href="https://commons.wikimedia.org/wiki/Commons:Bots/Requests/LanguageScreenshotBot">bot permission</a>. Thanks to <a href="https://commons.wikimedia.org/wiki/User:Whatamidoing_(WMF)">Whatamidoing</a> for helping me out with the exact numbers of images to be uploaded. Thanks to <a href="https://commons.wikimedia.org/wiki/User:EugeneZelenko">Eugene Zelenko</a> for approving our bot.</p>
<h3 id="jenkins-job">Jenkins Job</h3>
<p>Everything was almost done, except we wanted a new jenkins job where we can run our browser tests for any number of specific languages and deploy it to commons using LanguageScreenshotBot. For this we used (parameterized build plugin)[https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build] which allows you to enter parameter before you build the job. Thanks to <a href="https://www.mediawiki.org/wiki/User:Hashar">Antnoie Musso</a> for helping us setup this jenkins job. Thanks to <a href="http://wikimediafoundation.org/wiki/User:KMistry_(WMF)">Kartik Mistry</a>, who helped us in solving tofu related problems, due to missing fonts.</p>
<h3 id="conclusion">Conclusion</h3>
<p>Hence we successfully converted screenshots of VisualEditor userguide to around 40 languages. Even though there is any change in UI of VisualEditor, one can update the userguide just by clicking the build command in Jenkins job.</p>
<figure>
<img src="/assets/images/after_deploy.png" alt="Image of VisualEditor Before Language Screenshots" style="width: 700px;" />
<figcaption style="text-align: center;">Part of VisualEditor user guide(in Hebrew language) after Language Screenshot deployment</figcaption>
</figure>
<p><br /><br />
Go checkout the <a href="http://www.mediawiki.org/wiki/Help:VisualEditor/User_guide">VisualEditor userguide</a>. Thanks to <a href="http://wikimediafoundation.org/wiki/User:Mdennis">Maggie Dennis</a>, <a href="http://wikimediafoundation.org/wiki/User:Guillom">Guillaume Paumier</a> and <a href="http://wikimediafoundation.org/wiki/User:Jdforrester_(WMF)">James Forrester</a> for helping me out in screenshots. I had a great fun learning lots of things and talking to awesome people.</p>
<h1 id="post-gsoc">Post GSOC</h1>
<p>We(mainly Amire and Zeljko) created gems out of above project called <a href="https://github.com/amire80/screenshot">screenshot</a> and <a href="https://github.com/amire80/commons_upload">commons_upload</a> which helps us to create screenshot for different projects. Also I plan to build another tool above this where one can take screenshot without any effort to code. Checkout a small <a href="https://www.youtube.com/watch?v=w7RlwhKwq6w">demo of it</a>. You can also catch us in <a href="https://wikimania2015.wikimedia.org/wiki/Main_Page">Wikimania 2015</a> where we will be <a href="https://wikimania2015.wikimedia.org/wiki/Submissions/Making_Translated_Screenshots_With_No_Effort">presenting</a> this project.</p>
My experience in NITK RUG 20132013-12-08T00:00:00+00:00http://vikassy.github.io/experience/2013/12/08/my-experience-in-nitk-rug
<h3 id="what-is-nitk-rug">What is NITK RUG?</h3>
<p>NITK RUG is an unofficial group formed by ruby users in NITK. Currently we are 8 students who are part of various activities. For more information you can visit our <a href="http://nitkrug.herokuapp.com/">site</a>. </p>
<h3 id="activities">Activities</h3>
<p>During the odd semester(July-November) of 2013, we were part of many activities. Some of them are listed below:</p>
<ul>
<li><b>NITK RUG Website</b> <br />
Thanks to Sriram and SKarthik for making an awesome <a href="http://nitkrug.herokuapp.com/">site</a> in 2 days. We were able to deploy it in heroku also. Aim of the site was to provide a brief idea of what the group does.
</li><br />
<li><b>Dota2Alchemy</b><br />
Dota, one of the famous multiplayer strategy game. Many students in our college play Dota and take part in many online competitions. One among them is Sushant, who decided to make a new website <a href="http://www.dota2alchemy.com/">www.dota2alchemy.com</a> so that people can auction unique Dota2 items. Sushant, SKarthik and Sriram made this site, which had about 15,000 unique visitors till now.
</li><br />
<li><b>Pacman game</b><br />
As a part of NITK IEEE fest for first years, we worked on making a game(Pacman). To make it more fun we decided to make it realtime and multiplayer so that one team can compete with each other and the maximum the time spent by pacman wins.
<img src="/assets/images/pacman.jpg" alt="Pacman" style="width: 700px;margin-left: 0px" />
Some of the things we learnt while making this game are:
<ul>
<li style="margin-left:15px;"><b>Move.js and Backbone</b></li>
In front end we learnt to use move.js which we used to move the pacman in a map. Move.js is very easy to use and animation it provides is beautiful. Backbone is amazing, we just created a model called pacost [combination of Pacman and Ghost] and made its instances for pacmans and ghosts. When the user does keypress, javascript triggers a function of that ghost to change the direction and sends it to server about change in the direction.
<li style="margin-left:15px;"><b>Websockets</b></li>
For making it real time we used websockets. We used the em-websocket gem in the backend. The function of backend was simple, i.e. to send messages to all the clients about changes in direction of a particular pacman/ghost.
<li style="margin-left:15px;"><b>Don't mess with real time systems</b></li>
It is something I realized while testing the game. Initially we tested it with 3 player everything was working fine. But on the day of competition, we had a huge delay when we had 6 players. There was no satisfactory reason behind it and I was tensed about the event. Finally we changed some rules to make it just 1 pacman and 2 ghosts[that is the beauty of creating your own game], which had least delay.
<li style="margin-left:15px;"><b>Mistakes</b></li>
As this was the first time we were experimenting on realtime game, we made many mistakes. The biggest one was the delay, which made me conclude that I should never mess with realtime systems. But later we realized that the approach was not good, i.e to send the change in direction to the server because there was an assumption that all the pacman and ghost in each client are in same position. We could have solved it by sending the position and change in direction at the time of keypress by the user.
<li style="margin-left:15px;"><b>People</b></li>
Thanks to all the NITK IEEE executive members who helped us to manage the game.Special thanks to Thejdeep,Sushant,SKarthik,Sriram who are the people behind the making of game.
</ul>
</li>
<li><b>Airplanes Game</b><br />
Every odd semester we have a technical fest in NITK called Engineer. Many of us were in Comps committee. Inspired by WebGl used in our Engineer website, we decided to make another realtime multiplayer game based on WebGL. Finally we created a Aeroplane based game, where participants have to write an automated script to attack planes of opponents. This time the game was run in the Backend, except the shooting part. This time we used Babylon.js with em-websockets to make a 3D game. Babylon.js is awesome WebGL library, which is very easy to work out. This time we made equivalent backend i.e airplanes with positions. This time every millisecond the client sends the position to server and server sends it to everyone. This avoided the latency. Each success shoot was stored in a log file.After 20 mins we got a log file of 4GB, which we had to parse inorder to get the result.</li>
<li><b>Rails Rumble</b><br />
We participated in Rails Rumble.Our idea was to make a website in which one can use the normal web tools to create a dynamic website and we would give him source of Rails when he is done with website. We were not able to complete it in right time, but we have resumed the work and planned to finish the beta version of by this December.</li>
<li><b>NITK IEEE project</b><br />
As a part of NITK IEEE executive members, we can make projects. One of our project is to teach programming to students of schools and colleges in a software engineering way, i.e by creating a team and making a usable deployable product. First part of this is to teach students git. We are almost done with git part and final touch has to be given which we will be doing during this december.</li>
</ul>
<p>### Future plan</p>
<p>We plan to finish all the pending projects next semester of our college.We are also planing to expand the group by holding various workshops in college.
<!--break--></p>
My Experience in Ruby Conference India 20132013-06-27T00:00:00+00:00http://vikassy.github.io/conference/2013/06/27/my-experience-in-ruby-conference-india-2013
<style type="text/css">
ul.tabs
{
padding: 6px 0;
font-size: 0;
margin:0;
list-style-type: none;
text-align: center; /*set to left, center, or right to align the tabs as desired*/
}
ul.tabs li
{
display: inline;
margin: 0;
margin-right:2px; /*distance between tabs*/
}
ul.tabs li a
{
font: normal 12px Verdana;
text-decoration: none;
position: relative;
z-index: 1;
padding: 6px 16px;
border: 1px solid #CCC;
border-bottom-color:#AAA;
color: #000;
background: #F0F0F0 url(tabbg.gif) repeat-x 0 0;
border-radius: 2px 2px 0 0;
outline:none;
}
ul.tabs li a:visited
{
color: #000;
}
ul.tabs li a:hover
{
border: 1px solid #AAA;
background:#F0F0F0 url(tabbg.gif) 0 -36px repeat-x;
}
ul.tabs li.selected a
{
/*selected tab style */
padding: 9px 16px 6px;
position: relative;
top: 0px;
font-weight:bold;
background: white url(tabbg.gif) 0 -72px repeat-x;
border: 1px solid #AAA;
border-bottom-color: white;
}
ul.tabs li.selected a:hover
{
/*selected tab style */
text-decoration: none;
}
div.tabcontent
{
display: block;
}
div.tabcontents
{
border: 1px solid #AAA; padding: 30px;
background-color:#FFF;
border-radius: 2px;
}
</style>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var tabs=function(){var b=function(c,a){var b=new RegExp("(^| )"+a+"( |$)");return b.test(c.className)?true:false},j=function(a,c){if(!b(a,c))if(a.className=="")a.className=c;else a.className+=" "+c},h=function(a,b){var c=new RegExp("(^| )"+b+"( |$)");a.className=a.className.replace(c,"$1");a.className=a.className.replace(/ $/,"")},g=function(c,b){var a=document.getElementsByTagName("html");if(a)a[0].scrollTop+=b},e=function(){var b=window.location.pathname;if(b.indexOf("/")!=-1)b=b.split("/");var a=b[b.length-1]||"root";if(a.indexOf(".")!=-1)a=a.substring(0,a.indexOf("."));if(a>20)a=a.substring(a.length-19);return a},d=e(),c=function(a){this.a=0;this.b=[];this.c=[];this.d=[];this.e=0;this.f(a)};c.prototype={g:function(b){var c=new RegExp(d+b+"=(\\d+)"),a=document.cookie.match(c);return a?a[1]:this.h()},h:function(){for(var a=0,c=this.d.length;a<c;a++)if(b(this.d[a],"selected"))return a;return 0},j:function(d,c){for(var b=d.getAttribute("rel"),a=0;a<this.b.length;a++)if(this.b[a].getAttribute("rel")==b){j(this.b[a].parentNode,"selected");c&&this.e&&this.k(this.a,a)}else h(this.b[a].parentNode,"selected");this.l(b)},k:function(a,b){document.cookie=d+a+"="+b+"; path=/"},l:function(b){for(var a=0;a<this.c.length;a++)this.c[a].style.display=this.c[a].id==b?"block":"none"},m:function(a){if(a.id)for(var b=0;b<this.b.length;b++)if(this.b[b].getAttribute("rel")==a.id)return this.b[b];return a.parentNode.nodeName!="BODY"?this.m(a.parentNode):null},n:function(d,c){var a=document.getElementById(d);if(a){var b=this.m(a);if(b){this.j(b,0);if(!c)setTimeout(function(){a.scrollIntoView();g(a,-120)},0);else setTimeout(function(){window.scrollTo(0,0)},0);return 1}else return 0}},f:function(a){this.a=a.i;this.b=a.getElementsByTagName("a");this.d=a.getElementsByTagName("li");for(var b=0;b<this.b.length;b++)if(this.b[b].getAttribute("rel")){this.c.push(document.getElementById(this.b[b].getAttribute("rel")));var f=this;this.b[b].onclick=function(){f.j(this,1);return false}}var e=a.getAttribute("persist")||"";this.e=e.toLowerCase()=="true"?1:0;var d=window.location.hash;if(d&&d.length>1)if(this.n(d.substring(1),window.location.search.indexOf("noscroll=true")>-1))return;var c=this.e?parseInt(this.g(a.i)):this.h();if(c>=this.b.length)c=0;this.j(this.b[c],0)}};var a=[],i=function(d){var b=false;function a(){if(b)return;b=true;setTimeout(d,4)}if(document.addEventListener)document.addEventListener("DOMContentLoaded",a,false);else if(document.attachEvent){try{var e=window.frameElement!=null}catch(f){}if(document.documentElement.doScroll&&!e){function c(){if(b)return;try{document.documentElement.doScroll("left");a()}catch(d){setTimeout(c,10)}}c()}document.attachEvent("onreadystatechange",function(){document.readyState==="complete"&&a()})}if(window.addEventListener)window.addEventListener("load",a,false);else window.attachEvent&&window.attachEvent("onload",a)},f=function(){for(var e=document.getElementsByTagName("ul"),d=0,f=e.length;d<f;d++)if(b(e[d],"tabs")){e[d].i=a.length;a.push(new c(e[d]))}};i(f);return{open:function(c,d){for(var b=0;b<a.length;b++)a[b].n(c,d)}}}()
//--><!]]>
</script>
<ul class="tabs" persist="true">
<li class="selected"><a href="#" rel="view1">Day1</a></li>
<li class=""><a href="#" rel="view2" id="link2">Day2</a></li>
</ul>
<div class="tabcontents">
<div style="display: block;" id="view1" class="tabcontent">
<h3>Journey towards the conference</h3>
I live in NITK Surathkal(which is 367 kms from Bangalore) during college days and in Bangalore during holidays.I started using ruby in first year of my college and discovered about BRUG(Bangalore Ruby User Group). I attended various talks and met lots of rubyist. There I met <a href="https://twitter.com/_prakash">Prakash Murthy</a> in May 2013. He told me about RubyConf India, where he was giving a talk on "Taking Ruby Community in India to a new level". Later I was selected for student scholarship program, with <a href="https://twitter.com/_prakash">Prakash</a> as my developer sherpa.
Here is my experince in RubyConf India 2013.<br /><br />
<h3>Opening Keynote by Jim Weirich</h3>
I sat in first row with <a href="https://twitter.com/_prakash">Prakash</a> and he introduced me to Jim. It was amazing experince to meet the man behind <a href="https://rubykoans.com">rubykoans</a>, which introduced me to test driven development. He told me that today we were gonna write some more test. In his talk I came to know about KataRomanCalculator. He started to write simple tests to check if RomanNumeralConverter could converts 1 to I. Then he passed it by returning "I". He similarly passed other test with n*"I"(where n is the given number). He then started to cover the case of 5 and it's multiple with simple if condition. He then continued this step covering all cases. I had never seen such a kind of development by writing tests. His work can be found in his <a href="https://github.com/jimweirich/presentation_kata_and_analysis">github</a>. <br /><br />
<h3>Effective debugging by Jonathan Wallace</h3>
I learnt basic debugging last semister in my college and was interested in this talk. He taught us debugging via a scenario using various debuggers. After his talk I asked him a doubt which I had in my mind for couple of months, i.e could I use these to debug large code repository like rails, as I wanted to understand rails internals. He told that it was possible. Later he suggested me to look at the various blogs and materials which would help me understand rails internals.<br /><br />
<!-- SPLIT -->
<img src="/assets/images/jonathan.jpg" />
Thank you Prakash for the pic.
<br /><br />
<h3>Graph database and Pelting rubies</h3>
After a stomach full, I came across new database which I had never heard of, i.e Graph Database. Nikhil also mentioned that graph design or structure, played an important role. I will soon be trying out <a href="http://www.neo4j.org/">neo4j</a> for one of my summer project. <br /><br />
Again that evening I saw another surprising framework called metasploit. After being pariticipated in INCTF(See my last blog <a href="/automation/2013/06/06/how-we-automated-a-task-in-inctf/">post</a>), metaspoilt would help me in software testing and also other competitions. Ausmarton Fernandes exploited rails 2 server to get a command line. Everyone was shocked seeing such vulnerablitiy. I will try to write another blog post on this framework <br /> <br />
<h3>Evening talks</h3>
I always thought github is a perfect web application, but it turned out that I was wrong. Siddhant showed us how difficult it was to navigate for them. Next time whenever I make any web application, I will take care that it will be easy for blind people also to navigate.
<br /><br />
Steve Klabnik, gave talk on Functional Reactive Programming. It was very new to me, but I learnt about streaming by using <a href="https://github.com/steveklabnik/frappuccino">frappuccino</a> gem
<br /><br />
After such an amazing experience on the first day, I was looking forward for the next.
<a href="#" onclick="document.getElementById('link2').click()">Click here for day 2</a>
</div>
<div style="display: none;" id="view2" class="tabcontent">
<h3>Ruby 5k</h3>
I usually getup at 10 or 11 am, but this day it was 6!!! I thought 5km should be fun and easy, but it turned out to be a long one. I ran 2.5 km(or maybe less than that) and remaining was just a walk. <br /><br />
<img src="/assets/images/5k.jpg" width="100%" />
<h3>Aaron Patterson and Ruby, Rock N Roll </h3>
Today I realized that sitting in a conference is way more fun than watching it's video. Aaron patterson's talk was inspirational. I was happy to hear that he seriously started with ruby after using mechanize, which is similar in my case. I also got your Ruby sticker !! Thank you
<br /><br />
Sau Sheong Chang with his gem muse, created song with our tweets. He gave us an idea of music notes and beats which was tough to grasp for me. But it was fun and a great learning experience.
<br /><br />
<h3>Dissecting Ruby with Ruby</h3>
I have been using heroku for 1 year and was pleased to see Richard Schneeman, who is working in heroku. Jonnathan had told to attend this as I would learn to debug programs using any debugger. Yes, it was done using ruby itself. I have started to use <a href="http://www.codetriage.com/">codetriage</a> and working hard to make some contributions in opensource. I bugged him a lot with all my doubt which I had on heroku, and got to know a lot of this in ruby. <br /><br />
<h3>Inside Git and Ruby in style</h3>
Once I had given a <a href="Slideshare.net/VikasYaligar/git-presentation-15778897">talk</a> on git, but always wondered how it works. Shadab's gem <a href="https://github.com/shadabahmed/git_guts">git_guts</a> is a unique way of learning git internals. Using git on .git is a clever idea and the best way to understang git. I will soon write a blog post on git internals.
<br /><br />
Bhavin's talk on writing ruby in style, showed how important it was to write good. I learnt how to write beautiful code. <br /><br />
<h3>Evening talks!!</h3>
That evening Prakash took the Indian Ruby Community to whole new world. I sadly attended only half of his talk, as I was bugging Richard. But that half part was the ultimatum. I was luck to have him as developer sherpa in RubyConf India. I have decided to make one ruby group in NITK.
<br /><br />
Nick Sutterer also known as apotonick, talked on OOP techniques in Rails. He showed us many gems which can been used to make our life easier in rails. I got to know about many gems like apotomo and cells.
<br /><br />
Andy Lindeman showed us that there were many open issues in github and we had to contribute to the opensource. Again this motivated me to do something for the opensource community.
<br /><br />
<h3>Conclusion</h3>
This was my first conference and I learnt a lot. I would like to thank everyone in RubyConf India, for the brilliant event. I discovered how huge and helpfull the ruby community is. Thank you Prakash for guiding me. I had a great experience and looking forward for next RubyConf.
</div>
</div>
How we automated a task in InCTF2013-06-06T00:00:00+00:00http://vikassy.github.io/automation/2013/06/06/how-we-automated-a-task-in-inctf
<h3 id="what-is-inctf">What is InCTF?</h3>
<p>InCTF stands for Indian Capture the Flag, it’s an naional level capture the flag contest in India conducted by Amritapuri, Kollam.
InCTF 2013 had 3 rounds, first round was learning round which taught us GRUB based hacking into linux and many more. Second round was toughest of all rounds and was amazing, here there was binary exploit, forensics, reverse engineering and web based exploits.
Final round was CTF game which goes for around 6 hours.</p>
<h3 id="final-round">Final round</h3>
<p>In final round every team was given a Ubuntu server which can be run through virtual box. Each team had to hack root password of the server and start all the services(which was listed).
In InCTF 2013, there were 3 services i.e</p>
<ul>
<li><b>Python server:</b> <br />
This was a simple command line based server which allows one to create files and read files using commands like get and put. <br />
Syntax: <br />
<code>
put file_name one_word_content</code> <br />
<code>
get filename
</code></li>
<li><b>PHP based Apache server:</b> <br />
This was a web server where one can signup and create his own private posts.
</li>
<li><b>C based Socket I/O server:</b> <br />
This was again another command line based server where a user can signup and login to create a post. It had features like view users,posts.
</li>
</ul>
<!--break-->
<p>### The problem</p>
<p>Our automation was on python based service, which allowed basic functionality of put and get on files. When we checked it’s source in our server, we found out that all files related operations(create and read) were restricted to folder ‘files/’.
We also found that ‘files’ folder had flags in 16 bits hash named files. If we could find the names of the files then flags could have been easily retrived from get command.</p>
<p>
Not only that, it had a cpp file called worker which used to perform the actual task of read and write. The python script was only a medium for taking input from the user and check if it starts with get or put. If this is satisfied, then it would run the cpp executable with given input as command line arguments.
</p>
<p>Also every 10 mins, old flag and files are changed by the game server.
### Our team’s hack!</p>
<p>In final round of InCTF, I was a part of team ByteLandians with Dhruv, Abhay and Suresh.
<img src="/assets/images/bytelandians.jpg" alt="Drawing" style="width: 700px;margin-left: 0px" />
We went through the source again, and found out that the worker program was checking for number of arguments based on command, where as python script was not doing that. This lead to a simple idea of running:
<code> put file1 data;ls </code>
Hurray it worked!! because, python would finally run the following command<code>./worker put file1 data;ls</code>. This means ‘put’ ‘file1’ and ‘data’ were arguments to ./worker, but ls was executed in command line.
The vulnerabilty was intense, as it allowed one to execute shell command. Hence we started to collect the flags by running <code>puts file1 data;cat files/*</code>
As there were 13 teams and every 10 mins new flags were added, writing script was a must.
<!--break-->
## The script</p>
<p>As we had to telnet the server, the pipeline based input through shell would not work. After searching we found out that we could use expect.
We installed expect using:</p>
<pre>
<code>
sudo apt-get install expect</code></pre>
<p>Then we wrote the following shell script(automate.sh):</p>
<pre><code>#!/usr/bin/expect
spawn telnet 10.1.104.1 9090
expect -re "> ?$"
send "put file1 data;cat files/*"
expect eof
</code></pre>
<p>Then we generalized it by changing spawn command to <code>spawn telnet $1 9090</code> and passed the ip address using the following python script(automate.py):</p>
<pre><code>import os
ip = ["10.1.104.1","10.1.110.1"] #around 13 ip's in real game
os.system("./automate.sh "+ip)
</code></pre>
<p>Then all we had to do was <code>python automate.py > flag_file</code>. Then we could submit the data inside the file every 10 mins.</p>
<h3 id="result">Result</h3>
<p>This automation lead to collection of around 150 flags in 5 minutes. We were not able to collect much flag, as we ran our script very late. Also thanks to Dhruv, who was able to automate the web based service. With this we ended up being 3rd in the competition.</p>
Welcome to my blog on programming!2013-05-13T00:00:00+00:00http://vikassy.github.io/introduction/2013/05/13/hello
<p>
Hello I am Vikas S Yaligar, a BTech(Information Technology) student of NITK Surathkal. I will be writing various articles on hack, ruby, mobile apps, web and many more.
</p>
<!--break-->