#1 Module bridging the essential guide

zomgwtfbbq
127.0.0.1
From: from the internet!
Registered: 2010-08-14
Posts: 87
Website

Module bridging the essential guide

Bridging:
First of all let's start at the beginning.. in order to let modules communicate with each other you will need to understand how they work.
Most modules in THC_HS have the ability to run as a background task, this is interesting as you will be able to run several tasks next to each other, modules like these can be used
for bridging.
Bridging in this case is simply the communication between two modules, the most essential of all the modules is definitely THC_SS which can poll targets for results each x seconds, although you can
definitely write your own modules that can communicate with other modules too.

Tasks:
Tasks are not 100% essential but they do allow some useability that other modules without it just can't offer.
When a task runs it's inserted into $_PATHS['data_root']/running.txt, here's an example of the content:
thc_sb|1313672136|1313672187|1
thc_sb|1313672287|0|0

These are two separate tasks, the first is a completed task, the last is a running task.

Let's break it down:
thc_sb|1313672136|1313672187|1
thc_sb: the module that is running
1313672136: timestamp when the task started
1313672187: timestamp when the task completed
1: the task is completed

Now that we know this let's code something simple, we'll bridge THC_SB with THC_SS in order to mail us the results when the task has completed.
Let's setup a plan first:
1- find a way to send the request to the module
2- monitor the task
3- get results when done
4- mail them

For the communication we only need to know what the form sends to where and how, that is easy, when you look at the form this is the structure:

<form method="post" class="spacing" action="http://127.0.0.1/thc_hacksuite/thc_sb/screen.php" target="screen">
<table border=0 width="500">
<tr><td>year range</td><td>

<select multiple name="aYear[ ]">
<optgroup label="router manufacture year ">router manufacture year</optgroup>
<option value="2005">2005</option>
<option value="2006" selected>2006</option>
<option value="2007" selected>2007</option>
<option value="2008" selected>2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select></td></tr>
<tr><td>bssid</td><td><input type="text" name="sInput" value="f8a3d0">

</select></td></tr>
<tr><td colspan=2><input type="submit" name="submit" value="Bruteforce"> <input type="submit" name="submit" value="Dump File"></td></tr>
</table>
</form>

That's easy enough to send using sockets or curl, we'll use the latter method:

<?php
$aYear = array("2007","2008","2009","2010","2011");
$ch = curl_init();
// your url could be different, just check the source
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1/thc_hacksuite/thc_sb/screen.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "aYear[]=2007&aYear[]=2008&aYear[]=2009&aYear[]=2010&aYear[]=2011&sInput=f8a3d0&submit=Bruteforce");
$sResult = curl_exec($ch);
curl_close($ch);
?>

I'm not going into the validation of the array...it's easy enough to rewrite so that you will be able to set the years yourself in here, this is merely a POC.
So what's next?
Well let's first see if it works correctly by making a small script that outputs the post variables.

<?php
var_dump($_POST);
?>

I've changed the Curl url to a test file..this is the output for the above post fields that were posted.
Note that I placed an echo for $sResult or else you would get a blank page.

array(3) {
  ["aYear"]=>
  array(5) {
    [0]=>
    string(4) "2007"
    [1]=>
    string(4) "2008"
    [2]=>
    string(4) "2009"
    [3]=>
    string(4) "2010"
    [4]=>
    string(4) "2011"
  }
  ["sInput"]=>
  string(6) "f8a3d0"
  ["submit"]=>
  string(10) "Bruteforce"
}

As you can see this works without a hitch, now we know that we can make this script running, all we need is a script that polls the task file, this is pretty easy as the cms allows
you to code it with a few lines of code:

<?php
if(!function_exists("RawToArray")){
    include($_PATHS['functions_root']."/raw_to_array.php");
}
$sModuleToPoll = "thc_sb";
$aTask = array();
// the task file is predefined in the paths variable
if(@filesize($_PATHS['task_file'])>0){
    if(false!==($aFileData = RawToArray($_PATHS['task_file']))){
        // the last entry in the task file should be the task we're after
        $iItem = count($aFileData)-1;
        if($aFileData[$iItem][0]!=$sModuleToPoll){
            die("Expecting last entry to be a task for ".$sModuleToPoll);
        }
        $aTask = $aFileData[$iItem];
    }
    else{
        die("No tasks are running");
    }
}
else{
    die("Empty task file");
}
?>

If all went well we should now have an array that contains the properties for the task we just started through the curl request.

Well that's basically all we need to get our job done... the rest is about creating a callback in THC_SS, which I will do later...stay tuned.


I'm a motherfucker..but still cute! smile

#2 Module bridging the essential guide

thisislife
New member
Registered: 2011-09-24
Posts: 5

Re: Module bridging the essential guide

:bump: No updates yet?

#3 Module bridging the essential guide

zomgwtfbbq
127.0.0.1
From: from the internet!
Registered: 2010-08-14
Posts: 87
Website

Re: Module bridging the essential guide

Too busy but I'm sure you can stitch the missing part of this tutorial with the tutorial in current form, not sure when I'll finish it.


I'm a motherfucker..but still cute! smile

18-08-2011 02:41:28
New project uploaded! Check it out
16-04-2011 13:04:57
THC_HS 0.2 branch is now available, you can check out the update list here or download it from here.
24-03-2011 07:48:43
New video uploaded! Check it out
24-03-2011 07:43:09
New project uploaded! Check it out
19-03-2011 13:15:29
New video uploaded! Check it out
19-03-2011 13:10:08
New project uploaded! Check it out
05-03-2011 15:06:10
New video uploaded! Check it out
05-03-2011 13:26:50
New project uploaded! Check it out
23-02-2011 05:24:57
New video uploaded! Check it out
17-02-2011 09:46:24
New project uploaded! Check it out
09-01-2011 18:27:51
New project uploaded! Check it out
01-01-2011 14:22:22
first of all I wish everyone a happy new year, let's make the best of it. I've started the new year with an update on the suite, it's current version is 0.1.0 and all known issues have been solved. :) also rewrote the rss feed generator for the forum from scratch, added the education section and some other minor stuff not worth mentioning...ok you got me I forgot what they were, blame yesterday's Black label.. :p Cheers and happy hacking. :)
18-12-2010 17:55:07
finally the site is up, although there are some minor issues(that you probably won't even notice), the site is fully functional.. feel free to give us some feedback in the forum. :)
18-08-2010 22:02:13
template almost completed, now for the coding :D
17-08-2010 18:15:33
first mockup of the site
26-07-2010 21:15:33
registered hacksuite.com