luni, 11 martie 2013

Contribuited to my second open source project

I was looking for an application that could migrate issues from one of my Bitbucket repositories to one of my Github repositories.
I couldn't find anything already written but I found something close Git2BitIssues by tekstop. His application basically did the opposite of what I wanted. Moved things from Git to Bit not from Bit to Git. I built on it and achieved the desired result. You can check out the code if you need something similar done.
This has been my first experience using collaborative coding on GitHub and I was amazed by how smoothly everything went. The idea behind improving on someone else's code is that you first fork what he did. Basically you get a copy of his repository on your own account. You push your changes to this account and then you ask the author if he is ok with your changes via a pull request. It is all really easy and kind of fun.
Anyway now you can move your issues from one system to another with this application if you need to.

sâmbătă, 20 octombrie 2012

My first open source project - Seringa: The SQLi Framework

I publically launched my first open source project today. It's hosted at github.
A short description copied from the Wiki:
Seringa(Romanian for seringe) is an SQL injection framework featuring high customizability and a user-friendly interface. It is completely open source. It uses the .NET 4.0 framework and Windows Presentation Foundation(WPF) for the GUI. With regard to design it utilizes the Strategy Pattern to distinguish between various SQLi strategies whilst storing other relevant data such as exploits, payloads and patterns in xml files so that the framework can be easily customized from the outside(a manifestation of the Open-Closed Principle).
Seringa allows you to:
  • scan Google search results given a search string
  • test search results for SQLi vulnerability
  • test a single url for vulnerability
  • extract a database structure(databases,tables,columns) in a tree form
  • execute given payloads and receive results(some predefined queries include current database name, current database user, current database version etc)
  • save your penetration testing process to a file(mapping file) and load it later
  • use a proxy(regular or socks) when testing

Everyone is welcomed to contribute.

Contribuited to my first open source project - jQGrid

I had some problems with a jqGrid that contained a table within it. Turned out there was a bug in jQGrid. I fixed the problem locally and I thought others might be having the same problem as well so I tried to commit my changes to the jQGrid source repository. That didn't exactly go as planned but I managed to push the code throgh eventually. Check it out.
Anyway jqGrid is great. I really recommend it.

luni, 30 ianuarie 2012

JMultiLocGMap - joomla module that I created

I created a new Joomla module.
It's purpose is to display a Google map with multiple locations on it.
Locations can be grouped into categories.
All configuration is done through an xml inside it.
The module was born out of necessity. I needed it for a website I was working on for my father.
The requirement was to have a select box and a Google map and upon changing the selected item in the selection box a new set of Google markers would appear on the map.
For example the selection box could have "schools" and "kintergardens" and when modifying the selection to "schools" the schools on the map would be displayed and when choosing "kintergardens" the kindergartens on the map would be displayed.
The xml handles all configuration for this.
This is the first version(0.0.1). The project is still in it's infancy of course.
Hope it helps someone. Everything is open-source.
The project is hosted here.

sâmbătă, 5 martie 2011

Merging 2 word 2007(open xml) documents

I had to merge 2 word documents once.
They were both in word 2007(open xml) format.
I searched online everywhere for a way to merge them.
All the links were about using the altChunk element. I have a problem with that. The entire document gets put in there and that is a lot of unneeded data(like header and footer etc.).

So I did it another way:
1. cloned the second document's body
2. cloned all it's children and added them to the first document's main part

Radix tree implementation in C#

Update: you can find the entire source code here 

This is my implementation of a radix tree data structure. This is a data structure very similar to a trie. Basically instead of having each one of your nodes hold a char you have each one of your nodes store a string or as wikipedia puts it, it is a trie where "each node with only one child is merged with its child".
As I understand it the names radix tree and crit bit tree are only applied to trees storing integers and Patricia trie is retained for more general inputs.
As usual I am outputting the code for each class.

First, the node:

Then the actual tree
And the test program:

sâmbătă, 26 februarie 2011

PHP sitemap using a tree data structure

I was once asked to create a sitemap given a specific table structure.
This was the structure(the table):

The resulting sitemap as I understood it was supposed to look something like this:

The parenthesis after the titles actually hold the value of the id of the node so they weren't in the original design but whatever.

So I implemented this in PHP using a tree data structure where each node held 3 pieces of information:
id - the current node's id as read from the database
parent_id - the current node's parent id as read from the database
title - the title

A real-world implementation would also have to include a link and print out elements but this is good enough for educational purposes.

`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`id_parent` int(11) unsigned NOT NULL,
`title` varchar(100) NOT NULL,

INSERT INTO `sitepages` (`id`, `id_parent`, `title`) VALUES
(1, 0, 'Home'),
(2, 1, 'Page 1'),
(3, 0, 'Page 2'),
(4, 1, 'Page 3'),
(5, 3, 'Page 4'),
(6, 1, 'Page 5'),
(7, 4, 'Page 6'),
(8, 7, 'Page 7'),
(9, 5, 'Page 8');

I used to php classes to represent the tree. One to represent a node of the tree and one for the tree itself:

This is for the node:

//a node of a tree that is not binary, each nodes has multiple subnodes
class Node
public $id;
public $id_parent;
public $childnodes;
public $title;

public function __construct($id,$id_parent,$title)
//in the test script I use mysql_fetch_object which populates the members and then //calls the constuctor with all
//parameters as null
//the following checks are here to make sure no members are accidentally overriden

$this->id = $id;

$this->id_parent = $id_parent;

$this->title = $title;

$this->childnodes = array();

//check if this node has subnodes or not
public function hasChildren()
if($this->childnodes === null)
return false;

return false;

if(count($this->childnodes) == 0)
return false;

return true;

This is the tree:

class Tree

private $root;

//construct a tree with only one root node public function __construct()
$this->root = new Node(0,0);

//recursively traverse the tree looking for the appropiate parent id
//the node to be inserted($node) must have a parent id equal to one of the ids in the nodes of the tree
//if such an id is found in a node the node is included as a subnode of that node
private function addNodeRecursive(&$nextnode,$node)
if($nextnode == null)
return false;

if($nextnode->id == $node->id_parent)
return true;
foreach ($nextnode->childnodes as $childnode)
return false;
return false;

//add a node to the tree
//check if it is a valid node start at the root and recursively traverse the tree looking for the appropiate parent id
public function addNode($node)
if(!($node instanceof Node))

$nextnode = $this->root;


//print the tree in sitemap style
public function printSiteMap()
foreach($this->root->childnodes as $childnode)

//print the tree recursively
//first print the current node's value and then print the cycle through it's subnodes
public function printTree(&$nextnode,$level)

foreach($nextnode->childnodes as $childnode)

//add the appropiate number of before each node value so as to obtain a nicely formatted sitemap
//each node value is indented with respect to the node's level
private function printNodeAccordingToLevel($node,$level)
for($i=0;$i<$level;$i++) echo " "; echo $node->title."(".$node->id.")";

echo "


And this is a test just to make sure everything works:

$tree = new Tree();
if(!($conn = mysql_connect("localhost","root","")))
echo "Could not connect";
echo "No such database";
if($result = mysql_query("SELECT id,id_parent,title FROM sitepages"))
while ($page = mysql_fetch_object($result,'Node'))